@modootoday/pmcp 0.22.2 → 0.22.4

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 (104) 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-AWZ32Z66.js → apply-D2VIRMFY.js} +13 -13
  6. package/dist/{broadcast-ZALGUJVR.js → broadcast-DZGMSZRG.js} +3 -3
  7. package/dist/{chunk-XZ2TDH3J.js → chunk-2A3F7ID4.js} +14 -5
  8. package/dist/{chunk-JP27V2H4.js → chunk-3IX5TBRW.js} +2 -2
  9. package/dist/{chunk-ZYLJUABY.js → chunk-5KA3RS5Y.js} +2 -2
  10. package/dist/{chunk-57Q75MS4.js → chunk-5QKXEWDB.js} +2 -2
  11. package/dist/{chunk-OMIIXLMO.js → chunk-7DYWCQVB.js} +1 -1
  12. package/dist/{chunk-MR5IBS6L.js → chunk-7I7O7ZNT.js} +41 -10
  13. package/dist/{chunk-U3IHGG7X.js → chunk-7XK2KWLJ.js} +3 -3
  14. package/dist/{chunk-7FV2LORT.js → chunk-B2WRYGHJ.js} +4 -3
  15. package/dist/{chunk-W6GA5RAW.js → chunk-CILQCERV.js} +2 -2
  16. package/dist/{chunk-5F7TL3V7.js → chunk-CPFJ7J4G.js} +6 -6
  17. package/dist/{chunk-NAXUAC5S.js → chunk-F34XIDXT.js} +2 -2
  18. package/dist/{chunk-NFJ44OE2.js → chunk-FE7WOHZM.js} +13 -4
  19. package/dist/{chunk-4Z6NPSWX.js → chunk-FFCDSSKA.js} +126 -37
  20. package/dist/{chunk-D2DDM5VZ.js → chunk-H45C5W2P.js} +2 -2
  21. package/dist/chunk-HOTGJQIV.js +7 -0
  22. package/dist/{chunk-G25LCRIG.js → chunk-JJT5XRMV.js} +2 -2
  23. package/dist/{chunk-SKOP4ZST.js → chunk-JONJ75SF.js} +5 -5
  24. package/dist/{chunk-GE2PHR35.js → chunk-KR6PFEWU.js} +3 -3
  25. package/dist/{chunk-U2NWTZQP.js → chunk-MIIGZRVC.js} +2 -2
  26. package/dist/{chunk-KLWZZTUQ.js → chunk-MTVRKWQI.js} +3 -3
  27. package/dist/{chunk-VGW3N3HC.js → chunk-NDY3T7Z4.js} +14 -14
  28. package/dist/{chunk-BUD3WS4Y.js → chunk-PFHSFYQB.js} +2 -2
  29. package/dist/{chunk-5A7QRZP6.js → chunk-QUBU3ETR.js} +5 -5
  30. package/dist/{chunk-KUBHGVTD.js → chunk-RRPNPZ6I.js} +16 -10
  31. package/dist/{chunk-GZQH3RJA.js → chunk-T7SLHAHQ.js} +3 -3
  32. package/dist/{chunk-FOIQUPIQ.js → chunk-TAVFL3YB.js} +2 -2
  33. package/dist/{chunk-T6MQPVLH.js → chunk-W4W3EHQP.js} +2 -2
  34. package/dist/{cli-6FWRBCWM.js → cli-34EDFXJA.js} +8 -8
  35. package/dist/{cli-BOSY6VFP.js → cli-VCKKTXUU.js} +6 -6
  36. package/dist/cli.js +3 -3
  37. package/dist/{completion-V756JVX6.js → completion-AAEBLVVB.js} +2 -2
  38. package/dist/{diagnostics-R7S3DNXD.js → diagnostics-3XI6SJXF.js} +5 -5
  39. package/dist/{doctor-44S5EWK5.js → doctor-GAJKPOKS.js} +14 -14
  40. package/dist/{entry-GSGCMXE5.js → entry-GZCLQTIN.js} +9 -9
  41. package/dist/{exec-mcp-3COXHDYT.js → exec-mcp-3V34UNPH.js} +10 -10
  42. package/dist/{harness-K4WL2NSH.js → harness-YH6U6MNV.js} +3 -3
  43. package/dist/harness-launch-gate.js +3 -3
  44. package/dist/harness-worker.js +5 -5
  45. package/dist/hook-body.js +281 -138
  46. package/dist/{hook-spec-hZL4MSgi.d.ts → hook-spec-Bd24eo2L.d.ts} +1 -0
  47. package/dist/{hooks-HQOLXR3A.js → hooks-JWB7D4ZB.js} +4 -4
  48. package/dist/{host-N5UILUK7.js → host-DLBXM72V.js} +6 -6
  49. package/dist/{host-4W3JUQAO.js → host-LNH3TUR5.js} +12 -12
  50. package/dist/{host-run-CVYRZB7R.js → host-run-FVO5PZK2.js} +4 -4
  51. package/dist/http.js +1 -1
  52. package/dist/{import-mcp-IAGC3LJU.js → import-mcp-O553FGF3.js} +9 -9
  53. package/dist/index.d.ts +2 -2
  54. package/dist/index.js +13 -13
  55. package/dist/{init-HPEVKKMU.js → init-A6AAIGJU.js} +2 -2
  56. package/dist/{invoke-TD5YR2G7.js → invoke-GDELKQCE.js} +7 -7
  57. package/dist/{list-YUHJ5CTT.js → list-CQ4CPNWI.js} +11 -11
  58. package/dist/{logout-JQ5UPC5W.js → logout-TG32MVMB.js} +10 -10
  59. package/dist/{logs-74JGLQG6.js → logs-UHJM7ZCL.js} +3 -3
  60. package/dist/{mailbox-VK5AVTHI.js → mailbox-NIMBOQPA.js} +3 -3
  61. package/dist/{mainline-7HO7RCQH.js → mainline-FMZ44NFC.js} +31 -14
  62. package/dist/{mcp-B6SYBT3X.js → mcp-UYQVTWEF.js} +2 -2
  63. package/dist/{pause-CZ2OZYLC.js → pause-CBZ3BTJL.js} +3 -3
  64. package/dist/project/hook-adapter.d.ts +1 -1
  65. package/dist/{project-GOW2MEFY.js → project-NOTN6SMK.js} +4 -4
  66. package/dist/{report-Z3JV2PCT.js → report-ZHOHQ4PZ.js} +3 -3
  67. package/dist/{resume-DFIHT2RO.js → resume-UJEWQ66P.js} +3 -3
  68. package/dist/{run-7UNRLLYD.js → run-77MDEDAX.js} +9 -9
  69. package/dist/{run-ZOSIKNDX.js → run-S5M6ZUUH.js} +4 -4
  70. package/dist/{serve-VRBL67KO.js → serve-YNHUW5PQ.js} +3 -3
  71. package/dist/{setup-QMYAW3MB.js → setup-HYEYYVDU.js} +3 -3
  72. package/dist/{smoke-EXPR7HLD.js → smoke-UA7VVDKD.js} +3 -3
  73. package/dist/{start-login-NRD323LK.js → start-login-SWQVPQG3.js} +10 -10
  74. package/dist/{status-3RTGDN2K.js → status-KN2ZE64O.js} +3 -3
  75. package/dist/{status-JN2GT5UM.js → status-NGO7AC3U.js} +12 -12
  76. package/dist/{status-ZY5B7V6R.js → status-YPFUSE7K.js} +10 -10
  77. package/dist/stdio.js +2 -2
  78. package/dist/{sweep-EPJMEZR6.js → sweep-EPZCW63Q.js} +3 -3
  79. package/dist/{test-VGJXKCQT.js → test-2UYV4LSU.js} +23 -16
  80. package/dist/{tui-GORRJIMA.js → tui-ZKP3D5JM.js} +4 -4
  81. package/dist/{unbroadcast-NTOC3PY3.js → unbroadcast-N6LXHAMT.js} +3 -3
  82. package/dist/{worker-LJG2NDMK.js → worker-7OBOBMWM.js} +7 -7
  83. package/dist/{worktree-list-EMKUMCTQ.js → worktree-list-6CCHXXOZ.js} +2 -2
  84. package/dist/{worktree-sync-A277AF4M.js → worktree-sync-5ZVA5PUC.js} +3 -3
  85. package/docs/commands.md +1 -1
  86. package/docs/git-workflow.md +7 -2
  87. package/docs/project-configuration.md +1 -0
  88. package/gemini-extension.json +2 -2
  89. package/mcp.json +1 -1
  90. package/package.json +5 -5
  91. package/plugin.json +1 -1
  92. package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
  93. package/plugins/pmcp/.mcp.json +1 -1
  94. package/plugins/pmcp/gemini-extension.json +2 -2
  95. package/plugins/pmcp/mcp.json +1 -1
  96. package/plugins/pmcp/mod/commands.ts +10 -4
  97. package/plugins/pmcp/mod/host.ts +17 -1
  98. package/plugins/pmcp/mod/reader/read.ts +3 -1
  99. package/plugins/pmcp/mod/reader/types.ts +2 -0
  100. package/plugins/pmcp/mod/register.tsx +2 -1
  101. package/plugins/pmcp/mod/snapshot.ts +1 -0
  102. package/plugins/pmcp/mod/state.ts +1 -0
  103. package/plugins/pmcp/plugin.json +1 -1
  104. package/dist/chunk-FWKQA6TX.js +0 -7
