opencastle 1.3.1 → 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 +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
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
import { stringify } from 'yaml'
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
3
|
+
import { join } from 'node:path'
|
|
2
4
|
import { getEffortProfile } from './effort-scaling.js'
|
|
5
|
+
import { normalizePath, pathsOverlap } from './partition.js'
|
|
6
|
+
import { parseYaml, validateSpec } from '../run/schema.js'
|
|
3
7
|
|
|
4
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* The planner's task plan, and the spec built from it.
|
|
10
|
+
*
|
|
11
|
+
* The LLM decides only what it is good at: the tasks, their prompts, who does
|
|
12
|
+
* them, what they touch and what waits for what. Everything that decides how
|
|
13
|
+
* the run behaves — branch, runtime, concurrency, failure policy, the checks —
|
|
14
|
+
* is set here from facts the code can read, so a generated spec is safe and
|
|
15
|
+
* fast without anyone editing it.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** One task as the planner writes it. */
|
|
5
19
|
export interface TaskPlanTask {
|
|
6
20
|
id: string
|
|
7
21
|
agent?: string
|
|
@@ -13,18 +27,12 @@ export interface TaskPlanTask {
|
|
|
13
27
|
review?: string
|
|
14
28
|
complexity?: 1 | 2 | 3 | 5 | 8 | 13
|
|
15
29
|
prompt: string
|
|
16
|
-
gates?: string[]
|
|
17
|
-
built_in_gates?: Record<string, boolean | string>
|
|
18
30
|
}
|
|
19
31
|
|
|
32
|
+
/** The planner's whole answer. */
|
|
20
33
|
export interface TaskPlan {
|
|
21
34
|
name: string
|
|
22
|
-
branch?: string
|
|
23
|
-
concurrency?: number | 'auto'
|
|
24
|
-
on_failure?: 'continue' | 'stop'
|
|
25
35
|
tasks: TaskPlanTask[]
|
|
26
|
-
gates?: string[]
|
|
27
|
-
gate_retries?: number
|
|
28
36
|
}
|
|
29
37
|
|
|
30
38
|
/** A patch to apply to a task plan — output of the fix-convoy prompt */
|
|
@@ -34,79 +42,136 @@ export interface TaskPatch {
|
|
|
34
42
|
value: unknown // new value for the field
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
|
|
45
|
+
/** What the code, not the planner, decides about a run. */
|
|
46
|
+
export interface SpecSettings {
|
|
47
|
+
/** The runtime that planned it; run, resume and retry stay on it. */
|
|
48
|
+
adapter: string
|
|
49
|
+
/** Where the work lands. Never the user's checkout. */
|
|
50
|
+
branch: string
|
|
51
|
+
/** Project checks, run once after every task is merged. */
|
|
52
|
+
gates: string[]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** More agents at once than this costs more in rate limits and machine load than it saves. */
|
|
56
|
+
export const MAX_PLANNED_CONCURRENCY = 4
|
|
57
|
+
|
|
58
|
+
export function slugify(name: string): string {
|
|
38
59
|
return name
|
|
39
60
|
.toLowerCase()
|
|
40
61
|
.replace(/[^a-z0-9]+/g, '-')
|
|
41
62
|
.replace(/^-+|-+$/g, '')
|
|
42
63
|
}
|
|
43
64
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
// ── Project checks ──────────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun'
|
|
68
|
+
|
|
69
|
+
function readPackageJson(projectRoot: string): Record<string, unknown> | null {
|
|
70
|
+
const path = join(projectRoot, 'package.json')
|
|
71
|
+
if (!existsSync(path)) return null
|
|
72
|
+
try {
|
|
73
|
+
return JSON.parse(readFileSync(path, 'utf8')) as Record<string, unknown>
|
|
74
|
+
} catch {
|
|
75
|
+
return null
|
|
76
|
+
}
|
|
51
77
|
}
|
|
52
78
|
|
|
53
79
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
80
|
+
* The package manager a project uses: its `packageManager` field (what
|
|
81
|
+
* corepack honours), else its lockfile, else npm.
|
|
56
82
|
*/
|
|
57
|
-
export function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const enrichment: SpecEnrichment = {}
|
|
63
|
-
|
|
64
|
-
// Circuit breaker: higher complexity → lower threshold (trip faster)
|
|
65
|
-
if (complexity.complexity === 'high') {
|
|
66
|
-
enrichment.circuit_breaker = { threshold: 2, cooldown_ms: 300_000 }
|
|
67
|
-
} else if (complexity.complexity === 'medium') {
|
|
68
|
-
enrichment.circuit_breaker = { threshold: 3, cooldown_ms: 300_000 }
|
|
83
|
+
export function detectPackageManager(projectRoot: string): PackageManager {
|
|
84
|
+
const declared = readPackageJson(projectRoot)?.packageManager
|
|
85
|
+
if (typeof declared === 'string') {
|
|
86
|
+
const name = declared.split('@')[0]
|
|
87
|
+
if (name === 'npm' || name === 'pnpm' || name === 'yarn' || name === 'bun') return name
|
|
69
88
|
}
|
|
89
|
+
if (existsSync(join(projectRoot, 'pnpm-lock.yaml'))) return 'pnpm'
|
|
90
|
+
if (existsSync(join(projectRoot, 'yarn.lock'))) return 'yarn'
|
|
91
|
+
if (existsSync(join(projectRoot, 'bun.lockb')) || existsSync(join(projectRoot, 'bun.lock'))) return 'bun'
|
|
92
|
+
return 'npm'
|
|
93
|
+
}
|
|
70
94
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
enrichment.detect_drift = true
|
|
74
|
-
}
|
|
95
|
+
/** Cheapest first, so a type error fails the run before the test suite starts. */
|
|
96
|
+
const GATE_SCRIPTS = [['typecheck', 'type-check'], ['lint'], ['test'], ['build']]
|
|
75
97
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
98
|
+
/**
|
|
99
|
+
* The project's own checks, from its package.json scripts.
|
|
100
|
+
*
|
|
101
|
+
* They run once, after every task has merged, which is the only point at which
|
|
102
|
+
* they test the combined result. The planner used to choose gates itself and
|
|
103
|
+
* the spec builder added a per-task `npm test` once a plan passed five tasks:
|
|
104
|
+
* the whole suite, once per task, mostly against the same code.
|
|
105
|
+
*/
|
|
106
|
+
export function detectGates(projectRoot: string): string[] {
|
|
107
|
+
const scripts = readPackageJson(projectRoot)?.scripts
|
|
108
|
+
if (!scripts || typeof scripts !== 'object') return []
|
|
109
|
+
const pm = detectPackageManager(projectRoot)
|
|
110
|
+
const gates: string[] = []
|
|
111
|
+
for (const names of GATE_SCRIPTS) {
|
|
112
|
+
const name = names.find((n) => typeof (scripts as Record<string, unknown>)[n] === 'string')
|
|
113
|
+
if (!name) continue
|
|
114
|
+
const body = (scripts as Record<string, string>)[name]
|
|
115
|
+
// `npm init` writes a test script that always fails, and a watcher never
|
|
116
|
+
// exits; either would fail or hang every run.
|
|
117
|
+
if (/no test specified/.test(body) || /--watch\b/.test(body)) continue
|
|
118
|
+
gates.push(`${pm} run ${name}`)
|
|
86
119
|
}
|
|
120
|
+
return gates
|
|
121
|
+
}
|
|
87
122
|
|
|
88
|
-
|
|
89
|
-
|
|
123
|
+
// ── Building the spec ───────────────────────────────────────────────────────
|
|
124
|
+
|
|
125
|
+
/** Topological levels: a task's level is one more than its deepest dependency's. */
|
|
126
|
+
function levels(plan: TaskPlan): Map<string, number> {
|
|
127
|
+
const byId = new Map(plan.tasks.map((t) => [t.id, t]))
|
|
128
|
+
const memo = new Map<string, number>()
|
|
129
|
+
const visit = (id: string, seen: Set<string>): number => {
|
|
130
|
+
const known = memo.get(id)
|
|
131
|
+
if (known !== undefined) return known
|
|
132
|
+
if (seen.has(id)) return 0 // a cycle; checkPlan reports it
|
|
133
|
+
seen.add(id)
|
|
134
|
+
const deps = (byId.get(id)?.depends_on ?? []).filter((d) => byId.has(d))
|
|
135
|
+
const level = deps.length ? 1 + Math.max(...deps.map((d) => visit(d, seen))) : 0
|
|
136
|
+
memo.set(id, level)
|
|
137
|
+
return level
|
|
90
138
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (domains.has('database') || domains.has('api') || domains.has('backend')) {
|
|
95
|
-
gates.dependency_audit = 'auto'
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
enrichment.built_in_gates = gates
|
|
99
|
-
|
|
100
|
-
// Review concurrency scales with task count
|
|
101
|
-
enrichment.max_concurrent_reviews = complexity.total_tasks > 6 ? 3 : 2
|
|
139
|
+
for (const t of plan.tasks) visit(t.id, new Set())
|
|
140
|
+
return memo
|
|
141
|
+
}
|
|
102
142
|
|
|
103
|
-
|
|
143
|
+
/**
|
|
144
|
+
* How many tasks to run at once: the widest level of the plan, capped.
|
|
145
|
+
*
|
|
146
|
+
* A fixed 2 left wide plans waiting and gave a straight chain a slot it could
|
|
147
|
+
* never use.
|
|
148
|
+
*/
|
|
149
|
+
export function planConcurrency(plan: TaskPlan): number {
|
|
150
|
+
const width = new Map<number, number>()
|
|
151
|
+
for (const level of levels(plan).values()) width.set(level, (width.get(level) ?? 0) + 1)
|
|
152
|
+
const widest = Math.max(1, ...width.values())
|
|
153
|
+
return Math.min(widest, MAX_PLANNED_CONCURRENCY)
|
|
104
154
|
}
|
|
105
155
|
|
|
106
156
|
/**
|
|
107
|
-
* Converts a TaskPlan into
|
|
157
|
+
* Converts a TaskPlan into convoy YAML.
|
|
158
|
+
*
|
|
159
|
+
* Defaults that changed, and why:
|
|
160
|
+
* - `branch: convoy/<slug>`. Without one the engine merged into whatever was
|
|
161
|
+
* checked out, and resume of a branchless run crashed.
|
|
162
|
+
* - `on_failure: continue`. `stop` switched off every per-task retry and still
|
|
163
|
+
* let the rest of the wave run; with `continue` a failure blocks only what
|
|
164
|
+
* depends on it, and resume picks it up.
|
|
165
|
+
* - `adapter`, so a resumed run cannot land on a different runtime.
|
|
166
|
+
* - No `detect_drift`, and no built-in gates: drift asked a fresh session with
|
|
167
|
+
* no memory to grade work it never saw and re-ran tasks on its guess, and the
|
|
168
|
+
* built-in gates either repeated the full suite per task or read a diff that
|
|
169
|
+
* was not committed yet.
|
|
170
|
+
* - `gate_retries: 1` when there are gates: one agent attempt to fix a failing
|
|
171
|
+
* check on the merged result, rather than a finished run reported red over a
|
|
172
|
+
* lint error.
|
|
108
173
|
*/
|
|
109
|
-
export function buildConvoyYaml(plan: TaskPlan,
|
|
174
|
+
export function buildConvoyYaml(plan: TaskPlan, settings: SpecSettings): string {
|
|
110
175
|
const tasks = plan.tasks.map((task) => {
|
|
111
176
|
const t: Record<string, unknown> = {}
|
|
112
177
|
t.id = task.id
|
|
@@ -117,9 +182,7 @@ export function buildConvoyYaml(plan: TaskPlan, enrichment?: SpecEnrichment): st
|
|
|
117
182
|
if (task.depends_on && task.depends_on.length > 0) t.depends_on = task.depends_on
|
|
118
183
|
if (task.max_retries !== undefined) t.max_retries = task.max_retries
|
|
119
184
|
if (task.review !== undefined) t.review = task.review
|
|
120
|
-
|
|
121
|
-
if (task.built_in_gates !== undefined) t.built_in_gates = task.built_in_gates
|
|
122
|
-
// Auto-populate from effort table when complexity is set and fields are missing
|
|
185
|
+
// The effort table fills in what the planner left out, from its complexity score.
|
|
123
186
|
if (task.complexity !== undefined) {
|
|
124
187
|
const profile = getEffortProfile(task.complexity)
|
|
125
188
|
if (t.timeout === undefined) t.timeout = profile.timeout
|
|
@@ -134,42 +197,319 @@ export function buildConvoyYaml(plan: TaskPlan, enrichment?: SpecEnrichment): st
|
|
|
134
197
|
const spec: Record<string, unknown> = {
|
|
135
198
|
name: plan.name,
|
|
136
199
|
version: 1,
|
|
137
|
-
|
|
138
|
-
|
|
200
|
+
adapter: settings.adapter,
|
|
201
|
+
branch: settings.branch,
|
|
202
|
+
concurrency: planConcurrency(plan),
|
|
203
|
+
on_failure: 'continue',
|
|
139
204
|
}
|
|
205
|
+
if (settings.gates.length > 0) {
|
|
206
|
+
spec.gates = settings.gates
|
|
207
|
+
spec.gate_retries = 1
|
|
208
|
+
}
|
|
209
|
+
spec.defaults = { timeout: '30m', max_retries: 1, review: 'fast' }
|
|
210
|
+
spec.tasks = tasks
|
|
211
|
+
|
|
212
|
+
const header =
|
|
213
|
+
'# Written by `opencastle convoy`. Edit it if you like, then run it with:\n' +
|
|
214
|
+
'# opencastle convoy run <this file>\n'
|
|
215
|
+
return header + stringify(spec, { lineWidth: 120, defaultKeyType: 'PLAIN', defaultStringType: 'PLAIN' })
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// ── Files ───────────────────────────────────────────────────────────────────
|
|
140
219
|
|
|
141
|
-
|
|
220
|
+
function isGlob(path: string): boolean {
|
|
221
|
+
return path.includes('*') || path.includes('?')
|
|
222
|
+
}
|
|
142
223
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Every `files` entry as a concrete path or directory.
|
|
226
|
+
*
|
|
227
|
+
* The engine refuses a glob, and refused it only after the run had been
|
|
228
|
+
* recorded. A glob is reduced to the directory in front of its first wildcard
|
|
229
|
+
* (`src/**\/*.ts` → `src/`), which claims at least what the glob did. One with
|
|
230
|
+
* no directory in front (`*.md`) would claim the whole project, so it is
|
|
231
|
+
* dropped and reported instead.
|
|
232
|
+
*/
|
|
233
|
+
export function normalizePlanFiles(plan: TaskPlan): { plan: TaskPlan; notes: string[] } {
|
|
234
|
+
const notes: string[] = []
|
|
235
|
+
const tasks = plan.tasks.map((task) => {
|
|
236
|
+
if (!task.files?.length) return task
|
|
237
|
+
const files: string[] = []
|
|
238
|
+
for (const raw of task.files) {
|
|
239
|
+
let path = raw.trim()
|
|
240
|
+
if (isGlob(path)) {
|
|
241
|
+
const segments = path.replace(/\\/g, '/').split('/')
|
|
242
|
+
const fixed = segments.slice(0, segments.findIndex(isGlob))
|
|
243
|
+
if (fixed.length === 0 || fixed.every((s) => s === '' || s === '.')) {
|
|
244
|
+
notes.push(`${task.id}: dropped "${raw}" — a pattern at the project root would claim everything`)
|
|
245
|
+
continue
|
|
246
|
+
}
|
|
247
|
+
path = fixed.join('/') + '/'
|
|
248
|
+
notes.push(`${task.id}: "${raw}" → "${path}"`)
|
|
249
|
+
}
|
|
250
|
+
if (path && !files.includes(path)) files.push(path)
|
|
251
|
+
}
|
|
252
|
+
return { ...task, files }
|
|
253
|
+
})
|
|
254
|
+
return { plan: { ...plan, tasks }, notes }
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/** For each task, every task it waits for, directly or not. */
|
|
258
|
+
function ancestors(plan: TaskPlan): Map<string, Set<string>> {
|
|
259
|
+
const byId = new Map(plan.tasks.map((t) => [t.id, t]))
|
|
260
|
+
const memo = new Map<string, Set<string>>()
|
|
261
|
+
const visit = (id: string, path: Set<string>): Set<string> => {
|
|
262
|
+
const known = memo.get(id)
|
|
263
|
+
if (known) return known
|
|
264
|
+
const out = new Set<string>()
|
|
265
|
+
if (path.has(id)) return out // a cycle; checkPlan reports it
|
|
266
|
+
path.add(id)
|
|
267
|
+
for (const dep of byId.get(id)?.depends_on ?? []) {
|
|
268
|
+
if (!byId.has(dep)) continue
|
|
269
|
+
out.add(dep)
|
|
270
|
+
for (const a of visit(dep, path)) out.add(a)
|
|
271
|
+
}
|
|
272
|
+
path.delete(id)
|
|
273
|
+
memo.set(id, out)
|
|
274
|
+
return out
|
|
147
275
|
}
|
|
276
|
+
for (const t of plan.tasks) visit(t.id, new Set())
|
|
277
|
+
return memo
|
|
278
|
+
}
|
|
148
279
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
280
|
+
interface Conflict {
|
|
281
|
+
first: string
|
|
282
|
+
second: string
|
|
283
|
+
paths: string[]
|
|
284
|
+
}
|
|
153
285
|
|
|
154
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Pairs of tasks that may run at the same time and claim the same files.
|
|
288
|
+
*
|
|
289
|
+
* "At the same time" means neither waits for the other, directly or through
|
|
290
|
+
* others. That is stricter than the engine's check, which compares tasks
|
|
291
|
+
* phase by phase, and it is the right one for a scheduler that starts a task
|
|
292
|
+
* the moment its dependencies finish: two tasks in different phases can still
|
|
293
|
+
* overlap in time. Compared case-insensitively too, because the spec may run
|
|
294
|
+
* on macOS or Windows.
|
|
295
|
+
*/
|
|
296
|
+
function conflicts(plan: TaskPlan): Conflict[] {
|
|
297
|
+
const before = ancestors(plan)
|
|
298
|
+
const normalized = new Map<string, string[]>()
|
|
299
|
+
for (const t of plan.tasks) {
|
|
300
|
+
const paths: string[] = []
|
|
301
|
+
for (const f of t.files ?? []) {
|
|
302
|
+
try {
|
|
303
|
+
paths.push(normalizePath(f))
|
|
304
|
+
} catch {
|
|
305
|
+
// Reported by checkPlan.
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
normalized.set(t.id, paths)
|
|
309
|
+
}
|
|
310
|
+
const found: Conflict[] = []
|
|
311
|
+
for (let i = 0; i < plan.tasks.length; i++) {
|
|
312
|
+
for (let j = i + 1; j < plan.tasks.length; j++) {
|
|
313
|
+
const a = plan.tasks[i]
|
|
314
|
+
const b = plan.tasks[j]
|
|
315
|
+
if (before.get(a.id)?.has(b.id) || before.get(b.id)?.has(a.id)) continue
|
|
316
|
+
const paths: string[] = []
|
|
317
|
+
for (const pa of normalized.get(a.id) ?? []) {
|
|
318
|
+
for (const pb of normalized.get(b.id) ?? []) {
|
|
319
|
+
if (pathsOverlap(pa, pb) || pathsOverlap(pa.toLowerCase(), pb.toLowerCase())) {
|
|
320
|
+
if (!paths.includes(pa)) paths.push(pa)
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
if (paths.length) found.push({ first: a.id, second: b.id, paths })
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return found
|
|
328
|
+
}
|
|
155
329
|
|
|
156
|
-
|
|
157
|
-
|
|
330
|
+
/**
|
|
331
|
+
* Everything the code can check about a plan before an agent runs it.
|
|
332
|
+
*
|
|
333
|
+
* The schema the runner applies, plus the two rules the engine enforces only
|
|
334
|
+
* once the run has started: no globs, and no two concurrent tasks on the same
|
|
335
|
+
* files. An empty list means the engine will accept the spec.
|
|
336
|
+
*/
|
|
337
|
+
const TEST_PATH = /(^|\/)(tests?|__tests__|spec)\/|\.(test|spec)\.[cm]?[jt]sx?$|_test\.(go|py)$|(^|\/)test_[^/]+\.py$/
|
|
158
338
|
|
|
159
|
-
|
|
339
|
+
/**
|
|
340
|
+
* Fold a task that only writes tests for one other task into that task.
|
|
341
|
+
*
|
|
342
|
+
* Planners split work into "write the code" and "test the code" even when told
|
|
343
|
+
* not to: three real runs did it every time. Each split is another session,
|
|
344
|
+
* review and merge, and the agent that wrote the code never runs a test against
|
|
345
|
+
* it. A task folds in when every file it owns is a test file, it depends on
|
|
346
|
+
* exactly one task, nothing else claims its files, and that task is not itself
|
|
347
|
+
* test-only. Tasks that waited on it wait on the merged task instead.
|
|
348
|
+
*/
|
|
349
|
+
export function foldTestOnlyTasks(plan: TaskPlan): { plan: TaskPlan; folded: Array<[string, string]> } {
|
|
350
|
+
const byId = new Map(plan.tasks.map((t) => [t.id, { ...t, files: [...(t.files ?? [])], depends_on: [...(t.depends_on ?? [])] }]))
|
|
351
|
+
const isTestOnly = (t: TaskPlanTask): boolean => (t.files ?? []).length > 0 && (t.files ?? []).every((f) => TEST_PATH.test(f))
|
|
352
|
+
const folded: Array<[string, string]> = []
|
|
353
|
+
// A dependency another dependency already waits on adds nothing: tests that
|
|
354
|
+
// list both a store change and the routes built on it test the routes.
|
|
355
|
+
const ancestors = (id: string, seen = new Set<string>()): Set<string> => {
|
|
356
|
+
for (const d of byId.get(id)?.depends_on ?? []) {
|
|
357
|
+
if (!seen.has(d)) {
|
|
358
|
+
seen.add(d)
|
|
359
|
+
ancestors(d, seen)
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return seen
|
|
363
|
+
}
|
|
364
|
+
const direct = (deps: string[]): string[] => deps.filter((d) => !deps.some((o) => o !== d && ancestors(o).has(d)))
|
|
365
|
+
for (const task of plan.tasks) {
|
|
366
|
+
const t = byId.get(task.id)
|
|
367
|
+
if (!t || !isTestOnly(t)) continue
|
|
368
|
+
const deps = direct(t.depends_on)
|
|
369
|
+
if (deps.length !== 1) continue
|
|
370
|
+
const target = byId.get(deps[0])
|
|
371
|
+
if (!target || isTestOnly(target)) continue
|
|
372
|
+
const claimedElsewhere = [...byId.values()].some(
|
|
373
|
+
(o) => o.id !== t.id && o.id !== target.id && (o.files ?? []).some((f) => t.files.includes(f)),
|
|
374
|
+
)
|
|
375
|
+
if (claimedElsewhere) continue
|
|
376
|
+
target.files = [...new Set([...(target.files ?? []), ...t.files])]
|
|
377
|
+
target.prompt = `${target.prompt.trimEnd()}\n\nIn the same session, write the tests for this change:\n${t.prompt.trim()}`
|
|
378
|
+
byId.delete(t.id)
|
|
379
|
+
for (const other of byId.values()) {
|
|
380
|
+
if (other.depends_on.includes(t.id)) {
|
|
381
|
+
other.depends_on = [...new Set(other.depends_on.map((d) => (d === t.id ? target.id : d)))].filter((d) => d !== other.id)
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
folded.push([t.id, target.id])
|
|
385
|
+
}
|
|
386
|
+
return { plan: { ...plan, tasks: plan.tasks.filter((t) => byId.has(t.id)).map((t) => byId.get(t.id)!) }, folded }
|
|
387
|
+
}
|
|
160
388
|
|
|
161
|
-
|
|
162
|
-
|
|
389
|
+
export function checkPlan(plan: TaskPlan, settings: SpecSettings): string[] {
|
|
390
|
+
const problems: string[] = []
|
|
391
|
+
|
|
392
|
+
const shape = planShapeProblem(plan as unknown as Record<string, unknown>)
|
|
393
|
+
if (shape) {
|
|
394
|
+
problems.push(`Plan: ${shape}`)
|
|
395
|
+
} else {
|
|
396
|
+
try {
|
|
397
|
+
const { valid, errors } = validateSpec(parseYaml(buildConvoyYaml(plan, settings)))
|
|
398
|
+
if (!valid) problems.push(...errors.map((e) => `Schema: ${e}`))
|
|
399
|
+
} catch (err) {
|
|
400
|
+
problems.push(`Schema: ${err instanceof Error ? err.message : String(err)}`)
|
|
401
|
+
}
|
|
402
|
+
}
|
|
163
403
|
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
404
|
+
for (const task of plan.tasks) {
|
|
405
|
+
for (const f of task.files ?? []) {
|
|
406
|
+
if (isGlob(f)) {
|
|
407
|
+
problems.push(`Task "${task.id}": files entry "${f}" is a pattern — name a file or a directory`)
|
|
408
|
+
continue
|
|
409
|
+
}
|
|
410
|
+
if (/^([A-Za-z]:)?[\\/]/.test(f)) {
|
|
411
|
+
problems.push(`Task "${task.id}": files entry "${f}" must be relative to the project root`)
|
|
412
|
+
continue
|
|
413
|
+
}
|
|
414
|
+
try {
|
|
415
|
+
normalizePath(f)
|
|
416
|
+
} catch (err) {
|
|
417
|
+
problems.push(`Task "${task.id}": ${err instanceof Error ? err.message : String(err)}`)
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
for (const c of conflicts(plan)) {
|
|
423
|
+
problems.push(
|
|
424
|
+
`Tasks "${c.first}" and "${c.second}" can run at the same time but both claim ${c.paths.join(', ')}` +
|
|
425
|
+
` — give each its own files, or make one depend on the other`,
|
|
426
|
+
)
|
|
427
|
+
}
|
|
428
|
+
return problems
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Make the later of each conflicting pair wait for the earlier.
|
|
433
|
+
*
|
|
434
|
+
* The last resort, after fix-convoy has had its rounds: it costs parallelism,
|
|
435
|
+
* never correctness, and it cannot create a cycle — an edge is only added
|
|
436
|
+
* between two tasks that do not yet wait for each other in either direction.
|
|
437
|
+
*/
|
|
438
|
+
export function sequenceConflicts(plan: TaskPlan): { plan: TaskPlan; added: Array<[string, string]> } {
|
|
439
|
+
let current: TaskPlan = structuredClone(plan)
|
|
440
|
+
const added: Array<[string, string]> = []
|
|
441
|
+
for (;;) {
|
|
442
|
+
const [next] = conflicts(current)
|
|
443
|
+
if (!next) break
|
|
444
|
+
current = {
|
|
445
|
+
...current,
|
|
446
|
+
tasks: current.tasks.map((t) =>
|
|
447
|
+
t.id === next.second ? { ...t, depends_on: [...(t.depends_on ?? []), next.first] } : t,
|
|
448
|
+
),
|
|
449
|
+
}
|
|
450
|
+
added.push([next.second, next.first])
|
|
451
|
+
}
|
|
452
|
+
return { plan: current, added }
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
// ── Joining group plans ─────────────────────────────────────────────────────
|
|
456
|
+
|
|
457
|
+
export interface GroupPlan {
|
|
458
|
+
name: string
|
|
459
|
+
depends_on: string[]
|
|
460
|
+
plan: TaskPlan
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* One plan from the plans written for each group of a large feature.
|
|
465
|
+
*
|
|
466
|
+
* Groups used to become a chain of separate specs run one after another, even
|
|
467
|
+
* when the assessment said two of them were independent. Here a group's first
|
|
468
|
+
* tasks wait for the last tasks of every group it depends on, and nothing else
|
|
469
|
+
* is added: independent groups run side by side under the normal scheduler,
|
|
470
|
+
* and the user gets one spec, one plan to read and one run to resume.
|
|
471
|
+
*
|
|
472
|
+
* Two groups can both name a task `setup`. The later one is renamed
|
|
473
|
+
* `<group>-setup`, with its group's references to it.
|
|
474
|
+
*
|
|
475
|
+
* `groups` must come in dependency order (topologicalSortGroups).
|
|
476
|
+
*/
|
|
477
|
+
export function mergeGroupPlans(name: string, groups: GroupPlan[]): TaskPlan {
|
|
478
|
+
const taken = new Set<string>()
|
|
479
|
+
const sinks = new Map<string, string[]>()
|
|
480
|
+
const tasks: TaskPlanTask[] = []
|
|
481
|
+
|
|
482
|
+
for (const group of groups) {
|
|
483
|
+
const rename = new Map<string, string>()
|
|
484
|
+
for (const t of group.plan.tasks) {
|
|
485
|
+
let id = t.id
|
|
486
|
+
if (taken.has(id)) {
|
|
487
|
+
id = `${group.name}-${t.id}`
|
|
488
|
+
for (let n = 2; taken.has(id); n++) id = `${group.name}-${t.id}-${n}`
|
|
489
|
+
}
|
|
490
|
+
taken.add(id)
|
|
491
|
+
rename.set(t.id, id)
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
const upstream = group.depends_on.flatMap((g) => sinks.get(g) ?? [])
|
|
495
|
+
const dependedOn = new Set(group.plan.tasks.flatMap((t) => t.depends_on ?? []))
|
|
496
|
+
for (const t of group.plan.tasks) {
|
|
497
|
+
const own = (t.depends_on ?? []).map((d) => rename.get(d) ?? d)
|
|
498
|
+
// A copy each: a shared array would come out of the YAML writer as an anchor.
|
|
499
|
+
const depends_on = own.length > 0 ? own : [...upstream]
|
|
500
|
+
tasks.push({ ...t, id: rename.get(t.id)!, depends_on })
|
|
501
|
+
}
|
|
502
|
+
sinks.set(
|
|
503
|
+
group.name,
|
|
504
|
+
group.plan.tasks.filter((t) => !dependedOn.has(t.id)).map((t) => rename.get(t.id)!),
|
|
505
|
+
)
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
return { name, tasks }
|
|
171
509
|
}
|
|
172
510
|
|
|
511
|
+
// ── Patches and parsing ─────────────────────────────────────────────────────
|
|
512
|
+
|
|
173
513
|
/**
|
|
174
514
|
* Applies an array of patches to a task plan. Returns a new TaskPlan (immutable).
|
|
175
515
|
*/
|
|
@@ -203,7 +543,6 @@ function detectJsonTruncation(jsonText: string): string | null {
|
|
|
203
543
|
const trimmed = jsonText.trim()
|
|
204
544
|
if (!trimmed) return 'empty output'
|
|
205
545
|
|
|
206
|
-
// Count open/close braces and brackets
|
|
207
546
|
let braces = 0
|
|
208
547
|
let brackets = 0
|
|
209
548
|
let inString = false
|
|
@@ -243,14 +582,12 @@ export function parseTaskPlan(jsonText: string): TaskPlan | null {
|
|
|
243
582
|
}
|
|
244
583
|
|
|
245
584
|
/**
|
|
246
|
-
* Like parseTaskPlan but returns a diagnostic reason on failure
|
|
585
|
+
* Like parseTaskPlan but returns a diagnostic reason on failure, for the caller
|
|
586
|
+
* to report.
|
|
247
587
|
*/
|
|
248
588
|
export function parseTaskPlanWithReason(jsonText: string): ParseTaskPlanResult {
|
|
249
589
|
const truncation = detectJsonTruncation(jsonText)
|
|
250
|
-
if (truncation) {
|
|
251
|
-
console.warn(` ⚠ parseTaskPlan: ${truncation}`)
|
|
252
|
-
return { plan: null, reason: truncation }
|
|
253
|
-
}
|
|
590
|
+
if (truncation) return { plan: null, reason: truncation }
|
|
254
591
|
|
|
255
592
|
let parsed: Record<string, unknown>
|
|
256
593
|
try {
|
|
@@ -259,27 +596,33 @@ export function parseTaskPlanWithReason(jsonText: string): ParseTaskPlanResult {
|
|
|
259
596
|
return { plan: null, reason: `JSON.parse failed: ${err instanceof Error ? err.message : String(err)}` }
|
|
260
597
|
}
|
|
261
598
|
|
|
599
|
+
const problem = planShapeProblem(parsed)
|
|
600
|
+
if (problem) return { plan: null, reason: problem }
|
|
601
|
+
return { plan: parsed as unknown as TaskPlan }
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* What makes an object not a task plan, or null: a name, a non-empty task list,
|
|
606
|
+
* unique ids, a prompt each, dependencies that exist, and no cycle.
|
|
607
|
+
*/
|
|
608
|
+
function planShapeProblem(parsed: Record<string, unknown> | null): string | null {
|
|
262
609
|
if (!parsed || typeof parsed.name !== 'string') {
|
|
263
|
-
return
|
|
610
|
+
return `missing or invalid top-level "name" field (got ${typeof parsed?.name})`
|
|
264
611
|
}
|
|
265
612
|
if (!Array.isArray(parsed.tasks) || (parsed.tasks as unknown[]).length === 0) {
|
|
266
|
-
return
|
|
613
|
+
return `missing or empty "tasks" array`
|
|
267
614
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
615
|
+
const tasks = parsed.tasks as Array<Record<string, unknown>>
|
|
616
|
+
for (let i = 0; i < tasks.length; i++) {
|
|
617
|
+
const t = tasks[i]
|
|
618
|
+
if (!t || typeof t !== 'object') return `task[${i}] is not an object`
|
|
619
|
+
if (typeof t.id !== 'string') return `task[${i}] missing "id" field`
|
|
273
620
|
if (typeof t.prompt !== 'string') {
|
|
274
|
-
return
|
|
275
|
-
}
|
|
276
|
-
if ((t.prompt as string).length === 0) {
|
|
277
|
-
return { plan: null, reason: `task "${t.id}" has empty "prompt" field` }
|
|
621
|
+
return `task "${t.id}" missing "prompt" field (has keys: ${Object.keys(t).join(', ')})`
|
|
278
622
|
}
|
|
623
|
+
if (t.prompt.length === 0) return `task "${t.id}" has empty "prompt" field`
|
|
279
624
|
}
|
|
280
625
|
|
|
281
|
-
// Validate unique task IDs
|
|
282
|
-
const tasks = parsed.tasks as Array<Record<string, unknown>>
|
|
283
626
|
const ids = new Set<string>()
|
|
284
627
|
const duplicates: string[] = []
|
|
285
628
|
for (const task of tasks) {
|
|
@@ -287,20 +630,14 @@ export function parseTaskPlanWithReason(jsonText: string): ParseTaskPlanResult {
|
|
|
287
630
|
if (ids.has(id)) duplicates.push(id)
|
|
288
631
|
ids.add(id)
|
|
289
632
|
}
|
|
290
|
-
|
|
291
|
-
console.warn(` ⚠ parseTaskPlan: duplicate task IDs: ${duplicates.join(', ')}`)
|
|
292
|
-
return { plan: null, reason: `duplicate task IDs: ${duplicates.join(', ')}` }
|
|
293
|
-
}
|
|
633
|
+
if (duplicates.length > 0) return `duplicate task IDs: ${duplicates.join(', ')}`
|
|
294
634
|
|
|
295
|
-
// Validate depends_on references
|
|
296
635
|
for (const task of tasks) {
|
|
297
|
-
if (Array.isArray(task.depends_on)) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
303
|
-
}
|
|
636
|
+
if (task.depends_on !== undefined && !Array.isArray(task.depends_on)) {
|
|
637
|
+
return `task "${task.id as string}" has a depends_on that is not a list`
|
|
638
|
+
}
|
|
639
|
+
for (const dep of (task.depends_on as string[] | undefined) ?? []) {
|
|
640
|
+
if (!ids.has(dep)) return `task "${task.id as string}" depends on unknown task "${dep}"`
|
|
304
641
|
}
|
|
305
642
|
}
|
|
306
643
|
|
|
@@ -312,11 +649,9 @@ export function parseTaskPlanWithReason(jsonText: string): ParseTaskPlanResult {
|
|
|
312
649
|
adj.set(id, [])
|
|
313
650
|
}
|
|
314
651
|
for (const task of tasks) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
inDegree.set(task.id as string, (inDegree.get(task.id as string) ?? 0) + 1)
|
|
319
|
-
}
|
|
652
|
+
for (const dep of (task.depends_on as string[] | undefined) ?? []) {
|
|
653
|
+
adj.get(dep)!.push(task.id as string)
|
|
654
|
+
inDegree.set(task.id as string, (inDegree.get(task.id as string) ?? 0) + 1)
|
|
320
655
|
}
|
|
321
656
|
}
|
|
322
657
|
const queue = [...ids].filter(id => inDegree.get(id) === 0)
|
|
@@ -330,12 +665,8 @@ export function parseTaskPlanWithReason(jsonText: string): ParseTaskPlanResult {
|
|
|
330
665
|
if (deg === 0) queue.push(next)
|
|
331
666
|
}
|
|
332
667
|
}
|
|
333
|
-
if (visited < ids.size)
|
|
334
|
-
|
|
335
|
-
return { plan: null, reason: 'dependency cycle detected' }
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
return { plan: parsed as unknown as TaskPlan }
|
|
668
|
+
if (visited < ids.size) return 'dependency cycle detected'
|
|
669
|
+
return null
|
|
339
670
|
}
|
|
340
671
|
|
|
341
672
|
/**
|