@modootoday/pmcp 0.19.9 → 0.21.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 (128) hide show
  1. package/.agents/plugins/marketplace.json +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.mcp.json +1 -1
  5. package/dist/{apply-TM6B2Y3G.js → apply-6FLMTJDV.js} +57 -23
  6. package/dist/{attachment-D84OGI6n.d.ts → attachment-ms6s8Aow.d.ts} +1 -1
  7. package/dist/{available-HYSDAFYH.js → available-BFXLII4A.js} +7 -7
  8. package/dist/{broadcast-DSCHWUMB.js → broadcast-ZALGUJVR.js} +4 -4
  9. package/dist/chunk-2GI5RM3M.js +53 -0
  10. package/dist/{chunk-ICF2JZSN.js → chunk-2MAD4WNZ.js} +2 -2
  11. package/dist/{chunk-QYQGPDBE.js → chunk-33KGCJB2.js} +2 -2
  12. package/dist/{chunk-XNPOHPMJ.js → chunk-3X5JQYKN.js} +3 -3
  13. package/dist/{chunk-4XNAKVSO.js → chunk-57Q75MS4.js} +18 -18
  14. package/dist/{chunk-2S44RDO4.js → chunk-5FW7A6TG.js} +7 -4
  15. package/dist/chunk-5YCKFU5Q.js +1672 -0
  16. package/dist/{chunk-MCYGYZVZ.js → chunk-7FV2LORT.js} +2 -2
  17. package/dist/{chunk-57FHYW74.js → chunk-DEY23WTH.js} +122 -4
  18. package/dist/chunk-DJZPPCJP.js +274 -0
  19. package/dist/{chunk-4XWVLC23.js → chunk-G6JXCUSK.js} +2 -2
  20. package/dist/{chunk-T6GOWHK6.js → chunk-GFOQDLPL.js} +6 -1
  21. package/dist/{chunk-PG42KALG.js → chunk-GQP4GWU4.js} +5 -5
  22. package/dist/chunk-H4ZOKIER.js +7 -0
  23. package/dist/{chunk-XPWIJOZT.js → chunk-JQVSDPFL.js} +3 -3
  24. package/dist/{chunk-OG7QR2DP.js → chunk-KEHB4FZP.js} +17 -2
  25. package/dist/chunk-KUBHGVTD.js +126 -0
  26. package/dist/{chunk-SPUCY4AG.js → chunk-KVNNVLJR.js} +2 -2
  27. package/dist/chunk-LFFIQBNY.js +115 -0
  28. package/dist/{chunk-V7HG3STC.js → chunk-MR5IBS6L.js} +31 -15
  29. package/dist/{chunk-W5RLIUNC.js → chunk-NHUMPEPV.js} +2 -2
  30. package/dist/{chunk-I4DLMIN5.js → chunk-OFJIMBTL.js} +2 -2
  31. package/dist/{chunk-A6TM4NTI.js → chunk-OFPNCLG7.js} +2 -2
  32. package/dist/{chunk-3UOFHLY4.js → chunk-OS5DF3LL.js} +207 -15
  33. package/dist/{chunk-BZ2RXI5I.js → chunk-POTI2RJ6.js} +2 -2
  34. package/dist/{chunk-QTKD7JEL.js → chunk-R3MVL67T.js} +34 -34
  35. package/dist/{chunk-YN5GQCHN.js → chunk-RHJEGLYM.js} +6 -1
  36. package/dist/{chunk-YKU7KHJO.js → chunk-TBKVC2TA.js} +3 -5
  37. package/dist/{chunk-YYG3GUQW.js → chunk-UFWQTZDX.js} +29 -17
  38. package/dist/{chunk-PBDPWE5J.js → chunk-VBDDFO2V.js} +2 -2
  39. package/dist/{chunk-BRSESCGX.js → chunk-VUM6LO77.js} +4717 -4694
  40. package/dist/{chunk-FR6JHNLC.js → chunk-YLITJLTR.js} +3 -3
  41. package/dist/{chunk-CJ6OFTS3.js → chunk-YOWIYFIV.js} +6 -37
  42. package/dist/{chunk-VDBUZKXC.js → chunk-Z4Q6RYJH.js} +2 -2
  43. package/dist/{chunk-RRKGSYQ4.js → chunk-Z6WRFOFT.js} +13 -2
  44. package/dist/{chunk-YXAPCHXJ.js → chunk-ZIJ5IUXH.js} +31 -5
  45. package/dist/{claude-2C5L2HQL.js → claude-XVLF4N4S.js} +3 -3
  46. package/dist/{cli-BVRPAI23.js → cli-6FWRBCWM.js} +8 -8
  47. package/dist/{cli-YV6SFE4D.js → cli-RVPR3MH3.js} +7 -7
  48. package/dist/cli.js +11 -11
  49. package/dist/{completion-B3UT3GVI.js → completion-YTPHEVEW.js} +7 -7
  50. package/dist/{diagnostics-ONIAKCA3.js → diagnostics-IW54MLFK.js} +5 -6
  51. package/dist/{doctor-MJFU5L6R.js → doctor-EN4JPSKV.js} +35 -35
  52. package/dist/{entry-DZGKCL4G.js → entry-TQWSDTJ4.js} +14 -15
  53. package/dist/{exec-mcp-QK2VC6RX.js → exec-mcp-KKQ75N5O.js} +15 -13
  54. package/dist/{harness-GTED4GLK.js → harness-EB76F6BG.js} +6 -6
  55. package/dist/harness-launch-gate.js +3 -4
  56. package/dist/harness-worker.js +5 -6
  57. package/dist/hook-body.js +281 -98
  58. package/dist/{hook-spec-C7umArqw.d.ts → hook-spec-hZL4MSgi.d.ts} +8 -3
  59. package/dist/hooks-YWSHUNLM.js +24 -0
  60. package/dist/{host-AGNF2AQH.js → host-LSVITS6M.js} +6 -7
  61. package/dist/{host-3HTCZNVJ.js → host-OGGADMBT.js} +17 -15
  62. package/dist/{host-run-2OQZVQID.js → host-run-XO2TS4JC.js} +5 -7
  63. package/dist/http.d.ts +1 -1
  64. package/dist/http.js +1 -1
  65. package/dist/{import-mcp-7KEPR2B6.js → import-mcp-BJDJTPVS.js} +14 -11
  66. package/dist/index.d.ts +12 -3
  67. package/dist/index.js +25 -25
  68. package/dist/{init-BHGCF7JL.js → init-773PTQM5.js} +3 -3
  69. package/dist/{install-HF6CROQP.js → install-7V6NIA7W.js} +4 -4
  70. package/dist/{invoke-CVHF6PEK.js → invoke-Y7XH5S2L.js} +7 -8
  71. package/dist/{list-6XGQ3FR3.js → list-5W65XVES.js} +20 -17
  72. package/dist/{logout-6RJLG2KG.js → logout-XO6ALD45.js} +15 -12
  73. package/dist/{logs-VTW7S2LR.js → logs-74JGLQG6.js} +4 -4
  74. package/dist/mailbox/index.d.ts +3 -3
  75. package/dist/{mailbox-CNAONXN7.js → mailbox-VK5AVTHI.js} +9 -9
  76. package/dist/{mainline-JSG4MUKH.js → mainline-M2NSTAGC.js} +105 -36
  77. package/dist/{mcp-P55VLQLR.js → mcp-R62ZNVGJ.js} +2 -2
  78. package/dist/{pause-V5VCNOSH.js → pause-CZ2OZYLC.js} +4 -4
  79. package/dist/project/hook-adapter.d.ts +1 -1
  80. package/dist/{project-B57IQPDK.js → project-W5DQIZA6.js} +5 -5
  81. package/dist/{pty-FD4JGBZL.js → pty-CDLQ4NP2.js} +3 -3
  82. package/dist/report-Z3JV2PCT.js +105 -0
  83. package/dist/{resume-7S4K3R4X.js → resume-DFIHT2RO.js} +4 -4
  84. package/dist/{run-MC2BPLOE.js → run-OZLGSRHF.js} +14 -11
  85. package/dist/{run-LFJXONLW.js → run-WYJMTLX7.js} +4 -4
  86. package/dist/{serve-TFAEVXX3.js → serve-DCQGAGB7.js} +3 -3
  87. package/dist/{session-XM2CR425.js → session-YZVX4NGN.js} +4 -4
  88. package/dist/{setup-FHFQZJY6.js → setup-D3KEJBGO.js} +4 -4
  89. package/dist/smoke-FQQJOQBD.js +16 -0
  90. package/dist/{start-login-KXOHCR5A.js → start-login-EKXM75XQ.js} +15 -12
  91. package/dist/{status-YXOIEVOJ.js → status-23UDIYYP.js} +39 -22
  92. package/dist/{status-OYRB3KL5.js → status-3RTGDN2K.js} +10 -10
  93. package/dist/{status-AW7DOW7A.js → status-EDSEG32U.js} +15 -12
  94. package/dist/stdio.d.ts +2 -2
  95. package/dist/stdio.js +2 -2
  96. package/dist/{sweep-ZSYG6FNR.js → sweep-EPJMEZR6.js} +4 -4
  97. package/dist/{test-2HTOY4PJ.js → test-TM6PIZTV.js} +26 -18
  98. package/dist/{tui-DQFXYQ4H.js → tui-EQNJIDN5.js} +4 -4
  99. package/dist/{unbroadcast-FONZJWEW.js → unbroadcast-NTOC3PY3.js} +4 -4
  100. package/dist/{validate-WOFI7TMT.js → validate-KFBCUFI4.js} +2 -2
  101. package/dist/{worker-UXPGXAV2.js → worker-7X6WBPEI.js} +9 -10
  102. package/dist/{worktree-list-4PLE7K6L.js → worktree-list-EMKUMCTQ.js} +2 -2
  103. package/dist/{worktree-sync-GQVYAXGJ.js → worktree-sync-T6C5YEYS.js} +3 -3
  104. package/docs/commands.md +13 -6
  105. package/docs/git-workflow.md +46 -10
  106. package/docs/hooks.md +139 -12
  107. package/docs/project-configuration.md +34 -6
  108. package/docs/upgrading.md +94 -0
  109. package/gemini-extension.json +2 -2
  110. package/mcp.json +1 -1
  111. package/package.json +5 -5
  112. package/plugin.json +1 -1
  113. package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
  114. package/plugins/pmcp/.mcp.json +1 -1
  115. package/plugins/pmcp/gemini-extension.json +2 -2
  116. package/plugins/pmcp/mcp.json +1 -1
  117. package/plugins/pmcp/mod/reader/read.ts +14 -4
  118. package/plugins/pmcp/mod/sessions/format.ts +16 -1
  119. package/plugins/pmcp/mod/sessions/types.ts +1 -1
  120. package/plugins/pmcp/plugin.json +1 -1
  121. package/schema/catalog-v1.json +1 -7
  122. package/dist/chunk-EONAJAMJ.js +0 -130
  123. package/dist/chunk-IACJDHFQ.js +0 -1025
  124. package/dist/chunk-ISNRDHSD.js +0 -74
  125. package/dist/chunk-YGTJQVCK.js +0 -7
  126. package/dist/chunk-YLPXTJJM.js +0 -396
  127. package/dist/hooks-FRZ4SUNJ.js +0 -21
  128. package/dist/{core-C1LPjxK6.d.ts → core-Sug_rZrx.d.ts} +1 -1
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HOST_MANIFEST,
3
3
  HOST_POLICY
