@modootoday/pmcp 0.22.3 → 0.22.6

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 (82) 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-CYVC5LDG.js → apply-IQU3K5TB.js} +13 -13
  6. package/dist/{chunk-WPX4ONFT.js → chunk-3HEYCZFZ.js} +5 -5
  7. package/dist/{chunk-KUBHGVTD.js → chunk-42SO7KYX.js} +17 -11
  8. package/dist/chunk-4EQIZQX2.js +7 -0
  9. package/dist/{chunk-7LUYI7QM.js → chunk-5JWCGSZD.js} +2 -2
  10. package/dist/{chunk-FE7WOHZM.js → chunk-7CSUKCU7.js} +2 -2
  11. package/dist/{chunk-CALWIRAI.js → chunk-AOHHCYRF.js} +12 -12
  12. package/dist/{chunk-G7JONWL4.js → chunk-B3OZ4GGO.js} +13 -1
  13. package/dist/{chunk-RZZZHQCE.js → chunk-CLE6VHO6.js} +2 -2
  14. package/dist/{chunk-ICZH4NFR.js → chunk-E4X6GSNI.js} +5 -5
  15. package/dist/{chunk-PR2RBEXI.js → chunk-G6QFWOLV.js} +2 -2
  16. package/dist/{chunk-7Q3AIS4Q.js → chunk-GSU22DYJ.js} +2 -2
  17. package/dist/{chunk-MZF7VOQA.js → chunk-H4Z2AIXM.js} +2 -2
  18. package/dist/{chunk-UQNRGU3V.js → chunk-JN7TRPFB.js} +2 -2
  19. package/dist/{chunk-HV52EUSL.js → chunk-JUEMDWWJ.js} +4 -4
  20. package/dist/{chunk-ONYZIC2F.js → chunk-KFMHTOSI.js} +3 -3
  21. package/dist/{chunk-ULFV3EIZ.js → chunk-KTANZVAJ.js} +2 -2
  22. package/dist/{chunk-P6LNYYYH.js → chunk-M6X6HVQK.js} +2 -2
  23. package/dist/{chunk-XZ2TDH3J.js → chunk-PCSE36BM.js} +97 -14
  24. package/dist/{chunk-ESCOMAPX.js → chunk-PX4FWUEN.js} +3 -3
  25. package/dist/{chunk-MQMWVJZB.js → chunk-RZNZKI5A.js} +2 -2
  26. package/dist/{chunk-JUG4W7RF.js → chunk-SLL5FSDI.js} +2 -2
  27. package/dist/{chunk-2Q6MNGU5.js → chunk-SUDG7B6S.js} +2 -2
  28. package/dist/{chunk-V7LZTVWS.js → chunk-TBVQ7SM7.js} +2 -2
  29. package/dist/{chunk-NQFULJZC.js → chunk-TPTKRLI7.js} +3 -3
  30. package/dist/{chunk-MLGXDSHZ.js → chunk-WV3YP35O.js} +124 -37
  31. package/dist/{cli-A6HKRICM.js → cli-DYVNJYZ7.js} +8 -8
  32. package/dist/cli.js +3 -3
  33. package/dist/{completion-FDLVWLAC.js → completion-ORGJMKIY.js} +2 -2
  34. package/dist/{diagnostics-DYLW7WYV.js → diagnostics-TLKMQGMH.js} +5 -5
  35. package/dist/{doctor-FRQ5H5FU.js → doctor-27ZFI6JY.js} +15 -15
  36. package/dist/{entry-XPZZNQ4L.js → entry-T3HFGNC2.js} +9 -9
  37. package/dist/{exec-mcp-HOM2ZANM.js → exec-mcp-IZYZI2KM.js} +11 -11
  38. package/dist/{harness-WIGJRE5P.js → harness-DSB275UL.js} +3 -3
  39. package/dist/harness-launch-gate.js +3 -3
  40. package/dist/harness-worker.js +5 -5
  41. package/dist/hook-body.js +312 -131
  42. package/dist/{hooks-MIF3FONJ.js → hooks-UN4LMHZW.js} +3 -3
  43. package/dist/{host-JKZLOCZS.js → host-5M4RWFKB.js} +6 -6
  44. package/dist/{host-CE5TW5SC.js → host-X4WU2J3Z.js} +13 -13
  45. package/dist/{host-run-MJGJ7NVE.js → host-run-A64IXBGN.js} +4 -4
  46. package/dist/http.js +1 -1
  47. package/dist/{import-mcp-T3GZYEE5.js → import-mcp-PYX5OKQQ.js} +10 -10
  48. package/dist/index.d.ts +1 -1
  49. package/dist/index.js +14 -14
  50. package/dist/{init-D5VPDF2B.js → init-QUN7QS2K.js} +2 -2
  51. package/dist/{invoke-HEAOQLFQ.js → invoke-FGOUHWVB.js} +7 -7
  52. package/dist/{list-PCLCFG2J.js → list-5YUAOTM7.js} +12 -12
  53. package/dist/{logout-3ZXFXKHB.js → logout-PAODLQ5M.js} +11 -11
  54. package/dist/{mainline-6CTSVOWP.js → mainline-CRL5B3X3.js} +44 -12
  55. package/dist/{mcp-T6PYHRUL.js → mcp-WUUKG3JV.js} +2 -2
  56. package/dist/{modes-COBVV7RA.js → modes-SEINLLMK.js} +3 -3
  57. package/dist/{project-H4R3Q3QO.js → project-HY6O6DZQ.js} +4 -4
  58. package/dist/{run-V74M7PZK.js → run-55L6MVBR.js} +10 -10
  59. package/dist/{run-FMTHUOAZ.js → run-ZLIZZC2I.js} +4 -4
  60. package/dist/{serve-JKNEC4AX.js → serve-HKBA6OSF.js} +3 -3
  61. package/dist/{setup-HYEYYVDU.js → setup-SOUBEZ3H.js} +4 -4
  62. package/dist/{start-login-JRMVLK5J.js → start-login-VRH4OLKM.js} +11 -11
  63. package/dist/{status-6273XFHT.js → status-6JX7PKQ3.js} +11 -11
  64. package/dist/{status-RG2GFDQU.js → status-CZG6ZPUG.js} +12 -12
  65. package/dist/stdio.js +2 -2
  66. package/dist/{test-M365FK5N.js → test-22FIZGYO.js} +11 -11
  67. package/dist/{tui-PKPYE76A.js → tui-JUEU727K.js} +4 -4
  68. package/dist/{worker-C23EAPCY.js → worker-T7ERD4L7.js} +7 -7
  69. package/dist/{worktree-create-NO4UOOEP.js → worktree-create-KMXPQXIQ.js} +2 -2
  70. package/dist/{worktree-list-EMKUMCTQ.js → worktree-list-WH6OX6U7.js} +4 -4
  71. package/dist/{worktree-sync-A277AF4M.js → worktree-sync-VWNOJD63.js} +5 -5
  72. package/docs/git-workflow.md +13 -2
  73. package/gemini-extension.json +2 -2
  74. package/mcp.json +1 -1
  75. package/package.json +5 -5
  76. package/plugin.json +1 -1
  77. package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
  78. package/plugins/pmcp/.mcp.json +1 -1
  79. package/plugins/pmcp/gemini-extension.json +2 -2
  80. package/plugins/pmcp/mcp.json +1 -1
  81. package/plugins/pmcp/plugin.json +1 -1
  82. package/dist/chunk-JTRFZQTB.js +0 -7
