opencastle 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -131
- package/bin/cli.mjs +20 -10
- package/dist/cli/adapters/claude-code.d.ts +5 -3
- package/dist/cli/adapters/claude-code.d.ts.map +1 -1
- package/dist/cli/adapters/claude-code.js +7 -3
- package/dist/cli/adapters/claude-code.js.map +1 -1
- package/dist/cli/adapters/single-file-base.d.ts +18 -0
- package/dist/cli/adapters/single-file-base.d.ts.map +1 -1
- package/dist/cli/adapters/single-file-base.js +29 -4
- package/dist/cli/adapters/single-file-base.js.map +1 -1
- package/dist/cli/agent-plugin.test.js +12 -0
- package/dist/cli/agent-plugin.test.js.map +1 -1
- package/dist/cli/agent-roster.test.js +0 -48
- package/dist/cli/agent-roster.test.js.map +1 -1
- package/dist/cli/bootstrap.d.ts.map +1 -1
- package/dist/cli/bootstrap.js +20 -0
- package/dist/cli/bootstrap.js.map +1 -1
- package/dist/cli/boundary.test.js +9 -7
- package/dist/cli/boundary.test.js.map +1 -1
- package/dist/cli/ci.d.ts.map +1 -1
- package/dist/cli/ci.js +6 -4
- package/dist/cli/ci.js.map +1 -1
- package/dist/cli/command-namespace.test.js +33 -0
- package/dist/cli/command-namespace.test.js.map +1 -1
- package/dist/cli/convoy/artifacts.d.ts +9 -2
- package/dist/cli/convoy/artifacts.d.ts.map +1 -1
- package/dist/cli/convoy/artifacts.js +13 -10
- package/dist/cli/convoy/artifacts.js.map +1 -1
- package/dist/cli/convoy/artifacts.test.js +4 -2
- package/dist/cli/convoy/artifacts.test.js.map +1 -1
- package/dist/cli/convoy/engine.d.ts +53 -23
- package/dist/cli/convoy/engine.d.ts.map +1 -1
- package/dist/cli/convoy/engine.git.test.d.ts +2 -0
- package/dist/cli/convoy/engine.git.test.d.ts.map +1 -0
- package/dist/cli/convoy/engine.git.test.js +435 -0
- package/dist/cli/convoy/engine.git.test.js.map +1 -0
- package/dist/cli/convoy/engine.js +1746 -2305
- package/dist/cli/convoy/engine.js.map +1 -1
- package/dist/cli/convoy/engine.test.js +698 -678
- package/dist/cli/convoy/engine.test.js.map +1 -1
- package/dist/cli/convoy/event-schemas.d.ts +2 -0
- package/dist/cli/convoy/event-schemas.d.ts.map +1 -1
- package/dist/cli/convoy/event-schemas.js +59 -57
- package/dist/cli/convoy/event-schemas.js.map +1 -1
- package/dist/cli/convoy/events.d.ts +4 -1
- package/dist/cli/convoy/events.d.ts.map +1 -1
- package/dist/cli/convoy/events.js +69 -84
- package/dist/cli/convoy/events.js.map +1 -1
- package/dist/cli/convoy/events.test.js +50 -9
- package/dist/cli/convoy/events.test.js.map +1 -1
- package/dist/cli/convoy/gates.d.ts +9 -4
- package/dist/cli/convoy/gates.d.ts.map +1 -1
- package/dist/cli/convoy/gates.js +29 -14
- package/dist/cli/convoy/gates.js.map +1 -1
- package/dist/cli/convoy/isolation.d.ts +32 -6
- package/dist/cli/convoy/isolation.d.ts.map +1 -1
- package/dist/cli/convoy/isolation.js +72 -34
- package/dist/cli/convoy/isolation.js.map +1 -1
- package/dist/cli/convoy/isolation.test.js +66 -42
- package/dist/cli/convoy/isolation.test.js.map +1 -1
- package/dist/cli/convoy/lock.d.ts.map +1 -1
- package/dist/cli/convoy/lock.js +25 -10
- package/dist/cli/convoy/lock.js.map +1 -1
- package/dist/cli/convoy/lock.test.js +12 -0
- package/dist/cli/convoy/lock.test.js.map +1 -1
- package/dist/cli/convoy/merge.d.ts +21 -4
- package/dist/cli/convoy/merge.d.ts.map +1 -1
- package/dist/cli/convoy/merge.js +69 -53
- package/dist/cli/convoy/merge.js.map +1 -1
- package/dist/cli/convoy/merge.test.js +23 -1
- package/dist/cli/convoy/merge.test.js.map +1 -1
- package/dist/cli/convoy/progress.d.ts +35 -0
- package/dist/cli/convoy/progress.d.ts.map +1 -0
- package/dist/cli/convoy/progress.js +103 -0
- package/dist/cli/convoy/progress.js.map +1 -0
- package/dist/cli/convoy/progress.test.d.ts +2 -0
- package/dist/cli/convoy/progress.test.d.ts.map +1 -0
- package/dist/cli/convoy/progress.test.js +53 -0
- package/dist/cli/convoy/progress.test.js.map +1 -0
- package/dist/cli/convoy/read-model.d.ts +468 -0
- package/dist/cli/convoy/read-model.d.ts.map +1 -0
- package/dist/cli/convoy/read-model.js +1132 -0
- package/dist/cli/convoy/read-model.js.map +1 -0
- package/dist/cli/convoy/read-model.test.d.ts +2 -0
- package/dist/cli/convoy/read-model.test.d.ts.map +1 -0
- package/dist/cli/convoy/read-model.test.js +609 -0
- package/dist/cli/convoy/read-model.test.js.map +1 -0
- package/dist/cli/convoy/redact.d.ts +34 -0
- package/dist/cli/convoy/redact.d.ts.map +1 -0
- package/dist/cli/convoy/redact.js +66 -0
- package/dist/cli/convoy/redact.js.map +1 -0
- package/dist/cli/convoy/redact.test.d.ts +2 -0
- package/dist/cli/convoy/redact.test.d.ts.map +1 -0
- package/dist/cli/convoy/redact.test.js +43 -0
- package/dist/cli/convoy/redact.test.js.map +1 -0
- package/dist/cli/convoy/reviewer.d.ts +65 -0
- package/dist/cli/convoy/reviewer.d.ts.map +1 -0
- package/dist/cli/convoy/reviewer.js +141 -0
- package/dist/cli/convoy/reviewer.js.map +1 -0
- package/dist/cli/convoy/reviewer.test.d.ts +2 -0
- package/dist/cli/convoy/reviewer.test.d.ts.map +1 -0
- package/dist/cli/convoy/reviewer.test.js +96 -0
- package/dist/cli/convoy/reviewer.test.js.map +1 -0
- package/dist/cli/convoy/schedule.d.ts +30 -0
- package/dist/cli/convoy/schedule.d.ts.map +1 -0
- package/dist/cli/convoy/schedule.js +111 -0
- package/dist/cli/convoy/schedule.js.map +1 -0
- package/dist/cli/convoy/schedule.test.d.ts +2 -0
- package/dist/cli/convoy/schedule.test.d.ts.map +1 -0
- package/dist/cli/convoy/schedule.test.js +45 -0
- package/dist/cli/convoy/schedule.test.js.map +1 -0
- package/dist/cli/convoy/spec-builder.d.ts +120 -30
- package/dist/cli/convoy/spec-builder.d.ts.map +1 -1
- package/dist/cli/convoy/spec-builder.js +438 -114
- package/dist/cli/convoy/spec-builder.js.map +1 -1
- package/dist/cli/convoy/spec-builder.test.js +419 -435
- package/dist/cli/convoy/spec-builder.test.js.map +1 -1
- package/dist/cli/convoy/spec-types.d.ts +46 -92
- package/dist/cli/convoy/spec-types.d.ts.map +1 -1
- package/dist/cli/convoy/store.d.ts +6 -1
- package/dist/cli/convoy/store.d.ts.map +1 -1
- package/dist/cli/convoy/store.js +111 -15
- package/dist/cli/convoy/store.js.map +1 -1
- package/dist/cli/convoy/store.test.js +59 -13
- package/dist/cli/convoy/store.test.js.map +1 -1
- package/dist/cli/convoy/types.d.ts +76 -113
- package/dist/cli/convoy/types.d.ts.map +1 -1
- package/dist/cli/convoy/types.js +6 -13
- package/dist/cli/convoy/types.js.map +1 -1
- package/dist/cli/convoy/worktree.d.ts +88 -3
- package/dist/cli/convoy/worktree.d.ts.map +1 -1
- package/dist/cli/convoy/worktree.js +282 -56
- package/dist/cli/convoy/worktree.js.map +1 -1
- package/dist/cli/convoy/worktree.test.js +132 -1
- package/dist/cli/convoy/worktree.test.js.map +1 -1
- package/dist/cli/convoy-args.test.js +9 -27
- package/dist/cli/convoy-args.test.js.map +1 -1
- package/dist/cli/convoy-cmd.d.ts +31 -6
- package/dist/cli/convoy-cmd.d.ts.map +1 -1
- package/dist/cli/convoy-cmd.js +150 -200
- package/dist/cli/convoy-cmd.js.map +1 -1
- package/dist/cli/convoy-cmd.test.d.ts +2 -0
- package/dist/cli/convoy-cmd.test.d.ts.map +1 -0
- package/dist/cli/convoy-cmd.test.js +144 -0
- package/dist/cli/convoy-cmd.test.js.map +1 -0
- package/dist/cli/dashboard.d.ts +24 -11
- package/dist/cli/dashboard.d.ts.map +1 -1
- package/dist/cli/dashboard.js +241 -303
- package/dist/cli/dashboard.js.map +1 -1
- package/dist/cli/dashboard.test.d.ts +2 -0
- package/dist/cli/dashboard.test.d.ts.map +1 -0
- package/dist/cli/dashboard.test.js +340 -0
- package/dist/cli/dashboard.test.js.map +1 -0
- package/dist/cli/dispatcher.test.js +41 -2
- package/dist/cli/dispatcher.test.js.map +1 -1
- package/dist/cli/docs-accuracy.test.js +36 -11
- package/dist/cli/docs-accuracy.test.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +9 -6
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/init-own-files.test.d.ts +2 -0
- package/dist/cli/init-own-files.test.d.ts.map +1 -0
- package/dist/cli/init-own-files.test.js +133 -0
- package/dist/cli/init-own-files.test.js.map +1 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +106 -7
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/init.test.js +5 -4
- package/dist/cli/init.test.js.map +1 -1
- package/dist/cli/layers.d.ts.map +1 -1
- package/dist/cli/layers.js +13 -4
- package/dist/cli/layers.js.map +1 -1
- package/dist/cli/lesson.d.ts.map +1 -1
- package/dist/cli/lesson.js +6 -5
- package/dist/cli/lesson.js.map +1 -1
- package/dist/cli/log.d.ts +39 -0
- package/dist/cli/log.d.ts.map +1 -1
- package/dist/cli/log.js +267 -93
- package/dist/cli/log.js.map +1 -1
- package/dist/cli/log.test.d.ts +2 -0
- package/dist/cli/log.test.d.ts.map +1 -0
- package/dist/cli/log.test.js +208 -0
- package/dist/cli/log.test.js.map +1 -0
- package/dist/cli/nearest.d.ts +18 -0
- package/dist/cli/nearest.d.ts.map +1 -0
- package/dist/cli/nearest.js +38 -0
- package/dist/cli/nearest.js.map +1 -0
- package/dist/cli/nearest.test.d.ts +2 -0
- package/dist/cli/nearest.test.d.ts.map +1 -0
- package/dist/cli/nearest.test.js +24 -0
- package/dist/cli/nearest.test.js.map +1 -0
- package/dist/cli/pipeline.d.ts +61 -0
- package/dist/cli/pipeline.d.ts.map +1 -1
- package/dist/cli/pipeline.flow.test.d.ts +2 -0
- package/dist/cli/pipeline.flow.test.d.ts.map +1 -0
- package/dist/cli/pipeline.flow.test.js +524 -0
- package/dist/cli/pipeline.flow.test.js.map +1 -0
- package/dist/cli/pipeline.js +471 -690
- package/dist/cli/pipeline.js.map +1 -1
- package/dist/cli/plan.d.ts +82 -31
- package/dist/cli/plan.d.ts.map +1 -1
- package/dist/cli/plan.js +167 -507
- package/dist/cli/plan.js.map +1 -1
- package/dist/cli/plan.test.d.ts +2 -0
- package/dist/cli/plan.test.d.ts.map +1 -0
- package/dist/cli/plan.test.js +158 -0
- package/dist/cli/plan.test.js.map +1 -0
- package/dist/cli/prompt.d.ts.map +1 -1
- package/dist/cli/prompt.js +9 -7
- package/dist/cli/prompt.js.map +1 -1
- package/dist/cli/prompt.test.js +20 -2
- package/dist/cli/prompt.test.js.map +1 -1
- package/dist/cli/remove.d.ts.map +1 -1
- package/dist/cli/remove.js +3 -1
- package/dist/cli/remove.js.map +1 -1
- package/dist/cli/review.d.ts.map +1 -1
- package/dist/cli/review.js +7 -1
- package/dist/cli/review.js.map +1 -1
- package/dist/cli/run/adapters/agent-process.d.ts +82 -0
- package/dist/cli/run/adapters/agent-process.d.ts.map +1 -0
- package/dist/cli/run/adapters/agent-process.js +224 -0
- package/dist/cli/run/adapters/agent-process.js.map +1 -0
- package/dist/cli/run/adapters/agent-process.test.d.ts +2 -0
- package/dist/cli/run/adapters/agent-process.test.d.ts.map +1 -0
- package/dist/cli/run/adapters/agent-process.test.js +159 -0
- package/dist/cli/run/adapters/agent-process.test.js.map +1 -0
- package/dist/cli/run/adapters/claude.d.ts +53 -2
- package/dist/cli/run/adapters/claude.d.ts.map +1 -1
- package/dist/cli/run/adapters/claude.js +147 -171
- package/dist/cli/run/adapters/claude.js.map +1 -1
- package/dist/cli/run/adapters/claude.test.js +197 -254
- package/dist/cli/run/adapters/claude.test.js.map +1 -1
- package/dist/cli/run/adapters/codex.d.ts +25 -2
- package/dist/cli/run/adapters/codex.d.ts.map +1 -1
- package/dist/cli/run/adapters/codex.js +113 -81
- package/dist/cli/run/adapters/codex.js.map +1 -1
- package/dist/cli/run/adapters/codex.test.js +116 -95
- package/dist/cli/run/adapters/codex.test.js.map +1 -1
- package/dist/cli/run/adapters/copilot.d.ts +35 -1
- package/dist/cli/run/adapters/copilot.d.ts.map +1 -1
- package/dist/cli/run/adapters/copilot.js +104 -287
- package/dist/cli/run/adapters/copilot.js.map +1 -1
- package/dist/cli/run/adapters/copilot.test.js +122 -282
- package/dist/cli/run/adapters/copilot.test.js.map +1 -1
- package/dist/cli/run/adapters/cursor.d.ts +25 -7
- package/dist/cli/run/adapters/cursor.d.ts.map +1 -1
- package/dist/cli/run/adapters/cursor.js +103 -156
- package/dist/cli/run/adapters/cursor.js.map +1 -1
- package/dist/cli/run/adapters/cursor.test.js +106 -218
- package/dist/cli/run/adapters/cursor.test.js.map +1 -1
- package/dist/cli/run/adapters/index.d.ts +34 -5
- package/dist/cli/run/adapters/index.d.ts.map +1 -1
- package/dist/cli/run/adapters/index.js +147 -21
- package/dist/cli/run/adapters/index.js.map +1 -1
- package/dist/cli/run/adapters/index.test.d.ts +2 -0
- package/dist/cli/run/adapters/index.test.d.ts.map +1 -0
- package/dist/cli/run/adapters/index.test.js +129 -0
- package/dist/cli/run/adapters/index.test.js.map +1 -0
- package/dist/cli/run/adapters/opencode.d.ts +25 -9
- package/dist/cli/run/adapters/opencode.d.ts.map +1 -1
- package/dist/cli/run/adapters/opencode.js +136 -152
- package/dist/cli/run/adapters/opencode.js.map +1 -1
- package/dist/cli/run/adapters/opencode.test.js +99 -218
- package/dist/cli/run/adapters/opencode.test.js.map +1 -1
- package/dist/cli/run/adapters/permission-modes.d.ts +47 -4
- package/dist/cli/run/adapters/permission-modes.d.ts.map +1 -1
- package/dist/cli/run/adapters/permission-modes.js +113 -37
- package/dist/cli/run/adapters/permission-modes.js.map +1 -1
- package/dist/cli/run/adapters/permission-modes.test.js +55 -40
- package/dist/cli/run/adapters/permission-modes.test.js.map +1 -1
- package/dist/cli/run/adapters/stub-cli.test-helper.d.ts +22 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.d.ts.map +1 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.js +73 -0
- package/dist/cli/run/adapters/stub-cli.test-helper.js.map +1 -0
- package/dist/cli/run/platform.d.ts +52 -0
- package/dist/cli/run/platform.d.ts.map +1 -0
- package/dist/cli/run/platform.js +207 -0
- package/dist/cli/run/platform.js.map +1 -0
- package/dist/cli/run/platform.test.d.ts +2 -0
- package/dist/cli/run/platform.test.d.ts.map +1 -0
- package/dist/cli/run/platform.test.js +119 -0
- package/dist/cli/run/platform.test.js.map +1 -0
- package/dist/cli/run/schema.d.ts +6 -8
- package/dist/cli/run/schema.d.ts.map +1 -1
- package/dist/cli/run/schema.js +44 -68
- package/dist/cli/run/schema.js.map +1 -1
- package/dist/cli/run/schema.test.js +59 -279
- package/dist/cli/run/schema.test.js.map +1 -1
- package/dist/cli/run.d.ts +34 -56
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +379 -1132
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/run.test.d.ts +2 -0
- package/dist/cli/run.test.d.ts.map +1 -0
- package/dist/cli/run.test.js +318 -0
- package/dist/cli/run.test.js.map +1 -0
- package/dist/cli/sync-check.d.ts.map +1 -1
- package/dist/cli/sync-check.js +12 -3
- package/dist/cli/sync-check.js.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +3 -2
- package/dist/cli/sync.js.map +1 -1
- package/dist/cli/team-config.d.ts.map +1 -1
- package/dist/cli/team-config.js +2 -21
- package/dist/cli/team-config.js.map +1 -1
- package/dist/cli/tiers.test.js +4 -13
- package/dist/cli/tiers.test.js.map +1 -1
- package/dist/cli/update.d.ts.map +1 -1
- package/dist/cli/update.js +4 -3
- package/dist/cli/update.js.map +1 -1
- package/dist/cli/website-plugins.test.js +51 -2
- package/dist/cli/website-plugins.test.js.map +1 -1
- package/dist/orchestrator/plugins/coolify/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/coolify/config.js +13 -0
- package/dist/orchestrator/plugins/coolify/config.js.map +1 -1
- package/dist/orchestrator/plugins/sentry/config.d.ts.map +1 -1
- package/dist/orchestrator/plugins/sentry/config.js +13 -0
- package/dist/orchestrator/plugins/sentry/config.js.map +1 -1
- package/package.json +3 -10
- package/src/cli/adapters/claude-code.ts +7 -3
- package/src/cli/adapters/single-file-base.ts +47 -4
- package/src/cli/agent-plugin.test.ts +14 -0
- package/src/cli/agent-roster.test.ts +0 -55
- package/src/cli/bootstrap.ts +23 -0
- package/src/cli/boundary.test.ts +9 -7
- package/src/cli/ci.ts +6 -4
- package/src/cli/command-namespace.test.ts +35 -0
- package/src/cli/convoy/TELEMETRY.md +138 -130
- package/src/cli/convoy/artifacts.test.ts +4 -2
- package/src/cli/convoy/artifacts.ts +13 -12
- package/src/cli/convoy/engine.git.test.ts +462 -0
- package/src/cli/convoy/engine.test.ts +817 -850
- package/src/cli/convoy/engine.ts +1864 -2596
- package/src/cli/convoy/event-schemas.ts +63 -59
- package/src/cli/convoy/events.test.ts +58 -9
- package/src/cli/convoy/events.ts +69 -91
- package/src/cli/convoy/gates.ts +31 -12
- package/src/cli/convoy/isolation.test.ts +76 -43
- package/src/cli/convoy/isolation.ts +100 -38
- package/src/cli/convoy/lock.test.ts +16 -0
- package/src/cli/convoy/lock.ts +25 -8
- package/src/cli/convoy/merge.test.ts +25 -1
- package/src/cli/convoy/merge.ts +74 -61
- package/src/cli/convoy/progress.test.ts +59 -0
- package/src/cli/convoy/progress.ts +121 -0
- package/src/cli/convoy/read-model.test.ts +685 -0
- package/src/cli/convoy/read-model.ts +1469 -0
- package/src/cli/convoy/redact.test.ts +49 -0
- package/src/cli/convoy/redact.ts +73 -0
- package/src/cli/convoy/reviewer.test.ts +112 -0
- package/src/cli/convoy/reviewer.ts +196 -0
- package/src/cli/convoy/schedule.test.ts +56 -0
- package/src/cli/convoy/schedule.ts +109 -0
- package/src/cli/convoy/spec-builder.test.ts +460 -464
- package/src/cli/convoy/spec-builder.ts +460 -129
- package/src/cli/convoy/spec-types.ts +46 -108
- package/src/cli/convoy/store.test.ts +64 -13
- package/src/cli/convoy/store.ts +143 -33
- package/src/cli/convoy/types.ts +59 -71
- package/src/cli/convoy/worktree.test.ts +140 -1
- package/src/cli/convoy/worktree.ts +311 -61
- package/src/cli/convoy-args.test.ts +10 -30
- package/src/cli/convoy-cmd.test.ts +163 -0
- package/src/cli/convoy-cmd.ts +173 -215
- package/src/cli/dashboard/dashboard.css +2086 -0
- package/src/cli/dashboard/dashboard.js +1687 -0
- package/src/cli/dashboard/index.html +307 -0
- package/src/cli/dashboard.test.ts +382 -0
- package/src/cli/dashboard.ts +243 -339
- package/src/cli/dispatcher.test.ts +43 -2
- package/src/cli/docs-accuracy.test.ts +37 -10
- package/src/cli/doctor.ts +9 -6
- package/src/cli/init-own-files.test.ts +156 -0
- package/src/cli/init.test.ts +5 -4
- package/src/cli/init.ts +104 -7
- package/src/cli/layers.ts +13 -4
- package/src/cli/lesson.ts +6 -5
- package/src/cli/log.test.ts +228 -0
- package/src/cli/log.ts +302 -83
- package/src/cli/nearest.test.ts +27 -0
- package/src/cli/nearest.ts +38 -0
- package/src/cli/pipeline.flow.test.ts +607 -0
- package/src/cli/pipeline.ts +544 -759
- package/src/cli/plan.test.ts +193 -0
- package/src/cli/plan.ts +209 -545
- package/src/cli/prompt.test.ts +21 -2
- package/src/cli/prompt.ts +11 -7
- package/src/cli/remove.ts +3 -0
- package/src/cli/review.ts +7 -1
- package/src/cli/run/adapters/agent-process.test.ts +175 -0
- package/src/cli/run/adapters/agent-process.ts +252 -0
- package/src/cli/run/adapters/claude.test.ts +205 -260
- package/src/cli/run/adapters/claude.ts +151 -162
- package/src/cli/run/adapters/codex.test.ts +120 -100
- package/src/cli/run/adapters/codex.ts +115 -91
- package/src/cli/run/adapters/copilot.test.ts +135 -306
- package/src/cli/run/adapters/copilot.ts +105 -274
- package/src/cli/run/adapters/cursor.test.ts +111 -220
- package/src/cli/run/adapters/cursor.ts +105 -156
- package/src/cli/run/adapters/index.test.ts +148 -0
- package/src/cli/run/adapters/index.ts +168 -20
- package/src/cli/run/adapters/opencode.test.ts +106 -227
- package/src/cli/run/adapters/opencode.ts +139 -151
- package/src/cli/run/adapters/permission-modes.test.ts +63 -41
- package/src/cli/run/adapters/permission-modes.ts +118 -37
- package/src/cli/run/adapters/stub-cli.test-helper.ts +88 -0
- package/src/cli/run/platform.test.ts +128 -0
- package/src/cli/run/platform.ts +213 -0
- package/src/cli/run/schema.test.ts +62 -344
- package/src/cli/run/schema.ts +48 -78
- package/src/cli/run.test.ts +351 -0
- package/src/cli/run.ts +366 -1151
- package/src/cli/sync-check.ts +12 -3
- package/src/cli/sync.ts +3 -2
- package/src/cli/team-config.ts +2 -21
- package/src/cli/tiers.test.ts +4 -17
- package/src/cli/update.ts +4 -3
- package/src/cli/website-plugins.test.ts +55 -5
- package/src/orchestrator/agents/team-lead.agent.md +2 -2
- package/src/orchestrator/customizations/README.md +58 -13
- package/src/orchestrator/customizations/logs/README.md +23 -18
- package/src/orchestrator/instructions/general.instructions.md +1 -1
- package/src/orchestrator/plugins/coolify/config.ts +13 -0
- package/src/orchestrator/plugins/sentry/config.ts +13 -0
- package/src/orchestrator/prompts/assess-complexity.prompt.md +43 -26
- package/src/orchestrator/prompts/bootstrap-customizations.prompt.md +44 -49
- package/src/orchestrator/prompts/brainstorm.prompt.md +2 -2
- package/src/orchestrator/prompts/bug-fix.prompt.md +5 -4
- package/src/orchestrator/prompts/create-skill.prompt.md +29 -39
- package/src/orchestrator/prompts/fix-convoy.prompt.md +43 -29
- package/src/orchestrator/prompts/fix-prd.prompt.md +26 -22
- package/src/orchestrator/prompts/generate-convoy.prompt.md +139 -147
- package/src/orchestrator/prompts/generate-prd.prompt.md +75 -68
- package/src/orchestrator/prompts/implement-feature.prompt.md +7 -6
- package/src/orchestrator/prompts/validate-convoy.prompt.md +29 -28
- package/src/orchestrator/prompts/validate-prd.prompt.md +28 -21
- package/src/orchestrator/skills/agent-hooks/HOOKS-REFERENCE.md +3 -3
- package/src/orchestrator/skills/agent-hooks/SKILL.md +1 -1
- package/src/orchestrator/skills/fast-review/SKILL.md +3 -1
- package/src/orchestrator/skills/orchestration-protocols/SKILL.md +7 -8
- package/dist/cli/convoy/dag-analysis.d.ts +0 -39
- package/dist/cli/convoy/dag-analysis.d.ts.map +0 -1
- package/dist/cli/convoy/dag-analysis.js +0 -279
- package/dist/cli/convoy/dag-analysis.js.map +0 -1
- package/dist/cli/convoy/dag-analysis.test.d.ts +0 -2
- package/dist/cli/convoy/dag-analysis.test.d.ts.map +0 -1
- package/dist/cli/convoy/dag-analysis.test.js +0 -289
- package/dist/cli/convoy/dag-analysis.test.js.map +0 -1
- package/dist/cli/convoy/formula.d.ts +0 -19
- package/dist/cli/convoy/formula.d.ts.map +0 -1
- package/dist/cli/convoy/formula.js +0 -142
- package/dist/cli/convoy/formula.js.map +0 -1
- package/dist/cli/convoy/formula.test.d.ts +0 -2
- package/dist/cli/convoy/formula.test.d.ts.map +0 -1
- package/dist/cli/convoy/formula.test.js +0 -342
- package/dist/cli/convoy/formula.test.js.map +0 -1
- package/dist/cli/convoy/health.d.ts +0 -34
- package/dist/cli/convoy/health.d.ts.map +0 -1
- package/dist/cli/convoy/health.js +0 -123
- package/dist/cli/convoy/health.js.map +0 -1
- package/dist/cli/convoy/health.test.d.ts +0 -2
- package/dist/cli/convoy/health.test.d.ts.map +0 -1
- package/dist/cli/convoy/health.test.js +0 -448
- package/dist/cli/convoy/health.test.js.map +0 -1
- package/dist/cli/convoy/last-run.d.ts +0 -53
- package/dist/cli/convoy/last-run.d.ts.map +0 -1
- package/dist/cli/convoy/last-run.js +0 -54
- package/dist/cli/convoy/last-run.js.map +0 -1
- package/dist/cli/convoy/last-run.test.d.ts +0 -2
- package/dist/cli/convoy/last-run.test.d.ts.map +0 -1
- package/dist/cli/convoy/last-run.test.js +0 -110
- package/dist/cli/convoy/last-run.test.js.map +0 -1
- package/dist/cli/convoy/pipeline.d.ts +0 -41
- package/dist/cli/convoy/pipeline.d.ts.map +0 -1
- package/dist/cli/convoy/pipeline.js +0 -414
- package/dist/cli/convoy/pipeline.js.map +0 -1
- package/dist/cli/convoy/pipeline.test.d.ts +0 -2
- package/dist/cli/convoy/pipeline.test.d.ts.map +0 -1
- package/dist/cli/convoy/pipeline.test.js +0 -837
- package/dist/cli/convoy/pipeline.test.js.map +0 -1
- package/dist/cli/convoy/review-stages.d.ts +0 -9
- package/dist/cli/convoy/review-stages.d.ts.map +0 -1
- package/dist/cli/convoy/review-stages.js +0 -134
- package/dist/cli/convoy/review-stages.js.map +0 -1
- package/dist/cli/convoy/review-stages.test.d.ts +0 -2
- package/dist/cli/convoy/review-stages.test.d.ts.map +0 -1
- package/dist/cli/convoy/review-stages.test.js +0 -197
- package/dist/cli/convoy/review-stages.test.js.map +0 -1
- package/dist/cli/run/executor.d.ts +0 -15
- package/dist/cli/run/executor.d.ts.map +0 -1
- package/dist/cli/run/executor.js +0 -249
- package/dist/cli/run/executor.js.map +0 -1
- package/dist/cli/run/executor.test.d.ts +0 -2
- package/dist/cli/run/executor.test.d.ts.map +0 -1
- package/dist/cli/run/executor.test.js +0 -297
- package/dist/cli/run/executor.test.js.map +0 -1
- package/dist/cli/run/reporter.d.ts +0 -10
- package/dist/cli/run/reporter.d.ts.map +0 -1
- package/dist/cli/run/reporter.js +0 -142
- package/dist/cli/run/reporter.js.map +0 -1
- package/dist/cli/run-dry-run.test.d.ts +0 -2
- package/dist/cli/run-dry-run.test.d.ts.map +0 -1
- package/dist/cli/run-dry-run.test.js +0 -83
- package/dist/cli/run-dry-run.test.js.map +0 -1
- package/dist/cli/run-executor-flags.test.d.ts +0 -2
- package/dist/cli/run-executor-flags.test.d.ts.map +0 -1
- package/dist/cli/run-executor-flags.test.js +0 -31
- package/dist/cli/run-executor-flags.test.js.map +0 -1
- package/dist/cli/run-finish.test.d.ts +0 -2
- package/dist/cli/run-finish.test.d.ts.map +0 -1
- package/dist/cli/run-finish.test.js +0 -77
- package/dist/cli/run-finish.test.js.map +0 -1
- package/dist/cli/watch.d.ts +0 -15
- package/dist/cli/watch.d.ts.map +0 -1
- package/dist/cli/watch.js +0 -277
- package/dist/cli/watch.js.map +0 -1
- package/dist/dashboard/scripts/etl.d.ts +0 -10
- package/dist/dashboard/scripts/etl.d.ts.map +0 -1
- package/dist/dashboard/scripts/etl.js +0 -141
- package/dist/dashboard/scripts/etl.js.map +0 -1
- package/src/cli/convoy/dag-analysis.test.ts +0 -349
- package/src/cli/convoy/dag-analysis.ts +0 -367
- package/src/cli/convoy/formula.test.ts +0 -404
- package/src/cli/convoy/formula.ts +0 -174
- package/src/cli/convoy/health.test.ts +0 -519
- package/src/cli/convoy/health.ts +0 -189
- package/src/cli/convoy/last-run.test.ts +0 -130
- package/src/cli/convoy/last-run.ts +0 -87
- package/src/cli/convoy/pipeline.test.ts +0 -999
- package/src/cli/convoy/pipeline.ts +0 -492
- package/src/cli/convoy/review-stages.test.ts +0 -235
- package/src/cli/convoy/review-stages.ts +0 -166
- package/src/cli/run/executor.test.ts +0 -338
- package/src/cli/run/executor.ts +0 -292
- package/src/cli/run/reporter.ts +0 -160
- package/src/cli/run-dry-run.test.ts +0 -97
- package/src/cli/run-executor-flags.test.ts +0 -38
- package/src/cli/run-finish.test.ts +0 -91
- package/src/cli/watch.ts +0 -295
- package/src/dashboard/astro.config.mjs +0 -6
- package/src/dashboard/dist/_astro/index.CADNhRPS.css +0 -1
- package/src/dashboard/dist/data/.gitkeep +0 -0
- package/src/dashboard/dist/data/convoy-list.json +0 -1
- package/src/dashboard/dist/data/overall-stats.json +0 -29
- package/src/dashboard/dist/index.html +0 -1963
- package/src/dashboard/node_modules/.vite/deps/_metadata.json +0 -31
- package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js +0 -6776
- package/src/dashboard/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
- package/src/dashboard/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js +0 -99
- package/src/dashboard/node_modules/.vite/deps/astro___cssesc.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
- package/src/dashboard/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
- package/src/dashboard/node_modules/.vite/deps/package.json +0 -3
- package/src/dashboard/package-lock.json +0 -6
- package/src/dashboard/public/data/.gitkeep +0 -0
- package/src/dashboard/public/data/convoy-list.json +0 -1
- package/src/dashboard/public/data/overall-stats.json +0 -29
- package/src/dashboard/public/icon-192.png +0 -0
- package/src/dashboard/scripts/etl.test.ts +0 -166
- package/src/dashboard/scripts/etl.ts +0 -170
- package/src/dashboard/scripts/generate-demo-db.test.ts +0 -30
- package/src/dashboard/scripts/generate-demo-db.ts +0 -529
- package/src/dashboard/scripts/integration-test.ts +0 -504
- package/src/dashboard/scripts/verify-demo-data.sh +0 -51
- package/src/dashboard/seed-data/delegations.ndjson +0 -35
- package/src/dashboard/seed-data/events.ndjson +0 -104
- package/src/dashboard/seed-data/panels.ndjson +0 -13
- package/src/dashboard/seed-data/reviews.ndjson +0 -6
- package/src/dashboard/seed-data/sessions.ndjson +0 -50
- package/src/dashboard/src/env.d.ts +0 -1
- package/src/dashboard/src/layouts/Layout.astro +0 -25
- package/src/dashboard/src/pages/index.astro +0 -2313
- package/src/dashboard/src/styles/dashboard.css +0 -2943
- package/src/dashboard/tsconfig.json +0 -6
- /package/src/{dashboard/dist → cli/dashboard}/icon-192.png +0 -0
package/dist/cli/run.js
CHANGED
|
@@ -1,1213 +1,460 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `opencastle convoy run <spec.yml>` and `opencastle convoy resume`.
|
|
3
|
+
*
|
|
4
|
+
* Two things, and only two: start a spec, or continue the newest run that is
|
|
5
|
+
* not done. This file used to be a 1,250-line parser in front of three
|
|
6
|
+
* executors — the convoy engine, a legacy executor and a pipeline orchestrator —
|
|
7
|
+
* with watch mode, formulas, a dead-letter queue and a status report bolted on.
|
|
8
|
+
* Each path finished a run in its own way, so the summary printed twice and a
|
|
9
|
+
* finished run could sit waiting for Ctrl+C. The engine now does the work and
|
|
10
|
+
* prints its own summary; this file picks the runtime, shows the live view,
|
|
11
|
+
* and exits with the engine's code.
|
|
12
|
+
*/
|
|
1
13
|
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
14
|
import { resolve } from 'node:path';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { createExecutor, buildPhases } from './run/executor.js';
|
|
7
|
-
import { getAdapter, detectAdapter } from './run/adapters/index.js';
|
|
15
|
+
import { parseTaskSpecText } from './run/schema.js';
|
|
16
|
+
import { resolveAdapter, cleanupAdapters } from './run/adapters/index.js';
|
|
8
17
|
import { permissionModeError } from './run/adapters/permission-modes.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { PERMISSION_MODES } from './convoy/spec-types.js';
|
|
18
|
+
import { findProjectRoot, isRunAlive, readRun, readRunSpec, readRuns } from './convoy/read-model.js';
|
|
19
|
+
import { checkConvoyPlan, createConvoyEngine, RESUME_RESET_STATUSES } from './convoy/engine.js';
|
|
12
20
|
import { EngineAlreadyRunningError } from './convoy/lock.js';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return String(n);
|
|
19
|
-
}
|
|
20
|
-
const HELP = `
|
|
21
|
-
opencastle convoy run [options]
|
|
21
|
+
import { startDashboard } from './dashboard.js';
|
|
22
|
+
import { nearest } from './nearest.js';
|
|
23
|
+
import { c } from './prompt.js';
|
|
24
|
+
const RUN_HELP = `
|
|
25
|
+
opencastle convoy run <spec.yml> [options]
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
Run a convoy spec: one you wrote, or one opencastle convoy "<task>" wrote to
|
|
28
|
+
.opencastle/convoys/. The work lands on a branch of its own (the spec's
|
|
29
|
+
branch, or convoy/<name>-<id>); your checkout is never touched.
|
|
25
30
|
|
|
26
31
|
Options:
|
|
27
|
-
--
|
|
28
|
-
--
|
|
29
|
-
|
|
30
|
-
--
|
|
31
|
-
|
|
32
|
-
--concurrency, -c <n> Override max parallel tasks
|
|
33
|
-
--adapter, -a <name> Override agent runtime adapter
|
|
34
|
-
--report-dir <path> Where to write run reports, for legacy specs only
|
|
35
|
-
(default: .opencastle/runs). Convoy specs record to
|
|
36
|
-
.opencastle/convoy.db and .opencastle/logs instead
|
|
37
|
-
--permission-mode <m> How much a worker may do unattended: default,
|
|
38
|
-
acceptEdits (the default), auto, dontAsk,
|
|
39
|
-
bypassPermissions, plan
|
|
40
|
-
--verbose Show full agent output
|
|
41
|
-
--resume Resume the last interrupted convoy from .opencastle/convoy.db
|
|
42
|
-
--retry-failed [task-id] Retry failed/gate-failed/timed-out tasks from the last convoy
|
|
43
|
-
--status Print the current convoy state from .opencastle/convoy.db
|
|
44
|
-
--dlq-list List dead letter queue entries
|
|
45
|
-
--dlq-resolve <id> Resolve a DLQ entry (requires --resolution)
|
|
46
|
-
--dlq-retry <id> Reset a DLQ task to pending for retry
|
|
47
|
-
--convoy <id> Filter by convoy ID (used with --dlq-list)
|
|
48
|
-
--resolution <text> Resolution text (used with --dlq-resolve)
|
|
49
|
-
--watch Keep running, re-triggering on file changes, cron,
|
|
50
|
-
or git push (convoy specs only)
|
|
51
|
-
--watch-config <p> Path to watch configuration file (overrides spec
|
|
52
|
-
watch config)
|
|
53
|
-
--clear-scratchpad Clear scratchpad data at watch start
|
|
32
|
+
--dry-run Check the spec and show what would run; start nothing
|
|
33
|
+
--adapter, -a <name> Agent runtime: claude, codex, cursor, opencode or copilot
|
|
34
|
+
(default: the spec's, else the one opencastle init set up)
|
|
35
|
+
--concurrency, -c <n> Tasks at once (default: the spec's, else 4)
|
|
36
|
+
--verbose Stream agent output
|
|
54
37
|
--help, -h Show this help
|
|
55
38
|
`;
|
|
39
|
+
const RESUME_HELP = `
|
|
40
|
+
opencastle convoy resume [options]
|
|
41
|
+
|
|
42
|
+
Continue the newest run that is not done. Failed, timed-out and interrupted
|
|
43
|
+
tasks run again, and so do the tasks a failure skipped; finished tasks are
|
|
44
|
+
kept. It runs on the branch and runtime the run started with.
|
|
45
|
+
|
|
46
|
+
Options:
|
|
47
|
+
--dry-run List the tasks that would run; start nothing
|
|
48
|
+
--adapter, -a <name> Run on another agent runtime instead
|
|
49
|
+
--concurrency, -c <n> Tasks at once
|
|
50
|
+
--verbose Stream agent output
|
|
51
|
+
--help, -h Show this help
|
|
52
|
+
`;
|
|
53
|
+
const KNOWN_FLAGS = ['--dry-run', '--adapter', '-a', '--concurrency', '-c', '--verbose', '--help', '-h'];
|
|
56
54
|
/**
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* Four entry points build a spec — a fresh run, a retry, a convoy resume and a
|
|
60
|
-
* pipeline resume — and each used to repeat this by hand, which is how a flag
|
|
61
|
-
* comes to work on one of them and not the others.
|
|
55
|
+
* Flags this command used to take, and what to do instead. Named one by one,
|
|
56
|
+
* because "unknown option" is the wrong answer to a flag our own docs taught.
|
|
62
57
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
export const REMOVED_FLAGS = {
|
|
59
|
+
'--resume': 'Use: opencastle convoy resume',
|
|
60
|
+
'--retry-failed': 'Use: opencastle convoy resume — it re-runs failed tasks too',
|
|
61
|
+
'--status': 'Use: opencastle convoy — it shows the last run and what to do next',
|
|
62
|
+
'--dlq-list': 'Failed tasks are listed by opencastle convoy, and re-run by opencastle convoy resume',
|
|
63
|
+
'--dlq-resolve': 'Failed tasks are listed by opencastle convoy, and re-run by opencastle convoy resume',
|
|
64
|
+
'--dlq-retry': 'Use: opencastle convoy resume',
|
|
65
|
+
'--formula': 'Formulas are gone: write the spec out, or plan it with opencastle convoy "<task>"',
|
|
66
|
+
'--set': 'Formulas are gone: write the spec out, or plan it with opencastle convoy "<task>"',
|
|
67
|
+
'--watch': 'Watch mode is gone: run the spec again when you want it run',
|
|
68
|
+
'--watch-config': 'Watch mode is gone: run the spec again when you want it run',
|
|
69
|
+
'--clear-scratchpad': 'Watch mode is gone: run the spec again when you want it run',
|
|
70
|
+
'--report-dir': 'Runs are recorded in .opencastle/convoy.db. See them with opencastle convoy dashboard',
|
|
71
|
+
'--permission-mode': 'Set defaults.permission_mode in the spec instead',
|
|
72
|
+
};
|
|
74
73
|
/**
|
|
75
|
-
*
|
|
76
|
-
* one, and stop.
|
|
74
|
+
* Read `convoy run` or `convoy resume` arguments.
|
|
77
75
|
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* half ended in `process.exit`, so it stopped whether or not anyone remembered to
|
|
81
|
-
* say so; the dashboard half only registered a SIGINT handler, and four of the
|
|
82
|
-
* five then carried straight on into the next block. With the dashboard running,
|
|
83
|
-
* `convoy run` executed the whole spec on the engine and then ran it a second time
|
|
84
|
-
* on the legacy executor, and `--retry-failed` followed its retry with a full fresh
|
|
85
|
-
* run — every task done twice, and paid for twice, visible only when a dashboard
|
|
86
|
-
* was up.
|
|
87
|
-
*
|
|
88
|
-
* One copy, and it either exits or hands control back for the caller to `return`.
|
|
76
|
+
* The spec is positional; `-f`/`--file` still names it, quietly, because
|
|
77
|
+
* every spec written before this change says `convoy run -f <spec>`.
|
|
89
78
|
*/
|
|
90
|
-
export function
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
console.log(`\n ${c.dim('Results saved to .opencastle/convoy.db')}`);
|
|
98
|
-
console.log(` ${c.dim('Dashboard:')} ${dashboard.url}`);
|
|
99
|
-
console.log(`\n Press Ctrl+C to stop`);
|
|
100
|
-
printRetryHint();
|
|
101
|
-
process.on('SIGINT', () => {
|
|
102
|
-
console.log('\n Dashboard stopped.\n');
|
|
103
|
-
dashboard.server.close();
|
|
104
|
-
process.exit(exitCode);
|
|
105
|
-
});
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
printRetryHint();
|
|
109
|
-
process.exit(exitCode);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* The statuses `engine.retryFailed` reopens, and the ones `engine.resume` picks
|
|
113
|
-
* up. Named here so the `--dry-run` preview and the engine cannot drift about
|
|
114
|
-
* which tasks a run would touch.
|
|
115
|
-
*/
|
|
116
|
-
export const RETRYABLE_TASK_STATUSES = [
|
|
117
|
-
'failed',
|
|
118
|
-
'gate-failed',
|
|
119
|
-
'timed-out',
|
|
120
|
-
'review-blocked',
|
|
121
|
-
'disputed',
|
|
122
|
-
];
|
|
123
|
-
export const RESUMABLE_TASK_STATUSES = ['pending', 'assigned', 'running'];
|
|
124
|
-
/**
|
|
125
|
-
* What `--resume` or `--retry-failed` would do, without doing it.
|
|
126
|
-
*
|
|
127
|
-
* `--dry-run` was read only on the fresh-run path, so combining it with either
|
|
128
|
-
* of those flags spawned agents against the user's repository for real. The flag
|
|
129
|
-
* a person reaches for to find out what will happen was the one flag that did
|
|
130
|
-
* not change what happened.
|
|
131
|
-
*/
|
|
132
|
-
export function printRunDryRun(verb, runLabel, runName, tasks, statuses) {
|
|
133
|
-
const selected = tasks.filter((t) => statuses.includes(t.status));
|
|
134
|
-
console.log(`\n 🏰 ${runLabel}: ${runName}`);
|
|
135
|
-
console.log(c.dim(` [dry-run] Nothing will be executed.\n`));
|
|
136
|
-
if (selected.length === 0) {
|
|
137
|
-
console.log(verb === 'retry'
|
|
138
|
-
? ' No failed tasks to retry.'
|
|
139
|
-
: ' No unfinished tasks — nothing to resume.');
|
|
140
|
-
console.log(c.dim(` (matching: ${statuses.join(', ')})\n`));
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
console.log(` Would ${verb === 'retry' ? 're-run' : 'run'} ${selected.length} of ${tasks.length} task(s):`);
|
|
144
|
-
for (const t of selected) {
|
|
145
|
-
console.log(` ${t.id} ${c.dim(`— ${t.agent} [${t.status}]`)}`);
|
|
146
|
-
}
|
|
147
|
-
console.log();
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Parse CLI arguments for the run command.
|
|
151
|
-
*/
|
|
152
|
-
function parseArgs(args) {
|
|
153
|
-
const opts = {
|
|
154
|
-
file: 'convoy.yml',
|
|
155
|
-
dryRun: false,
|
|
156
|
-
concurrency: null,
|
|
157
|
-
adapter: null,
|
|
158
|
-
reportDir: null,
|
|
159
|
-
permissionMode: null,
|
|
160
|
-
verbose: false,
|
|
161
|
-
help: false,
|
|
162
|
-
resume: false,
|
|
163
|
-
status: false,
|
|
164
|
-
retryFailed: false,
|
|
165
|
-
retryFailedTaskIds: undefined,
|
|
166
|
-
dlqList: false,
|
|
167
|
-
dlqResolve: false,
|
|
168
|
-
dlqResolveId: undefined,
|
|
169
|
-
dlqResolveText: undefined,
|
|
170
|
-
dlqRetry: false,
|
|
171
|
-
dlqRetryId: undefined,
|
|
172
|
-
dlqConvoyFilter: undefined,
|
|
173
|
-
formula: null,
|
|
174
|
-
setVars: {},
|
|
175
|
-
watch: false,
|
|
176
|
-
watchConfig: null,
|
|
177
|
-
clearScratchpad: false,
|
|
79
|
+
export function parseRunArgs(args, command) {
|
|
80
|
+
const out = { spec: null, dryRun: false, adapter: null, concurrency: null, verbose: false, help: false };
|
|
81
|
+
const value = (i, flag) => {
|
|
82
|
+
const v = args[i + 1];
|
|
83
|
+
if (v === undefined || v.startsWith('-') || !v.trim())
|
|
84
|
+
return { error: `${flag} needs a value` };
|
|
85
|
+
return v;
|
|
178
86
|
};
|
|
179
87
|
for (let i = 0; i < args.length; i++) {
|
|
180
88
|
const arg = args[i];
|
|
181
89
|
switch (arg) {
|
|
182
90
|
case '--help':
|
|
183
91
|
case '-h':
|
|
184
|
-
|
|
185
|
-
break;
|
|
186
|
-
case '--file':
|
|
187
|
-
case '-f':
|
|
188
|
-
if (i + 1 >= args.length) {
|
|
189
|
-
console.error(' \u2717 --file requires a path');
|
|
190
|
-
process.exit(1);
|
|
191
|
-
}
|
|
192
|
-
opts.file = args[++i];
|
|
193
|
-
if (!opts.file.trim()) {
|
|
194
|
-
console.error(' ✗ --file cannot be empty');
|
|
195
|
-
process.exit(1);
|
|
196
|
-
}
|
|
92
|
+
out.help = true;
|
|
197
93
|
break;
|
|
198
|
-
case '--dryRun':
|
|
199
94
|
case '--dry-run':
|
|
200
|
-
|
|
95
|
+
out.dryRun = true;
|
|
201
96
|
break;
|
|
202
|
-
case '--
|
|
203
|
-
|
|
204
|
-
if (i + 1 >= args.length) {
|
|
205
|
-
console.error(' \u2717 --concurrency requires a number');
|
|
206
|
-
process.exit(1);
|
|
207
|
-
}
|
|
208
|
-
const val = parseInt(args[++i], 10);
|
|
209
|
-
if (!Number.isFinite(val) || val < 1) {
|
|
210
|
-
console.error(` ✗ --concurrency must be an integer >= 1`);
|
|
211
|
-
process.exit(1);
|
|
212
|
-
}
|
|
213
|
-
opts.concurrency = val;
|
|
97
|
+
case '--verbose':
|
|
98
|
+
out.verbose = true;
|
|
214
99
|
break;
|
|
215
|
-
}
|
|
216
100
|
case '--adapter':
|
|
217
|
-
case '-a':
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
opts.adapter = args[++i];
|
|
223
|
-
if (!opts.adapter.trim()) {
|
|
224
|
-
console.error(' ✗ --adapter cannot be empty');
|
|
225
|
-
process.exit(1);
|
|
226
|
-
}
|
|
227
|
-
break;
|
|
228
|
-
case '--report-dir':
|
|
229
|
-
if (i + 1 >= args.length) {
|
|
230
|
-
console.error(' \u2717 --report-dir requires a path');
|
|
231
|
-
process.exit(1);
|
|
232
|
-
}
|
|
233
|
-
opts.reportDir = args[++i];
|
|
234
|
-
if (!opts.reportDir.trim()) {
|
|
235
|
-
console.error(' ✗ --report-dir cannot be empty');
|
|
236
|
-
process.exit(1);
|
|
237
|
-
}
|
|
238
|
-
break;
|
|
239
|
-
case '--permission-mode': {
|
|
240
|
-
if (i + 1 >= args.length) {
|
|
241
|
-
console.error(' ✗ --permission-mode requires a mode');
|
|
242
|
-
process.exit(1);
|
|
243
|
-
}
|
|
244
|
-
const mode = args[++i];
|
|
245
|
-
if (!PERMISSION_MODES.includes(mode)) {
|
|
246
|
-
console.error(` ✗ --permission-mode must be one of: ${PERMISSION_MODES.join(', ')}`);
|
|
247
|
-
process.exit(1);
|
|
248
|
-
}
|
|
249
|
-
opts.permissionMode = mode;
|
|
101
|
+
case '-a': {
|
|
102
|
+
const v = value(i++, arg);
|
|
103
|
+
if (typeof v !== 'string')
|
|
104
|
+
return v;
|
|
105
|
+
out.adapter = v;
|
|
250
106
|
break;
|
|
251
107
|
}
|
|
252
|
-
case '--
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
opts.retryFailedTaskIds = [args[++i]];
|
|
262
|
-
}
|
|
263
|
-
break;
|
|
264
|
-
case '--status':
|
|
265
|
-
opts.status = true;
|
|
266
|
-
break;
|
|
267
|
-
case '--dlq-list':
|
|
268
|
-
opts.dlqList = true;
|
|
269
|
-
break;
|
|
270
|
-
case '--dlq-resolve':
|
|
271
|
-
opts.dlqResolve = true;
|
|
272
|
-
if (i + 1 < args.length && !args[i + 1].startsWith('--'))
|
|
273
|
-
opts.dlqResolveId = args[++i];
|
|
274
|
-
break;
|
|
275
|
-
case '--dlq-retry':
|
|
276
|
-
opts.dlqRetry = true;
|
|
277
|
-
if (i + 1 < args.length && !args[i + 1].startsWith('--'))
|
|
278
|
-
opts.dlqRetryId = args[++i];
|
|
279
|
-
break;
|
|
280
|
-
case '--resolution':
|
|
281
|
-
if (i + 1 >= args.length) {
|
|
282
|
-
console.error(' ✗ --resolution requires text');
|
|
283
|
-
process.exit(1);
|
|
284
|
-
}
|
|
285
|
-
opts.dlqResolveText = args[++i];
|
|
286
|
-
if (!opts.dlqResolveText.trim()) {
|
|
287
|
-
console.error(' ✗ --resolution cannot be empty');
|
|
288
|
-
process.exit(1);
|
|
289
|
-
}
|
|
290
|
-
break;
|
|
291
|
-
case '--convoy':
|
|
292
|
-
if (i + 1 >= args.length) {
|
|
293
|
-
console.error(' ✗ --convoy requires an ID');
|
|
294
|
-
process.exit(1);
|
|
295
|
-
}
|
|
296
|
-
opts.dlqConvoyFilter = args[++i];
|
|
297
|
-
if (!opts.dlqConvoyFilter.trim()) {
|
|
298
|
-
console.error(' ✗ --convoy cannot be empty');
|
|
299
|
-
process.exit(1);
|
|
300
|
-
}
|
|
301
|
-
break;
|
|
302
|
-
case '--formula':
|
|
303
|
-
if (i + 1 >= args.length) {
|
|
304
|
-
console.error(' ✗ --formula requires a path');
|
|
305
|
-
process.exit(1);
|
|
306
|
-
}
|
|
307
|
-
opts.formula = args[++i];
|
|
308
|
-
if (!opts.formula.trim()) {
|
|
309
|
-
console.error(' ✗ --formula cannot be empty');
|
|
310
|
-
process.exit(1);
|
|
311
|
-
}
|
|
312
|
-
break;
|
|
313
|
-
case '--set': {
|
|
314
|
-
if (i + 1 >= args.length) {
|
|
315
|
-
console.error(' ✗ --set requires key=value');
|
|
316
|
-
process.exit(1);
|
|
317
|
-
}
|
|
318
|
-
const pair = args[++i];
|
|
319
|
-
const eqIdx = pair.indexOf('=');
|
|
320
|
-
if (eqIdx < 1) {
|
|
321
|
-
console.error(` ✗ --set value must be in key=value format, got: ${pair}`);
|
|
322
|
-
process.exit(1);
|
|
323
|
-
}
|
|
324
|
-
opts.setVars[pair.slice(0, eqIdx)] = pair.slice(eqIdx + 1);
|
|
108
|
+
case '--concurrency':
|
|
109
|
+
case '-c': {
|
|
110
|
+
const v = value(i++, arg);
|
|
111
|
+
if (typeof v !== 'string')
|
|
112
|
+
return v;
|
|
113
|
+
const n = Number(v);
|
|
114
|
+
if (!/^\d+$/.test(v) || n < 1 || n > 50)
|
|
115
|
+
return { error: `--concurrency must be a whole number from 1 to 50, not "${v}"` };
|
|
116
|
+
out.concurrency = n;
|
|
325
117
|
break;
|
|
326
118
|
}
|
|
327
|
-
case '--
|
|
328
|
-
|
|
119
|
+
case '--file':
|
|
120
|
+
case '-f': {
|
|
121
|
+
if (command !== 'run')
|
|
122
|
+
return { error: `${arg} belongs to opencastle convoy run` };
|
|
123
|
+
const v = value(i++, arg);
|
|
124
|
+
if (typeof v !== 'string')
|
|
125
|
+
return v;
|
|
126
|
+
if (out.spec !== null)
|
|
127
|
+
return { error: `Two specs given: ${out.spec} and ${v}. Run one at a time.` };
|
|
128
|
+
out.spec = v;
|
|
329
129
|
break;
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
130
|
+
}
|
|
131
|
+
default: {
|
|
132
|
+
if (arg in REMOVED_FLAGS)
|
|
133
|
+
return { error: `${arg} was removed. ${REMOVED_FLAGS[arg]}.` };
|
|
134
|
+
if (arg.startsWith('-')) {
|
|
135
|
+
const near = nearest(arg, KNOWN_FLAGS);
|
|
136
|
+
return { error: `Unknown option ${arg}. ${near ? `Did you mean ${near}?` : `It accepts ${KNOWN_FLAGS.join(', ')}.`}` };
|
|
334
137
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
console.error(' ✗ --watch-config cannot be empty');
|
|
338
|
-
process.exit(1);
|
|
138
|
+
if (command === 'resume') {
|
|
139
|
+
return { error: `Unexpected argument "${arg}". resume continues the newest run that is not done, and takes no name.` };
|
|
339
140
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
default:
|
|
345
|
-
console.error(` ✗ Unknown option: ${arg}. Run with --help to see available options.`);
|
|
346
|
-
console.log(HELP);
|
|
347
|
-
process.exit(1);
|
|
141
|
+
if (out.spec !== null)
|
|
142
|
+
return { error: `Two specs given: ${out.spec} and ${arg}. Run one at a time.` };
|
|
143
|
+
out.spec = arg;
|
|
144
|
+
}
|
|
348
145
|
}
|
|
349
146
|
}
|
|
350
|
-
return
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Which executor a spec will run on, and therefore which flags mean anything.
|
|
354
|
-
*
|
|
355
|
-
* Three exist — the pipeline orchestrator for `version: 2`, the convoy engine
|
|
356
|
-
* for `version: 1`, and the legacy executor for everything else — and several
|
|
357
|
-
* flags are wired into exactly one of them:
|
|
358
|
-
*
|
|
359
|
-
* `--report-dir` is read where `createReporter` is called, which is the legacy
|
|
360
|
-
* path alone. For a `version: 1` spec, which is what every generated spec is,
|
|
361
|
-
* it was parsed, resolved against cwd, and never passed to the engine; the
|
|
362
|
-
* engine writes to SQLite and NDJSON and has no report directory at all. The
|
|
363
|
-
* flag was accepted, documented as "where to write run reports", and did
|
|
364
|
-
* nothing on the path nearly every user is on.
|
|
365
|
-
*
|
|
366
|
-
* `--watch` and its two companions are the mirror image: they live inside the
|
|
367
|
-
* convoy-engine branch, so a legacy or pipeline spec accepted them and ran
|
|
368
|
-
* once.
|
|
369
|
-
*/
|
|
370
|
-
export function specExecutor(spec) {
|
|
371
|
-
if (isPipelineSpec(spec))
|
|
372
|
-
return 'pipeline';
|
|
373
|
-
if (isConvoySpec(spec))
|
|
374
|
-
return 'engine';
|
|
375
|
-
return 'legacy';
|
|
147
|
+
return out;
|
|
376
148
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
executor: 'legacy',
|
|
382
|
-
set: (o) => o.reportDir !== null,
|
|
383
|
-
why: 'the convoy engine records runs in .opencastle/convoy.db and .opencastle/logs, not as report files',
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
flag: '--watch',
|
|
387
|
-
executor: 'engine',
|
|
388
|
-
set: (o) => o.watch,
|
|
389
|
-
why: 'only the convoy engine has a watch loop',
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
flag: '--watch-config',
|
|
393
|
-
executor: 'engine',
|
|
394
|
-
set: (o) => o.watchConfig !== null,
|
|
395
|
-
why: 'only the convoy engine has a watch loop',
|
|
396
|
-
},
|
|
397
|
-
{
|
|
398
|
-
flag: '--clear-scratchpad',
|
|
399
|
-
executor: 'engine',
|
|
400
|
-
set: (o) => o.clearScratchpad,
|
|
401
|
-
why: 'only the convoy engine has a watch loop',
|
|
402
|
-
},
|
|
403
|
-
];
|
|
404
|
-
/**
|
|
405
|
-
* Refuse a flag the spec's executor will never read.
|
|
406
|
-
*
|
|
407
|
-
* Same rule as everywhere else on this command: a flag is honoured or refused,
|
|
408
|
-
* never accepted and dropped. Silence here meant `--report-dir ./out` on an
|
|
409
|
-
* ordinary convoy spec exited 0 with `./out` empty.
|
|
410
|
-
*/
|
|
411
|
-
function assertFlagsApplyToSpec(spec, opts) {
|
|
412
|
-
const executor = specExecutor(spec);
|
|
413
|
-
for (const entry of EXECUTOR_ONLY_FLAGS) {
|
|
414
|
-
if (!entry.set(opts) || entry.executor === executor)
|
|
415
|
-
continue;
|
|
416
|
-
const kind = executor === 'pipeline'
|
|
417
|
-
? 'a pipeline spec (version: 2)'
|
|
418
|
-
: executor === 'engine'
|
|
419
|
-
? 'a convoy spec (version: 1)'
|
|
420
|
-
: 'a legacy spec (no version)';
|
|
421
|
-
console.error(` ✗ ${entry.flag} does nothing for ${kind}.`);
|
|
422
|
-
console.error(` ${entry.why}.`);
|
|
423
|
-
process.exit(1);
|
|
424
|
-
}
|
|
149
|
+
// ── Shared pieces ─────────────────────────────────────────────────────────────
|
|
150
|
+
/** Where `.opencastle/` is: the nearest one at or above the current directory, else here. */
|
|
151
|
+
function projectRootHere() {
|
|
152
|
+
return findProjectRoot(process.cwd()) ?? process.cwd();
|
|
425
153
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
* Every entry point resolves its own adapter, so every one of them calls this.
|
|
430
|
-
* Until now the mode simply evaporated on four of the five adapters: a run told
|
|
431
|
-
* to hold its workers to `plan` went ahead and wrote files, and said nothing
|
|
432
|
-
* about it. Refusing is the only honest answer left once a mode cannot be
|
|
433
|
-
* carried out, and it has to happen here — before a worker starts, while the
|
|
434
|
-
* user can still change the flag.
|
|
435
|
-
*/
|
|
436
|
-
function assertPermissionModeSupported(adapterName, spec) {
|
|
437
|
-
const mode = spec.defaults?.permission_mode;
|
|
438
|
-
if (!mode)
|
|
439
|
-
return;
|
|
440
|
-
const problem = permissionModeError(adapterName, mode);
|
|
441
|
-
if (problem) {
|
|
442
|
-
console.error(` ✗ ${problem}`);
|
|
443
|
-
process.exit(1);
|
|
444
|
-
}
|
|
154
|
+
function fail(message) {
|
|
155
|
+
console.error(` ${c.red('✗')} ${message}`);
|
|
156
|
+
return 1;
|
|
445
157
|
}
|
|
446
158
|
/**
|
|
447
|
-
*
|
|
159
|
+
* Pick the runtime, once, with the rule `resolveAdapter` owns. On resume the
|
|
160
|
+
* runtime the run recorded comes before the spec's own `adapter:`, so a run
|
|
161
|
+
* that started on the configured runtime continues on it.
|
|
448
162
|
*/
|
|
449
|
-
function
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
` • cursor — https://cursor.com (Cursor > Install CLI)\n` +
|
|
456
|
-
` • opencode — https://opencode.ai\n` +
|
|
457
|
-
` • codex — npm install -g @openai/codex\n` +
|
|
458
|
-
`\n` +
|
|
459
|
-
` Or specify an adapter explicitly: opencastle convoy run --adapter <name>`);
|
|
163
|
+
async function chooseRuntime(projectRoot, explicit, spec, recorded) {
|
|
164
|
+
const fromRecord = !explicit && Boolean(recorded);
|
|
165
|
+
const why = (text) => fromRecord ? text.replace(/adapter: \S+ in the spec/, 'the runtime this run started on') : text;
|
|
166
|
+
try {
|
|
167
|
+
const resolved = await resolveAdapter({ projectRoot, explicit, specAdapter: recorded || spec.adapter || null });
|
|
168
|
+
return { ...resolved, detail: why(resolved.detail) };
|
|
460
169
|
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
'claude': ' Install: npm install -g @anthropic-ai/claude-code\n' +
|
|
464
|
-
' Docs: https://docs.anthropic.com/en/docs/claude-code',
|
|
465
|
-
copilot: ' Requires the Copilot CLI installed and authenticated:\n' +
|
|
466
|
-
' https://docs.github.com/en/copilot/how-tos/set-up/install-copilot-cli\n' +
|
|
467
|
-
' Docs: https://docs.github.com/en/copilot',
|
|
468
|
-
cursor: ' The Cursor agent CLI ships with the Cursor editor.\n' +
|
|
469
|
-
' Install Cursor from https://cursor.com and ensure the\n' +
|
|
470
|
-
' "agent" command is on your PATH (Cursor > Install CLI).',
|
|
471
|
-
opencode: ' Install OpenCode from https://opencode.ai\n' +
|
|
472
|
-
' Ensure the "opencode" command is on your PATH.',
|
|
473
|
-
codex: ' Install: npm install -g @openai/codex\n' +
|
|
474
|
-
' Docs: https://developers.openai.com/codex',
|
|
475
|
-
};
|
|
476
|
-
const cliName = adapterName === 'cursor' ? 'agent' : adapterName;
|
|
477
|
-
const hint = hints[adapterName] ?? '';
|
|
478
|
-
console.error(` ✗ Adapter "${adapterName}" is not available.\n` +
|
|
479
|
-
` Make sure the "${cliName}" CLI is installed and on your PATH.\n` +
|
|
480
|
-
hint);
|
|
170
|
+
catch (err) {
|
|
171
|
+
throw new Error(why(err.message));
|
|
481
172
|
}
|
|
482
173
|
}
|
|
174
|
+
/** The run's own settings, after the command line has had its say. */
|
|
175
|
+
function applyArgs(spec, args, runtime) {
|
|
176
|
+
// Written into the spec the engine gets, so the run, its resume and its
|
|
177
|
+
// record all name the same runtime.
|
|
178
|
+
spec.adapter = runtime;
|
|
179
|
+
if (args.concurrency !== null)
|
|
180
|
+
spec.concurrency = args.concurrency;
|
|
181
|
+
if (args.verbose)
|
|
182
|
+
spec._verbose = true;
|
|
183
|
+
}
|
|
184
|
+
function concurrencyOf(spec) {
|
|
185
|
+
return typeof spec.concurrency === 'number' ? spec.concurrency : (spec.defaults?.max_swarm_concurrency ?? 4);
|
|
186
|
+
}
|
|
483
187
|
/**
|
|
484
|
-
*
|
|
188
|
+
* The live dashboard, on a terminal and outside CI. A run in a pipeline has
|
|
189
|
+
* nobody to look at it, and a port held open there is a port held for nothing.
|
|
485
190
|
*/
|
|
486
|
-
function
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
(
|
|
491
|
-
(result.summary.skipped > 0 ? ` | ${result.summary.skipped} skipped` : '') +
|
|
492
|
-
(result.summary.timedOut > 0 ? ` | ${result.summary.timedOut} timed out` : ''));
|
|
493
|
-
if (result.gateResults) {
|
|
494
|
-
const gatesPassed = result.gateResults.filter(g => g.passed).length;
|
|
495
|
-
const gatesFailed = result.gateResults.filter(g => !g.passed).length;
|
|
496
|
-
console.log(` Gates: ${gatesPassed}/${result.gateResults.length} passed${gatesFailed > 0 ? ` | ${gatesFailed} failed` : ''}`);
|
|
497
|
-
for (const g of result.gateResults) {
|
|
498
|
-
console.log(` ${g.passed ? '✓' : '✗'} ${g.command}`);
|
|
499
|
-
}
|
|
191
|
+
async function maybeStartDashboard(projectRoot) {
|
|
192
|
+
if (!process.stdout.isTTY || process.env.CI)
|
|
193
|
+
return null;
|
|
194
|
+
try {
|
|
195
|
+
return await startDashboard({ projectRoot, port: 4300, open: false });
|
|
500
196
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
parts.push(`Cost: $${result.cost.total_cost_usd.toFixed(2)}`);
|
|
505
|
-
}
|
|
506
|
-
console.log(` ${parts.join(' | ')}`);
|
|
197
|
+
catch {
|
|
198
|
+
// A busy port or a missing page must not stop the run itself.
|
|
199
|
+
return null;
|
|
507
200
|
}
|
|
508
201
|
}
|
|
509
202
|
/**
|
|
510
|
-
*
|
|
203
|
+
* Run the engine, then let go of everything: the dashboard's server, any agent
|
|
204
|
+
* an adapter still holds. Whatever happens, the caller gets an exit code back and
|
|
205
|
+
* nothing is left keeping the process alive.
|
|
511
206
|
*/
|
|
512
|
-
function
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
console.log(` ${icon} ${cr.convoyId}: ${cr.status} (${cr.duration})`);
|
|
207
|
+
async function drive(work, projectRoot) {
|
|
208
|
+
const dashboard = await maybeStartDashboard(projectRoot);
|
|
209
|
+
if (dashboard)
|
|
210
|
+
console.log(` ${c.dim('Live view:')} ${dashboard.url}`);
|
|
211
|
+
console.log('');
|
|
212
|
+
try {
|
|
213
|
+
const result = await work();
|
|
214
|
+
return result.exitCode ?? (result.status === 'done' ? 0 : 1);
|
|
521
215
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
parts.push(`Cost: $${result.cost.total_cost_usd.toFixed(2)}`);
|
|
216
|
+
catch (err) {
|
|
217
|
+
if (err instanceof EngineAlreadyRunningError) {
|
|
218
|
+
return fail(`${err.message}\n Watch it with: opencastle convoy dashboard`);
|
|
526
219
|
}
|
|
527
|
-
|
|
220
|
+
return fail(err.message);
|
|
528
221
|
}
|
|
222
|
+
finally {
|
|
223
|
+
await dashboard?.close();
|
|
224
|
+
await cleanupAdapters();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// ── convoy run <spec.yml> ─────────────────────────────────────────────────────
|
|
228
|
+
function fit(text, width) {
|
|
229
|
+
return text.length <= width ? text.padEnd(width) : text.slice(0, Math.max(0, width - 1)) + '…';
|
|
230
|
+
}
|
|
231
|
+
/** What a run would do: the tasks and their order, where the work lands, and on what. */
|
|
232
|
+
function describePlan(spec, runtime) {
|
|
233
|
+
const tasks = spec.tasks ?? [];
|
|
234
|
+
const rows = tasks.map((t) => ({
|
|
235
|
+
id: t.id,
|
|
236
|
+
agent: t.agent,
|
|
237
|
+
deps: t.depends_on.length ? t.depends_on.join(', ') : '–',
|
|
238
|
+
files: t.files.length ? t.files.join(', ') : '(any)',
|
|
239
|
+
}));
|
|
240
|
+
const width = (pick, header, cap) => Math.min(cap, Math.max(header.length, ...rows.map((r) => pick(r).length)));
|
|
241
|
+
const idW = width((r) => r.id, 'TASK', 32);
|
|
242
|
+
const agentW = width((r) => r.agent, 'AGENT', 18);
|
|
243
|
+
const depsW = width((r) => r.deps, 'WAITS FOR', 30);
|
|
244
|
+
const line = (a, b, d, f) => ` ${fit(a, idW)} ${fit(b, agentW)} ${fit(d, depsW)} ${f}`;
|
|
245
|
+
return [
|
|
246
|
+
` ${c.bold(`Convoy: ${spec.name}`)} ${c.dim(`— ${tasks.length} task${tasks.length === 1 ? '' : 's'}, up to ${concurrencyOf(spec)} at once`)}`,
|
|
247
|
+
'',
|
|
248
|
+
c.dim(line('TASK', 'AGENT', 'WAITS FOR', 'FILES')),
|
|
249
|
+
...rows.map((r) => line(r.id, r.agent, r.deps, r.files)),
|
|
250
|
+
'',
|
|
251
|
+
` ${c.dim('Runtime')} ${runtime}`,
|
|
252
|
+
` ${c.dim('Branch')} ${spec.branch ?? 'convoy/<name>-<id>, created when it runs'}`,
|
|
253
|
+
...(spec.gates?.length ? [` ${c.dim('Gates')} ${spec.gates.join(', ')} ${c.dim('(once, after the tasks)')}`] : []),
|
|
254
|
+
];
|
|
529
255
|
}
|
|
530
256
|
/**
|
|
531
|
-
*
|
|
257
|
+
* `convoy run <spec>`: the exit code it should end with.
|
|
258
|
+
*
|
|
259
|
+
* `runtime` is for the planner, which has already chosen the runtime and said
|
|
260
|
+
* which; the run uses it rather than choosing, and saying, a second time.
|
|
532
261
|
*/
|
|
533
|
-
export
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
console.
|
|
537
|
-
return;
|
|
262
|
+
export async function runSpec(args, opts = {}) {
|
|
263
|
+
if (!args.spec) {
|
|
264
|
+
console.error(` ${c.red('✗')} Name the spec to run: opencastle convoy run <spec.yml>`);
|
|
265
|
+
console.error(` ${c.dim('Specs the planner wrote are in .opencastle/convoys/.')}`);
|
|
266
|
+
return 1;
|
|
538
267
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
if (!existsSync(dbPath)) {
|
|
543
|
-
console.log(' No convoy database found at .opencastle/convoy.db');
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
const { createConvoyStore } = await import('./convoy/store.js');
|
|
547
|
-
const store = createConvoyStore(dbPath);
|
|
548
|
-
try {
|
|
549
|
-
const entries = store.listDlqEntries(opts.dlqConvoyFilter);
|
|
550
|
-
if (entries.length === 0) {
|
|
551
|
-
console.log(' No DLQ entries found.');
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
console.log(`\n Dead Letter Queue (${entries.length} entries):\n`);
|
|
555
|
-
for (const e of entries) {
|
|
556
|
-
const status = e.resolved ? c.green('resolved') : c.red('unresolved');
|
|
557
|
-
console.log(` ${e.id} ${status}`);
|
|
558
|
-
console.log(` Task: ${e.task_id} | Agent: ${e.agent} | Type: ${e.failure_type}`);
|
|
559
|
-
console.log(` Attempts: ${e.attempts} | Created: ${e.created_at}`);
|
|
560
|
-
if (e.resolution)
|
|
561
|
-
console.log(` Resolution: ${e.resolution}`);
|
|
562
|
-
console.log();
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
finally {
|
|
566
|
-
store.close();
|
|
567
|
-
}
|
|
568
|
-
return;
|
|
268
|
+
let specText;
|
|
269
|
+
try {
|
|
270
|
+
specText = await readFile(resolve(process.cwd(), args.spec), 'utf8');
|
|
569
271
|
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
console.error(' \u2717 --dlq-resolve requires a DLQ entry ID');
|
|
574
|
-
process.exit(1);
|
|
575
|
-
}
|
|
576
|
-
if (!opts.dlqResolveText) {
|
|
577
|
-
console.error(' \u2717 --dlq-resolve requires --resolution "text"');
|
|
578
|
-
process.exit(1);
|
|
579
|
-
}
|
|
580
|
-
if (!existsSync(dbPath)) {
|
|
581
|
-
console.error(' \u2717 No convoy database found at .opencastle/convoy.db');
|
|
582
|
-
process.exit(1);
|
|
583
|
-
}
|
|
584
|
-
const { createConvoyStore } = await import('./convoy/store.js');
|
|
585
|
-
const store = createConvoyStore(dbPath);
|
|
586
|
-
try {
|
|
587
|
-
store.resolveDlqEntry(opts.dlqResolveId, opts.dlqResolveText);
|
|
588
|
-
console.log(` \u2713 DLQ entry ${opts.dlqResolveId} resolved.`);
|
|
589
|
-
}
|
|
590
|
-
finally {
|
|
591
|
-
store.close();
|
|
592
|
-
}
|
|
593
|
-
return;
|
|
272
|
+
catch (err) {
|
|
273
|
+
const e = err;
|
|
274
|
+
return fail(e.code === 'ENOENT' ? `Spec not found: ${args.spec}` : `Cannot read ${args.spec}: ${e.message}`);
|
|
594
275
|
}
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
console.error(' \u2717 --dlq-retry requires a DLQ entry ID');
|
|
599
|
-
process.exit(1);
|
|
600
|
-
}
|
|
601
|
-
if (!existsSync(dbPath)) {
|
|
602
|
-
console.error(' \u2717 No convoy database found at .opencastle/convoy.db');
|
|
603
|
-
process.exit(1);
|
|
604
|
-
}
|
|
605
|
-
const { createConvoyStore } = await import('./convoy/store.js');
|
|
606
|
-
const store = createConvoyStore(dbPath);
|
|
607
|
-
try {
|
|
608
|
-
const entries = store.listDlqEntries();
|
|
609
|
-
const entry = entries.find(e => e.id === opts.dlqRetryId);
|
|
610
|
-
if (!entry) {
|
|
611
|
-
console.error(` \u2717 DLQ entry "${opts.dlqRetryId}" not found`);
|
|
612
|
-
process.exit(1);
|
|
613
|
-
}
|
|
614
|
-
// Reset the task to pending
|
|
615
|
-
store.updateTaskStatus(entry.task_id, entry.convoy_id, 'pending', {
|
|
616
|
-
worker_id: null,
|
|
617
|
-
worktree: null,
|
|
618
|
-
started_at: null,
|
|
619
|
-
finished_at: null,
|
|
620
|
-
});
|
|
621
|
-
store.resolveDlqEntry(entry.id, 'Retried via CLI');
|
|
622
|
-
// Reset convoy status to running if needed
|
|
623
|
-
const convoy = store.getConvoy(entry.convoy_id);
|
|
624
|
-
if (convoy && (convoy.status === 'failed' || convoy.status === 'done')) {
|
|
625
|
-
store.updateConvoyStatus(entry.convoy_id, 'running', {});
|
|
626
|
-
}
|
|
627
|
-
console.log(` \u2713 Task ${entry.task_id} reset to pending. Run 'opencastle convoy run --resume' to execute.`);
|
|
628
|
-
}
|
|
629
|
-
finally {
|
|
630
|
-
store.close();
|
|
631
|
-
}
|
|
632
|
-
return;
|
|
276
|
+
let spec;
|
|
277
|
+
try {
|
|
278
|
+
spec = parseTaskSpecText(specText);
|
|
633
279
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
if (!existsSync(dbPath)) {
|
|
637
|
-
console.log(' No convoy database found at .opencastle/convoy.db');
|
|
638
|
-
return;
|
|
639
|
-
}
|
|
640
|
-
const { createConvoyStore } = await import('./convoy/store.js');
|
|
641
|
-
const store = createConvoyStore(dbPath);
|
|
642
|
-
try {
|
|
643
|
-
const pipeline = store.getLatestPipeline();
|
|
644
|
-
if (pipeline) {
|
|
645
|
-
const pipelineConvoys = store.getConvoysByPipeline(pipeline.id);
|
|
646
|
-
console.log(`\n Pipeline: ${pipeline.name}`);
|
|
647
|
-
console.log(` ID: ${pipeline.id}`);
|
|
648
|
-
console.log(` Status: ${pipeline.status}`);
|
|
649
|
-
console.log(` Branch: ${pipeline.branch ?? '(none)'}`);
|
|
650
|
-
console.log(` Created: ${pipeline.created_at}`);
|
|
651
|
-
if (pipeline.started_at)
|
|
652
|
-
console.log(` Started: ${pipeline.started_at}`);
|
|
653
|
-
if (pipeline.finished_at)
|
|
654
|
-
console.log(` Finished: ${pipeline.finished_at}`);
|
|
655
|
-
if (pipelineConvoys.length > 0) {
|
|
656
|
-
console.log(`\n Convoys:`);
|
|
657
|
-
let totalTasks = 0;
|
|
658
|
-
let totalDone = 0;
|
|
659
|
-
let totalFailed = 0;
|
|
660
|
-
let totalTokens = 0;
|
|
661
|
-
for (const c of pipelineConvoys) {
|
|
662
|
-
const tasks = store.getTasksByConvoy(c.id);
|
|
663
|
-
const done = tasks.filter(t => t.status === 'done').length;
|
|
664
|
-
const failed = tasks.filter(t => t.status === 'failed').length;
|
|
665
|
-
totalTasks += tasks.length;
|
|
666
|
-
totalDone += done;
|
|
667
|
-
totalFailed += failed;
|
|
668
|
-
totalTokens += tasks.reduce((sum, t) => sum + (t.total_tokens ?? 0), 0);
|
|
669
|
-
console.log(` ${c.name} [${c.status}] — ${done}/${tasks.length} tasks done`);
|
|
670
|
-
}
|
|
671
|
-
console.log(`\n Tasks: ${totalDone} done | ${totalFailed} failed | ${totalTasks} total`);
|
|
672
|
-
if (totalTokens > 0)
|
|
673
|
-
console.log(` Tokens: ${formatTokens(totalTokens)}`);
|
|
674
|
-
}
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
const convoy = store.getLatestConvoy();
|
|
678
|
-
if (!convoy) {
|
|
679
|
-
console.log(' No convoy records found.');
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
const tasks = store.getTasksByConvoy(convoy.id);
|
|
683
|
-
const byStatus = tasks.reduce((acc, t) => {
|
|
684
|
-
acc[t.status] = (acc[t.status] ?? 0) + 1;
|
|
685
|
-
return acc;
|
|
686
|
-
}, {});
|
|
687
|
-
console.log(`\n Convoy: ${convoy.name}`);
|
|
688
|
-
console.log(` ID: ${convoy.id}`);
|
|
689
|
-
console.log(` Status: ${convoy.status}`);
|
|
690
|
-
console.log(` Branch: ${convoy.branch ?? '(none)'}`);
|
|
691
|
-
console.log(` Created: ${convoy.created_at}`);
|
|
692
|
-
if (convoy.started_at)
|
|
693
|
-
console.log(` Started: ${convoy.started_at}`);
|
|
694
|
-
if (convoy.finished_at)
|
|
695
|
-
console.log(` Finished: ${convoy.finished_at}`);
|
|
696
|
-
console.log(`\n Tasks:`);
|
|
697
|
-
for (const [status, count] of Object.entries(byStatus)) {
|
|
698
|
-
console.log(` ${status}: ${count}`);
|
|
699
|
-
}
|
|
700
|
-
console.log(` total: ${tasks.length}`);
|
|
701
|
-
const totalTokens = tasks.reduce((sum, t) => sum + (t.total_tokens ?? 0), 0);
|
|
702
|
-
if (tasks.some(t => t.total_tokens != null)) {
|
|
703
|
-
console.log(`\n Tokens: ${formatTokens(totalTokens)}`);
|
|
704
|
-
const tasksWithTokens = tasks.filter(t => t.total_tokens != null);
|
|
705
|
-
if (tasksWithTokens.length > 0) {
|
|
706
|
-
console.log(`\n Token usage by task:`);
|
|
707
|
-
for (const t of tasksWithTokens) {
|
|
708
|
-
const parts = [formatTokens(t.total_tokens)];
|
|
709
|
-
if (t.prompt_tokens != null)
|
|
710
|
-
parts.push(`in: ${formatTokens(t.prompt_tokens)}`);
|
|
711
|
-
if (t.completion_tokens != null)
|
|
712
|
-
parts.push(`out: ${formatTokens(t.completion_tokens)}`);
|
|
713
|
-
console.log(` ${t.id}: ${parts.join(' | ')}`);
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
finally {
|
|
719
|
-
store.close();
|
|
720
|
-
}
|
|
721
|
-
return;
|
|
280
|
+
catch (err) {
|
|
281
|
+
return fail(`${args.spec}: ${err.message}`);
|
|
722
282
|
}
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
console.error(' Run a convoy spec first: opencastle convoy run -f convoy.yml');
|
|
728
|
-
process.exit(1);
|
|
729
|
-
}
|
|
730
|
-
const { createConvoyStore } = await import('./convoy/store.js');
|
|
731
|
-
const store = createConvoyStore(dbPath);
|
|
732
|
-
const convoy = store.getLatestConvoy();
|
|
733
|
-
const retryTasks = convoy ? store.getTasksByConvoy(convoy.id) : [];
|
|
734
|
-
store.close();
|
|
735
|
-
if (!convoy) {
|
|
736
|
-
console.error(' ✗ No convoy records found in .opencastle/convoy.db');
|
|
737
|
-
process.exit(1);
|
|
738
|
-
}
|
|
739
|
-
// Before adapter detection: a preview should not require an agent CLI to be
|
|
740
|
-
// installed, and it must return before anything is executed.
|
|
741
|
-
if (opts.dryRun) {
|
|
742
|
-
printRunDryRun('retry', 'OpenCastle Convoy (Retry Failed)', convoy.name, opts.retryFailedTaskIds?.length
|
|
743
|
-
? retryTasks.filter((t) => opts.retryFailedTaskIds.includes(t.id))
|
|
744
|
-
: retryTasks, RETRYABLE_TASK_STATUSES);
|
|
745
|
-
return;
|
|
746
|
-
}
|
|
747
|
-
const retrySpec = parseTaskSpecText(convoy.spec_yaml);
|
|
748
|
-
applyCliOverrides(retrySpec, opts);
|
|
749
|
-
let retryDetectionFailed = false;
|
|
750
|
-
if (!retrySpec.adapter) {
|
|
751
|
-
const detected = await detectAdapter();
|
|
752
|
-
if (detected) {
|
|
753
|
-
retrySpec.adapter = detected;
|
|
754
|
-
console.log(` ℹ Auto-detected adapter: ${detected}`);
|
|
755
|
-
}
|
|
756
|
-
else {
|
|
757
|
-
retryDetectionFailed = true;
|
|
758
|
-
retrySpec.adapter = 'claude';
|
|
759
|
-
}
|
|
760
|
-
}
|
|
761
|
-
const retryAdapter = await getAdapter(retrySpec.adapter);
|
|
762
|
-
const retryAvailable = await retryAdapter.isAvailable();
|
|
763
|
-
if (!retryAvailable) {
|
|
764
|
-
printAdapterError(retryDetectionFailed, retrySpec.adapter);
|
|
765
|
-
process.exit(1);
|
|
766
|
-
}
|
|
767
|
-
assertPermissionModeSupported(retrySpec.adapter, retrySpec);
|
|
768
|
-
console.log(`\n 🏰 OpenCastle Convoy (Retry Failed): ${convoy.name}`);
|
|
769
|
-
console.log(` Convoy ID: ${convoy.id}`);
|
|
770
|
-
const { startDashboardServer } = await import('./dashboard.js');
|
|
771
|
-
let retryDashboardResult = null;
|
|
283
|
+
const projectRoot = projectRootHere();
|
|
284
|
+
let runtime = opts.runtime ?? null;
|
|
285
|
+
let runtimeProblem = null;
|
|
286
|
+
if (!runtime) {
|
|
772
287
|
try {
|
|
773
|
-
|
|
774
|
-
pkgRoot,
|
|
775
|
-
openBrowser: true,
|
|
776
|
-
convoyId: 'active',
|
|
777
|
-
});
|
|
778
|
-
}
|
|
779
|
-
catch {
|
|
780
|
-
// Dashboard failure must not block convoy
|
|
781
|
-
}
|
|
782
|
-
if (retryDashboardResult) {
|
|
783
|
-
console.log(` ${c.dim('Dashboard:')} ${retryDashboardResult.url}`);
|
|
784
|
-
}
|
|
785
|
-
const { createConvoyEngine } = await import('./convoy/engine.js');
|
|
786
|
-
const retryEngine = createConvoyEngine({
|
|
787
|
-
spec: retrySpec,
|
|
788
|
-
specYaml: convoy.spec_yaml,
|
|
789
|
-
adapter: retryAdapter,
|
|
790
|
-
verbose: opts.verbose,
|
|
791
|
-
});
|
|
792
|
-
await retryEngine.retryFailed(convoy.id, opts.retryFailedTaskIds);
|
|
793
|
-
let retryResult;
|
|
794
|
-
try {
|
|
795
|
-
retryResult = await retryEngine.resume(convoy.id);
|
|
288
|
+
runtime = await chooseRuntime(projectRoot, args.adapter, spec);
|
|
796
289
|
}
|
|
797
290
|
catch (err) {
|
|
798
|
-
|
|
799
|
-
console.error(` ✗ ${err.message}`);
|
|
800
|
-
process.exit(1);
|
|
801
|
-
}
|
|
802
|
-
throw err;
|
|
291
|
+
runtimeProblem = err.message;
|
|
803
292
|
}
|
|
804
|
-
printConvoyResult(retryResult);
|
|
805
|
-
return finishRun(retryDashboardResult, retryResult.status !== 'done');
|
|
806
293
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
console.error(' ✗ No convoy database found at .opencastle/convoy.db');
|
|
811
|
-
console.error(' Run a convoy spec first: opencastle convoy run -f convoy.yml');
|
|
812
|
-
process.exit(1);
|
|
813
|
-
}
|
|
814
|
-
const { createConvoyStore } = await import('./convoy/store.js');
|
|
815
|
-
const store = createConvoyStore(dbPath);
|
|
816
|
-
const { selectResumableRun } = await import('./convoy/last-run.js');
|
|
817
|
-
const selected = selectResumableRun(store);
|
|
818
|
-
if (!selected) {
|
|
819
|
-
store.close();
|
|
820
|
-
console.error(' ✗ No convoy records found in .opencastle/convoy.db');
|
|
821
|
-
process.exit(1);
|
|
822
|
-
}
|
|
823
|
-
// Whichever run was started most recently, and only if it can be continued.
|
|
824
|
-
// Preferring pipelines unconditionally meant a standalone convoy could never
|
|
825
|
-
// be resumed once the project had run one, and the status screen — which
|
|
826
|
-
// reads the same selector — named a different run than this command resumed.
|
|
827
|
-
if (!selected.resumable) {
|
|
828
|
-
store.close();
|
|
829
|
-
const { kind, record } = selected.run;
|
|
830
|
-
console.error(` ✗ Last ${kind} "${record.name}" already finished with status: ${record.status}`);
|
|
831
|
-
console.error(kind === 'pipeline'
|
|
832
|
-
? ' Only interrupted (running/pending/failed) pipelines can be resumed.'
|
|
833
|
-
: ' Only interrupted (running/pending) convoys can be resumed.');
|
|
834
|
-
if (kind === 'convoy' && record.status === 'failed') {
|
|
835
|
-
console.error(`\n To re-run its failed tasks: opencastle convoy retry`);
|
|
836
|
-
}
|
|
837
|
-
process.exit(1);
|
|
838
|
-
}
|
|
839
|
-
// Before adapter detection, and before either orchestrator is constructed.
|
|
840
|
-
if (opts.dryRun) {
|
|
841
|
-
const previewIds = selected.run.kind === 'pipeline'
|
|
842
|
-
? store.getConvoysByPipeline(selected.run.record.id).map((c) => c.id)
|
|
843
|
-
: [selected.run.record.id];
|
|
844
|
-
const previewTasks = previewIds.flatMap((id) => store.getTasksByConvoy(id));
|
|
845
|
-
store.close();
|
|
846
|
-
printRunDryRun('resume', selected.run.kind === 'pipeline'
|
|
847
|
-
? 'OpenCastle Pipeline (Resume)'
|
|
848
|
-
: 'OpenCastle Convoy (Resume)', selected.run.record.name, previewTasks, RESUMABLE_TASK_STATUSES);
|
|
849
|
-
return;
|
|
850
|
-
}
|
|
851
|
-
const latestPipeline = selected.run.kind === 'pipeline' ? selected.run.record : null;
|
|
852
|
-
// ── Pipeline resume (pending / running / failed) ────────────
|
|
853
|
-
if (latestPipeline) {
|
|
854
|
-
store.close();
|
|
855
|
-
const resumePipelineSpec = parseTaskSpecText(latestPipeline.spec_yaml);
|
|
856
|
-
applyCliOverrides(resumePipelineSpec, opts);
|
|
857
|
-
let resumePipelineDetectionFailed = false;
|
|
858
|
-
if (!resumePipelineSpec.adapter) {
|
|
859
|
-
const detected = await detectAdapter();
|
|
860
|
-
if (detected) {
|
|
861
|
-
resumePipelineSpec.adapter = detected;
|
|
862
|
-
console.log(` ℹ Auto-detected adapter: ${detected}`);
|
|
863
|
-
}
|
|
864
|
-
else {
|
|
865
|
-
resumePipelineDetectionFailed = true;
|
|
866
|
-
resumePipelineSpec.adapter = 'claude';
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
const resumePipelineAdapter = await getAdapter(resumePipelineSpec.adapter);
|
|
870
|
-
const resumePipelineAvailable = await resumePipelineAdapter.isAvailable();
|
|
871
|
-
if (!resumePipelineAvailable) {
|
|
872
|
-
printAdapterError(resumePipelineDetectionFailed, resumePipelineSpec.adapter);
|
|
873
|
-
process.exit(1);
|
|
874
|
-
}
|
|
875
|
-
assertPermissionModeSupported(resumePipelineSpec.adapter, resumePipelineSpec);
|
|
876
|
-
console.log(`\n 🏰 OpenCastle Pipeline (Resume): ${latestPipeline.name}`);
|
|
877
|
-
console.log(` Pipeline ID: ${latestPipeline.id}`);
|
|
878
|
-
const { startDashboardServer } = await import('./dashboard.js');
|
|
879
|
-
let resumePipelineDashResult = null;
|
|
880
|
-
try {
|
|
881
|
-
resumePipelineDashResult = await startDashboardServer({
|
|
882
|
-
pkgRoot,
|
|
883
|
-
openBrowser: true,
|
|
884
|
-
convoyId: 'active',
|
|
885
|
-
});
|
|
886
|
-
}
|
|
887
|
-
catch {
|
|
888
|
-
// Dashboard failure must not block pipeline
|
|
889
|
-
}
|
|
890
|
-
if (resumePipelineDashResult) {
|
|
891
|
-
console.log(` ${c.dim('Dashboard:')} ${resumePipelineDashResult.url}`);
|
|
892
|
-
}
|
|
893
|
-
const { createPipelineOrchestrator } = await import('./convoy/pipeline.js');
|
|
894
|
-
const resumePipelineOrchestrator = createPipelineOrchestrator({
|
|
895
|
-
spec: resumePipelineSpec,
|
|
896
|
-
specYaml: latestPipeline.spec_yaml,
|
|
897
|
-
adapter: resumePipelineAdapter,
|
|
898
|
-
verbose: opts.verbose,
|
|
899
|
-
});
|
|
900
|
-
const resumePipelineResult = await resumePipelineOrchestrator.resume(latestPipeline.id);
|
|
901
|
-
printPipelineResult(resumePipelineResult);
|
|
902
|
-
return finishRun(resumePipelineDashResult, resumePipelineResult.status !== 'done');
|
|
903
|
-
}
|
|
904
|
-
// ── Standalone convoy resume ────────────────────────────────
|
|
905
|
-
// Selection and the finished-run refusal both happened above, against the
|
|
906
|
-
// one selector. This branch only executes what was chosen.
|
|
907
|
-
const convoy = selected.run.record;
|
|
908
|
-
store.close();
|
|
909
|
-
const resumeSpec = parseTaskSpecText(convoy.spec_yaml);
|
|
910
|
-
applyCliOverrides(resumeSpec, opts);
|
|
911
|
-
let resumeDetectionFailed = false;
|
|
912
|
-
if (!resumeSpec.adapter) {
|
|
913
|
-
const detected = await detectAdapter();
|
|
914
|
-
if (detected) {
|
|
915
|
-
resumeSpec.adapter = detected;
|
|
916
|
-
console.log(` ℹ Auto-detected adapter: ${detected}`);
|
|
917
|
-
}
|
|
918
|
-
else {
|
|
919
|
-
resumeDetectionFailed = true;
|
|
920
|
-
resumeSpec.adapter = 'claude';
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
const resumeAdapter = await getAdapter(resumeSpec.adapter);
|
|
924
|
-
const resumeAvailable = await resumeAdapter.isAvailable();
|
|
925
|
-
if (!resumeAvailable) {
|
|
926
|
-
printAdapterError(resumeDetectionFailed, resumeSpec.adapter);
|
|
927
|
-
process.exit(1);
|
|
928
|
-
}
|
|
929
|
-
assertPermissionModeSupported(resumeSpec.adapter, resumeSpec);
|
|
930
|
-
console.log(`\n \uD83C\uDFF0 OpenCastle Convoy (Resume): ${convoy.name}`);
|
|
931
|
-
console.log(` Convoy ID: ${convoy.id}`);
|
|
932
|
-
const { startDashboardServer } = await import('./dashboard.js');
|
|
933
|
-
let resumeDashResult = null;
|
|
294
|
+
if (args.dryRun) {
|
|
295
|
+
// The engine's own check, so a dry run refuses exactly what a run refuses.
|
|
296
|
+
// Nothing is started and nothing is written to the database.
|
|
934
297
|
try {
|
|
935
|
-
|
|
936
|
-
pkgRoot,
|
|
937
|
-
openBrowser: true,
|
|
938
|
-
convoyId: 'active',
|
|
939
|
-
});
|
|
940
|
-
}
|
|
941
|
-
catch {
|
|
942
|
-
// Dashboard failure must not block convoy
|
|
943
|
-
}
|
|
944
|
-
if (resumeDashResult) {
|
|
945
|
-
console.log(` ${c.dim('Dashboard:')} ${resumeDashResult.url}`);
|
|
946
|
-
}
|
|
947
|
-
const { createConvoyEngine } = await import('./convoy/engine.js');
|
|
948
|
-
const resumeEngine = createConvoyEngine({
|
|
949
|
-
spec: resumeSpec,
|
|
950
|
-
specYaml: convoy.spec_yaml,
|
|
951
|
-
adapter: resumeAdapter,
|
|
952
|
-
verbose: opts.verbose,
|
|
953
|
-
});
|
|
954
|
-
let resumeResult;
|
|
955
|
-
try {
|
|
956
|
-
resumeResult = await resumeEngine.resume(convoy.id);
|
|
298
|
+
await checkConvoyPlan(spec, runtime?.name ?? (spec.adapter || 'auto'));
|
|
957
299
|
}
|
|
958
300
|
catch (err) {
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
301
|
+
return fail(err.message);
|
|
302
|
+
}
|
|
303
|
+
if (runtime)
|
|
304
|
+
applyArgs(spec, args, runtime.name);
|
|
305
|
+
else if (args.concurrency !== null)
|
|
306
|
+
spec.concurrency = args.concurrency;
|
|
307
|
+
console.log('');
|
|
308
|
+
for (const l of describePlan(spec, runtime?.detail ?? c.red('none usable — see below')))
|
|
309
|
+
console.log(l);
|
|
310
|
+
console.log('');
|
|
311
|
+
if (runtimeProblem)
|
|
312
|
+
return fail(runtimeProblem);
|
|
313
|
+
const problem = spec.defaults?.permission_mode ? permissionModeError(runtime.name, spec.defaults.permission_mode) : null;
|
|
314
|
+
if (problem)
|
|
315
|
+
return fail(problem);
|
|
316
|
+
console.log(` ${c.dim('Dry run — nothing started, nothing recorded. To run it:')} opencastle convoy run ${args.spec}`);
|
|
317
|
+
console.log('');
|
|
318
|
+
return 0;
|
|
319
|
+
}
|
|
320
|
+
if (!runtime)
|
|
321
|
+
return fail(runtimeProblem);
|
|
322
|
+
const problem = spec.defaults?.permission_mode ? permissionModeError(runtime.name, spec.defaults.permission_mode) : null;
|
|
323
|
+
if (problem)
|
|
324
|
+
return fail(problem);
|
|
325
|
+
applyArgs(spec, args, runtime.name);
|
|
326
|
+
console.log('');
|
|
327
|
+
console.log(` ${c.bold(`Convoy: ${spec.name}`)} ${c.dim(`— ${spec.tasks?.length ?? 0} tasks`)}`);
|
|
328
|
+
if (!opts.runtime)
|
|
329
|
+
console.log(` ${c.dim('Runtime:')} ${runtime.detail}`);
|
|
330
|
+
const models = describeModels(spec, runtime);
|
|
331
|
+
if (models)
|
|
332
|
+
console.log(` ${c.dim('Models:')} ${models}`);
|
|
333
|
+
const engine = createConvoyEngine({ spec, specYaml: specText, adapter: runtime.adapter, verbose: args.verbose, basePath: projectRoot });
|
|
334
|
+
return drive(() => engine.run(), projectRoot);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Which model the tasks run on, said once before they start: a run that picks
|
|
338
|
+
* models by tier spends far less than one on the runtime's default, and a
|
|
339
|
+
* person should be able to see which happened.
|
|
340
|
+
*/
|
|
341
|
+
function describeModels(spec, runtime) {
|
|
342
|
+
if (spec.defaults?.model)
|
|
343
|
+
return `${spec.defaults.model} for every task (defaults.model)`;
|
|
344
|
+
const t = runtime.adapter.tierModels;
|
|
345
|
+
if (!t)
|
|
346
|
+
return null;
|
|
347
|
+
return `by agent tier — ${[t.premium && `premium ${t.premium}`, t.standard && `standard ${t.standard}`, t.economy && `economy ${t.economy} (and reviews)`].filter(Boolean).join(', ')}`;
|
|
348
|
+
}
|
|
349
|
+
// ── convoy resume ─────────────────────────────────────────────────────────────
|
|
350
|
+
/** Not done: a status other than done, or a task that did not finish (older runs ended "done" with tasks skipped). */
|
|
351
|
+
function unfinished(run) {
|
|
352
|
+
return run.status !== 'done' || run.tasks_done < run.tasks_total;
|
|
353
|
+
}
|
|
354
|
+
/** `convoy resume`: the exit code it should end with. */
|
|
355
|
+
export async function resumeLast(args) {
|
|
356
|
+
const projectRoot = projectRootHere();
|
|
357
|
+
const runs = readRuns(projectRoot, 200);
|
|
358
|
+
if (runs.length === 0) {
|
|
359
|
+
console.error(` ${c.red('✗')} No convoy runs in this project yet.`);
|
|
360
|
+
console.error(` ${c.dim('Start one:')} opencastle convoy "<task>"`);
|
|
361
|
+
return 1;
|
|
967
362
|
}
|
|
968
|
-
|
|
969
|
-
|
|
363
|
+
const target = runs.find(unfinished);
|
|
364
|
+
if (!target) {
|
|
365
|
+
const last = runs[0];
|
|
366
|
+
console.log(` Nothing to resume: the last run, ${c.bold(last.name)}, finished with all ${last.tasks_total} tasks done.`);
|
|
367
|
+
console.log(` ${c.dim('Start another:')} opencastle convoy "<task>"`);
|
|
368
|
+
return 0;
|
|
369
|
+
}
|
|
370
|
+
if (isRunAlive(projectRoot, target.id)) {
|
|
371
|
+
console.error(` ${c.red('✗')} ${target.name} (${target.id}) is still running in another process.`);
|
|
372
|
+
console.error(` ${c.dim('Watch it:')} opencastle convoy dashboard`);
|
|
373
|
+
return 1;
|
|
374
|
+
}
|
|
375
|
+
const recorded = readRunSpec(projectRoot, target.id);
|
|
376
|
+
if (!recorded)
|
|
377
|
+
return fail(`The spec ${target.id} was started with is not in .opencastle/convoy.db.`);
|
|
970
378
|
let spec;
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
const formulaPath = resolve(process.cwd(), opts.formula);
|
|
974
|
-
let template;
|
|
975
|
-
try {
|
|
976
|
-
template = parseFormula(formulaPath);
|
|
977
|
-
}
|
|
978
|
-
catch (err) {
|
|
979
|
-
console.error(` ✗ ${err.message}`);
|
|
980
|
-
console.log(`\n ${c.dim('Resume:')} npx opencastle convoy run --formula ${opts.formula}`);
|
|
981
|
-
process.exit(1);
|
|
982
|
-
}
|
|
983
|
-
const validation = validateTemplate(template);
|
|
984
|
-
if (!validation.valid) {
|
|
985
|
-
console.error(` ✗ Invalid formula template:\n • ${validation.errors.join('\n • ')}`);
|
|
986
|
-
console.log(`\n ${c.dim('Resume:')} npx opencastle convoy run --formula ${opts.formula}`);
|
|
987
|
-
process.exit(1);
|
|
988
|
-
}
|
|
989
|
-
if (opts.dryRun) {
|
|
990
|
-
console.log(`\n 📋 Formula: ${template.name}`);
|
|
991
|
-
if (template.description)
|
|
992
|
-
console.log(` ${template.description}`);
|
|
993
|
-
console.log(` Variables:`);
|
|
994
|
-
for (const [key, val] of Object.entries(opts.setVars)) {
|
|
995
|
-
console.log(` ${key} = ${val}`);
|
|
996
|
-
}
|
|
997
|
-
for (const [key, def] of Object.entries(template.variables)) {
|
|
998
|
-
if (!(key in opts.setVars) && !def.required && def.default) {
|
|
999
|
-
console.log(` ${key} = ${def.default} (default)`);
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
try {
|
|
1004
|
-
spec = substituteVariables(template, opts.setVars);
|
|
1005
|
-
}
|
|
1006
|
-
catch (err) {
|
|
1007
|
-
console.error(` ✗ ${err.message}`);
|
|
1008
|
-
console.log(`\n ${c.dim('Resume:')} npx opencastle convoy run --formula ${opts.formula}`);
|
|
1009
|
-
process.exit(1);
|
|
1010
|
-
}
|
|
1011
|
-
specText = yamlStringify(spec);
|
|
379
|
+
try {
|
|
380
|
+
spec = parseTaskSpecText(recorded.specYaml);
|
|
1012
381
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
if (e.code === 'ENOENT') {
|
|
1022
|
-
console.error(` ✗ Task spec file not found: ${opts.file}`);
|
|
1023
|
-
}
|
|
1024
|
-
else {
|
|
1025
|
-
console.error(` ✗ Cannot read task spec file: ${e.message}`);
|
|
1026
|
-
}
|
|
1027
|
-
console.log(`\n ${c.dim('Resume:')} npx opencastle convoy run -f ${opts.file}`);
|
|
1028
|
-
process.exit(1);
|
|
1029
|
-
}
|
|
1030
|
-
try {
|
|
1031
|
-
spec = parseTaskSpecText(specText);
|
|
1032
|
-
}
|
|
1033
|
-
catch (err) {
|
|
1034
|
-
console.error(` ✗ ${err.message}`);
|
|
1035
|
-
console.log(`\n ${c.dim('Resume:')} npx opencastle convoy run -f ${opts.file}`);
|
|
1036
|
-
process.exit(1);
|
|
1037
|
-
}
|
|
382
|
+
catch (err) {
|
|
383
|
+
return fail(`The spec ${target.name} was recorded with no longer reads: ${err.message}`);
|
|
384
|
+
}
|
|
385
|
+
const done = `${target.tasks_done}/${target.tasks_total} tasks done`;
|
|
386
|
+
console.log('');
|
|
387
|
+
console.log(` ${c.bold(`Resuming ${target.name}`)} ${c.dim(`(${target.id}) — ${target.status}, ${done}`)}`);
|
|
388
|
+
if (target !== runs[0]) {
|
|
389
|
+
console.log(` ${c.dim(`The newest run, ${runs[0].name}, finished; this is the newest one that did not.`)}`);
|
|
1038
390
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
if (detected) {
|
|
1048
|
-
spec.adapter = detected;
|
|
1049
|
-
console.log(` ℹ Auto-detected adapter: ${detected}`);
|
|
391
|
+
if (args.dryRun) {
|
|
392
|
+
// Read from the read model: a preview opens nothing that could migrate or write.
|
|
393
|
+
const tasks = readRun(projectRoot, target.id)?.tasks ?? [];
|
|
394
|
+
const again = new Set(['pending', ...RESUME_RESET_STATUSES]);
|
|
395
|
+
const selected = tasks.filter((t) => again.has(t.status));
|
|
396
|
+
console.log('');
|
|
397
|
+
if (selected.length === 0) {
|
|
398
|
+
console.log(' No task would run: every task is done.');
|
|
1050
399
|
}
|
|
1051
400
|
else {
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
401
|
+
console.log(` Would run ${selected.length} of ${tasks.length} task(s):`);
|
|
402
|
+
for (const t of selected)
|
|
403
|
+
console.log(` ${t.id} ${c.dim(`— ${t.agent} [${t.status}]`)}`);
|
|
404
|
+
}
|
|
405
|
+
console.log('');
|
|
406
|
+
console.log(` ${c.dim('Dry run — nothing started, nothing recorded.')}`);
|
|
407
|
+
console.log('');
|
|
408
|
+
return 0;
|
|
1055
409
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
console.log(`\n 🏰 Pipeline Plan: ${spec.name}`);
|
|
1060
|
-
console.log(` Convoy chain: ${spec.depends_on_convoy.join(' → ')}`);
|
|
1061
|
-
if (spec.tasks?.length) {
|
|
1062
|
-
console.log(` Plus ${spec.tasks.length} local tasks after chain completes`);
|
|
1063
|
-
}
|
|
1064
|
-
if (spec.branch)
|
|
1065
|
-
console.log(` Branch: ${spec.branch}`);
|
|
1066
|
-
if (spec.gates?.length)
|
|
1067
|
-
console.log(` Gates: ${spec.gates.length} validation commands`);
|
|
1068
|
-
if (!spec.tasks?.length)
|
|
1069
|
-
return;
|
|
1070
|
-
}
|
|
1071
|
-
else if (isConvoySpec(spec)) {
|
|
1072
|
-
console.log(`\n \uD83C\uDFF0 Convoy Plan: ${spec.name}`);
|
|
1073
|
-
console.log(` Adapter: ${spec.adapter} | Concurrency: ${spec.concurrency} | Tasks: ${spec.tasks.length}`);
|
|
1074
|
-
if (spec.branch)
|
|
1075
|
-
console.log(` Branch: ${spec.branch}`);
|
|
1076
|
-
if (spec.gates?.length)
|
|
1077
|
-
console.log(` Gates: ${spec.gates.length} validation commands`);
|
|
1078
|
-
}
|
|
1079
|
-
const phases = buildPhases(spec.tasks);
|
|
1080
|
-
printExecutionPlan(spec, phases);
|
|
1081
|
-
return;
|
|
410
|
+
let runtime;
|
|
411
|
+
try {
|
|
412
|
+
runtime = await chooseRuntime(projectRoot, args.adapter, spec, recorded.adapter);
|
|
1082
413
|
}
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
const available = await adapter.isAvailable();
|
|
1086
|
-
if (!available) {
|
|
1087
|
-
printAdapterError(detectionFailed, spec.adapter);
|
|
1088
|
-
console.log(`\n ${c.dim('Resume:')} npx opencastle convoy run -f ${opts.file}`);
|
|
1089
|
-
process.exit(1);
|
|
414
|
+
catch (err) {
|
|
415
|
+
return fail(err.message);
|
|
1090
416
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
adapter,
|
|
1120
|
-
verbose: opts.verbose,
|
|
1121
|
-
});
|
|
1122
|
-
let pipelineResult;
|
|
1123
|
-
try {
|
|
1124
|
-
pipelineResult = await pipelineOrchestrator.run();
|
|
1125
|
-
}
|
|
1126
|
-
catch (err) {
|
|
1127
|
-
if (err instanceof EngineAlreadyRunningError) {
|
|
1128
|
-
console.error(` ✗ ${err.message}`);
|
|
1129
|
-
console.log(`\n ${c.dim('Resume:')} npx opencastle convoy run -f ${opts.file} --resume`);
|
|
1130
|
-
process.exit(1);
|
|
1131
|
-
}
|
|
1132
|
-
throw err;
|
|
1133
|
-
}
|
|
1134
|
-
printPipelineResult(pipelineResult);
|
|
1135
|
-
return finishRun(pipelineDashboardResult, pipelineResult.status !== 'done', `npx opencastle convoy run -f ${opts.file} --retry-failed`);
|
|
417
|
+
const problem = spec.defaults?.permission_mode ? permissionModeError(runtime.name, spec.defaults.permission_mode) : null;
|
|
418
|
+
if (problem)
|
|
419
|
+
return fail(problem);
|
|
420
|
+
applyArgs(spec, args, runtime.name);
|
|
421
|
+
console.log(` ${c.dim('Runtime:')} ${runtime.detail}`);
|
|
422
|
+
const models = describeModels(spec, runtime);
|
|
423
|
+
if (models)
|
|
424
|
+
console.log(` ${c.dim('Models:')} ${models}`);
|
|
425
|
+
const engine = createConvoyEngine({ spec, specYaml: recorded.specYaml, adapter: runtime.adapter, verbose: args.verbose, basePath: projectRoot });
|
|
426
|
+
return drive(() => engine.resume(target.id), projectRoot);
|
|
427
|
+
}
|
|
428
|
+
// ── Entry points ──────────────────────────────────────────────────────────────
|
|
429
|
+
/**
|
|
430
|
+
* Exit once what was written has reached the terminal or the pipe. Exiting is
|
|
431
|
+
* deliberate: a finished run must never sit waiting for Ctrl+C because some
|
|
432
|
+
* handle — a socket, a timer, an agent's pipe — was left open.
|
|
433
|
+
*/
|
|
434
|
+
export function exitWith(code) {
|
|
435
|
+
process.exitCode = code;
|
|
436
|
+
process.stdout.write('', () => process.stderr.write('', () => process.exit(code)));
|
|
437
|
+
}
|
|
438
|
+
async function main(args, command) {
|
|
439
|
+
const parsed = parseRunArgs(args, command);
|
|
440
|
+
if ('error' in parsed) {
|
|
441
|
+
console.error(` ${c.red('✗')} ${parsed.error}`);
|
|
442
|
+
console.error(` Run "opencastle convoy ${command} --help" for usage.`);
|
|
443
|
+
exitWith(1);
|
|
444
|
+
return;
|
|
1136
445
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
console.log(`\n \uD83C\uDFF0 OpenCastle Convoy: ${spec.name}`);
|
|
1141
|
-
console.log(` Adapter: ${adapter.name} | Concurrency: ${spec.concurrency} | Tasks: ${spec.tasks.length}`);
|
|
1142
|
-
if (spec.branch)
|
|
1143
|
-
console.log(` Branch: ${spec.branch}`);
|
|
1144
|
-
if (spec.gates?.length)
|
|
1145
|
-
console.log(` Gates: ${spec.gates.length} validation commands`);
|
|
1146
|
-
const { startDashboardServer } = await import('./dashboard.js');
|
|
1147
|
-
let dashboardResult = null;
|
|
1148
|
-
try {
|
|
1149
|
-
dashboardResult = await startDashboardServer({
|
|
1150
|
-
pkgRoot,
|
|
1151
|
-
openBrowser: true,
|
|
1152
|
-
convoyId: 'active',
|
|
1153
|
-
});
|
|
1154
|
-
}
|
|
1155
|
-
catch {
|
|
1156
|
-
// Dashboard failure must not block convoy
|
|
1157
|
-
}
|
|
1158
|
-
if (dashboardResult) {
|
|
1159
|
-
console.log(` ${c.dim('Dashboard:')} ${dashboardResult.url}`);
|
|
1160
|
-
}
|
|
1161
|
-
const engine = createConvoyEngine({
|
|
1162
|
-
spec,
|
|
1163
|
-
specYaml: specText,
|
|
1164
|
-
adapter,
|
|
1165
|
-
verbose: opts.verbose,
|
|
1166
|
-
});
|
|
1167
|
-
if (opts.watch) {
|
|
1168
|
-
const pidPath = resolve(process.cwd(), '.opencastle', 'watch.pid');
|
|
1169
|
-
const { watchLoop } = await import('./watch.js');
|
|
1170
|
-
await watchLoop({
|
|
1171
|
-
spec,
|
|
1172
|
-
specText,
|
|
1173
|
-
specPath: resolve(process.cwd(), opts.file),
|
|
1174
|
-
adapter,
|
|
1175
|
-
verbose: opts.verbose,
|
|
1176
|
-
pidPath,
|
|
1177
|
-
clearScratchpad: opts.clearScratchpad,
|
|
1178
|
-
watchConfigPath: opts.watchConfig ? resolve(process.cwd(), opts.watchConfig) : null,
|
|
1179
|
-
printResult: printConvoyResult,
|
|
1180
|
-
});
|
|
1181
|
-
return;
|
|
1182
|
-
}
|
|
1183
|
-
let result;
|
|
1184
|
-
try {
|
|
1185
|
-
result = await engine.run();
|
|
1186
|
-
}
|
|
1187
|
-
catch (err) {
|
|
1188
|
-
if (err instanceof EngineAlreadyRunningError) {
|
|
1189
|
-
console.error(` ✗ ${err.message}`);
|
|
1190
|
-
console.log(`\n ${c.dim('Resume:')} npx opencastle convoy run -f ${opts.file} --resume`);
|
|
1191
|
-
process.exit(1);
|
|
1192
|
-
}
|
|
1193
|
-
throw err;
|
|
1194
|
-
}
|
|
1195
|
-
printConvoyResult(result);
|
|
1196
|
-
return finishRun(dashboardResult, result.status !== 'done', `npx opencastle convoy run -f ${opts.file} --retry-failed`);
|
|
446
|
+
if (parsed.help) {
|
|
447
|
+
console.log(command === 'run' ? RUN_HELP : RESUME_HELP);
|
|
448
|
+
return;
|
|
1197
449
|
}
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
const executor = createExecutor(spec, adapter, reporter);
|
|
1208
|
-
const report = await executor.run();
|
|
1209
|
-
// ── Exit code ────────────────────────────────────────────────
|
|
1210
|
-
const hasFailures = report.summary.failed > 0 || report.summary['timed-out'] > 0;
|
|
1211
|
-
process.exit(hasFailures ? 1 : 0);
|
|
450
|
+
exitWith(command === 'run' ? await runSpec(parsed) : await resumeLast(parsed));
|
|
451
|
+
}
|
|
452
|
+
/** `opencastle convoy run <spec.yml>`. */
|
|
453
|
+
export default async function run({ args }) {
|
|
454
|
+
await main(args, 'run');
|
|
455
|
+
}
|
|
456
|
+
/** `opencastle convoy resume`, and its hidden alias `retry`. */
|
|
457
|
+
export async function resume({ args }) {
|
|
458
|
+
await main(args, 'resume');
|
|
1212
459
|
}
|
|
1213
460
|
//# sourceMappingURL=run.js.map
|