cool-workflow 0.2.2 → 0.2.3

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 (136) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/apps/architecture-review/app.json +1 -1
  4. package/apps/architecture-review-fast/app.json +1 -1
  5. package/apps/end-to-end-golden-path/app.json +1 -1
  6. package/apps/pr-review-fix-ci/app.json +1 -1
  7. package/apps/release-cut/app.json +1 -1
  8. package/apps/research-synthesis/app.json +1 -1
  9. package/dist/cli/dispatch.js +11 -5
  10. package/dist/cli/entry.js +41 -1
  11. package/dist/cli/io.js +6 -2
  12. package/dist/cli/parseargv.js +1 -0
  13. package/dist/core/capability-data.js +1 -0
  14. package/dist/core/format/completion.js +68 -0
  15. package/dist/core/format/help.js +25 -6
  16. package/dist/core/format/safe-json.js +73 -0
  17. package/dist/core/format/state-explosion-text.js +1 -1
  18. package/dist/core/multi-agent/candidate-scoring.js +5 -1
  19. package/dist/core/multi-agent/collaboration.js +3 -3
  20. package/dist/core/multi-agent/coordinator.js +5 -5
  21. package/dist/core/multi-agent/runtime.js +4 -4
  22. package/dist/core/multi-agent/topology.js +3 -3
  23. package/dist/core/pipeline/dispatch.js +18 -4
  24. package/dist/core/pipeline/drive-decide.js +2 -1
  25. package/dist/core/state/migrations.js +16 -1
  26. package/dist/core/state/state-explosion/digest.js +13 -13
  27. package/dist/core/state/state-explosion/graph.js +17 -11
  28. package/dist/core/state/state-explosion/report.js +6 -6
  29. package/dist/core/util/numeric-flag.js +40 -0
  30. package/dist/core/version.js +1 -1
  31. package/dist/mcp/server.js +99 -11
  32. package/dist/shell/audit-cli.js +57 -25
  33. package/dist/shell/coordinator-io.js +73 -13
  34. package/dist/shell/dispatch.js +1 -1
  35. package/dist/shell/doctor.js +80 -1
  36. package/dist/shell/drive.js +243 -49
  37. package/dist/shell/eval-text.js +2 -2
  38. package/dist/shell/evidence-reasoning.js +4 -4
  39. package/dist/shell/execution-backend/agent.js +20 -1
  40. package/dist/shell/execution-backend/container.js +4 -1
  41. package/dist/shell/execution-backend/local.js +4 -1
  42. package/dist/shell/feedback-cli.js +6 -6
  43. package/dist/shell/fs-atomic.js +218 -29
  44. package/dist/shell/man-cli.js +6 -0
  45. package/dist/shell/metrics-cli.js +2 -1
  46. package/dist/shell/multi-agent-cli.js +367 -323
  47. package/dist/shell/multi-agent-host.js +9 -9
  48. package/dist/shell/multi-agent-operator-ux.js +80 -38
  49. package/dist/shell/node-store.js +10 -4
  50. package/dist/shell/observability.js +1 -1
  51. package/dist/shell/operator-ux-text.js +22 -22
  52. package/dist/shell/operator-ux.js +15 -14
  53. package/dist/shell/orchestrator.js +49 -38
  54. package/dist/shell/pipeline-cli.js +87 -40
  55. package/dist/shell/reclamation-io.js +14 -4
  56. package/dist/shell/registry-cli.js +19 -17
  57. package/dist/shell/remote-source.js +13 -8
  58. package/dist/shell/report-cli.js +45 -0
  59. package/dist/shell/report.js +2 -1
  60. package/dist/shell/run-registry-io.js +77 -19
  61. package/dist/shell/run-store.js +74 -2
  62. package/dist/shell/scheduling-io.js +12 -13
  63. package/dist/shell/state-cli.js +2 -7
  64. package/dist/shell/state-explosion-cli.js +17 -9
  65. package/dist/shell/topology-io.js +36 -5
  66. package/dist/shell/trust-audit.js +224 -22
  67. package/dist/shell/trust-policy-io.js +1 -1
  68. package/dist/shell/worker-cli.js +35 -31
  69. package/dist/wiring/capability-table/basics.js +33 -8
  70. package/dist/wiring/capability-table/exec-backend.js +20 -11
  71. package/dist/wiring/capability-table/multi-agent.js +172 -165
  72. package/dist/wiring/capability-table/parity.js +1 -0
  73. package/dist/wiring/capability-table/pipeline.js +54 -42
  74. package/dist/wiring/capability-table/registry-core.js +29 -10
  75. package/dist/wiring/capability-table/reporting.js +137 -96
  76. package/dist/wiring/capability-table/scheduling-registry.js +195 -161
  77. package/dist/wiring/capability-table/state.js +36 -28
  78. package/dist/wiring/capability-table/trust-ledger.js +46 -22
  79. package/dist/wiring/capability-table/workflow-apps.js +83 -68
  80. package/docs/agent-delegation-drive.7.md +2 -0
  81. package/docs/candidate-scoring.7.md +1 -1
  82. package/docs/canonical-workflow-apps.7.md +7 -7
  83. package/docs/cli-mcp-parity.7.md +8 -3
  84. package/docs/contract-migration-tooling.7.md +2 -0
  85. package/docs/control-plane-scheduling.7.md +2 -0
  86. package/docs/coordinator-blackboard.7.md +17 -17
  87. package/docs/dogfood-one-real-repo.7.md +11 -11
  88. package/docs/durable-state-and-locking.7.md +2 -0
  89. package/docs/end-to-end-golden-path.7.md +14 -14
  90. package/docs/evidence-adoption-reasoning-chain.7.md +2 -0
  91. package/docs/execution-backends.7.md +2 -0
  92. package/docs/getting-started.md +37 -37
  93. package/docs/multi-agent-cli-mcp-surface.7.md +19 -17
  94. package/docs/multi-agent-eval-replay-harness.7.md +15 -13
  95. package/docs/multi-agent-operator-ux.7.md +21 -19
  96. package/docs/multi-agent-runtime-core.7.md +22 -22
  97. package/docs/multi-agent-topologies.7.md +6 -6
  98. package/docs/multi-agent-trust-policy-audit.7.md +11 -11
  99. package/docs/node-snapshot-diff-replay.7.md +2 -0
  100. package/docs/observability-cost-accounting.7.md +2 -0
  101. package/docs/operator-ux.7.md +34 -34
  102. package/docs/pipeline-runner.7.md +4 -4
  103. package/docs/project-index.md +27 -4
  104. package/docs/real-execution-backends.7.md +2 -0
  105. package/docs/release-and-migration.7.md +3 -1
  106. package/docs/release-tooling.7.md +2 -0
  107. package/docs/routines.md +4 -4
  108. package/docs/run-registry-control-plane.7.md +21 -19
  109. package/docs/run-retention-reclamation.7.md +2 -0
  110. package/docs/scheduled-tasks.md +14 -14
  111. package/docs/security-trust-hardening.7.md +15 -15
  112. package/docs/state-explosion-management.7.md +12 -10
  113. package/docs/team-collaboration.7.md +2 -0
  114. package/docs/trust-audit-anchor.7.md +2 -0
  115. package/docs/unix-principles.md +3 -1
  116. package/docs/verifier-gated-commit.7.md +1 -1
  117. package/docs/web-desktop-workbench.7.md +2 -0
  118. package/docs/workflow-app-framework.7.md +13 -13
  119. package/manifest/plugin.manifest.json +1 -1
  120. package/package.json +2 -2
  121. package/scripts/agents/claude-p-agent.js +2 -2
  122. package/scripts/block-unapproved-tag.sh +23 -2
  123. package/scripts/canonical-apps.js +4 -4
  124. package/scripts/children/batch-delegate-child.js +52 -2
  125. package/scripts/dogfood-release.js +1 -1
  126. package/scripts/fake-date-for-reproduction.js +44 -0
  127. package/scripts/golden-path.js +4 -4
  128. package/scripts/purity-baseline.json +3 -0
  129. package/scripts/release-flow.js +57 -1
  130. package/scripts/verdict-keygen.js +83 -0
  131. package/scripts/verify-bump-reproduction.sh +148 -0
  132. package/scripts/verify-verdict-signature.js +61 -0
  133. package/skills/cool-workflow/SKILL.md +9 -9
  134. package/skills/cool-workflow/references/commands.md +89 -88
  135. package/ui/workbench/app.css +37 -1
  136. package/ui/workbench/app.js +124 -6