package/dist/hook-body.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/hooks/entry.ts
2
- import { dirname as dirname12, resolve as resolve20 } from "node:path";
2
+ import { dirname as dirname13, resolve as resolve20 } from "node:path";
3
3
 
4
4
  // src/hooks/contract.ts
5
5
  var NEUTRAL_EVENTS = [
@@ -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
@@ -907,10 +907,10 @@ function bypasses(step, options2) {
907
907
  return options2.noVerify && name === "git" && step.argv.includes("--no-verify");
908
908
  }
909
909
  function fallback(command6, options2) {
910
- const names2 = options2.variables.map(escape);
911
- if (options2.noVerify) names2.push("--no-verify");
912
- if (names2.length === 0) return false;
913
- 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(
914
914
  command6
915
915
  );
916
916
  }
@@ -2718,8 +2718,8 @@ function claimants(store, session, root) {
2718
2718
  (record) => record.live && record.session !== session && record.worktree === root
2719
2719
  ).map((record) => record.alias || record.session.slice(0, 8));
2720
2720
  }
2721
- function claimantNotice(root, names2) {
2722
- 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.`;
2723
2723
  }
2724
2724
 
2725
2725
  // src/hooks/policies/workspace/leftovers.ts
@@ -2867,47 +2867,10 @@ var sharedCheckout = {
2867
2867
  };
2868
2868
 
2869
2869
  // src/hooks/policies/workspace/mainline-deliver.ts
2870
- import { resolve as resolve9 } from "node:path";
2871
- var PUSH = /\bgit\b[^|;&\n]*\spush\b/u;
2872
- 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.";
2873
- function sameRepository(dir, commonDir) {
2874
- return checkoutOf(dir)?.commonDir === commonDir;
2875
- }
2876
- var mainlineDeliver = {
2877
- id: "git.mainline.deliver",
2878
- events: ["before_tool"],
2879
- tools: ["shell"],
2880
- fail: "closed",
2881
- defaultMode: "deny",
2882
- options(raw) {
2883
- onlyKeys(raw, []);
2884
- return {};
2885
- },
2886
- evaluate(input) {
2887
- const call = shellCall(input);
2888
- const project6 = checkoutOf(input.projectRoot);
2889
- if (!call || !project6) return pass;
2890
- if (!call.steps) {
2891
- const hit2 = PUSH.test(call.command) && sameRepository(input.cwd, project6.commonDir);
2892
- return hit2 ? { verdict: "deny", reason: REASON8 } : pass;
2893
- }
2894
- for (const step of realSteps(call.steps)) {
2895
- if (program(step.argv[0]) !== "git") continue;
2896
- const git2 = gitCall(step.argv);
2897
- if (git2.sub !== "push") continue;
2898
- const dir = resolve9(input.cwd, step.dir, git2.dir);
2899
- if (sameRepository(dir, project6.commonDir))
2900
- return { verdict: "deny", reason: REASON8 };
2901
- }
2902
- return pass;
2903
- }
2904
- };
2905
-
2906
- // src/hooks/policies/workspace/worktree-sync.ts
2907
- import { relative as relative6, resolve as resolve11 } from "node:path";
2870
+ import { resolve as resolve10 } from "node:path";
2908
2871
 
2909
2872
  // src/git/detect.ts
2910
- import { dirname as dirname5, resolve as resolve10 } from "node:path";
2873
+ import { dirname as dirname5, resolve as resolve9 } from "node:path";
2911
2874
 
2912
2875
  // src/git/exec.ts
2913
2876
  var LOCAL_ENV = [
@@ -2934,6 +2897,17 @@ function git(cwd, args, extra) {
2934
2897
  const stderr = run3.stderr || run3.error?.message || "";
2935
2898
  return { status: run3.status ?? 1, stdout: run3.stdout ?? "", stderr };
2936
2899
  }
2900
+ function gitWithInput(cwd, args, input) {
2901
+ const run3 = spawnSync("git", args, {
2902
+ cwd,
2903
+ encoding: "utf8",
2904
+ env: cleanEnv(),
2905
+ input,
2906
+ maxBuffer: 256 * 1024 * 1024
2907
+ });
2908
+ const stderr = run3.stderr || run3.error?.message || "";
2909
+ return { status: run3.status ?? 1, stdout: run3.stdout ?? "", stderr };
2910
+ }
2937
2911
  function gitText(cwd, args) {
2938
2912
  const run3 = git(cwd, args);
2939
2913
  if (run3.status !== 0) return "";
@@ -2987,11 +2961,11 @@ function detect(cwd, prefs = {}) {
2987
2961
  const remote = defaultRemote(root, prefs.remote);
2988
2962
  const mainline = defaultMainline(root, remote, prefs.mainline);
2989
2963
  return {
2990
- root: resolve10(root),
2991
- gitDir: resolve10(gitDir),
2992
- commonDir: resolve10(commonDir),
2993
- mainRoot: dirname5(resolve10(commonDir)),
2994
- linked: resolve10(gitDir) !== resolve10(commonDir),
2964
+ root: resolve9(root),
2965
+ gitDir: resolve9(gitDir),
2966
+ commonDir: resolve9(commonDir),
2967
+ mainRoot: dirname5(resolve9(commonDir)),
2968
+ linked: resolve9(gitDir) !== resolve9(commonDir),
2995
2969
  remote,
2996
2970
  mainline,
2997
2971
  upstream: `${remote}/${mainline}`,
@@ -2999,6 +2973,124 @@ function detect(cwd, prefs = {}) {
2999
2973
  };
3000
2974
  }
3001
2975
 
2976
+ // src/hooks/policies/workspace/mainline-deliver.ts
2977
+ var PUSH = /\bgit\b[^|;&\n]*\spush\b/u;
2978
+ 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.";
2979
+ var VALUE_OPTIONS = /* @__PURE__ */ new Set([
2980
+ "--repo",
2981
+ "--receive-pack",
2982
+ "--exec",
2983
+ "-o",
2984
+ "--push-option"
2985
+ ]);
2986
+ var EVERY_BRANCH = /* @__PURE__ */ new Set(["--all", "--branches", "--mirror"]);
2987
+ function sameRepository(dir, commonDir) {
2988
+ return checkoutOf(dir)?.commonDir === commonDir;
2989
+ }
2990
+ function gitText2(dir, args) {
2991
+ const run3 = spawnSync("git", ["-C", dir, ...args], {
2992
+ encoding: "utf8",
2993
+ timeout: 5e3
2994
+ });
2995
+ return run3.status === 0 ? run3.stdout.trim() : "";
2996
+ }
2997
+ function names2(ref, branch) {
2998
+ if (ref.includes("*")) return true;
2999
+ return [branch, `heads/${branch}`, `refs/heads/${branch}`].includes(ref);
3000
+ }
3001
+ function movesMainline(dir, args, options2) {
3002
+ const positional = [];
3003
+ let repo = "";
3004
+ for (let index = 0; index < args.length; index += 1) {
3005
+ const word = args[index];
3006
+ if (word === "--") {
3007
+ positional.push(...args.slice(index + 1));
3008
+ break;
3009
+ }
3010
+ if (!word.startsWith("-") || word === "-") {
3011
+ positional.push(word);
3012
+ continue;
3013
+ }
3014
+ const option = word.split("=")[0];
3015
+ if (option === "-n" || option === "--dry-run") return false;
3016
+ if (/^-[a-zA-Z]+$/u.test(word) && word.includes("n")) return false;
3017
+ if (EVERY_BRANCH.has(option)) return true;
3018
+ if (VALUE_OPTIONS.has(option) && !word.includes("=")) {
3019
+ if (option === "--repo") repo = args[index + 1] ?? "";
3020
+ index += 1;
3021
+ continue;
3022
+ }
3023
+ if (option === "--repo") repo = word.slice("--repo=".length);
3024
+ }
3025
+ const ctx = detect(dir, {
3026
+ ...options2.remote ? { remote: options2.remote } : {},
3027
+ ...options2.branch ? { mainline: options2.branch } : {}
3028
+ });
3029
+ const remote = options2.remote ?? ctx?.remote ?? "origin";
3030
+ const branch = options2.branch ?? ctx?.mainline ?? "main";
3031
+ const target = positional[0] ?? repo;
3032
+ if (target && target !== remote && /^[\w.-]+$/u.test(target)) return false;
3033
+ const current = gitText2(dir, ["symbolic-ref", "--short", "-q", "HEAD"]);
3034
+ const refspecs = positional.slice(1);
3035
+ if (refspecs.length === 0) {
3036
+ if (!current) return false;
3037
+ const upstream = gitText2(dir, [
3038
+ "rev-parse",
3039
+ "--abbrev-ref",
3040
+ "--symbolic-full-name",
3041
+ "@{upstream}"
3042
+ ]);
3043
+ return current === branch || upstream === `${remote}/${branch}`;
3044
+ }
3045
+ return refspecs.some((spec) => {
3046
+ const plain = spec.replace(/^\+/u, "");
3047
+ const colon = plain.indexOf(":");
3048
+ let dst = colon < 0 ? plain : plain.slice(colon + 1) || plain.slice(0, colon);
3049
+ if (dst === "HEAD" || dst === "@") dst = current;
3050
+ return dst !== "" && names2(dst, branch);
3051
+ });
3052
+ }
3053
+ var mainlineDeliver = {
3054
+ id: "git.mainline.deliver",
3055
+ events: ["before_tool"],
3056
+ tools: ["shell"],
3057
+ fail: "closed",
3058
+ defaultMode: "deny",
3059
+ options(raw) {
3060
+ onlyKeys(raw, ["remote", "branch"]);
3061
+ const text9 = (key) => {
3062
+ const value = raw[key];
3063
+ if (value === void 0) return {};
3064
+ if (typeof value !== "string" || value === "")
3065
+ throw new Error(`${key} must be a name`);
3066
+ return { [key]: value };
3067
+ };
3068
+ return { ...text9("remote"), ...text9("branch") };
3069
+ },
3070
+ evaluate(input, ctx) {
3071
+ const call = shellCall(input);
3072
+ const project6 = checkoutOf(input.projectRoot);
3073
+ if (!call || !project6) return pass;
3074
+ if (!call.steps) {
3075
+ const hit2 = PUSH.test(call.command) && sameRepository(input.cwd, project6.commonDir);
3076
+ return hit2 ? { verdict: "deny", reason: REASON8 } : pass;
3077
+ }
3078
+ for (const step of realSteps(call.steps)) {
3079
+ if (program(step.argv[0]) !== "git") continue;
3080
+ const git2 = gitCall(step.argv);
3081
+ if (git2.sub !== "push") continue;
3082
+ const dir = resolve10(input.cwd, step.dir, git2.dir);
3083
+ if (!sameRepository(dir, project6.commonDir)) continue;
3084
+ if (movesMainline(dir, step.argv.slice(git2.at + 1), ctx.options))
3085
+ return { verdict: "deny", reason: REASON8 };
3086
+ }
3087
+ return pass;
3088
+ }
3089
+ };
3090
+
3091
+ // src/hooks/policies/workspace/worktree-sync.ts
3092
+ import { relative as relative6, resolve as resolve11 } from "node:path";
3093
+
3002
3094
  // src/git/modes.ts
3003
3095
  import { join as join6 } from "node:path";
3004
3096
  function withUmask(mask, run3) {
@@ -3180,8 +3272,18 @@ function pinsSuperseded(cwd, upstream, sha) {
3180
3272
  }
3181
3273
 
3182
3274
  // src/git/landed.ts
3275
+ var GitReadError = class extends Error {
3276
+ };
3277
+ function read3(cwd, args) {
3278
+ const run3 = git(cwd, args);
3279
+ if (run3.status !== 0)
3280
+ throw new GitReadError(
3281
+ `git ${args.join(" ")} failed (exit ${run3.status}); nothing was chosen: ${run3.stderr.trim()}`
3282
+ );
3283
+ return run3.stdout;
3284
+ }
3183
3285
  function cherry(cwd, upstream, head = "HEAD") {
3184
- const listed = git(cwd, ["cherry", "-v", upstream, head]).stdout;
3286
+ const listed = read3(cwd, ["cherry", "-v", upstream, head]);
3185
3287
  const carried = [];
3186
3288
  const missing = [];
3187
3289
  for (const line of listed.split("\n")) {
@@ -3205,8 +3307,75 @@ function distance(cwd, upstream) {
3205
3307
  return { behind, ahead };
3206
3308
  }
3207
3309
 
3310
+ // src/git/added-submodules.ts
3311
+ import { dirname as dirname7, join as join9 } from "node:path";
3312
+ var ADDED_GITLINK = /^:\d{6} 160000 [0-9a-f]{40} ([0-9a-f]{40}) [AT]\t(.+)$/u;
3313
+ function initAddedSubmodules(root, from, to) {
3314
+ const raw = gitText(root, [
3315
+ "diff",
3316
+ "--raw",
3317
+ "--abbrev=40",
3318
+ "--no-renames",
3319
+ from,
3320
+ to
3321
+ ]);
3322
+ const lines = [];
3323
+ for (const entry of raw.split("\n")) {
3324
+ const added = ADDED_GITLINK.exec(entry);
3325
+ if (!added) continue;
3326
+ const [, pin = "", path = ""] = added;
3327
+ lines.push(`${path}: ${initOne(root, path, pin)}`);
3328
+ }
3329
+ return lines;
3330
+ }
3331
+ function initOne(root, path, pin) {
3332
+ const dir = join9(root, path);
3333
+ if (existsSync(join9(dir, ".git"))) return "already checked out";
3334
+ let displaced = "";
3335
+ if (existsSync(dir) && readdirSync(dir).length > 0) {
3336
+ if (unignoredFiles(root, path).length > 0)
3337
+ return `new submodule not checked out: ${path} holds files git does not ignore; move them aside, then git submodule update --init ${path}`;
3338
+ displaced = displace(root, path);
3339
+ }
3340
+ const done = git(root, ["submodule", "update", "--init", "-q", "--", path]);
3341
+ const aside = displaced ? `; its ignored files from before are in ${displaced}, so run the install again` : "";
3342
+ if (done.status !== 0)
3343
+ return `new submodule not checked out: ${done.stderr.trim()}${aside}`;
3344
+ return `new submodule checked out at ${pin.slice(0, 10)}${aside}`;
3345
+ }
3346
+ function unignoredFiles(root, path) {
3347
+ const kept = [];
3348
+ let level = [path];
3349
+ while (level.length > 0) {
3350
+ const entries = level.flatMap(
3351
+ (dir) => readdirSync(join9(root, dir), { withFileTypes: true }).map((entry) => ({
3352
+ path: `${dir}/${entry.name}`,
3353
+ dir: entry.isDirectory()
3354
+ }))
3355
+ );
3356
+ const checked = gitWithInput(
3357
+ root,
3358
+ ["check-ignore", "--no-index", "--stdin", "-z"],
3359
+ entries.map((entry) => `${entry.path}\0`).join("")
3360
+ );
3361
+ const ignored = new Set(checked.stdout.split("\0").filter(Boolean));
3362
+ const open2 = entries.filter((entry) => !ignored.has(entry.path));
3363
+ kept.push(...open2.filter((entry) => !entry.dir).map((entry) => entry.path));
3364
+ level = open2.filter((entry) => entry.dir).map((entry) => entry.path);
3365
+ }
3366
+ return kept;
3367
+ }
3368
+ function displace(root, path) {
3369
+ const gitDir = gitText(root, ["rev-parse", "--absolute-git-dir"]);
3370
+ const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/gu, "-");
3371
+ const target = join9(gitDir, "pmcp-displaced", stamp, path);
3372
+ mkdirSync(dirname7(target), { recursive: true });
3373
+ renameSync(join9(root, path), target);
3374
+ return target;
3375
+ }
3376
+
3208
3377
  // src/git/submodules.ts
3209
- import { join as join9 } from "node:path";
3378
+ import { join as join10 } from "node:path";
3210
3379
  function clean(dir) {
3211
3380
  return git(dir, ["status", "--porcelain"]).stdout.trim() === "";
3212
3381
  }
@@ -3216,8 +3385,8 @@ function hasCommit(dir, sha) {
3216
3385
  function movableSubmodules(root) {
3217
3386
  const listed = git(root, ["submodule", "status"]).stdout;
3218
3387
  return listed.split("\n").filter((line) => /^[ +]/u.test(line)).map((line) => line.trim().split(/\s+/u)[1] ?? "").filter((path) => {
3219
- const dir = join9(root, path);
3220
- if (!path || !existsSync(join9(dir, ".git"))) return false;
3388
+ const dir = join10(root, path);
3389
+ if (!path || !existsSync(join10(dir, ".git"))) return false;
3221
3390
  const local = gitText(dir, [
3222
3391
  "rev-list",
3223
3392
  "--count",
@@ -3232,7 +3401,7 @@ function updateToPins(root, paths) {
3232
3401
  const lines = [];
3233
3402
  for (const path of paths) {
3234
3403
  const pin = gitText(root, ["rev-parse", `HEAD:${path}`]);
3235
- const dir = join9(root, path);
3404
+ const dir = join10(root, path);
3236
3405
  if (!pin || !hasCommit(dir, pin)) {
3237
3406
  lines.push(
3238
3407
  `${path}: left alone, ${pin.slice(0, 10) || "its pin"} is not in its checkout`
@@ -3250,15 +3419,23 @@ function updateToPins(root, paths) {
3250
3419
 
3251
3420
  // src/git/worktrees/sync.ts
3252
3421
  function heldBy(root, upstream, ahead) {
3253
- const dirty = gitText(root, [
3422
+ const status = git(root, [
3254
3423
  "status",
3255
3424
  "--porcelain",
3256
3425
  "--untracked-files=no",
3257
3426
  "--ignore-submodules=all"
3258
3427
  ]);
3259
- if (dirty) return "uncommitted changes";
3428
+ if (status.status !== 0)
3429
+ return `git status failed (exit ${status.status}): ${status.stderr.trim()}`;
3430
+ if (status.stdout.trim()) return "uncommitted changes";
3260
3431
  if (ahead === 0) return null;
3261
- const own = cherry(root, upstream).missing.length;
3432
+ let own;
3433
+ try {
3434
+ own = cherry(root, upstream).missing.length;
3435
+ } catch (error) {
3436
+ if (error instanceof GitReadError) return error.message;
3437
+ throw error;
3438
+ }
3262
3439
  if (own > 0) return `${own} unlanded commit(s)`;
3263
3440
  return null;
3264
3441
  }
@@ -3306,6 +3483,10 @@ function syncOnce(options2) {
3306
3483
  `moved ${before2.slice(0, 10)} -> ${after.slice(0, 10)}, ${counted.behind} commit(s)`
3307
3484
  );
3308
3485
  for (const line of updateToPins(ctx.root, submodules)) report2.info(line);
3486
+ if (options2.followSubmodules) {
3487
+ for (const line of initAddedSubmodules(ctx.root, before2, after))
3488
+ report2.info(line);
3489
+ }
3309
3490
  if (options2.umask !== void 0)
3310
3491
  reportModes(report2, [
3311
3492
  ...restoreModes(ctx.root, before2, after),
@@ -3909,8 +4090,8 @@ function toolKind2(name) {
3909
4090
  }
3910
4091
  function matcherFor(tools) {
3911
4092
  if (tools.includes("other")) return void 0;
3912
- const names2 = Object.entries(TOOL_KINDS2).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
3913
- return names2.length > 0 ? names2.join("|") : void 0;
4093
+ const names3 = Object.entries(TOOL_KINDS2).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
4094
+ return names3.length > 0 ? names3.join("|") : void 0;
3914
4095
  }
3915
4096
 
3916
4097
  // src/hooks/runtimes/claude/output.ts
@@ -4166,8 +4347,8 @@ function toolKind3(name) {
4166
4347
  }
4167
4348
  function matcherFor2(tools) {
4168
4349
  if (tools.includes("other")) return void 0;
4169
- const names2 = Object.entries(TOOL_KINDS3).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
4170
- return names2.length > 0 ? names2.join("|") : void 0;
4350
+ const names3 = Object.entries(TOOL_KINDS3).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
4351
+ return names3.length > 0 ? names3.join("|") : void 0;
4171
4352
  }
4172
4353
 
4173
4354
  // src/hooks/runtimes/codex/output.ts
@@ -4407,8 +4588,8 @@ function toolKind4(name) {
4407
4588
  }
4408
4589
  function matcherFor3(tools) {
4409
4590
  if (tools.includes("other")) return void 0;
4410
- const names2 = Object.entries(TOOL_KINDS4).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
4411
- return names2.length > 0 ? `^(${names2.join("|")})$` : void 0;
4591
+ const names3 = Object.entries(TOOL_KINDS4).filter(([, kind]) => tools.includes(kind)).map(([name]) => name);
4592
+ return names3.length > 0 ? `^(${names3.join("|")})$` : void 0;
4412
4593
  }
4413
4594
 
4414
4595
  // src/hooks/runtimes/gemini/output.ts
@@ -5083,18 +5264,18 @@ async function dispatch(raw, compiled, deps) {
5083
5264
  }
5084
5265
 
5085
5266
  // src/hooks/entry/fail-closed.ts
5086
- import { join as join12 } from "node:path";
5267
+ import { join as join13 } from "node:path";
5087
5268
 
5088
5269
  // src/hooks/compiled.ts
5089
- import { join as join11 } from "node:path";
5270
+ import { join as join12 } from "node:path";
5090
5271
 
5091
5272
  // src/hooks/integrity-cache.ts
5092
5273
  import { homedir as homedir2 } from "node:os";
5093
- import { dirname as dirname7, join as join10 } from "node:path";
5274
+ import { dirname as dirname8, join as join11 } from "node:path";
5094
5275
  var LIMIT = 64;
5095
5276
  function cacheFile() {
5096
- const base = process.env["XDG_CACHE_HOME"] || join10(homedir2(), ".cache");
5097
- return join10(base, "pmcp", "hook-verified.json");
5277
+ const base = process.env["XDG_CACHE_HOME"] || join11(homedir2(), ".cache");
5278
+ return join11(base, "pmcp", "hook-verified.json");
5098
5279
  }
5099
5280
  function readCache() {
5100
5281
  try {
@@ -5125,7 +5306,7 @@ function rememberVerified(key, stamp, sha) {
5125
5306
  [key, { stamp, sha }]
5126
5307
  ]);
5127
5308
  const file2 = cacheFile();
5128
- mkdirSync(dirname7(file2), { recursive: true });
5309
+ mkdirSync(dirname8(file2), { recursive: true });
5129
5310
  const temporary = `${file2}.${process.pid}.tmp`;
5130
5311
  writeFileSync(temporary, JSON.stringify(cache), { mode: 384 });
5131
5312
  renameSync(temporary, file2);
@@ -5164,8 +5345,8 @@ function readLockFile(path) {
5164
5345
  }
5165
5346
  }
5166
5347
  function readCompiled(root) {
5167
- const policyPath = join11(root, POLICY_FILE);
5168
- const files2 = [policyPath, join11(root, LOCK_FILE)];
5348
+ const policyPath = join12(root, POLICY_FILE);
5349
+ const files2 = [policyPath, join12(root, LOCK_FILE)];
5169
5350
  const before2 = stampOf(files2);
5170
5351
  const text9 = readFileSync(policyPath, "utf8");
5171
5352
  const lock = readLockFile(files2[1]);
@@ -5188,7 +5369,7 @@ function readCompiled(root) {
5188
5369
  var FAILED_CLOSED = "pmcp hook could not evaluate this call and refused it";
5189
5370
  function rawFailure(root) {
5190
5371
  try {
5191
- const raw = JSON.parse(readFileSync(join12(root, POLICY_FILE), "utf8"))["failure"];
5372
+ const raw = JSON.parse(readFileSync(join13(root, POLICY_FILE), "utf8"))["failure"];
5192
5373
  if (!raw || typeof raw.timeoutMs !== "number" || typeof raw.retry !== "number" || !Array.isArray(raw.pass) || !raw.pass.every(
5193
5374
  (kind) => PASS_KINDS.includes(kind)
5194
5375
  ))
@@ -5223,7 +5404,7 @@ function failClosed(adapter, event, root, error, stated = false) {
5223
5404
  }
5224
5405
 
5225
5406
  // src/hooks/entry/lock-repair.ts
5226
- import { join as join13, resolve as resolve19 } from "node:path";
5407
+ import { join as join14, resolve as resolve19 } from "node:path";
5227
5408
  var REV = String.raw`[\w./~^@{}-]+`;
5228
5409
  var LOCK = String.raw`(?:\./)?pmcp\.lock`;
5229
5410
  var REPAIRS = [
@@ -5242,7 +5423,7 @@ function repairsLock(input, root) {
5242
5423
  if (!tool) return false;
5243
5424
  if (tool.kind === "read") return true;
5244
5425
  if (tool.kind === "edit") {
5245
- const lock = join13(root, LOCK_FILE);
5426
+ const lock = join14(root, LOCK_FILE);
5246
5427
  return tool.paths.length > 0 && tool.paths.every((path) => resolve19(input.cwd, path) === lock);
5247
5428
  }
5248
5429
  if (tool.kind === "shell") {
@@ -5263,7 +5444,7 @@ function lockRepair(adapter, event, root, input, error) {
5263
5444
  }
5264
5445
 
5265
5446
  // src/hooks/entry/logger.ts
5266
- import { dirname as dirname8, join as join16 } from "node:path";
5447
+ import { dirname as dirname9, join as join17 } from "node:path";
5267
5448
 
5268
5449
  // src/logging/levels.ts
5269
5450
  var LEVEL_RANK = {
@@ -5387,11 +5568,11 @@ var silentLogger = createLogger(() => {
5387
5568
  });
5388
5569
 
5389
5570
  // src/logging/sinks/file.ts
5390
- import { join as join14 } from "node:path";
5571
+ import { join as join15 } from "node:path";
5391
5572
  var FILE = /^pmcp-(\d{8})(?:\.\d+)?\.jsonl$/u;
5392
5573
  function dailyLogFile(dir, now = /* @__PURE__ */ new Date()) {
5393
5574
  const day = now.toISOString().slice(0, 10).replaceAll("-", "");
5394
- return join14(dir, `pmcp-${day}.jsonl`);
5575
+ return join15(dir, `pmcp-${day}.jsonl`);
5395
5576
  }
5396
5577
  function roll(file2) {
5397
5578
  let index = 1;
@@ -5413,16 +5594,16 @@ function fileSink(target) {
5413
5594
  };
5414
5595
  }
5415
5596
  function logFiles(dir) {
5416
- let names2 = [];
5597
+ let names3 = [];
5417
5598
  try {
5418
- names2 = readdirSync(dir).filter((name) => FILE.test(name));
5599
+ names3 = readdirSync(dir).filter((name) => FILE.test(name));
5419
5600
  } catch {
5420
5601
  return [];
5421
5602
  }
5422
5603
  const part = (name) => Number(/\.(\d+)\.jsonl$/u.exec(name)?.[1] ?? Number.MAX_SAFE_INTEGER);
5423
- return names2.sort(
5604
+ return names3.sort(
5424
5605
  (a, b) => a.slice(5, 13).localeCompare(b.slice(5, 13)) || part(a) - part(b)
5425
- ).map((name) => join14(dir, name));
5606
+ ).map((name) => join15(dir, name));
5426
5607
  }
5427
5608
  function pruneLogs(dir, keepDays, now = /* @__PURE__ */ new Date()) {
5428
5609
  const cutoff = new Date(now.getTime() - keepDays * 864e5).toISOString().slice(0, 10).replaceAll("-", "");
@@ -5438,13 +5619,13 @@ function pruneLogs(dir, keepDays, now = /* @__PURE__ */ new Date()) {
5438
5619
 
5439
5620
  // src/sessions/state-dir.ts
5440
5621
  import { homedir as homedir3 } from "node:os";
5441
- import { join as join15 } from "node:path";
5622
+ import { join as join16 } from "node:path";
5442
5623
  function projectStateDir(root, override, env = process.env) {
5443
5624
  if (override) return expandPath(root, override);
5444
5625
  const anchor = gitCommonDir(root) ?? realpathSync(root);
5445
5626
  const id = createHash("sha256").update(anchor).digest("hex").slice(0, 16);
5446
- const base = env["XDG_STATE_HOME"] || join15(homedir3(), ".local", "state");
5447
- return join15(base, "pmcp", "projects", id);
5627
+ const base = env["XDG_STATE_HOME"] || join16(homedir3(), ".local", "state");
5628
+ return join16(base, "pmcp", "projects", id);
5448
5629
  }
5449
5630
 
5450
5631
  // src/hooks/entry/logger.ts
@@ -5459,7 +5640,7 @@ function hookLogger(root, compiled, runtime2, event) {
5459
5640
  process.env["PMCP_LOG"]
5460
5641
  );
5461
5642
  const file2 = compiled?.logFile ? expandPath(root, compiled.logFile) : void 0;
5462
- const dir = file2 ? dirname8(file2) : join16(projectStateDir(root, compiled?.stateDir), "logs");
5643
+ const dir = file2 ? dirname9(file2) : join17(projectStateDir(root, compiled?.stateDir), "logs");
5463
5644
  const sink = fileSink({
5464
5645
  dir,
5465
5646
  ...file2 ? { file: file2 } : {},
@@ -5475,18 +5656,18 @@ function hookLogger(root, compiled, runtime2, event) {
5475
5656
  }
5476
5657
 
5477
5658
  // src/hooks/entry/state-dir.ts
5478
- import { join as join18 } from "node:path";
5659
+ import { join as join19 } from "node:path";
5479
5660
 
5480
5661
  // src/sessions/lease-files.ts
5481
- import { dirname as dirname9, isAbsolute as isAbsolute13, join as join17 } from "node:path";
5662
+ import { dirname as dirname10, isAbsolute as isAbsolute13, join as join18 } from "node:path";
5482
5663
  var GATE_DIR = "${gate_dir}/";
5483
5664
  function gateTree(root, stateDir, gate, env) {
5484
5665
  const override = gate.treeEnv ? env[gate.treeEnv] : void 0;
5485
5666
  if (override) return override;
5486
- return gate.tree ? expandPath(root, gate.tree) : join17(stateDir, "gate", "tree");
5667
+ return gate.tree ? expandPath(root, gate.tree) : join18(stateDir, "gate", "tree");
5487
5668
  }
5488
5669
  function atGateDir(path, gateDir) {
5489
- return path.startsWith(GATE_DIR) ? join17(gateDir, path.slice(GATE_DIR.length)) : path;
5670
+ return path.startsWith(GATE_DIR) ? join18(gateDir, path.slice(GATE_DIR.length)) : path;
5490
5671
  }
5491
5672
  function resolvePauseFile(file2, gateDir) {
5492
5673
  return file2 === void 0 ? void 0 : atGateDir(file2, gateDir);
@@ -5508,14 +5689,14 @@ function leaseFilesFor(root, stateDir, files2, gate, env) {
5508
5689
  if (!files2 || Object.keys(files2).length === 0) return {};
5509
5690
  return resolveLeaseFiles(
5510
5691
  files2,
5511
- dirname9(gateTree(root, stateDir, gate ?? {}, env))
5692
+ dirname10(gateTree(root, stateDir, gate ?? {}, env))
5512
5693
  );
5513
5694
  }
5514
5695
  function pauseFileFor(root, stateDir, file2, gate, env) {
5515
5696
  if (!file2) return void 0;
5516
5697
  return resolvePauseFile(
5517
5698
  file2,
5518
- dirname9(gateTree(root, stateDir, gate ?? {}, env))
5699
+ dirname10(gateTree(root, stateDir, gate ?? {}, env))
5519
5700
  );
5520
5701
  }
5521
5702
 
@@ -5541,7 +5722,7 @@ function pauseFileAnswer(root) {
5541
5722
  compiled?.sessions.gate,
5542
5723
  process.env
5543
5724
  );
5544
- return `${file2 ?? join18(stateDir, STATE_FILES.pause)}
5725
+ return `${file2 ?? join19(stateDir, STATE_FILES.pause)}
5545
5726
  `;
5546
5727
  }
