@mmerterden/multi-agent-pipeline 17.6.0 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.md +127 -0
  2. package/README.md +43 -1
  3. package/README.tr.md +41 -0
  4. package/docs/adr/0011-dormant-ci.md +25 -1
  5. package/docs/server-readiness.md +188 -0
  6. package/index.js +16 -1
  7. package/install/_common.mjs +42 -17
  8. package/install/_dev-only-files.mjs +8 -0
  9. package/install/_unattended-profile.mjs +113 -0
  10. package/install/index.mjs +48 -0
  11. package/manifest.json +1049 -0
  12. package/package.json +5 -2
  13. package/pipeline/commands/multi-agent/status/SKILL.md +52 -21
  14. package/pipeline/lib/_jira-auth.sh +8 -0
  15. package/pipeline/lib/analysis-jira-write.sh +32 -0
  16. package/pipeline/lib/ask-choice.sh +13 -2
  17. package/pipeline/lib/autopilot-state.sh +8 -0
  18. package/pipeline/lib/fatal.mjs +129 -0
  19. package/pipeline/lib/figma-mcp-refresh.sh +18 -0
  20. package/pipeline/lib/figma-screenshot.sh +18 -0
  21. package/pipeline/lib/invoked-directly.mjs +43 -0
  22. package/pipeline/lib/jira-publish.sh +42 -0
  23. package/pipeline/lib/md2confluence-v3.py +47 -0
  24. package/pipeline/lib/outbound-gate.mjs +175 -0
  25. package/pipeline/lib/plan-todos.sh +27 -6
  26. package/pipeline/lib/post-pr-review.sh +77 -8
  27. package/pipeline/lib/repo-hygiene.sh +8 -3
  28. package/pipeline/lib/require-jq.sh +40 -0
  29. package/pipeline/lib/run-paths.sh +335 -0
  30. package/pipeline/multi-agent-refs/features/autopilot-circuit-breaker.md +70 -0
  31. package/pipeline/multi-agent-refs/features/cost-analysis.md +93 -0
  32. package/pipeline/multi-agent-refs/features/doctor.md +45 -0
  33. package/pipeline/multi-agent-refs/features/verify.md +83 -0
  34. package/pipeline/multi-agent-refs/phases/operations.md +13 -2
  35. package/pipeline/multi-agent-refs/phases/phase-0-init.md +1 -1
  36. package/pipeline/multi-agent-refs/unattended-contract.md +129 -0
  37. package/pipeline/scripts/_run-paths.mjs +372 -0
  38. package/pipeline/scripts/aggregate-metrics.mjs +64 -64
  39. package/pipeline/scripts/autopilot-arming.mjs +2 -1
  40. package/pipeline/scripts/autopilot-intake.mjs +2 -1
  41. package/pipeline/scripts/autopilot-runner.mjs +206 -2
  42. package/pipeline/scripts/build-references.mjs +2 -1
  43. package/pipeline/scripts/build-stack-plugins.mjs +10 -2
  44. package/pipeline/scripts/capture-evidence.sh +7 -2
  45. package/pipeline/scripts/classify-plan-safety.mjs +2 -1
  46. package/pipeline/scripts/cost-analyze.mjs +600 -0
  47. package/pipeline/scripts/cost-budget-check.mjs +4 -12
  48. package/pipeline/scripts/council-view.mjs +2 -1
  49. package/pipeline/scripts/crush-json.mjs +2 -1
  50. package/pipeline/scripts/diff-explain.mjs +6 -9
  51. package/pipeline/scripts/diff-risk-score.mjs +2 -1
  52. package/pipeline/scripts/doctor.mjs +138 -4
  53. package/pipeline/scripts/evidence-gate.mjs +9 -3
  54. package/pipeline/scripts/feedback-send.mjs +12 -2
  55. package/pipeline/scripts/gc-abandoned.sh +29 -13
  56. package/pipeline/scripts/gc-worktrees.sh +11 -4
  57. package/pipeline/scripts/github-ssh-setup.sh +64 -7
  58. package/pipeline/scripts/graph-mermaid.mjs +4 -2
  59. package/pipeline/scripts/keychain-save.sh +101 -30
  60. package/pipeline/scripts/learn-from-transcripts.mjs +2 -1
  61. package/pipeline/scripts/learning-curve.mjs +34 -29
  62. package/pipeline/scripts/make-manifest.mjs +199 -0
  63. package/pipeline/scripts/migrate-prefs.mjs +2 -1
  64. package/pipeline/scripts/migrate-state.mjs +94 -4
  65. package/pipeline/scripts/phase-banner.sh +6 -2
  66. package/pipeline/scripts/phase-tracker.sh +41 -3
  67. package/pipeline/scripts/plan-coverage-gate.mjs +6 -2
  68. package/pipeline/scripts/pre-commit-check.sh +7 -0
  69. package/pipeline/scripts/pre-push-check.sh +7 -0
  70. package/pipeline/scripts/purge.sh +23 -6
  71. package/pipeline/scripts/render-agent-log-cost.sh +9 -2
  72. package/pipeline/scripts/render-cost-summary.sh +9 -2
  73. package/pipeline/scripts/render-work-summary.sh +11 -4
  74. package/pipeline/scripts/review-file-filter.mjs +4 -2
  75. package/pipeline/scripts/review-scope.mjs +2 -1
  76. package/pipeline/scripts/routine-registry.mjs +2 -1
  77. package/pipeline/scripts/run-aggregator.mjs +13 -14
  78. package/pipeline/scripts/run-metrics.mjs +3 -1
  79. package/pipeline/scripts/runs-index.mjs +343 -0
  80. package/pipeline/scripts/scorecard-snapshot.mjs +178 -0
  81. package/pipeline/scripts/search-logs.sh +18 -0
  82. package/pipeline/scripts/test-gap-scan.mjs +2 -1
  83. package/pipeline/scripts/test-integrity-gate.mjs +2 -1
  84. package/pipeline/scripts/update-issue-progress.sh +56 -7
  85. package/pipeline/scripts/usage-report.mjs +12 -1
  86. package/pipeline/scripts/validate-analysis-doc.mjs +2 -1
  87. package/pipeline/scripts/validate-code-graph.mjs +6 -3
  88. package/pipeline/scripts/validate-complaint-doc.mjs +2 -1
  89. package/pipeline/scripts/validate-diff-risk.mjs +6 -3
  90. package/pipeline/scripts/validate-test-gap.mjs +6 -3
  91. package/pipeline/scripts/validate-triage.mjs +3 -1
  92. package/pipeline/scripts/verify-citations.mjs +4 -2
  93. package/pipeline/scripts/verify.mjs +327 -0
  94. package/pipeline/scripts/worktree-finalize.sh +13 -4
  95. package/pipeline/scripts/write-state.mjs +154 -15
  96. package/pipeline/skills/.skill-manifest.json +2 -2
  97. package/pipeline/skills/.skills-index.json +56 -1
  98. package/pipeline/skills/shared/README.md +8 -3
  99. package/pipeline/skills/shared/core/multi-agent-status/SKILL.md +33 -9
  100. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/package_app.sh +4 -1
  101. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/setup_dev_signing.sh +4 -1
  102. package/pipeline/skills/shared/external/macos-spm-app-packaging/assets/templates/sign-and-notarize.sh +2 -1
  103. package/pipeline/skills/skills-index.md +6 -1