@@ -177,6 +177,7 @@ const PAYLOAD_PROBE_DEFERRED_GROUPS = [
177
177
  "coordinator.summary",
178
178
  "coordinator.decision",
179
179
  "audit.verify",
180
+ "audit.repair",
180
181
  "audit.worker",
181
182
  "audit.provenance",
182
183
  "audit.multi-agent",
@@ -15,8 +15,15 @@ const io_2 = require("../../cli/io");
15
15
  // wires argv shape -> handler call, per cli/dispatch.ts's generic
16
16
  // executor contract.
17
17
  // ---------------------------------------------------------------------
18
- const pipeline_cli_1 = require("../../shell/pipeline-cli");
19
- const commit_summary_1 = require("../../shell/commit-summary");
18
+ // This file is required unconditionally at startup for every command, so
19
+ // a top-level import of pipeline-cli/commit-summary would cost every
20
+ // invocation, not just plan/run/dispatch/result/commit/commit.summary ones.
21
+ function loadPipelineCli() {
22
+ return require("../../shell/pipeline-cli");
23
+ }
24
+ function loadCommitSummary() {
25
+ return require("../../shell/commit-summary");
26
+ }
20
27
  (0, registry_core_1.attachCliBinding)("plan", {
21
28
  path: ["plan"],
22
29
  jsonMode: "default",
@@ -25,7 +32,7 @@ const commit_summary_1 = require("../../shell/commit-summary");
25
32
  if (!workflowId) {
26
33
  throw new Error('Missing workflow id.\n Tip: plan an architecture review with "cw plan architecture-review"');
27
34
  }
28
- return { json: (0, pipeline_cli_1.planRun)({ ...args.options, workflowId }) };
35
+ return { json: loadPipelineCli().planRun({ ...args.options, workflowId }) };
29
36
  },
30
37
  });
