(program: Command)
| 47 | }; |
| 48 | |
| 49 | export function registerTaskCommands(program: Command): void { |
| 50 | program |
| 51 | .command("run") |
| 52 | .argument( |
| 53 | "<workspace>", |
| 54 | "Path to the orchestrate workspace (contains plan.json)" |
| 55 | ) |
| 56 | .option( |
| 57 | "--root", |
| 58 | "Mark this as the root workspace for the operator-facing re-run hint." |
| 59 | ) |
| 60 | .option( |
| 61 | "--slack-channel <id>", |
| 62 | "Slack channel id for the root run. Falls back to SLACK_CHANNEL_ID." |
| 63 | ) |
| 64 | .option( |
| 65 | "--max-runtime-sec <number>", |
| 66 | "Exit with code 100 after this many seconds when non-terminal work remains.", |
| 67 | String(DEFAULT_MAX_RUNTIME_SEC) |
| 68 | ) |
| 69 | .option( |
| 70 | "--exit-on-all-done", |
| 71 | "Keep draining to quiescence instead of returning on the first terminal error. Default is exit-on-error so the planner reacts to failures promptly (in-flight workers reattach on the next run)." |
| 72 | ) |
| 73 | .description( |
| 74 | "Run the reconcile loop: spawn pending tasks (respecting dependsOn), wait for handoffs, write them to <workspace>/handoffs/, repeat until terminal. Idempotent — rerun to pick up plan.json changes or retries." |
| 75 | ) |
| 76 | .action( |
| 77 | async ( |
| 78 | workspace: string, |
| 79 | opts: { |
| 80 | root?: boolean; |
| 81 | slackChannel?: string; |
| 82 | maxRuntimeSec: string; |
| 83 | exitOnAllDone?: boolean; |
| 84 | } |
| 85 | ) => { |
| 86 | const maxRuntimeSec = parsePositiveIntegerOrBail({ |
| 87 | value: opts.maxRuntimeSec, |
| 88 | flag: "--max-runtime-sec", |
| 89 | }); |
| 90 | const slackChannel = opts.root |
| 91 | ? resolveWorkspaceSlackChannelOrBail({ |
| 92 | workspace, |
| 93 | explicit: opts.slackChannel, |
| 94 | }) |
| 95 | : undefined; |
| 96 | const mgr = await loadOrBail(workspace, { slackChannel }); |
| 97 | const code = await runOrchestrateLoop(mgr, { |
| 98 | maxRuntimeSec, |
| 99 | rootMode: opts.root, |
| 100 | exitOnError: !opts.exitOnAllDone, |
| 101 | }); |
| 102 | process.exit(code); |
| 103 | } |
| 104 | ); |
| 105 | |
| 106 | program |
no test coverage detected