cool-workflow 0.1.89 → 0.1.90

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 (50) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/README.md +40 -1
  4. package/apps/architecture-review/app.json +1 -1
  5. package/apps/architecture-review-fast/app.json +1 -1
  6. package/apps/end-to-end-golden-path/app.json +1 -1
  7. package/apps/pr-review-fix-ci/app.json +1 -1
  8. package/apps/release-cut/app.json +1 -1
  9. package/apps/research-synthesis/app.json +1 -1
  10. package/dist/capability-core.js +120 -9
  11. package/dist/capability-registry.js +6 -0
  12. package/dist/cli/command-surface.js +94 -4
  13. package/dist/cli.js +26 -1
  14. package/dist/clones.js +162 -0
  15. package/dist/drive.js +35 -1
  16. package/dist/mcp/tool-call.js +4 -0
  17. package/dist/mcp/tool-definitions.js +5 -0
  18. package/dist/orchestrator/report.js +6 -0
  19. package/dist/orchestrator.js +12 -4
  20. package/dist/remote-source.js +444 -0
  21. package/dist/term.js +54 -8
  22. package/dist/version.js +1 -1
  23. package/docs/agent-delegation-drive.7.md +2 -0
  24. package/docs/cli-mcp-parity.7.md +7 -2
  25. package/docs/contract-migration-tooling.7.md +2 -0
  26. package/docs/control-plane-scheduling.7.md +2 -0
  27. package/docs/durable-state-and-locking.7.md +2 -0
  28. package/docs/evidence-adoption-reasoning-chain.7.md +2 -0
  29. package/docs/execution-backends.7.md +2 -0
  30. package/docs/multi-agent-cli-mcp-surface.7.md +2 -0
  31. package/docs/multi-agent-eval-replay-harness.7.md +2 -0
  32. package/docs/multi-agent-operator-ux.7.md +2 -0
  33. package/docs/node-snapshot-diff-replay.7.md +2 -0
  34. package/docs/observability-cost-accounting.7.md +2 -0
  35. package/docs/project-index.md +13 -4
  36. package/docs/real-execution-backends.7.md +2 -0
  37. package/docs/release-and-migration.7.md +2 -0
  38. package/docs/release-tooling.7.md +2 -0
  39. package/docs/remote-source-review.7.md +88 -0
  40. package/docs/run-registry-control-plane.7.md +2 -0
  41. package/docs/run-retention-reclamation.7.md +2 -0
  42. package/docs/state-explosion-management.7.md +2 -0
  43. package/docs/team-collaboration.7.md +2 -0
  44. package/docs/web-desktop-workbench.7.md +2 -0
  45. package/manifest/plugin.manifest.json +1 -1
  46. package/manifest/source-context-profiles.json +1 -1
  47. package/package.json +1 -1
  48. package/scripts/canonical-apps.js +4 -4
  49. package/scripts/dogfood-release.js +1 -1
  50. package/scripts/golden-path.js +4 -4
