fix(slashcommand): use slash separator for nested commands

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 12:29:42 +09:00
parent b20a34bfa7
commit 7f742723b5
2 changed files with 9 additions and 3 deletions

View File

@@ -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")

View File

@@ -18,6 +18,8 @@ export interface CommandDiscoveryOptions {
enabledPluginsOverride?: Record<string, boolean>
}
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")