projectstore-claude 0.29.3 → 0.30.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 (57) hide show
  1. package/README.md +13 -12
  2. package/bin/projectstore-claude.mjs +2 -2
  3. package/node_modules/projectstore/.claude-plugin/marketplace.json +1 -1
  4. package/node_modules/projectstore/.claude-plugin/plugin.json +1 -1
  5. package/node_modules/projectstore/README.md +153 -77
  6. package/node_modules/projectstore/commands/bind.md +6 -17
  7. package/node_modules/projectstore/commands/doctor.md +12 -7
  8. package/node_modules/projectstore/commands/statusline.md +1 -1
  9. package/node_modules/projectstore/commands/story.md +15 -2
  10. package/node_modules/projectstore/docs/extending.md +11 -6
  11. package/node_modules/projectstore/docs/getting-started.md +21 -1
  12. package/node_modules/projectstore/docs/harnesses.md +13 -10
  13. package/node_modules/projectstore/docs/how-it-works.md +6 -4
  14. package/node_modules/projectstore/harnesses/claude-code.json +16 -15
  15. package/node_modules/projectstore/harnesses/codex.json +12 -13
  16. package/node_modules/projectstore/hooks/band.tsx +48 -20
  17. package/node_modules/projectstore/hooks/pre-compact.mjs +7 -10
  18. package/node_modules/projectstore/hooks/session-rules.mjs +14 -8
  19. package/node_modules/projectstore/hooks/session-start.mjs +50 -18
  20. package/node_modules/projectstore/hooks/session-stop.mjs +8 -6
  21. package/node_modules/projectstore/package.json +11 -2
  22. package/node_modules/projectstore/scripts/band-shared.mjs +141 -24
  23. package/node_modules/projectstore/scripts/band.mjs +72 -21
  24. package/node_modules/projectstore/scripts/binding.mjs +616 -85
  25. package/node_modules/projectstore/scripts/build-adapters.mjs +73 -29
  26. package/node_modules/projectstore/scripts/cli.mjs +1015 -185
  27. package/node_modules/projectstore/scripts/codemap.mjs +22 -7
  28. package/node_modules/projectstore/scripts/convergence.mjs +253 -83
  29. package/node_modules/projectstore/scripts/diff-refs.mjs +14 -8
  30. package/node_modules/projectstore/scripts/doctor-report.mjs +91 -23
  31. package/node_modules/projectstore/scripts/doctor.mjs +1317 -371
  32. package/node_modules/projectstore/scripts/draft.mjs +5 -2
  33. package/node_modules/projectstore/scripts/fetch-shell.mjs +188 -39
  34. package/node_modules/projectstore/scripts/graph.mjs +19 -13
  35. package/node_modules/projectstore/scripts/harness.mjs +123 -48
  36. package/node_modules/projectstore/scripts/install-harness.mjs +3532 -618
  37. package/node_modules/projectstore/scripts/kanban.mjs +2 -1
  38. package/node_modules/projectstore/scripts/lib.mjs +694 -159
  39. package/node_modules/projectstore/scripts/mcp.mjs +386 -105
  40. package/node_modules/projectstore/scripts/portable-registration.mjs +224 -51
  41. package/node_modules/projectstore/scripts/provenance.mjs +26 -10
  42. package/node_modules/projectstore/scripts/query.mjs +378 -80
  43. package/node_modules/projectstore/scripts/reconcile.mjs +55 -18
  44. package/node_modules/projectstore/scripts/run-host.mjs +62 -17
  45. package/node_modules/projectstore/scripts/scaffold.mjs +89 -28
  46. package/node_modules/projectstore/scripts/setup.mjs +987 -0
  47. package/node_modules/projectstore/scripts/stages.mjs +5 -1
  48. package/node_modules/projectstore/scripts/statusline-launcher.mjs +36 -11
  49. package/node_modules/projectstore/scripts/statusline.mjs +32 -14
  50. package/node_modules/projectstore/scripts/story-section.mjs +39 -17
  51. package/node_modules/projectstore/scripts/surfaces.mjs +416 -95
  52. package/node_modules/projectstore/scripts/term.mjs +382 -97
  53. package/node_modules/projectstore/scripts/tokens.mjs +106 -28
  54. package/node_modules/projectstore/scripts/touch-session.mjs +109 -70
  55. package/node_modules/projectstore/scripts/version-guard.mjs +74 -27
  56. package/node_modules/projectstore/scripts/worktree.mjs +16 -5
  57. package/package.json +3 -3
