fix(shared): support opencode directory aliases

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-03-26 11:22:00 +09:00
parent da3e80464d
commit 6d688ac0ae
2 changed files with 12 additions and 5 deletions

View File

@@ -26,8 +26,10 @@ describe("opencode-command-dirs", () => {
const dirs = getOpenCodeSkillDirs({ binary: "opencode" })
expect(dirs).toContain("/home/user/.config/opencode/profiles/opus/skills")
expect(dirs).toContain("/home/user/.config/opencode/profiles/opus/skill")
expect(dirs).toContain("/home/user/.config/opencode/skills")
expect(dirs).toHaveLength(2)
expect(dirs).toContain("/home/user/.config/opencode/skill")
expect(dirs).toHaveLength(4)
})
})
})
@@ -41,7 +43,8 @@ describe("opencode-command-dirs", () => {
const dirs = getOpenCodeSkillDirs({ binary: "opencode" })
expect(dirs).toContain("/home/user/.config/opencode/skills")
expect(dirs).toHaveLength(1)
expect(dirs).toContain("/home/user/.config/opencode/skill")
expect(dirs).toHaveLength(2)
})
})
})
@@ -56,9 +59,11 @@ describe("opencode-command-dirs", () => {
const { getOpenCodeCommandDirs } = await import("./opencode-command-dirs")
const dirs = getOpenCodeCommandDirs({ binary: "opencode" })
expect(dirs).toContain("/home/user/.config/opencode/profiles/opus/commands")
expect(dirs).toContain("/home/user/.config/opencode/profiles/opus/command")
expect(dirs).toContain("/home/user/.config/opencode/commands")
expect(dirs).toContain("/home/user/.config/opencode/command")
expect(dirs).toHaveLength(2)
expect(dirs).toHaveLength(4)
})
})
})

View File

@@ -17,8 +17,9 @@ export function getOpenCodeCommandDirs(options: OpenCodeConfigDirOptions): strin
return Array.from(
new Set([
join(configDir, "commands"),
join(configDir, "command"),
...(parentConfigDir ? [join(parentConfigDir, "command")] : []),
...(parentConfigDir ? [join(parentConfigDir, "commands"), join(parentConfigDir, "command")] : []),
])
)
}
@@ -30,7 +31,8 @@ export function getOpenCodeSkillDirs(options: OpenCodeConfigDirOptions): string[
return Array.from(
new Set([
join(configDir, "skills"),
...(parentConfigDir ? [join(parentConfigDir, "skills")] : []),
join(configDir, "skill"),
...(parentConfigDir ? [join(parentConfigDir, "skills"), join(parentConfigDir, "skill")] : []),
])
)
}