@@ -41,6 +41,7 @@
41
41
  // Exit: 0 valid, 1 invalid (or WARN under --strict), 64 usage error.
42
42
 
43
43
  import { readFileSync } from "node:fs";
44
+ import { runMain } from "../lib/fatal.mjs";
44
45
 
45
46
  // A repo-less run (Locked 35) still splits by channel, derived from the evidence:
46
47
  // "mobile" and "web" are its platform values. "none" is the narrower case where the
@@ -1019,4 +1020,4 @@ function main() {
1019
1020
  console.log(`validate-analysis-doc: OK (mode=${mode}, ${warns.length} warning(s))`);
1020
1021
  }
1021
1022
 
1022
- main();
1023
+ runMain("validate-analysis-doc", main);
@@ -162,13 +162,16 @@ export function validate(obj) {
162
162
  obj = JSON.parse(raw);
163
163
  } catch (e) {
164
164
  console.log(JSON.stringify({ ok: false, errors: [`JSON parse error: ${e.message}`] }));
165
- process.exit(1);
165
+ process.exitCode = 1;
166
+ return;
166
167
  }
167
168
  const errors = validate(obj);
168
169
  if (errors.length === 0) {
169
170
  console.log(JSON.stringify({ ok: true, errors: [] }));
170
- process.exit(0);
171
+ return;
171
172
  }