@@ -8,9 +8,21 @@ import { join, resolve } from "node:path";
8
8
  import { homedir } from "node:os";
9
9
  import { whichOnPath, cmpPrecedence } from "./lib.mjs";
10
10
 
11
- const readJson = (path) => { try { return JSON.parse(readFileSync(path, "utf8")); } catch { return null; } };
11
+ const readJson = (path) => {
12
+ try {
13
+ return JSON.parse(readFileSync(path, "utf8"));
14
+ } catch {
15
+ return null;
16
+ }
17
+ };
12
18
  const samePath = (a, b) => {
13
- const real = (p) => { try { return realpathSync(p); } catch { return resolve(p); } };
19
+ const real = (p) => {
20
+ try {
21
+ return realpathSync(p);
22
+ } catch {
23
+ return resolve(p);
24
+ }
25
+ };
14
26
  return Boolean(a && b) && real(a) === real(b);
15
27
  };
16
28
 
@@ -19,19 +31,31 @@ function parseValue(raw) {
19
31
  if (s === "true") return true;
20
32
  if (s === "false") return false;
21
33
  if (s.startsWith('"') && s.endsWith('"')) {
22
- try { return JSON.parse(s); } catch { return s.slice(1, -1); }
34
+ try {
35
+ return JSON.parse(s);
36
+ } catch {
37
+ return s.slice(1, -1);
38
+ }
23
39
  }
24
40
  return s;
25
41
  }
26
42
 