31
38
  // `cw run <app> --drive [--once]` and `cw run drive <run-id> [--step]`
@@ -40,19 +47,19 @@ const commit_summary_1 = require("../../shell/commit-summary");
40
47
  path: ["run"],
41
48
  helpPath: ["run", "drive"],
42
49
  jsonMode: "default",
43
- handler: (args) => {
50
+ handler: async (args) => {
44
51
  const registrySubcommands = new Set(["drive", "search", "list", "show", "resume", "archive", "rerun", "export", "import", "verify-import", "inspect-archive", "restore"]);
45
52
  const target = args.positionals[0];
46
53
  if (args.options.drive && !registrySubcommands.has(String(target || ""))) {
47
54
  const runId = (0, io_2.optionalArg)(args.options.run) || (0, io_2.optionalArg)(args.options.runId);
48
55
  if (args.options.preview)
49
- return { json: (0, pipeline_cli_1.runDrivePreview)({ ...args.options, runId: runId || target }) };
56
+ return { json: loadPipelineCli().runDrivePreview({ ...args.options, runId: runId || target }) };
50
57
  const driveArgs = { ...args.options };
51
58
  if (runId)
52
59
  driveArgs.runId = runId;
53
60
  else
54
61
  driveArgs.appId = target;
55
- return { json: (0, pipeline_cli_1.runDriveStep)(driveArgs) };
62
+ return { json: await loadPipelineCli().runDriveStep(driveArgs) };
56
63
  }
57
64
  const [subcommand, id] = args.positionals;
58
65
  if (subcommand === "drive") {
@@ -60,34 +67,34 @@ const commit_summary_1 = require("../../shell/commit-summary");
60
67
  const driveArgs = { ...args.options };
61
68
  if (id)
62
69
  driveArgs.runId = id;
63
- return { json: (0, pipeline_cli_1.runDriveStep)(driveArgs) };
70
+ return { json: await loadPipelineCli().runDriveStep(driveArgs) };
64
71
  }
65
- return { json: (0, pipeline_cli_1.runDrivePreview)({ ...args.options, runId: (0, io_1.required)(id, "run id") }) };
72
+ return { json: loadPipelineCli().runDrivePreview({ ...args.options, runId: (0, io_1.required)(id, "run id") }) };
66
73
  }
67
74
  // MILESTONE 11 (reporting/run-export) — the archive family. Handler
68
75
  // bodies live in shell/run-export-cli.ts; this arm only wires argv
69
76
  // shape -> handler call.
70
77
  if (subcommand === "export") {
71
- const result = (0, run_export_cli_1.runExportCli)((0, io_1.required)(id, "run id"), args.options);
78
+ const result = loadRunExportCli().runExportCli((0, io_1.required)(id, "run id"), args.options);
72
79
  return { json: result };
73
80
  }
74
81
  if (subcommand === "import") {
75
- const result = (0, run_export_cli_1.runImportCli)((0, io_1.required)(id, "archive path"), args.options);
82
+ const result = loadRunExportCli().runImportCli((0, io_1.required)(id, "archive path"), args.options);
76
83
  return { json: result };
77
84
  }
78
85
  if (subcommand === "verify-import") {
79
- const result = (0, run_export_cli_1.runVerifyImportCli)((0, io_1.required)(id, "run id"), args.options);
86
+ const result = loadRunExportCli().runVerifyImportCli((0, io_1.required)(id, "run id"), args.options);
80
87
  return { json: result, exitCode: args.options.strict && !result.ok ? 1 : undefined };
81
88
  }
82
89
  if (subcommand === "inspect-archive") {
83
- const result = (0, run_export_cli_1.runInspectArchiveCli)((0, io_1.required)(id, "archive path"), args.options);
90
+ const result = loadRunExportCli().runInspectArchiveCli((0, io_1.required)(id, "archive path"), args.options);
84
91
  return { json: result, exitCode: result.ok ? undefined : 1 };
85
92
  }
86
93
  if (subcommand === "restore") {
87
- const result = (0, run_export_cli_1.runRestoreCli)((0, io_1.required)(id, "archive path"), args.options);
94
+ const result = loadRunExportCli().runRestoreCli((0, io_1.required)(id, "archive path"), args.options);
88
95
  return { json: result, exitCode: result.ok ? undefined : 1 };
89
96
  }
90
- throw new Error("Usage: cw.js run search|list|show|resume|archive|rerun|drive|export|import|verify-import|inspect-archive|restore [run-id|archive] [--scope repo|home] [--json] | cw.js run <app> --drive [--once] [--incremental] [--repo R --question Q]");
97
+ throw new Error("Usage: cw run search|list|show|resume|archive|rerun|drive|export|import|verify-import|inspect-archive|restore [run-id|archive] [--scope repo|home] [--json] | cw run <app> --drive [--once] [--incremental] [--repo R --question Q]");
91
98
  },
