@modootoday/pmcp 0.19.7 → 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-2N53IUWM.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-AAMJ5A2R.js → chunk-2S44RDO4.js} +2 -2
  9. package/dist/{chunk-M6OLH75N.js → chunk-3UOFHLY4.js} +5 -5
  10. package/dist/{chunk-UGODVKBJ.js → chunk-4XNAKVSO.js} +2 -2
  11. package/dist/{chunk-L6XBFXDT.js → chunk-4XWVLC23.js} +3 -3
  12. package/dist/{chunk-AW3OY32A.js → chunk-57FHYW74.js} +17 -5
  13. package/dist/{chunk-MARV7HLS.js → chunk-A6TM4NTI.js} +3 -3
  14. package/dist/{chunk-RVE3EMGF.js → chunk-BRSESCGX.js} +344 -80
  15. package/dist/{chunk-YGA2HFGB.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-P2B7CDRM.js → chunk-EONAJAMJ.js} +3 -3
  19. package/dist/{chunk-N2GVNL4G.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-WS4SDGEE.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-RUFB4N2P.js → chunk-PBDPWE5J.js} +3 -3
  27. package/dist/{chunk-HEBCQTOD.js → chunk-PEMMV5YQ.js} +2 -2
  28. package/dist/{chunk-6FZXF3G6.js → chunk-PG42KALG.js} +5 -5
  29. package/dist/{chunk-7B6IC3F7.js → chunk-PUIWESU3.js} +3 -3
  30. package/dist/{chunk-JBW4JPIF.js → chunk-QTKD7JEL.js} +21 -21
  31. package/dist/{chunk-F3PZXF55.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-HSIQKOI5.js → chunk-SPUCY4AG.js} +2 -2
  35. package/dist/{chunk-DHAPQUEF.js → chunk-V7HG3STC.js} +2 -2
  36. package/dist/{chunk-OOPTHZVQ.js → chunk-VDBUZKXC.js} +2 -2
  37. package/dist/{chunk-XP2U3LO3.js → chunk-W5RLIUNC.js} +2 -2
  38. package/dist/{chunk-3MAHF3RQ.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-LYMHFHDJ.js → chunk-YKU7KHJO.js} +3 -3
  42. package/dist/{chunk-6GOAMHFJ.js → chunk-YLPXTJJM.js} +2 -2
  43. package/dist/{chunk-7B2KRL2H.js → chunk-YXAPCHXJ.js} +52 -5
  44. package/dist/{chunk-L6YMDRKU.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-6PLM6T4X.js → completion-B3UT3GVI.js} +2 -2
  50. package/dist/{config-DnpLL2kT.d.ts → config-DzHB75Jz.d.ts} +2 -0
  51. package/dist/{diagnostics-E3ZFK2DG.js → diagnostics-ONIAKCA3.js} +7 -7
  52. package/dist/{doctor-AVJ6V5OZ.js → doctor-MJFU5L6R.js} +20 -20
  53. package/dist/{entry-J7YM5OF3.js → entry-DZGKCL4G.js} +12 -12
  54. package/dist/{exec-mcp-IEQRT3UO.js → exec-mcp-QK2VC6RX.js} +13 -13
  55. package/dist/{harness-OM5AYSLY.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-PPUVHNN6.js → hooks-FRZ4SUNJ.js} +3 -3
  60. package/dist/{host-53O2BR6F.js → host-3HTCZNVJ.js} +16 -16
  61. package/dist/{host-EJF3JFMD.js → host-AGNF2AQH.js} +8 -8
  62. package/dist/{host-run-YPSYP6TC.js → host-run-2OQZVQID.js} +21 -13
  63. package/dist/http.js +1 -1
  64. package/dist/{import-mcp-7I7USMVM.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-4AXJXIZQ.js → init-BHGCF7JL.js} +2 -2
  68. package/dist/{install-MQ7QSJQ7.js → install-HF6CROQP.js} +19 -9
  69. package/dist/{invoke-TWWYDHG7.js → invoke-CVHF6PEK.js} +9 -9
  70. package/dist/{list-TBCWXSK2.js → list-6XGQ3FR3.js} +13 -13
  71. package/dist/{list-FB6RNYYB.js → list-WK2IYUK7.js} +4 -4
  72. package/dist/{logout-QXOOQ2NB.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-XHFC7DUL.js → mcp-P55VLQLR.js} +2 -2
  80. package/dist/{pause-2HQ7CKMR.js → pause-V5VCNOSH.js} +5 -5
  81. package/dist/{project-IDRHI3AJ.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-X7CPBDYV.js → run-LFJXONLW.js} +4 -4
  87. package/dist/{run-BYQVIDBZ.js → run-MC2BPLOE.js} +14 -14
  88. package/dist/{serve-ZWZEEMAO.js → serve-TFAEVXX3.js} +9 -9
  89. package/dist/{setup-63E3TVJK.js → setup-FHFQZJY6.js} +5 -6
  90. package/dist/{start-login-YACBMXW2.js → start-login-KXOHCR5A.js} +12 -12
  91. package/dist/{status-GFD3YOYT.js → status-AW7DOW7A.js} +12 -12
  92. package/dist/{status-CM753VKY.js → status-OYRB3KL5.js} +8 -8
  93. package/dist/{status-QHOZDGYN.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-NAVM6ZFB.js → test-2HTOY4PJ.js} +13 -13
  97. package/dist/{tui-W7QMB743.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-4ADJPJ2A.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 +6 -6
  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-ZVXYPC3Q.js +0 -7
package/dist/hook-body.js CHANGED
@@ -46,10 +46,10 @@ function compose(decisions) {
46
46
  function lower(decision, lowering) {
47
47
  if (decision.verdict !== "ask" || !lowering) return decision;
48
48
  if (lowering.ask === "deny") return { ...decision, verdict: "deny" };
49
- const { verdict: _verdict, reason, ...rest } = decision;
49
+ const { verdict: _verdict, reason: reason2, ...rest } = decision;
50
50
  return {
51
51
  ...rest,
52
- context: [...decision.context ?? [], `pmcp: ${reason ?? "would ask"}`]
52
+ context: [...decision.context ?? [], `pmcp: ${reason2 ?? "would ask"}`]
53
53
  };
54
54
  }
55
55
 
@@ -657,20 +657,39 @@ function touchesLock(words, scripts) {
657
657
  return true;
658
658
  return runsScript(words, scripts);
659
659
  }
660
- function mutates(words, scripts = []) {
660
+ var DEFAULT_MUTATING_COMMANDS = [
661
+ ...[...DOCKER_MUTATING].map((verb) => ["docker", verb]),
662
+ ...[...WRANGLER_MUTATING].map((verb) => ["wrangler", verb])
663
+ ];
664
+ var DEFAULT_MUTATING_SCRIPT_NAMES = [
665
+ "^git:",
666
+ "^docker:",
667
+ "^deploy",
668
+ "^release",
669
+ "^publish"
670
+ ];
671
+ var DEFAULT_MUTATING_RULES = {
672
+ scripts: [],
673
+ commands: DEFAULT_MUTATING_COMMANDS,
674
+ scriptNames: DEFAULT_MUTATING_SCRIPT_NAMES.map(
675
+ (source) => new RegExp(source, "u")
676
+ )
677
+ };
678
+ var RUNNERS = /* @__PURE__ */ new Set(["bun", "npm", "pnpm", "yarn"]);
679
+ function mutates(words, rules = DEFAULT_MUTATING_RULES) {
661
680
  const [name = "", sub = ""] = words;
662
681
  if (name === "git") {
663
682
  const call = gitCall(words);
664
683
  if (GIT_MUTATING.has(call.sub)) return true;
665
684
  return call.sub === "worktree" && ["add", "remove", "move"].includes(call.next);
666
685
  }
667
- if (touchesLock(words, scripts)) return true;
668
- if (name === "bun" && sub === "run")
669
- return /^(git:|docker:|deploy|release|publish)/u.test(words[2] ?? "");
686
+ if (touchesLock(words, rules.scripts)) return true;
687
+ if (RUNNERS.has(name) && sub === "run")
688
+ return rules.scriptNames.some((pattern) => pattern.test(words[2] ?? ""));
670
689
  if (["npm", "pnpm", "yarn"].includes(name)) return PACKAGE_MUTATING.has(sub);
671
- if (name === "docker") return DOCKER_MUTATING.has(sub);
672
- if (name === "wrangler") return WRANGLER_MUTATING.has(sub);
673
- return false;
690
+ return rules.commands.some(
691
+ (prefix) => prefix.length > 0 && prefix.every((word, at) => words[at] === word)
692
+ );
674
693
  }
675
694
 
676
695
  // src/hooks/dispatch/enrich.ts
@@ -1749,18 +1768,41 @@ var mailbox = {
1749
1768
  };
1750
1769
 
1751
1770
  // src/hooks/policies/sessions/pause.ts
1752
- 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;
1771
+ 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;
1772
+ var escape2 = (word) => word.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
1753
1773
  function changes(input, options2) {
1754
1774
  const tool = input.tool;
1755
1775
  if (tool?.kind === "edit") return true;
1756
1776
  if (tool?.kind !== "shell") return false;
1757
1777
  if (!tool.steps) {
1758
1778
  const command6 = tool.command ?? "";
1759
- return MUTATING.test(command6) || options2.scripts.some((s) => s.test(command6));
1779
+ return BUILT_IN.test(command6) || options2.commands.some(
1780
+ (prefix) => new RegExp(`\\b${prefix.map(escape2).join("\\s+")}\\b`, "u").test(
1781
+ command6
1782
+ )
1783
+ ) || options2.scripts.some((s) => s.test(command6));
1760
1784
  }
1761
- return realSteps(tool.steps).some(
1762
- (step) => mutates(step.argv, options2.scripts)
1763
- );
1785
+ return realSteps(tool.steps).some((step) => mutates(step.argv, options2));
1786
+ }
1787
+ function patterns(raw, key) {
1788
+ const list = stringList(raw, key);
1789
+ if (list === void 0) return null;
1790
+ return list.map((source) => {
1791
+ try {
1792
+ return new RegExp(source, "u");
1793
+ } catch {
1794
+ throw new Error(`${key}: ${source} is not a regular expression`);
1795
+ }
1796
+ });
1797
+ }
1798
+ function prefixes(raw) {
1799
+ const value = raw["commands"];
1800
+ if (value === void 0) return null;
1801
+ if (!Array.isArray(value) || !value.every(
1802
+ (prefix) => Array.isArray(prefix) && prefix.length > 0 && prefix.every((word) => typeof word === "string" && word !== "")
1803
+ ))
1804
+ throw new Error("commands must be a list of argv prefixes");
1805
+ return value;
1764
1806
  }
1765
1807
  function foreign(pause2, input, ctx) {
1766
1808
  const session = input.session.id;
@@ -1775,17 +1817,14 @@ var pause = {
1775
1817
  fail: "closed",
1776
1818
  defaultMode: "deny",
1777
1819
  options(raw) {
1778
- onlyKeys(raw, ["refuses", "scripts"]);
1820
+ onlyKeys(raw, ["refuses", "scripts", "commands", "script_names"]);
1779
1821
  if (raw["refuses"] !== void 0 && raw["refuses"] !== "mutating")
1780
1822
  throw new Error("refuses must be mutating");
1781
- const scripts = (stringList(raw, "scripts") ?? []).map((source) => {
1782
- try {
1783
- return new RegExp(source, "u");
1784
- } catch {
1785
- throw new Error(`scripts: ${source} is not a regular expression`);
1786
- }
1787
- });
1788
- return { scripts };
1823
+ return {
1824
+ scripts: patterns(raw, "scripts") ?? [],
1825
+ commands: prefixes(raw) ?? DEFAULT_MUTATING_COMMANDS,
1826
+ scriptNames: patterns(raw, "script_names") ?? DEFAULT_MUTATING_SCRIPT_NAMES.map((source) => new RegExp(source, "u"))
1827
+ };
1789
1828
  },
1790
1829
  evaluate(input, ctx) {
1791
1830
  const current = ctx.store.pause.read();
@@ -1859,8 +1898,8 @@ function fields(input) {
1859
1898
  return { ...cwd, status: "working", waiting: "" };
1860
1899
  if (input.event === "after_tool") return { ...cwd, status: "working" };
1861
1900
  if (input.event === "notification") {
1862
- const reason = input.notification?.type || input.notification?.message;
1863
- return { status: "waiting", waiting: reason ?? "" };
1901
+ const reason2 = input.notification?.type || input.notification?.message;
1902
+ return { status: "waiting", waiting: reason2 ?? "" };
1864
1903
  }
1865
1904
  if (input.event === "stop") {
1866
1905
  return {
@@ -2029,8 +2068,8 @@ var composeTeardown = {
2029
2068
  };
2030
2069
  }
2031
2070
  for (const step of realSteps(call.steps)) {
2032
- const reason = teardownReason(step.argv);
2033
- if (reason) return { verdict: "deny", reason };
2071
+ const reason2 = teardownReason(step.argv);
2072
+ if (reason2) return { verdict: "deny", reason: reason2 };
2034
2073
  }
2035
2074
  return pass;
2036
2075
  }
@@ -2138,6 +2177,220 @@ var inPlaceEdit = {
2138
2177
  }
2139
2178
  };
2140
2179
 
2180
+ // src/hooks/policies/shell/regex-cost.ts
2181
+ var BASIC_INTERVAL = /^\\\{(\d*)(?:,(\d*))?\\\}/u;
2182
+ var INTERVAL = /^\{(\d*)(?:,(\d*))?\}/u;
2183
+ function repetitionCounts(pattern, flavor) {
2184
+ const counts = [];
2185
+ for (let at = 0; at < pattern.length; at += 1) {
2186
+ const char = pattern[at];
2187
+ if (char !== "\\" && char !== "{") continue;
2188
+ const shape3 = flavor === "basic" ? BASIC_INTERVAL : INTERVAL;
2189
+ const interval = char === "{" && flavor === "basic" ? null : shape3.exec(pattern.slice(at));
2190
+ if (!interval) {
2191
+ if (char === "\\") at += 1;
2192
+ continue;
2193
+ }
2194
+ for (const bound of [interval[1], interval[2]])
2195
+ if (bound) counts.push(Number(bound));
2196
+ at += interval[0].length - 1;
2197
+ }
2198
+ return counts;
2199
+ }
2200
+ function nestedQuantifier(pattern) {
2201
+ const groups = [];
2202
+ let quantified = false;
2203
+ for (let at = 0; at < pattern.length; at += 1) {
2204
+ const char = pattern[at];
2205
+ if (char === "\\") {
2206
+ at += 1;
2207
+ continue;
2208
+ }
2209
+ if (char === "[") {
2210
+ at = classEnd(pattern, at);
2211
+ continue;
2212
+ }
2213
+ if (char === "(") {
2214
+ groups.push(quantified);
2215
+ quantified = false;
2216
+ continue;
2217
+ }
2218
+ if (char === ")") {
2219
+ const inner = quantified;
2220
+ quantified = groups.pop() ?? false;
2221
+ if (inner && repeats(pattern, at + 1)) return true;
2222
+ quantified ||= inner;
2223
+ continue;
2224
+ }
2225
+ if (repeats(pattern, at)) quantified = true;
2226
+ }
2227
+ return false;
2228
+ }
2229
+ function repeats(pattern, at) {
2230
+ const char = pattern[at];
2231
+ if (char === "*" || char === "+") return true;
2232
+ return char === "{" && /^\{\d*,\}/u.test(pattern.slice(at));
2233
+ }
2234
+ function classEnd(pattern, start) {
2235
+ let at = start + 1;
2236
+ if (pattern[at] === "^") at += 1;
2237
+ if (pattern[at] === "]") at += 1;
2238
+ for (; at < pattern.length; at += 1) {
2239
+ if (pattern[at] === "\\") at += 1;
2240
+ else if (pattern[at] === "]") return at;
2241
+ }
2242
+ return pattern.length;
2243
+ }
2244
+ function patternCost(pattern, flavor, onlyMatching, limits) {
2245
+ const largest = Math.max(0, ...repetitionCounts(pattern, flavor));
2246
+ if (largest > limits.threshold)
2247
+ return `a repetition count of ${largest} (the limit is ${limits.threshold})`;
2248
+ if (flavor === "perl" && nestedQuantifier(pattern))
2249
+ return "a -P pattern with a quantified group inside a quantifier, such as (a+)+ or (.*)*";
2250
+ if (limits.onlyMatchingWildcards && onlyMatching && (pattern.match(/\.\*/gu) ?? []).length > 1)
2251
+ return "-o with more than one .*";
2252
+ return null;
2253
+ }
2254
+
2255
+ // src/hooks/policies/shell/runaway-regex.ts
2256
+ var GREPS = {
2257
+ grep: "basic",
2258
+ zgrep: "basic",
2259
+ egrep: "extended",
2260
+ fgrep: "fixed"
2261
+ };
2262
+ var VALUE_SHORT = /* @__PURE__ */ new Set(["e", "f", "m", "A", "B", "C", "d", "D", "O"]);
2263
+ var VALUE_LONG = /* @__PURE__ */ new Set([
2264
+ "regexp",
2265
+ "file",
2266
+ "max-count",
2267
+ "after-context",
2268
+ "before-context",
2269
+ "context",
2270
+ "include",
2271
+ "exclude",
2272
+ "exclude-dir",
2273
+ "exclude-from",
2274
+ "binary-files",
2275
+ "devices",
2276
+ "directories",
2277
+ "label",
2278
+ "max-depth",
2279
+ "threads"
2280
+ ]);
2281
+ var FLAVOR_SHORT = {
2282
+ E: "extended",
2283
+ P: "perl",
2284
+ F: "fixed",
2285
+ G: "basic"
2286
+ };
2287
+ var FLAVOR_LONG = {
2288
+ "extended-regexp": "extended",
2289
+ "perl-regexp": "perl",
2290
+ "fixed-strings": "fixed",
2291
+ "basic-regexp": "basic"
2292
+ };
2293
+ function readGrep(args, start) {
2294
+ const patterns2 = [];
2295
+ let flavor = start;
2296
+ let onlyMatching = false;
2297
+ let operand;
2298
+ let fromFile = false;
2299
+ for (let at = 0; at < args.length; at += 1) {
2300
+ const arg = args[at];
2301
+ if (arg === "--") {
2302
+ operand ??= args[at + 1];
2303
+ break;
2304
+ }
2305
+ if (arg.startsWith("--")) {
2306
+ const [name = "", inline] = arg.slice(2).split(/=(.*)/su);
2307
+ if (FLAVOR_LONG[name]) flavor = FLAVOR_LONG[name];
2308
+ if (name === "only-matching") onlyMatching = true;
2309
+ const value = VALUE_LONG.has(name) && inline === void 0 ? args[at += 1] : inline;
2310
+ if (name === "regexp" && value !== void 0) patterns2.push(value);
2311
+ if (name === "file") fromFile = true;
2312
+ continue;
2313
+ }
2314
+ if (arg.startsWith("-") && arg.length > 1) {
2315
+ for (let i = 1; i < arg.length; i += 1) {
2316
+ const flag2 = arg[i];
2317
+ if (FLAVOR_SHORT[flag2]) flavor = FLAVOR_SHORT[flag2];
2318
+ if (flag2 === "o") onlyMatching = true;
2319
+ if (!VALUE_SHORT.has(flag2)) continue;
2320
+ const value = i + 1 < arg.length ? arg.slice(i + 1) : args[at += 1];
2321
+ if (flag2 === "e" && value !== void 0) patterns2.push(value);
2322
+ if (flag2 === "f") fromFile = true;
2323
+ break;
2324
+ }
2325
+ continue;
2326
+ }
2327
+ operand ??= arg;
2328
+ }
2329
+ if (patterns2.length === 0 && !fromFile && operand !== void 0)
2330
+ patterns2.push(operand);
2331
+ return { patterns: patterns2, flavor, onlyMatching };
2332
+ }
2333
+ function grepOf(argv) {
2334
+ const name = program(argv[0]);
2335
+ if (GREPS[name]) return readGrep(argv.slice(1), GREPS[name]);
2336
+ if (name !== "git") return null;
2337
+ const call = gitCall(argv);
2338
+ return call.sub === "grep" ? readGrep(argv.slice(call.at + 1), "basic") : null;
2339
+ }
2340
+ function timed(step) {
2341
+ const at = step.raw.indexOf(step.argv[0]);
2342
+ return step.raw.slice(0, at < 0 ? 0 : at).some((word) => program(word) === "timeout");
2343
+ }
2344
+ function costOf(step, options2) {
2345
+ const grep = grepOf(step.argv);
2346
+ if (!grep || grep.flavor === "fixed") return null;
2347
+ if (options2.allowTimeout && timed(step)) return null;
2348
+ for (const pattern of grep.patterns) {
2349
+ const why = patternCost(pattern, grep.flavor, grep.onlyMatching, options2);
2350
+ if (why) return why;
2351
+ }
2352
+ return null;
2353
+ }
2354
+ 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.`;
2355
+ function integer(raw, key, fallback3) {
2356
+ const value = raw[key] ?? fallback3;
2357
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 1 || value > 32767)
2358
+ throw new Error(`${key} must be an integer from 1 to 32767`);
2359
+ return value;
2360
+ }
2361
+ function bool(raw, key, fallback3) {
2362
+ const value = raw[key] ?? fallback3;
2363
+ if (typeof value !== "boolean")
2364
+ throw new Error(`${key} must be true or false`);
2365
+ return value;
2366
+ }
2367
+ var runawayRegex = {
2368
+ id: "shell.runaway_regex",
2369
+ events: ["before_tool"],
2370
+ tools: ["shell"],
2371
+ fail: "closed",
2372
+ defaultMode: "deny",
2373
+ options(raw) {
2374
+ onlyKeys(raw, ["threshold", "only_matching_wildcards", "allow_timeout"]);
2375
+ return {
2376
+ threshold: integer(raw, "threshold", 255),
2377
+ onlyMatchingWildcards: bool(raw, "only_matching_wildcards", false),
2378
+ allowTimeout: bool(raw, "allow_timeout", true)
2379
+ };
2380
+ },
2381
+ // Unreadable shell syntax passes: a wrong refusal here costs more than a slow grep.
2382
+ evaluate(input, ctx) {
2383
+ const call = shellCall(input);
2384
+ if (!call?.steps) return pass;
2385
+ for (const step of realSteps(call.steps)) {
2386
+ const why = costOf(step, ctx.options);
2387
+ if (why)
2388
+ return { verdict: "deny", reason: reason(why, ctx.options.threshold) };
2389
+ }
2390
+ return pass;
2391
+ }
2392
+ };
2393
+
2141
2394
  // src/hooks/policies/shell/operands.ts
2142
2395
  var SEARCH = {
2143
2396
  code: ["-e", "--regexp"],
@@ -3026,8 +3279,12 @@ function blocked2(input, ctx) {
3026
3279
  const pause2 = ctx.store.pause.read();
3027
3280
  if (pause2 && pause2.by !== input.session.id)
3028
3281
  return `the workspace is paused (${pause2.reason})`;
3029
- const lease = ctx.store.leases.read("lockfile");
3030
- return lease ? `a lockfile change is being delivered (${lease.subject})` : null;
3282
+ for (const name of ctx.options.leases ?? ["lockfile"]) {
3283
+ const lease = ctx.store.leases.read(name);
3284
+ if (lease)
3285
+ return `a change under lease ${name} is being delivered (${lease.subject})`;
3286
+ }
3287
+ return null;
3031
3288
  }
3032
3289
  function changed(root, from, paths, to = "HEAD") {
3033
3290
  if (paths.length === 0) return [];
@@ -3076,7 +3333,7 @@ function move(input, ctx, git2) {
3076
3333
  });
3077
3334
  if (result === "current") return [];
3078
3335
  if (result === "held")
3079
- return lines.map((line) => `Desk ${git2.root}: ${line}`);
3336
+ return lines.map((line) => `Worktree ${git2.root}: ${line}`);
3080
3337
  if (opts.install && opts.installAfterMove === "background" && changed(git2.root, before2, opts.installWhen).length > 0) {
3081
3338
  backgroundInstall(git2.root, opts.install, opts.umask);
3082
3339
  lines.push(`installing in the background: ${opts.install.join(" ")}`);
@@ -3086,7 +3343,7 @@ function move(input, ctx, git2) {
3086
3343
  lines.push(
3087
3344
  `These rule files changed with the move; re-read them before going on: ${rules.join(", ")}`
3088
3345
  );
3089
- return lines.map((line) => `Desk ${git2.root}: ${line}`);
3346
+ return lines.map((line) => `Worktree ${git2.root}: ${line}`);
3090
3347
  }
3091
3348
  var worktreeSync = {
3092
3349
  id: "git.worktrees.sync",
@@ -3101,9 +3358,9 @@ var worktreeSync = {
3101
3358
  if (input.event === "prompt" && opts.betweenPrompts === "off") return pass;
3102
3359
  const git2 = desk(input, opts);
3103
3360
  if (!git2) return pass;
3104
- const reason = blocked2(input, ctx);
3105
- if (reason)
3106
- return input.event === "session_start" ? { context: [`Desk ${git2.root} was not moved: ${reason}.`] } : pass;
3361
+ const reason2 = blocked2(input, ctx);
3362
+ if (reason2)
3363
+ return input.event === "session_start" ? { context: [`Worktree ${git2.root} was not moved: ${reason2}.`] } : pass;
3107
3364
  const lines = move(input, ctx, git2);
3108
3365
  return lines.length > 0 ? { context: lines } : pass;
3109
3366
  }
@@ -3172,15 +3429,15 @@ function run2(entry, input) {
3172
3429
  const extra = Object.keys(response).some(
3173
3430
  (key) => key !== "decision" && key !== "reason"
3174
3431
  );
3175
- const reason = response["reason"];
3176
- if (extra || reason !== void 0 && typeof reason !== "string")
3432
+ const reason2 = response["reason"];
3433
+ if (extra || reason2 !== void 0 && typeof reason2 !== "string")
3177
3434
  return { verdict: "deny", reason: FAILED };
3178
3435
  if (response["decision"] === "allow") return pass;
3179
3436
  if (response["decision"] !== "deny")
3180
3437
  return { verdict: "deny", reason: FAILED };
3181
3438
  return {
3182
3439
  verdict: "deny",
3183
- reason: typeof reason === "string" ? reason.slice(0, 2e3) : FAILED
3440
+ reason: typeof reason2 === "string" ? reason2.slice(0, 2e3) : FAILED
3184
3441
  };
3185
3442
  }
3186
3443
  function customPolicy(entry) {
@@ -3204,6 +3461,7 @@ var GUARDS = byId([
3204
3461
  composeTeardown,
3205
3462
  hostApproval,
3206
3463
  secretExfiltration,
3464
+ runawayRegex,
3207
3465
  pushWithoutVerify,
3208
3466
  forcedBranchMove,
3209
3467
  gateBypassEnv,
@@ -3322,14 +3580,14 @@ function silent(event) {
3322
3580
  }
3323
3581
  function render(input, decision) {
3324
3582
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
3325
- const reason = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON);
3583
+ const reason2 = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON);
3326
3584
  if (input.event === "before_tool") {
3327
- const out2 = blocking ? { decision: "deny", reason } : { decision: "allow" };
3585
+ const out2 = blocking ? { decision: "deny", reason: reason2 } : { decision: "allow" };
3328
3586
  return { stdout: `${JSON.stringify(out2)}
3329
3587
  `, exitCode: 0 };
3330
3588
  }
3331
3589
  const notes = [...decision.context ?? []];
3332
- if (blocking) notes.unshift(reason);
3590
+ if (blocking) notes.unshift(reason2);
3333
3591
  if (decision.feedback) notes.push(decision.feedback);
3334
3592
  let out = {};
3335
3593
  if (notes.length > 0 && input.event !== "after_tool") {
@@ -3523,19 +3781,19 @@ var MAX_REASON2 = 2e3;
3523
3781
  function render2(input, decision) {
3524
3782
  const hookEventName = NATIVE_EVENTS2[input.event];
3525
3783
  const context = decision.context?.length ? decision.context.join("\n\n") : void 0;
3526
- const reason = decision.reason?.slice(0, MAX_REASON2);
3784
+ const reason2 = decision.reason?.slice(0, MAX_REASON2);
3527
3785
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
3528
3786
  const out = shape(input, decision, {
3529
3787
  hookEventName,
3530
3788
  context,
3531
- reason,
3789
+ reason: reason2,
3532
3790
  blocking
3533
3791
  });
3534
3792
  return { stdout: out ? `${JSON.stringify(out)}
3535
3793
  ` : "", exitCode: 0 };
3536
3794
  }
3537
3795
  function shape(input, decision, parts) {
3538
- const { hookEventName, context, reason, blocking } = parts;
3796
+ const { hookEventName, context, reason: reason2, blocking } = parts;
3539
3797
  const contextOnly = context ? { hookSpecificOutput: { hookEventName, additionalContext: context } } : {};
3540
3798
  if (input.event === "before_tool") {
3541
3799
  if (!blocking && !context) return null;
@@ -3543,7 +3801,7 @@ function shape(input, decision, parts) {
3543
3801
  if (blocking) {
3544
3802
  refusal = {
3545
3803
  permissionDecision: decision.verdict,
3546
- ...reason ? { permissionDecisionReason: reason } : {}
3804
+ ...reason2 ? { permissionDecisionReason: reason2 } : {}
3547
3805
  };
3548
3806
  }
3549
3807
  return {
@@ -3555,7 +3813,7 @@ function shape(input, decision, parts) {
3555
3813
  };
3556
3814
  }
3557
3815
  if (input.event === "prompt" || input.event === "after_tool" || input.event === "stop") {
3558
- const feedback = blocking ? reason ?? "Refused" : decision.feedback;
3816
+ const feedback = blocking ? reason2 ?? "Refused" : decision.feedback;
3559
3817
  if (!feedback && !context) return null;
3560
3818
  return {
3561
3819
  ...feedback ? { decision: "block", reason: feedback } : {},
@@ -3773,12 +4031,12 @@ var MAX_REASON3 = 2e3;
3773
4031
  function render3(input, decision) {
3774
4032
  const hookEventName = NATIVE_EVENTS3[input.event];
3775
4033
  const context = decision.context?.length ? decision.context.join("\n\n") : void 0;
3776
- const reason = decision.reason?.slice(0, MAX_REASON3);
4034
+ const reason2 = decision.reason?.slice(0, MAX_REASON3);
3777
4035
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
3778
4036
  const out = shape2(input, decision, {
3779
4037
  hookEventName,
3780
4038
  context,
3781
- reason,
4039
+ reason: reason2,
3782
4040
  blocking
3783
4041
  });
3784
4042
  if (!out && input.event === "stop") return { stdout: "{}\n", exitCode: 0 };
@@ -3786,7 +4044,7 @@ function render3(input, decision) {
3786
4044
  ` : "", exitCode: 0 };
3787
4045
  }
3788
4046
  function shape2(input, decision, parts) {
3789
- const { hookEventName, context, reason, blocking } = parts;
4047
+ const { hookEventName, context, reason: reason2, blocking } = parts;
3790
4048
  const contextOnly = context ? { hookSpecificOutput: { hookEventName, additionalContext: context } } : {};
3791
4049
  if (input.event === "before_tool") {
3792
4050
  if (!blocking && !context) return null;
@@ -3794,7 +4052,7 @@ function shape2(input, decision, parts) {
3794
4052
  if (blocking) {
3795
4053
  refusal = {
3796
4054
  permissionDecision: "deny",
3797
- ...reason ? { permissionDecisionReason: reason } : {}
4055
+ ...reason2 ? { permissionDecisionReason: reason2 } : {}
3798
4056
  };
3799
4057
  }
3800
4058
  return {
@@ -3806,7 +4064,7 @@ function shape2(input, decision, parts) {
3806
4064
  };
3807
4065
  }
3808
4066
  if (input.event === "prompt" || input.event === "after_tool" || input.event === "stop") {
3809
- const feedback = blocking ? reason ?? "Refused" : decision.feedback;
4067
+ const feedback = blocking ? reason2 ?? "Refused" : decision.feedback;
3810
4068
  if (!feedback && !context) return null;
3811
4069
  return {
3812
4070
  ...feedback ? { decision: "block", reason: feedback } : {},
@@ -4011,12 +4269,12 @@ var DELIVERS = [
4011
4269
  ];
4012
4270
  function render4(input, decision) {
4013
4271
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
4014
- const reason = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON4);
4272
+ const reason2 = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON4);
4015
4273
  const out = {};
4016
4274
  const notes = [...decision.context ?? []];
4017
4275
  if (blocking && input.event === "before_tool")
4018
- Object.assign(out, { decision: "deny", reason });
4019
- else if (blocking) notes.unshift(reason);
4276
+ Object.assign(out, { decision: "deny", reason: reason2 });
4277
+ else if (blocking) notes.unshift(reason2);
4020
4278
  if (decision.feedback) notes.push(decision.feedback);
4021
4279
  if (notes.length > 0 && DELIVERS.includes(input.event))
4022
4280
  out["hookSpecificOutput"] = {
@@ -4200,10 +4458,10 @@ var DELIVERS2 = [
4200
4458
  ];
4201
4459
  function render5(input, decision) {
4202
4460
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
4203
- const reason = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON5);
4461
+ const reason2 = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON5);
4204
4462
  const notes = [...decision.context ?? []];
4205
4463
  const refuse = blocking && input.event === "before_tool";
4206
- if (blocking && !refuse) notes.unshift(reason);
4464
+ if (blocking && !refuse) notes.unshift(reason2);
4207
4465
  if (decision.feedback) notes.push(decision.feedback);
4208
4466
  const quiet = input.event === "stop" && input.stop?.active === true;
4209
4467
  const context = notes.length > 0 && DELIVERS2.includes(input.event) && !quiet ? notes.join("\n\n") : void 0;
@@ -4211,7 +4469,7 @@ function render5(input, decision) {
4211
4469
  const out = {
4212
4470
  hookSpecificOutput: {
4213
4471
  hookEventName: NATIVE_EVENTS5[input.event],
4214
- ...refuse ? { permissionDecision: "deny", permissionDecisionReason: reason } : {},
4472
+ ...refuse ? { permissionDecision: "deny", permissionDecisionReason: reason2 } : {},
4215
4473
  ...context ? { additionalContext: context } : {}
4216
4474
  }
4217
4475
  };
@@ -4401,14 +4659,14 @@ var DELIVERS3 = [
4401
4659
  ];
4402
4660
  function render6(input, decision) {
4403
4661
  const blocking = decision.verdict === "deny" || decision.verdict === "ask";
4404
- const reason = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON6);
4662
+ const reason2 = (decision.reason ?? "Refused by pmcp").slice(0, MAX_REASON6);
4405
4663
  if (input.event === "before_tool") {
4406
- const out2 = blocking ? { deny: reason } : {};
4664
+ const out2 = blocking ? { deny: reason2 } : {};
4407
4665
  return { stdout: `${JSON.stringify(out2)}
4408
4666
  `, exitCode: 0 };
4409
4667
  }
4410
4668
  const notes = [...decision.context ?? []];
4411
- if (blocking) notes.unshift(reason);
4669
+ if (blocking) notes.unshift(reason2);
4412
4670
  if (decision.feedback) notes.push(decision.feedback);
4413
4671
  const out = notes.length > 0 && DELIVERS3.includes(input.event) ? { context: notes.join("\n\n") } : {};
4414
4672
  return { stdout: `${JSON.stringify(out)}
@@ -4765,7 +5023,7 @@ function failedEntry(adapter, event, root, input, failure, error) {
4765
5023
  }
4766
5024
  function failClosed(adapter, event, root, error, stated = false) {
4767
5025
  if (event !== "before_tool") return "";
4768
- const reason = error instanceof PolicyIntegrityError || stated && error instanceof Error ? error.message : FAILED_CLOSED;
5026
+ const reason2 = error instanceof PolicyIntegrityError || stated && error instanceof Error ? error.message : FAILED_CLOSED;
4769
5027
  const input = {
4770
5028
  contract: 2,
4771
5029
  runtime: adapter.id,
@@ -4774,7 +5032,7 @@ function failClosed(adapter, event, root, error, stated = false) {
4774
5032
  cwd: root,
4775
5033
  projectRoot: root
4776
5034
  };
4777
- return adapter.render(input, { verdict: "deny", reason }).stdout;
5035
+ return adapter.render(input, { verdict: "deny", reason: reason2 }).stdout;
4778
5036
  }
4779
5037
 
4780
5038
  // src/hooks/entry/logger.ts
@@ -10,12 +10,12 @@ import {
10
10
  async function run(context) {
11
11
  const [verb = "list", ...extra] = context.args.positional;
12
12
  if (extra.length) throw new ArgumentError("Use hooks list or hooks test");
13
- if (verb === "list") return (await import("./list-TBCWXSK2.js")).run(context);
14
- if (verb === "test") return (await import("./test-NAVM6ZFB.js")).run(context);
13
+ if (verb === "list") return (await import("./list-6XGQ3FR3.js")).run(context);
14
+ if (verb === "test") return (await import("./test-2HTOY4PJ.js")).run(context);
15
15
  throw new ArgumentError("Use hooks list or hooks test");
16
16
  }
17
17
  var hooksCommand = { ...hooksSpec, run };
18
18
  export {
19
19
  hooksCommand
20
20
  };
21
- //# sourceMappingURL=hooks-PPUVHNN6.js.map
21
+ //# sourceMappingURL=hooks-FRZ4SUNJ.js.map