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
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { mkdtempSync, mkdirSync, writeFileSync, chmodSync, readFileSync, rmSync, realpathSync, existsSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join, delimiter } from 'node:path'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A stand-in agent CLI for adapter tests: a POSIX shell script put on a
|
|
7
|
+
* scratch PATH under the real command's name. It records the arguments it was
|
|
8
|
+
* given, the directory it ran in and what arrived on stdin, prints canned
|
|
9
|
+
* output, and exits with a chosen code. No real agent session is ever started.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const SCRIPT = `#!/bin/sh
|
|
13
|
+
log="$STUB_LOG"
|
|
14
|
+
pwd > "$log/cwd"
|
|
15
|
+
: > "$log/argv"
|
|
16
|
+
for a in "$@"; do printf '%s\\n' "$a" >> "$log/argv"; done
|
|
17
|
+
cat > "$log/stdin"
|
|
18
|
+
if [ -n "$STUB_SLEEP" ]; then sleep "$STUB_SLEEP"; fi
|
|
19
|
+
if [ -n "$STUB_LAST_MESSAGE" ]; then
|
|
20
|
+
prev=""
|
|
21
|
+
for a in "$@"; do
|
|
22
|
+
if [ "$prev" = "-o" ] || [ "$prev" = "--output-last-message" ]; then printf '%s' "$STUB_LAST_MESSAGE" > "$a"; fi
|
|
23
|
+
prev="$a"
|
|
24
|
+
done
|
|
25
|
+
fi
|
|
26
|
+
if [ -f "$log/stdout.txt" ]; then cat "$log/stdout.txt"; fi
|
|
27
|
+
if [ -f "$log/stderr.txt" ]; then cat "$log/stderr.txt" >&2; fi
|
|
28
|
+
exit "\${STUB_EXIT:-0}"
|
|
29
|
+
`
|
|
30
|
+
|
|
31
|
+
export interface StubCli {
|
|
32
|
+
/** Directory on PATH holding the stub(s). */
|
|
33
|
+
bin: string
|
|
34
|
+
/** Directory the stub writes its records into. */
|
|
35
|
+
log: string
|
|
36
|
+
/** A scratch directory to run the agent in. */
|
|
37
|
+
work: string
|
|
38
|
+
/** What the stub prints on stdout (and stderr) next time it runs. */
|
|
39
|
+
respond(stdout: string, stderr?: string): void
|
|
40
|
+
argv(): string[]
|
|
41
|
+
cwd(): string
|
|
42
|
+
stdin(): string
|
|
43
|
+
/** Restore PATH and remove the scratch directories. */
|
|
44
|
+
restore(): void
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Put stub CLIs named `names` on a PATH of their own, replacing the real one
|
|
49
|
+
* so a real CLI can never be reached. `sh`, `cat` and `pwd` are still found
|
|
50
|
+
* through /bin and /usr/bin.
|
|
51
|
+
*/
|
|
52
|
+
export function installStubCli(...names: string[]): StubCli {
|
|
53
|
+
const root = realpathSync(mkdtempSync(join(tmpdir(), 'oc-stub-')))
|
|
54
|
+
const bin = join(root, 'bin')
|
|
55
|
+
const log = join(root, 'log')
|
|
56
|
+
const work = join(root, 'work')
|
|
57
|
+
for (const d of [bin, log, work]) mkdirSync(d)
|
|
58
|
+
for (const name of names) {
|
|
59
|
+
writeFileSync(join(bin, name), SCRIPT)
|
|
60
|
+
chmodSync(join(bin, name), 0o755)
|
|
61
|
+
}
|
|
62
|
+
const saved = { PATH: process.env.PATH, STUB_LOG: process.env.STUB_LOG }
|
|
63
|
+
process.env.PATH = [bin, '/usr/bin', '/bin'].join(delimiter)
|
|
64
|
+
process.env.STUB_LOG = log
|
|
65
|
+
const read = (f: string) => (existsSync(join(log, f)) ? readFileSync(join(log, f), 'utf8') : '')
|
|
66
|
+
return {
|
|
67
|
+
bin,
|
|
68
|
+
log,
|
|
69
|
+
work,
|
|
70
|
+
respond(stdout, stderr) {
|
|
71
|
+
writeFileSync(join(log, 'stdout.txt'), stdout)
|
|
72
|
+
if (stderr !== undefined) writeFileSync(join(log, 'stderr.txt'), stderr)
|
|
73
|
+
},
|
|
74
|
+
argv: () => read('argv').split('\n').slice(0, -1),
|
|
75
|
+
cwd: () => read('cwd').trim(),
|
|
76
|
+
stdin: () => read('stdin'),
|
|
77
|
+
restore() {
|
|
78
|
+
process.env.PATH = saved.PATH
|
|
79
|
+
if (saved.STUB_LOG === undefined) delete process.env.STUB_LOG
|
|
80
|
+
else process.env.STUB_LOG = saved.STUB_LOG
|
|
81
|
+
delete process.env.STUB_EXIT
|
|
82
|
+
delete process.env.STUB_LAST_MESSAGE
|
|
83
|
+
delete process.env.STUB_SLEEP
|
|
84
|
+
rmSync(root, { recursive: true, force: true })
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { mkdtempSync, writeFileSync, chmodSync, rmSync, existsSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'node:path'
|
|
4
|
+
import { describe, it, expect, afterEach } from 'vitest'
|
|
5
|
+
import { resolveCommand, commandExists, quoteForCmd, runShell, spawnCommand, killTree } from './platform.js'
|
|
6
|
+
|
|
7
|
+
const posix = process.platform !== 'win32'
|
|
8
|
+
|
|
9
|
+
describe('finding a command without `which`', () => {
|
|
10
|
+
const dirs: string[] = []
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
for (const d of dirs.splice(0)) rmSync(d, { recursive: true, force: true })
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it.skipIf(!posix)('finds an executable on PATH and ignores a file that is not one', async () => {
|
|
16
|
+
const dir = mkdtempSync(join(tmpdir(), 'oc-path-'))
|
|
17
|
+
dirs.push(dir)
|
|
18
|
+
writeFileSync(join(dir, 'fake-agent'), '#!/bin/sh\necho hi\n')
|
|
19
|
+
chmodSync(join(dir, 'fake-agent'), 0o755)
|
|
20
|
+
writeFileSync(join(dir, 'not-executable'), 'x')
|
|
21
|
+
const env = { PATH: dir }
|
|
22
|
+
expect(resolveCommand('fake-agent', env)).toBe(join(dir, 'fake-agent'))
|
|
23
|
+
expect(await commandExists('fake-agent', env)).toBe(true)
|
|
24
|
+
expect(await commandExists('not-executable', env)).toBe(false)
|
|
25
|
+
expect(await commandExists('nowhere-to-be-found', env)).toBe(false)
|
|
26
|
+
})
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
describe('quoting for cmd.exe', () => {
|
|
30
|
+
// The same output cross-spawn produces for these inputs.
|
|
31
|
+
it('quotes and caret-escapes metacharacters', () => {
|
|
32
|
+
expect(quoteForCmd('hello world')).toBe('^"hello^ world^"')
|
|
33
|
+
expect(quoteForCmd('a&b')).toBe('^"a^&b^"')
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('escapes a double quote with a backslash, then the quote itself', () => {
|
|
37
|
+
expect(quoteForCmd('say "hi"')).toBe('^"say^ \\^"hi\\^"^"')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('escapes twice for a .cmd shim, which re-parses its arguments', () => {
|
|
41
|
+
expect(quoteForCmd('a&b', true)).toBe('^^^"a^^^&b^^^"')
|
|
42
|
+
})
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
describe.skipIf(!posix)('running a gate through the platform shell', () => {
|
|
46
|
+
it('reports the exit code and both streams', async () => {
|
|
47
|
+
const r = await runShell('echo out && echo err 1>&2 && exit 3', { cwd: tmpdir() })
|
|
48
|
+
expect(r.code).toBe(3)
|
|
49
|
+
expect(r.stdout.trim()).toBe('out')
|
|
50
|
+
expect(r.stderr.trim()).toBe('err')
|
|
51
|
+
expect(r.timedOut).toBe(false)
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
it('stops a command that runs past its timeout', async () => {
|
|
55
|
+
const started = Date.now()
|
|
56
|
+
const r = await runShell('sleep 30', { cwd: tmpdir(), timeoutMs: 200 })
|
|
57
|
+
expect(r.timedOut).toBe(true)
|
|
58
|
+
expect(Date.now() - started).toBeLessThan(10_000)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('stops the command and its children when the signal aborts', async () => {
|
|
62
|
+
// A gate leads its own process group, so a terminal Ctrl+C never reaches
|
|
63
|
+
// it; an interrupted run used to wait for the whole command.
|
|
64
|
+
const marker = join(tmpdir(), `oc-abort-${process.pid}-${Date.now()}`)
|
|
65
|
+
const controller = new AbortController()
|
|
66
|
+
const started = Date.now()
|
|
67
|
+
const running = runShell(`sh -c 'sleep 2; touch "${marker}"' & wait`, { cwd: tmpdir(), signal: controller.signal })
|
|
68
|
+
setTimeout(() => controller.abort(), 200)
|
|
69
|
+
const r = await running
|
|
70
|
+
expect(r.code).not.toBe(0)
|
|
71
|
+
expect(r.timedOut).toBe(false)
|
|
72
|
+
expect(Date.now() - started).toBeLessThan(1_500)
|
|
73
|
+
// The grandchild was killed too: it never got to write its marker.
|
|
74
|
+
await new Promise((done) => setTimeout(done, 2_500))
|
|
75
|
+
expect(existsSync(marker)).toBe(false)
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
it('starts nothing when the signal has already aborted', async () => {
|
|
79
|
+
const controller = new AbortController()
|
|
80
|
+
controller.abort()
|
|
81
|
+
const marker = join(tmpdir(), `oc-aborted-${process.pid}-${Date.now()}`)
|
|
82
|
+
const r = await runShell(`touch "${marker}"`, { cwd: tmpdir(), signal: controller.signal })
|
|
83
|
+
expect(r.code).toBe(130)
|
|
84
|
+
expect(existsSync(marker)).toBe(false)
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
describe.skipIf(!posix)('stopping a process tree', () => {
|
|
89
|
+
it('reaches the children of the process, not only the process', async () => {
|
|
90
|
+
// A shell that starts a child and waits on it: killing only the shell left the child running.
|
|
91
|
+
const child = spawnCommand('sh', ['-c', 'sleep 30 & wait'], { stdio: 'ignore' })
|
|
92
|
+
await new Promise((r) => setTimeout(r, 200))
|
|
93
|
+
const closed = new Promise<void>((r) => child.on('close', () => r()))
|
|
94
|
+
killTree(child.pid)
|
|
95
|
+
await closed
|
|
96
|
+
// The shell closing is not the end of the group: on Linux the `sleep` it
|
|
97
|
+
// started is handed to init when the shell dies and stays a group member
|
|
98
|
+
// until init reaps it, a moment later. Wait for that, but for less than the
|
|
99
|
+
// 5s SIGKILL escalation, so this still proves SIGTERM reached the child.
|
|
100
|
+
const groupAlive = (): boolean => {
|
|
101
|
+
try {
|
|
102
|
+
process.kill(-child.pid!, 0)
|
|
103
|
+
return true
|
|
104
|
+
} catch {
|
|
105
|
+
return false
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const deadline = Date.now() + 3_000
|
|
109
|
+
while (groupAlive() && Date.now() < deadline) await new Promise((r) => setTimeout(r, 25))
|
|
110
|
+
expect(groupAlive()).toBe(false)
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
it('kills at once with a grace of 0, for a process that cannot wait to escalate', async () => {
|
|
114
|
+
// A shell that ignores SIGTERM: only SIGKILL ends it, and here it comes first.
|
|
115
|
+
const child = spawnCommand('sh', ['-c', "trap '' TERM; echo ready; while true; do sleep 1; done"], { stdio: ['ignore', 'pipe', 'ignore'] })
|
|
116
|
+
await new Promise<void>((r) => child.stdout!.once('data', () => r()))
|
|
117
|
+
const started = Date.now()
|
|
118
|
+
const closed = new Promise<NodeJS.Signals | null>((r) => child.on('close', (_code, signal) => r(signal)))
|
|
119
|
+
killTree(child.pid, 0)
|
|
120
|
+
expect(await closed).toBe('SIGKILL')
|
|
121
|
+
expect(Date.now() - started).toBeLessThan(2_000)
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
it('does nothing for a process that is already gone', () => {
|
|
125
|
+
expect(() => killTree(2 ** 22 + 12345)).not.toThrow()
|
|
126
|
+
expect(() => killTree(undefined)).not.toThrow()
|
|
127
|
+
})
|
|
128
|
+
})
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import { spawn, type ChildProcess, type SpawnOptions } from 'node:child_process'
|
|
2
|
+
import { accessSync, constants, statSync } from 'node:fs'
|
|
3
|
+
import { delimiter, join, isAbsolute } from 'node:path'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Process handling that works the same on macOS, Linux and Windows.
|
|
7
|
+
*
|
|
8
|
+
* Convoy drives other CLIs and runs the project's own commands, and every one of
|
|
9
|
+
* those calls used to assume a POSIX box: `which` to find a binary (Windows has
|
|
10
|
+
* none, so no runtime was ever found there), `sh -c` for gates, a bare `spawn`
|
|
11
|
+
* of npm-installed CLIs (Node refuses `.cmd` shims without a shell since
|
|
12
|
+
* 18.20.2 / 20.12.2), and a SIGTERM to one pid that left the agent's own
|
|
13
|
+
* children running.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const isWindows = process.platform === 'win32'
|
|
17
|
+
|
|
18
|
+
function isExecutableFile(path: string): boolean {
|
|
19
|
+
try {
|
|
20
|
+
if (!statSync(path).isFile()) return false
|
|
21
|
+
if (isWindows) return true
|
|
22
|
+
accessSync(path, constants.X_OK)
|
|
23
|
+
return true
|
|
24
|
+
} catch {
|
|
25
|
+
return false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** The full path a command name resolves to on PATH, or null. PATHEXT is honoured on Windows. */
|
|
30
|
+
export function resolveCommand(name: string, env: NodeJS.ProcessEnv = process.env): string | null {
|
|
31
|
+
const exts = isWindows
|
|
32
|
+
? ['', ...(env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter(Boolean).map((e) => e.toLowerCase())]
|
|
33
|
+
: ['']
|
|
34
|
+
const candidatesFor = (base: string) => exts.map((ext) => base + ext)
|
|
35
|
+
if (isAbsolute(name) || name.includes('/') || (isWindows && name.includes('\\'))) {
|
|
36
|
+
return candidatesFor(name).find(isExecutableFile) ?? null
|
|
37
|
+
}
|
|
38
|
+
// Windows spells it Path; Node exposes both, but a copied env object may carry only one.
|
|
39
|
+
const pathVar = env.PATH ?? env.Path ?? ''
|
|
40
|
+
for (const dir of pathVar.split(delimiter).filter(Boolean)) {
|
|
41
|
+
for (const candidate of candidatesFor(join(dir, name))) {
|
|
42
|
+
if (isExecutableFile(candidate)) return candidate
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Whether a command resolves on PATH. No `which`, so it answers on Windows too. */
|
|
49
|
+
export async function commandExists(name: string, env: NodeJS.ProcessEnv = process.env): Promise<boolean> {
|
|
50
|
+
return resolveCommand(name, env) !== null
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// cmd.exe metacharacters, escaped with a caret. A `.cmd` shim passes its
|
|
54
|
+
// arguments through cmd.exe a second time, so they are escaped twice — the
|
|
55
|
+
// same rule cross-spawn applies.
|
|
56
|
+
const CMD_META = /([()\][%!^"`<>&|;, *?])/g
|
|
57
|
+
|
|
58
|
+
/** One argument quoted for cmd.exe. */
|
|
59
|
+
export function quoteForCmd(arg: string, doubleEscape = false): string {
|
|
60
|
+
let quoted = arg
|
|
61
|
+
.replace(/(\\*)"/g, '$1$1\\"')
|
|
62
|
+
.replace(/(\\*)$/, '$1$1')
|
|
63
|
+
quoted = `"${quoted}"`.replace(CMD_META, '^$1')
|
|
64
|
+
if (doubleEscape) quoted = quoted.replace(CMD_META, '^$1')
|
|
65
|
+
return quoted
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Spawn a CLI by name, the way a shell would find it.
|
|
70
|
+
*
|
|
71
|
+
* On POSIX the child leads its own process group, so `killTree` reaches
|
|
72
|
+
* everything it starts. On Windows a `.cmd`/`.bat` shim — how npm installs
|
|
73
|
+
* every Node CLI — is run through cmd.exe with each argument quoted, because
|
|
74
|
+
* Node no longer spawns one without a shell. Long input belongs on stdin:
|
|
75
|
+
* Windows caps a command line near 32K characters.
|
|
76
|
+
*/
|
|
77
|
+
export function spawnCommand(command: string, args: string[], options: SpawnOptions = {}): ChildProcess {
|
|
78
|
+
if (!isWindows) {
|
|
79
|
+
return spawn(command, args, { detached: true, ...options })
|
|
80
|
+
}
|
|
81
|
+
const resolved = resolveCommand(command, (options.env as NodeJS.ProcessEnv | undefined) ?? process.env) ?? command
|
|
82
|
+
if (/\.(cmd|bat)$/i.test(resolved)) {
|
|
83
|
+
// The command is caret-escaped, not quoted; each argument is quoted and,
|
|
84
|
+
// because a shim re-parses it, escaped twice. Node wraps the whole line in
|
|
85
|
+
// `cmd /d /s /c "…"` itself when `shell` is true.
|
|
86
|
+
const line = [resolved.replace(CMD_META, '^$1'), ...args.map((a) => quoteForCmd(a, true))].join(' ')
|
|
87
|
+
return spawn(line, { ...options, shell: true, windowsHide: true, windowsVerbatimArguments: true })
|
|
88
|
+
}
|
|
89
|
+
return spawn(resolved, args, { ...options, windowsHide: true })
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Stop a process and everything it started.
|
|
94
|
+
*
|
|
95
|
+
* SIGTERM first, SIGKILL five seconds later if anything is still there. The
|
|
96
|
+
* escalation used to test `proc.killed`, which is already true once SIGTERM is
|
|
97
|
+
* *sent*, so it never fired and an agent that ignored SIGTERM ran on.
|
|
98
|
+
*
|
|
99
|
+
* A `graceMs` of 0 sends SIGKILL at once: for a process that is itself about
|
|
100
|
+
* to exit, which cannot wait to escalate.
|
|
101
|
+
*/
|
|
102
|
+
export function killTree(pid: number | undefined, graceMs = 5000): void {
|
|
103
|
+
if (!pid) return
|
|
104
|
+
if (isWindows) {
|
|
105
|
+
try {
|
|
106
|
+
spawn('taskkill', ['/pid', String(pid), '/T', '/F'], { stdio: 'ignore', windowsHide: true }).on('error', () => {})
|
|
107
|
+
} catch { /* already gone */ }
|
|
108
|
+
return
|
|
109
|
+
}
|
|
110
|
+
// The whole group when the process leads one (spawnCommand makes it), the
|
|
111
|
+
// process alone otherwise. The escalation goes to the same target: falling
|
|
112
|
+
// back to the bare pid once the group is gone could reach an unrelated
|
|
113
|
+
// process that has since been given that pid.
|
|
114
|
+
let target: number
|
|
115
|
+
try {
|
|
116
|
+
process.kill(-pid, graceMs <= 0 ? 'SIGKILL' : 'SIGTERM')
|
|
117
|
+
target = -pid
|
|
118
|
+
} catch {
|
|
119
|
+
try {
|
|
120
|
+
process.kill(pid, graceMs <= 0 ? 'SIGKILL' : 'SIGTERM')
|
|
121
|
+
target = pid
|
|
122
|
+
} catch {
|
|
123
|
+
return // already gone
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (graceMs <= 0) return
|
|
127
|
+
const timer = setTimeout(() => {
|
|
128
|
+
try { process.kill(target, 'SIGKILL') } catch { /* it went on SIGTERM */ }
|
|
129
|
+
}, graceMs)
|
|
130
|
+
timer.unref()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface ShellResult {
|
|
134
|
+
code: number
|
|
135
|
+
stdout: string
|
|
136
|
+
stderr: string
|
|
137
|
+
timedOut: boolean
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const OUTPUT_CAP = 256 * 1024
|
|
141
|
+
|
|
142
|
+
/** Keep the end of a stream: a failing test run's verdict is at the bottom. */
|
|
143
|
+
function appendCapped(current: string, chunk: string): string {
|
|
144
|
+
const next = current + chunk
|
|
145
|
+
return next.length > OUTPUT_CAP ? next.slice(next.length - OUTPUT_CAP) : next
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Run a project command — a gate such as `npm test` — through the platform's
|
|
150
|
+
* own shell (`/bin/sh` or cmd.exe). Gates were run with `sh -c`, which does not
|
|
151
|
+
* exist on Windows.
|
|
152
|
+
*
|
|
153
|
+
* Aborting `signal` kills the command and everything it started. A gate runs in
|
|
154
|
+
* a process group of its own, so the terminal's Ctrl+C never reaches it: without
|
|
155
|
+
* this, an interrupted run waited for a ten-minute test suite to finish.
|
|
156
|
+
*/
|
|
157
|
+
export function runShell(
|
|
158
|
+
command: string,
|
|
159
|
+
opts: { cwd: string; env?: NodeJS.ProcessEnv; timeoutMs?: number; signal?: AbortSignal },
|
|
160
|
+
): Promise<ShellResult> {
|
|
161
|
+
return new Promise((resolvePromise) => {
|
|
162
|
+
if (opts.signal?.aborted) {
|
|
163
|
+
resolvePromise({ code: 130, stdout: '', stderr: 'Interrupted before it started', timedOut: false })
|
|
164
|
+
return
|
|
165
|
+
}
|
|
166
|
+
const child = spawn(command, {
|
|
167
|
+
cwd: opts.cwd,
|
|
168
|
+
env: opts.env ?? process.env,
|
|
169
|
+
shell: true,
|
|
170
|
+
windowsHide: true,
|
|
171
|
+
detached: !isWindows,
|
|
172
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
173
|
+
})
|
|
174
|
+
let stdout = ''
|
|
175
|
+
let stderr = ''
|
|
176
|
+
let timedOut = false
|
|
177
|
+
let settled = false
|
|
178
|
+
const timer = opts.timeoutMs
|
|
179
|
+
? setTimeout(() => {
|
|
180
|
+
timedOut = true
|
|
181
|
+
killTree(child.pid)
|
|
182
|
+
}, opts.timeoutMs)
|
|
183
|
+
: null
|
|
184
|
+
const onAbort = (): void => killTree(child.pid)
|
|
185
|
+
opts.signal?.addEventListener('abort', onAbort, { once: true })
|
|
186
|
+
child.stdout?.on('data', (d) => (stdout = appendCapped(stdout, String(d))))
|
|
187
|
+
child.stderr?.on('data', (d) => (stderr = appendCapped(stderr, String(d))))
|
|
188
|
+
const finish = (code: number) => {
|
|
189
|
+
if (settled) return
|
|
190
|
+
settled = true
|
|
191
|
+
if (timer) clearTimeout(timer)
|
|
192
|
+
opts.signal?.removeEventListener('abort', onAbort)
|
|
193
|
+
resolvePromise({ code, stdout, stderr, timedOut })
|
|
194
|
+
}
|
|
195
|
+
child.on('error', (err) => {
|
|
196
|
+
stderr = appendCapped(stderr, err.message)
|
|
197
|
+
finish(127)
|
|
198
|
+
})
|
|
199
|
+
child.on('close', (code, signal) => finish(code ?? (signal ? 128 : 1)))
|
|
200
|
+
})
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** Open a URL in the default browser. Never throws: a headless box simply has none. */
|
|
204
|
+
export function openUrl(url: string): void {
|
|
205
|
+
try {
|
|
206
|
+
const child = isWindows
|
|
207
|
+
? // `start` is a cmd.exe builtin, not a program; the empty string is its window title.
|
|
208
|
+
spawn('cmd', ['/c', 'start', '""', url], { stdio: 'ignore', windowsHide: true, detached: true })
|
|
209
|
+
: spawn(process.platform === 'darwin' ? 'open' : 'xdg-open', [url], { stdio: 'ignore', detached: true })
|
|
210
|
+
child.on('error', () => {})
|
|
211
|
+
child.unref()
|
|
212
|
+
} catch { /* no browser */ }
|
|
213
|
+
}
|