4
- } from "./chunk-EONAJAMJ.js";
4
+ } from "./chunk-DEY23WTH.js";
5
5
  import {
6
6
  projectStateDir
7
7
  } from "./chunk-OEH47H6A.js";
@@ -99,4 +99,4 @@ export {
99
99
  hostApprovalDoctor,
100
100
  writeApproval
101
101
  };
102
- //# sourceMappingURL=chunk-SPUCY4AG.js.map
102
+ //# sourceMappingURL=chunk-KVNNVLJR.js.map
@@ -0,0 +1,115 @@
1
+ // src/hooks/inspection/report.ts
2
+ function readReportTable(value) {
3
+ if (value === void 0) return { excludeSessions: [] };
4
+ if (value === null || typeof value !== "object" || Array.isArray(value))
5
+ throw new Error("[hooks.report] must be a table");
6
+ const table = value;
7
+ const unknown = Object.keys(table).find((key) => key !== "exclude_sessions");
8
+ if (unknown) throw new Error(`unknown [hooks.report] key ${unknown}`);
9
+ const list = table["exclude_sessions"] ?? [];
10
+ if (!Array.isArray(list) || !list.every((item) => typeof item === "string"))
11
+ throw new Error(
12
+ "[hooks.report] exclude_sessions must be a list of regexes"
13
+ );
14
+ return {
15
+ excludeSessions: list.map((source) => {
16
+ try {
17
+ return new RegExp(source, "u");
18
+ } catch {
19
+ throw new Error(
20
+ `[hooks.report] exclude_sessions has an invalid regex ${source}`
21
+ );
22
+ }
23
+ })
24
+ };
25
+ }
26
+ function guardLines(lines, settings) {
27
+ const kept = [];
28
+ let excluded = 0;
29
+ for (const line of lines) {
30
+ if (line.component !== "hooks.entry" || line["msg"] !== "policy") continue;
31
+ const data = line["data"] ?? {};
32
+ if (typeof line["policy"] !== "string" || typeof data["raw"] !== "string")
33
+ continue;
34
+ const session = String(line["session"] ?? "");
35
+ if (settings.excludeSessions.some((pattern) => pattern.test(session))) {
36
+ excluded += 1;
37
+ continue;
38
+ }
39
+ kept.push({
40
+ ts: String(line.ts ?? ""),
41
+ policy: line["policy"],
42
+ runtime: String(line["runtime"] ?? ""),
43
+ session,
44
+ mode: String(data["mode"] ?? ""),
45
+ raw: data["raw"],
46
+ verdict: String(line["verdict"] ?? "allow"),
47
+ ...typeof data["tool"] === "string" ? { tool: data["tool"] } : {},
48
+ durationMs: Number(line["duration_ms"] ?? 0)
49
+ });
50
+ }
51
+ return { kept, excluded };
52
+ }
53
+ function percentile(sorted, share) {
54
+ if (sorted.length === 0) return 0;
55
+ const index = Math.min(
56
+ sorted.length - 1,
57
+ Math.max(0, Math.ceil(share * sorted.length) - 1)
58
+ );
59
+ return sorted[index];
60
+ }
61
+ var count = (into, key) => {
62
+ into[key] = (into[key] ?? 0) + 1;
63
+ };
64
+ function report(lines, excluded) {
65
+ const groups = /* @__PURE__ */ new Map();
66
+ for (const line of lines) {
67
+ const key = `${line.policy}\0${line.runtime}`;
68
+ groups.set(key, [...groups.get(key) ?? [], line]);
69
+ }
70
+ const guards = [...groups.values()].map((group) => {
71
+ const raw = {};
72
+ const verdict = {};
73
+ for (const line of group) {
74
+ count(raw, line.raw);
75
+ count(verdict, line.verdict);
76
+ }
77
+ const durations = group.map((line) => line.durationMs).sort((a, b) => a - b);
78
+ return {
79
+ policy: group[0].policy,
80
+ runtime: group[0].runtime,
81
+ calls: group.length,
82
+ raw,
83
+ verdict,
84
+ modes: [...new Set(group.map((line) => line.mode))].sort(),
85
+ sessions: new Set(group.map((line) => line.session)).size,
86
+ durationMs: {
87
+ p50: percentile(durations, 0.5),
88
+ p95: percentile(durations, 0.95),
89
+ max: durations.at(-1) ?? 0
90
+ }
91
+ };
92
+ });
93
+ guards.sort(
94
+ (a, b) => a.policy.localeCompare(b.policy) || a.runtime.localeCompare(b.runtime)
95
+ );
96
+ return {
97
+ lines: lines.length,
98
+ sessions: new Set(lines.map((line) => line.session)).size,
99
+ excluded,
100
+ guards
101
+ };
102
+ }
103
+ function wouldRefuse(lines, policy) {
104
+ return lines.filter(
105
+ (line) => line.policy === policy && line.raw !== "allow" && line.verdict !== "deny" && line.verdict !== line.raw
106
+ );
107
+ }
108
+
109
+ export {
110
+ readReportTable,
111
+ guardLines,
112
+ report,
113
+ wouldRefuse
114
+ };
115
+ //# sourceMappingURL=chunk-LFFIQBNY.js.map
@@ -7,8 +7,9 @@ import {
7
7
  asPause,
8
8
  asRecord,
9
9
  isLive,
10
+ latestRecord,
10
11
  leaseFile
11
- } from "./chunk-RRKGSYQ4.js";
12
+ } from "./chunk-Z6WRFOFT.js";
12
13
  import {
13
14
  expandPath,
14
15
  projectStateDir
@@ -46,8 +47,8 @@ function matches(selector, recipient) {
46
47
  return !!recipient.session && recipient.session.startsWith(value);
47
48
  if (kind === "alias") return recipient.alias === value;
48
49
  if (kind === "role") return (recipient.roles ?? []).includes(value);
49
- if (!isWorktree(kind) || !recipient.desk) return false;
50
- return recipient.desk === value || basename(recipient.desk) === value;
50
+ if (!isWorktree(kind) || !recipient.worktree) return false;
51
+ return recipient.worktree === value || basename(recipient.worktree) === value;
51
52
  }
52
53
  function before(message, recipient) {
53
54
  if (!recipient.since) return false;
@@ -413,20 +414,35 @@ import { readdirSync as readdirSync2, rmSync as rmSync5 } from "fs";
413
414
  import { join as join5 } from "path";
414
415
  var SESSION_ID = /^[A-Za-z0-9_-]{8,64}$/u;
415
416
  function filesRegistry(dir, staleMs) {
416
- const fleetDir = join5(dir, STATE_FILES.records);
417
- const pathOf = (session) => join5(fleetDir, `${session}.json`);
418
- const get = (session) => SESSION_ID.test(session) ? asRecord(readJson(pathOf(session))) : null;
417
+ const records = join5(dir, STATE_FILES.records);
418
+ const dirs = [records, join5(dir, STATE_FILES.legacyRecords)];
419
+ const pathsOf = (session) => dirs.map((records2) => join5(records2, `${session}.json`));
420
+ const get = (session) => {
421
+ if (!SESSION_ID.test(session)) return null;
422
+ return latestRecord(
423
+ pathsOf(session).map((path) => asRecord(readJson(path)))
424
+ );
425
+ };
419
426
  const list = (now = Date.now()) => {
420
- let names = [];
421
- try {
422
- names = readdirSync2(fleetDir).filter((name) => name.endsWith(".json"));
423
- } catch {
424
- return [];
427
+ const found = /* @__PURE__ */ new Map();
428
+ for (const folder of dirs) {
429
+ let names = [];
430
+ try {
431
+ names = readdirSync2(folder).filter((name) => name.endsWith(".json"));
432
+ } catch {
433
+ continue;
434
+ }
435
+ for (const name of names)
436
+ found.set(name, [
437
+ ...found.get(name) ?? [],
438
+ asRecord(readJson(join5(folder, name)))
439
+ ]);
425
440
  }
426
- return names.map((name) => asRecord(readJson(join5(fleetDir, name)))).filter((record2) => record2 !== null).map((record2) => ({ ...record2, live: isLive(record2, now, staleMs) }));
441
+ return [...found.values()].map(latestRecord).filter((record2) => record2 !== null).map((record2) => ({ ...record2, live: isLive(record2, now, staleMs) }));
427
442
  };
428
443
  const remove = (session) => {
429
- if (SESSION_ID.test(session)) rmSync5(pathOf(session), { force: true });
444
+ if (!SESSION_ID.test(session)) return;
445
+ for (const path of pathsOf(session)) rmSync5(path, { force: true });
430
446
  };
431
447
  return {
432
448
  get,
@@ -446,7 +462,7 @@ function filesRegistry(dir, staleMs) {
446
462
  next["worktree"] = checkout?.root ?? "";
447
463
  next["branch"] = checkout?.branch ?? "";
448
464
  }
449
- writeJson(pathOf(session), next);
465
+ writeJson(join5(records, `${session}.json`), next);
450
466
  return next;
451
467
  },
452
468
  sweep(now = Date.now()) {
@@ -681,4 +697,4 @@ export {
681
697
  readStoreSettings,
682
698
  openStore
683
699
  };
684
- //# sourceMappingURL=chunk-V7HG3STC.js.map
700
+ //# sourceMappingURL=chunk-MR5IBS6L.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  alive
3
- } from "./chunk-RRKGSYQ4.js";
3
+ } from "./chunk-Z6WRFOFT.js";
4
4
 
5
5
  // src/sessions/wake/claude-socket.ts
6
6
  import { existsSync, readdirSync, readFileSync } from "fs";
@@ -27,4 +27,4 @@ function claudeSocket(session, home) {
27
27
  export {
28
28
  claudeSocket
29
29
  };
30
- //# sourceMappingURL=chunk-W5RLIUNC.js.map
30
+ //# sourceMappingURL=chunk-NHUMPEPV.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ancestors
3
- } from "./chunk-RRKGSYQ4.js";
3
+ } from "./chunk-Z6WRFOFT.js";
4
4
 
5
5
  // src/sessions/wake/pty-ref.ts
6
6
  import { existsSync } from "fs";
@@ -29,4 +29,4 @@ export {
29
29
  ptyRef,
30
30
  ptyReachable
31
31
  };
32
- //# sourceMappingURL=chunk-I4DLMIN5.js.map
32
+ //# sourceMappingURL=chunk-OFJIMBTL.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-RPCIROW7.js";
4
4
  import {
5
5
  readSpec
6
- } from "./chunk-BRSESCGX.js";
6
+ } from "./chunk-VUM6LO77.js";
7
7
  import {
8
8
  ArgumentError
9
9
  } from "./chunk-A4PKLESO.js";
@@ -25,4 +25,4 @@ function serverFrom(context) {
25
25
  export {
26
26
  serverFrom
27
27
  };
28
- //# sourceMappingURL=chunk-A6TM4NTI.js.map
28
+ //# sourceMappingURL=chunk-OFPNCLG7.js.map
@@ -2,17 +2,16 @@ import {
2
2
  backupFiles
3
3
  } from "./chunk-P4N7DBD5.js";
4
4
  import {
5
- BUNDLE_NATIVE_FILES,
6
- HOOK_DIRECTORY,
7
5
  checkProject,
6
+ guardVersionProblems,
8
7
  prepare,
9
8
  present,
10
9
  writeNative
11
- } from "./chunk-IACJDHFQ.js";
12
- import {
13
- ANTIGRAVITY_MCP_PLUGIN
14
- } from "./chunk-YLPXTJJM.js";
10
+ } from "./chunk-DJZPPCJP.js";
15
11
  import {
12
+ ANTIGRAVITY_MCP_PLUGIN,
13
+ BUNDLE_NATIVE_FILES,
14
+ HOOK_DIRECTORY as HOOK_DIRECTORY2,
16
15
  changedSincePlan,
17
16
  exists,
18
17
  getKey,
@@ -22,17 +21,20 @@ import {
22
21
  same,
23
22
  splitKeyed,
24
23
  withoutBlock
25
- } from "./chunk-BRSESCGX.js";
24
+ } from "./chunk-VUM6LO77.js";
26
25
  import {
27
26
  RULES_DIR,
28
27
  legacyLinks
29
28
  } from "./chunk-NRBQK6UX.js";
29
+ import {
30
+ HOOK_DIRECTORY
31
+ } from "./chunk-5YCKFU5Q.js";
30
32
  import {
31
33
  LOCK_FILE,
32
34
  replaceFile,
33
35
  replaceLink,
34
36
  writeLock
35
- } from "./chunk-57FHYW74.js";
37
+ } from "./chunk-DEY23WTH.js";
36
38
 