173
+ // `errors` is one entry per violation and has no bound, so process.exit(1)
174
+ // here truncated the report exactly when there was most of it to read.
172
175
  console.log(JSON.stringify({ ok: false, errors }));
173
- process.exit(1);
176
+ process.exitCode = 1;
174
177
  })();
@@ -40,6 +40,7 @@
40
40
  // Exit: 0 valid, 1 invalid (or WARN under --strict), 64 usage error.
41
41
 
42
42
  import { readFileSync } from "node:fs";
43
+ import { runMain } from "../lib/fatal.mjs";
43
44
 
44
45
  const REQUIRED_FM = ["run_name", "generated_at", "language", "complaint_count", "graylog_degraded"];
45
46
 
@@ -263,4 +264,4 @@ function main() {
263
264
  process.exit(0);
264
265
  }
265
266
 
266
- main();
267
+ runMain("validate-complaint-doc", main);
@@ -120,13 +120,16 @@ function validate(obj) {
120
120
  obj = JSON.parse(raw);
121
121
  } catch (e) {
122
122
  console.log(JSON.stringify({ ok: false, errors: [`JSON parse error: ${e.message}`] }));
123
- process.exit(1);
123
+ process.exitCode = 1;
124
+ return;
124
125
  }
125
126
  const errors = validate(obj);
126
127
  if (errors.length === 0) {
127
128
  console.log(JSON.stringify({ ok: true, errors: [] }));
128
- process.exit(0);
129
+ return;
129
130
  }
131
+ // `errors` is one entry per violation and has no bound, so process.exit(1)
132
+ // here truncated the report exactly when there was most of it to read.
130
133
  console.log(JSON.stringify({ ok: false, errors }));
131
- process.exit(1);
134
+ process.exitCode = 1;
132
135
  })();
@@ -88,13 +88,16 @@ function validate(obj) {
88
88
  obj = JSON.parse(raw);
89
89
  } catch (e) {
90
90
  console.log(JSON.stringify({ ok: false, errors: [`JSON parse error: ${e.message}`] }));
91
- process.exit(1);
91
+ process.exitCode = 1;
92
+ return;
92
93
  }
93
94
  const errors = validate(obj);
94
95
  if (errors.length === 0) {
95
96
  console.log(JSON.stringify({ ok: true, errors: [] }));
96
- process.exit(0);
97
+ return;
97
98
  }
99
+ // `errors` is one entry per violation and has no bound, so process.exit(1)
100
+ // here truncated the report exactly when there was most of it to read.
98
101
  console.log(JSON.stringify({ ok: false, errors }));
99
- process.exit(1);
102
+ process.exitCode = 1;
100
103
  })();