5547
5728
 
@@ -5579,10 +5760,10 @@ var gitProbe = {
5579
5760
  };
5580
5761
 
5581
5762
  // src/sessions/files/broadcast.ts
5582
- import { join as join19 } from "node:path";
5763
+ import { join as join20 } from "node:path";
5583
5764
 
5584
5765
  // src/sessions/files/json.ts
5585
- import { dirname as dirname10 } from "node:path";
5766
+ import { dirname as dirname11 } from "node:path";
5586
5767
  function readJson3(path) {
5587
5768
  try {
5588
5769
  return JSON.parse(readFileSync(path, "utf8"));
@@ -5591,7 +5772,7 @@ function readJson3(path) {
5591
5772
  }
5592
5773
  }
5593
5774
  function writeJson(path, value) {
5594
- mkdirSync(dirname10(path), { recursive: true, mode: 448 });
5775
+ mkdirSync(dirname11(path), { recursive: true, mode: 448 });
5595
5776
  const temporary = `${path}.${process.pid}.tmp`;
5596
5777
  writeFileSync(temporary, `${JSON.stringify(value, null, 2)}
5597
5778
  `, {
@@ -5615,7 +5796,7 @@ function readLines(path) {
5615
5796
  });
5616
5797
  }
5617
5798
  function writeLines(path, values) {
5618
- mkdirSync(dirname10(path), { recursive: true, mode: 448 });
5799
+ mkdirSync(dirname11(path), { recursive: true, mode: 448 });
5619
5800
  writeFileSync(
5620
5801
  path,
5621
5802
  `${values.map((value) => JSON.stringify(value)).join("\n")}
@@ -5626,8 +5807,8 @@ function writeLines(path, values) {
5626
5807
 
5627
5808
  // src/sessions/files/broadcast.ts
5628
5809
  function filesBroadcast(dir, keep, registry2) {
5629
- const latestPath = join19(dir, STATE_FILES.broadcast);
5630
- const historyPath = join19(dir, STATE_FILES.history);
5810
+ const latestPath = join20(dir, STATE_FILES.broadcast);
5811
+ const historyPath = join20(dir, STATE_FILES.history);
5631
5812
  const list = () => {
5632
5813
  const latest = asBroadcast(readJson3(latestPath));
5633
5814
  if (!latest) return [];
@@ -5671,16 +5852,16 @@ function filesBroadcast(dir, keep, registry2) {
5671
5852
  }
5672
5853
 
5673
5854
  // src/sessions/files/leases.ts
5674
- import { dirname as dirname11, join as join20 } from "node:path";
5855
+ import { dirname as dirname12, join as join21 } from "node:path";
5675
5856
  function filesLeases(dir, files2 = {}) {
5676
- const leasePath = (name) => files2[name]?.file ?? join20(dir, leaseFile(name));
5677
- const read3 = (name) => {
5857
+ const leasePath = (name) => files2[name]?.file ?? join21(dir, leaseFile(name));
5858
+ const read4 = (name) => {
5678
5859
  const lease = asLease(readJson3(leasePath(name)));
5679
5860
  if (!lease || !alive(lease.pid)) return null;
5680
5861
  return lease;
5681
5862
  };
5682
5863
  return {
5683
- read: read3,
5864
+ read: read4,
5684
5865
  // Atomic against another process taking the same file (another tool may share it): the
5685
5866
  // record is linked into place, and a dead holder's record is replaced and then re-read, so
5686
5867
  // of two takers replacing it at once only the one whose record stays holds the lease.
@@ -5693,7 +5874,7 @@ function filesLeases(dir, files2 = {}) {
5693
5874
  ...lease.cwd ? { cwd: lease.cwd } : {},
5694
5875
  since: (/* @__PURE__ */ new Date()).toISOString()
5695
5876
  };
5696
- mkdirSync(dirname11(path), { recursive: true });
5877
+ mkdirSync(dirname12(path), { recursive: true });
5697
5878
  const temp = `${path}.${process.pid}.${Date.now()}.tmp`;
5698
5879
  writeFileSync(temp, `${JSON.stringify(record)}
5699
5880
  `);
@@ -5704,7 +5885,7 @@ function filesLeases(dir, files2 = {}) {
5704
5885
  } catch (error) {
5705
5886
  if (error.code !== "EEXIST") throw error;
5706
5887
  }
5707
- const held = read3(name);
5888
+ const held = read4(name);
5708
5889
  if (held && held.pid !== pid) return false;
5709
5890
  renameSync(temp, path);
5710
5891
  return asLease(readJson3(path))?.pid === pid;
@@ -5723,28 +5904,28 @@ function filesLeases(dir, files2 = {}) {
5723
5904
  }
5724
5905
 
5725
5906
  // src/sessions/files/mailbox.ts
5726
- import { join as join21 } from "node:path";
5907
+ import { join as join22 } from "node:path";
5727
5908
  var ID = /^\d{13}-[0-9a-f]{8}$/u;
5728
5909
  var SAFE_KEY = /^@?[\w.-]+$/u;
5729
5910
  function filesMailbox(dir, settings) {
5730
- const messages = join21(dir, "messages");
5731
- const inbox = join21(dir, "inbox");
5732
- const pathOf = (id) => join21(messages, `${id}.json`);
5911
+ const messages = join22(dir, "messages");
5912
+ const inbox = join22(dir, "inbox");
5913
+ const pathOf = (id) => join22(messages, `${id}.json`);
5733
5914
  const marker = (key, id, kind) => {
5734
5915
  if (!SAFE_KEY.test(key) || !ID.test(id))
5735
5916
  throw new Error(`invalid mailbox key ${key} or id ${id}`);
5736
- return join21(inbox, key, `${id}.${kind}`);
5917
+ return join22(inbox, key, `${id}.${kind}`);
5737
5918
  };
5738
5919
  const audit = (event, fields2) => {
5739
5920
  if (!settings.audit) return;
5740
5921
  const line = { at: (/* @__PURE__ */ new Date()).toISOString(), event, ...fields2 };
5741
- appendFileSync(join21(dir, "messages.jsonl"), `${JSON.stringify(line)}
5922
+ appendFileSync(join22(dir, "messages.jsonl"), `${JSON.stringify(line)}
5742
5923
  `, {
5743
5924
  mode: 384
5744
5925
  });
5745
5926
  };
5746
5927
  const touch = (path) => {
5747
- mkdirSync(join21(path, ".."), { recursive: true, mode: 448 });
5928
+ mkdirSync(join22(path, ".."), { recursive: true, mode: 448 });
5748
5929
  try {
5749
5930
  writeFileSync(path, "", { flag: "wx", mode: 384 });
5750
5931
  return true;
@@ -5761,7 +5942,7 @@ function filesMailbox(dir, settings) {
5761
5942
  if (existsSync(inbox))
5762
5943
  for (const key of readdirSync(inbox))
5763
5944
  for (const kind of ["ack", "delivered"])
5764
- rmSync(join21(inbox, key, `${message.id}.${kind}`), { force: true });
5945
+ rmSync(join22(inbox, key, `${message.id}.${kind}`), { force: true });
5765
5946
  audit(event, { id: message.id });
5766
5947
  };
5767
5948
  return {
@@ -5837,9 +6018,9 @@ function filesMailbox(dir, settings) {
5837
6018
  }
5838
6019
 
5839
6020
  // src/sessions/files/pause.ts
5840
- import { join as join22 } from "node:path";
6021
+ import { join as join23 } from "node:path";
5841
6022
  function filesPause(dir, file2) {
5842
- const path = file2 ?? join22(dir, STATE_FILES.pause);
6023
+ const path = file2 ?? join23(dir, STATE_FILES.pause);
5843
6024
  return {
5844
6025
  read: () => asPause(readJson3(path)),
5845
6026
  write(pause2) {
@@ -5857,12 +6038,12 @@ function filesPause(dir, file2) {
5857
6038
  }
5858
6039
 
5859
6040
  // src/sessions/files/registry.ts
5860
- import { join as join23 } from "node:path";
6041
+ import { join as join24 } from "node:path";
5861
6042
  var SESSION_ID = /^[A-Za-z0-9_-]{8,64}$/u;
5862
6043
  function filesRegistry(dir, staleMs) {
5863
- const records = join23(dir, STATE_FILES.records);
5864
- const dirs = [records, join23(dir, STATE_FILES.legacyRecords)];
5865
- const pathsOf = (session) => dirs.map((records2) => join23(records2, `${session}.json`));
6044
+ const records = join24(dir, STATE_FILES.records);
6045
+ const dirs = [records, join24(dir, STATE_FILES.legacyRecords)];
6046
+ const pathsOf = (session) => dirs.map((records2) => join24(records2, `${session}.json`));
5866
6047
  const get = (session) => {
5867
6048
  if (!SESSION_ID.test(session)) return null;
5868
6049
  return latestRecord(
@@ -5872,16 +6053,16 @@ function filesRegistry(dir, staleMs) {
5872
6053
  const list = (now = Date.now()) => {
5873
6054
  const found = /* @__PURE__ */ new Map();
5874
6055
  for (const folder of dirs) {
5875
- let names2 = [];
6056
+ let names3 = [];
5876
6057
  try {
5877
- names2 = readdirSync(folder).filter((name) => name.endsWith(".json"));
6058
+ names3 = readdirSync(folder).filter((name) => name.endsWith(".json"));
5878
6059
  } catch {
5879
6060
  continue;
5880
6061
  }
5881
- for (const name of names2)
6062
+ for (const name of names3)
5882
6063
  found.set(name, [
5883
6064
  ...found.get(name) ?? [],
5884
- asRecord(readJson3(join23(folder, name)))
6065
+ asRecord(readJson3(join24(folder, name)))
5885
6066
  ]);
5886
6067
  }
5887
6068
  return [...found.values()].map(latestRecord).filter((record) => record !== null).map((record) => ({ ...record, live: isLive(record, now, staleMs) }));
@@ -5908,7 +6089,7 @@ function filesRegistry(dir, staleMs) {
5908
6089
  next["worktree"] = checkout?.root ?? "";
5909
6090
  next["branch"] = checkout?.branch ?? "";
5910
6091
  }
5911
- writeJson(join23(records, `${session}.json`), next);
6092
+ writeJson(join24(records, `${session}.json`), next);
5912
6093
  return next;
5913
6094
  },
5914
6095
  sweep(now = Date.now()) {
@@ -6066,7 +6247,7 @@ var self = import.meta.filename;
6066
6247
  if (process.argv[1] && resolve20(process.argv[1]) === self) {
6067
6248
  process.exitCode = await main(
6068
6249
  process.argv.slice(2),
6069
- resolve20(dirname12(self), "../..")
6250
+ resolve20(dirname13(self), "../..")
6070
6251
  );
6071
6252
  }
6072
6253
  export {