/os-tk-run
Inputs
- •
--max-cycles N(default: 1)
Goal
Run a bounded Ralph-style loop:
- •pick a safe next ticket (file-aware)
- •implement exactly that ticket
- •run review gate (fix-loop)
- •close/merge if SHIP
Parse arguments
Determine MAX_CYCLES from $ARGUMENTS:
- •default:
MAX_CYCLES=1 - •if
--max-cycles Npresent, setMAX_CYCLES=N
(Keep parsing minimal; if unclear, ask user to re-run with --max-cycles <int>.)
Loop
For cycle=1..MAX_CYCLES:
1) Pick next ticket (or STOP)
Use the os-tk-orchestrator subagent to:
- •refresh queue state
- •ensure file predictions
- •add deps for overlaps
- •recommend a safe next ticket
Call via pi-async-subagents tool subagent:
js
subagent({
"agent": "os-tk-orchestrator",
"task": "Queue step for /os-tk-run (include cycle number in your summary).\n\nDo the same work as /os-tk-queue --next, then output TWO things:\n\n1) Human summary in your normal format.\n2) A machine line at the very end:\n NEXT_TICKET=<ticket-id-or-empty>\n\nRules:\n- NEXT_TICKET must be the concrete tk id (e.g. nw-5c46), not an alias.\n- If no safe next ticket exists, output NEXT_TICKET= (empty) and explain why in the human section.",
"agentScope": "both",
"async": false
})
Extract NEXT_TICKET from the subagent output.
- •If empty: STOP (nothing safe to do).
2) Work
Invoke /os-tk-work <NEXT_TICKET>.
3) Review gate
Invoke /os-tk-review <NEXT_TICKET>.
If review fails beyond max iterations (no SHIP note for current diff): STOP.
4) Done
Invoke /os-tk-done <NEXT_TICKET>.
If done fails (gate mismatch, merge conflict, etc.): STOP.
Stop conditions
- •Empty queue / no safe next ticket
- •Review gate cannot reach SHIP within configured iterations
- •Any command error that requires human intervention
Output
After each cycle, print a short summary:
- •ticket id
- •verdict (SHIP/NEEDS_WORK/MAJOR_RETHINK)
- •next action (stop/continue)