2025-12-28 17:30:27 +09:00
|
|
|
import type { CommandDefinition } from "../claude-code-command-loader"
|
|
|
|
|
import type { BuiltinCommandName, BuiltinCommands } from "./types"
|
|
|
|
|
import { INIT_DEEP_TEMPLATE } from "./templates/init-deep"
|
2025-12-30 17:41:03 +09:00
|
|
|
import { RALPH_LOOP_TEMPLATE, CANCEL_RALPH_TEMPLATE } from "./templates/ralph-loop"
|
2025-12-28 17:30:27 +09:00
|
|
|
|
|
|
|
|
const BUILTIN_COMMAND_DEFINITIONS: Record<BuiltinCommandName, Omit<CommandDefinition, "name">> = {
|
|
|
|
|
"init-deep": {
|
|
|
|
|
description: "(builtin) Initialize hierarchical AGENTS.md knowledge base",
|
|
|
|
|
template: `<command-instruction>
|
|
|
|
|
${INIT_DEEP_TEMPLATE}
|
|
|
|
|
</command-instruction>
|
|
|
|
|
|
|
|
|
|
<user-request>
|
|
|
|
|
$ARGUMENTS
|
|
|
|
|
</user-request>`,
|
|
|
|
|
argumentHint: "[--create-new] [--max-depth=N]",
|
|
|
|
|
},
|
2025-12-30 17:41:03 +09:00
|
|
|
"ralph-loop": {
|
|
|
|
|
description: "(builtin) Start self-referential development loop until completion",
|
|
|
|
|
template: `<command-instruction>
|
|
|
|
|
${RALPH_LOOP_TEMPLATE}
|
|
|
|
|
</command-instruction>
|
|
|
|
|
|
|
|
|
|
<user-task>
|
|
|
|
|
$ARGUMENTS
|
|
|
|
|
</user-task>`,
|
|
|
|
|
argumentHint: '"task description" [--completion-promise=TEXT] [--max-iterations=N]',
|
|
|
|
|
},
|
|
|
|
|
"cancel-ralph": {
|
|
|
|
|
description: "(builtin) Cancel active Ralph Loop",
|
|
|
|
|
template: `<command-instruction>
|
|
|
|
|
${CANCEL_RALPH_TEMPLATE}
|
|
|
|
|
</command-instruction>`,
|
|
|
|
|
},
|
2025-12-28 17:30:27 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function loadBuiltinCommands(
|
|
|
|
|
disabledCommands?: BuiltinCommandName[]
|
|
|
|
|
): BuiltinCommands {
|
|
|
|
|
const disabled = new Set(disabledCommands ?? [])
|
|
|
|
|
const commands: BuiltinCommands = {}
|
|
|
|
|
|
|
|
|
|
for (const [name, definition] of Object.entries(BUILTIN_COMMAND_DEFINITIONS)) {
|
|
|
|
|
if (!disabled.has(name as BuiltinCommandName)) {
|
|
|
|
|
commands[name] = {
|
|
|
|
|
name,
|
|
|
|
|
...definition,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return commands
|
|
|
|
|
}
|