37
39
  // src/project/apply/files.ts
38
40
  import { mkdirSync } from "fs";
@@ -162,13 +164,13 @@ function backupBeforeWrite(spec, outputs, stale) {
162
164
  ".agents/hooks.json"
163
165
  ]),
164
166
  ...outputs.filter(
165
- (output) => output.kind === "file" && output.path.startsWith(`${HOOK_DIRECTORY}/`)
167
+ (output) => output.kind === "file" && output.path.startsWith(`${HOOK_DIRECTORY2}/`)
166
168
  ).map((output) => output.path),
167
- ...stale.filter((entry) => entry.path.startsWith(`${HOOK_DIRECTORY}/`)).map((entry) => entry.path)
169
+ ...stale.filter((entry) => entry.path.startsWith(`${HOOK_DIRECTORY2}/`)).map((entry) => entry.path)
168
170
  ];
169
171
  const changedHooks = outputs.some(
170
- (output) => (output.kind === "json" && output.managed !== void 0 || output.kind === "file" && output.path.startsWith(`${HOOK_DIRECTORY}/`)) && !present(spec.root, output)
171
- ) || stale.some((entry) => entry.path.startsWith(`${HOOK_DIRECTORY}/`));
172
+ (output) => (output.kind === "json" && output.managed !== void 0 || output.kind === "file" && output.path.startsWith(`${HOOK_DIRECTORY2}/`)) && !present(spec.root, output)
173
+ ) || stale.some((entry) => entry.path.startsWith(`${HOOK_DIRECTORY2}/`));
172
174
  if (!changedMcp && !staleMcp && !changedHooks) return void 0;
