cool-workflow 0.1.97 → 0.2.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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +11 -2
- package/apps/architecture-review/app.json +1 -1
- package/apps/architecture-review-fast/app.json +1 -1
- package/apps/end-to-end-golden-path/app.json +1 -1
- package/apps/pr-review-fix-ci/app.json +1 -1
- package/apps/release-cut/app.json +1 -1
- package/apps/research-synthesis/app.json +1 -1
- package/dist/cli/dispatch.js +236 -0
- package/dist/cli/entry.js +120 -0
- package/dist/cli/io.js +21 -4
- package/dist/cli/parseargv.js +157 -0
- package/dist/cli.js +6 -33
- package/dist/core/capability-table.js +3534 -0
- package/dist/core/format/help.js +314 -0
- package/dist/{state-explosion/format.js → core/format/state-explosion-text.js} +10 -1
- package/dist/core/hash.js +137 -0
- package/dist/core/multi-agent/candidate-scoring.js +219 -0
- package/dist/core/multi-agent/collaboration.js +481 -0
- package/dist/core/multi-agent/coordinator.js +515 -0
- package/dist/core/multi-agent/eval-replay.js +306 -0
- package/dist/core/multi-agent/runtime.js +929 -0
- package/dist/core/multi-agent/topology.js +298 -0
- package/dist/core/multi-agent/trust-policy.js +197 -0
- package/dist/core/pipeline/commit-gate.js +320 -0
- package/dist/{pipeline-contract.js → core/pipeline/contract.js} +24 -37
- package/dist/core/pipeline/dispatch.js +103 -0
- package/dist/core/pipeline/drive-decide.js +227 -0
- package/dist/core/pipeline/error-feedback.js +161 -0
- package/dist/core/pipeline/loop-expansion.js +124 -0
- package/dist/{result-normalize.js → core/pipeline/result-normalize.js} +14 -37
- package/dist/core/pipeline/runner.js +230 -0
- package/dist/{contract-migration.js → core/state/contract-migration.js} +68 -92
- package/dist/{state-migrations.js → core/state/migrations.js} +103 -96
- package/dist/core/state/node-projection.js +95 -0
- package/dist/core/state/node-snapshot.js +230 -0
- package/dist/core/state/run-paths.js +93 -0
- package/dist/{schema-validate.js → core/state/schema-validate.js} +35 -28
- package/dist/core/state/schema.js +50 -0
- package/dist/core/state/state-explosion/digest.js +243 -0
- package/dist/core/state/state-explosion/graph.js +527 -0
- package/dist/{state-explosion → core/state/state-explosion}/helpers.js +34 -3
- package/dist/core/state/state-explosion/report.js +187 -0
- package/dist/{state-explosion → core/state/state-explosion}/size.js +25 -7
- package/dist/{state-node.js → core/state/state-node.js} +90 -113
- package/dist/core/state/types.js +19 -0
- package/dist/{validation.js → core/state/validation.js} +64 -131
- package/dist/core/trust/evidence-grounding.js +134 -0
- package/dist/core/trust/ledger.js +199 -0
- package/dist/{telemetry-attestation.js → core/trust/telemetry-attestation.js} +94 -68
- package/dist/core/trust/telemetry-ledger.js +127 -0
- package/dist/core/types.js +20 -0
- package/dist/core/version.js +16 -0
- package/dist/{workflow-app-framework.js → core/workflow-apps/app-schema.js} +337 -426
- package/dist/mcp/dispatch.js +104 -0
- package/dist/mcp/server.js +144 -0
- package/dist/mcp-server.js +6 -84
- package/dist/{agent-config.js → shell/agent-config.js} +118 -71
- package/dist/shell/app-run-cli.js +88 -0
- package/dist/shell/audit-cli.js +259 -0
- package/dist/shell/audit-provenance.js +83 -0
- package/dist/shell/candidate-scoring-io.js +459 -0
- package/dist/shell/collaboration-io.js +264 -0
- package/dist/shell/commit-summary.js +104 -0
- package/dist/shell/commit.js +290 -0
- package/dist/shell/coordinator-io.js +476 -0
- package/dist/shell/demo-cli.js +19 -0
- package/dist/shell/dispatch.js +162 -0
- package/dist/{doctor.js → shell/doctor.js} +123 -56
- package/dist/shell/drive.js +873 -0
- package/dist/shell/error-feedback-io.js +305 -0
- package/dist/shell/eval-io.js +473 -0
- package/dist/{multi-agent-eval/format.js → shell/eval-text.js} +78 -49
- package/dist/{evidence-reasoning.js → shell/evidence-reasoning.js} +124 -255
- package/dist/shell/exec-backend-cli.js +88 -0
- package/dist/shell/execution-backend/agent.js +475 -0
- package/dist/shell/execution-backend/ci.js +15 -0
- package/dist/shell/execution-backend/container.js +69 -0
- package/dist/shell/execution-backend/envelopes.js +55 -0
- package/dist/shell/execution-backend/local.js +113 -0
- package/dist/shell/execution-backend/probes.js +175 -0
- package/dist/shell/execution-backend/registry.js +402 -0
- package/dist/shell/execution-backend/remote.js +128 -0
- package/dist/shell/execution-backend/types.js +11 -0
- package/dist/shell/feedback-cli.js +81 -0
- package/dist/shell/feedback-operations.js +48 -0
- package/dist/shell/fs-atomic.js +276 -0
- package/dist/shell/harness.js +98 -0
- package/dist/shell/ledger-cli.js +212 -0
- package/dist/shell/ledger-io.js +169 -0
- package/dist/shell/man-cli.js +89 -0
- package/dist/shell/metrics-cli.js +98 -0
- package/dist/shell/multi-agent-cli.js +1002 -0
- package/dist/shell/multi-agent-host.js +563 -0
- package/dist/shell/multi-agent-io.js +387 -0
- package/dist/{multi-agent-operator-ux.js → shell/multi-agent-operator-ux.js} +234 -191
- package/dist/shell/node-store.js +124 -0
- package/dist/{observability/format.js → shell/observability-format.js} +7 -1
- package/dist/{observability/intake.js → shell/observability-intake.js} +79 -56
- package/dist/{observability.js → shell/observability.js} +159 -332
- package/dist/{onramp.js → shell/onramp.js} +11 -0
- package/dist/{operator-ux/format.js → shell/operator-ux-text.js} +250 -239
- package/dist/shell/operator-ux.js +431 -0
- package/dist/shell/orchestrator.js +231 -0
- package/dist/shell/pipeline-cli.js +667 -0
- package/dist/shell/pipeline.js +217 -0
- package/dist/shell/reclamation-io.js +1366 -0
- package/dist/shell/registry-cli.js +329 -0
- package/dist/{remote-source.js → shell/remote-source.js} +12 -5
- package/dist/shell/report-cli.js +101 -0
- package/dist/shell/report-view-cli.js +117 -0
- package/dist/{orchestrator → shell}/report.js +289 -282
- package/dist/shell/reporter.js +62 -0
- package/dist/shell/run-export-cli.js +106 -0
- package/dist/shell/run-export.js +680 -0
- package/dist/shell/run-registry-io.js +1014 -0
- package/dist/shell/run-store.js +164 -0
- package/dist/{sandbox-profile.js → shell/sandbox-profile.js} +134 -95
- package/dist/{scheduler.js → shell/scheduler-io.js} +248 -48
- package/dist/shell/scheduling-io.js +311 -0
- package/dist/shell/state-cli.js +181 -0
- package/dist/shell/state-explosion-cli.js +197 -0
- package/dist/shell/telemetry-cli.js +85 -0
- package/dist/{telemetry-demo.js → shell/telemetry-demo.js} +149 -119
- package/dist/shell/telemetry-ledger-io.js +132 -0
- package/dist/{term.js → shell/term.js} +36 -46
- package/dist/shell/topology-io.js +361 -0
- package/dist/shell/trust-audit.js +471 -0
- package/dist/{multi-agent-trust.js → shell/trust-policy-io.js} +67 -205
- package/dist/shell/verifier.js +48 -0
- package/dist/shell/workbench-host.js +250 -0
- package/dist/shell/workbench-text.js +18 -0
- package/dist/shell/workbench.js +175 -0
- package/dist/shell/worker-cli.js +124 -0
- package/dist/shell/worker-isolation.js +852 -0
- package/dist/shell/workflow-app-loader.js +650 -0
- package/docs/agent-delegation-drive.7.md +4 -0
- package/docs/cli-mcp-parity.7.md +284 -211
- package/docs/contract-migration-tooling.7.md +4 -0
- package/docs/control-plane-scheduling.7.md +4 -0
- package/docs/cross-agent-ledger.7.md +217 -0
- package/docs/designs/handoff-ledger.md +145 -0
- package/docs/durable-state-and-locking.7.md +4 -0
- package/docs/evidence-adoption-reasoning-chain.7.md +4 -0
- package/docs/execution-backends.7.md +4 -0
- package/docs/handoff-setup.md +120 -0
- package/docs/multi-agent-cli-mcp-surface.7.md +4 -0
- package/docs/multi-agent-eval-replay-harness.7.md +4 -0
- package/docs/multi-agent-operator-ux.7.md +4 -0
- package/docs/node-snapshot-diff-replay.7.md +4 -0
- package/docs/observability-cost-accounting.7.md +4 -0
- package/docs/project-index.md +143 -71
- package/docs/real-execution-backends.7.md +4 -0
- package/docs/release-and-migration.7.md +4 -0
- package/docs/release-tooling.7.md +4 -0
- package/docs/run-registry-control-plane.7.md +4 -0
- package/docs/run-retention-reclamation.7.md +25 -0
- package/docs/state-explosion-management.7.md +4 -0
- package/docs/team-collaboration.7.md +4 -0
- package/docs/web-desktop-workbench.7.md +4 -0
- package/manifest/plugin.manifest.json +1 -1
- package/manifest/source-context-profiles.json +9 -13
- package/package.json +1 -1
- package/scripts/agents/codex-agent.js +34 -4
- package/scripts/agents/cw-attest-wrap.js +2 -2
- package/scripts/bump-version.js +4 -3
- package/scripts/canonical-apps.js +4 -4
- package/scripts/children/batch-delegate-child.js +30 -10
- package/scripts/dogfood-architecture-review.js +2 -3
- package/scripts/dogfood-release.js +3 -3
- package/scripts/gen-parity-doc.js +15 -2
- package/scripts/golden-path.js +4 -4
- package/scripts/onramp-check.js +1 -1
- package/scripts/parity-check.js +38 -21
- package/scripts/release-flow.js +9 -3
- package/scripts/sync-project-index.js +51 -27
- package/scripts/validate-run-state-schema.js +2 -2
- package/scripts/version-sync-check.js +30 -30
- package/dist/candidate-scoring.js +0 -729
- package/dist/capability-core.js +0 -1186
- package/dist/capability-registry.js +0 -879
- package/dist/cli/command-surface.js +0 -490
- package/dist/cli/format.js +0 -56
- package/dist/cli/handlers/audit.js +0 -82
- package/dist/cli/handlers/blackboard.js +0 -81
- package/dist/cli/handlers/candidate.js +0 -40
- package/dist/cli/handlers/clones.js +0 -34
- package/dist/cli/handlers/collaboration.js +0 -61
- package/dist/cli/handlers/eval.js +0 -40
- package/dist/cli/handlers/maintenance.js +0 -107
- package/dist/cli/handlers/multi-agent.js +0 -165
- package/dist/cli/handlers/node.js +0 -41
- package/dist/cli/handlers/operational.js +0 -155
- package/dist/cli/handlers/operator.js +0 -146
- package/dist/cli/handlers/registry.js +0 -68
- package/dist/cli/handlers/run.js +0 -153
- package/dist/cli/handlers/scheduling.js +0 -132
- package/dist/cli/handlers/workbench.js +0 -41
- package/dist/cli/handlers/worker.js +0 -45
- package/dist/cli/run-summary.js +0 -45
- package/dist/clones.js +0 -162
- package/dist/collaboration.js +0 -726
- package/dist/commit.js +0 -592
- package/dist/compare.js +0 -18
- package/dist/coordinator/classify.js +0 -45
- package/dist/coordinator/paths.js +0 -42
- package/dist/coordinator/util.js +0 -126
- package/dist/coordinator.js +0 -990
- package/dist/daemon.js +0 -44
- package/dist/dispatch.js +0 -250
- package/dist/drive.js +0 -827
- package/dist/error-feedback.js +0 -419
- package/dist/evidence-grounding.js +0 -184
- package/dist/execution-backend/agent.js +0 -294
- package/dist/execution-backend/probes.js +0 -112
- package/dist/execution-backend/util.js +0 -47
- package/dist/execution-backend.js +0 -961
- package/dist/gates.js +0 -48
- package/dist/harness.js +0 -61
- package/dist/loop-expansion.js +0 -60
- package/dist/mcp/tool-call.js +0 -434
- package/dist/mcp/tool-definitions.js +0 -1040
- package/dist/mcp-surface.js +0 -30
- package/dist/multi-agent/graph.js +0 -84
- package/dist/multi-agent/helpers.js +0 -141
- package/dist/multi-agent/ids.js +0 -20
- package/dist/multi-agent/paths.js +0 -22
- package/dist/multi-agent-eval/normalize.js +0 -51
- package/dist/multi-agent-eval.js +0 -678
- package/dist/multi-agent-host.js +0 -777
- package/dist/multi-agent.js +0 -984
- package/dist/node-projection.js +0 -59
- package/dist/node-snapshot.js +0 -260
- package/dist/operator-ux.js +0 -631
- package/dist/orchestrator/app-operations.js +0 -211
- package/dist/orchestrator/audit-operations.js +0 -182
- package/dist/orchestrator/candidate-operations.js +0 -117
- package/dist/orchestrator/cli-options.js +0 -294
- package/dist/orchestrator/collaboration-operations.js +0 -86
- package/dist/orchestrator/feedback-operations.js +0 -81
- package/dist/orchestrator/host-operations.js +0 -78
- package/dist/orchestrator/lifecycle-operations.js +0 -626
- package/dist/orchestrator/migration-operations.js +0 -44
- package/dist/orchestrator/multi-agent-operations.js +0 -362
- package/dist/orchestrator/topology-operations.js +0 -84
- package/dist/orchestrator.js +0 -917
- package/dist/pipeline-runner.js +0 -285
- package/dist/reclamation/hash.js +0 -72
- package/dist/reclamation.js +0 -812
- package/dist/reporter.js +0 -67
- package/dist/run-export.js +0 -784
- package/dist/run-registry/derive.js +0 -175
- package/dist/run-registry/format.js +0 -124
- package/dist/run-registry/gc.js +0 -251
- package/dist/run-registry/policy.js +0 -16
- package/dist/run-registry/queue.js +0 -115
- package/dist/run-registry.js +0 -850
- package/dist/run-state-schema.js +0 -68
- package/dist/scheduling.js +0 -184
- package/dist/state-explosion.js +0 -1014
- package/dist/state.js +0 -367
- package/dist/telemetry-ledger.js +0 -196
- package/dist/topology.js +0 -565
- package/dist/triggers.js +0 -184
- package/dist/trust-audit.js +0 -644
- package/dist/types/blackboard.js +0 -2
- package/dist/types/candidate.js +0 -2
- package/dist/types/collaboration.js +0 -2
- package/dist/types/core.js +0 -2
- package/dist/types/drive.js +0 -10
- package/dist/types/error-feedback.js +0 -2
- package/dist/types/evidence-reasoning.js +0 -2
- package/dist/types/execution-backend.js +0 -2
- package/dist/types/multi-agent.js +0 -2
- package/dist/types/observability.js +0 -2
- package/dist/types/pipeline.js +0 -2
- package/dist/types/reclamation.js +0 -8
- package/dist/types/report-bundle.js +0 -6
- package/dist/types/result.js +0 -2
- package/dist/types/run-registry.js +0 -2
- package/dist/types/run.js +0 -2
- package/dist/types/sandbox.js +0 -2
- package/dist/types/schedule.js +0 -2
- package/dist/types/state-node.js +0 -2
- package/dist/types/topology.js +0 -2
- package/dist/types/trust.js +0 -2
- package/dist/types/workbench.js +0 -2
- package/dist/types/worker.js +0 -2
- package/dist/types/workflow-app.js +0 -2
- package/dist/types.js +0 -44
- package/dist/util/fingerprint.js +0 -19
- package/dist/util/fingerprint.test.js +0 -27
- package/dist/verifier.js +0 -78
- package/dist/version.js +0 -8
- package/dist/workbench-host.js +0 -182
- package/dist/workbench.js +0 -192
- package/dist/worker-accept/acceptance.js +0 -114
- package/dist/worker-accept/blackboard-fanout.js +0 -80
- package/dist/worker-accept/blackboard-linkage.js +0 -19
- package/dist/worker-accept/context.js +0 -2
- package/dist/worker-accept/telemetry-ledger.js +0 -126
- package/dist/worker-accept/validation.js +0 -77
- package/dist/worker-accept/verifier-completion.js +0 -73
- package/dist/worker-isolation/helpers.js +0 -51
- package/dist/worker-isolation/paths.js +0 -46
- package/dist/worker-isolation.js +0 -656
- package/dist/workflow-api.js +0 -131
- /package/dist/{types → core/types}/boundary.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cool-workflow",
|
|
3
3
|
"description": "A workflow control plane and run-time you are able to check: it sends out jobs in TypeScript, makes certain of work against facts before it goes through, puts state into fixed records, orders jobs by time, runs jobs again and again, gets a group of agents to do their parts together, and talks MCP. It gives the doing of the work to outside agents — it never runs the models itself.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "COOLWHITE LLC"
|
|
7
7
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cool-workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A workflow control plane and run-time you are able to check: it sends out jobs in TypeScript, makes certain of work against facts before it goes through, puts state into fixed records, orders jobs by time, runs jobs again and again, gets a group of agents to do their parts together, and talks MCP. It gives the doing of the work to outside agents — it never runs the models itself.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "COOLWHITE LLC"
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- AUTO-GENERATED from /README.md by scripts/sync-readme.js — edit the root README, then run `npm run sync:readme`. DO NOT edit this file directly. -->
|
|
2
2
|
<div align="center">
|
|
3
3
|
|
|
4
|
-
<img src="https://raw.githubusercontent.com/coo1white/cool-workflow/main/docs/assets/cw-hero.png" alt="Cool Workflow
|
|
4
|
+
<img src="https://raw.githubusercontent.com/coo1white/cool-workflow/main/docs/assets/cw-hero.png" alt="Cool Workflow hero image: the CW name over a line reading ask, plan, dispatch, verify, report — the stages of a saved, cited run." width="100%">
|
|
5
5
|
|
|
6
6
|
<br><br>
|
|
7
7
|
|
|
@@ -49,7 +49,7 @@ Upgrade later with `brew update && brew upgrade cool-workflow`.
|
|
|
49
49
|
</details>
|
|
50
50
|
|
|
51
51
|
**You need:** Node.js v18+ and one agent CLI on your machine — `claude`, `codex`, `gemini`, or
|
|
52
|
-
`opencode` (all auto-detected). No agent yet? `cw demo` still works — **CW never runs a model itself.**
|
|
52
|
+
`opencode` (all auto-detected). No agent yet? `cw demo tamper` still works — **CW never runs a model itself.**
|
|
53
53
|
|
|
54
54
|
## Quick Start
|
|
55
55
|
|
|
@@ -110,6 +110,12 @@ is long, parallel, or high-stakes, you can't tell what happened or trust the res
|
|
|
110
110
|
| **Deterministic, local replay** | Every step is plain JSON under `.cw/runs/<id>/` — read it, diff it, resume it, replay it. No hidden database; the runtime never *guesses* success. |
|
|
111
111
|
| **Vendor-neutral by design** | One source-of-truth manifest generates every vendor adapter (Claude, Codex, …) over a shared CLI + MCP runtime, with a fail-closed drift check. No lock-in, no forked logic. |
|
|
112
112
|
|
|
113
|
+
**What CW is not.** CW is not the model — it never calls a model API and never holds your keys;
|
|
114
|
+
your agent does that work out of process. It is not a CI system or a build tool — it keeps and
|
|
115
|
+
checks the record of agent work, it does not stand in for your tests or your release pipeline.
|
|
116
|
+
And it is not a big framework to take up — it is a small set of commands over plain `.cw/` files
|
|
117
|
+
on your own disk, not a library your code has to be built around.
|
|
118
|
+
|
|
113
119
|
## How It Works
|
|
114
120
|
|
|
115
121
|
CW is a small TypeScript tool with **zero runtime dependencies**. It drives your agent over a repo — or
|
|
@@ -133,6 +139,9 @@ ask simple → run simple → verify simple → resume simple
|
|
|
133
139
|
| `research-synthesis` | Answer a question over a local folder of files — your docs, notes, or papers |
|
|
134
140
|
| `release-cut` | Run a gated, reviewed release with dry-run evidence |
|
|
135
141
|
|
|
142
|
+
Every app writes the same thing: a saved, cited report you can re-verify offline. These four are
|
|
143
|
+
the main lanes; `cw app list` shows all eight installed apps.
|
|
144
|
+
|
|
136
145
|
```bash
|
|
137
146
|
cw app list # see everything installed
|
|
138
147
|
cw doctor # check your setup → cw fix shows the fix commands
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "architecture-review",
|
|
4
4
|
"title": "Architecture Review",
|
|
5
5
|
"summary": "Map a repository architecture, assess risks, verify important findings, and synthesize an evidence-backed verdict.",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.2.0",
|
|
7
7
|
"author": "COOLWHITE LLC",
|
|
8
8
|
"inputs": [
|
|
9
9
|
{
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "architecture-review-fast",
|
|
4
4
|
"title": "Architecture Review Fast",
|
|
5
5
|
"summary": "Run a shorter architecture review with parallel map and assess phases for faster first results.",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.2.0",
|
|
7
7
|
"author": "COOLWHITE LLC",
|
|
8
8
|
"inputs": [
|
|
9
9
|
{
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "pr-review-fix-ci",
|
|
4
4
|
"title": "PR Review Fix CI",
|
|
5
5
|
"summary": "Review a pull request or branch, inspect CI failures, diagnose actionable issues, optionally patch, verify, and summarize with evidence.",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.2.0",
|
|
7
7
|
"author": "COOLWHITE LLC",
|
|
8
8
|
"inputs": [
|
|
9
9
|
{
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "release-cut",
|
|
4
4
|
"title": "Release Cut",
|
|
5
5
|
"summary": "Prepare a release with checklist discipline: version checks, changelog, tests, packaging, release notes, and final verification.",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.2.0",
|
|
7
7
|
"author": "COOLWHITE LLC",
|
|
8
8
|
"inputs": [
|
|
9
9
|
{
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"id": "research-synthesis",
|
|
4
4
|
"title": "Research Synthesis",
|
|
5
5
|
"summary": "Split a research question into claims, investigate sources, cross-check evidence, verify claims, and synthesize a concise answer.",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.2.0",
|
|
7
7
|
"author": "COOLWHITE LLC",
|
|
8
8
|
"inputs": [
|
|
9
9
|
{
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// cli/dispatch.ts — the generic CLI executor over core/capability-table.ts.
|
|
3
|
+
//
|
|
4
|
+
// MILESTONE 2 (v2/PLAN.md build order, step 2; see the Revision note there
|
|
5
|
+
// for why this lands here, right after CLI parsing, instead of late).
|
|
6
|
+
//
|
|
7
|
+
// `dispatch(args)` first tries the CAPABILITY TABLE: it looks up the row
|
|
8
|
+
// whose `cli.path` matches the parsed command (+ enough leading
|
|
9
|
+
// positionals to disambiguate a subcommand, e.g. `sandbox list`), calls
|
|
10
|
+
// its `cli.handler`, and prints the `CliHandlerResult` per the row's
|
|
11
|
+
// `jsonMode`. This is the ONLY code path future milestones touch when
|
|
12
|
+
// they add a capability — as a table row, never a new switch arm here.
|
|
13
|
+
//
|
|
14
|
+
// Everything below `dispatchLegacy` is the milestone-1 carry-over: a
|
|
15
|
+
// small, explicitly-scoped switch for verbs that conformance/cases/
|
|
16
|
+
// cli-argv-parsing.case.js and cli-exit-codes.case.js probe but that do
|
|
17
|
+
// not yet have a real subsystem behind them (see each case's own
|
|
18
|
+
// PLACEHOLDER comment for which future milestone owns it). Per the
|
|
19
|
+
// Revision note in v2/PLAN.md, THIS file is never hand-extended again —
|
|
20
|
+
// `dispatchLegacy`'s arms shrink to nothing as later milestones move each
|
|
21
|
+
// one into a real capability-table row; nothing new is ever added here.
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.KNOWN_COMMANDS = void 0;
|
|
24
|
+
exports.dispatch = dispatch;
|
|
25
|
+
const help_1 = require("../core/format/help");
|
|
26
|
+
const capability_table_1 = require("../core/capability-table");
|
|
27
|
+
const parseargv_1 = require("./parseargv");
|
|
28
|
+
Object.defineProperty(exports, "KNOWN_COMMANDS", { enumerable: true, get: function () { return parseargv_1.KNOWN_COMMANDS; } });
|
|
29
|
+
const io_1 = require("./io");
|
|
30
|
+
const workflow_app_loader_1 = require("../shell/workflow-app-loader");
|
|
31
|
+
function firstPositional(args, index = 0) {
|
|
32
|
+
return args.positionals[index];
|
|
33
|
+
}
|
|
34
|
+
/** Writes a `CliHandlerResult` to stdout and applies its exit code, per
|
|
35
|
+
* the row's `jsonMode`:
|
|
36
|
+
* - `"default"` — always prints `result.json` as JSON (falls back to
|
|
37
|
+
* `result.text` when a row has no canonical JSON shape).
|
|
38
|
+
* - `"flag"` — prints `result.text` normally, `result.json` under
|
|
39
|
+
* `--json`/`--format json`.
|
|
40
|
+
* - `"human"` — always prints `result.text`; there is no JSON form. */
|
|
41
|
+
function renderCliResult(result, jsonMode, options) {
|
|
42
|
+
const useJson = jsonMode === "default" || (jsonMode === "flag" && (0, io_1.wantsJson)(options));
|
|
43
|
+
if (useJson && result.json !== undefined) {
|
|
44
|
+
(0, io_1.printJson)(result.json);
|
|
45
|
+
}
|
|
46
|
+
else if (result.text !== undefined) {
|
|
47
|
+
process.stdout.write(result.text.endsWith("\n") ? result.text : `${result.text}\n`);
|
|
48
|
+
}
|
|
49
|
+
else if (result.json !== undefined) {
|
|
50
|
+
(0, io_1.printJson)(result.json);
|
|
51
|
+
}
|
|
52
|
+
if (result.exitCode !== undefined)
|
|
53
|
+
process.exitCode = result.exitCode;
|
|
54
|
+
}
|
|
55
|
+
/** Tries the capability table for `args`. Matches the row whose
|
|
56
|
+
* `cli.path` is `[command]` or `[command, positionals[0]]` (the only two
|
|
57
|
+
* path lengths any milestone-2 row uses); returns true when a table row
|
|
58
|
+
* handled the command. */
|
|
59
|
+
function dispatchTable(args) {
|
|
60
|
+
const candidates = [[args.command]];
|
|
61
|
+
if (args.positionals.length > 0)
|
|
62
|
+
candidates.push([args.command, args.positionals[0]]);
|
|
63
|
+
for (const candidatePath of candidates.slice().reverse()) {
|
|
64
|
+
const row = (0, capability_table_1.findCapabilityByCliPath)(candidatePath);
|
|
65
|
+
if (!row || !row.cli)
|
|
66
|
+
continue;
|
|
67
|
+
const consumed = candidatePath.length - 1; // path[0] is the command itself, already consumed
|
|
68
|
+
const cliArgs = {
|
|
69
|
+
positionals: args.positionals.slice(consumed),
|
|
70
|
+
options: args.options,
|
|
71
|
+
};
|
|
72
|
+
const result = row.cli.handler(cliArgs);
|
|
73
|
+
renderCliResult(result, row.cli.jsonMode, args.options);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
// MILESTONE 12 (workflow-apps) — `search` filters the SAME real app
|
|
79
|
+
// discovery `cw app list`/`cw list` use (shell/workflow-app-loader.ts),
|
|
80
|
+
// by id/title/summary, matching `listApps` in the old build.
|
|
81
|
+
function formatSearchResults(keyword, results) {
|
|
82
|
+
if (results.length === 0) {
|
|
83
|
+
return `No workflows matched "${keyword}".\n Tip: cw list for all available workflows.`;
|
|
84
|
+
}
|
|
85
|
+
const lines = [`${results.length} workflow${results.length === 1 ? "" : "s"} matching "${keyword}"`];
|
|
86
|
+
for (const r of results) {
|
|
87
|
+
lines.push(` ${r.id} — ${r.title}`);
|
|
88
|
+
const cut = r.summary.length > 120 ? `${r.summary.slice(0, 119)}…` : r.summary;
|
|
89
|
+
lines.push(` ${cut}`);
|
|
90
|
+
}
|
|
91
|
+
lines.push("");
|
|
92
|
+
lines.push("Use cw info <id> for full details.");
|
|
93
|
+
return lines.join("\n");
|
|
94
|
+
}
|
|
95
|
+
/** The milestone-1 carry-over switch. See file header: never extended
|
|
96
|
+
* again — each arm here is replaced by a capability-table row when its
|
|
97
|
+
* own build-order milestone lands, not edited in place. */
|
|
98
|
+
function dispatchLegacy(args) {
|
|
99
|
+
switch (args.command) {
|
|
100
|
+
case "": {
|
|
101
|
+
process.stdout.write((0, io_1.styledHelp)());
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
case "help": {
|
|
105
|
+
const topic = firstPositional(args);
|
|
106
|
+
if (topic) {
|
|
107
|
+
process.stdout.write((0, help_1.formatCommandHelp)(topic, parseargv_1.suggestCommand));
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
process.stdout.write((0, io_1.styledHelp)());
|
|
111
|
+
}
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// NOTE: "version" is not an arm here — it is a real capability-table
|
|
115
|
+
// row (core/capability-table.ts) that dispatchTable() above always
|
|
116
|
+
// matches first, per the Revision note's "table rows, never a new
|
|
117
|
+
// switch arm" rule. Same for "list", "status", and "sandbox list".
|
|
118
|
+
// `search` filters the real app discovery by title/summary/id (see
|
|
119
|
+
// note above); MILESTONE 12.
|
|
120
|
+
case "search": {
|
|
121
|
+
const keyword = args.positionals.join(" ");
|
|
122
|
+
if (!keyword.trim()) {
|
|
123
|
+
throw new Error('Missing search keyword.\n Tip: cw search architecture to find workflows about architecture.');
|
|
124
|
+
}
|
|
125
|
+
const lower = keyword.toLowerCase();
|
|
126
|
+
const results = (0, workflow_app_loader_1.listWorkflowApps)()
|
|
127
|
+
.filter((a) => String(a.title).toLowerCase().includes(lower) ||
|
|
128
|
+
String(a.summary).toLowerCase().includes(lower) ||
|
|
129
|
+
String(a.id).toLowerCase().includes(lower))
|
|
130
|
+
.map((a) => ({ id: String(a.id), title: String(a.title), summary: String(a.summary) }));
|
|
131
|
+
if ((0, io_1.wantsJson)(args.options)) {
|
|
132
|
+
(0, io_1.printJson)(results);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
process.stdout.write(`${formatSearchResults(keyword, results)}\n`);
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
// NOTE: "plan" and "quickstart" are not arms here any more — both are
|
|
140
|
+
// now real capability-table rows (core/capability-table.ts, milestone
|
|
141
|
+
// 6+7) that dispatchTable() above always matches first.
|
|
142
|
+
// PLACEHOLDER (milestone 3/6, state kernel + pipeline) — real `next`
|
|
143
|
+
// loads run state and returns dispatchable tasks; this milestone only
|
|
144
|
+
// reproduces the io.required missing-run-id refusal.
|
|
145
|
+
case "next": {
|
|
146
|
+
const runId = (0, io_1.required)((0, io_1.optionalArg)(firstPositional(args)), "run id");
|
|
147
|
+
throw new Error(`next is not implemented in this milestone (runId=${runId})`);
|
|
148
|
+
}
|
|
149
|
+
// MILESTONE 8 — `ledger propose|review|verify|apply|list` are now
|
|
150
|
+
// real capability-table rows (core/capability-table.ts) that
|
|
151
|
+
// dispatchTable() above always matches first; this arm is reached
|
|
152
|
+
// only for an unrecognized subcommand (byte-exact to the old
|
|
153
|
+
// build's handleLedger default case). NOTE: "ledger" is
|
|
154
|
+
// intentionally absent from KNOWN_COMMANDS (see cli/parseargv.ts)
|
|
155
|
+
// even though the dispatcher handles it here — a known, preserved
|
|
156
|
+
// wart, not a bug.
|
|
157
|
+
case "ledger": {
|
|
158
|
+
throw new Error("Usage: cw ledger propose|review|verify|apply|list [options]");
|
|
159
|
+
}
|
|
160
|
+
// PLACEHOLDER (milestone 10, scheduling/gc) — real `gc verify` checks
|
|
161
|
+
// whether a run's disk footprint was actually reclaimed; a run that
|
|
162
|
+
// was never reclaimed is not a failure (exit 0), which is exactly the
|
|
163
|
+
// shape this stub reproduces for an unresolvable run id.
|
|
164
|
+
case "gc": {
|
|
165
|
+
const sub = firstPositional(args);
|
|
166
|
+
if (sub === "verify") {
|
|
167
|
+
const runId = (0, io_1.optionalArg)(firstPositional(args, 1));
|
|
168
|
+
const payload = {
|
|
169
|
+
schemaVersion: 1,
|
|
170
|
+
runId: runId ?? null,
|
|
171
|
+
reclaimed: false,
|
|
172
|
+
verified: false,
|
|
173
|
+
tier: "live",
|
|
174
|
+
capability: "re-runnable",
|
|
175
|
+
chainLength: 0,
|
|
176
|
+
checks: [{ name: "located", pass: false, code: "not-reclaimed", detail: "run source not found" }],
|
|
177
|
+
nextAction: "node scripts/cw.js registry refresh --scope home",
|
|
178
|
+
};
|
|
179
|
+
(0, io_1.printJson)(payload);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
throw new Error(`gc ${sub ?? ""} is not implemented in this milestone`);
|
|
183
|
+
}
|
|
184
|
+
// NOTE: "run" is not an arm here any more — run.drive.step/run.drive
|
|
185
|
+
// are now real capability-table rows (core/capability-table.ts,
|
|
186
|
+
// milestone 6+7) that dispatchTable() above always matches first
|
|
187
|
+
// (their handler reproduces the inspect-archive/restore placeholder
|
|
188
|
+
// shapes this arm used to own), per the Revision note's "table rows,
|
|
189
|
+
// never a new switch arm" rule.
|
|
190
|
+
// NOTE: "sandbox" is not an arm here — sandbox.list/show/validate are
|
|
191
|
+
// now real capability-table rows (core/capability-table.ts, milestone
|
|
192
|
+
// 5) that dispatchTable() above always matches first, per the
|
|
193
|
+
// Revision note's "table rows, never a new switch arm" rule.
|
|
194
|
+
// NOTE: "topology" is not an arm here any more — topology.list/show/
|
|
195
|
+
// validate/apply/summary/graph are now real capability-table rows
|
|
196
|
+
// (core/capability-table.ts, milestone 9) that dispatchTable() above
|
|
197
|
+
// always matches first, per the Revision note's "table rows, never a
|
|
198
|
+
// new switch arm" rule.
|
|
199
|
+
// PLACEHOLDER (milestone 3/4, state kernel + contract-migration) —
|
|
200
|
+
// real `migration check`/`prove` resolve a run id or file target; the
|
|
201
|
+
// missing-target refusal is the only shape this milestone reproduces.
|
|
202
|
+
case "migration": {
|
|
203
|
+
const sub = firstPositional(args);
|
|
204
|
+
if (sub === "check" || sub === "prove") {
|
|
205
|
+
const target = (0, io_1.optionalArg)(firstPositional(args, 1));
|
|
206
|
+
if (!target) {
|
|
207
|
+
throw new Error('Missing target (run-id or state/app file).\n Tip: find run ids with "cw run list" or create one with "cw quickstart"');
|
|
208
|
+
}
|
|
209
|
+
throw new Error(`migration ${sub} is not implemented in this milestone`);
|
|
210
|
+
}
|
|
211
|
+
throw new Error(`migration ${sub ?? ""} is not implemented in this milestone`);
|
|
212
|
+
}
|
|
213
|
+
// NOTE: "report" is not an arm here any more — report/report.bundle/
|
|
214
|
+
// report.verify-bundle are now real capability-table rows
|
|
215
|
+
// (core/capability-table.ts, milestones 8/11) that dispatchTable()
|
|
216
|
+
// above always matches first, per the Revision note's "table rows,
|
|
217
|
+
// never a new switch arm" rule.
|
|
218
|
+
default: {
|
|
219
|
+
const hint = (0, parseargv_1.suggestCommand)(args.command);
|
|
220
|
+
const tail = hint ? `. Did you mean: ${hint}?` : "";
|
|
221
|
+
throw new Error(`Unknown command: ${args.command}${tail}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/** Runs one parsed command. Throws on any recoverable failure (the entry
|
|
226
|
+
* point's top-level catch turns that into the `cw: <message>` stderr
|
|
227
|
+
* shape + exit 1); sets `process.exitCode = 1` directly for the
|
|
228
|
+
* fail-closed-but-clean-JSON verbs (never a hard `process.exit`).
|
|
229
|
+
*
|
|
230
|
+
* Tries the capability table FIRST (real rows always win), then falls
|
|
231
|
+
* back to the milestone-1 legacy switch for verbs not yet migrated. */
|
|
232
|
+
function dispatch(args) {
|
|
233
|
+
if (dispatchTable(args))
|
|
234
|
+
return;
|
|
235
|
+
dispatchLegacy(args);
|
|
236
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// cli/entry.ts — the real entry point (`cw` / `cool-workflow` binaries).
|
|
3
|
+
//
|
|
4
|
+
// Byte-exact port of the shape of src/cli.ts + the top-of-function part of
|
|
5
|
+
// src/cli/command-surface.ts's `runCli` in the old build: top-level flag
|
|
6
|
+
// redirects, then dispatch (see cli/dispatch.ts), then the top-level
|
|
7
|
+
// catch that turns any thrown error into the fixed `cw: <message>` /
|
|
8
|
+
// ` Try: <hint>` stderr shape.
|
|
9
|
+
//
|
|
10
|
+
// Color: MILESTONE 11 (reporting/observability) wires shell/term.ts's
|
|
11
|
+
// color primitives here — the "Cool Workflow" help header is bolded and
|
|
12
|
+
// the error path is styled (bold "cw:", red message, dim "Try:"), TTY/
|
|
13
|
+
// env-gated exactly as SPEC/reporting-ux.md's "Color rule" describes.
|
|
14
|
+
// Every conformance case still pipes with NO_COLOR=1 by default (lib.js),
|
|
15
|
+
// so byte content there is unaffected; cli-color-env.case.js exercises
|
|
16
|
+
// the FORCE_COLOR/NO_COLOR/CW_NO_COLOR branches explicitly.
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.recoveryHint = recoveryHint;
|
|
19
|
+
exports.runCli = runCli;
|
|
20
|
+
exports.main = main;
|
|
21
|
+
const parseargv_1 = require("./parseargv");
|
|
22
|
+
const dispatch_1 = require("./dispatch");
|
|
23
|
+
const help_1 = require("../core/format/help");
|
|
24
|
+
const parseargv_2 = require("./parseargv");
|
|
25
|
+
const capability_table_1 = require("../core/capability-table");
|
|
26
|
+
const term_1 = require("../shell/term");
|
|
27
|
+
const io_1 = require("./io");
|
|
28
|
+
/** MILESTONE 2: `version` is now a pure projection of the capability
|
|
29
|
+
* table's `version` row — there is exactly one place its print text
|
|
30
|
+
* lives (core/capability-table.ts's cli handler), not a second
|
|
31
|
+
* hard-coded copy here. `help` has no row of its own (it is cli/
|
|
32
|
+
* entry.ts's own top-level redirect, same as milestone 1); its text
|
|
33
|
+
* comes from core/format/help.ts either way. */
|
|
34
|
+
function printVersion() {
|
|
35
|
+
const row = (0, capability_table_1.findCapability)("version");
|
|
36
|
+
const result = row?.cli?.handler({ positionals: [], options: {} });
|
|
37
|
+
process.stdout.write(result?.text ?? "");
|
|
38
|
+
}
|
|
39
|
+
/** src/cli.ts:18-29 — map a top-level error message to ONE copy-pasteable
|
|
40
|
+
* recovery command. Content-based so it stays correct regardless of which
|
|
41
|
+
* call site threw; returns undefined rather than a wrong guess. */
|
|
42
|
+
function recoveryHint(message) {
|
|
43
|
+
const m = message.toLowerCase();
|
|
44
|
+
if (m.startsWith("unknown command"))
|
|
45
|
+
return "cw help";
|
|
46
|
+
if (m.includes("not configured") || m.includes("agent backend"))
|
|
47
|
+
return "cw doctor";
|
|
48
|
+
if (m.includes("missing") && m.includes("repo"))
|
|
49
|
+
return 'cw -q "<question>" -dir <project-folder>';
|
|
50
|
+
if (m.includes("app") && (m.includes("not found") || m.includes("not available")))
|
|
51
|
+
return "cw app list";
|
|
52
|
+
if (m.includes("run id") || m.includes("run not found"))
|
|
53
|
+
return "cw run list";
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
async function runCli(argv = process.argv.slice(2)) {
|
|
57
|
+
const args = (0, parseargv_1.parseArgv)(argv);
|
|
58
|
+
// Top-level flags: accept --version / -v / --help / -h before command lookup.
|
|
59
|
+
// (src/cli/command-surface.ts:46-55)
|
|
60
|
+
if (args.command?.startsWith("-") || !args.command) {
|
|
61
|
+
if (args.command === "--version" || args.command === "-v" || args.options.v || args.options.version) {
|
|
62
|
+
printVersion();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (!args.command || args.command === "--help" || args.command === "-h" || args.options.h || args.options.help) {
|
|
66
|
+
process.stdout.write((0, io_1.styledHelp)());
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
// Vendor short flags -> --agent-command (src/cli/command-surface.ts:59-62).
|
|
71
|
+
if (args.options.claude)
|
|
72
|
+
args.options["agent-command"] = "builtin:claude";
|
|
73
|
+
if (args.options.codex)
|
|
74
|
+
args.options["agent-command"] = "builtin:codex";
|
|
75
|
+
if (args.options.gemini)
|
|
76
|
+
args.options["agent-command"] = "builtin:gemini";
|
|
77
|
+
if (args.options.deepseek)
|
|
78
|
+
args.options["agent-command"] = "builtin:deepseek";
|
|
79
|
+
// -dir / --dir / -d is a second name for --repo; an explicit --repo wins
|
|
80
|
+
// (src/cli/command-surface.ts:65).
|
|
81
|
+
if (!args.options.repo && args.options.dir)
|
|
82
|
+
args.options.repo = args.options.dir;
|
|
83
|
+
// Presentation flags set env vars before any agent spawn
|
|
84
|
+
// (src/cli/command-surface.ts:73-75).
|
|
85
|
+
if (args.options.verbose)
|
|
86
|
+
process.env.CW_VERBOSE = "1";
|
|
87
|
+
if (args.options["no-color"])
|
|
88
|
+
process.env.CW_NO_COLOR = "1";
|
|
89
|
+
if (args.options.full)
|
|
90
|
+
process.env.CW_OUTPUT = "full";
|
|
91
|
+
// `cw <verb> --help` / `-h` -> per-command help
|
|
92
|
+
// (src/cli/command-surface.ts:80-83).
|
|
93
|
+
if ((args.options.help || args.options.h) && args.command && !args.command.startsWith("-")) {
|
|
94
|
+
process.stdout.write((0, help_1.formatCommandHelp)(args.command, parseargv_2.suggestCommand));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Bare -q / --question -> redirect to quickstart (src/cli/command-surface.ts:88-93).
|
|
98
|
+
if (args.command === "-q" || args.command === "--question") {
|
|
99
|
+
if (!args.options.question && args.positionals[0])
|
|
100
|
+
args.options.question = args.positionals.shift();
|
|
101
|
+
args.command = "quickstart";
|
|
102
|
+
}
|
|
103
|
+
else if (!args.command && typeof args.options.question === "string") {
|
|
104
|
+
args.command = "quickstart";
|
|
105
|
+
}
|
|
106
|
+
(0, dispatch_1.dispatch)(args);
|
|
107
|
+
}
|
|
108
|
+
/** Top-level run wrapper matching src/cli.ts's catch shape byte-for-byte:
|
|
109
|
+
* `cw: <message>\n` then, only when a hint matches, ` Try: <hint>\n` on
|
|
110
|
+
* stderr; `process.exitCode = 1` (never a hard `process.exit`). */
|
|
111
|
+
function main(argv = process.argv.slice(2)) {
|
|
112
|
+
return runCli(argv).catch((error) => {
|
|
113
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
114
|
+
process.stderr.write(`${(0, term_1.bold)("cw:", process.stderr)} ${(0, term_1.red)(message, process.stderr)}\n`);
|
|
115
|
+
const hint = recoveryHint(message);
|
|
116
|
+
if (hint)
|
|
117
|
+
process.stderr.write(` ${(0, term_1.dim)("Try:", process.stderr)} ${hint}\n`);
|
|
118
|
+
process.exitCode = 1;
|
|
119
|
+
});
|
|
120
|
+
}
|
package/dist/cli/io.js
CHANGED
|
@@ -1,16 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// cli/io.ts — shared CLI input/output helpers.
|
|
3
|
+
//
|
|
4
|
+
// Byte-exact port of src/cli/io.ts in the old build. Pure + zero-dep: arg
|
|
5
|
+
// coercion + JSON stdout. See SPEC/cli-surface.md "Shared io helpers".
|
|
6
|
+
//
|
|
7
|
+
// MILESTONE 11 (reporting/observability) adds `styledHelp` — the one
|
|
8
|
+
// place `formatHelp()`'s plain text gets its "Cool Workflow" header
|
|
9
|
+
// bolded, TTY/env-gated via shell/term.ts's `bold()`. Kept here (not in
|
|
10
|
+
// core/format/help.ts, which stays a pure text generator) since it needs
|
|
11
|
+
// shell/term.ts's env/TTY read.
|
|
5
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.styledHelp = styledHelp;
|
|
6
14
|
exports.required = required;
|
|
7
15
|
exports.optionalArg = optionalArg;
|
|
8
16
|
exports.printJson = printJson;
|
|
9
17
|
exports.wantsJson = wantsJson;
|
|
18
|
+
const help_1 = require("../core/format/help");
|
|
19
|
+
const term_1 = require("../shell/term");
|
|
20
|
+
/** Bold ONLY the fixed "Cool Workflow" header line of `formatHelp()`'s
|
|
21
|
+
* plain text. */
|
|
22
|
+
function styledHelp() {
|
|
23
|
+
const text = (0, help_1.formatHelp)();
|
|
24
|
+
return text.replace(/^Cool Workflow\n/, `${(0, term_1.bold)("Cool Workflow")}\n`);
|
|
25
|
+
}
|
|
10
26
|
/** Require a positional/option value or fail with a copy-pasteable recovery tip. */
|
|
11
27
|
function required(value, label) {
|
|
12
|
-
if (!value)
|
|
28
|
+
if (!value) {
|
|
13
29
|
throw new Error(`Missing ${label}.\n Tip: find run ids with "cw run list" or create one with "cw quickstart"`);
|
|
30
|
+
}
|
|
14
31
|
return value;
|
|
15
32
|
}
|
|
16
33
|
/** Normalize an optional CLI arg to a trimmed non-empty string, else undefined. */
|