92
99
  });
93
100
  // PARITY: `run.drive` (the read-only MCP preview tool) now ALSO carries
@@ -104,19 +111,19 @@ const commit_summary_1 = require("../../shell/commit-summary");
104
111
  (0, registry_core_1.attachCliBinding)("run.drive", {
105
112
  path: ["run", "drive"],
106
113
  jsonMode: "default",
107
- handler: (args) => {
114
+ handler: async (args) => {
108
115
  const id = args.positionals[0];
109
116
  if (args.options.step) {
110
117
  const driveArgs = { ...args.options };
111
118
  if (id)
112
119
  driveArgs.runId = id;
113
- return { json: (0, pipeline_cli_1.runDriveStep)(driveArgs) };
120
+ return { json: await loadPipelineCli().runDriveStep(driveArgs) };
114
121
  }
115
- return { json: (0, pipeline_cli_1.runDrivePreview)({ ...args.options, runId: (0, io_1.required)(id, "run id") }) };
122
+ return { json: loadPipelineCli().runDrivePreview({ ...args.options, runId: (0, io_1.required)(id, "run id") }) };
116
123
  },
117
124
  });
118
- registry_core_1.REGISTRY_BY_CAPABILITY.get("run.drive").mcp.handler = (args) => (0, pipeline_cli_1.runDrivePreview)(args);
119
- registry_core_1.REGISTRY_BY_CAPABILITY.get("run.drive.step").mcp.handler = (args) => (0, pipeline_cli_1.runDriveStep)(args);
125
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.drive").mcp.handler = (args) => loadPipelineCli().runDrivePreview(args);
126
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.drive.step").mcp.handler = (args) => loadPipelineCli().runDriveStep(args);
120
127
  // PARITY: `run.drive.step` advances the run by spawning the external
121
128
  // agent per worker and recording attested output — not a read probe.
122
129
  // CLI (--drive/--step) and MCP route through the same drive() core; the
@@ -124,20 +131,20 @@ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.drive.step").mcp.handler = (args
124
131
  registry_core_1.REGISTRY_BY_CAPABILITY.get("run.drive.step").payloadIdentical = false;
125
132
  registry_core_1.REGISTRY_BY_CAPABILITY.get("run.drive.step").reason =
126
133
  "Mutating: advances the run by spawning the external agent per worker and recording attested output — not a read probe. CLI (--drive/--step) and MCP route through the same drive() core.";
127
- registry_core_1.REGISTRY_BY_CAPABILITY.get("plan").mcp.handler = (args) => (0, pipeline_cli_1.planRun)(args);
134
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("plan").mcp.handler = (args) => loadPipelineCli().planRun(args);
128
135
  // GAP #24: dispatchRun reads the sandbox profile from `args.sandbox` only
129
136
  // (the CLI's --sandbox flag). The cw_dispatch MCP tool also accepts the
130
137
  // `sandboxProfile`/`sandboxProfileId` aliases (its declared properties), so
131
138
  // normalize them onto `sandbox` here — mirrors the old build's
132
139
  // sandboxProfileIdFrom() alias set — before handing off.
133
- registry_core_1.REGISTRY_BY_CAPABILITY.get("dispatch").mcp.handler = (args) => (0, pipeline_cli_1.dispatchRun)({ ...args, sandbox: args.sandbox ?? args.sandboxProfile ?? args.sandboxProfileId });
134
- registry_core_1.REGISTRY_BY_CAPABILITY.get("result").mcp.handler = (args) => (0, pipeline_cli_1.recordResultRun)(args);
140
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("dispatch").mcp.handler = (args) => loadPipelineCli().dispatchRun({ ...args, sandbox: args.sandbox ?? args.sandboxProfile ?? args.sandboxProfileId });
141
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("result").mcp.handler = (args) => loadPipelineCli().recordResultRun(args);
135
142
  // `cw_commit` returns the FLAT commit envelope (verifierGated/checkpoint/
136
143
  // selectionId/… at the top level, plus a nested `commit`), matching the old
137
144
  // build's commitEnvelope. `commitRun` (CLI shape) returns `{ runId, commit }`;
138
145
  // lift the commit's key fields to the top for the MCP surface.
139
146
  registry_core_1.REGISTRY_BY_CAPABILITY.get("commit").mcp.handler = (args) => {
140
- const result = (0, pipeline_cli_1.commitRun)(args);
147
+ const result = loadPipelineCli().commitRun(args);
141
148
  const commit = result.commit || {};
142
149
  return {
143
150
  runId: result.runId,
@@ -168,12 +175,16 @@ registry_core_1.REGISTRY_BY_CAPABILITY.get("commit").reason =
168
175
  // handler above; these tools are called directly by name over MCP, so
169
176
  // each needs its own mcp.handler per byte-compat item 5's two-field
170
177
  // row shape).
171
- const run_export_cli_1 = require("../../shell/run-export-cli");
172
- registry_core_1.REGISTRY_BY_CAPABILITY.get("run.export").mcp.handler = (args) => (0, run_export_cli_1.runExportCli)((0, io_1.required)((0, io_2.optionalArg)(args.runId), "run id"), args);
173
- registry_core_1.REGISTRY_BY_CAPABILITY.get("run.import").mcp.handler = (args) => (0, run_export_cli_1.runImportCli)((0, io_1.required)((0, io_2.optionalArg)(args.archive || args.path || args.file), "archive path"), args);
174
- registry_core_1.REGISTRY_BY_CAPABILITY.get("run.verify-import").mcp.handler = (args) => (0, run_export_cli_1.runVerifyImportCli)((0, io_1.required)((0, io_2.optionalArg)(args.runId), "run id"), args);
175
- registry_core_1.REGISTRY_BY_CAPABILITY.get("run.inspect-archive").mcp.handler = (args) => (0, run_export_cli_1.runInspectArchiveCli)((0, io_1.required)((0, io_2.optionalArg)(args.archive || args.path || args.file), "archive path"), args);
176
- registry_core_1.REGISTRY_BY_CAPABILITY.get("run.restore").mcp.handler = (args) => (0, run_export_cli_1.runRestoreCli)((0, io_1.required)((0, io_2.optionalArg)(args.archive || args.path || args.file), "archive path"), args);
178
+ // Same lazy-load reasoning as loadPipelineCli/loadCommitSummary above, for
179
+ // the run.export/import/verify-import/inspect-archive/restore family.
180
+ function loadRunExportCli() {
181
+ return require("../../shell/run-export-cli");
182
+ }
183
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.export").mcp.handler = (args) => loadRunExportCli().runExportCli((0, io_1.required)((0, io_2.optionalArg)(args.runId), "run id"), args);
184
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.import").mcp.handler = (args) => loadRunExportCli().runImportCli((0, io_1.required)((0, io_2.optionalArg)(args.archive || args.path || args.file), "archive path"), args);
185
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.verify-import").mcp.handler = (args) => loadRunExportCli().runVerifyImportCli((0, io_1.required)((0, io_2.optionalArg)(args.runId), "run id"), args);
186
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.inspect-archive").mcp.handler = (args) => loadRunExportCli().runInspectArchiveCli((0, io_1.required)((0, io_2.optionalArg)(args.archive || args.path || args.file), "archive path"), args);
187
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.restore").mcp.handler = (args) => loadRunExportCli().runRestoreCli((0, io_1.required)((0, io_2.optionalArg)(args.archive || args.path || args.file), "archive path"), args);
177
188
  // `run export|import|verify-import|inspect-archive|restore` each carry their
178
189
  // own two-token cli.path (found before the ["run"] run.drive.step catch-all
179
190
  // per the reversed candidate order), calling the same shell fns with the
@@ -184,20 +195,20 @@ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.restore").mcp.handler = (args) =
184
195
  path: ["run", "export"],
185
196
  jsonMode: "default",
186
197
  hiddenFromHelp: true,
187
- handler: (args) => ({ json: (0, run_export_cli_1.runExportCli)((0, io_1.required)(args.positionals[0], "run id"), args.options) }),
198
+ handler: (args) => ({ json: loadRunExportCli().runExportCli((0, io_1.required)(args.positionals[0], "run id"), args.options) }),
188
199
  });
189
200
  (0, registry_core_1.attachCliBinding)("run.import", {
190
201
  path: ["run", "import"],
191
202
  jsonMode: "default",
192
203
  hiddenFromHelp: true,
193
- handler: (args) => ({ json: (0, run_export_cli_1.runImportCli)((0, io_1.required)(args.positionals[0], "archive path"), args.options) }),
204
+ handler: (args) => ({ json: loadRunExportCli().runImportCli((0, io_1.required)(args.positionals[0], "archive path"), args.options) }),
194
205
  });
195
206
  (0, registry_core_1.attachCliBinding)("run.verify-import", {
196
207
  path: ["run", "verify-import"],
197
208
  jsonMode: "default",
198
209
  hiddenFromHelp: true,
199
210
  handler: (args) => {
200
- const result = (0, run_export_cli_1.runVerifyImportCli)((0, io_1.required)(args.positionals[0], "run id"), args.options);
211
+ const result = loadRunExportCli().runVerifyImportCli((0, io_1.required)(args.positionals[0], "run id"), args.options);
201
212
  return { json: result, exitCode: args.options.strict && !result.ok ? 1 : undefined };
202
213
  },
203
214
  });
@@ -206,7 +217,7 @@ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.restore").mcp.handler = (args) =
206
217
  jsonMode: "default",
207
218
  hiddenFromHelp: true,
208
219
  handler: (args) => {
209
- const result = (0, run_export_cli_1.runInspectArchiveCli)((0, io_1.required)(args.positionals[0], "archive path"), args.options);
220
+ const result = loadRunExportCli().runInspectArchiveCli((0, io_1.required)(args.positionals[0], "archive path"), args.options);
210
221
  return { json: result, exitCode: result.ok ? undefined : 1 };
211
222
  },
212
223
  });
