opencastle 1.3.1 → 1.4.1
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 +16 -10
- package/bin/cli.mjs +8 -9
- package/dist/cli/agent-roster.test.js +0 -48
- package/dist/cli/agent-roster.test.js.map +1 -1
- package/dist/cli/boundary.test.js +9 -7
- package/dist/cli/boundary.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 -201
- 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 +35 -2
- package/dist/cli/dispatcher.test.js.map +1 -1
- package/dist/cli/docs-accuracy.test.js +3 -3
- package/dist/cli/docs-accuracy.test.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/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/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/package.json +3 -10
- package/src/cli/agent-roster.test.ts +0 -55
- package/src/cli/boundary.test.ts +9 -7
- package/src/cli/convoy/TELEMETRY.md +131 -125
- 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 -216
- 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 +36 -2
- package/src/cli/docs-accuracy.test.ts +3 -3
- 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/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/team-config.ts +2 -21
- package/src/cli/tiers.test.ts +4 -17
- package/src/orchestrator/agents/team-lead.agent.md +1 -1
- package/src/orchestrator/prompts/assess-complexity.prompt.md +43 -26
- package/src/orchestrator/prompts/brainstorm.prompt.md +1 -1
- package/src/orchestrator/prompts/bug-fix.prompt.md +2 -2
- 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 +2 -2
- 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
|
@@ -76,8 +76,8 @@ export function writeArtifact(
|
|
|
76
76
|
return { task_id: taskId, convoy_id: convoyId, filename: safeFilename, type, size_bytes, summary, path: filePath }
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export function listArtifacts(convoyId: string, taskId: string): ArtifactRef[] {
|
|
80
|
-
const dir = getArtifactDir(convoyId, taskId)
|
|
79
|
+
export function listArtifacts(convoyId: string, taskId: string, basePath?: string): ArtifactRef[] {
|
|
80
|
+
const dir = getArtifactDir(convoyId, taskId, basePath)
|
|
81
81
|
if (!existsSync(dir)) return []
|
|
82
82
|
|
|
83
83
|
const refs: ArtifactRef[] = []
|
|
@@ -111,7 +111,14 @@ export function readArtifact(ref: ArtifactRef): string {
|
|
|
111
111
|
return readFileSync(ref.path, 'utf8')
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
|
|
114
|
+
/**
|
|
115
|
+
* The artifacts an agent's answer points at that actually exist.
|
|
116
|
+
*
|
|
117
|
+
* A reference to a missing file is dropped rather than reported on stderr: the
|
|
118
|
+
* engine prints a status line on the same terminal, and the answer itself is
|
|
119
|
+
* stored for anyone who wants to see what the agent claimed.
|
|
120
|
+
*/
|
|
121
|
+
export function extractArtifactRefs(taskId: string, convoyId: string, output: string, basePath?: string): ArtifactRef[] {
|
|
115
122
|
const pattern = /\[ARTIFACT:\s*([^\]]+)\]\s*(.+)/g
|
|
116
123
|
const refs: ArtifactRef[] = []
|
|
117
124
|
let match: RegExpExecArray | null
|
|
@@ -121,18 +128,12 @@ export function extractArtifactRefs(taskId: string, convoyId: string, output: st
|
|
|
121
128
|
const filename = basename(match[1].trim())
|
|
122
129
|
const summary = match[2].trim()
|
|
123
130
|
|
|
124
|
-
if (!filename || filename === '..')
|
|
125
|
-
process.stderr.write('[artifacts] Warning: invalid artifact filename from agent output\n')
|
|
126
|
-
continue
|
|
127
|
-
}
|
|
131
|
+
if (!filename || filename === '..') continue
|
|
128
132
|
|
|
129
|
-
const dir = getArtifactDir(convoyId, taskId)
|
|
133
|
+
const dir = getArtifactDir(convoyId, taskId, basePath)
|
|
130
134
|
const filePath = join(dir, filename)
|
|
131
135
|
|
|
132
|
-
if (!existsSync(filePath))
|
|
133
|
-
process.stderr.write(`[artifacts] Warning: referenced artifact not found: ${filePath}\n`)
|
|
134
|
-
continue
|
|
135
|
-
}
|
|
136
|
+
if (!existsSync(filePath)) continue
|
|
136
137
|
|
|
137
138
|
refs.push({ task_id: taskId, filename, summary, path: filePath })
|
|
138
139
|
}
|
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The engine against real git repositories, with stub agents.
|
|
3
|
+
*
|
|
4
|
+
* Each test here reproduces a way the old engine lost or misreported work —
|
|
5
|
+
* see the audit in the convoy rework — and checks the history it leaves behind,
|
|
6
|
+
* not only the statuses it records.
|
|
7
|
+
*/
|
|
8
|
+
import { execFileSync } from 'node:child_process'
|
|
9
|
+
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs'
|
|
10
|
+
import { tmpdir, hostname } from 'node:os'
|
|
11
|
+
import { join } from 'node:path'
|
|
12
|
+
import { DatabaseSync } from 'node:sqlite'
|
|
13
|
+
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
|
14
|
+
import { createConvoyEngine, defaultBranchName, type ConvoyEngineOptions } from './engine.js'
|
|
15
|
+
import { createConvoyStore } from './store.js'
|
|
16
|
+
import { ensureRootWorktree, listAllWorktrees } from './worktree.js'
|
|
17
|
+
import { _resetAllowlistCache, _setAllowlistConfigPath } from './gates.js'
|
|
18
|
+
import type { AgentAdapter, ExecuteOptions, ExecuteResult, Task, TaskSpec } from './spec-types.js'
|
|
19
|
+
|
|
20
|
+
let repo: string
|
|
21
|
+
|
|
22
|
+
function git(...args: string[]): string {
|
|
23
|
+
return execFileSync('git', args, { cwd: repo, encoding: 'utf8' }).trim()
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
repo = realpathSync(mkdtempSync(join(tmpdir(), 'convoy-git-')))
|
|
28
|
+
git('init', '-q', '-b', 'main')
|
|
29
|
+
git('config', 'user.email', 't@t')
|
|
30
|
+
git('config', 'user.name', 't')
|
|
31
|
+
writeFileSync(join(repo, 'README.md'), '# proj\n')
|
|
32
|
+
writeFileSync(join(repo, '.gitignore'), '.opencastle/\n')
|
|
33
|
+
git('add', '-A')
|
|
34
|
+
git('commit', '-qm', 'init')
|
|
35
|
+
_setAllowlistConfigPath('/nonexistent/secret-scan-config.yml')
|
|
36
|
+
_resetAllowlistCache()
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
rmSync(repo, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 })
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
type Behaviour = (task: Task, options: ExecuteOptions) => Promise<ExecuteResult> | ExecuteResult
|
|
44
|
+
|
|
45
|
+
/** An agent that runs `behaviour` in the worktree it is given. */
|
|
46
|
+
function stubAdapter(behaviour: Behaviour, name = 'stub'): AgentAdapter & { execute: ReturnType<typeof vi.fn>; kill: ReturnType<typeof vi.fn> } {
|
|
47
|
+
return {
|
|
48
|
+
name,
|
|
49
|
+
isAvailable: vi.fn().mockResolvedValue(true),
|
|
50
|
+
execute: vi.fn(async (task: Task, options: ExecuteOptions = {}) => behaviour(task, options)),
|
|
51
|
+
kill: vi.fn(),
|
|
52
|
+
} as unknown as AgentAdapter & { execute: ReturnType<typeof vi.fn>; kill: ReturnType<typeof vi.fn> }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Writes `<task id>.txt` in its worktree, or whatever the task names. */
|
|
56
|
+
const writesOwnFile: Behaviour = (task, options) => {
|
|
57
|
+
writeFileSync(join(options.cwd!, `${task.id}.txt`), `${task.id}\n`)
|
|
58
|
+
return { success: true, output: 'done', exitCode: 0 }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function spec(tasks: Array<Partial<Task> & { id: string }>, extra: Partial<TaskSpec> = {}): TaskSpec {
|
|
62
|
+
return {
|
|
63
|
+
name: 'Git Convoy',
|
|
64
|
+
concurrency: 2,
|
|
65
|
+
on_failure: 'continue',
|
|
66
|
+
adapter: 'stub',
|
|
67
|
+
defaults: { review: 'none' },
|
|
68
|
+
tasks: tasks.map((t) => ({
|
|
69
|
+
prompt: `Do ${t.id}`,
|
|
70
|
+
agent: 'developer',
|
|
71
|
+
timeout: '30s',
|
|
72
|
+
depends_on: [],
|
|
73
|
+
files: [],
|
|
74
|
+
description: t.id,
|
|
75
|
+
max_retries: 0,
|
|
76
|
+
...t,
|
|
77
|
+
})),
|
|
78
|
+
...extra,
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function engine(opts: Partial<ConvoyEngineOptions> & Pick<ConvoyEngineOptions, 'spec' | 'adapter'>) {
|
|
83
|
+
return createConvoyEngine({
|
|
84
|
+
specYaml: 'name: git-convoy',
|
|
85
|
+
basePath: repo,
|
|
86
|
+
handleSignals: false,
|
|
87
|
+
output: { write: () => true, isTTY: false },
|
|
88
|
+
...opts,
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Wait until the run's own log says `taskId` was merged.
|
|
94
|
+
*
|
|
95
|
+
* The conflict tests need one task to merge before the other finishes. A fixed
|
|
96
|
+
* sleep did that on an idle machine and not under load: the first task's
|
|
97
|
+
* commit and merge outran the sleep, the order flipped, and the task with no
|
|
98
|
+
* retry left took the conflict instead.
|
|
99
|
+
*/
|
|
100
|
+
async function mergedFirst(taskId: string): Promise<void> {
|
|
101
|
+
const dir = join(repo, '.opencastle', 'logs', 'convoys')
|
|
102
|
+
const merged = (): boolean => {
|
|
103
|
+
if (!existsSync(dir)) return false
|
|
104
|
+
return readdirSync(dir).some((f) =>
|
|
105
|
+
readFileSync(join(dir, f), 'utf8').split('\n').some((line) => line.includes('"type":"task_merged"') && line.includes(`"task_id":"${taskId}"`)))
|
|
106
|
+
}
|
|
107
|
+
for (let i = 0; i < 400 && !merged(); i++) await new Promise((r) => setTimeout(r, 25))
|
|
108
|
+
if (!merged()) throw new Error(`${taskId} was never merged`)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Every task that did not finish, and why: the message a failing assertion should carry. */
|
|
112
|
+
function whyNotDone(convoyId: string): string {
|
|
113
|
+
const store = createConvoyStore(join(repo, '.opencastle', 'convoy.db'))
|
|
114
|
+
try {
|
|
115
|
+
return store.getTasksByConvoy(convoyId)
|
|
116
|
+
.filter((t) => t.status !== 'done')
|
|
117
|
+
.map((t) => `${t.id}: ${t.status} — ${String(t.output ?? '').slice(0, 600)}`)
|
|
118
|
+
.join('\n')
|
|
119
|
+
} finally {
|
|
120
|
+
store.close()
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function filesOn(branch: string): string[] {
|
|
125
|
+
return git('ls-tree', '--name-only', '-r', branch).split('\n').filter(Boolean).sort()
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
describe('work lands on a branch of its own', () => {
|
|
129
|
+
it('keeps every one of 8 parallel tasks, and leaves the user’s checkout alone', async () => {
|
|
130
|
+
const before = git('rev-parse', 'HEAD')
|
|
131
|
+
const tasks = Array.from({ length: 8 }, (_, i) => ({ id: `t${i + 1}`, files: [`t${i + 1}.txt`] }))
|
|
132
|
+
const result = await engine({ spec: spec(tasks, { concurrency: 8 }), adapter: stubAdapter(writesOwnFile) }).run()
|
|
133
|
+
|
|
134
|
+
expect(result.status, whyNotDone(result.convoyId)).toBe('done')
|
|
135
|
+
expect(result.summary.done).toBe(8)
|
|
136
|
+
expect(result.branch).toBe(defaultBranchName('Git Convoy', result.convoyId))
|
|
137
|
+
expect(result.baseRef).toBe('main')
|
|
138
|
+
// All eight on the branch…
|
|
139
|
+
expect(filesOn(result.branch!)).toEqual(['.gitignore', 'README.md', ...tasks.map((t) => `t${t.id.slice(1)}.txt`)].sort())
|
|
140
|
+
// …and none of it in the user's checkout, which is where it was, clean.
|
|
141
|
+
expect(git('rev-parse', 'HEAD')).toBe(before)
|
|
142
|
+
expect(git('rev-parse', '--abbrev-ref', 'HEAD')).toBe('main')
|
|
143
|
+
expect(git('status', '--porcelain')).toBe('')
|
|
144
|
+
// The integration worktree is gone; the branch is the result.
|
|
145
|
+
expect((await listAllWorktrees(repo)).map((w) => w.path)).toEqual([repo])
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
it('refuses to merge into the branch the user has checked out', async () => {
|
|
149
|
+
const adapter = stubAdapter(writesOwnFile)
|
|
150
|
+
await expect(engine({ spec: spec([{ id: 'a' }], { branch: 'main' }), adapter }).run()).rejects.toThrow(/checked out/)
|
|
151
|
+
expect(adapter.execute).not.toHaveBeenCalled()
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('refuses a caller-supplied checkout that is the user’s own', async () => {
|
|
155
|
+
// The pipeline passes `_convoyWorktreeDir: null`, meaning "merge in
|
|
156
|
+
// basePath"; with no pipeline branch, basePath was the user's checkout.
|
|
157
|
+
const adapter = stubAdapter(writesOwnFile)
|
|
158
|
+
await expect(engine({ spec: spec([{ id: 'a' }]), adapter, _convoyWorktreeDir: null }).run())
|
|
159
|
+
.rejects.toThrow(/Refusing to merge convoy work into/)
|
|
160
|
+
expect(adapter.execute).not.toHaveBeenCalled()
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
it('writes the event log to the main repository, never into a worktree it removes', async () => {
|
|
164
|
+
const result = await engine({ spec: spec([{ id: 'a', files: ['a.txt'] }]), adapter: stubAdapter(writesOwnFile) }).run()
|
|
165
|
+
expect(result.logPath).toBe(join(repo, '.opencastle', 'logs', 'convoys', `${result.convoyId}.ndjson`))
|
|
166
|
+
const lines = readFileSync(result.logPath!, 'utf8').trim().split('\n').map((l) => JSON.parse(l) as { type: string })
|
|
167
|
+
expect(lines.map((l) => l.type)).toContain('task_merged')
|
|
168
|
+
expect(lines.map((l) => l.type)).toContain('convoy_finished')
|
|
169
|
+
})
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
describe('the change is committed before anything checks it', () => {
|
|
173
|
+
it('secret_scan sees an uncommitted file the agent wrote', async () => {
|
|
174
|
+
// Gates diffed base..HEAD before anything was committed, so a secret the
|
|
175
|
+
// agent left uncommitted was never scanned.
|
|
176
|
+
const token = 'ghp_' + 'abcdefghijklmnopqrstuvwxyz0123456789AB'
|
|
177
|
+
const adapter = stubAdapter((_task, options) => {
|
|
178
|
+
writeFileSync(join(options.cwd!, 'config.ts'), `export const token = "${token}"\n`)
|
|
179
|
+
return { success: true, output: 'done', exitCode: 0 }
|
|
180
|
+
})
|
|
181
|
+
const result = await engine({
|
|
182
|
+
spec: spec([{ id: 'leaky', files: ['config.ts'] }], { defaults: { review: 'none', built_in_gates: { secret_scan: true } } }),
|
|
183
|
+
adapter,
|
|
184
|
+
}).run()
|
|
185
|
+
|
|
186
|
+
expect(result.status).toBe('failed')
|
|
187
|
+
const store = createConvoyStore(join(repo, '.opencastle', 'convoy.db'))
|
|
188
|
+
const task = store.getTask('leaky', result.convoyId)!
|
|
189
|
+
store.close()
|
|
190
|
+
expect(task.status).toBe('gate-failed')
|
|
191
|
+
expect(task.output).toContain('secret_scan')
|
|
192
|
+
// Reported without quoting the secret.
|
|
193
|
+
expect(task.output).not.toContain(token)
|
|
194
|
+
expect(filesOn(result.branch!)).not.toContain('config.ts')
|
|
195
|
+
})
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
describe('merge conflicts', () => {
|
|
199
|
+
it('re-runs the conflicting task once, from the tip that now holds the other change', async () => {
|
|
200
|
+
const prompts: Record<string, string[]> = {}
|
|
201
|
+
const adapter = stubAdapter(async (task, options) => {
|
|
202
|
+
;(prompts[task.id] ??= []).push(task.prompt)
|
|
203
|
+
// Neither declared shared.txt, so both run at once and both write it.
|
|
204
|
+
writeFileSync(join(options.cwd!, 'shared.txt'), `from ${task.id}\n`)
|
|
205
|
+
if (task.id === 'b' && prompts.b.length === 1) await mergedFirst('a')
|
|
206
|
+
return { success: true, output: 'done', exitCode: 0 }
|
|
207
|
+
})
|
|
208
|
+
const result = await engine({ spec: spec([{ id: 'a' }, { id: 'b', max_retries: 1 }]), adapter }).run()
|
|
209
|
+
|
|
210
|
+
expect(result.status).toBe('done')
|
|
211
|
+
expect(prompts.a).toHaveLength(1)
|
|
212
|
+
expect(prompts.b).toHaveLength(2)
|
|
213
|
+
expect(prompts.b[1]).toContain('conflicted with work merged while you ran, in: shared.txt')
|
|
214
|
+
expect(prompts.b[1]).toContain('### Instructions\nDo b')
|
|
215
|
+
expect(git('show', `${result.branch}:shared.txt`)).toBe('from b')
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
it('fails the task and keeps its branch when no retry is left for a re-run', async () => {
|
|
219
|
+
const adapter = stubAdapter(async (task, options) => {
|
|
220
|
+
writeFileSync(join(options.cwd!, 'shared.txt'), `from ${task.id}\n`)
|
|
221
|
+
if (task.id === 'b') {
|
|
222
|
+
writeFileSync(join(options.cwd!, 'b-only.txt'), 'b\n')
|
|
223
|
+
await mergedFirst('a')
|
|
224
|
+
}
|
|
225
|
+
return { success: true, output: 'done', exitCode: 0 }
|
|
226
|
+
})
|
|
227
|
+
const result = await engine({
|
|
228
|
+
spec: spec([{ id: 'a', max_retries: 0 }, { id: 'b', max_retries: 0 }]),
|
|
229
|
+
adapter,
|
|
230
|
+
}).run()
|
|
231
|
+
|
|
232
|
+
expect(result.status).toBe('failed')
|
|
233
|
+
expect(result.keptBranches).toHaveLength(1)
|
|
234
|
+
const kept = result.keptBranches![0]
|
|
235
|
+
expect(kept.taskId).toBe('b')
|
|
236
|
+
// The work is still there, on the kept branch.
|
|
237
|
+
expect(git('show', `${kept.branch}:b-only.txt`)).toBe('b')
|
|
238
|
+
const store = createConvoyStore(join(repo, '.opencastle', 'convoy.db'))
|
|
239
|
+
const types = store.getEvents(result.convoyId).map((e) => e.type)
|
|
240
|
+
store.close()
|
|
241
|
+
expect(types).toContain('merge_conflict_detected')
|
|
242
|
+
expect(types).toContain('merge_failed')
|
|
243
|
+
})
|
|
244
|
+
})
|
|
245
|
+
|
|
246
|
+
describe('resume', () => {
|
|
247
|
+
function seedOldRun(convoyId: string, statuses: Record<string, string>, deps: Record<string, string[]> = {}): void {
|
|
248
|
+
mkdirSync(join(repo, '.opencastle'), { recursive: true })
|
|
249
|
+
const store = createConvoyStore(join(repo, '.opencastle', 'convoy.db'))
|
|
250
|
+
// The old engine recorded the user's own branch here even when the spec named none.
|
|
251
|
+
store.insertConvoy({
|
|
252
|
+
id: convoyId, name: 'Old Run', spec_hash: 'x', status: 'failed', branch: 'main',
|
|
253
|
+
created_at: new Date().toISOString(), spec_yaml: 'name: old',
|
|
254
|
+
})
|
|
255
|
+
for (const [id, status] of Object.entries(statuses)) {
|
|
256
|
+
store.insertTask({
|
|
257
|
+
id, convoy_id: convoyId, phase: deps[id] ? 1 : 0, prompt: `Do ${id}`, agent: 'developer', adapter: null,
|
|
258
|
+
model: null, timeout_ms: 30_000, status: status as never, retries: 1, max_retries: 1,
|
|
259
|
+
files: JSON.stringify([`${id}.txt`]), depends_on: deps[id] ? JSON.stringify(deps[id]) : null, gates: null,
|
|
260
|
+
})
|
|
261
|
+
}
|
|
262
|
+
store.close()
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
it('continues a run recorded without a branch of its own, and re-runs the dependents a failure skipped', async () => {
|
|
266
|
+
// Old engine: resume crashed with "'main' is already used by worktree",
|
|
267
|
+
// and retry never reset the skipped dependent, then reported done.
|
|
268
|
+
seedOldRun('convoy-old', { a: 'failed', b: 'skipped' }, { b: ['a'] })
|
|
269
|
+
const adapter = stubAdapter(writesOwnFile)
|
|
270
|
+
const result = await engine({
|
|
271
|
+
spec: spec([{ id: 'a', files: ['a.txt'] }, { id: 'b', files: ['b.txt'], depends_on: ['a'] }]),
|
|
272
|
+
adapter,
|
|
273
|
+
}).resume('convoy-old')
|
|
274
|
+
|
|
275
|
+
expect(result.status).toBe('done')
|
|
276
|
+
expect(adapter.execute.mock.calls.map(([t]) => (t as Task).id)).toEqual(['a', 'b'])
|
|
277
|
+
expect(result.branch).toBe(defaultBranchName('Old Run', 'convoy-old'))
|
|
278
|
+
expect(filesOn(result.branch!)).toEqual(['.gitignore', 'README.md', 'a.txt', 'b.txt'])
|
|
279
|
+
expect(git('status', '--porcelain')).toBe('')
|
|
280
|
+
const store = createConvoyStore(join(repo, '.opencastle', 'convoy.db'))
|
|
281
|
+
const convoy = store.getConvoy('convoy-old')!
|
|
282
|
+
const tasks = store.getTasksByConvoy('convoy-old')
|
|
283
|
+
store.close()
|
|
284
|
+
expect(convoy.branch).toBe(result.branch)
|
|
285
|
+
expect(convoy.base_ref).toBe('main')
|
|
286
|
+
// A failed task got its retry budget back.
|
|
287
|
+
expect(tasks.find((t) => t.id === 'a')!.retries).toBe(0)
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
it('takes over at once after a run that was killed: dead lock, stale worktree, running task', async () => {
|
|
291
|
+
const convoyId = 'convoy-killed'
|
|
292
|
+
const branch = 'convoy/killed-abc123'
|
|
293
|
+
git('branch', branch)
|
|
294
|
+
// The killed run's integration worktree is still registered and holds the branch.
|
|
295
|
+
await ensureRootWorktree({ repoRoot: repo, branch, base: 'main', dirName: 'killed' })
|
|
296
|
+
const store = createConvoyStore(join(repo, '.opencastle', 'convoy.db'))
|
|
297
|
+
store.insertConvoy({ id: convoyId, name: 'Killed', spec_hash: 'x', status: 'running', branch, base_ref: 'main', created_at: new Date().toISOString(), spec_yaml: 'name: k' })
|
|
298
|
+
store.insertTask({ id: 'a', convoy_id: convoyId, phase: 0, prompt: 'Do a', agent: 'developer', adapter: null, model: null, timeout_ms: 30_000, status: 'running', retries: 0, max_retries: 0, files: JSON.stringify(['a.txt']), depends_on: null, gates: null })
|
|
299
|
+
store.close()
|
|
300
|
+
// The dead process's lock, with a heartbeat one second old.
|
|
301
|
+
const db = new DatabaseSync(join(repo, '.opencastle', 'convoy.db'))
|
|
302
|
+
const now = new Date().toISOString()
|
|
303
|
+
db.prepare('INSERT OR REPLACE INTO engine_lock (id, pid, hostname, started_at, last_heartbeat) VALUES (1, ?, ?, ?, ?)').run(999_999, hostname(), now, now)
|
|
304
|
+
db.close()
|
|
305
|
+
|
|
306
|
+
const result = await engine({ spec: spec([{ id: 'a', files: ['a.txt'] }]), adapter: stubAdapter(writesOwnFile) }).resume(convoyId)
|
|
307
|
+
|
|
308
|
+
expect(result.status).toBe('done')
|
|
309
|
+
expect(result.branch).toBe(branch)
|
|
310
|
+
expect(filesOn(branch)).toContain('a.txt')
|
|
311
|
+
expect((await listAllWorktrees(repo)).map((w) => w.path)).toEqual([repo])
|
|
312
|
+
})
|
|
313
|
+
})
|
|
314
|
+
|
|
315
|
+
describe('interrupting a run', () => {
|
|
316
|
+
it('kills running agents, requeues their tasks, releases the lock and resolves with 130', async () => {
|
|
317
|
+
const controller = new AbortController()
|
|
318
|
+
// `slow` runs until it is killed. A fixed two seconds ran out first on a
|
|
319
|
+
// loaded machine, and the run then ended failed rather than interrupted.
|
|
320
|
+
let release: () => void = () => {}
|
|
321
|
+
const killed = new Promise<void>((r) => (release = r))
|
|
322
|
+
const adapter = stubAdapter(async (task, options) => {
|
|
323
|
+
if (task.id === 'slow') {
|
|
324
|
+
await killed
|
|
325
|
+
return { success: false, output: 'killed', exitCode: 143 }
|
|
326
|
+
}
|
|
327
|
+
writeFileSync(join(options.cwd!, `${task.id}.txt`), 'x\n')
|
|
328
|
+
return { success: true, output: 'done', exitCode: 0 }
|
|
329
|
+
})
|
|
330
|
+
const tasks = [
|
|
331
|
+
{ id: 'quick', files: ['quick.txt'] },
|
|
332
|
+
{ id: 'slow', files: ['slow.txt'] },
|
|
333
|
+
{ id: 'later', files: ['later.txt'], depends_on: ['slow'] },
|
|
334
|
+
]
|
|
335
|
+
adapter.kill.mockImplementation(() => release())
|
|
336
|
+
const run = engine({
|
|
337
|
+
spec: spec(tasks, { concurrency: 2 }),
|
|
338
|
+
adapter,
|
|
339
|
+
signal: controller.signal,
|
|
340
|
+
}).run()
|
|
341
|
+
// Interrupt once `quick` has merged and `slow` is still running.
|
|
342
|
+
const dbFile = join(repo, '.opencastle', 'convoy.db')
|
|
343
|
+
for (let i = 0; i < 200; i++) {
|
|
344
|
+
await new Promise((r) => setTimeout(r, 50))
|
|
345
|
+
try {
|
|
346
|
+
const db = new DatabaseSync(dbFile, { readOnly: true })
|
|
347
|
+
const row = db.prepare("SELECT status FROM task WHERE id = 'quick'").get() as { status: string } | undefined
|
|
348
|
+
db.close()
|
|
349
|
+
if (row?.status === 'done') break
|
|
350
|
+
} catch { /* not created yet */ }
|
|
351
|
+
}
|
|
352
|
+
controller.abort()
|
|
353
|
+
const result = await run
|
|
354
|
+
|
|
355
|
+
expect(result.status).toBe('interrupted')
|
|
356
|
+
expect(result.exitCode).toBe(130)
|
|
357
|
+
expect(adapter.kill).toHaveBeenCalledWith(expect.objectContaining({ id: 'slow' }))
|
|
358
|
+
const store = createConvoyStore(join(repo, '.opencastle', 'convoy.db'))
|
|
359
|
+
const byId = Object.fromEntries(store.getTasksByConvoy(result.convoyId).map((t) => [t.id, t.status]))
|
|
360
|
+
const convoy = store.getConvoy(result.convoyId)!
|
|
361
|
+
store.close()
|
|
362
|
+
expect(convoy.status).toBe('interrupted')
|
|
363
|
+
expect(byId.quick).toBe('done')
|
|
364
|
+
expect(byId.slow).toBe('pending')
|
|
365
|
+
expect(byId.later).toBe('pending')
|
|
366
|
+
|
|
367
|
+
// The lock is free and the run carries on where it stopped.
|
|
368
|
+
const again = stubAdapter(writesOwnFile)
|
|
369
|
+
const resumed = await engine({ spec: spec(tasks), adapter: again }).resume(result.convoyId)
|
|
370
|
+
expect(again.execute.mock.calls.map(([t]) => (t as Task).id)).toEqual(['slow', 'later'])
|
|
371
|
+
expect(resumed.status).toBe('done')
|
|
372
|
+
expect(filesOn(resumed.branch!)).toEqual(['.gitignore', 'README.md', 'later.txt', 'quick.txt', 'slow.txt'])
|
|
373
|
+
})
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
describe('gates that run once', () => {
|
|
377
|
+
it('runs npm test once after all tasks, not once per task', async () => {
|
|
378
|
+
const counter = join(repo, '..', `${repo.split('/').pop()}-count.txt`)
|
|
379
|
+
writeFileSync(join(repo, 'package.json'), JSON.stringify({
|
|
380
|
+
name: 'p', version: '1.0.0', private: true,
|
|
381
|
+
scripts: { test: `node -e "require('fs').appendFileSync('${counter}', 'x')"` },
|
|
382
|
+
}))
|
|
383
|
+
git('add', '-A')
|
|
384
|
+
git('commit', '-qm', 'package')
|
|
385
|
+
try {
|
|
386
|
+
const tasks = [{ id: 'a', files: ['a.txt'] }, { id: 'b', files: ['b.txt'] }, { id: 'c', files: ['c.txt'] }]
|
|
387
|
+
const result = await engine({
|
|
388
|
+
spec: spec(tasks, { defaults: { review: 'none', built_in_gates: { regression_test: true } } }),
|
|
389
|
+
adapter: stubAdapter(writesOwnFile),
|
|
390
|
+
}).run()
|
|
391
|
+
expect(result.status).toBe('done')
|
|
392
|
+
expect(readFileSync(counter, 'utf8')).toBe('x')
|
|
393
|
+
expect(result.gateResults).toEqual([{ command: 'npm test', exitCode: 0, passed: true }])
|
|
394
|
+
} finally {
|
|
395
|
+
rmSync(counter, { force: true })
|
|
396
|
+
}
|
|
397
|
+
}, 30_000)
|
|
398
|
+
|
|
399
|
+
it('runs the spec gates on the merged result and commits a gate fix on the branch', async () => {
|
|
400
|
+
const adapter = stubAdapter((task, options) => {
|
|
401
|
+
if (task.id === 'gate-fix-1') writeFileSync(join(options.cwd!, 'fixed.txt'), 'ok\n')
|
|
402
|
+
else writeFileSync(join(options.cwd!, `${task.id}.txt`), 'x\n')
|
|
403
|
+
return { success: true, output: 'done', exitCode: 0 }
|
|
404
|
+
})
|
|
405
|
+
const result = await engine({
|
|
406
|
+
spec: spec([{ id: 'a', files: ['a.txt'] }], { gates: ['node -e "process.exit(require(\'fs\').existsSync(\'fixed.txt\') ? 0 : 1)"'], gate_retries: 1 }),
|
|
407
|
+
adapter,
|
|
408
|
+
}).run()
|
|
409
|
+
expect(result.status).toBe('done')
|
|
410
|
+
expect(filesOn(result.branch!)).toContain('fixed.txt')
|
|
411
|
+
expect(adapter.execute.mock.calls.at(-1)![1]).toMatchObject({ cwd: expect.stringContaining(join('.opencastle', 'worktrees')) })
|
|
412
|
+
}, 30_000)
|
|
413
|
+
})
|
|
414
|
+
|
|
415
|
+
describe('prompts', () => {
|
|
416
|
+
it('start with the same shared context for every task, so a prompt cache can serve it', async () => {
|
|
417
|
+
const prompts: string[] = []
|
|
418
|
+
const adapter = stubAdapter((task, options) => {
|
|
419
|
+
prompts.push(task.prompt)
|
|
420
|
+
return writesOwnFile(task, options)
|
|
421
|
+
})
|
|
422
|
+
await engine({ spec: spec([{ id: 'a', files: ['a.txt'] }, { id: 'b', files: ['b.txt'], depends_on: ['a'] }]), adapter }).run()
|
|
423
|
+
const shared = prompts.map((p) => p.slice(0, p.indexOf('## Your task:')))
|
|
424
|
+
expect(shared[0].length).toBeGreaterThan(100)
|
|
425
|
+
expect(shared[1]).toBe(shared[0])
|
|
426
|
+
expect(prompts[0].match(/Change only the files/g)).toHaveLength(1)
|
|
427
|
+
expect(prompts[0]).not.toContain('.github/instructions')
|
|
428
|
+
expect(prompts[0]).not.toContain('Objective')
|
|
429
|
+
})
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
describe('kept branches', () => {
|
|
433
|
+
it.skipIf(process.platform === 'win32')('fails a task whose merge is refused for any reason, and keeps its work on its branch', async () => {
|
|
434
|
+
// A pre-merge-commit hook refuses every merge commit. The first task's
|
|
435
|
+
// merge is a fast-forward and needs none; the second, cut from the same
|
|
436
|
+
// base, does — and is refused.
|
|
437
|
+
const hookDir = join(repo, '.git', 'hooks')
|
|
438
|
+
mkdirSync(hookDir, { recursive: true })
|
|
439
|
+
writeFileSync(join(hookDir, 'pre-merge-commit'), '#!/bin/sh\necho "merges are frozen" >&2\nexit 1\n', { mode: 0o755 })
|
|
440
|
+
const adapter = stubAdapter(async (task, options) => {
|
|
441
|
+
if (task.id === 'second') await mergedFirst('first')
|
|
442
|
+
writeFileSync(join(options.cwd!, `${task.id}.txt`), `${task.id}\n`)
|
|
443
|
+
return { success: true, output: 'done', exitCode: 0 }
|
|
444
|
+
})
|
|
445
|
+
const result = await engine({
|
|
446
|
+
spec: spec([{ id: 'first', files: ['first.txt'] }, { id: 'second', files: ['second.txt'] }], { concurrency: 2 }),
|
|
447
|
+
adapter,
|
|
448
|
+
}).run()
|
|
449
|
+
|
|
450
|
+
expect(result.status).toBe('failed')
|
|
451
|
+
const kept = result.keptBranches?.find((k) => k.taskId === 'second')
|
|
452
|
+
expect(kept).toBeDefined()
|
|
453
|
+
expect(git('show', `${kept!.branch}:second.txt`)).toBe('second')
|
|
454
|
+
expect(filesOn(result.branch!)).toContain('first.txt')
|
|
455
|
+
expect(filesOn(result.branch!)).not.toContain('second.txt')
|
|
456
|
+
const store = createConvoyStore(join(repo, '.opencastle', 'convoy.db'))
|
|
457
|
+
const task = store.getTask('second', result.convoyId)!
|
|
458
|
+
store.close()
|
|
459
|
+
expect(task.output).toContain('merges are frozen')
|
|
460
|
+
expect(task.output).toContain(kept!.branch)
|
|
461
|
+
})
|
|
462
|
+
})
|