phase 01: type change for command files

This commit is contained in:
Adrian
2026-02-20 13:16:02 -05:00
parent d83c1a29c3
commit da94da90db
6 changed files with 115 additions and 17 deletions

View File

@@ -16,8 +16,8 @@ describe("convertClaudeToOpenCode", () => {
permissions: "from-commands",
})
expect(bundle.config.command?.["workflows:review"]).toBeDefined()
expect(bundle.config.command?.["plan_review"]).toBeDefined()
expect(bundle.commandFiles.find((f) => f.name === "workflows:review")).toBeDefined()
expect(bundle.commandFiles.find((f) => f.name === "plan_review")).toBeDefined()
const permission = bundle.config.permission as Record<string, string | Record<string, string>>
expect(Object.keys(permission).sort()).toEqual([
@@ -71,8 +71,10 @@ describe("convertClaudeToOpenCode", () => {
expect(parsed.data.model).toBe("anthropic/claude-sonnet-4-20250514")
expect(parsed.data.temperature).toBe(0.1)
const modelCommand = bundle.config.command?.["workflows:work"]
expect(modelCommand?.model).toBe("openai/gpt-4o")
const modelCommand = bundle.commandFiles.find((f) => f.name === "workflows:work")
expect(modelCommand).toBeDefined()
const commandParsed = parseFrontmatter(modelCommand!.content)
expect(commandParsed.data.model).toBe("openai/gpt-4o")
})
test("resolves bare Claude model aliases to full IDs", () => {
@@ -208,10 +210,10 @@ describe("convertClaudeToOpenCode", () => {
})
// deploy-docs has disable-model-invocation: true, should be excluded
expect(bundle.config.command?.["deploy-docs"]).toBeUndefined()
expect(bundle.commandFiles.find((f) => f.name === "deploy-docs")).toBeUndefined()
// Normal commands should still be present
expect(bundle.config.command?.["workflows:review"]).toBeDefined()
expect(bundle.commandFiles.find((f) => f.name === "workflows:review")).toBeDefined()
})
test("rewrites .claude/ paths to .opencode/ in command bodies", () => {
@@ -240,10 +242,11 @@ Run \`/compound-engineering-setup\` to create a settings file.`,
permissions: "none",
})
const template = bundle.config.command?.["review"]?.template ?? ""
const commandFile = bundle.commandFiles.find((f) => f.name === "review")
expect(commandFile).toBeDefined()
// Tool-agnostic path in project root — no rewriting needed
expect(template).toContain("compound-engineering.local.md")
expect(commandFile!.content).toContain("compound-engineering.local.md")
})
test("rewrites .claude/ paths in agent bodies", () => {

View File

@@ -21,6 +21,7 @@ describe("writeOpenCodeBundle", () => {
config: { $schema: "https://opencode.ai/config.json" },
agents: [{ name: "agent-one", content: "Agent content" }],
plugins: [{ name: "hook.ts", content: "export {}" }],
commandFiles: [],
skillDirs: [
{
name: "skill-one",
@@ -44,6 +45,7 @@ describe("writeOpenCodeBundle", () => {
config: { $schema: "https://opencode.ai/config.json" },
agents: [{ name: "agent-one", content: "Agent content" }],
plugins: [],
commandFiles: [],
skillDirs: [
{
name: "skill-one",
@@ -68,6 +70,7 @@ describe("writeOpenCodeBundle", () => {
config: { $schema: "https://opencode.ai/config.json" },
agents: [{ name: "agent-one", content: "Agent content" }],
plugins: [],
commandFiles: [],
skillDirs: [
{
name: "skill-one",
@@ -99,6 +102,7 @@ describe("writeOpenCodeBundle", () => {
config: { $schema: "https://opencode.ai/config.json", new: "config" },
agents: [],
plugins: [],
commandFiles: [],
skillDirs: [],
}