@modootoday/pmcp 0.19.8 → 0.19.9

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 (127) 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-6OEABVQT.js → apply-TM6B2Y3G.js} +17 -17
  6. package/dist/{available-GFMTJW4E.js → available-HYSDAFYH.js} +4 -4
  7. package/dist/{broadcast-56NPEJWM.js → broadcast-DSCHWUMB.js} +5 -5
  8. package/dist/{chunk-SRX2ONSZ.js → chunk-2S44RDO4.js} +2 -2
  9. package/dist/{chunk-GXACIGVS.js → chunk-3UOFHLY4.js} +5 -5
  10. package/dist/{chunk-UGODVKBJ.js → chunk-4XNAKVSO.js} +2 -2
  11. package/dist/{chunk-LJL4L73I.js → chunk-4XWVLC23.js} +3 -3
  12. package/dist/{chunk-42RFOVU3.js → chunk-57FHYW74.js} +17 -5
  13. package/dist/{chunk-VHTRCE5G.js → chunk-A6TM4NTI.js} +3 -3
  14. package/dist/{chunk-3CYQWRGM.js → chunk-BRSESCGX.js} +344 -80
  15. package/dist/{chunk-TLIOBOZ2.js → chunk-BZ2RXI5I.js} +2 -2
  16. package/dist/{chunk-J5ZS7GLA.js → chunk-C3G75JH7.js} +2 -2
  17. package/dist/{chunk-HEWZ6INU.js → chunk-CJ6OFTS3.js} +22 -5
  18. package/dist/{chunk-CVZEVTTX.js → chunk-EONAJAMJ.js} +3 -3
  19. package/dist/{chunk-PTDMSVKS.js → chunk-FR6JHNLC.js} +3 -3
  20. package/dist/{chunk-QPL7E2HW.js → chunk-GJXOFDJT.js} +9 -2
  21. package/dist/{chunk-3PW4FI7U.js → chunk-I4DLMIN5.js} +2 -2
  22. package/dist/{chunk-JZK7ZO7K.js → chunk-I4U2A6HP.js} +2 -2
  23. package/dist/{chunk-6U623E6Y.js → chunk-IACJDHFQ.js} +6 -6
  24. package/dist/{chunk-NWOV2E26.js → chunk-JZKAJUVT.js} +2 -2
  25. package/dist/{chunk-E4FJOLPJ.js → chunk-MCYGYZVZ.js} +3 -3
  26. package/dist/{chunk-QXDD75DY.js → chunk-PBDPWE5J.js} +3 -3
  27. package/dist/{chunk-HEBCQTOD.js → chunk-PEMMV5YQ.js} +2 -2
  28. package/dist/{chunk-SHZPE6FD.js → chunk-PG42KALG.js} +5 -5
  29. package/dist/{chunk-7B6IC3F7.js → chunk-PUIWESU3.js} +3 -3
  30. package/dist/{chunk-ZYSALKKW.js → chunk-QTKD7JEL.js} +21 -21
  31. package/dist/{chunk-CTA7255D.js → chunk-QYQGPDBE.js} +2 -2
  32. package/dist/{chunk-7DLZC73N.js → chunk-RPCIROW7.js} +2 -2
  33. package/dist/{chunk-C4NHQGHL.js → chunk-RRKGSYQ4.js} +1 -1
  34. package/dist/{chunk-TFZLX66B.js → chunk-SPUCY4AG.js} +2 -2
  35. package/dist/{chunk-DHAPQUEF.js → chunk-V7HG3STC.js} +2 -2
  36. package/dist/{chunk-6QM5OWGZ.js → chunk-VDBUZKXC.js} +2 -2
  37. package/dist/{chunk-XP2U3LO3.js → chunk-W5RLIUNC.js} +2 -2
  38. package/dist/{chunk-RXKX33WU.js → chunk-XNPOHPMJ.js} +3 -3
  39. package/dist/{chunk-XLXDXJY2.js → chunk-XPWIJOZT.js} +5 -5
  40. package/dist/chunk-YGTJQVCK.js +7 -0
  41. package/dist/{chunk-44YE6B63.js → chunk-YKU7KHJO.js} +3 -3
  42. package/dist/{chunk-P4424VLT.js → chunk-YLPXTJJM.js} +2 -2
  43. package/dist/{chunk-7B2KRL2H.js → chunk-YXAPCHXJ.js} +52 -5
  44. package/dist/{chunk-VUSA7POL.js → chunk-YYG3GUQW.js} +9 -9
  45. package/dist/{claude-U2JC2DNQ.js → claude-2C5L2HQL.js} +3 -3
  46. package/dist/{cli-BTPTJWCC.js → cli-BVRPAI23.js} +8 -8
  47. package/dist/{cli-UFCFDIVI.js → cli-YV6SFE4D.js} +5 -5
  48. package/dist/cli.js +3 -3
  49. package/dist/{completion-UI4IOYXY.js → completion-B3UT3GVI.js} +2 -2
  50. package/dist/{config-DnpLL2kT.d.ts → config-DzHB75Jz.d.ts} +2 -0
  51. package/dist/{diagnostics-QSQDE2KO.js → diagnostics-ONIAKCA3.js} +7 -7
  52. package/dist/{doctor-EOBNGAAB.js → doctor-MJFU5L6R.js} +20 -20
  53. package/dist/{entry-HBROO3YP.js → entry-DZGKCL4G.js} +12 -12
  54. package/dist/{exec-mcp-DZU2DEPD.js → exec-mcp-QK2VC6RX.js} +13 -13
  55. package/dist/{harness-H4OKGO6F.js → harness-GTED4GLK.js} +3 -3
  56. package/dist/harness-launch-gate.js +5 -5
  57. package/dist/harness-worker.js +7 -7
  58. package/dist/hook-body.js +319 -61
  59. package/dist/{hooks-T5JAK3VQ.js → hooks-FRZ4SUNJ.js} +3 -3
  60. package/dist/{host-IRPBT5AL.js → host-3HTCZNVJ.js} +16 -16
  61. package/dist/{host-5JOCZURV.js → host-AGNF2AQH.js} +8 -8
  62. package/dist/{host-run-KPH5ZNYU.js → host-run-2OQZVQID.js} +21 -13
  63. package/dist/http.js +1 -1
  64. package/dist/{import-mcp-24QRNZBJ.js → import-mcp-7KEPR2B6.js} +11 -11
  65. package/dist/index.d.ts +5 -3
  66. package/dist/index.js +19 -19
  67. package/dist/{init-EPIJY23S.js → init-BHGCF7JL.js} +2 -2
  68. package/dist/{install-MQ7QSJQ7.js → install-HF6CROQP.js} +19 -9
  69. package/dist/{invoke-2SXY6G3P.js → invoke-CVHF6PEK.js} +9 -9
  70. package/dist/{list-C3WEYY3N.js → list-6XGQ3FR3.js} +13 -13
  71. package/dist/{list-FB6RNYYB.js → list-WK2IYUK7.js} +4 -4
  72. package/dist/{logout-J4SFSWMA.js → logout-6RJLG2KG.js} +12 -12
  73. package/dist/{logs-H3RPKNTE.js → logs-VTW7S2LR.js} +6 -6
  74. package/dist/mailbox/index.d.ts +1 -1
  75. package/dist/mailbox/index.js +3 -3
  76. package/dist/{mailbox-UECKDZ3Q.js → mailbox-CNAONXN7.js} +8 -8
  77. package/dist/{mailbox-5DWLH4W2.js → mailbox-YN6PG66A.js} +4 -4
  78. package/dist/{mainline-FPK4HWFF.js → mainline-JSG4MUKH.js} +11 -12
  79. package/dist/{mcp-W6OADCKB.js → mcp-P55VLQLR.js} +2 -2
  80. package/dist/{pause-2HQ7CKMR.js → pause-V5VCNOSH.js} +5 -5
  81. package/dist/{project-TZAYGUHM.js → project-B57IQPDK.js} +4 -4
  82. package/dist/{pty-XTJ4MIWK.js → pty-FD4JGBZL.js} +3 -3
  83. package/dist/{recovery-54KHNJX4.js → recovery-HB2YFQSQ.js} +3 -3
  84. package/dist/{reindex-ZULHSQWY.js → reindex-I7RYWCUR.js} +5 -5
  85. package/dist/{resume-ETFTR5V3.js → resume-7S4K3R4X.js} +5 -5
  86. package/dist/{run-XZ75CAFL.js → run-LFJXONLW.js} +4 -4
  87. package/dist/{run-QQB74HRI.js → run-MC2BPLOE.js} +14 -14
  88. package/dist/{serve-TILM4DH5.js → serve-TFAEVXX3.js} +9 -9
  89. package/dist/{setup-63E3TVJK.js → setup-FHFQZJY6.js} +5 -6
  90. package/dist/{start-login-C2BWQNO5.js → start-login-KXOHCR5A.js} +12 -12
  91. package/dist/{status-3AU65SCN.js → status-AW7DOW7A.js} +12 -12
  92. package/dist/{status-CM753VKY.js → status-OYRB3KL5.js} +8 -8
  93. package/dist/{status-JMXH6XG4.js → status-YXOIEVOJ.js} +23 -23
  94. package/dist/stdio.js +5 -5
  95. package/dist/{sweep-VY2TNOO5.js → sweep-ZSYG6FNR.js} +5 -5
  96. package/dist/{test-MCM44GOL.js → test-2HTOY4PJ.js} +13 -13
  97. package/dist/{tui-BL4OSDW4.js → tui-DQFXYQ4H.js} +6 -6
  98. package/dist/{unbroadcast-RKTBP57G.js → unbroadcast-FONZJWEW.js} +5 -5
  99. package/dist/{validate-AVM2VHMM.js → validate-WOFI7TMT.js} +5 -5
  100. package/dist/{worker-GHQKC5XU.js → worker-UXPGXAV2.js} +10 -10
  101. package/dist/{worktree-list-NEIDD66X.js → worktree-list-4PLE7K6L.js} +4 -4
  102. package/docs/git-workflow.md +26 -7
  103. package/docs/hooks.md +22 -12
  104. package/docs/project-configuration.md +19 -12
  105. package/gemini-extension.json +2 -2
  106. package/mcp.json +1 -1
  107. package/package.json +5 -5
  108. package/plugin.json +1 -1
  109. package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
  110. package/plugins/pmcp/.mcp.json +1 -1
  111. package/plugins/pmcp/gemini-extension.json +2 -2
  112. package/plugins/pmcp/mcp.json +1 -1
  113. package/plugins/pmcp/mod/draw.tsx +9 -2
  114. package/plugins/pmcp/mod/guard.ts +3 -3
  115. package/plugins/pmcp/mod/model.ts +15 -4
  116. package/plugins/pmcp/mod/reader/read.ts +19 -4
  117. package/plugins/pmcp/mod/reader/settings.ts +7 -0
  118. package/plugins/pmcp/mod/reader/types.ts +2 -0
  119. package/plugins/pmcp/mod/sessions/format.ts +9 -1
  120. package/plugins/pmcp/plugin.json +1 -1
  121. package/schema/catalog-v1.json +3 -8
  122. package/schema/library.json +3 -8
  123. package/schema/marketplace-manifest.json +2 -6
  124. package/schema/skill-frontmatter.json +3 -8
  125. package/schema/skill-metadata-core.json +3 -8
  126. package/dist/chunk-DXJZ2ZCX.js +0 -56
  127. package/dist/chunk-QHH3TXOA.js +0 -7