package/dist/clones.js ADDED
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ // src/clones.ts — manage the remote-source clone cache that `--link`/URL reviews populate.
3
+ //
4
+ // The cache lives under resolveCwHome()/clones/<hash>/ (one content-addressed checkout per
5
+ // URL+ref). `cw clones list` inspects it; `cw clones gc` reclaims it (a TTL sweep, or --all).
6
+ // Pure filesystem work — no network, no git. Fail closed: gc only ever deletes a path it has
7
+ // proven is INSIDE the clones root (the hash dir names are hex, so this always holds; the
8
+ // assertion guards against a future change).
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.listClones = listClones;
14
+ exports.gcClones = gcClones;
15
+ const node_fs_1 = __importDefault(require("node:fs"));
16
+ const node_path_1 = __importDefault(require("node:path"));
17
+ const run_registry_1 = require("./run-registry");
18
+ function isTrue(value) {
19
+ return value === true || value === "true" || value === "1" || value === 1;
20
+ }
21
+ function optionalNumber(value) {
22
+ if (value === undefined || value === null || value === "")
23
+ return undefined;
24
+ const n = Number(value);
25
+ return Number.isFinite(n) ? n : undefined;
26
+ }
27
+ function clonesRoot(args) {
28
+ // resolveCwHome reads CW_HOME/XDG_STATE_HOME from the environment — the same root the
29
+ // materialize step writes to, so list/gc see exactly what `--link` created.
30
+ void args;
31
+ return node_path_1.default.join((0, run_registry_1.resolveCwHome)(), "clones");
32
+ }
33
+ /** Total bytes of a directory tree, NOT following symlinks (lstat). Missing/unreadable
34
+ * entries are skipped — sizing is best-effort and must never throw. */
35
+ function dirSize(dir) {
36
+ let total = 0;
37
+ const walk = (d) => {
38
+ let names;
39
+ try {
40
+ names = node_fs_1.default.readdirSync(d);
41
+ }
42
+ catch {
43
+ return;
44
+ }
45
+ for (const name of names) {
46
+ const p = node_path_1.default.join(d, name);
47
+ let st;
48
+ try {
49
+ st = node_fs_1.default.lstatSync(p);
50
+ }
51
+ catch {
52
+ continue;
53
+ }
54
+ if (st.isDirectory())
55
+ walk(p);
56
+ else
57
+ total += st.size;
58
+ }
59
+ };
60
+ walk(dir);
61
+ return total;
62
+ }
63
+ function readEntries(root) {
64
+ let names = [];
65
+ try {
66
+ names = node_fs_1.default.readdirSync(root);
67
+ }
68
+ catch {
69
+ return []; // no cache yet
70
+ }
71
+ const entries = [];
72
+ for (const hash of names) {
73
+ if (hash.startsWith("."))
74
+ continue; // skip in-progress .stage-* temp dirs
75
+ const dir = node_path_1.default.join(root, hash);
76
+ let st;
77
+ try {
78
+ st = node_fs_1.default.statSync(dir);
79
+ }
80
+ catch {
81
+ continue;
82
+ }
83
+ if (!st.isDirectory())
84
+ continue;
85
+ let meta = {};
86
+ try {
87
+ meta = JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(dir, ".cw-clone-meta.json"), "utf8"));
88
+ }
89
+ catch {
90
+ /* legacy/partial entry without meta — still listable/reclaimable */
91
+ }
92
+ entries.push({
93
+ hash,
94
+ url: typeof meta.url === "string" ? meta.url : "(unknown)",
95
+ kind: typeof meta.kind === "string" ? meta.kind : "git",
96
+ ref: typeof meta.ref === "string" ? meta.ref : null,
97
+ fetchedAt: typeof meta.fetchedAt === "string" ? meta.fetchedAt : null,
98
+ commit: typeof meta.commit === "string" ? meta.commit : null,
99
+ bytes: dirSize(dir)
100
+ });
101
+ }
102
+ entries.sort((a, b) => (a.fetchedAt || "").localeCompare(b.fetchedAt || ""));
103
+ return entries;
104
+ }
105
+ /** `cw clones list` — every cached remote checkout with its origin, commit, age, and size. */
106
+ function listClones(args) {
107
+ const root = clonesRoot(args);
108
+ const entries = readEntries(root);
109
+ return {
110
+ schemaVersion: 1,
111
+ clonesDir: root,
112
+ count: entries.length,
113
+ totalBytes: entries.reduce((sum, e) => sum + e.bytes, 0),
114
+ entries
115
+ };
116
+ }
117
+ /** `cw clones gc [--older-than-days N] [--all]` — reclaim cached checkouts. Default keeps
118
+ * entries fetched within the last 30 days; `--all` removes every entry. Deletes ONLY paths
119
+ * proven inside the clones root (fail closed). `--now` (ISO) is injectable for deterministic
120
+ * tests; an entry with no fetchedAt is treated as old (eligible). */
121
+ function gcClones(args) {
122
+ const root = clonesRoot(args);
123
+ const all = isTrue(args.all);
124
+ let olderThanDays = null;
125
+ if (!all) {
126
+ const raw = args.olderThanDays ?? args["older-than-days"];
127
+ olderThanDays = optionalNumber(raw) ?? 30;
128
+ if (!Number.isFinite(olderThanDays) || olderThanDays < 0) {
129
+ throw new Error(`--older-than-days must be a non-negative number (got ${String(raw)})`);
130
+ }
131
+ }
132
+ let now = Date.now();
133
+ if (args.now !== undefined) {
134
+ now = new Date(String(args.now)).getTime();
135
+ if (!Number.isFinite(now))
136
+ throw new Error(`--now must be a valid ISO date (got ${String(args.now)})`);
137
+ }
138
+ const cutoff = olderThanDays != null ? now - olderThanDays * 24 * 60 * 60 * 1000 : Infinity;
139
+ const rootResolved = node_path_1.default.resolve(root);
140
+ const removed = [];
141
+ let freedBytes = 0;
142
+ const entries = readEntries(root);
143
+ for (const entry of entries) {
144
+ if (!all) {
145
+ // Fail-SAFE: a TTL sweep reclaims only entries we can PROVE are old enough. An entry with
146
+ // no (or an unparseable) fetchedAt is a partial/legacy materialize that never wrote meta —
147
+ // we cannot date it, so we KEEP it (never delete what you can't age). `--all` clears them.
148
+ if (!entry.fetchedAt)
149
+ continue;
150
+ const age = new Date(entry.fetchedAt).getTime();
151
+ if (!Number.isFinite(age) || age > cutoff)
152
+ continue;
153
+ }
154
+ const dir = node_path_1.default.join(root, entry.hash);
155
+ if (!node_path_1.default.resolve(dir).startsWith(rootResolved + node_path_1.default.sep))
156
+ continue; // containment, fail closed
157
+ node_fs_1.default.rmSync(dir, { recursive: true, force: true });
158
+ removed.push({ hash: entry.hash, url: entry.url, bytes: entry.bytes });
159
+ freedBytes += entry.bytes;
160
+ }
161
+ return { schemaVersion: 1, clonesDir: root, removed, freedBytes, keptCount: entries.length - removed.length, olderThanDays, all };
162
+ }
package/dist/drive.js CHANGED
@@ -32,6 +32,7 @@ exports.drive = drive;
32
32
  exports.drivePreview = drivePreview;
