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
package/src/cli/log.ts
CHANGED
|
@@ -1,47 +1,309 @@
|
|
|
1
1
|
import { mkdir, appendFile, readFile, stat } from 'node:fs/promises'
|
|
2
2
|
import { join, dirname } from 'node:path'
|
|
3
|
+
import * as v from 'valibot'
|
|
4
|
+
import { TIER_IDS } from './tiers.js'
|
|
5
|
+
import { nearest } from './nearest.js'
|
|
3
6
|
import type { CliContext } from './types.js'
|
|
4
7
|
|
|
8
|
+
/**
|
|
9
|
+
* `opencastle log` — append one agent record to `.opencastle/logs/events.ndjson`.
|
|
10
|
+
*
|
|
11
|
+
* Agents call this from generated instructions, so a record it accepts is a
|
|
12
|
+
* record every reader of the log has to cope with. It used to accept anything:
|
|
13
|
+
* `--type session` with no fields, `--outcome banana`, a value-less `--model`
|
|
14
|
+
* stored as `true`, `--task 007` stored as the number 7, `--agnet`, and a
|
|
15
|
+
* caller-supplied `--timestamp yesterday`. Each record type is now checked
|
|
16
|
+
* against the schema in `customizations/logs/README.md`, field by field, and a
|
|
17
|
+
* record that does not match is refused with every reason at once.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
type Kind = 'text' | 'count' | 'number' | 'boolean' | 'list'
|
|
21
|
+
|
|
22
|
+
interface Field {
|
|
23
|
+
kind: Kind
|
|
24
|
+
required: boolean
|
|
25
|
+
/** The only values a text field may take. */
|
|
26
|
+
values?: readonly string[]
|
|
27
|
+
/** Smallest value of a count. */
|
|
28
|
+
min?: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const req = (kind: Kind, values?: readonly string[]): Field => ({ kind, required: true, values })
|
|
32
|
+
const opt = (kind: Kind, values?: readonly string[]): Field => ({ kind, required: false, values })
|
|
33
|
+
const attempt: Field = { kind: 'count', required: true, min: 1 }
|
|
34
|
+
|
|
35
|
+
const OUTCOMES = ['success', 'partial', 'failed'] as const
|
|
36
|
+
|
|
37
|
+
/** The record schemas, as `customizations/logs/README.md` documents them. `log.test.ts` holds the two together. */
|
|
38
|
+
export const LOG_RECORDS: Record<string, Record<string, Field>> = {
|
|
39
|
+
session: {
|
|
40
|
+
agent: req('text'),
|
|
41
|
+
model: opt('text'),
|
|
42
|
+
task: req('text'),
|
|
43
|
+
tracker_issue: opt('text'),
|
|
44
|
+
outcome: req('text', OUTCOMES),
|
|
45
|
+
duration_min: opt('number'),
|
|
46
|
+
files_changed: opt('count'),
|
|
47
|
+
retries: opt('count'),
|
|
48
|
+
lessons_added: opt('list'),
|
|
49
|
+
discoveries: opt('list'),
|
|
50
|
+
},
|
|
51
|
+
delegation: {
|
|
52
|
+
session_id: req('text'),
|
|
53
|
+
agent: req('text'),
|
|
54
|
+
model: opt('text'),
|
|
55
|
+
tier: req('text', TIER_IDS),
|
|
56
|
+
mechanism: req('text', ['sub-agent', 'background']),
|
|
57
|
+
tracker_issue: opt('text'),
|
|
58
|
+
outcome: req('text', [...OUTCOMES, 'redirected']),
|
|
59
|
+
retries: opt('count'),
|
|
60
|
+
phase: opt('count'),
|
|
61
|
+
file_partition: opt('list'),
|
|
62
|
+
},
|
|
63
|
+
review: {
|
|
64
|
+
tracker_issue: opt('text'),
|
|
65
|
+
agent: req('text'),
|
|
66
|
+
reviewer_model: opt('text'),
|
|
67
|
+
verdict: req('text', ['pass', 'fail']),
|
|
68
|
+
attempt,
|
|
69
|
+
issues_critical: req('count'),
|
|
70
|
+
issues_major: req('count'),
|
|
71
|
+
issues_minor: req('count'),
|
|
72
|
+
confidence: req('text', ['low', 'medium', 'high']),
|
|
73
|
+
escalated: req('boolean'),
|
|
74
|
+
duration_sec: opt('number'),
|
|
75
|
+
},
|
|
76
|
+
panel: {
|
|
77
|
+
panel_key: req('text'),
|
|
78
|
+
verdict: req('text', ['pass', 'block']),
|
|
79
|
+
pass_count: req('count'),
|
|
80
|
+
block_count: req('count'),
|
|
81
|
+
must_fix: req('count'),
|
|
82
|
+
should_fix: req('count'),
|
|
83
|
+
reviewer_model: opt('text'),
|
|
84
|
+
weighted: req('boolean'),
|
|
85
|
+
attempt,
|
|
86
|
+
tracker_issue: opt('text'),
|
|
87
|
+
artifacts_count: opt('count'),
|
|
88
|
+
report_path: opt('text'),
|
|
89
|
+
},
|
|
90
|
+
dispute: {
|
|
91
|
+
dispute_id: req('text'),
|
|
92
|
+
tracker_issue: opt('text'),
|
|
93
|
+
priority: req('text', ['critical', 'high', 'medium', 'low']),
|
|
94
|
+
trigger: req('text', ['panel-3x-block', 'approach-conflict', 'criteria-conflict', 'architectural-ambiguity', 'external-dependency']),
|
|
95
|
+
implementing_agent: req('text'),
|
|
96
|
+
reviewing_agents: req('list'),
|
|
97
|
+
total_attempts: req('count'),
|
|
98
|
+
est_tokens_spent: opt('count'),
|
|
99
|
+
status: req('text', ['pending', 'resolved', 'deferred']),
|
|
100
|
+
resolution_option_chosen: opt('text'),
|
|
101
|
+
resolved_at: opt('text'),
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const TYPES = Object.keys(LOG_RECORDS)
|
|
106
|
+
|
|
107
|
+
type AnySchema = v.GenericSchema<unknown>
|
|
108
|
+
|
|
109
|
+
function schemaFor(field: Field): AnySchema {
|
|
110
|
+
const text = v.pipe(v.string(), v.nonEmpty())
|
|
111
|
+
const base: AnySchema =
|
|
112
|
+
field.kind === 'text'
|
|
113
|
+
? field.values ? v.picklist(field.values as string[]) : text
|
|
114
|
+
: field.kind === 'count'
|
|
115
|
+
? v.pipe(v.number(), v.integer(), v.minValue(field.min ?? 0))
|
|
116
|
+
: field.kind === 'number'
|
|
117
|
+
? v.pipe(v.number(), v.minValue(0))
|
|
118
|
+
: field.kind === 'boolean'
|
|
119
|
+
? v.boolean()
|
|
120
|
+
: v.pipe(v.array(text), v.minLength(1))
|
|
121
|
+
return field.required ? base : v.optional(base)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const SCHEMAS: Record<string, AnySchema> = Object.fromEntries(
|
|
125
|
+
Object.entries(LOG_RECORDS).map(([type, fields]) => [
|
|
126
|
+
type,
|
|
127
|
+
v.strictObject(Object.fromEntries(Object.entries(fields).map(([k, f]) => [k, schemaFor(f)]))),
|
|
128
|
+
]),
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
/** What a field accepts, in words, for error messages and help. */
|
|
132
|
+
function describe(field: Field): string {
|
|
133
|
+
if (field.values) return `one of ${field.values.join(', ')}`
|
|
134
|
+
switch (field.kind) {
|
|
135
|
+
case 'count': return field.min ? `a whole number, at least ${field.min}` : 'a whole number, 0 or more'
|
|
136
|
+
case 'number': return 'a number, 0 or more'
|
|
137
|
+
case 'boolean': return 'true or false'
|
|
138
|
+
case 'list': return 'a comma-separated list'
|
|
139
|
+
default: return 'text'
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const OWN_FLAGS = ['--type', '--logs-dir', '--dry-run', '--help']
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Turn one argv value into the field's type.
|
|
147
|
+
*
|
|
148
|
+
* Only numeric fields become numbers. Every id and text field stays exactly as
|
|
149
|
+
* typed, so `--session_id 2024` and `--task 007` are the strings "2024" and "007".
|
|
150
|
+
*/
|
|
151
|
+
function convert(raw: string, field: Field | undefined): unknown {
|
|
152
|
+
switch (field?.kind) {
|
|
153
|
+
case 'count':
|
|
154
|
+
case 'number':
|
|
155
|
+
return /^-?\d+(\.\d+)?$/.test(raw) ? Number(raw) : raw
|
|
156
|
+
case 'boolean':
|
|
157
|
+
return raw === 'true' ? true : raw === 'false' ? false : raw
|
|
158
|
+
case 'list':
|
|
159
|
+
return raw.split(',').map((s) => s.trim()).filter(Boolean)
|
|
160
|
+
default:
|
|
161
|
+
return raw
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export type ParsedLog =
|
|
166
|
+
| { ok: true; help: true }
|
|
167
|
+
| { ok: true; help: false; record: Record<string, unknown>; logsDir: string | null; dryRun: boolean }
|
|
168
|
+
| { ok: false; errors: string[]; type: string | null }
|
|
169
|
+
|
|
170
|
+
/** Read `opencastle log` arguments into a checked record, or every reason it is not one. */
|
|
171
|
+
export function parseLogArgs(args: string[], now: Date = new Date()): ParsedLog {
|
|
172
|
+
const errors: string[] = []
|
|
173
|
+
const given = new Map<string, string>()
|
|
174
|
+
// Fields already reported for how they were passed; the schema check need not repeat them.
|
|
175
|
+
const reported = new Set<string>()
|
|
176
|
+
let type: string | null = null
|
|
177
|
+
let logsDir: string | null = null
|
|
178
|
+
let dryRun = false
|
|
179
|
+
|
|
180
|
+
// First pass: the type decides which fields are known, wherever --type appears.
|
|
181
|
+
const typeAt = args.indexOf('--type')
|
|
182
|
+
const typeGuess = typeAt >= 0 ? args[typeAt + 1] : undefined
|
|
183
|
+
const fields = typeGuess && typeGuess in LOG_RECORDS ? LOG_RECORDS[typeGuess] : null
|
|
184
|
+
const knownFields = fields ? Object.keys(fields) : [...new Set(Object.values(LOG_RECORDS).flatMap((f) => Object.keys(f)))]
|
|
185
|
+
|
|
186
|
+
for (let i = 0; i < args.length; i++) {
|
|
187
|
+
const arg = args[i]
|
|
188
|
+
if (arg === '--help' || arg === '-h') return { ok: true, help: true }
|
|
189
|
+
if (arg === '--dry-run') { dryRun = true; continue }
|
|
190
|
+
if (!arg.startsWith('--')) {
|
|
191
|
+
errors.push(`Unexpected "${arg}". Every value follows its --field; quote values that contain spaces.`)
|
|
192
|
+
continue
|
|
193
|
+
}
|
|
194
|
+
const key = arg.slice(2)
|
|
195
|
+
const value = args[i + 1]
|
|
196
|
+
// A flag needs a value. One followed by another flag, or by nothing, used to
|
|
197
|
+
// be stored as `true` — a `--model` whose variable was empty became a model
|
|
198
|
+
// named true.
|
|
199
|
+
const missing = value === undefined || value.startsWith('--')
|
|
200
|
+
if (!missing) i++
|
|
201
|
+
|
|
202
|
+
if (key === 'timestamp') {
|
|
203
|
+
errors.push('--timestamp is not accepted: opencastle log sets the timestamp itself.')
|
|
204
|
+
continue
|
|
205
|
+
}
|
|
206
|
+
const isOwn = key === 'type' || key === 'logs-dir'
|
|
207
|
+
if (!isOwn && !knownFields.includes(key)) {
|
|
208
|
+
const suggestion = nearest(key, [...knownFields, ...OWN_FLAGS.map((f) => f.slice(2))])
|
|
209
|
+
const where = fields ? `a ${typeGuess} record` : 'any record type'
|
|
210
|
+
errors.push(`Unknown option --${key} for ${where}.${suggestion ? ` Did you mean --${suggestion}?` : ''}`)
|
|
211
|
+
continue
|
|
212
|
+
}
|
|
213
|
+
if (missing) {
|
|
214
|
+
errors.push(`--${key} needs a value.`)
|
|
215
|
+
reported.add(key)
|
|
216
|
+
continue
|
|
217
|
+
}
|
|
218
|
+
if (value.trim() === '') {
|
|
219
|
+
errors.push(`--${key} cannot be empty. Leave it out instead when there is nothing to record.`)
|
|
220
|
+
reported.add(key)
|
|
221
|
+
continue
|
|
222
|
+
}
|
|
223
|
+
if (key === 'type') type = value
|
|
224
|
+
else if (key === 'logs-dir') logsDir = value
|
|
225
|
+
else if (given.has(key)) errors.push(`--${key} is given twice.`)
|
|
226
|
+
else given.set(key, value)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (!type) {
|
|
230
|
+
errors.unshift(`--type is required: one of ${TYPES.join(', ')}.`)
|
|
231
|
+
return { ok: false, errors, type: null }
|
|
232
|
+
}
|
|
233
|
+
if (!(type in LOG_RECORDS)) {
|
|
234
|
+
const suggestion = nearest(type, TYPES)
|
|
235
|
+
errors.unshift(`--type "${type}" is not a record type: one of ${TYPES.join(', ')}.${suggestion ? ` Did you mean ${suggestion}?` : ''}`)
|
|
236
|
+
return { ok: false, errors, type: null }
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const schema = LOG_RECORDS[type]
|
|
240
|
+
const values: Record<string, unknown> = {}
|
|
241
|
+
for (const [key, raw] of given) values[key] = convert(raw, schema[key])
|
|
242
|
+
|
|
243
|
+
const result = v.safeParse(SCHEMAS[type], values)
|
|
244
|
+
if (!result.success) {
|
|
245
|
+
for (const issue of result.issues) {
|
|
246
|
+
const key = String(issue.path?.[0]?.key ?? '')
|
|
247
|
+
if (!key || reported.has(key)) continue
|
|
248
|
+
reported.add(key)
|
|
249
|
+
const field = schema[key]
|
|
250
|
+
if (!field) continue
|
|
251
|
+
errors.push(
|
|
252
|
+
given.has(key)
|
|
253
|
+
? `--${key} must be ${describe(field)}, not "${given.get(key)}".`
|
|
254
|
+
: `--${key} is required${field.kind === 'text' && !field.values ? '' : `: ${describe(field)}`}.`,
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (errors.length > 0) return { ok: false, errors, type }
|
|
259
|
+
|
|
260
|
+
// Fields in the order they were given, after the two every record starts with.
|
|
261
|
+
const record: Record<string, unknown> = { type, timestamp: now.toISOString() }
|
|
262
|
+
for (const key of given.keys()) record[key] = values[key]
|
|
263
|
+
return { ok: true, help: false, record, logsDir, dryRun }
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function fieldList(fields: Record<string, Field>): string {
|
|
267
|
+
const words = Object.entries(fields).map(([k, f]) => `${f.required ? '*' : ''}${k}${f.values ? `=${f.values.join('|')}` : ''}`)
|
|
268
|
+
const lines: string[] = []
|
|
269
|
+
let line = ''
|
|
270
|
+
for (const w of words) {
|
|
271
|
+
if (line && line.length + w.length + 1 > 62) {
|
|
272
|
+
lines.push(line)
|
|
273
|
+
line = w
|
|
274
|
+
} else {
|
|
275
|
+
line = line ? `${line} ${w}` : w
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (line) lines.push(line)
|
|
279
|
+
return lines.join('\n ')
|
|
280
|
+
}
|
|
281
|
+
|
|
5
282
|
const HELP = `
|
|
6
|
-
opencastle log
|
|
283
|
+
opencastle log --type <type> --<field> <value> ...
|
|
7
284
|
|
|
8
|
-
Append
|
|
285
|
+
Append one record to .opencastle/logs/events.ndjson. Each record is checked
|
|
286
|
+
against its schema; a record that does not match is refused, with every
|
|
287
|
+
reason. opencastle log sets the timestamp itself.
|
|
9
288
|
|
|
10
289
|
Options:
|
|
11
|
-
--type <type>
|
|
12
|
-
--<field> <value>
|
|
13
|
-
--logs-dir <path>
|
|
14
|
-
--dry-run
|
|
15
|
-
--help, -h
|
|
290
|
+
--type <type> ${TYPES.join(' | ')}
|
|
291
|
+
--<field> <value> A field of that record type (below)
|
|
292
|
+
--logs-dir <path> Write to another logs directory
|
|
293
|
+
--dry-run Print the record without writing it
|
|
294
|
+
--help, -h Show this help
|
|
16
295
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
296
|
+
Fields (* required):
|
|
297
|
+
${Object.entries(LOG_RECORDS).map(([t, f]) => ` ${t.padEnd(12)} ${fieldList(f)}`).join('\n')}
|
|
298
|
+
|
|
299
|
+
Lists are comma-separated. Booleans are true or false. Leave out a field you
|
|
300
|
+
have no value for; an empty value is refused.
|
|
20
301
|
|
|
21
302
|
Examples:
|
|
22
303
|
opencastle log --type session --agent Developer --task "Fix bug" --outcome success
|
|
23
304
|
opencastle log --type delegation --session_id feat/prj-1 --agent Developer --tier standard --mechanism sub-agent --outcome success
|
|
24
|
-
opencastle log --type panel --panel_key auth-review --verdict pass --pass_count 3 --block_count 0
|
|
25
305
|
`
|
|
26
306
|
|
|
27
|
-
const VALID_TYPES = ['session', 'delegation', 'review', 'panel', 'dispute']
|
|
28
|
-
|
|
29
|
-
const ARRAY_FIELDS = new Set([
|
|
30
|
-
'file_partition',
|
|
31
|
-
'lessons_added',
|
|
32
|
-
'discoveries',
|
|
33
|
-
'reviewing_agents',
|
|
34
|
-
])
|
|
35
|
-
|
|
36
|
-
const BOOLEAN_FIELDS = new Set(['escalated', 'weighted'])
|
|
37
|
-
|
|
38
|
-
function coerceValue(key: string, raw: string): unknown {
|
|
39
|
-
if (ARRAY_FIELDS.has(key)) return raw.split(',').map((s) => s.trim()).filter(Boolean)
|
|
40
|
-
if (BOOLEAN_FIELDS.has(key)) return raw === 'true'
|
|
41
|
-
if (/^-?\d+(\.\d+)?$/.test(raw)) return Number(raw)
|
|
42
|
-
return raw
|
|
43
|
-
}
|
|
44
|
-
|
|
45
307
|
/** Resolve the path to the logs directory (walks up to find .opencastle/). */
|
|
46
308
|
async function resolveLogsDir(override?: string | null): Promise<string> {
|
|
47
309
|
if (override) return override
|
|
@@ -83,73 +345,30 @@ export async function appendEvent(
|
|
|
83
345
|
}
|
|
84
346
|
|
|
85
347
|
export default async function log({ args }: CliContext): Promise<void> {
|
|
86
|
-
|
|
348
|
+
const parsed = parseLogArgs(args)
|
|
349
|
+
if (parsed.ok && parsed.help) {
|
|
87
350
|
console.log(HELP)
|
|
88
351
|
return
|
|
89
352
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
for (let i = 0; i < args.length; i++) {
|
|
97
|
-
const arg = args[i]
|
|
98
|
-
switch (arg) {
|
|
99
|
-
case '--type':
|
|
100
|
-
if (i + 1 >= args.length) { console.error(' \u2717 --type requires a value'); process.exit(1) }
|
|
101
|
-
type = args[++i]
|
|
102
|
-
if (!type.trim()) { console.error(' \u2717 --type cannot be empty'); process.exit(1) }
|
|
103
|
-
break
|
|
104
|
-
case '--logs-dir':
|
|
105
|
-
if (i + 1 >= args.length) { console.error(' \u2717 --logs-dir requires a path'); process.exit(1) }
|
|
106
|
-
logsDir = args[++i]
|
|
107
|
-
if (!logsDir.trim()) { console.error(' \u2717 --logs-dir cannot be empty'); process.exit(1) }
|
|
108
|
-
break
|
|
109
|
-
default:
|
|
110
|
-
if (arg.startsWith('--')) {
|
|
111
|
-
const key = arg.slice(2)
|
|
112
|
-
const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype'])
|
|
113
|
-
if (DANGEROUS_KEYS.has(key)) break
|
|
114
|
-
const next = args[i + 1]
|
|
115
|
-
if (next === undefined || next.startsWith('--')) {
|
|
116
|
-
fields[key] = true
|
|
117
|
-
} else {
|
|
118
|
-
const raw = args[++i]
|
|
119
|
-
if (!raw.trim()) { console.error(` \u2717 --${key} cannot be empty`); process.exit(1) }
|
|
120
|
-
fields[key] = coerceValue(key, raw)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (!type) {
|
|
127
|
-
console.error(' \u2717 --type is required. Use one of: session, delegation, review, panel, dispute')
|
|
128
|
-
console.error(' Run "opencastle log --help" for usage.')
|
|
129
|
-
process.exit(1)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
if (!VALID_TYPES.includes(type)) {
|
|
133
|
-
console.error(` \u2717 Invalid --type "${type}". Must be one of: ${VALID_TYPES.join(', ')}`)
|
|
353
|
+
if (!parsed.ok) {
|
|
354
|
+
const what = parsed.type ? `a ${parsed.type} record` : 'this record'
|
|
355
|
+
console.error(` ✗ opencastle log refused ${what}:`)
|
|
356
|
+
for (const e of parsed.errors) console.error(` ${e}`)
|
|
357
|
+
console.error(' Run "opencastle log --help" for the fields of each record type.')
|
|
134
358
|
process.exit(1)
|
|
135
359
|
}
|
|
136
360
|
|
|
137
|
-
|
|
138
|
-
delete fields['timestamp']
|
|
139
|
-
const record = { type, timestamp, ...fields }
|
|
140
|
-
|
|
141
|
-
if (dryRun) {
|
|
361
|
+
if (parsed.dryRun) {
|
|
142
362
|
console.log(` [dry-run] Would append to events.ndjson:`)
|
|
143
|
-
console.log(JSON.stringify(record))
|
|
363
|
+
console.log(JSON.stringify(parsed.record))
|
|
144
364
|
return
|
|
145
365
|
}
|
|
146
366
|
|
|
147
367
|
try {
|
|
148
|
-
await appendEvent(record, logsDir)
|
|
149
|
-
console.log(JSON.stringify(record))
|
|
368
|
+
await appendEvent(parsed.record, parsed.logsDir)
|
|
369
|
+
console.log(JSON.stringify(parsed.record))
|
|
150
370
|
} catch (err: unknown) {
|
|
151
371
|
console.error(` ✗ Failed to write log: ${(err as Error).message}`)
|
|
152
372
|
process.exit(1)
|
|
153
373
|
}
|
|
154
374
|
}
|
|
155
|
-
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import { editDistance, nearest } from './nearest.js'
|
|
3
|
+
|
|
4
|
+
describe('editDistance', () => {
|
|
5
|
+
it('counts single-character edits', () => {
|
|
6
|
+
expect(editDistance('--port', '--prot')).toBe(2)
|
|
7
|
+
expect(editDistance('--dryRun', '--dry-run')).toBe(2)
|
|
8
|
+
expect(editDistance('', 'abc')).toBe(3)
|
|
9
|
+
expect(editDistance('same', 'same')).toBe(0)
|
|
10
|
+
})
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
describe('nearest', () => {
|
|
14
|
+
it('names a likely typo', () => {
|
|
15
|
+
expect(nearest('--verbos', ['--dry-run', '--verbose'])).toBe('--verbose')
|
|
16
|
+
expect(nearest('resum', ['run', 'resume', 'dashboard'])).toBe('resume')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('names nothing when nothing is close, rather than a wrong guess', () => {
|
|
20
|
+
expect(nearest('--json', ['--port', '--no-open'])).toBeNull()
|
|
21
|
+
expect(nearest('status', ['run', 'resume', 'dashboard', 'plan'])).toBeNull()
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('can ignore case', () => {
|
|
25
|
+
expect(nearest('McpServers', ['mcpServers'], { ignoreCase: true })).toBe('mcpServers')
|
|
26
|
+
})
|
|
27
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Did you mean …?" for a word someone typed.
|
|
3
|
+
*
|
|
4
|
+
* Four commands carried their own copy of this, with thresholds that had begun
|
|
5
|
+
* to differ: one always named a candidate, however far off, so `--json` on the
|
|
6
|
+
* viewer was answered with "did you mean --port?". One copy, one rule.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Levenshtein distance: the fewest single-character edits from `a` to `b`. */
|
|
10
|
+
export function editDistance(a: string, b: string): number {
|
|
11
|
+
const row = Array.from({ length: b.length + 1 }, (_, i) => i)
|
|
12
|
+
for (let i = 1; i <= a.length; i++) {
|
|
13
|
+
let prev = row[0]
|
|
14
|
+
row[0] = i
|
|
15
|
+
for (let j = 1; j <= b.length; j++) {
|
|
16
|
+
const cur = row[j]
|
|
17
|
+
row[j] = Math.min(row[j] + 1, row[j - 1] + 1, prev + (a[i - 1] === b[j - 1] ? 0 : 1))
|
|
18
|
+
prev = cur
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return row[b.length]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The candidate closest to `word`, or null when none is close enough to be a
|
|
26
|
+
* plausible typo: within two edits, or a third of the word's length for a long
|
|
27
|
+
* one. A suggestion that is not a likely typo sends people the wrong way.
|
|
28
|
+
*/
|
|
29
|
+
export function nearest(word: string, candidates: readonly string[], opts: { ignoreCase?: boolean } = {}): string | null {
|
|
30
|
+
const norm = (s: string): string => (opts.ignoreCase ? s.toLowerCase() : s)
|
|
31
|
+
let best: string | null = null
|
|
32
|
+
let bestDistance = Infinity
|
|
33
|
+
for (const candidate of candidates) {
|
|
34
|
+
const d = editDistance(norm(word), norm(candidate))
|
|
35
|
+
if (d < bestDistance) [best, bestDistance] = [candidate, d]
|
|
36
|
+
}
|
|
37
|
+
return best !== null && bestDistance <= Math.max(2, Math.floor(word.length / 3)) ? best : null
|
|
38
|
+
}
|