@@ -215,7 +226,7 @@ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.restore").mcp.handler = (args) =
215
226
  jsonMode: "default",
216
227
  hiddenFromHelp: true,
217
228
  handler: (args) => {
218
- const result = (0, run_export_cli_1.runRestoreCli)((0, io_1.required)(args.positionals[0], "archive path"), args.options);
229
+ const result = loadRunExportCli().runRestoreCli((0, io_1.required)(args.positionals[0], "archive path"), args.options);
219
230
  return { json: result, exitCode: result.ok ? undefined : 1 };
220
231
  },
221
232
  });
@@ -225,9 +236,9 @@ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.restore").mcp.handler = (args) =
225
236
  // wrapper (byte-behavior port of the old build's caseTokens).
226
237
  caseTokens: ["quickstart", "audit-run"],
227
238
  jsonMode: "default",
228
- handler: (args) => {
239
+ handler: async (args) => {
229
240
  const appId = (0, io_2.optionalArg)(args.positionals[0]);
230
- const result = (0, pipeline_cli_1.quickstartRun)({ ...args.options, appId });
241
+ const result = (await loadPipelineCli().quickstartRun({ ...args.options, appId }));
231
242
  // Fail closed on both known bad outcomes: a --check preflight that
232
243
  // found a blocking gap, OR a --bundle that did not self-verify.
233
244
  const bundle = result.bundle;
@@ -241,7 +252,7 @@ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.restore").mcp.handler = (args) =
241
252
  jsonMode: "default",
242
253
  handler: (args) => {
243
254
  const runId = (0, io_1.required)((0, io_2.optionalArg)(args.positionals[0]), "run id");
244
- return { json: (0, pipeline_cli_1.dispatchRun)({ ...args.options, runId }) };
255
+ return { json: loadPipelineCli().dispatchRun({ ...args.options, runId }) };
245
256
  },
246
257
  });
