cool-workflow 0.1.98 → 0.2.1

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.
Files changed (315) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/README.md +18 -7
  4. package/apps/architecture-review/app.json +2 -2
  5. package/apps/architecture-review/workflow.js +12 -12
  6. package/apps/architecture-review-fast/app.json +1 -1
  7. package/apps/end-to-end-golden-path/app.json +1 -1
  8. package/apps/pr-review-fix-ci/app.json +1 -1
  9. package/apps/release-cut/app.json +1 -1
  10. package/apps/research-synthesis/app.json +1 -1
  11. package/dist/cli/dispatch.js +236 -0
  12. package/dist/cli/entry.js +120 -0
  13. package/dist/cli/io.js +21 -4
  14. package/dist/cli/parseargv.js +157 -0
  15. package/dist/cli.js +6 -33
  16. package/dist/core/capability-table.js +3518 -0
  17. package/dist/core/format/help.js +314 -0
  18. package/dist/{state-explosion/format.js → core/format/state-explosion-text.js} +10 -1
  19. package/dist/core/hash.js +137 -0
  20. package/dist/core/multi-agent/candidate-scoring.js +219 -0
  21. package/dist/core/multi-agent/collaboration.js +481 -0
  22. package/dist/core/multi-agent/coordinator.js +515 -0
  23. package/dist/core/multi-agent/eval-replay.js +306 -0
  24. package/dist/core/multi-agent/runtime.js +929 -0
  25. package/dist/core/multi-agent/topology.js +298 -0
  26. package/dist/core/multi-agent/trust-policy.js +197 -0
  27. package/dist/core/pipeline/commit-gate.js +320 -0
  28. package/dist/{pipeline-contract.js → core/pipeline/contract.js} +24 -37
  29. package/dist/core/pipeline/dispatch.js +103 -0
  30. package/dist/core/pipeline/drive-decide.js +227 -0
  31. package/dist/core/pipeline/error-feedback.js +161 -0
  32. package/dist/core/pipeline/loop-expansion.js +124 -0
  33. package/dist/{result-normalize.js → core/pipeline/result-normalize.js} +14 -37
  34. package/dist/core/pipeline/runner.js +230 -0
  35. package/dist/{contract-migration.js → core/state/contract-migration.js} +68 -92
  36. package/dist/{state-migrations.js → core/state/migrations.js} +103 -96
  37. package/dist/core/state/node-projection.js +95 -0
  38. package/dist/core/state/node-snapshot.js +230 -0
  39. package/dist/core/state/run-paths.js +93 -0
  40. package/dist/{schema-validate.js → core/state/schema-validate.js} +35 -28
  41. package/dist/core/state/schema.js +50 -0
  42. package/dist/core/state/state-explosion/digest.js +243 -0
  43. package/dist/core/state/state-explosion/graph.js +527 -0
  44. package/dist/{state-explosion → core/state/state-explosion}/helpers.js +34 -3
  45. package/dist/core/state/state-explosion/report.js +187 -0
  46. package/dist/{state-explosion → core/state/state-explosion}/size.js +25 -7
  47. package/dist/{state-node.js → core/state/state-node.js} +90 -113
  48. package/dist/core/state/types.js +19 -0
  49. package/dist/{validation.js → core/state/validation.js} +64 -131
  50. package/dist/core/trust/evidence-grounding.js +134 -0
  51. package/dist/core/trust/ledger.js +199 -0
  52. package/dist/{telemetry-attestation.js → core/trust/telemetry-attestation.js} +94 -68
  53. package/dist/core/trust/telemetry-ledger.js +127 -0
  54. package/dist/core/types.js +20 -0
  55. package/dist/core/version.js +16 -0
  56. package/dist/{workflow-app-framework.js → core/workflow-apps/app-schema.js} +337 -426
  57. package/dist/mcp/dispatch.js +104 -0
  58. package/dist/mcp/server.js +144 -0
  59. package/dist/mcp-server.js +6 -84
  60. package/dist/{agent-config.js → shell/agent-config.js} +118 -71
  61. package/dist/shell/app-run-cli.js +88 -0
  62. package/dist/shell/audit-cli.js +259 -0
  63. package/dist/shell/audit-provenance.js +83 -0
  64. package/dist/shell/candidate-scoring-io.js +459 -0
  65. package/dist/shell/collaboration-io.js +264 -0
  66. package/dist/shell/commit-summary.js +104 -0
  67. package/dist/shell/commit.js +290 -0
  68. package/dist/shell/coordinator-io.js +476 -0
  69. package/dist/shell/demo-cli.js +19 -0
  70. package/dist/shell/dispatch.js +162 -0
  71. package/dist/shell/doctor.js +292 -0
  72. package/dist/shell/drive.js +885 -0
  73. package/dist/shell/error-feedback-io.js +305 -0
  74. package/dist/shell/eval-io.js +473 -0
  75. package/dist/{multi-agent-eval/format.js → shell/eval-text.js} +78 -49
  76. package/dist/{evidence-reasoning.js → shell/evidence-reasoning.js} +124 -255
  77. package/dist/shell/exec-backend-cli.js +88 -0
  78. package/dist/shell/execution-backend/agent.js +507 -0
  79. package/dist/shell/execution-backend/ci.js +15 -0
  80. package/dist/shell/execution-backend/container.js +69 -0
  81. package/dist/shell/execution-backend/envelopes.js +55 -0
  82. package/dist/shell/execution-backend/local.js +113 -0
  83. package/dist/shell/execution-backend/probes.js +175 -0
  84. package/dist/shell/execution-backend/registry.js +402 -0
  85. package/dist/shell/execution-backend/remote.js +128 -0
  86. package/dist/shell/execution-backend/types.js +11 -0
  87. package/dist/shell/feedback-cli.js +81 -0
  88. package/dist/shell/feedback-operations.js +48 -0
  89. package/dist/shell/fs-atomic.js +276 -0
  90. package/dist/shell/harness.js +98 -0
  91. package/dist/shell/ledger-cli.js +212 -0
  92. package/dist/shell/ledger-io.js +169 -0
  93. package/dist/shell/man-cli.js +89 -0
  94. package/dist/shell/metrics-cli.js +100 -0
  95. package/dist/shell/multi-agent-cli.js +1002 -0
  96. package/dist/shell/multi-agent-host.js +563 -0
  97. package/dist/shell/multi-agent-io.js +387 -0
  98. package/dist/{multi-agent-operator-ux.js → shell/multi-agent-operator-ux.js} +234 -191
  99. package/dist/shell/node-store.js +124 -0
  100. package/dist/{observability/format.js → shell/observability-format.js} +7 -1
  101. package/dist/{observability/intake.js → shell/observability-intake.js} +79 -56
  102. package/dist/{observability.js → shell/observability.js} +159 -332
  103. package/dist/{onramp.js → shell/onramp.js} +11 -0
  104. package/dist/{operator-ux/format.js → shell/operator-ux-text.js} +250 -239
  105. package/dist/shell/operator-ux.js +431 -0
  106. package/dist/shell/orchestrator.js +231 -0
  107. package/dist/shell/pipeline-cli.js +667 -0
  108. package/dist/shell/pipeline.js +217 -0
  109. package/dist/shell/reclamation-io.js +1366 -0
  110. package/dist/shell/registry-cli.js +344 -0
  111. package/dist/{remote-source.js → shell/remote-source.js} +2 -2
  112. package/dist/shell/report-cli.js +101 -0
  113. package/dist/shell/report-view-cli.js +117 -0
  114. package/dist/{orchestrator → shell}/report.js +289 -282
  115. package/dist/shell/reporter.js +62 -0
  116. package/dist/shell/run-export-cli.js +106 -0
  117. package/dist/shell/run-export.js +680 -0
  118. package/dist/shell/run-registry-io.js +1014 -0
  119. package/dist/shell/run-store.js +164 -0
  120. package/dist/{sandbox-profile.js → shell/sandbox-profile.js} +134 -95
  121. package/dist/{scheduler.js → shell/scheduler-io.js} +257 -48
  122. package/dist/shell/scheduling-io.js +321 -0
  123. package/dist/shell/state-cli.js +181 -0
  124. package/dist/shell/state-explosion-cli.js +197 -0
  125. package/dist/shell/telemetry-cli.js +85 -0
  126. package/dist/{telemetry-demo.js → shell/telemetry-demo.js} +149 -119
  127. package/dist/shell/telemetry-ledger-io.js +132 -0
  128. package/dist/{term.js → shell/term.js} +36 -46
  129. package/dist/shell/topology-io.js +361 -0
  130. package/dist/shell/trust-audit.js +472 -0
  131. package/dist/{multi-agent-trust.js → shell/trust-policy-io.js} +67 -205
  132. package/dist/shell/verifier.js +48 -0
  133. package/dist/shell/workbench-host.js +258 -0
  134. package/dist/shell/workbench-text.js +18 -0
  135. package/dist/shell/workbench.js +170 -0
  136. package/dist/shell/worker-cli.js +124 -0
  137. package/dist/shell/worker-isolation.js +852 -0
  138. package/dist/shell/workflow-app-loader.js +650 -0
  139. package/docs/agent-delegation-drive.7.md +4 -0
  140. package/docs/cli-mcp-parity.7.md +282 -219
  141. package/docs/contract-migration-tooling.7.md +4 -0
  142. package/docs/control-plane-scheduling.7.md +4 -0
  143. package/docs/durable-state-and-locking.7.md +4 -0
  144. package/docs/evidence-adoption-reasoning-chain.7.md +4 -0
  145. package/docs/execution-backends.7.md +4 -0
  146. package/docs/multi-agent-cli-mcp-surface.7.md +4 -0
  147. package/docs/multi-agent-eval-replay-harness.7.md +4 -0
  148. package/docs/multi-agent-operator-ux.7.md +4 -0
  149. package/docs/node-snapshot-diff-replay.7.md +4 -0
  150. package/docs/observability-cost-accounting.7.md +6 -1
  151. package/docs/project-index.md +137 -71
  152. package/docs/real-execution-backends.7.md +4 -0
  153. package/docs/release-and-migration.7.md +4 -0
  154. package/docs/release-tooling.7.md +4 -0
  155. package/docs/remote-source-review.7.md +4 -4
  156. package/docs/report-verifiable-bundle.7.md +1 -1
  157. package/docs/run-registry-control-plane.7.md +4 -0
  158. package/docs/run-retention-reclamation.7.md +25 -0
  159. package/docs/security-trust-hardening.7.md +3 -1
  160. package/docs/state-explosion-management.7.md +4 -0
  161. package/docs/team-collaboration.7.md +4 -0
  162. package/docs/web-desktop-workbench.7.md +15 -1
  163. package/manifest/plugin.manifest.json +1 -1
  164. package/manifest/source-context-profiles.json +9 -13
  165. package/package.json +1 -1
  166. package/scripts/agents/agent-adapter-core.js +22 -2
  167. package/scripts/agents/claude-p-agent.js +8 -3
  168. package/scripts/agents/cw-attest-wrap.js +2 -2
  169. package/scripts/agents/gemini-agent.js +5 -1
  170. package/scripts/agents/opencode-agent.js +5 -1
  171. package/scripts/bump-version.js +4 -3
  172. package/scripts/canonical-apps.js +4 -4
  173. package/scripts/dogfood-architecture-review.js +2 -3
  174. package/scripts/dogfood-release.js +3 -3
  175. package/scripts/gen-parity-doc.js +15 -2
  176. package/scripts/golden-path.js +4 -4
  177. package/scripts/onramp-check.js +1 -1
  178. package/scripts/parity-check.js +38 -21
  179. package/scripts/release-flow.js +2 -2
  180. package/scripts/sync-project-index.js +51 -27
  181. package/scripts/validate-run-state-schema.js +2 -2
  182. package/scripts/version-sync-check.js +30 -30
  183. package/dist/candidate-scoring.js +0 -729
  184. package/dist/capability-core.js +0 -1189
  185. package/dist/capability-registry.js +0 -885
  186. package/dist/cli/command-surface.js +0 -494
  187. package/dist/cli/format.js +0 -56
  188. package/dist/cli/handlers/audit.js +0 -82
  189. package/dist/cli/handlers/blackboard.js +0 -81
  190. package/dist/cli/handlers/candidate.js +0 -40
  191. package/dist/cli/handlers/clones.js +0 -34
  192. package/dist/cli/handlers/collaboration.js +0 -61
  193. package/dist/cli/handlers/eval.js +0 -40
  194. package/dist/cli/handlers/ledger.js +0 -169
  195. package/dist/cli/handlers/maintenance.js +0 -107
  196. package/dist/cli/handlers/multi-agent.js +0 -165
  197. package/dist/cli/handlers/node.js +0 -41
  198. package/dist/cli/handlers/operational.js +0 -155
  199. package/dist/cli/handlers/operator.js +0 -146
  200. package/dist/cli/handlers/registry.js +0 -68
  201. package/dist/cli/handlers/run.js +0 -153
  202. package/dist/cli/handlers/scheduling.js +0 -132
  203. package/dist/cli/handlers/workbench.js +0 -41
  204. package/dist/cli/handlers/worker.js +0 -45
  205. package/dist/cli/run-summary.js +0 -45
  206. package/dist/clones.js +0 -162
  207. package/dist/collaboration.js +0 -726
  208. package/dist/commit.js +0 -592
  209. package/dist/compare.js +0 -18
  210. package/dist/coordinator/classify.js +0 -45
  211. package/dist/coordinator/paths.js +0 -42
  212. package/dist/coordinator/util.js +0 -126
  213. package/dist/coordinator.js +0 -990
  214. package/dist/daemon.js +0 -44
  215. package/dist/dispatch.js +0 -250
  216. package/dist/doctor.js +0 -212
  217. package/dist/drive.js +0 -864
  218. package/dist/error-feedback.js +0 -419
  219. package/dist/evidence-grounding.js +0 -184
  220. package/dist/execution-backend/agent.js +0 -354
  221. package/dist/execution-backend/probes.js +0 -112
  222. package/dist/execution-backend/util.js +0 -47
  223. package/dist/execution-backend.js +0 -961
  224. package/dist/gates.js +0 -48
  225. package/dist/harness.js +0 -61
  226. package/dist/ledger.js +0 -313
  227. package/dist/loop-expansion.js +0 -60
  228. package/dist/mcp/tool-call.js +0 -470
  229. package/dist/mcp/tool-definitions.js +0 -1066
  230. package/dist/mcp-surface.js +0 -30
  231. package/dist/multi-agent/graph.js +0 -84
  232. package/dist/multi-agent/helpers.js +0 -141
  233. package/dist/multi-agent/ids.js +0 -20
  234. package/dist/multi-agent/paths.js +0 -22
  235. package/dist/multi-agent-eval/normalize.js +0 -51
  236. package/dist/multi-agent-eval.js +0 -678
  237. package/dist/multi-agent-host.js +0 -777
  238. package/dist/multi-agent.js +0 -984
  239. package/dist/node-projection.js +0 -59
  240. package/dist/node-snapshot.js +0 -260
  241. package/dist/operator-ux.js +0 -631
  242. package/dist/orchestrator/app-operations.js +0 -211
  243. package/dist/orchestrator/audit-operations.js +0 -182
  244. package/dist/orchestrator/candidate-operations.js +0 -117
  245. package/dist/orchestrator/cli-options.js +0 -294
  246. package/dist/orchestrator/collaboration-operations.js +0 -86
  247. package/dist/orchestrator/feedback-operations.js +0 -81
  248. package/dist/orchestrator/host-operations.js +0 -78
  249. package/dist/orchestrator/lifecycle-operations.js +0 -650
  250. package/dist/orchestrator/migration-operations.js +0 -44
  251. package/dist/orchestrator/multi-agent-operations.js +0 -362
  252. package/dist/orchestrator/topology-operations.js +0 -84
  253. package/dist/orchestrator.js +0 -925
  254. package/dist/pipeline-runner.js +0 -285
  255. package/dist/reclamation/hash.js +0 -72
  256. package/dist/reclamation.js +0 -812
  257. package/dist/reporter.js +0 -67
  258. package/dist/run-export.js +0 -815
  259. package/dist/run-registry/derive.js +0 -175
  260. package/dist/run-registry/format.js +0 -124
  261. package/dist/run-registry/gc.js +0 -251
  262. package/dist/run-registry/policy.js +0 -16
  263. package/dist/run-registry/queue.js +0 -115
  264. package/dist/run-registry.js +0 -850
  265. package/dist/run-state-schema.js +0 -68
  266. package/dist/scheduling.js +0 -184
  267. package/dist/state-explosion.js +0 -1014
  268. package/dist/state.js +0 -367
  269. package/dist/telemetry-ledger.js +0 -196
  270. package/dist/topology.js +0 -565
  271. package/dist/triggers.js +0 -184
  272. package/dist/trust-audit.js +0 -644
  273. package/dist/types/blackboard.js +0 -2
  274. package/dist/types/candidate.js +0 -2
  275. package/dist/types/collaboration.js +0 -2
  276. package/dist/types/core.js +0 -2
  277. package/dist/types/drive.js +0 -10
  278. package/dist/types/error-feedback.js +0 -2
  279. package/dist/types/evidence-reasoning.js +0 -2
  280. package/dist/types/execution-backend.js +0 -2
  281. package/dist/types/multi-agent.js +0 -2
  282. package/dist/types/observability.js +0 -2
  283. package/dist/types/pipeline.js +0 -2
  284. package/dist/types/reclamation.js +0 -8
  285. package/dist/types/report-bundle.js +0 -6
  286. package/dist/types/result.js +0 -2
  287. package/dist/types/run-registry.js +0 -2
  288. package/dist/types/run.js +0 -2
  289. package/dist/types/sandbox.js +0 -2
  290. package/dist/types/schedule.js +0 -2
  291. package/dist/types/state-node.js +0 -2
  292. package/dist/types/topology.js +0 -2
  293. package/dist/types/trust.js +0 -2
  294. package/dist/types/workbench.js +0 -2
  295. package/dist/types/worker.js +0 -2
  296. package/dist/types/workflow-app.js +0 -2
  297. package/dist/types.js +0 -44
  298. package/dist/util/fingerprint.js +0 -19
  299. package/dist/util/fingerprint.test.js +0 -27
  300. package/dist/verifier.js +0 -78
  301. package/dist/version.js +0 -8
  302. package/dist/workbench-host.js +0 -192
  303. package/dist/workbench.js +0 -192
  304. package/dist/worker-accept/acceptance.js +0 -114
  305. package/dist/worker-accept/blackboard-fanout.js +0 -80
  306. package/dist/worker-accept/blackboard-linkage.js +0 -19
  307. package/dist/worker-accept/context.js +0 -2
  308. package/dist/worker-accept/telemetry-ledger.js +0 -126
  309. package/dist/worker-accept/validation.js +0 -77
  310. package/dist/worker-accept/verifier-completion.js +0 -73
  311. package/dist/worker-isolation/helpers.js +0 -51
  312. package/dist/worker-isolation/paths.js +0 -46
  313. package/dist/worker-isolation.js +0 -656
  314. package/dist/workflow-api.js +0 -131
  315. /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.1.98",