173
175
  return backupFiles(spec.root, [
174
176
  ...MCP_PATHS,
@@ -187,7 +189,8 @@ function project(spec, options) {
187
189
  }
188
190
  const conflicts = [
189
191
  ...permissionConflicts(spec),
190
- ...changedSincePlan(spec.root, basis)
192
+ ...changedSincePlan(spec.root, basis),
193
+ ...guardVersionProblems(spec)
191
194
  ];
192
195
  if (conflicts.length > 0) {
193
196
  return { code: 3, problems: conflicts, outputs: outputs.length, pruned: 0 };
@@ -205,7 +208,196 @@ function project(spec, options) {
205
208
  };
206
209
  }
207
210
 
211
+ // src/project/unmanaged-hooks.ts
212
+ import { spawnSync } from "child_process";
213
+ import {
214
+ accessSync,
215
+ constants,
216
+ existsSync as existsSync3,
217
+ readFileSync as readFileSync2,
218
+ statSync
219
+ } from "fs";
220
+ import { dirname as dirname2, isAbsolute, join as join4, relative, resolve } from "path";
221
+ var SETTINGS = [
222
+ ".claude/settings.json",
223
+ ".claude/settings.local.json",
224
+ ".codex/hooks.json"
225
+ ];
226
+ var INTERPRETERS = /* @__PURE__ */ new Set([
227
+ "node",
228
+ "bun",
229
+ "deno",
230
+ "tsx",
231
+ "python",
232
+ "python3",
233
+ "bash",
234
+ "sh",
235
+ "zsh",
236
+ "dash",
237
+ "ruby",
238
+ "perl"
239
+ ]);
240
+ function commands(value) {
241
+ const hooks = value?.["hooks"];
242
+ if (!hooks || typeof hooks !== "object" || Array.isArray(hooks)) return [];
243
+ const found = [];
244
+ for (const [event, groups] of Object.entries(hooks)) {
245
+ if (!Array.isArray(groups)) continue;
246
+ for (const group of groups) {
247
+ const entries = group?.["hooks"];
248
+ if (!Array.isArray(entries)) continue;
249
+ for (const entry of entries) {
250
+ const command = entry?.["command"];
251
+ if (typeof command === "string") found.push({ event, command });
252
+ }
253
+ }
254
+ }
255
+ return found;
256
+ }
257
+ function firstWords(command) {
258
+ const words = [];
259
+ let word = "";
260
+ let quote = null;
261
+ let started = false;
262
+ for (const char of command) {
263
+ if (quote) {
264
+ if (char === quote) quote = null;
265
+ else word += char;
266
+ continue;
267
+ }
268
+ if (char === "'" || char === '"') {
269
+ quote = char;
270
+ started = true;
271
+ continue;
272
+ }
273
+ if (/\s/u.test(char)) {
274
+ if (started) words.push(word);
275
+ word = "";
276
+ started = false;
277
+ continue;
278
+ }
279
+ if (";|&<>()".includes(char)) break;
280
+ word += char;
281
+ started = true;
282
+ }
283
+ if (started) words.push(word);
284
+ return words;
285
+ }
286
+ function expand(word, vars) {
287
+ let unknown = null;
288
+ const path = word.replace(/^~(?=\/|$)/u, vars["HOME"] ?? "~").replace(/\$\{(\w+)\}|\$(\w+)/gu, (_, braced, bare) => {
289
+ const name = braced ?? bare;
290
+ const value = vars[name];
291
+ if (value === void 0) unknown ??= name;
292
+ return value ?? "";
293
+ });
294
+ if (unknown === "CLAUDE_PLUGIN_ROOT")
295
+ return { problem: "${CLAUDE_PLUGIN_ROOT} outside a plugin" };
296
+ if (unknown !== null) return { skip: true };
297
+ return { path };
298
+ }
299
+ function scriptProblem(path, direct) {
300
+ if (!existsSync3(path)) return "the script does not exist";
301
+ if (!statSync(path).isFile()) return "the script is not a file";
302
+ if (!direct) return null;
303
+ try {
304
+ accessSync(path, constants.X_OK);
305
+ } catch {
306
+ return "the script is not executable";
307
+ }
308
+ const head = readFileSync2(path).subarray(0, 2).toString("latin1");
309
+ if (head !== "#!") return "the script has no shebang";
310
+ return null;
311
+ }
312
+ function commandProblem(command, cwd, vars) {
313
+ const words = firstWords(command).filter(
314
+ (word, index, all) => !(/^\w+=/u.test(word) && all.slice(0, index).every((w) => /^\w+=/u.test(w)))
315
+ );
316
+ const program = words[0];
317
+ if (program === void 0) return "the command is empty";
318
+ const base = program.slice(program.lastIndexOf("/") + 1);
319
+ let target = program;
320
+ let direct = true;
321
+ if (INTERPRETERS.has(base)) {
322
+ const script = words.slice(1).find((word) => !word.startsWith("-"));
323
+ if (script === void 0 || words.slice(1).some((w) => /^-[ec]$/u.test(w)))
324
+ return null;
325
+ target = script;
326
+ direct = false;
327
+ }
328
+ if (!target.includes("/") && !target.includes("$")) return null;
329
+ const expanded = expand(target, vars);
330
+ if ("skip" in expanded) return null;
331
+ if ("problem" in expanded) return expanded.problem;
332
+ const path = isAbsolute(expanded.path) ? expanded.path : resolve(cwd, expanded.path);
333
+ return scriptProblem(path, direct);
334
+ }
335
+ function readHooksFile(path) {
336
+ try {
337
+ return JSON.parse(readFileSync2(path, "utf8"));
338
+ } catch {
339
+ return null;
340
+ }
341
+ }
342
+ function pluginHookFiles(root) {
343
+ const listed = spawnSync(
344
+ "git",
345
+ ["ls-files", "-z", "--", ":(glob)**/.claude-plugin/plugin.json"],
346
+ { cwd: root, encoding: "utf8" }
347
+ );
348
+ if (listed.status !== 0) return [];
349
+ const found = [];
350
+ for (const manifest of listed.stdout.split("\0").filter(Boolean)) {
351
+ const plugin = dirname2(dirname2(join4(root, manifest)));
352
+ const declared = readHooksFile(join4(root, manifest))?.["hooks"];
353
+ const file = resolve(
354
+ plugin,
355
+ typeof declared === "string" ? declared : "hooks/hooks.json"
356
+ );
357
+ if (existsSync3(file)) found.push({ file, plugin });
358
+ }
359
+ return found;
360
+ }
361
+ function unmanagedHookProblems(root, env = process.env) {
362
+ return unmanagedHooks(root, env).problems;
363
+ }
364
+ function unmanagedHooks(root, env = process.env) {
365
+ let checked = 0;
366
+ const sources = [
367
+ ...SETTINGS.map((file) => ({ file: join4(root, file), plugin: void 0 })),
368
+ ...pluginHookFiles(root)
369
+ ];
370
+ const problems = [];
371
+ for (const source of sources) {
372
+ if (!existsSync3(source.file)) continue;
373
+ const vars = {
374
+ ...env,
375
+ CLAUDE_PROJECT_DIR: root,
376
+ CLAUDE_PLUGIN_ROOT: source.plugin
377
+ };
378
+ for (const { event, command } of commands(readHooksFile(source.file))) {
379
+ if (command.includes(`${HOOK_DIRECTORY}/`)) continue;
380
+ checked += 1;
381
+ const problem = commandProblem(command, root, vars);
382
+ if (problem)
383
+ problems.push({
384
+ file: relative(root, source.file),
385
+ event,
386
+ command,
387
+ problem
388
+ });
389
+ }
390
+ }
391
+ return { checked, problems };
392
+ }
393
+ function describeHookProblem(problem) {
394
+ return `${problem.file} ${problem.event}: ${problem.command}: ${problem.problem}`;
395
+ }
396
+
208
397
  export {
209
- project
398
+ project,
399
+ unmanagedHookProblems,
400
+ unmanagedHooks,
401
+ describeHookProblem
210
402
  };
211
- //# sourceMappingURL=chunk-3UOFHLY4.js.map
403
+ //# sourceMappingURL=chunk-OS5DF3LL.js.map
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-34DECPVC.js";
7
7
  import {
8
8
  ptyBinary
9
- } from "./chunk-EONAJAMJ.js";
9
+ } from "./chunk-DEY23WTH.js";
10
10
 
11
11
  // src/harness/adapters/systemd/admission.ts
12
12
  var nativeHostTools = ["systemctl", "systemd-run"];
@@ -36,4 +36,4 @@ export {
36
36
  nativeHostTools,
37
37
  assertNativeHost
38
38
  };
39
- //# sourceMappingURL=chunk-BZ2RXI5I.js.map
39
+ //# sourceMappingURL=chunk-POTI2RJ6.js.map