247
258
  (0, registry_core_1.attachCliBinding)("result", {
@@ -251,7 +262,7 @@ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.restore").mcp.handler = (args) =
251
262
  const runId = (0, io_1.required)((0, io_2.optionalArg)(args.positionals[0]), "run id");
252
263
  const taskId = (0, io_1.required)((0, io_2.optionalArg)(args.positionals[1]), "task id");
253
264
  const resultPath = (0, io_1.required)((0, io_2.optionalArg)(args.positionals[2]), "result file path");
254
- return { json: (0, pipeline_cli_1.recordResultRun)({ ...args.options, runId, taskId, resultPath }) };
265
+ return { json: loadPipelineCli().recordResultRun({ ...args.options, runId, taskId, resultPath }) };
255
266
  },
256
267
  });
257
268
  (0, registry_core_1.attachCliBinding)("commit", {
@@ -259,7 +270,7 @@ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.restore").mcp.handler = (args) =
259
270
  jsonMode: "default",
260
271
  handler: (args) => {
261
272
  const runId = (0, io_1.required)((0, io_2.optionalArg)(args.positionals[0]), "run id");
262
- return { json: (0, pipeline_cli_1.commitRun)({ ...args.options, runId }) };
273
+ return { json: loadPipelineCli().commitRun({ ...args.options, runId }) };
263
274
  },
264
275
  });