@@ -1,12 +1,6 @@
1
1
  import {
2
2
  readLoggingTable
3
3
  } from "./chunk-HQOB7OQS.js";
4
- import {
5
- readGitConfig
6
- } from "./chunk-7B2KRL2H.js";
7
- import {
8
- detect
9
- } from "./chunk-2Q6MNGU5.js";
10
4
  import {
11
5
  syncWorktree
12
6
  } from "./chunk-ICF2JZSN.js";
@@ -21,20 +15,26 @@ import {
21
15
  import {
22
16
  ptyFields,
23
17
  ptyRef
24
- } from "./chunk-3PW4FI7U.js";
18
+ } from "./chunk-I4DLMIN5.js";
19
+ import {
20
+ withUmask
21
+ } from "./chunk-P6LNYYYH.js";
22
+ import {
23
+ leaseSpecs,
24
+ readGitConfig
25
+ } from "./chunk-YXAPCHXJ.js";
26
+ import {
27
+ detect
28
+ } from "./chunk-2Q6MNGU5.js";
25
29
  import {
26
30
  inboxKey,
27
31
  noticeOf,
28
32
  readStoreSettings
29
- } from "./chunk-DHAPQUEF.js";
33
+ } from "./chunk-V7HG3STC.js";
30
34
  import {
31
35
  STATE_FILES,
32
- leaseFile,
33
36
  runtimePid
34
- } from "./chunk-C4NHQGHL.js";
35
- import {
36
- withUmask
37
- } from "./chunk-P6LNYYYH.js";
37
+ } from "./chunk-RRKGSYQ4.js";
38
38
  import {
39
39
  gitText
40
40
  } from "./chunk-G7JONWL4.js";
