From 953268087975275af5a20d112e306363435b8e7e Mon Sep 17 00:00:00 2001 From: Rouven Hi! <3582050+RouHim@users.noreply.github.com> Date: Sat, 24 Jan 2026 07:55:31 +0100 Subject: [PATCH] fix(slashcommand): include built-in commands (like start-work) in discovery (#1031) This ensures that commands defined in src/features/builtin-commands/commands.ts (like /start-work, /refactor, /init-deep) are visible to the slashcommand tool and the agent. Previously, only markdown-based commands were discovered. --- src/tools/slashcommand/tools.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/tools/slashcommand/tools.ts b/src/tools/slashcommand/tools.ts index 3ee2c8ae9..6719fa6ac 100644 --- a/src/tools/slashcommand/tools.ts +++ b/src/tools/slashcommand/tools.ts @@ -6,6 +6,7 @@ import type { CommandFrontmatter } from "../../features/claude-code-command-load import { isMarkdownFile } from "../../shared/file-utils" import { getClaudeConfigDir } from "../../shared" import { discoverAllSkills, type LoadedSkill } from "../../features/opencode-skill-loader" +import { loadBuiltinCommands } from "../../features/builtin-commands" import type { CommandScope, CommandMetadata, CommandInfo, SlashcommandToolOptions } from "./types" function discoverCommandsFromDir(commandsDir: string, scope: CommandScope): CommandInfo[] { @@ -63,7 +64,22 @@ export function discoverCommandsSync(): CommandInfo[] { const projectCommands = discoverCommandsFromDir(projectCommandsDir, "project") const opencodeProjectCommands = discoverCommandsFromDir(opencodeProjectDir, "opencode-project") - return [...opencodeProjectCommands, ...projectCommands, ...opencodeGlobalCommands, ...userCommands] + const builtinCommandsMap = loadBuiltinCommands() + const builtinCommands: CommandInfo[] = Object.values(builtinCommandsMap).map(cmd => ({ + name: cmd.name, + metadata: { + name: cmd.name, + description: cmd.description || "", + argumentHint: cmd.argumentHint, + model: cmd.model, + agent: cmd.agent, + subtask: cmd.subtask + }, + content: cmd.template, + scope: "builtin" + })) + + return [...builtinCommands, ...opencodeProjectCommands, ...projectCommands, ...opencodeGlobalCommands, ...userCommands] } function skillToCommandInfo(skill: LoadedSkill): CommandInfo { @@ -234,7 +250,7 @@ export function createSlashcommandTool(options: SlashcommandToolOptions = {}): T if (partialMatches.length > 0) { const matchList = partialMatches.map((cmd) => `/${cmd.name}`).join(", ") return ( - `No exact match for "/${cmdName}". Did you mean: ${matchList}?\n\n` + + `No exact match for "/${cmdName}\". Did you mean: ${matchList}?\n\n` + formatCommandList(allItems) ) }