27
43
  export function readTomlSections(path) {
28
44
  let text;
29
- try { text = readFileSync(path, "utf8"); } catch { return new Map(); }
45
+ try {
46
+ text = readFileSync(path, "utf8");
47
+ } catch {
48
+ return new Map();
49
+ }
30
50
  const sections = new Map();
31
51
  let current = null;
32
52
  for (const line of text.split(/\r?\n/)) {
33
53
  const header = line.match(/^\s*\[([^\]]+)]\s*(?:#.*)?$/);
34
- if (header) { current = header[1]; if (!sections.has(current)) sections.set(current, {}); continue; }
54
+ if (header) {
55
+ current = header[1];
56
+ if (!sections.has(current)) sections.set(current, {});
57
+ continue;
58
+ }
35
59
  if (!current || /^\s*(?:#|$)/.test(line)) continue;
36
60
  const kv = line.match(/^\s*([A-Za-z0-9_-]+)\s*=\s*(.*?)\s*(?:#.*)?$/);
37
61
  if (kv) sections.get(current)[kv[1]] = parseValue(kv[2]);
@@ -43,17 +67,23 @@ export function payloadFiles(root) {
43
67
  const out = [];
44
68
  const walk = (at, rel = "") => {
45
69
  let entries;
46
- try { entries = readdirSync(at, { withFileTypes: true }); } catch { return; }
70
+ try {
71
+ entries = readdirSync(at, { withFileTypes: true });
72
+ } catch {
73
+ return;
74
+ }
47
75
  for (const e of entries.sort((a, b) => a.name.localeCompare(b.name))) {
48
76
  if (e.name.startsWith(".DS_Store")) continue;
49
- const abs = join(at, e.name), next = rel ? `${rel}/${e.name}` : e.name;
77
+ const abs = join(at, e.name),
78
+ next = rel ? `${rel}/${e.name}` : e.name;
50
79
  // npm creates command shims as symlinks here. The shell invokes the
51
80
  // bundled core by its real path, so these convenience links are neither
52
81
  // runtime input nor portable plugin payload.
53
82
  if (next === "node_modules/.bin" || next.startsWith("node_modules/.bin/")) continue;
54
83
  const st = lstatSync(abs);
55
84
  if (st.isSymbolicLink()) throw new Error(`plugin payload contains a symlink: ${next}`);
56
- if (st.isDirectory()) walk(abs, next); else if (st.isFile()) out.push(next);
85
+ if (st.isDirectory()) walk(abs, next);
86
+ else if (st.isFile()) out.push(next);
57
87
  }
58
88
  };
59
89
  walk(root);
@@ -65,7 +95,11 @@ export function payloadDigest(root) {
65
95
  const h = createHash("sha256");
66
96
  for (const rel of files) {
67
97
  h.update(rel + "\n");
68
- h.update(createHash("sha256").update(readFileSync(join(root, rel))).digest("hex") + "\n");
98
+ h.update(
99
+ createHash("sha256")
100
+ .update(readFileSync(join(root, rel)))
101
+ .digest("hex") + "\n",
102
+ );
69
103
  }
70
104
  return { count: files.length, sha256: h.digest("hex") };
71
105
  }
@@ -92,24 +126,32 @@ export function renderPortableCatalog(s) {
92
126
  return {
93
127
  name: s.marketplace_name,
94
128
  interface: { displayName: "ProjectStore (npm)" },
95
- plugins: [{
96
- name: s.plugin_name,
97
- source: { source: "local", path: `./${s.plugin_subdir}` },
98
- policy: { installation: "AVAILABLE", authentication: "ON_INSTALL" },
99
- category: "Developer Tools",
100
- }],
129
+ plugins: [
130
+ {
131
+ name: s.plugin_name,
132
+ source: { source: "local", path: `./${s.plugin_subdir}` },
133
+ policy: { installation: "AVAILABLE", authentication: "ON_INSTALL" },
134
+ category: "Developer Tools",
135
+ },
136
+ ],
101
137
  };
102
138
  }
103
139
 
104
- function pluginTable(id) { return `plugins.${JSON.stringify(id)}`; }
105
- function marketplaceTable(name) { return `marketplaces.${name}`; }
140
+ function pluginTable(id) {
141
+ return `plugins.${JSON.stringify(id)}`;
142
+ }
143
+ function marketplaceTable(name) {
144
+ return `marketplaces.${name}`;
145
+ }
106
146
 
107
147
  function pluginIds(sections) {
108
148
  const ids = [];
109
149
  for (const key of sections.keys()) {
110
150
  const m = key.match(/^plugins\.(.+)$/);
111
151
  if (!m) continue;
112
- try { ids.push(m[1].startsWith('"') ? JSON.parse(m[1]) : m[1]); } catch {}
152
+ try {
153
+ ids.push(m[1].startsWith('"') ? JSON.parse(m[1]) : m[1]);
154
+ } catch {}
113
155
  }
114
156
  return ids;
115
157
  }
@@ -132,23 +174,38 @@ export function isPortablePluginRoot(root) {
132
174
  }
133
175
  // The first manifest that parses, or null — or, with `kind`, that one only.
134
176
  export function payloadManifest(root, { kind = null } = {}) {
135
- for (const p of kind ? [payloadManifestPath(root, kind)] : payloadManifestPaths(root)) { const m = readJson(p); if (m) return m; }
177
+ for (const p of kind ? [payloadManifestPath(root, kind)] : payloadManifestPaths(root)) {
178
+ const m = readJson(p);
179
+ if (m) return m;
180
+ }
136
181
  return null;
137
182
  }
138
183
 
139
184
  function cacheEntries(paths, s) {
140
185
  const base = join(paths.cacheDir, s.marketplace_name, s.plugin_name);
141
186
  let names;
142
- try { names = readdirSync(base); } catch { return []; }
143
- return names.map((name) => {
144
- const path = join(base, name);
145
- const manifest = payloadManifest(path);
146
- let at = 0; try { at = statSync(path).mtimeMs; } catch {}
147
- if (!manifest || typeof manifest.version !== "string") return null;
148
- let digest = null;
149
- try { digest = payloadDigest(path); } catch {}
150
- return { path, version: manifest.version, at, digest };
151
- }).filter(Boolean).sort((a, b) => b.at - a.at || b.version.localeCompare(a.version));
187
+ try {
188
+ names = readdirSync(base);
189
+ } catch {
190
+ return [];
191
+ }
192
+ return names
193
+ .map((name) => {
194
+ const path = join(base, name);
195
+ const manifest = payloadManifest(path);
196
+ let at = 0;
197
+ try {
198
+ at = statSync(path).mtimeMs;
199
+ } catch {}
200
+ if (!manifest || typeof manifest.version !== "string") return null;
201
+ let digest = null;
202
+ try {
203
+ digest = payloadDigest(path);
204
+ } catch {}
205
+ return { path, version: manifest.version, at, digest };
206
+ })
207
+ .filter(Boolean)
208
+ .sort((a, b) => b.at - a.at || b.version.localeCompare(a.version));
152
209
  }
153
210
 
154
211
  // Where the payload to register lives. A surface conditioned on a distribution
@@ -182,7 +239,20 @@ export function portablePayloadRoot(s, { root, env = process.env, fetched = null
182
239
  // the one rung a local-tarball install at an unchanged version trips, and it
183
240
  // is decided after a real fetch. `unavailable` for want of a payload fires
184
241
  // only when there is neither. Doctor passes neither and reads as before.
185
- export function analysePortableRegistration(projectDir, s, { root, payloadRoot: explicitPayloadRoot = null, version = null, fetched = null, home = homedir(), harness, env = process.env, ignoreJournal = false } = {}) {
242
+ export function analysePortableRegistration(
243
+ projectDir,
244
+ s,
245
+ {
246
+ root,
247
+ payloadRoot: explicitPayloadRoot = null,
248
+ version = null,
249
+ fetched = null,
250
+ home = homedir(),
251
+ harness,
252
+ env = process.env,
253
+ ignoreJournal = false,
254
+ } = {},
255
+ ) {
186
256
  const paths = portableRegistrationPaths(s, { home, projectDir, harness, env });
187
257
  const payloadRoot = explicitPayloadRoot || portablePayloadRoot(s, { root, env, fetched });
188
258
  const desiredManifest = payloadRoot ? payloadManifest(payloadRoot) : null;
@@ -202,7 +272,8 @@ export function analysePortableRegistration(projectDir, s, { root, payloadRoot:
202
272
  const others = [...new Set([...pluginIds(global), ...pluginIds(project)])]
203
273
  .filter((other) => other !== id && other.split("@")[0] === s.plugin_name)
204
274
  .map((other) => {
205
- const g = global.get(pluginTable(other)) || null, p = project.get(pluginTable(other)) || null;
275
+ const g = global.get(pluginTable(other)) || null,
276
+ p = project.get(pluginTable(other)) || null;
206
277
  return { id: other, enabled: typeof p?.enabled === "boolean" ? p.enabled : g?.enabled === true };
207
278
  });
208
279
  // A registration newer than what this run offers (the converge story's rule
@@ -210,41 +281,143 @@ export function analysePortableRegistration(projectDir, s, { root, payloadRoot:
210
281
  // reason, and the cache is then read at the version the host registered —
211
282
  // keyed on the desired version, a newer registration's integrity rungs
212
283
  // checked the wrong cache directory.
213
- const newer = typeof ownership?.version === "string" && typeof desiredVersion === "string" && cmpPrecedence(ownership.version, desiredVersion) > 0;
284
+ const newer =
285
+ typeof ownership?.version === "string" &&
286
+ typeof desiredVersion === "string" &&
287
+ cmpPrecedence(ownership.version, desiredVersion) > 0;
214
288
  const caches = cacheEntries(paths, s);
215
289
  const installed = caches.find((e) => e.version === (newer ? ownership.version : desiredVersion)) || caches[0] || null;
216
- const out = { id, paths, path: paths.dir, payloadRoot, desiredVersion, versionOnly, bin, ownership, journal, catalog, market, globalPlugin, projectPlugin, enabled, others, caches, installed, installPath: installed?.path || null, installedVersion: installed?.version || null, state: "absent", reason: null, produced: Boolean(desiredManifest), contentDiffers: null, newer };
290
+ const out = {
291
+ id,
292
+ paths,
293
+ path: paths.dir,
294
+ payloadRoot,
295
+ desiredVersion,
296
+ versionOnly,
297
+ bin,
298
+ ownership,
299
+ journal,
300
+ catalog,
301
+ market,
302
+ globalPlugin,
303
+ projectPlugin,
304
+ enabled,
305
+ others,
306
+ caches,
307
+ installed,
308
+ installPath: installed?.path || null,
309
+ installedVersion: installed?.version || null,
310
+ state: "absent",
311
+ reason: null,
312
+ produced: Boolean(desiredManifest),
313
+ contentDiffers: null,
314
+ newer,
315
+ };
217
316
  const enabledOther = others.find((other) => other.enabled);
218
317
  const nothing = !existsSync(paths.dir) && !market && !globalPlugin && !installed && !enabledOther;
219
- if (!desiredManifest && !versionOnly) return { ...out, state: "unavailable", reason: payloadRoot ? `${payloadRoot} is not a portable plugin root` : `nothing to register from this run: ${harness?.display_name || "this harness"}'s plugin is registered from its distribution shell, not from the core` };
220
- if (!bin && nothing) return { ...out, state: "unavailable", reason: `\`${s.cli.bin}\` is not on PATH — the registration needs the host CLI` };
318
+ if (!desiredManifest && !versionOnly)
319
+ return {
320
+ ...out,
321
+ state: "unavailable",
322
+ reason: payloadRoot
323
+ ? `${payloadRoot} is not a portable plugin root`
324
+ : `nothing to register from this run: ${harness?.display_name || "this harness"}'s plugin is registered from its distribution shell, not from the core`,
325
+ };
326
+ if (!bin && nothing)
327
+ return {
328
+ ...out,
329
+ state: "unavailable",
330
+ reason: `\`${s.cli.bin}\` is not on PATH — the registration needs the host CLI`,
331
+ };
221
332
  let desiredDigest = null;
222
- if (!versionOnly) { try { desiredDigest = payloadDigest(payloadRoot); } catch (e) { return { ...out, state: "unavailable", reason: e.message }; } }
333
+ if (!versionOnly) {
334
+ try {
335
+ desiredDigest = payloadDigest(payloadRoot);
336
+ } catch (e) {
337
+ return { ...out, state: "unavailable", reason: e.message };
338
+ }
339
+ }
223
340
  out.desiredDigest = desiredDigest;
224
- if (enabledOther) return { ...out, state: "conflict", refusal: `${enabledOther.id} is already enabled; two ProjectStore plugins would load the same skills and hooks. Disable or remove that registration explicitly, then retry` };
341
+ if (enabledOther)
342
+ return {
343
+ ...out,
344
+ state: "conflict",
345
+ refusal: `${enabledOther.id} is already enabled; two ProjectStore plugins would load the same skills and hooks. Disable or remove that registration explicitly, then retry`,
346
+ };
225
347
  // A journal the rollback could not prove names the run that left it, when,
226
348
  // and its error, so the reader of the plan is not told recovery is assured
227
349
  // (issue #28). Every other phase reads as before.
228
- if (journal && !ignoreJournal) return { ...out, state: "stale", reason: journal.phase === "recovery-required"
229
- ? `a previous run${journal.failed_at ? ` (${journal.failed_at})` : ""} could not prove its restore: ${String(journal.error || "no error recorded").split("\n")[0]}; this run re-proves the previous state before applying this plan, and refuses if it cannot (${paths.journal})`
230
- : "an interrupted registration has a recovery journal; the next confirmed run recovers it before applying this plan" };
231
- if (existsSync(paths.dir) && !ownership) return { ...out, state: "foreign", refusal: `${paths.dir} exists without ${s.ownership_manifest}; a source this installer does not own holds the stable marketplace path` };
232
- if (market?.source && !samePath(market.source, paths.dir)) return { ...out, state: "foreign", refusal: `${paths.globalConfig} points marketplace ${s.marketplace_name} at ${market.source}, not ${paths.dir}` };
350
+ if (journal && !ignoreJournal)
351
+ return {
352
+ ...out,
353
+ state: "stale",
354
+ reason:
355
+ journal.phase === "recovery-required"
356
+ ? `a previous run${journal.failed_at ? ` (${journal.failed_at})` : ""} could not prove its restore: ${String(journal.error || "no error recorded").split("\n")[0]}; this run re-proves the previous state before applying this plan, and refuses if it cannot (${paths.journal})`
357
+ : "an interrupted registration has a recovery journal; the next confirmed run recovers it before applying this plan",
358
+ };
359
+ if (existsSync(paths.dir) && !ownership)
360
+ return {
361
+ ...out,
362
+ state: "foreign",
363
+ refusal: `${paths.dir} exists without ${s.ownership_manifest}; a source this installer does not own holds the stable marketplace path`,
364
+ };
365
+ if (market?.source && !samePath(market.source, paths.dir))
366
+ return {
367
+ ...out,
368
+ state: "foreign",
369
+ refusal: `${paths.globalConfig} points marketplace ${s.marketplace_name} at ${market.source}, not ${paths.dir}`,
370
+ };
233
371
  if (nothing) return out;
234
372
  let sourceDigest = null;
235
- try { if (existsSync(paths.payload)) sourceDigest = payloadDigest(paths.payload); } catch {}
373
+ try {
374
+ if (existsSync(paths.payload)) sourceDigest = payloadDigest(paths.payload);
375
+ } catch {}
236
376
  out.sourceDigest = sourceDigest;
237
- out.contentDiffers = versionOnly ? null : Boolean(ownership?.digest) && (ownership.digest.sha256 !== desiredDigest.sha256 || ownership.digest.count !== desiredDigest.count);
377
+ out.contentDiffers = versionOnly
378
+ ? null
379
+ : Boolean(ownership?.digest) &&
380
+ (ownership.digest.sha256 !== desiredDigest.sha256 || ownership.digest.count !== desiredDigest.count);
238
381
  if (!ownership || !catalog) return { ...out, state: "stale", reason: "the owned marketplace source is incomplete" };
239
- if (!versionOnly && ownership.version === desiredVersion && out.contentDiffers) return { ...out, state: "conflict", refusal: `release ${desiredVersion} already owns this marketplace with a different payload digest` };
240
- if (!sourceDigest || sourceDigest.sha256 !== ownership.digest?.sha256 || sourceDigest.count !== ownership.digest?.count) return { ...out, state: "stale", reason: "the stable source does not match its recorded digest" };
382
+ if (!versionOnly && ownership.version === desiredVersion && out.contentDiffers)
383
+ return {
384
+ ...out,
385
+ state: "conflict",
386
+ refusal: `release ${desiredVersion} already owns this marketplace with a different payload digest`,
387
+ };
388
+ if (
389
+ !sourceDigest ||
390
+ sourceDigest.sha256 !== ownership.digest?.sha256 ||
391
+ sourceDigest.count !== ownership.digest?.count
392
+ )
393
+ return { ...out, state: "stale", reason: "the stable source does not match its recorded digest" };
241
394
  if (!market) return { ...out, state: "stale", reason: "the host does not know the marketplace" };
242
- if (!installed || installed.version !== ownership.version) return { ...out, state: "stale", reason: "the host cache does not contain the registered payload version" };
243
- if (!installed.digest || installed.digest.sha256 !== ownership.digest?.sha256 || installed.digest.count !== ownership.digest?.count) return { ...out, state: "stale", reason: "the materialised host cache does not match the registered payload digest" };
395
+ if (!installed || installed.version !== ownership.version)
396
+ return { ...out, state: "stale", reason: "the host cache does not contain the registered payload version" };
397
+ if (
398
+ !installed.digest ||
399
+ installed.digest.sha256 !== ownership.digest?.sha256 ||
400
+ installed.digest.count !== ownership.digest?.count
401
+ )
402
+ return {
403
+ ...out,
404
+ state: "stale",
405
+ reason: "the materialised host cache does not match the registered payload digest",
406
+ };
244
407
  // The newer rung, after the integrity rungs: a sound registration newer
245
408
  // than this run is current and never staged over (rule 6). A damaged one
246
409
  // stayed stale above, with its real reason; the planner skips it.
247
- if (newer) return { ...out, state: "current", reason: `the registration is at ${ownership.version}, newer than this package (${desiredVersion}) — not downgraded` };
248
- if (ownership.version !== desiredVersion) return { ...out, state: "stale", reason: `installed ${ownership.version}; package offers ${desiredVersion}` };
249
- return { ...out, state: "current", reason: enabled ? null : "installed globally but disabled by effective configuration" };
410
+ if (newer)
411
+ return {
412
+ ...out,
413
+ state: "current",
414
+ reason: `the registration is at ${ownership.version}, newer than this package (${desiredVersion}) — not downgraded`,
415
+ };
416
+ if (ownership.version !== desiredVersion)
417
+ return { ...out, state: "stale", reason: `installed ${ownership.version}; package offers ${desiredVersion}` };
418
+ return {
419
+ ...out,
420
+ state: "current",
421
+ reason: enabled ? null : "installed globally but disabled by effective configuration",
422
+ };
250
423
  }
@@ -88,15 +88,18 @@ export const STALE_TEXT = Object.freeze({
88
88
 
89
89
  // Contract 5's resolution wording (Ivan Morozov's), in one place for the
90
90
  // verbs that refuse and the report that names.
91
- export const FOREIGN_TEXT = "a file we did not write sits at our path — rename it if it is yours, or delete it to let install take the name";
91
+ export const FOREIGN_TEXT =
92
+ "a file we did not write sits at our path — rename it if it is yours, or delete it to let install take the name";
92
93
 
93
94
  const normalizeEol = (s) => s.replace(/\r\n/g, "\n");
94
95
 
95
96
  function unsupportedFormat(format) {
96
97
  return new Error(
97
98
  `format "${format}" cannot carry a provenance line — a JSON surface is a ` +
98
- `SHARED surface (install spec contracts 2 and 6), owned per entry, not stamped; ` +
99
- `known stampable formats: ${Object.keys(DELIMITERS).filter((k) => DELIMITERS[k]).join(", ")}`,
99
+ `SHARED surface (install spec contracts 2 and 6), owned per entry, not stamped; ` +
100
+ `known stampable formats: ${Object.keys(DELIMITERS)
101
+ .filter((k) => DELIMITERS[k])
102
+ .join(", ")}`,
100
103
  );
101
104
  }
102
105
 
@@ -149,7 +152,8 @@ export function provenanceLine({ src, srcHash, pkg, project, render }) {
149
152
  // whitespace would be emitted, fail to parse back, derive `foreign`, and
150
153
  // make our own file immune to uninstall — refuse it here instead.
151
154
  for (const [k, v] of Object.entries({ src, pkg })) {
152
- if (/\s/.test(v)) throw new Error(`provenanceLine: field "${k}" may not contain whitespace (got ${JSON.stringify(v)})`);
155
+ if (/\s/.test(v))
156
+ throw new Error(`provenanceLine: field "${k}" may not contain whitespace (got ${JSON.stringify(v)})`);
153
157
  }
154
158
  if (!/^[0-9a-f]{12}$/.test(srcHash) || !/^[0-9a-f]{12}$/.test(render)) {
155
159
  throw new Error("provenanceLine: srcHash and render must be 12 lowercase hex characters");
@@ -198,7 +202,9 @@ function insertionOffset(body, format) {
198
202
  const m = /^---\n(?:[\s\S]*?\n)?---(?:\n|$)/.exec(body);
199
203
  if (m) return m[0].length;
200
204
  if (body.startsWith("---\n") || body === "---") {
201
- throw new Error("insertStamp: markdown body opens a frontmatter block that never closes — refusing to stamp before it");
205
+ throw new Error(
206
+ "insertStamp: markdown body opens a frontmatter block that never closes — refusing to stamp before it",
207
+ );
202
208
  }
203
209
  }
204
210
  if (format === "mjs" && body.startsWith("#!")) {
@@ -219,7 +225,9 @@ export function insertStamp(body, { format, harness, source, generator = DEFAULT
219
225
  delimitersFor(format);
220
226
  const text = normalizeEol(String(body));
221
227
  if (bareTokenRe().test(text)) {
222
- throw new Error(`insertStamp: the body already carries a bare ${PROVENANCE_TOKEN} line — it would survive into the installed file`);
228
+ throw new Error(
229
+ `insertStamp: the body already carries a bare ${PROVENANCE_TOKEN} line — it would survive into the installed file`,
230
+ );
223
231
  }
224
232
  const at = insertionOffset(text, format);
225
233
  const block = banner(format, { harness, source, generator, remedy }) + PROVENANCE_TOKEN + "\n";
@@ -250,7 +258,10 @@ export function substituteProvenance(tokenized, { format, src, srcHash, pkg, pro
250
258
  // read and be born "edited by hand" — a false accusation reinstalling cannot
251
259
  // clear. The cost: an edit confined to such a quoted line does not move
252
260
  // `render=`; strictly narrower harm than a permanent false positive.
253
- export function stamp(body, { format, src, srcHash, pkg, project, harness, generator = DEFAULT_GENERATOR, remedy = DEFAULT_REMEDY }) {
261
+ export function stamp(
262
+ body,
263
+ { format, src, srcHash, pkg, project, harness, generator = DEFAULT_GENERATOR, remedy = DEFAULT_REMEDY },
264
+ ) {
254
265
  const tokenized = insertStamp(body, { format, harness, source: src, generator, remedy });
255
266
  const render = renderHash(neutralizeProject(tokenizeProvenance(tokenized) ?? tokenized, project));
256
267
  const text = substituteProvenance(tokenized, { format, src, srcHash, pkg, project, render });
@@ -336,7 +347,8 @@ export function deriveState({ file, sourceHash: srcNow, pkg, renderNowHash, proj
336
347
  provenance,
337
348
  writtenBy: provenance ? provenance.project : null,
338
349
  sameProject: Boolean(
339
- provenance && typeof project === "string" &&
350
+ provenance &&
351
+ typeof project === "string" &&
340
352
  stripTrailingSlash(provenance.project) === stripTrailingSlash(project),
341
353
  ),
342
354
  });
@@ -348,8 +360,12 @@ export function deriveState({ file, sourceHash: srcNow, pkg, renderNowHash, proj
348
360
  const parsed = parseProvenance(file.text);
349
361
  if (!parsed) return result("foreign");
350
362
  const provenance = {
351
- v: parsed.v, src: parsed.src, srcHash: parsed.srcHash,
352
- pkg: parsed.pkg, project: parsed.project, render: parsed.render,
363
+ v: parsed.v,
364
+ src: parsed.src,
365
+ srcHash: parsed.srcHash,
366
+ pkg: parsed.pkg,
367
+ project: parsed.project,
368
+ render: parsed.render,
353
369
  };
354
370
 
355
371
  // A newer grammar than this parser knows. The spec does not say; reporting