33
33
  const node_fs_1 = __importDefault(require("node:fs"));
34
34
  const node_path_1 = __importDefault(require("node:path"));
35
+ const term_1 = require("./term");
35
36
  const dispatch_1 = require("./dispatch");
36
37
  const execution_backend_1 = require("./execution-backend");
37
38
  const worker_isolation_1 = require("./worker-isolation");
@@ -690,6 +691,34 @@ function drive(runner, runId, options = {}) {
690
691
  const cap = Math.max(1, Math.floor(run.workflow.limits?.maxConcurrentAgents || 1));
691
692
  return Math.max(1, Math.min(cap, phase.taskIds.length));
692
693
  };
694
+ // Phase-boundary progress (brew-style): announce each phase when it becomes active
695
+ // and when it finishes — `==> Map ✓ (6/6)` / `==> Assess … (3/6)`. Describes CW's OWN
696
+ // phases (vendor-neutral); goes to stderr via emitProgress so stdout stays clean data.
697
+ const announcedPhaseComplete = new Set();
698
+ let activePhaseId;
699
+ const titleCase = (s) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s);
700
+ const emitPhaseProgress = (run) => {
701
+ for (const ph of run.phases || []) {
702
+ const phaseTasks = run.tasks.filter((task) => ph.taskIds.includes(task.id));
703
+ const total = phaseTasks.length;
704
+ if (total === 0)
705
+ continue;
706
+ const done = phaseTasks.filter((task) => task.status === "completed").length;
707
+ const label = titleCase(ph.name || ph.id);
708
+ if (done >= total) {
709
+ if (!announcedPhaseComplete.has(ph.id)) {
710
+ announcedPhaseComplete.add(ph.id);
711
+ emitProgress((0, term_1.phaseProgressLine)(label, done, total, ph.mode, process.stderr));
712
+ }
713
+ continue;
714
+ }
715
+ if (ph.id !== activePhaseId) {
716
+ activePhaseId = ph.id;
717
+ emitProgress((0, term_1.phaseProgressLine)(label, done, total, ph.mode, process.stderr));
718
+ }
719
+ return; // only the first not-yet-complete phase is "active"
720
+ }
721
+ };
693
722
  for (let i = 0; i < maxIterations; i++) {
694
723
  const width = concurrency > 1 ? concurrency : autoWidth(runner.loadRun(runId));
695
724
  const roundSteps = width > 1 ? driveConcurrentRound(ctx, width) : [driveStep(ctx)];
@@ -706,6 +735,10 @@ function drive(runner, runId, options = {}) {
706
735
  .filter(Boolean)
707
736
  .join(" "));
708
737
  }