265
276
  // GAP #26: restore `cw commit summary <run-id>` (CLI + help row). The old
@@ -272,9 +283,10 @@ registry_core_1.REGISTRY_BY_CAPABILITY.get("run.restore").mcp.handler = (args) =
272
283
  path: ["commit", "summary"],
273
284
  jsonMode: "flag",
274
285
  handler: (args) => {
275
- const summary = (0, commit_summary_1.commitSummaryCli)({ ...args.options, runId: (0, io_1.required)(args.positionals[0], "run id") });
276
- return { json: summary, text: `${(0, commit_summary_1.formatCommitSummaryText)(summary)}\n` };
286
+ const commitSummary = loadCommitSummary();
287
+ const summary = commitSummary.commitSummaryCli({ ...args.options, runId: (0, io_1.required)(args.positionals[0], "run id") });
288
+ return { json: summary, text: `${commitSummary.formatCommitSummaryText(summary)}\n` };
277
289
  },
278
290
  });
279
- registry_core_1.REGISTRY_BY_CAPABILITY.get("commit.summary").mcp.handler = (args) => (0, commit_summary_1.commitSummaryCli)(args);
291
+ registry_core_1.REGISTRY_BY_CAPABILITY.get("commit.summary").mcp.handler = (args) => loadCommitSummary().commitSummaryCli(args);
280
292
  // ---------------------------------------------------------------------
@@ -33,10 +33,28 @@ exports.declaredMcpTools = declaredMcpTools;
33
33
  exports.findCapabilityByMcpTool = findCapabilityByMcpTool;
34
34
  const capability_data_1 = require("../../core/capability-data");
35
35
  const io_1 = require("../../cli/io");