@@ -48,7 +48,7 @@ import {
48
48
  packagedBinary,
49
49
  readHost,
50
50
  readLock
51
- } from "./chunk-42RFOVU3.js";
51
+ } from "./chunk-57FHYW74.js";
52
52
  import {
53
53
  checkoutOf,
54
54
  hasLinkedWorktrees
@@ -56,7 +56,7 @@ import {
56
56
  import {
57
57
  ConfigError,
58
58
  readMarketplaces
59
- } from "./chunk-QPL7E2HW.js";
59
+ } from "./chunk-GJXOFDJT.js";
60
60
  import {
61
61
  envNames
62
62
  } from "./chunk-J6KL3COD.js";
@@ -129,14 +129,14 @@ function silent(event) {
129
129
  }
130
130
  function render(input, decision) {
131
131
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
132
- const reason = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON);
132
+ const reason2 = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON);
133
133
  if (input.event === "before_tool") {
134
- const out2 = blocking ? { decision: "deny", reason } : { decision: "allow" };
134
+ const out2 = blocking ? { decision: "deny", reason: reason2 } : { decision: "allow" };
135
135
  return { stdout: `${JSON.stringify(out2)}
136
136
  `, exitCode: 0 };
137
137
  }
138
138
  const notes = [...decision.context ?? []];
139
- if (blocking) notes.unshift(reason);
139
+ if (blocking) notes.unshift(reason2);
140
140
  if (decision.feedback) notes.push(decision.feedback);
141
141
  let out = {};