@@ -292,4 +292,6 @@ function validate(raw) {
292
292
  const raw = await readInput();
293
293
  const result = validate(raw);
294
294
  console.log(JSON.stringify(result, null, 2));
295
- process.exit(result.ok ? result.code : 1);
295
+ // Assigned rather than called: process.exit() would cut this payload short when
296
+ // stdout is a pipe, which is how every caller reads it.
297
+ process.exitCode = result.ok ? result.code : 1;
@@ -45,6 +45,8 @@
45
45
  import { readFileSync, realpathSync, statSync } from "node:fs";
46
46
  import { resolve as resolvePath, sep } from "node:path";
47
47
  import { spawnSync } from "node:child_process";
48
+ import { runMain } from "../lib/fatal.mjs";
49
+ import { invokedDirectly } from "../lib/invoked-directly.mjs";
48
50
 
49
51
  /**
50
52
  * Reject a path before it reaches git.
@@ -423,6 +425,6 @@ function main() {
423
425
  process.exit(report.unresolved.length === 0 ? 0 : 1);
424
426
  }
425
427
 
426
- if (import.meta.url === `file://${process.argv[1]}`) {
427
- main();
428
+ if (invokedDirectly(import.meta.url)) {
429
+ runMain("verify-citations", main);
428
430
  }
@@ -0,0 +1,327 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * verify.mjs - "is this install the thing that was published".
4
+ *
5
+ * Two questions, and they fail in different directions.
6
+ *
7
+ * 1. PACKAGE. Every file the package shipped, against the SHA-256 recorded in
8
+ * manifest.json at publish time. A file that differs was edited after
9
+ * install or arrived damaged; a file that is missing was never written.
10
+ * 2. INSTALL. ~/.claude holds a COPY of the package's pipeline tree, made by
11
+ * install.js. From the moment it is written the two drift independently,
12
+ * and both directions are real: an edit in ~/.claude is a change with no
13
+ * source, and a file the installer skipped is a script the docs describe
14
+ * and nobody has.
15
+ *
16
+ * Only the Claude tree is compared byte for byte. The Copilot and Codex trees
17
+ * are path-rewritten by the installer on purpose, so a byte difference there is
18
+ * the design rather than the bug, and they are reported as counts.
19
+ *
20
+ * What a green result means, stated plainly because the opposite is easy to
21
+ * imply: it means the bytes match what the publisher recorded. It is not proof
22
+ * of who published them. The manifest, the signature and this verifier all
23
+ * travel inside the same tarball, so anyone able to rewrite one can rewrite the
24
+ * others - provenance is npm's integrity field, not ours. This catches damage,
25
+ * partial installs and post-install edits, which are the failures that actually
26
+ * happen.
27
+ *
28
+ * Usage:
29
+ * verify.mjs both questions, human output
30
+ * verify.mjs --package package integrity only
31
+ * verify.mjs --install install drift only
32
+ * verify.mjs --json
33
+ *
34
+ * Exit codes:
35
+ * 0 everything matches
36
+ * 1 a difference was found
37
+ * 2 nothing to verify (no manifest - a dev checkout, or a pre-manifest version)
38
+ */
39
+
40
+ import { createHash, createPublicKey, verify as cryptoVerify } from "node:crypto";
41
+ import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
42
+ import { homedir } from "node:os";
43
+ import { dirname, join, relative } from "node:path";
44
+ import { fileURLToPath, pathToFileURL } from "node:url";
45
+ import { runMain } from "../lib/fatal.mjs";
46
+
47
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
48
+ const MANIFEST = join(ROOT, "manifest.json");
49
+
50
+ const argv = process.argv.slice(2);
51
+ const has = (f) => argv.includes(f);
52
+ const json = has("--json");
53
+
54
+ /**
55
+ * The ed25519 public key a signature is checked against. It comes from the
56
+ * environment and nothing is pinned in this file yet - so on a stock install a
57
+ * signed manifest reports "signed, no public key to check it against" rather
58
+ * than claiming valid. That is the honest state: a signature nobody can check
59
+ * is not a signature that passed, and hard-coding a key here before there is a
60
+ * release key to hard-code would be the opposite.
61
+ */
62
+ const PUBLIC_KEY = process.env.MULTI_AGENT_SIGNING_PUBKEY || "";
63
+
64
+ const sha256 = (p) => createHash("sha256").update(readFileSync(p)).digest("hex");
65
+
66
+ /**
67
+ * Walk a tree, following symlinks but never twice.
68
+ *
69
+ * Following them is required rather than optional: `install --link` puts a
70
+ * symlink at ~/.claude/scripts, and a walker that skipped symlinks would report
71
+ * a linked install as entirely missing. The cost is that a link pointing at an
72
+ * ancestor turns the walk into a loop, so every directory is recorded by its
73
+ * RESOLVED path and visited once.
74
+ */
75
+ function walk(dir, base = dir, out = [], seen = new Set()) {
76
+ let real;
77
+ try {
78
+ real = realpathSync(dir);
79
+ } catch {
80
+ return out;
81
+ }
82
+ if (seen.has(real)) return out;
83
+ seen.add(real);
84
+ let entries;
85
+ try {
86
+ entries = readdirSync(dir);
87
+ } catch {
88
+ return out;
89
+ }
90
+ for (const name of entries) {
91
+ if (name === ".DS_Store" || name === "__pycache__") continue;
92
+ const abs = join(dir, name);
93
+ let st;
94
+ try {
95
+ st = statSync(abs);
96
+ } catch {
97
+ continue;
98
+ }
99
+ if (st.isDirectory()) walk(abs, base, out, seen);
100
+ else out.push(relative(base, abs));
101
+ }
102
+ return out;
103
+ }
104
+
105
+ // --- 1. package integrity ----------------------------------------------------
106
+
107
+ function verifyPackage() {
108
+ const manifest = JSON.parse(readFileSync(MANIFEST, "utf-8"));
109
+ const changed = [];
110
+ const missing = [];
111
+ for (const [rel, want] of Object.entries(manifest.files)) {
112
+ const abs = join(ROOT, rel);
113
+ if (!existsSync(abs)) {
114
+ missing.push(rel);
115
+ continue;
116
+ }
117
+ if (sha256(abs) !== want) changed.push(rel);
118
+ }
119
+
120
+ let signature = "unsigned";
121
+ const sigPath = join(ROOT, "manifest.sig");
122
+ if (existsSync(sigPath)) {
123
+ if (!PUBLIC_KEY) signature = "signed, no public key to check it against";
124
+ else {
125
+ try {
126
+ const ok = cryptoVerify(
127
+ null,
128
+ Buffer.from(readFileSync(MANIFEST)),
129
+ createPublicKey(PUBLIC_KEY),
130
+ Buffer.from(readFileSync(sigPath, "utf-8").trim(), "base64"),
131
+ );
132
+ signature = ok ? "valid" : "INVALID";
133
+ } catch (err) {
134
+ signature = `unverifiable: ${err?.message ?? err}`;
135
+ }
136
+ }
137
+ }
138
+
139
+ return {
140
+ version: manifest.version,
141
+ commit: manifest.commit,
142
+ fileCount: manifest.fileCount,
143
+ changed,
144
+ missing,
145
+ signature,
146
+ ok: changed.length === 0 && missing.length === 0 && signature !== "INVALID",
147
+ };
148
+ }
149
+
150
+ // --- 2. install drift --------------------------------------------------------
151
+
152
+ /**
153
+ * The trees install.js writes into ~/.claude, and how each one may be compared.
154
+ * Kept as data rather than asked of the installer, because the installer's job
155
+ * is to WRITE them and a verifier that asks the writer what it wrote proves
156
+ * nothing.
157
+ *
158
+ * `bytes` means the copy is verbatim and a difference is drift. `presence` is
159
+ * for commands/, where install.js rewrites each SKILL.md's `description` into
160
+ * the user's outputLanguage - every file differs there BY DESIGN, so comparing
161
+ * bytes would report 57 findings on a healthy machine and teach everyone to
162
+ * ignore the whole report.
163
+ */
164
+ const CLAUDE_TREES = [
165
+ ["scripts", "scripts", "bytes"],
166
+ ["lib", "lib", "bytes"],
167
+ ["multi-agent-refs", "multi-agent-refs", "bytes"],
168
+ ["agents", "agents", "bytes"],
169
+ ["commands/multi-agent", "commands/multi-agent", "presence"],
170
+ ];
171
+
172
+ /**
173
+ * Files the package carries but the installer deliberately does not write:
174
+ * smokes, linters, fixtures and the rest of the maintainer surface. Without
175
+ * this filter every one of them reads as "the installer skipped a file", which
176
+ * is 251 false findings on a correct install.
177
+ */
178
+ async function devOnly() {
179
+ try {
180
+ const mod = await import(new URL("../../install/_dev-only-files.mjs", import.meta.url).href);
181
+ return mod.isDevOnlyScript;
182
+ } catch {
183
+ // No filter available: say so by filtering nothing, and let the counts be
184
+ // wrong loudly rather than silently.
185
+ return null;
186
+ }
187
+ }
188
+
189
+ async function verifyInstall() {
190
+ const home = homedir();
191
+ const claude = join(home, ".claude");
192
+ if (!existsSync(claude)) {
193
+ return { present: false, reason: "no ~/.claude on this machine", ok: true, trees: [] };
194
+ }
195
+
196
+ const isDevOnly = await devOnly();
197
+ const trees = [];
198
+ let differing = 0;
199
+ let absent = 0;
200
+ for (const [srcRel, dstRel, mode] of CLAUDE_TREES) {
201
+ const src = join(ROOT, "pipeline", srcRel);
202
+ const dst = join(claude, dstRel);
203
+ if (!existsSync(src)) continue;
204
+ const srcFiles = walk(src).filter(
205
+ (rel) => !(srcRel === "scripts" && isDevOnly && isDevOnly(rel)),
206
+ );
207
+ const changed = [];
208
+ const missing = [];
209
+ for (const rel of srcFiles) {
210
+ const b = join(dst, rel);
211
+ if (!existsSync(b)) {
212
+ missing.push(rel);
213
+ continue;
214
+ }
215
+ if (mode === "bytes" && sha256(join(src, rel)) !== sha256(b)) changed.push(rel);
216
+ }
217
+ differing += changed.length;
218
+ absent += missing.length;
219
+ trees.push({ tree: dstRel, mode, files: srcFiles.length, changed, missing });
220
+ }
221
+
222
+ const others = [".copilot", ".codex"].filter((h) => existsSync(join(home, h)));
223
+
224
+ return {
225
+ present: true,
226
+ trees,
227
+ differing,
228
+ absent,
229
+ otherHosts: others,
230
+ ok: differing === 0 && absent === 0,
231
+ };
232
+ }
233
+
234
+ // --- output ------------------------------------------------------------------
235
+
236
+ async function main() {
237
+ const wantPackage = has("--package") || !has("--install");
238
+ const wantInstall = has("--install") || !has("--package");
239
+
240
+ if (wantPackage && !existsSync(MANIFEST)) {
241
+ const msg =
242
+ "no manifest.json - this is a source checkout or a version published before manifests existed";
243
+ if (json)
244
+ process.stdout.write(`${JSON.stringify({ kind: "UNVERIFIABLE", reason: msg }, null, 2)}\n`);
245
+ else process.stdout.write(`UNVERIFIABLE: ${msg}\n`);
246
+ process.exitCode = 2;
247
+ return;
248
+ }
249
+
250
+ const pkg = wantPackage ? verifyPackage() : null;
251
+ const inst = wantInstall ? await verifyInstall() : null;
252
+
253
+ if (json) {
254
+ process.stdout.write(`${JSON.stringify({ package: pkg, install: inst }, null, 2)}\n`);
255
+ } else {
256
+ if (pkg) {
257
+ process.stdout.write(
258
+ `paket: ${pkg.version} (${pkg.commit?.slice(0, 12) ?? "commit bilinmiyor"}) - ${pkg.fileCount} dosya, imza: ${pkg.signature}\n`,
259
+ );
260
+ if (!pkg.changed.length && !pkg.missing.length)
261
+ process.stdout.write(" butun dosyalar yayinlandigi gibi\n");
262
+ const SHOWN = 20;
263
+ for (const f of pkg.changed.slice(0, SHOWN)) process.stdout.write(` ! degismis: ${f}\n`);
264
+ for (const f of pkg.missing.slice(0, SHOWN)) process.stdout.write(` ! eksik: ${f}\n`);
265
+ // Counted per list against what was actually PRINTED. Subtracting a flat
266
+ // 40 from the combined total spent a budget the lists had not used: with
267
+ // 25 changed and 0 missing it printed 20, hid 5, and said nothing - a
268
+ // tampered install under-reported by up to twenty files with no sign.
269
+ const hidden =
270
+ Math.max(0, pkg.changed.length - SHOWN) + Math.max(0, pkg.missing.length - SHOWN);
271
+ if (hidden > 0) process.stdout.write(` ... ve ${hidden} dosya daha\n`);
272
+ }
273
+ if (inst) {
274
+ if (!inst.present) process.stdout.write(`kurulum: ${inst.reason}\n`);
275
+ else {
276
+ const total = inst.trees.reduce((a, t) => a + t.files, 0);
277
+ process.stdout.write(
278
+ `kurulum: ~/.claude - ${inst.trees.length} agac, ${total} dosya karsilastirildi\n`,
279
+ );
280
+ for (const t of inst.trees) {
281
+ if (!t.changed.length && !t.missing.length) continue;
282
+ const how =
283
+ t.mode === "presence" ? " (yalnizca varlik: aciklamalar kurulumda cevriliyor)" : "";
284
+ process.stdout.write(
285
+ ` ${t.tree}: ${t.changed.length} farkli, ${t.missing.length} eksik${how}\n`,
286
+ );
287
+ for (const f of [...t.changed.slice(0, 5)]) process.stdout.write(` ! ${f}\n`);
288
+ for (const f of [...t.missing.slice(0, 5)])
289
+ process.stdout.write(` ? ${f} (hic yazilmamis)\n`);
290
+ }
291
+ if (inst.ok) process.stdout.write(" kaynakla birebir ayni\n");
292
+ if (inst.otherHosts.length)
293
+ process.stdout.write(
294
+ ` ${inst.otherHosts.join(", ")} kurulu - yollari kurulumda yeniden yazildigi icin bayt karsilastirmasi yapilmadi\n`,
295
+ );
296
+ }
297
+ }
298
+ }
299
+
300
+ const bad = (pkg && !pkg.ok) || (inst && !inst.ok);
301
+ process.exitCode = bad ? 1 : 0;
302
+ }
303
+
304
+ // Importable AND runnable: index.js calls main() for `multi-agent-pipeline
305
+ // verify`, and the direct-run guard keeps a bare `node verify.mjs` behaving
306
+ // the same way every other script here does.
307
+ export { main };
308
+
309
+ /**
310
+ * realpath, not a string compare against argv[1]. Two ordinary situations break
311
+ * the naive form: macOS hands out /var/folders/... paths that resolve to
312
+ * /private/var/folders/..., and `install --link` puts a SYMLINK at
313
+ * ~/.claude/scripts/verify.mjs - in both cases import.meta.url is the resolved
314
+ * path, argv[1] is not, and the script silently does nothing at all.
315
+ */
316
+ function invokedDirectly() {
317
+ if (!process.argv[1]) return false;
318
+ try {
319
+ return import.meta.url === pathToFileURL(realpathSync(process.argv[1])).href;
320
+ } catch {
321
+ return false;
322
+ }
323
+ }
324
+
325
+ if (invokedDirectly()) {
326
+ runMain("verify", main);
327
+ }
@@ -28,7 +28,7 @@
28
28
  # 0 removed (or dry-run that would remove)
29
29
  # 3 SKIPPED by a safety precondition - not an error, reason is reported
30
30
  # 1 usage / hard error
31
- set -uo pipefail
31
+ set -euo pipefail
32
32
 
33
33
  WORKTREE=""; PROJECT_ROOT=""; TASK_ID=""; PROJECT=""; BRANCH=""
34
34
  LOGS_ROOT="${HOME}/.claude/logs/multi-agent"
@@ -97,6 +97,10 @@ skip() { REASON="$1"; emit; exit 3; }
97
97
  # preference at all, because turning it off appears to work and does nothing.
98
98
  PREFS="${PREFS_FILE:-$HOME/.claude/multi-agent-preferences.json}"
99
99
  if [ -f "$PREFS" ] && command -v node >/dev/null 2>&1; then
100
+ # `|| echo true` on the far side already covers a node that throws: an
101
+ # unreadable preference file reads as "not set", which is the default. Noted
102
+ # here because it is the one assignment in this file that was ALREADY safe
103
+ # under `set -e`, and the next reader should not have to re-derive that.
100
104
  enabled="$(node -e '
101
105
  const fs=require("fs");
102
106
  try {
@@ -173,6 +177,9 @@ fi
173
177
  # alternatives are end-anchored - unanchored, `.build.log.old` was forgiven here
174
178
  # but not deletable below, which made every removal refuse forever.
175
179
  ARTIFACTS_RE='^(agent-state\.json|phase-tracker\.json|triage-output\.json|\.review-diff\.txt|\.build\.log|\.test\.log)$|^\.pipeline/'
180
+ # Forgiven at the end of the pipeline (see below): a worktree whose git dir is
181
+ # already gone reports nothing, and "nothing dirty" is the correct reading of
182
+ # that - aborting would strand the removal this function exists to perform.
176
183
  dirty="$(git -C "$rp_wt" status --porcelain 2>/dev/null | awk '
177
184
  {
178
185
  st = substr($0, 1, 2); path = substr($0, 4);
@@ -183,7 +190,7 @@ dirty="$(git -C "$rp_wt" status --porcelain 2>/dev/null | awk '
183
190
  continue # our own untracked artefact
184
191
  fi
185
192
  printf '%s\n' "$path"
186
- done)"
193
+ done || true)"
187
194
  if [ -n "$dirty" ]; then
188
195
  first="$(printf '%s\n' "$dirty" | head -1)"
189
196
  skip "worktree has uncommitted changes (e.g. $first) - refusing to remove"
@@ -219,7 +226,9 @@ copy_one() {
219
226
  SALVAGED="${SALVAGED:+$SALVAGED,}\"$1\""
220
227
  return 0
221
228
  fi
222
- mkdir -p "$DEST/$(dirname "$1")" 2>/dev/null
229
+ # Forgiven: this function already tolerates a copy that does not happen, and
230
+ # aborting here would skip the worktree removal that follows.
231
+ mkdir -p "$DEST/$(dirname "$1")" 2>/dev/null || true
223
232
  [ -d "$DEST/$1" ] && rm -rf "${DEST:?}/$1"
224
233
  cp -R "$src" "$DEST/$1" 2>/dev/null && SALVAGED="${SALVAGED:+$SALVAGED,}\"$1\""
225
234
  }
@@ -240,7 +249,7 @@ copy_from_logs() {
240
249
  SALVAGED="${SALVAGED:+$SALVAGED,}\"$1\""
241
250
  return 0
242
251
  fi
243
- mkdir -p "$DEST/$(dirname "$1")" 2>/dev/null
252
+ mkdir -p "$DEST/$(dirname "$1")" 2>/dev/null || true
244
253
  cp -R "$src" "$DEST/$1" 2>/dev/null && SALVAGED="${SALVAGED:+$SALVAGED,}\"$1\""
245
254
  }
246
255