738
+ // Brew-style phase boundaries: after each round, announce a newly-active phase and
739
+ // any phase that just finished (`==> Map ✓ (6/6)` / `==> Assess … (3/6)`). Cheap —
740
+ // reuses the run we just advanced; goes to stderr via emitProgress so stdout is clean.
741
+ emitPhaseProgress(runner.loadRun(runId));
709
742
  const last = roundSteps[roundSteps.length - 1];
710
743
  if (options.once)
711
744
  break;
@@ -739,7 +772,8 @@ function drive(runner, runId, options = {}) {
739
772
  parkedWorkers,
740
773
  commitId: committed?.id,
741
774
  reportPath: run.paths.report,
742
- statePath: run.paths.state
775
+ statePath: run.paths.state,
776
+ agentConfigured: agentConfigured(config)
743
777
  };
744
778
  }
745
779
  /** Read-only, deterministic preview of the NEXT drive step for a run — no mutation,
@@ -402,6 +402,10 @@ function callTool(name, args) {
402
402
  return (0, capability_core_1.gcRun)((0, capability_core_1.runRegistryFor)(args, runner), (0, capability_core_1.optionalString)(args.runId), args);
403
403
  case "cw_gc_verify":
404
404
  return (0, capability_core_1.gcVerify)((0, capability_core_1.runRegistryFor)(args, runner), String(args.runId || ""), args);
405
+ case "cw_clones_list":
406
+ return (0, capability_core_1.listClones)(args);
407
+ case "cw_clones_gc":
408
+ return (0, capability_core_1.gcClones)(args);
405
409
  case "cw_telemetry_verify":
406
410
  return (0, capability_core_1.telemetryVerify)(runner, args);
407
411
  case "cw_history":
@@ -952,6 +952,11 @@ function toolDefinitions() {
952
952
  scope: stringSchema("home (default, cross-repo) or repo"),
953
953
  runId: stringSchema("Run id to verify")
954
954
  }),
955
+ capabilityTool("clones.list", "List the cached remote-source checkouts that `--link`/URL reviews populate (origin URL, kind, commit, age, bytes). Read-only. Peer of `cw clones list`.", {}),
956
+ capabilityTool("clones.gc", "Reclaim cached remote-source checkouts: a TTL sweep (entries older than --older-than-days, default 30) or --all. Deletes only inside the clones cache. Peer of `cw clones gc`.", {
957
+ olderThanDays: numberSchema("Reclaim checkouts fetched more than N days ago (default 30; ignored with all)"),
958
+ all: booleanSchema("Reclaim every cached checkout")
959
+ }),
955
960
  capabilityTool("telemetry.verify", "Re-prove a run's telemetry attestation ledger offline: prevHash chain linkage + independent per-record hash recompute (never trusts the stored hash), and optionally re-run ed25519 checks with a public key. A forged or edited record fails it. Peer of `cw telemetry verify`.", {
956
961
  cwd: stringSchema("Repo workspace"),
957
962
  runId: stringSchema("Run id to verify"),
@@ -39,6 +39,12 @@ function writeReport(run) {
39
39
  `- Created: ${run.createdAt}`,
40
40
  `- Updated: ${run.updatedAt}`,
41
41
  `- Repository: ${String(run.inputs.repo || run.cwd)}`,
42
+ // Remote provenance (v0.1.91): when the repo was materialized from a --link/URL, record
43
+ // the sanitized origin + resolved commit so the report itself says where the code came
44
+ // from. Conditional — absent for a local-repo run, so existing reports stay byte-identical.
45
+ ...(run.inputs.sourceUrl
46
+ ? [`- Source: ${String(run.inputs.sourceUrl)}${run.inputs.sourceCommit ? `@${String(run.inputs.sourceCommit)}` : ""}`]
47
+ : []),
42
48
  `- Question: ${String(run.inputs.question || "")}`,
43
49
  `- Invariants: ${formatInputList(run.inputs.invariant)}`,
44
50
  `- Loop Stage: ${run.loopStage}`,
@@ -806,7 +806,7 @@ function parseArgv(argv) {
806
806
  }
807
807
  if (!token.startsWith("--")) {
808
808
  // Single-dash short flag aliases: -q → question, -r → repo, -a → agent-command, -h → help, -v → version
809
- const shortMap = { q: "question", r: "repo", a: "agent-command", h: "help", v: "version" };
809
+ const shortMap = { q: "question", r: "repo", d: "dir", l: "link", a: "agent-command", h: "help", v: "version" };
810
810
  const flag = token.slice(1);
811
811
  // Handle combined short flags like -qr (not common but safe to ignore)
812
812
  const key = shortMap[flag] || flag;
@@ -824,7 +824,13 @@ function parseArgv(argv) {
824
824
  }
825
825
  else {
826
826
  key = withoutPrefix;
827
- value = rest[index + 1] && !rest[index + 1].startsWith("--") ? rest[++index] : true;
827
+ // A flag's value is never ANOTHER flag: reject a next token starting with `-`
828
+ // (single OR double dash), matching the single-dash branch above. Without this, a
829
+ // valueless `--flag` greedily swallowed the following single-dash flag — e.g.
830
+ // `run app --drive -dir /p` made `drive="-dir"` and dropped `-dir` entirely. A
831
+ // value that legitimately starts with `-` still goes through `--key=-value` or
832
+ // after a `--` end-of-options marker (both handled above).
833
+ value = rest[index + 1] && !rest[index + 1].startsWith("-") ? rest[++index] : true;
828
834
  }
829
835
  appendOption(options, key, value);
830
836
  }
@@ -835,7 +841,7 @@ exports.KNOWN_COMMANDS = new Set([
835
841
  "help", "list", "doctor", "info", "search", "man", "init", "quickstart", "plan", "status", "next",
836
842
  "dispatch", "result", "state", "commit", "report", "app", "sandbox",
837
843
  "backend", "contract", "node", "feedback", "worker", "audit", "candidate",
838
- "review", "loop", "schedule", "routine", "registry", "run", "queue",
844
+ "review", "loop", "schedule", "routine", "registry", "run", "queue", "clones",
839
845
  "history", "audit-run", "multi-agent", "topology", "summary", "blackboard",
840
846
  "coordinator", "metrics", "operator", "sched", "gc", "telemetry",
841
847
  "migration", "demo", "workbench", "approve", "reject", "comment", "handoff",
@@ -927,7 +933,7 @@ function formatHelp() {
927
933
  const out = process.stdout;
928
934
  const moreCommands = ("list search info init plan status next dispatch result state commit report app " +
929
935
  "sandbox backend contract node feedback worker audit candidate review loop schedule " +
930
- "routine registry run queue history quickstart audit-run multi-agent topology summary " +
936
+ "routine registry run queue clones history quickstart audit-run multi-agent topology summary " +
931
937
  "blackboard coordinator metrics operator sched gc telemetry migration demo workbench " +
932
938
  "approve reject comment handoff graph eval man version update fix").split(" ");
933
939
  // Wrap the command list into clean, indented, pipe-joined lines (<=76 cols) instead of
@@ -949,6 +955,7 @@ function formatHelp() {
949
955
  (0, term_1.bold)("Cool Workflow", out),
950
956
  "",
951
957
  " -q \"question\" [-claude|-codex|-deepseek] Ask a question, get a report",
958
+ " -q \"question\" --link <url> Review a remote repo by URL",
952
959
  " version Show version",
953
960
  " update Update to latest release",
954
961
  " doctor Check setup",
@@ -957,6 +964,7 @@ function formatHelp() {
957
964
  (0, term_1.bold)("Flags", out),
958
965
  " -q, --question TEXT The task or question to answer",
959
966
  " -r, --repo PATH Target repository path (default: .)",
967
+ " -d, --dir PATH Project folder to review (alias for --repo)",
960
968
  " -claude Use Claude agent",
961
969
  " -codex Use Codex agent",
962
970
  " -deepseek Use DeepSeek (via opencode)",