4
+ "version": "0.2.1",
5
5
  "author": {
6
6
  "name": "COOLWHITE LLC"
7
7
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cool-workflow",
3
- "version": "0.1.98",
3
+ "version": "0.2.1",
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 your AI report, already proven. Point your agent at any repo or folder and get a saved, cited report you can re-verify offline." width="100%">
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
 
@@ -64,16 +64,18 @@ cw demo tamper
64
64
  ### 2 · Ask a question about your code — one command
65
65
 
66
66
  ```bash
67
- cw -q "What are the main risks here?"
67
+ cw -q "How does auth work end-to-end here?"
68
68
  ```
69
69
 
70
- CW auto-detects the current repo and the first agent on your `PATH`. Pin a specific one with a flag
71
- (`-claude`, `-codex`, `-gemini`, `-deepseek`). Point it anywhere no `cd` required or review a
72
- **remote repo by URL** and CW clones, snapshots, and reviews the checkout:
70
+ Any question works, not only a risk audit architecture questions, "is it safe to change X",
71
+ "what would break if Y rotated" all get a direct, cited answer. CW auto-detects the current repo
72
+ and the first agent on your `PATH`. Pin a specific one with a flag (`-claude`, `-codex`, `-gemini`,
73
+ `-deepseek`). Point it anywhere — no `cd` required — or review a **remote repo by URL** and CW
74
+ clones, snapshots, and reviews the checkout:
73
75
 
74
76
  ```bash
75
77
  cw -q "What are the security risks?" -dir /path/to/project
76
- cw -q "What are the risks?" --link https://github.com/owner/repo
78
+ cw -q "Is it safe to swap this queue for Redis?" --link https://github.com/owner/repo
77
79
  ```
78
80
 
79
81
  **Not just code.** Aim CW at a folder of docs, notes, or papers and it reads them as sources for the
@@ -110,6 +112,12 @@ is long, parallel, or high-stakes, you can't tell what happened or trust the res
110
112
  | **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
113
  | **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
114
 
115
+ **What CW is not.** CW is not the model — it never calls a model API and never holds your keys;
116
+ your agent does that work out of process. It is not a CI system or a build tool — it keeps and
117
+ checks the record of agent work, it does not stand in for your tests or your release pipeline.
118
+ And it is not a big framework to take up — it is a small set of commands over plain `.cw/` files
119
+ on your own disk, not a library your code has to be built around.
120
+
113
121
  ## How It Works
114
122
 
115
123
  CW is a small TypeScript tool with **zero runtime dependencies**. It drives your agent over a repo — or
@@ -133,6 +141,9 @@ ask simple → run simple → verify simple → resume simple
133
141
  | `research-synthesis` | Answer a question over a local folder of files — your docs, notes, or papers |
134
142
  | `release-cut` | Run a gated, reviewed release with dry-run evidence |
135
143
 
144
+ Every app writes the same thing: a saved, cited report you can re-verify offline. These four are
145
+ the main lanes; `cw app list` shows all eight installed apps.
146
+
136
147
  ```bash
137
148
  cw app list # see everything installed
138
149
  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.1.98",
6
+ "version": "0.2.1",
7
7
  "author": "COOLWHITE LLC",
8
8
  "inputs": [
9
9
  {
@@ -16,7 +16,7 @@
16
16
  "name": "question",
17
17
  "type": "string",
18
18
  "required": true,
19
- "description": "Architecture question or decision to review."
19
+ "description": "Architecture question or decision to review. Every phase scopes its work to this question - not only a fixed risk list."
20
20
  },
21
21
  {
22
22
  "name": "invariant",
@@ -8,7 +8,7 @@ module.exports = ({ workflow, phase, parallel, agent, artifact, input }) => {
8
8
  input("question", {
9
9
  type: "string",
10
10
  required: true,
11
- description: "Architecture question or decision to review."
11
+ description: "Architecture question or decision to review. Every phase scopes its work to this question - not only a fixed risk list."
12
12
  }),
13
13
  input("invariant", {
14
14
  type: "string",
@@ -41,54 +41,54 @@ module.exports = ({ workflow, phase, parallel, agent, artifact, input }) => {
41
41
  ),
42
42
  agent(
43
43
  "map:web-client",
44
- "Map web/client/UI boundaries, local state, backend dependencies, build/runtime assumptions, and candidate risks in {{repo}}. Focus: {{focus}}. Return exact files and commands that informed the map.",
44
+ "Map web/client/UI boundaries, local state, backend dependencies, build/runtime assumptions, and candidate risks in {{repo}} as they relate to {{question}}. Focus: {{focus}}. Invariants: {{invariant}}. Return exact files and commands that informed the map.",
45
45
  { sandboxProfileId: "readonly" }
46
46
  ),
47
47
  agent(
48
48
  "map:db-security",
49
- "Map database, persistence, migrations, secrets, auth, permissions, and security-sensitive paths in {{repo}}. Return candidate risks with file paths, config names, and uncertainty boundaries.",
49
+ "Map database, persistence, migrations, secrets, auth, permissions, and security-sensitive paths in {{repo}} as they relate to {{question}}. Focus: {{focus}}. Invariants: {{invariant}}. Return candidate risks with file paths, config names, and uncertainty boundaries.",
50
50
  { sandboxProfileId: "readonly" }
51
51
  ),
52
52
  agent(
53
53
  "map:deploy-config",
54
- "Map deployment, CI, package scripts, Docker or compose files, reverse proxies, environment config, supervision, and operational assumptions. Return concrete files and release or runtime risks.",
54
+ "Map deployment, CI, package scripts, Docker or compose files, reverse proxies, environment config, supervision, and operational assumptions in {{repo}} as they relate to {{question}}. Focus: {{focus}}. Invariants: {{invariant}}. Return concrete files and release or runtime risks.",
55
55
  { sandboxProfileId: "readonly" }
56
56
  ),
57
57
  agent(
58
58
  "map:jobs-operators",
59
- "Map background jobs, admin/operator surfaces, queues, scheduled work, generated files, state transitions, and failure recovery paths. Identify missing or non-applicable areas explicitly.",
59
+ "Map background jobs, admin/operator surfaces, queues, scheduled work, generated files, state transitions, and failure recovery paths in {{repo}} as they relate to {{question}}. Focus: {{focus}}. Invariants: {{invariant}}. Identify missing or non-applicable areas explicitly.",
60
60
  { sandboxProfileId: "readonly" }
61
61
  ),
62
62
  agent(
63
63
  "map:transport-core",
64
- "Map protocol, daemon, transport, rendering, networking, worker isolation, or core engine boundaries when present. If absent, explain why with inspected evidence.",
64
+ "Map protocol, daemon, transport, rendering, networking, worker isolation, or core engine boundaries when present in {{repo}}, as they relate to {{question}}. Focus: {{focus}}. Invariants: {{invariant}}. If absent, explain why with inspected evidence.",
65
65
  { sandboxProfileId: "readonly" }
66
66
  )
67
67
  ]),
68
68
  parallel("Assess", [
69
69
  agent(
70
70
  "assess:security",
71
- "Assess mapper findings through a security lens. Separate real, conditional, non-issue, and unknown risks with evidence, falsifiers, and exact files or config keys.",
71
+ "Assess mapper findings through a security lens as they relate to {{question}}. Focus: {{focus}}. Invariants: {{invariant}}. Separate real, conditional, non-issue, and unknown risks with evidence, falsifiers, and exact files or config keys.",
72
72
  { sandboxProfileId: "readonly" }
73
73
  ),
74
74
  agent(
75
75
  "assess:data-correctness",
76
- "Assess data correctness, schema drift, persistence invariants, concurrency, transactions, cache behavior, and state corruption risks. Tie every important claim to inspected evidence.",
76
+ "Assess data correctness, schema drift, persistence invariants, concurrency, transactions, cache behavior, and state corruption risks as they relate to {{question}}. Focus: {{focus}}. Invariants: {{invariant}}. Tie every important claim to inspected evidence.",
77
77
  { sandboxProfileId: "readonly" }
78
78
  ),
79
79
  agent(
80
80
  "assess:failure-modes",
81
- "Assess startup, shutdown, retries, partial failure, dependency outage, backup/restore, release rollback, and recovery behavior. Identify deterministic commands that could verify the claims.",
81
+ "Assess startup, shutdown, retries, partial failure, dependency outage, backup/restore, release rollback, and recovery behavior as they relate to {{question}}. Focus: {{focus}}. Invariants: {{invariant}}. Identify deterministic commands that could verify the claims.",
82
82
  { sandboxProfileId: "readonly" }
83
83
  ),
84
84
  agent(
85
85
  "assess:scale-ops",
86
- "Assess scale, operational complexity, observability, configuration, packaging, deployment, and maintenance risks. Include exact files, scripts, or missing controls.",
86
+ "Assess scale, operational complexity, observability, configuration, packaging, deployment, and maintenance risks as they relate to {{question}}. Focus: {{focus}}. Invariants: {{invariant}}. Include exact files, scripts, or missing controls.",
87
87
  { sandboxProfileId: "readonly" }
88
88
  ),
89
89
  agent(
90
90
  "assess:maintainability",
91
- "Assess module boundaries, ownership clarity, coupling, extensibility, testability, and future change risk. Distinguish architectural risks from style preferences.",
91
+ "Assess module boundaries, ownership clarity, coupling, extensibility, testability, and future change risk as they relate to {{question}}. Focus: {{focus}}. Invariants: {{invariant}}. Distinguish architectural risks from style preferences.",
92
92
  { sandboxProfileId: "readonly" }
93
93
  ),
94
94
  agent(
@@ -100,7 +100,7 @@ module.exports = ({ workflow, phase, parallel, agent, artifact, input }) => {
100
100
  phase("Verify", [
101
101
  agent(
102
102
  "verify:p0-p2-risks",
103
- "Re-open evidence for every candidate P0/P1/P2 risk. Confirm real risks, downgrade unsupported concerns, and list exact file paths, commands, logs, or unknowns. The cw:result evidence array must cite durable locators.",
103
+ "Re-open evidence for every candidate P0/P1/P2 risk found so far, judged against {{question}}. Confirm real risks, downgrade unsupported concerns, and list exact file paths, commands, logs, or unknowns. The cw:result evidence array must cite durable locators.",
104
104
  { requiresEvidence: true, sandboxProfileId: "readonly" }
105
105
  )
106
106
  ]),
@@ -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.1.98",
6
+ "version": "0.2.1",
7
7
  "author": "COOLWHITE LLC",
8
8
  "inputs": [
9
9
  {
@@ -3,7 +3,7 @@
3
3
  "id": "end-to-end-golden-path",
4
4
  "title": "End-to-End Golden Path",
5
5
  "summary": "Deterministic one-worker workflow app for proving the CW integration chain.",
6
- "version": "0.1.98",
6
+ "version": "0.2.1",
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.1.98",
6
+ "version": "0.2.1",
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.1.98",
6
+ "version": "0.2.1",
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.1.98",
6
+ "version": "0.2.1",
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 (docs/rebuild/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 docs/rebuild/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
- // Shared CLI input/output helpers, extracted from command-surface.ts so the
3
- // dispatcher and per-command handler modules import ONE copy instead of carrying
4
- // these in the god-object. Pure + zero-dep: arg coercion + JSON stdout.
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. */