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