From 7f742723b5d75501acbbbda452d398e7b5bf6ecb Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 26 Mar 2026 12:29:42 +0900 Subject: [PATCH] fix(slashcommand): use slash separator for nested commands Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/tools/slashcommand/command-discovery.test.ts | 2 +- src/tools/slashcommand/command-discovery.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tools/slashcommand/command-discovery.test.ts b/src/tools/slashcommand/command-discovery.test.ts index 1bf6ce016..b0b3c2b5a 100644 --- a/src/tools/slashcommand/command-discovery.test.ts +++ b/src/tools/slashcommand/command-discovery.test.ts @@ -250,7 +250,7 @@ Use nested command. ) const commands = discoverCommandsSync(projectDir) - const nestedCommand = commands.find((command) => command.name === "refactor:code") + const nestedCommand = commands.find((command) => command.name === "refactor/code") expect(nestedCommand?.content).toContain("Use nested command.") expect(nestedCommand?.scope).toBe("opencode-project") diff --git a/src/tools/slashcommand/command-discovery.ts b/src/tools/slashcommand/command-discovery.ts index 574c0cb65..dc8922381 100644 --- a/src/tools/slashcommand/command-discovery.ts +++ b/src/tools/slashcommand/command-discovery.ts @@ -18,6 +18,8 @@ export interface CommandDiscoveryOptions { enabledPluginsOverride?: Record } +const NESTED_COMMAND_SEPARATOR = "/" + function discoverCommandsFromDir( commandsDir: string, scope: CommandScope, @@ -31,7 +33,9 @@ function discoverCommandsFromDir( for (const entry of entries) { if (entry.isDirectory()) { if (entry.name.startsWith(".")) continue - const nestedPrefix = prefix ? `${prefix}:${entry.name}` : entry.name + const nestedPrefix = prefix + ? `${prefix}${NESTED_COMMAND_SEPARATOR}${entry.name}` + : entry.name commands.push( ...discoverCommandsFromDir(join(commandsDir, entry.name), scope, nestedPrefix), ) @@ -42,7 +46,9 @@ function discoverCommandsFromDir( const commandPath = join(commandsDir, entry.name) const baseCommandName = basename(entry.name, ".md") - const commandName = prefix ? `${prefix}:${baseCommandName}` : baseCommandName + const commandName = prefix + ? `${prefix}${NESTED_COMMAND_SEPARATOR}${baseCommandName}` + : baseCommandName try { const content = readFileSync(commandPath, "utf-8")