142
142
  if (notes.length > 0 && input.event !== "after_tool") {
@@ -330,19 +330,19 @@ var MAX_REASON2 = 2e3;
330
330
  function render2(input, decision) {
331
331
  const hookEventName = NATIVE_EVENTS2[input.event];
332
332
  const context = decision.context?.length ? decision.context.join("\n\n") : void 0;
333
- const reason = decision.reason?.slice(0, MAX_REASON2);
333
+ const reason2 = decision.reason?.slice(0, MAX_REASON2);
334
334
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
335
335
  const out = shape(input, decision, {
336
336
  hookEventName,
337
337
  context,
338
- reason,
338
+ reason: reason2,
339
339
  blocking
340
340
  });
341
341
  return { stdout: out ? `${JSON.stringify(out)}
342
342
  ` : "", exitCode: 0 };
343
343
  }
344
344
  function shape(input, decision, parts) {
345
- const { hookEventName, context, reason, blocking } = parts;
345
+ const { hookEventName, context, reason: reason2, blocking } = parts;
346
346
  const contextOnly = context ? { hookSpecificOutput: { hookEventName, additionalContext: context } } : {};
347
347
  if (input.event === "before_tool") {
348
348
  if (!blocking && !context) return null;
@@ -350,7 +350,7 @@ function shape(input, decision, parts) {
350
350
  if (blocking) {
351
351
  refusal = {
352
352
  permissionDecision: decision.verdict,
353
- ...reason ? { permissionDecisionReason: reason } : {}
353
+ ...reason2 ? { permissionDecisionReason: reason2 } : {}
354
354
  };
355
355
  }
356
356
  return {
@@ -362,7 +362,7 @@ function shape(input, decision, parts) {
362
362
  };
363
363
  }
364
364
  if (input.event === "prompt" || input.event === "after_tool" || input.event === "stop") {
365
- const feedback = blocking ? reason ?? "Refused" : decision.feedback;
365
+ const feedback = blocking ? reason2 ?? "Refused" : decision.feedback;
366
366
  if (!feedback && !context) return null;
367
367
  return {
368
368
  ...feedback ? { decision: "block", reason: feedback } : {},
@@ -580,12 +580,12 @@ var MAX_REASON3 = 2e3;
580
580
  function render3(input, decision) {
581
581
  const hookEventName = NATIVE_EVENTS3[input.event];
582
582
  const context = decision.context?.length ? decision.context.join("\n\n") : void 0;
583
- const reason = decision.reason?.slice(0, MAX_REASON3);
583
+ const reason2 = decision.reason?.slice(0, MAX_REASON3);
584
584
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
585
585
  const out = shape2(input, decision, {
586
586
  hookEventName,
587
587
  context,
588
- reason,
588
+ reason: reason2,
589
589
  blocking
590
590
  });
591
591
  if (!out && input.event === "stop") return { stdout: "{}\n", exitCode: 0 };
@@ -593,7 +593,7 @@ function render3(input, decision) {
593
593
  ` : "", exitCode: 0 };
594
594
  }
595
595
  function shape2(input, decision, parts) {
596
- const { hookEventName, context, reason, blocking } = parts;
596
+ const { hookEventName, context, reason: reason2, blocking } = parts;
597
597
  const contextOnly = context ? { hookSpecificOutput: { hookEventName, additionalContext: context } } : {};
598
598
  if (input.event === "before_tool") {
599
599
  if (!blocking && !context) return null;
@@ -601,7 +601,7 @@ function shape2(input, decision, parts) {
601
601
  if (blocking) {
602
602
  refusal = {
603
603
  permissionDecision: "deny",
604
- ...reason ? { permissionDecisionReason: reason } : {}
604
+ ...reason2 ? { permissionDecisionReason: reason2 } : {}
605
605
  };
606
606
  }
607
607
  return {
@@ -613,7 +613,7 @@ function shape2(input, decision, parts) {
613
613
  };
614
614
  }
615
615
  if (input.event === "prompt" || input.event === "after_tool" || input.event === "stop") {
616
- const feedback = blocking ? reason ?? "Refused" : decision.feedback;
616
+ const feedback = blocking ? reason2 ?? "Refused" : decision.feedback;
617
617
  if (!feedback && !context) return null;
618
618
  return {
619
619
  ...feedback ? { decision: "block", reason: feedback } : {},
@@ -818,12 +818,12 @@ var DELIVERS = [
818
818
  ];
819
819
  function render4(input, decision) {
820
820
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
821
- const reason = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON4);
821
+ const reason2 = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON4);
822
822
  const out = {};
823
823
  const notes = [...decision.context ?? []];
824
824
  if (blocking && input.event === "before_tool")
825
- Object.assign(out, { decision: "deny", reason });
826
- else if (blocking) notes.unshift(reason);
825
+ Object.assign(out, { decision: "deny", reason: reason2 });
826
+ else if (blocking) notes.unshift(reason2);
827
827
  if (decision.feedback) notes.push(decision.feedback);
828
828
  if (notes.length > 0 && DELIVERS.includes(input.event))
829
829
  out["hookSpecificOutput"] = {
@@ -1007,10 +1007,10 @@ var DELIVERS2 = [
1007
1007
  ];
1008
1008
  function render5(input, decision) {
1009
1009
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
1010
- const reason = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON5);
1010
+ const reason2 = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON5);
1011
1011
  const notes = [...decision.context ?? []];
1012
1012
  const refuse = blocking && input.event === "before_tool";
1013
- if (blocking && !refuse) notes.unshift(reason);
1013
+ if (blocking && !refuse) notes.unshift(reason2);
1014
1014
  if (decision.feedback) notes.push(decision.feedback);
1015
1015
  const quiet = input.event === "stop" && input.stop?.active === true;
1016
1016
  const context = notes.length > 0 && DELIVERS2.includes(input.event) && !quiet ? notes.join("\n\n") : void 0;
@@ -1018,7 +1018,7 @@ function render5(input, decision) {
1018
1018
  const out = {
1019
1019
  hookSpecificOutput: {
1020
1020
  hookEventName: NATIVE_EVENTS5[input.event],
1021
- ...refuse ? { permissionDecision: "deny", permissionDecisionReason: reason } : {},
1021
+ ...refuse ? { permissionDecision: "deny", permissionDecisionReason: reason2 } : {},
1022
1022
  ...context ? { additionalContext: context } : {}
1023
1023
  }
1024
1024
  };
@@ -1208,14 +1208,14 @@ var DELIVERS3 = [
1208
1208
  ];
1209
1209
  function render6(input, decision) {
1210
1210
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
1211
- const reason = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON6);
1211
+ const reason2 = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON6);
1212
1212
  if (input.event === "before_tool") {
1213
- const out2 = blocking ? { deny: reason } : {};
1213
+ const out2 = blocking ? { deny: reason2 } : {};
1214
1214
  return { stdout: `${JSON.stringify(out2)}
1215
1215
  `, exitCode: 0 };
1216
1216
  }
1217
1217
  const notes = [...decision.context ?? []];
1218
- if (blocking) notes.unshift(reason);
1218
+ if (blocking) notes.unshift(reason2);
1219
1219
  if (decision.feedback) notes.push(decision.feedback);
1220
1220
  const out = notes.length > 0 && DELIVERS3.includes(input.event) ? { context: notes.join("\n\n") } : {};
1221
1221
  return { stdout: `${JSON.stringify(out)}
@@ -2046,20 +2046,39 @@ function touchesLock(words, scripts) {
2046
2046
  return true;
2047
2047
  return runsScript(words, scripts);
2048
2048
  }
2049
- function mutates(words, scripts = []) {
2049
+ var DEFAULT_MUTATING_COMMANDS = [
2050
+ ...[...DOCKER_MUTATING].map((verb) => ["docker", verb]),
2051
+ ...[...WRANGLER_MUTATING].map((verb) => ["wrangler", verb])
2052
+ ];
2053
+ var DEFAULT_MUTATING_SCRIPT_NAMES = [
2054
+ "^git:",
2055
+ "^docker:",
2056
+ "^deploy",
2057
+ "^release",
2058
+ "^publish"
2059
+ ];
2060
+ var DEFAULT_MUTATING_RULES = {
2061
+ scripts: [],
2062
+ commands: DEFAULT_MUTATING_COMMANDS,
2063
+ scriptNames: DEFAULT_MUTATING_SCRIPT_NAMES.map(
2064
+ (source) => new RegExp(source, "u")
2065
+ )
2066
+ };
2067
+ var RUNNERS = /* @__PURE__ */ new Set(["bun", "npm", "pnpm", "yarn"]);
2068
+ function mutates(words, rules2 = DEFAULT_MUTATING_RULES) {
2050
2069
  const [name = "", sub = ""] = words;
2051
2070
  if (name === "git") {
2052
2071
  const call = gitCall(words);
2053
2072
  if (GIT_MUTATING.has(call.sub)) return true;
2054
2073
  return call.sub === "worktree" && ["add", "remove", "move"].includes(call.next);
2055
2074
  }
2056
- if (touchesLock(words, scripts)) return true;
2057
- if (name === "bun" && sub === "run")
2058
- return /^(git:|docker:|deploy|release|publish)/u.test(words[2] ?? "");
2075
+ if (touchesLock(words, rules2.scripts)) return true;
2076
+ if (RUNNERS.has(name) && sub === "run")
2077
+ return rules2.scriptNames.some((pattern) => pattern.test(words[2] ?? ""));
2059
2078
  if (["npm", "pnpm", "yarn"].includes(name)) return PACKAGE_MUTATING.has(sub);
2060
- if (name === "docker") return DOCKER_MUTATING.has(sub);
2061
- if (name === "wrangler") return WRANGLER_MUTATING.has(sub);
2062
- return false;
2079
+ return rules2.commands.some(
2080
+ (prefix) => prefix.length > 0 && prefix.every((word, at) => words[at] === word)
2081
+ );
2063
2082
  }
2064
2083
 
2065
2084
  // src/hooks/policies/_shared.ts
@@ -2740,18 +2759,41 @@ var mailbox = {
2740
2759
  };
2741
2760
 
2742
2761
  // src/hooks/policies/sessions/pause.ts
2743
- var MUTATING = /\b(git\s+(commit|push|merge|rebase|reset|checkout|switch|cherry-pick|revert|am|stash|tag|clean|restore|rm|mv|worktree\s+(add|remove|move))|bun\s+(install|i|add|remove|rm|update|link)\b|(npm|pnpm|yarn)\s+(install|i|add|remove|publish|ci)\b|docker\s+(compose|build|push|run|rm|stop|restart)|wrangler\s+(deploy|publish|secret))\b/u;
2762
+ var BUILT_IN = /\b(git\s+(commit|push|merge|rebase|reset|checkout|switch|cherry-pick|revert|am|stash|tag|clean|restore|rm|mv|worktree\s+(add|remove|move))|bun\s+(install|i|add|remove|rm|update|link)\b|(npm|pnpm|yarn)\s+(install|i|add|remove|publish|ci)\b)\b/u;
2763
+ var escape2 = (word) => word.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
2744
2764
  function changes(input, options2) {
2745
2765
  const tool = input.tool;
2746
2766
  if (tool?.kind === "edit") return true;
2747
2767
  if (tool?.kind !== "shell") return false;
2748
2768
  if (!tool.steps) {
2749
2769
  const command6 = tool.command ?? "";
2750
- return MUTATING.test(command6) || options2.scripts.some((s) => s.test(command6));
2770
+ return BUILT_IN.test(command6) || options2.commands.some(
2771
+ (prefix) => new RegExp(`\\b${prefix.map(escape2).join("\\s+")}\\b`, "u").test(
2772
+ command6
2773
+ )
2774
+ ) || options2.scripts.some((s) => s.test(command6));
2751
2775
  }
2752
- return realSteps(tool.steps).some(
2753
- (step) => mutates(step.argv, options2.scripts)
2754
- );
2776
+ return realSteps(tool.steps).some((step) => mutates(step.argv, options2));
2777
+ }
2778
+ function patterns(raw, key) {
2779
+ const list2 = stringList(raw, key);
2780
+ if (list2 === void 0) return null;
2781
+ return list2.map((source) => {
2782
+ try {
2783
+ return new RegExp(source, "u");
2784
+ } catch {
2785
+ throw new Error(`${key}: ${source} is not a regular expression`);
2786
+ }
2787
+ });
2788
+ }
2789
+ function prefixes(raw) {
2790
+ const value = raw["commands"];
2791
+ if (value === void 0) return null;
2792
+ if (!Array.isArray(value) || !value.every(
2793
+ (prefix) => Array.isArray(prefix) && prefix.length > 0 && prefix.every((word) => typeof word === "string" && word !== "")
2794
+ ))
2795
+ throw new Error("commands must be a list of argv prefixes");
2796
+ return value;
2755
2797
  }
2756
2798
  function foreign(pause2, input, ctx) {
2757
2799
  const session = input.session.id;
@@ -2766,17 +2808,14 @@ var pause = {
2766
2808
  fail: "closed",
2767
2809
  defaultMode: "deny",
2768
2810
  options(raw) {
2769
- onlyKeys(raw, ["refuses", "scripts"]);
2811
+ onlyKeys(raw, ["refuses", "scripts", "commands", "script_names"]);
2770
2812
  if (raw["refuses"] !== void 0 && raw["refuses"] !== "mutating")
2771
2813
  throw new Error("refuses must be mutating");
2772
- const scripts = (stringList(raw, "scripts") ?? []).map((source) => {
2773
- try {
2774
- return new RegExp(source, "u");
2775
- } catch {
2776
- throw new Error(`scripts: ${source} is not a regular expression`);
2777
- }
2778
- });
2779
- return { scripts };
2814
+ return {
2815
+ scripts: patterns(raw, "scripts") ?? [],
2816
+ commands: prefixes(raw) ?? DEFAULT_MUTATING_COMMANDS,
2817
+ scriptNames: patterns(raw, "script_names") ?? DEFAULT_MUTATING_SCRIPT_NAMES.map((source) => new RegExp(source, "u"))
2818
+ };
2780
2819
  },
2781
2820
  evaluate(input, ctx) {
2782
2821
  const current = ctx.store.pause.read();
@@ -2850,8 +2889,8 @@ function fields(input) {
2850
2889
  return { ...cwd, status: "working", waiting: "" };
2851
2890
  if (input.event === "after_tool") return { ...cwd, status: "working" };
2852
2891
  if (input.event === "notification") {
2853
- const reason = input.notification?.type || input.notification?.message;
2854
- return { status: "waiting", waiting: reason ?? "" };
2892
+ const reason2 = input.notification?.type || input.notification?.message;
2893
+ return { status: "waiting", waiting: reason2 ?? "" };
2855
2894
  }
2856
2895
  if (input.event === "stop") {
2857
2896
  return {
@@ -3020,8 +3059,8 @@ var composeTeardown = {
3020
3059
  };
3021
3060
  }
3022
3061
  for (const step of realSteps(call.steps)) {
3023
- const reason = teardownReason(step.argv);
3024
- if (reason) return { verdict: "deny", reason };
3062
+ const reason2 = teardownReason(step.argv);
3063
+ if (reason2) return { verdict: "deny", reason: reason2 };
3025
3064
  }
3026
3065
  return pass;
3027
3066
  }
@@ -3129,6 +3168,220 @@ var inPlaceEdit = {
3129
3168
  }
3130
3169
  };
3131
3170
 
3171
+ // src/hooks/policies/shell/regex-cost.ts
3172
+ var BASIC_INTERVAL = /^\\\{(\d*)(?:,(\d*))?\\\}/u;
3173
+ var INTERVAL = /^\{(\d*)(?:,(\d*))?\}/u;
3174
+ function repetitionCounts(pattern, flavor) {
3175
+ const counts = [];
3176
+ for (let at = 0; at < pattern.length; at += 1) {
3177
+ const char = pattern[at];
3178
+ if (char !== "\\" && char !== "{") continue;
3179
+ const shape3 = flavor === "basic" ? BASIC_INTERVAL : INTERVAL;
3180
+ const interval = char === "{" && flavor === "basic" ? null : shape3.exec(pattern.slice(at));
3181
+ if (!interval) {
3182
+ if (char === "\\") at += 1;
3183
+ continue;
3184
+ }
3185
+ for (const bound of [interval[1], interval[2]])
3186
+ if (bound) counts.push(Number(bound));
3187
+ at += interval[0].length - 1;
3188
+ }
3189
+ return counts;
3190
+ }
3191
+ function nestedQuantifier(pattern) {
3192
+ const groups = [];
3193
+ let quantified = false;
3194
+ for (let at = 0; at < pattern.length; at += 1) {
3195
+ const char = pattern[at];
3196
+ if (char === "\\") {
3197
+ at += 1;
3198
+ continue;
3199
+ }
3200
+ if (char === "[") {
3201
+ at = classEnd(pattern, at);
3202
+ continue;
3203
+ }
3204
+ if (char === "(") {
3205
+ groups.push(quantified);
3206
+ quantified = false;
3207
+ continue;
3208
+ }
3209
+ if (char === ")") {
3210
+ const inner = quantified;
3211
+ quantified = groups.pop() ?? false;
3212
+ if (inner && repeats(pattern, at + 1)) return true;
3213
+ quantified ||= inner;
3214
+ continue;
3215
+ }
3216
+ if (repeats(pattern, at)) quantified = true;
3217
+ }
3218
+ return false;
3219
+ }
3220
+ function repeats(pattern, at) {
3221
+ const char = pattern[at];
3222
+ if (char === "*" || char === "+") return true;
3223
+ return char === "{" && /^\{\d*,\}/u.test(pattern.slice(at));
3224
+ }
3225
+ function classEnd(pattern, start) {
3226
+ let at = start + 1;
3227
+ if (pattern[at] === "^") at += 1;
3228
+ if (pattern[at] === "]") at += 1;
3229
+ for (; at < pattern.length; at += 1) {
3230
+ if (pattern[at] === "\\") at += 1;
3231
+ else if (pattern[at] === "]") return at;
3232
+ }
3233
+ return pattern.length;
3234
+ }
3235
+ function patternCost(pattern, flavor, onlyMatching, limits) {
3236
+ const largest = Math.max(0, ...repetitionCounts(pattern, flavor));
3237
+ if (largest > limits.threshold)
3238
+ return `a repetition count of ${largest} (the limit is ${limits.threshold})`;
3239
+ if (flavor === "perl" && nestedQuantifier(pattern))
3240
+ return "a -P pattern with a quantified group inside a quantifier, such as (a+)+ or (.*)*";
3241
+ if (limits.onlyMatchingWildcards && onlyMatching && (pattern.match(/\.\*/gu) ?? []).length > 1)
3242
+ return "-o with more than one .*";
3243
+ return null;
3244
+ }
3245
+
3246
+ // src/hooks/policies/shell/runaway-regex.ts
3247
+ var GREPS = {
3248
+ grep: "basic",
3249
+ zgrep: "basic",
3250
+ egrep: "extended",
3251
+ fgrep: "fixed"
3252
+ };
3253
+ var VALUE_SHORT = /* @__PURE__ */ new Set(["e", "f", "m", "A", "B", "C", "d", "D", "O"]);
3254
+ var VALUE_LONG = /* @__PURE__ */ new Set([
3255
+ "regexp",
3256
+ "file",
3257
+ "max-count",
3258
+ "after-context",
3259
+ "before-context",
3260
+ "context",
3261
+ "include",
3262
+ "exclude",
3263
+ "exclude-dir",
3264
+ "exclude-from",
3265
+ "binary-files",
3266
+ "devices",
3267
+ "directories",
3268
+ "label",
3269
+ "max-depth",
3270
+ "threads"
3271
+ ]);
3272
+ var FLAVOR_SHORT = {
3273
+ E: "extended",
3274
+ P: "perl",
3275
+ F: "fixed",
3276
+ G: "basic"
3277
+ };
3278
+ var FLAVOR_LONG = {
3279
+ "extended-regexp": "extended",
3280
+ "perl-regexp": "perl",
3281
+ "fixed-strings": "fixed",
3282
+ "basic-regexp": "basic"
3283
+ };
3284
+ function readGrep(args, start) {
3285
+ const patterns2 = [];
3286
+ let flavor = start;
3287
+ let onlyMatching = false;
3288
+ let operand;
3289
+ let fromFile = false;
3290
+ for (let at = 0; at < args.length; at += 1) {
3291
+ const arg = args[at];
3292
+ if (arg === "--") {
3293
+ operand ??= args[at + 1];
3294
+ break;
3295
+ }
3296
+ if (arg.startsWith("--")) {
3297
+ const [name = "", inline] = arg.slice(2).split(/=(.*)/su);
3298
+ if (FLAVOR_LONG[name]) flavor = FLAVOR_LONG[name];
3299
+ if (name === "only-matching") onlyMatching = true;
3300
+ const value = VALUE_LONG.has(name) && inline === void 0 ? args[at += 1] : inline;
3301
+ if (name === "regexp" && value !== void 0) patterns2.push(value);
3302
+ if (name === "file") fromFile = true;
3303
+ continue;
3304
+ }
3305
+ if (arg.startsWith("-") && arg.length > 1) {
3306
+ for (let i = 1; i < arg.length; i += 1) {
3307
+ const flag2 = arg[i];
3308
+ if (FLAVOR_SHORT[flag2]) flavor = FLAVOR_SHORT[flag2];
3309
+ if (flag2 === "o") onlyMatching = true;
3310
+ if (!VALUE_SHORT.has(flag2)) continue;
3311
+ const value = i + 1 < arg.length ? arg.slice(i + 1) : args[at += 1];
3312
+ if (flag2 === "e" && value !== void 0) patterns2.push(value);
3313
+ if (flag2 === "f") fromFile = true;
3314
+ break;
3315
+ }
3316
+ continue;
3317
+ }
3318
+ operand ??= arg;
3319
+ }
3320
+ if (patterns2.length === 0 && !fromFile && operand !== void 0)
3321
+ patterns2.push(operand);
3322
+ return { patterns: patterns2, flavor, onlyMatching };
3323
+ }
3324
+ function grepOf(argv) {
3325
+ const name = program(argv[0]);
3326
+ if (GREPS[name]) return readGrep(argv.slice(1), GREPS[name]);
3327
+ if (name !== "git") return null;
3328
+ const call = gitCall(argv);
3329
+ return call.sub === "grep" ? readGrep(argv.slice(call.at + 1), "basic") : null;
3330
+ }
3331
+ function timed(step) {
3332
+ const at = step.raw.indexOf(step.argv[0]);
3333
+ return step.raw.slice(0, at < 0 ? 0 : at).some((word) => program(word) === "timeout");
3334
+ }
3335
+ function costOf(step, options2) {
3336
+ const grep = grepOf(step.argv);
3337
+ if (!grep || grep.flavor === "fixed") return null;
3338
+ if (options2.allowTimeout && timed(step)) return null;
3339
+ for (const pattern of grep.patterns) {
3340
+ const why = patternCost(pattern, grep.flavor, grep.onlyMatching, options2);
3341
+ if (why) return why;
3342
+ }
3343
+ return null;
3344
+ }
3345
+ var reason = (why, threshold) => `This grep can keep a CPU core busy for minutes: ${why}. Find the line with grep -n and no -o or large count, then print a window around it with sed -n 'N,+K p' FILE; or use rg, which matches in linear time; or bring the count to ${threshold} or below; or bound the run with timeout 20 grep \u2026.`;
3346
+ function integer(raw, key, fallback3) {
3347
+ const value = raw[key] ?? fallback3;
3348
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 1 || value > 32767)
3349
+ throw new Error(`${key} must be an integer from 1 to 32767`);
3350
+ return value;
3351
+ }
3352
+ function bool(raw, key, fallback3) {
3353
+ const value = raw[key] ?? fallback3;
3354
+ if (typeof value !== "boolean")
3355
+ throw new Error(`${key} must be true or false`);
3356
+ return value;
3357
+ }
3358
+ var runawayRegex = {
3359
+ id: "shell.runaway_regex",
3360
+ events: ["before_tool"],
3361
+ tools: ["shell"],
3362
+ fail: "closed",
3363
+ defaultMode: "deny",
3364
+ options(raw) {
3365
+ onlyKeys(raw, ["threshold", "only_matching_wildcards", "allow_timeout"]);
3366
+ return {
3367
+ threshold: integer(raw, "threshold", 255),
3368
+ onlyMatchingWildcards: bool(raw, "only_matching_wildcards", false),
3369
+ allowTimeout: bool(raw, "allow_timeout", true)
3370
+ };
3371
+ },
3372
+ // Unreadable shell syntax passes: a wrong refusal here costs more than a slow grep.
3373
+ evaluate(input, ctx) {
3374
+ const call = shellCall(input);
3375
+ if (!call?.steps) return pass;
3376
+ for (const step of realSteps(call.steps)) {
3377
+ const why = costOf(step, ctx.options);
3378
+ if (why)
3379
+ return { verdict: "deny", reason: reason(why, ctx.options.threshold) };
3380
+ }
3381
+ return pass;
3382
+ }
3383
+ };
3384
+
3132
3385
  // src/hooks/policies/shell/operands.ts
3133
3386
  var SEARCH = {
3134
3387
  code: ["-e", "--regexp"],
@@ -3657,8 +3910,12 @@ function blocked2(input, ctx) {
3657
3910
  const pause2 = ctx.store.pause.read();
3658
3911
  if (pause2 && pause2.by !== input.session.id)
3659
3912
  return `the workspace is paused (${pause2.reason})`;
3660
- const lease = ctx.store.leases.read("lockfile");
3661
- return lease ? `a lockfile change is being delivered (${lease.subject})` : null;
3913
+ for (const name of ctx.options.leases ?? ["lockfile"]) {
3914
+ const lease = ctx.store.leases.read(name);
3915
+ if (lease)
3916
+ return `a change under lease ${name} is being delivered (${lease.subject})`;
3917
+ }
3918
+ return null;
3662
3919
  }
3663
3920
  function changed(root, from, paths, to = "HEAD") {
3664
3921
  if (paths.length === 0) return [];
@@ -3707,7 +3964,7 @@ function move(input, ctx, git) {
3707
3964
  });
3708
3965
  if (result === "current") return [];
3709
3966
  if (result === "held")
3710
- return lines.map((line) => `Desk ${git.root}: ${line}`);
3967
+ return lines.map((line) => `Worktree ${git.root}: ${line}`);
3711
3968
  if (opts.install && opts.installAfterMove === "background" && changed(git.root, before, opts.installWhen).length > 0) {
3712
3969
  backgroundInstall(git.root, opts.install, opts.umask);
3713
3970
  lines.push(`installing in the background: ${opts.install.join(" ")}`);
@@ -3717,7 +3974,7 @@ function move(input, ctx, git) {
3717
3974
  lines.push(
3718
3975
  `These rule files changed with the move; re-read them before going on: ${rules2.join(", ")}`
3719
3976
  );
3720
- return lines.map((line) => `Desk ${git.root}: ${line}`);
3977
+ return lines.map((line) => `Worktree ${git.root}: ${line}`);
3721
3978
  }
3722
3979
  var worktreeSync = {
3723
3980
  id: "git.worktrees.sync",
@@ -3732,9 +3989,9 @@ var worktreeSync = {
3732
3989
  if (input.event === "prompt" && opts.betweenPrompts === "off") return pass;
3733
3990
  const git = desk(input, opts);
3734
3991
  if (!git) return pass;
3735
- const reason = blocked2(input, ctx);
3736
- if (reason)
3737
- return input.event === "session_start" ? { context: [`Desk ${git.root} was not moved: ${reason}.`] } : pass;
3992
+ const reason2 = blocked2(input, ctx);
3993
+ if (reason2)
3994
+ return input.event === "session_start" ? { context: [`Worktree ${git.root} was not moved: ${reason2}.`] } : pass;
3738
3995
  const lines = move(input, ctx, git);
3739
3996
  return lines.length > 0 ? { context: lines } : pass;
3740
3997
  }
@@ -3806,15 +4063,15 @@ function run2(entry, input) {
3806
4063
  const extra = Object.keys(response).some(
3807
4064
  (key) => key !== "decision" && key !== "reason"
3808
4065
  );
3809
- const reason = response["reason"];
3810
- if (extra || reason !== void 0 && typeof reason !== "string")
4066
+ const reason2 = response["reason"];
4067
+ if (extra || reason2 !== void 0 && typeof reason2 !== "string")
3811
4068
  return { verdict: "deny", reason: FAILED };
3812
4069
  if (response["decision"] === "allow") return pass;
3813
4070
  if (response["decision"] !== "deny")
3814
4071
  return { verdict: "deny", reason: FAILED };
3815
4072
  return {
3816
4073
  verdict: "deny",
3817
- reason: typeof reason === "string" ? reason.slice(0, 2e3) : FAILED
4074
+ reason: typeof reason2 === "string" ? reason2.slice(0, 2e3) : FAILED
3818
4075
  };
3819
4076
  }
3820
4077
  function customPolicy(entry) {
@@ -3838,6 +4095,7 @@ var GUARDS = byId([
3838
4095
  composeTeardown,
3839
4096
  hostApproval,
3840
4097
  secretExfiltration,
4098
+ runawayRegex,
3841
4099
  pushWithoutVerify,
3842
4100
  forcedBranchMove,
3843
4101
  gateBypassEnv,
@@ -4107,7 +4365,7 @@ function readFailure(value) {
4107
4365
  for (const key of Object.keys(table3))
4108
4366
  if (!["timeout_ms", "retry", "pass"].includes(key))
4109
4367
  throw new Error(`[hooks.failure] unknown key ${key}`);
4110
- const integer = (key, fallback3, min, max) => {
4368
+ const integer2 = (key, fallback3, min, max) => {
4111
4369
  const v = table3[key] ?? fallback3;
4112
4370
  if (typeof v !== "number" || !Number.isInteger(v) || v < min || v > max)
4113
4371
  throw new Error(
@@ -4121,8 +4379,8 @@ function readFailure(value) {
4121
4379
  `[hooks.failure] pass must list ${PASS_KINDS.join(" or ")}`
4122
4380
  );
4123
4381
  return {
4124
- timeoutMs: integer("timeout_ms", 2e3, 100, 6e4),
4125
- retry: integer("retry", 1, 0, 3),
4382
+ timeoutMs: integer2("timeout_ms", 2e3, 100, 6e4),
4383
+ retry: integer2("retry", 1, 0, 3),
4126
4384
  pass: [...new Set(pass2)]
4127
4385
  };
4128
4386
  }
@@ -4370,6 +4628,7 @@ function readWorktreeSync(tables, root) {
4370
4628
  installWhen: git.sync?.installWhenChanged ?? [],
4371
4629
  noticePaths: sync.noticePaths,
4372
4630
  followSubmodules: git.submodules?.follow === "clean_pins",
4631
+ leases: leaseSpecs(git).map((spec) => spec.name),
4373
4632
  ...git.umask !== void 0 ? { umask: git.umask } : {}
4374
4633
  };
4375
4634
  return {
@@ -4530,7 +4789,6 @@ import { join as join2 } from "path";
4530
4789
  var STATE_PATHS = {
4531
4790
  records: STATE_FILES.records,
4532
4791
  pause: STATE_FILES.pause,
4533
- lease: leaseFile("lockfile"),
4534
4792
  broadcast: STATE_FILES.broadcast
4535
4793
  };
4536
4794
 
@@ -4544,7 +4802,7 @@ var KEYS4 = {
4544
4802
  commands: "commands",
4545
4803
  hold_foreign_edits: "holdForeignEdits"
4546
4804
  };
4547
- function readUiClaude(path, raw, sessionHooks) {
4805
+ function readUiClaude(path, raw, sessionHooks, worktreeRoot) {
4548
4806
  if (raw === void 0) return void 0;
4549
4807
  if (raw === null || typeof raw !== "object" || Array.isArray(raw))
4550
4808
  throw new ConfigError(path, "[ui] must be a table");
@@ -4570,7 +4828,8 @@ function readUiClaude(path, raw, sessionHooks) {
4570
4828
  sessionsPane: switches["sessionsPane"] ?? true,
4571
4829
  statusBand: switches["statusBand"] ?? true,
4572
4830
  commands: switches["commands"] ?? true,
4573
- holdForeignEdits: switches["holdForeignEdits"] ?? true
4831
+ holdForeignEdits: switches["holdForeignEdits"] ?? true,
4832
+ worktreeRoot
4574
4833
  };
4575
4834
  }
4576
4835
  var settingsText = (ui) => `${JSON.stringify(ui, null, 2)}
@@ -5053,7 +5312,12 @@ function readSpec(config) {
5053
5312
  throw new ConfigError(path, m);
5054
5313
  }
5055
5314
  );
5056
- const uiClaude = readUiClaude(path, raw["ui"], sessionHooks);
5315
+ const uiClaude = readUiClaude(
5316
+ path,
5317
+ raw["ui"],
5318
+ sessionHooks,
5319
+ readGitConfig(config)?.worktrees?.root ?? ".claude/worktrees"
5320
+ );
5057
5321
  const permissions = readPermissions(path, raw["permissions"]);
5058
5322
  const host = readHost(path, raw["host"]);
5059
5323
  const harness = readHarness(path, raw["harness"]);
@@ -5116,4 +5380,4 @@ export {
5116
5380
  permissionDoctor,
5117
5381
  readSpec
5118
5382
  };
5119
- //# sourceMappingURL=chunk-3CYQWRGM.js.map
5383
+ //# sourceMappingURL=chunk-BRSESCGX.js.map