package/dist/hook-body.js CHANGED
@@ -259,13 +259,13 @@ function worktreesOf(checkout) {
259
259
  const found = [
260
260
  { path: dirname(checkout.commonDir), branch: branchOf(checkout.commonDir) }
261
261
  ];
262
- let names2 = [];
262
+ let names3 = [];
263
263
  try {
264
- names2 = readdirSync(join2(checkout.commonDir, "worktrees"));
264
+ names3 = readdirSync(join2(checkout.commonDir, "worktrees"));
265
265
  } catch {
266
266
  return found;
267
267
  }
268
- for (const name of names2) {
268
+ for (const name of names3) {
269
269
  const admin = join2(checkout.commonDir, "worktrees", name);
270
270
  try {
271
271
  const dotGit = readFileSync(join2(admin, "gitdir"), "utf8").trim();
@@ -324,12 +324,12 @@ function protectOffFile(input, file2) {
324
324
  if (!tool.steps) {
325
325
  return (tool.command ?? "").includes(file2) ? { verdict: "deny", reason: REASON } : {};
326
326
  }
327
- const names2 = tool.steps.some(
327
+ const names3 = tool.steps.some(
328
328
  (step) => !READ_ONLY.has(step.argv[0] ?? "") && step.raw.some(
329
329
  (word) => word === file2 || expandPath(resolve3(input.cwd, step.dir), word) === target
330
330
  )
331
331
  );
332
- return names2 ? { verdict: "deny", reason: REASON } : {};
332
+ return names3 ? { verdict: "deny", reason: REASON } : {};
333
333
  }
334
334
 
335
335
  // src/hooks/shell/tokenize.ts
@@ -741,11 +741,12 @@ async function runPolicy(selected, input, deps) {
741
741
  const { policy, mode } = selected;
742
742
  const log = deps.log.child({ policy: policy.id });
743
743
  const started = deps.now();
744
- const finish = (decision) => {
744
+ const finish = (decision, raw) => {
745
745
  deps.onPolicy?.({
746
746
  policy: policy.id,
747
747
  mode,
748
748
  decision,
749
+ ...raw ? { raw } : {},
749
750
  durationMs: deps.now() - started
750
751
  });
751
752
  return decision;
@@ -785,7 +786,7 @@ async function runPolicy(selected, input, deps) {
785
786
  ...input.tool ? { tool: input.tool.kind, native: input.tool.native } : {},
786
787
  duration_ms: deps.now() - started
787
788
  });
788
- return finish(decision);
789
+ return finish(decision, raw);
789
790
  } catch (error) {
790
791
  log.error("policy failed", {
791
792
  error: error instanceof Error ? error.message : String(error)
@@ -906,10 +907,10 @@ function bypasses(step, options2) {
906
907
  return options2.noVerify && name === "git" && step.argv.includes("--no-verify");
907
908
  }
908
909
  function fallback(command6, options2) {
909
- const names2 = options2.variables.map(escape);
910
- if (options2.noVerify) names2.push("--no-verify");
911
- if (names2.length === 0) return false;
912
- return new RegExp(`(?:^|[^\\w-])(?:${names2.join("|")})\\b`, "u").test(
910
+ const names3 = options2.variables.map(escape);
911
+ if (options2.noVerify) names3.push("--no-verify");
912
+ if (names3.length === 0) return false;
913
+ return new RegExp(`(?:^|[^\\w-])(?:${names3.join("|")})\\b`, "u").test(
913
914
  command6
914
915
  );
915
916
  }
@@ -2252,7 +2253,7 @@ function classEnd(pattern, start) {
2252
2253
  function patternCost(pattern, flavor, onlyMatching, limits) {
2253
2254
  const largest = Math.max(0, ...repetitionCounts(pattern, flavor));
2254
2255
  if (largest > limits.threshold)
2255
- return `a repetition count of ${largest} (the limit is ${limits.threshold})`;
2256
+ return `a repetition count of ${largest} (the limit is ${limits.threshold}), whose cost is in compiling the pattern, so even an empty input holds the core`;
2256
2257
  if (flavor === "perl" && nestedQuantifier(pattern))
2257
2258
  return "a -P pattern with a quantified group inside a quantifier, such as (a+)+ or (.*)*";
2258
2259
  if (limits.onlyMatchingWildcards && onlyMatching && (pattern.match(/\.\*/gu) ?? []).length > 1)
@@ -2717,8 +2718,8 @@ function claimants(store, session, root) {
2717
2718
  (record) => record.live && record.session !== session && record.worktree === root
2718
2719
  ).map((record) => record.alias || record.session.slice(0, 8));
2719
2720
  }
2720
- function claimantNotice(root, names2) {
2721
- return `Another live session works in ${root}: ${names2.join(", ")}. Edit only files that are yours, and name every path when you commit.`;
2721
+ function claimantNotice(root, names3) {
2722
+ return `Another live session works in ${root}: ${names3.join(", ")}. Edit only files that are yours, and name every path when you commit.`;
2722
2723
  }
2723
2724
 
2724
2725
  // src/hooks/policies/workspace/leftovers.ts
@@ -2866,47 +2867,10 @@ var sharedCheckout = {
2866
2867
  };
2867
2868
 
2868
2869
  // src/hooks/policies/workspace/mainline-deliver.ts
2869
- import { resolve as resolve9 } from "node:path";
2870
- var PUSH = /\bgit\b[^|;&\n]*\spush\b/u;
2871
- var REASON8 = "This repository's mainline moves only through pmcp git deliver, which replays, gates and pushes one delivery at a time. Commit, then run pmcp git deliver; other repositories push from their own directory.";
2872
- function sameRepository(dir, commonDir) {
2873
- return checkoutOf(dir)?.commonDir === commonDir;
2874
- }
2875
- var mainlineDeliver = {
2876
- id: "git.mainline.deliver",
2877
- events: ["before_tool"],
2878
- tools: ["shell"],
2879
- fail: "closed",
2880
- defaultMode: "deny",
2881
- options(raw) {
2882
- onlyKeys(raw, []);
2883
- return {};
2884
- },
2885
- evaluate(input) {
2886
- const call = shellCall(input);
2887
- const project6 = checkoutOf(input.projectRoot);
2888
- if (!call || !project6) return pass;
2889
- if (!call.steps) {
2890
- const hit2 = PUSH.test(call.command) && sameRepository(input.cwd, project6.commonDir);
2891
- return hit2 ? { verdict: "deny", reason: REASON8 } : pass;
2892
- }
2893
- for (const step of realSteps(call.steps)) {
2894
- if (program(step.argv[0]) !== "git") continue;
2895
- const git2 = gitCall(step.argv);
2896
- if (git2.sub !== "push") continue;
2897
- const dir = resolve9(input.cwd, step.dir, git2.dir);
2898
- if (sameRepository(dir, project6.commonDir))
2899
- return { verdict: "deny", reason: REASON8 };
2900
- }
2901
- return pass;
2902
- }
2903
- };
2904
-
2905
- // src/hooks/policies/workspace/worktree-sync.ts
2906
- import { relative as relative6, resolve as resolve11 } from "node:path";
2870
+ import { resolve as resolve10 } from "node:path";
2907
2871
 
2908
2872
  // src/git/detect.ts
2909
- import { dirname as dirname5, resolve as resolve10 } from "node:path";
2873
+ import { dirname as dirname5, resolve as resolve9 } from "node:path";
2910
2874
 
2911
2875
  // src/git/exec.ts
2912
2876
  var LOCAL_ENV = [
@@ -2986,11 +2950,11 @@ function detect(cwd, prefs = {}) {
2986
2950
  const remote = defaultRemote(root, prefs.remote);
2987
2951
  const mainline = defaultMainline(root, remote, prefs.mainline);
2988
2952
  return {
2989
- root: resolve10(root),
2990
- gitDir: resolve10(gitDir),
2991
- commonDir: resolve10(commonDir),
2992
- mainRoot: dirname5(resolve10(commonDir)),
2993
- linked: resolve10(gitDir) !== resolve10(commonDir),
2953
+ root: resolve9(root),
2954
+ gitDir: resolve9(gitDir),
2955
+ commonDir: resolve9(commonDir),
2956
+ mainRoot: dirname5(resolve9(commonDir)),
2957
+ linked: resolve9(gitDir) !== resolve9(commonDir),
2994
2958
  remote,
2995
2959
  mainline,
2996
2960
  upstream: `${remote}/${mainline}`,
@@ -2998,6 +2962,124 @@ function detect(cwd, prefs = {}) {
2998
2962
  };
2999
2963
  }
3000
2964
 
2965
+ // src/hooks/policies/workspace/mainline-deliver.ts
2966
+ var PUSH = /\bgit\b[^|;&\n]*\spush\b/u;
2967
+ var REASON8 = "This repository's mainline moves only through pmcp git deliver, which replays, gates and pushes one delivery at a time. Commit, then run pmcp git deliver; other branches, other remotes and other repositories push as usual.";
2968
+ var VALUE_OPTIONS = /* @__PURE__ */ new Set([
2969
+ "--repo",
2970
+ "--receive-pack",
2971
+ "--exec",
2972
+ "-o",
2973
+ "--push-option"
2974
+ ]);
2975
+ var EVERY_BRANCH = /* @__PURE__ */ new Set(["--all", "--branches", "--mirror"]);
2976
+ function sameRepository(dir, commonDir) {
2977
+ return checkoutOf(dir)?.commonDir === commonDir;
2978
+ }
2979
+ function gitText2(dir, args) {
2980
+ const run3 = spawnSync("git", ["-C", dir, ...args], {
2981
+ encoding: "utf8",
2982
+ timeout: 5e3
2983
+ });
2984
+ return run3.status === 0 ? run3.stdout.trim() : "";
2985
+ }
2986
+ function names2(ref, branch) {
2987
+ if (ref.includes("*")) return true;
2988
+ return [branch, `heads/${branch}`, `refs/heads/${branch}`].includes(ref);
2989
+ }
2990
+ function movesMainline(dir, args, options2) {
2991
+ const positional = [];
2992
+ let repo = "";
2993
+ for (let index = 0; index < args.length; index += 1) {
2994
+ const word = args[index];
2995
+ if (word === "--") {
2996
+ positional.push(...args.slice(index + 1));
2997
+ break;
2998
+ }
2999
+ if (!word.startsWith("-") || word === "-") {
3000
+ positional.push(word);
3001
+ continue;
3002
+ }
3003
+ const option = word.split("=")[0];
3004
+ if (option === "-n" || option === "--dry-run") return false;
3005
+ if (/^-[a-zA-Z]+$/u.test(word) && word.includes("n")) return false;
3006
+ if (EVERY_BRANCH.has(option)) return true;
3007
+ if (VALUE_OPTIONS.has(option) && !word.includes("=")) {
3008
+ if (option === "--repo") repo = args[index + 1] ?? "";
3009
+ index += 1;
3010
+ continue;
3011
+ }
3012
+ if (option === "--repo") repo = word.slice("--repo=".length);
3013
+ }
3014
+ const ctx = detect(dir, {
3015
+ ...options2.remote ? { remote: options2.remote } : {},
3016
+ ...options2.branch ? { mainline: options2.branch } : {}
3017
+ });
3018
+ const remote = options2.remote ?? ctx?.remote ?? "origin";
3019
+ const branch = options2.branch ?? ctx?.mainline ?? "main";
3020
+ const target = positional[0] ?? repo;
3021
+ if (target && target !== remote && /^[\w.-]+$/u.test(target)) return false;
3022
+ const current = gitText2(dir, ["symbolic-ref", "--short", "-q", "HEAD"]);
3023
+ const refspecs = positional.slice(1);
3024
+ if (refspecs.length === 0) {
3025
+ if (!current) return false;
3026
+ const upstream = gitText2(dir, [
3027
+ "rev-parse",
3028
+ "--abbrev-ref",
3029
+ "--symbolic-full-name",
3030
+ "@{upstream}"
3031
+ ]);
3032
+ return current === branch || upstream === `${remote}/${branch}`;
3033
+ }
3034
+ return refspecs.some((spec) => {
3035
+ const plain = spec.replace(/^\+/u, "");
3036
+ const colon = plain.indexOf(":");
3037
+ let dst = colon < 0 ? plain : plain.slice(colon + 1) || plain.slice(0, colon);
3038
+ if (dst === "HEAD" || dst === "@") dst = current;
3039
+ return dst !== "" && names2(dst, branch);
3040
+ });
3041
+ }
3042
+ var mainlineDeliver = {
3043
+ id: "git.mainline.deliver",
3044
+ events: ["before_tool"],
3045
+ tools: ["shell"],
3046
+ fail: "closed",
3047
+ defaultMode: "deny",
3048
+ options(raw) {
3049
+ onlyKeys(raw, ["remote", "branch"]);
3050
+ const text9 = (key) => {
3051
+ const value = raw[key];
3052
+ if (value === void 0) return {};
3053
+ if (typeof value !== "string" || value === "")
3054
+ throw new Error(`${key} must be a name`);
3055
+ return { [key]: value };
3056
+ };
3057
+ return { ...text9("remote"), ...text9("branch") };
3058
+ },
3059
+ evaluate(input, ctx) {
3060
+ const call = shellCall(input);
3061
+ const project6 = checkoutOf(input.projectRoot);
3062
+ if (!call || !project6) return pass;
3063
+ if (!call.steps) {
3064
+ const hit2 = PUSH.test(call.command) && sameRepository(input.cwd, project6.commonDir);
3065
+ return hit2 ? { verdict: "deny", reason: REASON8 } : pass;
3066
+ }
3067
+ for (const step of realSteps(call.steps)) {
3068
+ if (program(step.argv[0]) !== "git") continue;
3069
+ const git2 = gitCall(step.argv);
3070
+ if (git2.sub !== "push") continue;
3071
+ const dir = resolve10(input.cwd, step.dir, git2.dir);
3072
+ if (!sameRepository(dir, project6.commonDir)) continue;
3073
+ if (movesMainline(dir, step.argv.slice(git2.at + 1), ctx.options))
3074
+ return { verdict: "deny", reason: REASON8 };
3075
+ }
3076
+ return pass;
3077
+ }
3078
+ };
3079
+
3080
+ // src/hooks/policies/workspace/worktree-sync.ts
3081
+ import { relative as relative6, resolve as resolve11 } from "node:path";
3082
+
3001
3083
  // src/git/modes.ts
3002
3084
  import { join as join6 } from "node:path";
3003
3085
  function withUmask(mask, run3) {
@@ -3179,8 +3261,18 @@ function pinsSuperseded(cwd, upstream, sha) {
3179
3261
  }
3180
3262
 
3181
3263
  // src/git/landed.ts
3264
+ var GitReadError = class extends Error {
3265
+ };
3266
+ function read3(cwd, args) {
3267
+ const run3 = git(cwd, args);
3268
+ if (run3.status !== 0)
3269
+ throw new GitReadError(
3270
+ `git ${args.join(" ")} failed (exit ${run3.status}); nothing was chosen: ${run3.stderr.trim()}`
3271
+ );
3272
+ return run3.stdout;
3273
+ }
3182
3274
  function cherry(cwd, upstream, head = "HEAD") {
3183
- const listed = git(cwd, ["cherry", "-v", upstream, head]).stdout;
3275
+ const listed = read3(cwd, ["cherry", "-v", upstream, head]);
3184
3276
  const carried = [];
3185
3277
  const missing = [];
3186
3278
  for (const line of listed.split("\n")) {
@@ -3249,15 +3341,23 @@ function updateToPins(root, paths) {
3249
3341
 
3250
3342
  // src/git/worktrees/sync.ts
3251
3343
  function heldBy(root, upstream, ahead) {
3252
- const dirty = gitText(root, [
3344
+ const status = git(root, [
3253
3345
  "status",
3254
3346
  "--porcelain",
3255
3347
  "--untracked-files=no",
3256
3348
  "--ignore-submodules=all"
3257
3349
  ]);
3258
- if (dirty) return "uncommitted changes";
3350
+ if (status.status !== 0)
3351
+ return `git status failed (exit ${status.status}): ${status.stderr.trim()}`;
3352
+ if (status.stdout.trim()) return "uncommitted changes";
3259
3353
  if (ahead === 0) return null;
3260
- const own = cherry(root, upstream).missing.length;
3354
+ let own;
3355
+ try {
3356
+ own = cherry(root, upstream).missing.length;
3357
+ } catch (error) {
3358
+ if (error instanceof GitReadError) return error.message;
3359
+ throw error;
3360
+ }
3261
3361
  if (own > 0) return `${own} unlanded commit(s)`;
3262
3362
  return null;
3263
3363
  }
@@ -3908,8 +4008,8 @@ function toolKind2(name) {
3908
4008
  }
3909
4009
  function matcherFor(tools) {
3910
4010
  if (tools.includes("other")) return void 0;
3911
- const names2 = Object.entries(TOOL_KINDS2).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
3912
- return names2.length > 0 ? names2.join("|") : void 0;
4011
+ const names3 = Object.entries(TOOL_KINDS2).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
4012
+ return names3.length > 0 ? names3.join("|") : void 0;
3913
4013
  }
3914
4014
 
3915
4015
  // src/hooks/runtimes/claude/output.ts
@@ -4165,8 +4265,8 @@ function toolKind3(name) {
4165
4265
  }
4166
4266
  function matcherFor2(tools) {
4167
4267
  if (tools.includes("other")) return void 0;
4168
- const names2 = Object.entries(TOOL_KINDS3).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
4169
- return names2.length > 0 ? names2.join("|") : void 0;
4268
+ const names3 = Object.entries(TOOL_KINDS3).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
4269
+ return names3.length > 0 ? names3.join("|") : void 0;
4170
4270
  }
4171
4271
 
4172
4272
  // src/hooks/runtimes/codex/output.ts
@@ -4406,8 +4506,8 @@ function toolKind4(name) {
4406
4506
  }
4407
4507
  function matcherFor3(tools) {
4408
4508
  if (tools.includes("other")) return void 0;
4409
- const names2 = Object.entries(TOOL_KINDS4).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
4410
- return names2.length > 0 ? `^(${names2.join("|")})$` : void 0;
4509
+ const names3 = Object.entries(TOOL_KINDS4).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
4510
+ return names3.length > 0 ? `^(${names3.join("|")})$` : void 0;
4411
4511
  }
4412
4512
 
4413
4513
  // src/hooks/runtimes/gemini/output.ts
@@ -5412,14 +5512,14 @@ function fileSink(target) {
5412
5512
  };
5413
5513
  }
5414
5514
  function logFiles(dir) {
5415
- let names2 = [];
5515
+ let names3 = [];
5416
5516
  try {
5417
- names2 = readdirSync(dir).filter((name) => FILE.test(name));
5517
+ names3 = readdirSync(dir).filter((name) => FILE.test(name));
5418
5518
  } catch {
5419
5519
  return [];
5420
5520
  }
5421
5521
  const part = (name) => Number(/\.(\d+)\.jsonl$/u.exec(name)?.[1] ?? Number.MAX_SAFE_INTEGER);
5422
- return names2.sort(
5522
+ return names3.sort(
5423
5523
  (a, b) => a.slice(5, 13).localeCompare(b.slice(5, 13)) || part(a) - part(b)
5424
5524
  ).map((name) => join14(dir, name));
5425
5525
  }
@@ -5474,13 +5574,73 @@ function hookLogger(root, compiled, runtime2, event) {
5474
5574
  }
5475
5575
 
5476
5576
  // src/hooks/entry/state-dir.ts
5477
- function stateDirAnswer(root) {
5478
- let declared;
5577
+ import { join as join18 } from "node:path";
5578
+
5579
+ // src/sessions/lease-files.ts
5580
+ import { dirname as dirname9, isAbsolute as isAbsolute13, join as join17 } from "node:path";
5581
+ var GATE_DIR = "${gate_dir}/";
5582
+ function gateTree(root, stateDir, gate, env) {
5583
+ const override = gate.treeEnv ? env[gate.treeEnv] : void 0;
5584
+ if (override) return override;
5585
+ return gate.tree ? expandPath(root, gate.tree) : join17(stateDir, "gate", "tree");
5586
+ }
5587
+ function atGateDir(path, gateDir) {
5588
+ return path.startsWith(GATE_DIR) ? join17(gateDir, path.slice(GATE_DIR.length)) : path;
5589
+ }
5590
+ function resolvePauseFile(file2, gateDir) {
5591
+ return file2 === void 0 ? void 0 : atGateDir(file2, gateDir);
5592
+ }
5593
+ function resolveLeaseFiles(files2, gateDir) {
5594
+ const resolve21 = (path) => path === void 0 ? void 0 : atGateDir(path, gateDir);
5595
+ return Object.fromEntries(
5596
+ Object.entries(files2 ?? {}).map(([name, f]) => {
5597
+ const file2 = resolve21(f.file);
5598
+ const events2 = resolve21(f.events);
5599
+ return [
5600
+ name,
5601
+ { ...file2 ? { file: file2 } : {}, ...events2 ? { events: events2 } : {} }
5602
+ ];
5603
+ })
5604
+ );
5605
+ }
5606
+ function leaseFilesFor(root, stateDir, files2, gate, env) {
5607
+ if (!files2 || Object.keys(files2).length === 0) return {};
5608
+ return resolveLeaseFiles(
5609
+ files2,
5610
+ dirname9(gateTree(root, stateDir, gate ?? {}, env))
5611
+ );
5612
+ }
5613
+ function pauseFileFor(root, stateDir, file2, gate, env) {
5614
+ if (!file2) return void 0;
5615
+ return resolvePauseFile(
5616
+ file2,
5617
+ dirname9(gateTree(root, stateDir, gate ?? {}, env))
5618
+ );
5619
+ }
5620
+
5621
+ // src/hooks/entry/state-dir.ts
5622
+ function verified(root) {
5479
5623
  try {
5480
- declared = readCompiled(root).stateDir;
5624
+ return readCompiled(root);
5481
5625
  } catch {
5626
+ return null;
5482
5627
  }
5483
- return `${projectStateDir(root, declared)}
5628
+ }
5629
+ function stateDirAnswer(root) {
5630
+ return `${projectStateDir(root, verified(root)?.stateDir)}
5631
+ `;
5632
+ }
5633
+ function pauseFileAnswer(root) {
5634
+ const compiled = verified(root);
5635
+ const stateDir = projectStateDir(root, compiled?.stateDir);
5636
+ const file2 = pauseFileFor(
5637
+ root,
5638
+ stateDir,
5639
+ compiled?.sessions.pauseFile,
5640
+ compiled?.sessions.gate,
5641
+ process.env
5642
+ );
5643
+ return `${file2 ?? join18(stateDir, STATE_FILES.pause)}
5484
5644
  `;
5485
5645
  }
5486
5646
 
@@ -5518,10 +5678,10 @@ var gitProbe = {
5518
5678
  };
5519
5679
 
5520
5680
  // src/sessions/files/broadcast.ts
5521
- import { join as join17 } from "node:path";
5681
+ import { join as join19 } from "node:path";
5522
5682
 
5523
5683
  // src/sessions/files/json.ts
5524
- import { dirname as dirname9 } from "node:path";
5684
+ import { dirname as dirname10 } from "node:path";
5525
5685
  function readJson3(path) {
5526
5686
  try {
5527
5687
  return JSON.parse(readFileSync(path, "utf8"));
@@ -5530,7 +5690,7 @@ function readJson3(path) {
5530
5690
  }
5531
5691
  }
5532
5692
  function writeJson(path, value) {
5533
- mkdirSync(dirname9(path), { recursive: true, mode: 448 });
5693
+ mkdirSync(dirname10(path), { recursive: true, mode: 448 });
5534
5694
  const temporary = `${path}.${process.pid}.tmp`;
5535
5695
  writeFileSync(temporary, `${JSON.stringify(value, null, 2)}
5536
5696
  `, {
@@ -5554,7 +5714,7 @@ function readLines(path) {
5554
5714
  });
5555
5715
  }
5556
5716
  function writeLines(path, values) {
5557
- mkdirSync(dirname9(path), { recursive: true, mode: 448 });
5717
+ mkdirSync(dirname10(path), { recursive: true, mode: 448 });
5558
5718
  writeFileSync(
5559
5719
  path,
5560
5720
  `${values.map((value) => JSON.stringify(value)).join("\n")}
@@ -5565,8 +5725,8 @@ function writeLines(path, values) {
5565
5725
 
5566
5726
  // src/sessions/files/broadcast.ts
5567
5727
  function filesBroadcast(dir, keep, registry2) {
5568
- const latestPath = join17(dir, STATE_FILES.broadcast);
5569
- const historyPath = join17(dir, STATE_FILES.history);
5728
+ const latestPath = join19(dir, STATE_FILES.broadcast);
5729
+ const historyPath = join19(dir, STATE_FILES.history);
5570
5730
  const list = () => {
5571
5731
  const latest = asBroadcast(readJson3(latestPath));
5572
5732
  if (!latest) return [];
@@ -5610,16 +5770,16 @@ function filesBroadcast(dir, keep, registry2) {
5610
5770
  }
5611
5771
 
5612
5772
  // src/sessions/files/leases.ts
5613
- import { dirname as dirname10, join as join18 } from "node:path";
5773
+ import { dirname as dirname11, join as join20 } from "node:path";
5614
5774
  function filesLeases(dir, files2 = {}) {
5615
- const leasePath = (name) => files2[name]?.file ?? join18(dir, leaseFile(name));
5616
- const read3 = (name) => {
5775
+ const leasePath = (name) => files2[name]?.file ?? join20(dir, leaseFile(name));
5776
+ const read4 = (name) => {
5617
5777
  const lease = asLease(readJson3(leasePath(name)));
5618
5778
  if (!lease || !alive(lease.pid)) return null;
5619
5779
  return lease;
5620
5780
  };
5621
5781
  return {
5622
- read: read3,
5782
+ read: read4,
5623
5783
  // Atomic against another process taking the same file (another tool may share it): the
5624
5784
  // record is linked into place, and a dead holder's record is replaced and then re-read, so
5625
5785
  // of two takers replacing it at once only the one whose record stays holds the lease.
@@ -5632,7 +5792,7 @@ function filesLeases(dir, files2 = {}) {
5632
5792
  ...lease.cwd ? { cwd: lease.cwd } : {},
5633
5793
  since: (/* @__PURE__ */ new Date()).toISOString()
5634
5794
  };
5635
- mkdirSync(dirname10(path), { recursive: true });
5795
+ mkdirSync(dirname11(path), { recursive: true });
5636
5796
  const temp = `${path}.${process.pid}.${Date.now()}.tmp`;
5637
5797
  writeFileSync(temp, `${JSON.stringify(record)}
5638
5798
  `);
@@ -5643,7 +5803,7 @@ function filesLeases(dir, files2 = {}) {
5643
5803
  } catch (error) {
5644
5804
  if (error.code !== "EEXIST") throw error;
5645
5805
  }
5646
- const held = read3(name);
5806
+ const held = read4(name);
5647
5807
  if (held && held.pid !== pid) return false;
5648
5808
  renameSync(temp, path);
5649
5809
  return asLease(readJson3(path))?.pid === pid;
@@ -5662,28 +5822,28 @@ function filesLeases(dir, files2 = {}) {
5662
5822
  }
5663
5823
 
5664
5824
  // src/sessions/files/mailbox.ts
5665
- import { join as join19 } from "node:path";
5825
+ import { join as join21 } from "node:path";
5666
5826
  var ID = /^\d{13}-[0-9a-f]{8}$/u;
5667
5827
  var SAFE_KEY = /^@?[\w.-]+$/u;
5668
5828
  function filesMailbox(dir, settings) {
5669
- const messages = join19(dir, "messages");
5670
- const inbox = join19(dir, "inbox");
5671
- const pathOf = (id) => join19(messages, `${id}.json`);
5829
+ const messages = join21(dir, "messages");
5830
+ const inbox = join21(dir, "inbox");
5831
+ const pathOf = (id) => join21(messages, `${id}.json`);
5672
5832
  const marker = (key, id, kind) => {
5673
5833
  if (!SAFE_KEY.test(key) || !ID.test(id))
5674
5834
  throw new Error(`invalid mailbox key ${key} or id ${id}`);
5675
- return join19(inbox, key, `${id}.${kind}`);
5835
+ return join21(inbox, key, `${id}.${kind}`);
5676
5836
  };
5677
5837
  const audit = (event, fields2) => {
5678
5838
  if (!settings.audit) return;
5679
5839
  const line = { at: (/* @__PURE__ */ new Date()).toISOString(), event, ...fields2 };
5680
- appendFileSync(join19(dir, "messages.jsonl"), `${JSON.stringify(line)}
5840
+ appendFileSync(join21(dir, "messages.jsonl"), `${JSON.stringify(line)}
5681
5841
  `, {
5682
5842
  mode: 384
5683
5843
  });
5684
5844
  };
5685
5845
  const touch = (path) => {
5686
- mkdirSync(join19(path, ".."), { recursive: true, mode: 448 });
5846
+ mkdirSync(join21(path, ".."), { recursive: true, mode: 448 });
5687
5847
  try {
5688
5848
  writeFileSync(path, "", { flag: "wx", mode: 384 });
5689
5849
  return true;
@@ -5700,7 +5860,7 @@ function filesMailbox(dir, settings) {
5700
5860
  if (existsSync(inbox))
5701
5861
  for (const key of readdirSync(inbox))
5702
5862
  for (const kind of ["ack", "delivered"])
5703
- rmSync(join19(inbox, key, `${message.id}.${kind}`), { force: true });
5863
+ rmSync(join21(inbox, key, `${message.id}.${kind}`), { force: true });
5704
5864
  audit(event, { id: message.id });
5705
5865
  };
5706
5866
  return {
@@ -5776,9 +5936,9 @@ function filesMailbox(dir, settings) {
5776
5936
  }
5777
5937
 
5778
5938
  // src/sessions/files/pause.ts
5779
- import { join as join20 } from "node:path";
5780
- function filesPause(dir) {
5781
- const path = join20(dir, STATE_FILES.pause);
5939
+ import { join as join22 } from "node:path";
5940
+ function filesPause(dir, file2) {
5941
+ const path = file2 ?? join22(dir, STATE_FILES.pause);
5782
5942
  return {
5783
5943
  read: () => asPause(readJson3(path)),
5784
5944
  write(pause2) {
@@ -5796,12 +5956,12 @@ function filesPause(dir) {
5796
5956
  }
5797
5957
 
5798
5958
  // src/sessions/files/registry.ts
5799
- import { join as join21 } from "node:path";
5959
+ import { join as join23 } from "node:path";
5800
5960
  var SESSION_ID = /^[A-Za-z0-9_-]{8,64}$/u;
5801
5961
  function filesRegistry(dir, staleMs) {
5802
- const records = join21(dir, STATE_FILES.records);
5803
- const dirs = [records, join21(dir, STATE_FILES.legacyRecords)];
5804
- const pathsOf = (session) => dirs.map((records2) => join21(records2, `${session}.json`));
5962
+ const records = join23(dir, STATE_FILES.records);
5963
+ const dirs = [records, join23(dir, STATE_FILES.legacyRecords)];
5964
+ const pathsOf = (session) => dirs.map((records2) => join23(records2, `${session}.json`));
5805
5965
  const get = (session) => {
5806
5966
  if (!SESSION_ID.test(session)) return null;
5807
5967
  return latestRecord(
@@ -5811,16 +5971,16 @@ function filesRegistry(dir, staleMs) {
5811
5971
  const list = (now = Date.now()) => {
5812
5972
  const found = /* @__PURE__ */ new Map();
5813
5973
  for (const folder of dirs) {
5814
- let names2 = [];
5974
+ let names3 = [];
5815
5975
  try {
5816
- names2 = readdirSync(folder).filter((name) => name.endsWith(".json"));
5976
+ names3 = readdirSync(folder).filter((name) => name.endsWith(".json"));
5817
5977
  } catch {
5818
5978
  continue;
5819
5979
  }
5820
- for (const name of names2)
5980
+ for (const name of names3)
5821
5981
  found.set(name, [
5822
5982
  ...found.get(name) ?? [],
5823
- asRecord(readJson3(join21(folder, name)))
5983
+ asRecord(readJson3(join23(folder, name)))
5824
5984
  ]);
5825
5985
  }
5826
5986
  return [...found.values()].map(latestRecord).filter((record) => record !== null).map((record) => ({ ...record, live: isLive(record, now, staleMs) }));
@@ -5847,7 +6007,7 @@ function filesRegistry(dir, staleMs) {
5847
6007
  next["worktree"] = checkout?.root ?? "";
5848
6008
  next["branch"] = checkout?.branch ?? "";
5849
6009
  }
5850
- writeJson(join21(records, `${session}.json`), next);
6010
+ writeJson(join23(records, `${session}.json`), next);
5851
6011
  return next;
5852
6012
  },
5853
6013
  sweep(now = Date.now()) {
@@ -5872,7 +6032,7 @@ function createFilesStore(dir, options2 = {}) {
5872
6032
  return {
5873
6033
  dir,
5874
6034
  registry: registry2,
5875
- pause: filesPause(dir),
6035
+ pause: filesPause(dir, options2.pauseFile),
5876
6036
  leases: filesLeases(dir, options2.leaseFiles),
5877
6037
  // With the mailbox on, a broadcast is also a message to all, which the mailbox delivers;
5878
6038
  // broadcast.json stays the record status, snapshot and the Claude band read.
@@ -5897,41 +6057,16 @@ function createFilesStore(dir, options2 = {}) {
5897
6057
  };
5898
6058
  }
5899
6059
 
5900
- // src/sessions/lease-files.ts
5901
- import { dirname as dirname11, isAbsolute as isAbsolute13, join as join22 } from "node:path";
5902
- var GATE_DIR = "${gate_dir}/";
5903
- function gateTree(root, stateDir, gate, env) {
5904
- const override = gate.treeEnv ? env[gate.treeEnv] : void 0;
5905
- if (override) return override;
5906
- return gate.tree ? expandPath(root, gate.tree) : join22(stateDir, "gate", "tree");
5907
- }
5908
- function resolveLeaseFiles(files2, gateDir) {
5909
- const resolve21 = (path) => path?.startsWith(GATE_DIR) ? join22(gateDir, path.slice(GATE_DIR.length)) : path;
5910
- return Object.fromEntries(
5911
- Object.entries(files2 ?? {}).map(([name, f]) => {
5912
- const file2 = resolve21(f.file);
5913
- const events2 = resolve21(f.events);
5914
- return [
5915
- name,
5916
- { ...file2 ? { file: file2 } : {}, ...events2 ? { events: events2 } : {} }
5917
- ];
5918
- })
5919
- );
5920
- }
5921
- function leaseFilesFor(root, stateDir, files2, gate, env) {
5922
- if (!files2 || Object.keys(files2).length === 0) return {};
5923
- return resolveLeaseFiles(
5924
- files2,
5925
- dirname11(gateTree(root, stateDir, gate ?? {}, env))
5926
- );
5927
- }
5928
-
5929
6060
  // src/hooks/entry.ts
5930
6061
  async function main(argv, root) {
5931
6062
  if (argv[0] === "--state-dir") {
5932
6063
  writeStdout(stateDirAnswer(root));
5933
6064
  return 0;
5934
6065
  }
6066
+ if (argv[0] === "--pause-file") {
6067
+ writeStdout(pauseFileAnswer(root));
6068
+ return 0;
6069
+ }
5935
6070
  const projected = runtime(argv[0] ?? "");
5936
6071
  const event = argv[1];
5937
6072
  if (!projected || !NEUTRAL_EVENTS.includes(event) || !projected.nativeEvent(event)) {
@@ -5959,6 +6094,13 @@ async function main(argv, root) {
5959
6094
  if (!input) return pass2();
5960
6095
  const run3 = log.child({ session: input.session.id });
5961
6096
  const stateDir = projectStateDir(root, compiled.stateDir);
6097
+ const pauseFile = pauseFileFor(
6098
+ root,
6099
+ stateDir,
6100
+ compiled.sessions.pauseFile,
6101
+ compiled.sessions.gate,
6102
+ process.env
6103
+ );
5962
6104
  const store = createFilesStore(stateDir, {
5963
6105
  ...compiled.sessions,
5964
6106
  leaseFiles: leaseFilesFor(
@@ -5967,7 +6109,8 @@ async function main(argv, root) {
5967
6109
  compiled.sessions.leaseFiles,
5968
6110
  compiled.sessions.gate,
5969
6111
  process.env
5970
- )
6112
+ ),
6113
+ ...pauseFile ? { pauseFile } : {}
5971
6114
  });
5972
6115
  const decision = await dispatch(input, compiled, {
5973
6116
  log: run3,