Replaces legacy adapter ids (codex_local / claude_local / gemini_local / claude_compatible) across ~42 test files with pi-mono equivalents: - codex_local → openai-codex - claude_local → claude-pro - gemini_local → gemini-cli - claude_compatible → anthropic Hand-rewrites where fixture semantics changed: - connector-matching: TASK_TYPE_PREFERENCE ordering rebased (claude-pro first for code/content/management; google first for research) - connector-model-policy: getModels(provider) from pi-ai instead of the deleted adapter.module.models array - session-management + edge-case-session: adapter exemption removed; rotation now uniform under pi-mono - ipc-core-admin-handlers: CSV compat model replaced with pi-ai anthropic - connectors.spec: lookup by openai-codex id (catalog now starts with claude-pro) - onboarding-model-pool: listProviderModels(provider) helper; label text changed to "ChatGPT Plus/Pro (Codex)" - database integration: added vault insecure-fallback env + electron mock - command-paths: uses new @main/connector-helpers normalizeCommandValue - pi-mono-migrations: added `as string` casts for 3 negative-existence assertions verifying legacy ids were removed Drops: - pnpm-workspace.yaml packages: [] (was "packages/*"; directory empty) - obsolete CONNECTOR_STRENGTHS import; .module.models probing Verification: - pnpm typecheck → 0 errors - pnpm lint → 0 errors / 0 warnings - pnpm build:verify → 0 errors / 0 warnings - pnpm test:unit → 508/508 pass - pnpm test:integration → 96/96 pass - All 6 adapter hard gates pass (NOT FOUND / 0 matches / empty) - pi-ai / pi-agent-core / pi-coding-agent all resolved @0.67.6
171 lines
5.0 KiB
TypeScript
171 lines
5.0 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import {
|
|
TOKEN_BUDGETS,
|
|
resolveTokenBudget,
|
|
} from "@main/skill-types";
|
|
import type {
|
|
SkillSourceType,
|
|
TrustLevel,
|
|
FileInventoryEntry,
|
|
SkillRecord,
|
|
SkillImportResult,
|
|
RuntimeSkillEntry,
|
|
ManagedSkillRef,
|
|
SkillAssignment,
|
|
SkillUpdateStatus,
|
|
} from "@main/skill-types";
|
|
|
|
describe("skill-types", () => {
|
|
describe("TOKEN_BUDGETS", () => {
|
|
it("has entries for all supported connector types", () => {
|
|
expect(TOKEN_BUDGETS).toHaveProperty("claude-pro");
|
|
expect(TOKEN_BUDGETS).toHaveProperty("anthropic");
|
|
expect(TOKEN_BUDGETS).toHaveProperty("gemini-cli");
|
|
expect(TOKEN_BUDGETS).toHaveProperty("google");
|
|
});
|
|
|
|
it("has numeric token caps for each connector", () => {
|
|
expect(TOKEN_BUDGETS["claude-pro"]).toBe(50000);
|
|
expect(TOKEN_BUDGETS["anthropic"]).toBe(50000);
|
|
expect(TOKEN_BUDGETS["gemini-cli"]).toBe(50000);
|
|
expect(TOKEN_BUDGETS["google"]).toBe(50000);
|
|
});
|
|
});
|
|
|
|
describe("resolveTokenBudget", () => {
|
|
it("returns exact match for known connector types", () => {
|
|
expect(resolveTokenBudget("claude-pro")).toBe(50000);
|
|
expect(resolveTokenBudget("anthropic")).toBe(50000);
|
|
expect(resolveTokenBudget("gemini-cli")).toBe(50000);
|
|
});
|
|
|
|
it("resolves anthropic-family connectors to the larger injection budget", () => {
|
|
expect(resolveTokenBudget("amazon-bedrock")).toBe(50000);
|
|
expect(resolveTokenBudget("google-vertex")).toBe(50000);
|
|
});
|
|
|
|
it("returns 30000 default for unknown connector types", () => {
|
|
expect(resolveTokenBudget("unknown_connector")).toBe(30000);
|
|
});
|
|
});
|
|
|
|
describe("type shape checks", () => {
|
|
it("SkillSourceType accepts all five source kinds", () => {
|
|
const sources: SkillSourceType[] = [
|
|
"github",
|
|
"local_path",
|
|
"url",
|
|
"skills_sh",
|
|
"managed",
|
|
];
|
|
expect(sources).toHaveLength(5);
|
|
});
|
|
|
|
it("TrustLevel accepts all three levels", () => {
|
|
const levels: TrustLevel[] = [
|
|
"markdown_only",
|
|
"assets",
|
|
"scripts_executables",
|
|
];
|
|
expect(levels).toHaveLength(3);
|
|
});
|
|
|
|
it("FileInventoryEntry has path and kind", () => {
|
|
const entry: FileInventoryEntry = { path: "SKILL.md", kind: "skill" };
|
|
expect(entry.path).toBe("SKILL.md");
|
|
expect(entry.kind).toBe("skill");
|
|
});
|
|
|
|
it("FileInventoryEntry kind accepts all six values", () => {
|
|
const kinds: FileInventoryEntry["kind"][] = [
|
|
"skill",
|
|
"reference",
|
|
"script",
|
|
"asset",
|
|
"markdown",
|
|
"other",
|
|
];
|
|
expect(kinds).toHaveLength(6);
|
|
});
|
|
|
|
it("SkillRecord has all expected properties", () => {
|
|
const record: SkillRecord = {
|
|
id: "test-id",
|
|
companyId: "company-1",
|
|
key: "owner/repo/slug",
|
|
slug: "slug",
|
|
name: "Test Skill",
|
|
description: null,
|
|
markdown: "# Test",
|
|
sourceType: "github",
|
|
sourceLocator: "https://github.com/owner/repo",
|
|
sourceRef: "abc123",
|
|
trustLevel: "markdown_only",
|
|
compatibility: "compatible",
|
|
fileInventory: [],
|
|
metadata: null,
|
|
createdAt: "2025-01-01T00:00:00Z",
|
|
updatedAt: "2025-01-01T00:00:00Z",
|
|
};
|
|
expect(record.id).toBe("test-id");
|
|
expect(record.companyId).toBe("company-1");
|
|
});
|
|
|
|
it("SkillImportResult has skillId, key, name, isUpdate", () => {
|
|
const result: SkillImportResult = {
|
|
skillId: "id-1",
|
|
key: "owner/repo/slug",
|
|
name: "Test",
|
|
isUpdate: false,
|
|
};
|
|
expect(result.isUpdate).toBe(false);
|
|
});
|
|
|
|
it("RuntimeSkillEntry has runtimeName, sourcePath, name, tokenEstimate and semantics", () => {
|
|
const entry: RuntimeSkillEntry = {
|
|
runtimeName: "claude",
|
|
sourcePath: "/path/to/skill",
|
|
name: "test-skill",
|
|
tokenEstimate: 1000,
|
|
allowedTools: ["read", "write"],
|
|
hooks: ["on_task_start"],
|
|
contextMode: "inline",
|
|
isAgent: false,
|
|
effort: "medium",
|
|
whenToUse: "when writing code",
|
|
};
|
|
expect(entry.tokenEstimate).toBe(1000);
|
|
expect(entry.allowedTools).toEqual(["read", "write"]);
|
|
expect(entry.contextMode).toBe("inline");
|
|
});
|
|
|
|
it("ManagedSkillRef has runtimeName and sourcePath only", () => {
|
|
const ref: ManagedSkillRef = {
|
|
runtimeName: "claude",
|
|
sourcePath: "/path/to/skill",
|
|
};
|
|
expect(ref.runtimeName).toBe("claude");
|
|
expect(ref.sourcePath).toBe("/path/to/skill");
|
|
});
|
|
|
|
it("SkillAssignment has agentId and skillId", () => {
|
|
const assignment: SkillAssignment = {
|
|
agentId: "agent-1",
|
|
skillId: "skill-1",
|
|
};
|
|
expect(assignment.agentId).toBe("agent-1");
|
|
});
|
|
|
|
it("SkillUpdateStatus has all expected fields", () => {
|
|
const status: SkillUpdateStatus = {
|
|
skillId: "skill-1",
|
|
key: "owner/repo/slug",
|
|
currentRef: "abc",
|
|
latestRef: "def",
|
|
hasUpdate: true,
|
|
};
|
|
expect(status.hasUpdate).toBe(true);
|
|
});
|
|
});
|
|
});
|