fix(slashcommand): deduplicate opencode command 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:36:59 +09:00
parent 9fde370838
commit 94b4a4f850
2 changed files with 49 additions and 2 deletions
@@ -204,4 +204,35 @@ Use ancestor command.
expect(ancestorCommand?.scope).toBe("opencode-project")
expect(ancestorCommand?.content).toContain("Use ancestor command.")
})
it("deduplicates same-named opencode commands while keeping the higher-priority alias", () => {
const commandsRoot = join(projectDir, ".opencode")
const singularDir = join(commandsRoot, "command")
const pluralDir = join(commandsRoot, "commands")
mkdirSync(singularDir, { recursive: true })
mkdirSync(pluralDir, { recursive: true })
writeFileSync(
join(singularDir, "duplicate.md"),
`---
description: Singular duplicate command
---
Use singular command.
`,
)
writeFileSync(
join(pluralDir, "duplicate.md"),
`---
description: Plural duplicate command
---
Use plural command.
`,
)
const commands = discoverCommandsSync(projectDir)
const duplicates = commands.filter((command) => command.name === "duplicate")
expect(duplicates).toHaveLength(1)
expect(duplicates[0]?.content).toContain("Use plural command.")
})
})