36
- const run_store_1 = require("../../shell/run-store");
37
- const operator_ux_1 = require("../../shell/operator-ux");
38
- const workflow_app_loader_1 = require("../../shell/workflow-app-loader");
39
- const state_explosion_cli_1 = require("../../shell/state-explosion-cli");
36
+ // Every capability-table module (this file plus each domain slice) is
37
+ // required unconditionally at CLI/MCP startup, for every single command
38
+ // (index.ts's whole point is to populate REGISTRY before dispatch can
39
+ // look anything up) — so a top-level `import` of a shell module here
40
+ // means EVERY invocation pays that module's full load cost, even the
41
+ // 99% of commands that never touch `status`/`summary.refresh`/`list`.
42
+ // Requiring these 4 lazily (inside the handler that actually uses them)
43
+ // measured live: this file alone was ~30-45ms of a ~75-100ms `cw --version`
44
+ // require chain, the single largest slice. The 8 domain slices have the
45
+ // same shape and are a natural follow-up, not attempted here.
46
+ function loadRunStore() {
47
+ return require("../../shell/run-store");
48
+ }
49
+ function loadOperatorUx() {
50
+ return require("../../shell/operator-ux");
51
+ }
52
+ function loadWorkflowAppLoader() {
53
+ return require("../../shell/workflow-app-loader");
54
+ }
55
+ function loadStateExplosionCli() {
56
+ return require("../../shell/state-explosion-cli");
57
+ }
40
58
  /** Real handlers implemented at THIS milestone, keyed by capability id.
41
59
  * Every tool row not listed here gets `notYetImplemented`. Kept as a
42
60
  * small side table (rather than inlined into MCP_TOOL_DATA above) so the
@@ -47,8 +65,8 @@ const MCP_REAL_HANDLERS = {
47
65
  list: () => listBundledWorkflows(),
48
66
  "sandbox.list": () => listBundledSandboxProfiles(),
49
67
  status: (args) => statusPayload(optionalString(args.runId)),
50
- "summary.refresh": (args) => (0, state_explosion_cli_1.summaryRefreshCli)((0, io_1.required)(optionalString(args.runId), "run id"), args),
51
- "summary.show": (args) => (0, state_explosion_cli_1.summaryShowCli)((0, io_1.required)(optionalString(args.runId), "run id"), args),
68
+ "summary.refresh": (args) => loadStateExplosionCli().summaryRefreshCli((0, io_1.required)(optionalString(args.runId), "run id"), args),
69
+ "summary.show": (args) => loadStateExplosionCli().summaryShowCli((0, io_1.required)(optionalString(args.runId), "run id"), args),
52
70
  };
53
71
  function optionalString(value) {
54
72
  return typeof value === "string" && value.trim() ? value.trim() : undefined;
@@ -57,7 +75,7 @@ function optionalString(value) {
57
75
  * `apps/*\/app.json` + legacy `workflows/*.workflow.js` on disk, per
58
76
  * `listWorkflowsShallow` (shell/workflow-app-loader.ts). */
59
77
  function listBundledWorkflows() {
60
- return (0, workflow_app_loader_1.listWorkflowsShallow)();
78
+ return loadWorkflowAppLoader().listWorkflowsShallow();
61
79
  }
62
80
  /** PLACEHOLDER (milestone 5, execution-backend/sandbox) — the real
63
81
  * `sandbox.list` resolves and stamps each of the 4 bundled profiles
@@ -77,11 +95,12 @@ function listBundledSandboxProfiles() {
77
95
  * shape exactly (`{runId:null, nextActions}`); a real run id resolves to
78
96
  * `summarizeRun`'s payload (MILESTONE 11, reporting/observability). */
79
97
  function statusPayload(runId, cwd) {
98
+ const operatorUx = loadOperatorUx();
80
99
  if (!runId) {
81
- return { runId: null, nextActions: (0, operator_ux_1.adviseNoRun)() };
100
+ return { runId: null, nextActions: operatorUx.adviseNoRun() };
82
101
  }
83
- const run = (0, run_store_1.loadRunFromCwd)(runId, cwd || process.cwd());
84
- return (0, operator_ux_1.summarizeRun)(run);
102
+ const run = loadRunStore().loadRunFromCwd(runId, cwd || process.cwd());
103
+ return operatorUx.summarizeRun(run);
85
104
  }
86
105
  // ---------------------------------------------------------------------
87
106
  // Public table-derived API