feat(commands): add /handoff builtin command with programmatic context synthesis

Port handoff concept from ampcode as a builtin command that extracts
detailed context summary from current session for seamless continuation
in a new session. Enhanced with programmatic context gathering:

- Add HANDOFF_TEMPLATE with phased extraction (gather programmatic
  context via session_read/todoread/git, extract context, format, instruct)
- Gather concrete data: session history, todo state, git diff/status
- Include compaction-style sections: USER REQUESTS (AS-IS) verbatim,
  EXPLICIT CONSTRAINTS verbatim, plus all original handoff sections
- Register handoff in BuiltinCommandName type and command definitions
- Include session context variables (SESSION_ID, TIMESTAMP, ARGUMENTS)
- Add 14 tests covering registration, template content, programmatic
  gathering, compaction-style sections, and emoji-free constraint
This commit is contained in:
justsisyphus
2026-01-27 17:40:41 +09:00
committed by YeonGyu-Kim
parent 0743855b40
commit a5489718f9
4 changed files with 333 additions and 1 deletions
+17
View File
@@ -5,6 +5,7 @@ import { RALPH_LOOP_TEMPLATE, CANCEL_RALPH_TEMPLATE } from "./templates/ralph-lo
import { STOP_CONTINUATION_TEMPLATE } from "./templates/stop-continuation"
import { REFACTOR_TEMPLATE } from "./templates/refactor"
import { START_WORK_TEMPLATE } from "./templates/start-work"
import { HANDOFF_TEMPLATE } from "./templates/handoff"
const BUILTIN_COMMAND_DEFINITIONS: Record<BuiltinCommandName, Omit<CommandDefinition, "name">> = {
"init-deep": {
@@ -77,6 +78,22 @@ $ARGUMENTS
${STOP_CONTINUATION_TEMPLATE}
</command-instruction>`,
},
handoff: {
description: "(builtin) Create a detailed context summary for continuing work in a new session",
template: `<command-instruction>
${HANDOFF_TEMPLATE}
</command-instruction>
<session-context>
Session ID: $SESSION_ID
Timestamp: $TIMESTAMP
</session-context>
<user-request>
$ARGUMENTS
</user-request>`,
argumentHint: "[goal]",
},
}
export function loadBuiltinCommands(