11import type { CliAgentConfig } from './cli-agent-types'
2+ import { CLI_AGENT_MODES } from './cli-agent-types'
23
34const TMUX_SESSION_DOCS = `## Session Logs (Paper Trail)
45
@@ -71,33 +72,42 @@ The review should focus on these key areas:
7172 - Missing or incomplete type definitions`
7273
7374export function getSpawnerPrompt ( config : CliAgentConfig ) : string {
74- const base = `Expert at testing ${ config . cliName } CLI functionality using tmux, or performing code reviews via ${ config . cliName } .
75+ const defaultMode = config . defaultMode ?? 'work'
76+ const modeDescriptions = {
77+ work : `Use ${ config . cliName } to implement features, fix bugs, refactor code, or complete other coding tasks.` ,
78+ review : `Uses ${ config . cliName } CLI to perform code reviews on specified files or directories.` ,
79+ }
80+ const modeLines = CLI_AGENT_MODES . map ( mode => {
81+ const isDefault = mode === defaultMode
82+ return `- \`${ mode } \`${ isDefault ? ' (default)' : '' } : ${ modeDescriptions [ mode ] } `
83+ } ) . join ( '\n' )
84+
85+ const base = `Expert at using ${ config . cliName } CLI via tmux for implementation work or code reviews.
7586
7687**Modes:**
77- - \`test\` (default): Spawns tmux sessions, sends input to ${ config . cliName } CLI, captures terminal output, and validates behavior.
78- - \`review\`: Uses ${ config . cliName } CLI to perform code reviews on specified files or directories.
88+ ${ modeLines }
7989
8090**Paper trail:** Session logs are saved to \`debug/tmux-sessions/{session}/\`. Use \`read_files\` to view captures.
8191
8292**Your responsibilities as the parent agent:**
83931. If \`scriptIssues\` is not empty, fix the scripts in \`scripts/tmux/\` based on the suggested fixes
84942. Use \`read_files\` on the capture paths to see what the CLI displayed
85- 3. Re-run the test after fixing any script issues`
95+ 3. Re-run the agent after fixing any script issues`
8696
8797 return config . spawnerPromptExtras ? `${ base } \n\n${ config . spawnerPromptExtras } ` : base
8898}
8999
90100export function getSystemPrompt ( config : CliAgentConfig ) : string {
91101 const cliSpecificSection = config . cliSpecificDocs ? `\n${ config . cliSpecificDocs } \n` : '\n'
92102
93- return `You are an expert at testing ${ config . cliName } CLI using tmux. You have access to helper scripts that handle the complexities of tmux communication with TUI apps.
103+ return `You are an expert at using ${ config . cliName } CLI via tmux for implementation work and code reviews . You have access to helper scripts that handle the complexities of tmux communication with TUI apps.
94104
95105## ${ config . cliName } Startup
96106
97- For testing ${ config . cliName } , use the \`--command\` flag with permission bypass:
107+ To start ${ config . cliName } , use the \`--command\` flag with permission bypass:
98108
99109\`\`\`bash
100- # Start ${ config . cliName } CLI (with permission bypass for testing )
110+ # Start ${ config . cliName } CLI (with permission bypass)
101111SESSION=$(./scripts/tmux/tmux-cli.sh start --command "${ config . startCommand } ")
102112
103113# Or with specific options
@@ -108,12 +118,12 @@ SESSION=$(./scripts/tmux/tmux-cli.sh start --command "${config.startCommand} --h
108118${ cliSpecificSection }
109119## Helper Scripts
110120
111- Use these scripts in \`scripts/tmux/\` for reliable CLI testing :
121+ Use these scripts in \`scripts/tmux/\` for reliable CLI interaction :
112122
113123### Unified Script (Recommended)
114124
115125\`\`\`bash
116- # Start a ${ config . cliName } test session (with permission bypass)
126+ # Start a ${ config . cliName } session (with permission bypass)
117127SESSION=$(./scripts/tmux/tmux-cli.sh start --command "${ config . startCommand } ")
118128
119129# Send input to the CLI
@@ -162,7 +172,8 @@ ${TMUX_DEBUG_TIPS}`
162172}
163173
164174export function getDefaultReviewModeInstructions ( config : CliAgentConfig ) : string {
165- return `## Review Mode Instructions
175+ const isDefault = config . defaultMode === 'review'
176+ return `## Review Mode Instructions${ isDefault ? ' (Default)' : '' }
166177
167178In review mode, you send a detailed review prompt to ${ config . cliName } . The prompt MUST start with the word "review" and include specific areas of concern.
168179
@@ -216,60 +227,98 @@ ${REVIEW_CRITERIA}
216227 \`\`\``
217228}
218229
219- export function getInstructionsPrompt ( config : CliAgentConfig ) : string {
220- const reviewModeInstructions = config . reviewModeInstructions ?? getDefaultReviewModeInstructions ( config )
230+ export function getWorkModeInstructions ( config : CliAgentConfig ) : string {
231+ const isDefault = ( config . defaultMode ?? 'work' ) === 'work'
232+ return `## Work Mode Instructions${ isDefault ? ' (Default)' : '' }
221233
222- return `Instructions:
234+ Use ${ config . cliName } to complete implementation tasks like building features, fixing bugs, or refactoring code.
223235
224- Check the \`mode\` parameter to determine your operation:
225- - If \`mode\` is "review": follow **Review Mode** instructions
226- - Otherwise: follow **Test Mode** instructions (default)
236+ ### Workflow
227237
228- ---
238+ 1. **Start ${ config . cliName } ** with permission bypass:
239+ \`\`\`bash
240+ SESSION=$(./scripts/tmux/tmux-cli.sh start --command "${ config . startCommand } ")
241+ \`\`\`
229242
230- ## Test Mode Instructions
243+ 2. **Wait for CLI to initialize**, then capture:
244+ \`\`\`bash
245+ sleep 3
246+ ./scripts/tmux/tmux-cli.sh capture "$SESSION" --label "initial-state"
247+ \`\`\`
248+
249+ 3. **Send your task** (from the prompt you received) to the CLI:
250+ \`\`\`bash
251+ ./scripts/tmux/tmux-cli.sh send "$SESSION" "<the task from your prompt parameter>"
252+ \`\`\`
231253
232- 1. ** Use the helper scripts** in \`scripts/tmux/\` - they handle bracketed paste mode automatically
254+ Use the exact task description from the prompt the parent agent gave you.
233255
234- 2 . **Start a ${ config . cliName } test session ** with permission bypass :
256+ 4 . **Wait for completion and capture output ** (implementation tasks may take a while) :
235257 \`\`\`bash
236- SESSION=$( ./scripts/tmux/tmux-cli.sh start --command " ${ config . startCommand } ")
258+ ./scripts/tmux/tmux-cli.sh capture "$SESSION" --label "work-in-progress" --wait 30
237259 \`\`\`
238260
239- 3. **Verify the CLI started** by capturing initial output :
261+ If the work is still in progress, wait and capture again :
240262 \`\`\`bash
241- ./scripts/tmux/tmux-cli.sh capture "$SESSION"
263+ ./scripts/tmux/tmux-cli.sh capture "$SESSION" --label "work-continued" --wait 30
242264 \`\`\`
243265
244- 4 . **Send commands ** and capture responses :
266+ 5 . **Send follow-up prompts ** if needed to refine or continue the work :
245267 \`\`\`bash
246- ./scripts/tmux/tmux-cli.sh send "$SESSION" "your command here "
247- ./scripts/tmux/tmux-cli.sh capture "$SESSION" --wait 3
268+ ./scripts/tmux/tmux-cli.sh send "$SESSION" "<follow-up instructions> "
269+ ./scripts/tmux/tmux-cli.sh capture "$SESSION" --label "follow-up" -- wait 30
248270 \`\`\`
249271
250- 5 . **Always clean up ** when done :
272+ 6 . **Verify the changes ** by checking files or running commands :
251273 \`\`\`bash
252- ./scripts/tmux/tmux-cli.sh stop "$SESSION"
274+ ./scripts/tmux/tmux-cli.sh send "$SESSION" "run the tests to verify the changes"
275+ ./scripts/tmux/tmux-cli.sh capture "$SESSION" --label "verification" --wait 60
253276 \`\`\`
254277
255- 6 . **Use labels when capturing ** to create a clear paper trail :
278+ 7 . **Clean up ** when done :
256279 \`\`\`bash
257- ./scripts/tmux/tmux-cli.sh capture "$SESSION" --label "initial-state"
258- ./scripts/tmux/tmux-cli.sh capture "$SESSION" --label "after-help-command" --wait 2
280+ ./scripts/tmux/tmux-cli.sh stop "$SESSION"
259281 \`\`\`
260282
283+ ### Tips
284+
285+ - Break complex tasks into smaller prompts
286+ - Capture frequently to track progress
287+ - Use descriptive labels for captures
288+ - Check intermediate results before moving on`
289+ }
290+
291+ export function getInstructionsPrompt ( config : CliAgentConfig ) : string {
292+ const defaultMode = config . defaultMode ?? 'work'
293+ const workModeInstructions = config . workModeInstructions ?? getWorkModeInstructions ( config )
294+ const reviewModeInstructions = config . reviewModeInstructions ?? getDefaultReviewModeInstructions ( config )
295+
296+ const modeNames = { work : 'Work Mode' , review : 'Review Mode' }
297+ const nonDefaultModes = CLI_AGENT_MODES . filter ( m => m !== defaultMode )
298+ const modeChecks = nonDefaultModes . map ( m => `- If \`mode\` is "${ m } ": follow **${ modeNames [ m ] } ** instructions` ) . join ( '\n' )
299+
300+ return `Instructions:
301+
302+ Check the \`mode\` parameter to determine your operation:
303+ ${ modeChecks }
304+ - Otherwise: follow **${ modeNames [ defaultMode ] } ** instructions (default)
305+
306+ ---
307+
308+ ${ workModeInstructions }
309+
261310---
262311
263312${ reviewModeInstructions }
264313
265314---
266315
267- ## Output (Both Modes)
316+ ## Output (All Modes)
268317
269318**Report results using set_output** - You MUST call set_output with structured results:
270319- \`overallStatus\`: "success", "failure", or "partial"
271- - \`summary\`: Brief description of what was tested/reviewed
272- - \`testResults \`: Array of test outcomes (for test mode)
320+ - \`summary\`: Brief description of what was done
321+ - \`results \`: Array of task outcomes (for work mode)
273322- \`scriptIssues\`: Array of any problems with the helper scripts
274323- \`captures\`: Array of capture paths with labels
275324- \`reviewFindings\`: Array of code review findings (for review mode)
@@ -278,7 +327,7 @@ ${reviewModeInstructions}
278327- \`script\`: Which script failed
279328- \`issue\`: What went wrong
280329- \`errorOutput\`: The actual error message
281- - \`suggestedFix\`: How the parent agent should fix the script
330+ - \`suggestedFix\`: How to fix the script
282331
283332**Always include captures** in your output so the parent agent can see what you saw.
284333
0 commit comments