@modootoday/pmcp 0.18.4 → 0.19.1

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 (103) 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-75UWIUVQ.js → apply-IPTASVRS.js} +16 -17
  6. package/dist/{broadcast-CBMVOV3G.js → broadcast-56NPEJWM.js} +3 -4
  7. package/dist/{chunk-ARA4VDHD.js → chunk-2DAC45ZT.js} +2 -2
  8. package/dist/{chunk-JS5RTH4I.js → chunk-2Q6MNGU5.js} +2 -2
  9. package/dist/{chunk-ZWLUH3F2.js → chunk-2W6CEJD7.js} +2 -2
  10. package/dist/{chunk-YRGDWUFY.js → chunk-3BLHIEAK.js} +2 -2
  11. package/dist/{chunk-R26RWSFW.js → chunk-3CLLHFP7.js} +2 -2
  12. package/dist/{chunk-HE2C2S5A.js → chunk-3H5FZCKX.js} +3 -3
  13. package/dist/{chunk-TFRJ5QOS.js → chunk-7FAA32PB.js} +3 -3
  14. package/dist/{chunk-DCU2EXQV.js → chunk-D5D3V6RU.js} +4 -4
  15. package/dist/{chunk-LTZH5E3G.js → chunk-DHAPQUEF.js} +235 -30
  16. package/dist/{chunk-LBXO4VPG.js → chunk-E4FJOLPJ.js} +6 -3
  17. package/dist/{chunk-OPYFEHKG.js → chunk-G7JONWL4.js} +29 -1
  18. package/dist/{chunk-4JUSGIMX.js → chunk-G7NN23YK.js} +2 -2
  19. package/dist/chunk-GPSOPGJA.js +7 -0
  20. package/dist/{chunk-LGO2SZAS.js → chunk-IKJOXDCF.js} +2 -2
  21. package/dist/{chunk-QEW4J3IZ.js → chunk-ISNRDHSD.js} +2 -2
  22. package/dist/{chunk-S3PIAMXV.js → chunk-J5XQW2CM.js} +68 -8
  23. package/dist/{chunk-LFR245MZ.js → chunk-JAICIL6H.js} +5 -5
  24. package/dist/{chunk-GZHHEHKY.js → chunk-JJBSYUSQ.js} +19 -7
  25. package/dist/{chunk-YSUINA5Q.js → chunk-MB72PZH7.js} +8 -8
  26. package/dist/{chunk-3CA3NNVH.js → chunk-MFPQDXUQ.js} +5 -5
  27. package/dist/{chunk-VQ2HEGWH.js → chunk-OKW7VKNQ.js} +2 -2
  28. package/dist/{chunk-6UXJ62XJ.js → chunk-OWW5VY4D.js} +3 -3
  29. package/dist/{chunk-OB3P5RMN.js → chunk-U2FPMGEM.js} +2 -2
  30. package/dist/{chunk-XELAZAIM.js → chunk-UD3BEEBQ.js} +54 -12
  31. package/dist/{chunk-EAWPJHJ7.js → chunk-UGODVKBJ.js} +2 -2
  32. package/dist/{chunk-MSOZPOPX.js → chunk-UOLV2AWA.js} +7 -3
  33. package/dist/{chunk-FBIDDE3N.js → chunk-XKGS2FNF.js} +71 -51
  34. package/dist/{chunk-XMXBE5IQ.js → chunk-XS2QM6AT.js} +5 -5
  35. package/dist/{chunk-45Y3KZ3Q.js → chunk-Y65MO2SS.js} +87 -20
  36. package/dist/{chunk-DAR6RGRN.js → chunk-YTSJRA4Z.js} +2 -2
  37. package/dist/{chunk-QBJC4DRP.js → chunk-ZYMJV7YX.js} +14 -14
  38. package/dist/{cli-ZN7ZVDEZ.js → cli-MUP2NSXT.js} +10 -9
  39. package/dist/{cli-MI4ZCAZ3.js → cli-T5LHBUY2.js} +8 -8
  40. package/dist/cli.js +3 -3
  41. package/dist/{completion-WYJAKJE4.js → completion-ZY5P443T.js} +2 -2
  42. package/dist/{diagnostics-ADIVFSBW.js → diagnostics-KUNS6LCZ.js} +12 -12
  43. package/dist/{doctor-BBCS4DF5.js → doctor-UH7KEOSO.js} +18 -19
  44. package/dist/{entry-DMOTX4SS.js → entry-DOUDMRO2.js} +10 -10
  45. package/dist/{exec-mcp-OBUM3DVW.js → exec-mcp-TGW6FXGC.js} +13 -14
  46. package/dist/{harness-6AUE3I4Q.js → harness-7HC6UR2D.js} +3 -3
  47. package/dist/harness-launch-gate.js +4 -4
  48. package/dist/harness-worker.js +6 -6
  49. package/dist/hook-body.js +446 -278
  50. package/dist/{hook-spec-C5fWTSCH.d.ts → hook-spec-0aGt29Pg.d.ts} +22 -2
  51. package/dist/{hooks-HLPQPVRY.js → hooks-L2MKB75Z.js} +3 -3
  52. package/dist/{host-5Q3X6OY7.js → host-OAQZTYII.js} +15 -16
  53. package/dist/{host-LGSWU3PJ.js → host-QSBXKTWT.js} +7 -7
  54. package/dist/{host-run-4NMQQASQ.js → host-run-HFOADX32.js} +10 -6
  55. package/dist/http.js +1 -1
  56. package/dist/{import-mcp-WU7TO2RT.js → import-mcp-BCYXJAIU.js} +11 -12
  57. package/dist/index.d.ts +2 -2
  58. package/dist/index.js +17 -18
  59. package/dist/{init-XA6XXLGA.js → init-NVJVNZOD.js} +2 -2
  60. package/dist/{invoke-CYQZYU5T.js → invoke-KVTEPXSC.js} +8 -8
  61. package/dist/{list-FNGXY5D7.js → list-2VRPMASP.js} +13 -14
  62. package/dist/{logout-N753FBZP.js → logout-6T5ZDLHQ.js} +12 -13
  63. package/dist/{logs-TBUA4UWU.js → logs-H3RPKNTE.js} +3 -4
  64. package/dist/{mailbox-BMTZOSZ7.js → mailbox-O3MX6QPF.js} +3 -4
  65. package/dist/{mainline-KAD2ERLP.js → mainline-DG75NLBS.js} +306 -57
  66. package/dist/{mcp-GR4VXKTG.js → mcp-7UKG5TD3.js} +2 -2
  67. package/dist/{pause-7LILUVGL.js → pause-2HQ7CKMR.js} +3 -4
  68. package/dist/project/hook-adapter.d.ts +1 -1
  69. package/dist/{project-OEBACWEX.js → project-BPKQOSKQ.js} +4 -4
  70. package/dist/{resume-26VFAAMH.js → resume-ETFTR5V3.js} +3 -4
  71. package/dist/{run-MDRUOEFL.js → run-5JD62E7R.js} +11 -12
  72. package/dist/{run-7XNGPU2I.js → run-WGIRM6Z7.js} +4 -4
  73. package/dist/{serve-HXHNWKEK.js → serve-J575WVIU.js} +3 -3
  74. package/dist/setup-T6T2PFC4.js +20 -0
  75. package/dist/{start-login-PWCEKNED.js → start-login-2AYCHWLV.js} +12 -13
  76. package/dist/{status-QFOBQ42J.js → status-2YWTJOMH.js} +20 -27
  77. package/dist/{status-54IYX2FN.js → status-425ZKIE6.js} +12 -13
  78. package/dist/{status-RO55QPKV.js → status-GPSLH4VO.js} +3 -4
  79. package/dist/stdio.js +2 -2
  80. package/dist/{sweep-35LGQTTO.js → sweep-VY2TNOO5.js} +3 -4
  81. package/dist/{test-36ZUVALT.js → test-XBLZOX52.js} +50 -15
  82. package/dist/{tui-CSRW4DN2.js → tui-WNVBHP65.js} +4 -4
  83. package/dist/{unbroadcast-5QNGAJR2.js → unbroadcast-RKTBP57G.js} +3 -4
  84. package/dist/{worker-EODWT4KK.js → worker-CGF3UIJE.js} +8 -8
  85. package/dist/{worktree-create-PZSRB7PH.js → worktree-create-NO4UOOEP.js} +2 -2
  86. package/dist/{worktree-list-JYB6VXLW.js → worktree-list-NEIDD66X.js} +4 -4
  87. package/dist/{worktree-sync-UF5CXPWV.js → worktree-sync-W4BDDLRO.js} +8 -9
  88. package/docs/commands.md +1 -1
  89. package/docs/git-workflow.md +58 -1
  90. package/docs/hooks.md +29 -0
  91. package/docs/project-configuration.md +7 -7
  92. package/gemini-extension.json +2 -2
  93. package/mcp.json +1 -1
  94. package/package.json +5 -5
  95. package/plugin.json +1 -1
  96. package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
  97. package/plugins/pmcp/.mcp.json +1 -1
  98. package/plugins/pmcp/gemini-extension.json +2 -2
  99. package/plugins/pmcp/mcp.json +1 -1
  100. package/plugins/pmcp/plugin.json +1 -1
  101. package/dist/chunk-26WLNWDG.js +0 -93
  102. package/dist/chunk-MZCRCMEY.js +0 -7
  103. package/dist/setup-DTKZLZUT.js +0 -18
@@ -612,7 +612,7 @@
612
612
  },
613
613
  {
614
614
  "name": "pmcp",
615
- "version": "0.18.4",
615
+ "version": "0.19.1",
616
616
  "description": "Find package skills and use native runtime project configuration.",
617
617
  "source": { "source": "local", "path": "./plugins/pmcp" },
618
618
  "policy": { "installation": "AVAILABLE", "authentication": "ON_USE" },
@@ -445,7 +445,7 @@
445
445
  },
446
446
  {
447
447
  "name": "pmcp",
448
- "version": "0.18.4",
448
+ "version": "0.19.1",
449
449
  "description": "Find package skills and use native runtime project configuration.",
450
450
  "source": "./plugins/pmcp"
451
451
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcp",
3
- "version": "0.18.4",
3
+ "version": "0.19.1",
4
4
  "description": "Find package skills and use native runtime project configuration.",
5
5
  "author": { "name": "modootoday" },
6
6
  "license": "Elastic-2.0",
package/.mcp.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "pmcp": {
4
4
  "type": "stdio",
5
5
  "command": "npx",
6
- "args": ["-y", "@modootoday/pmcp@0.18.4", "serve"]
6
+ "args": ["-y", "@modootoday/pmcp@0.19.1", "serve"]
7
7
  }
8
8
  }
9
9
  }
@@ -1,36 +1,35 @@
1
1
  import {
2
2
  specFrom
3
- } from "./chunk-VQ2HEGWH.js";
3
+ } from "./chunk-OKW7VKNQ.js";
4
4
  import {
5
5
  catalogFrom
6
6
  } from "./chunk-HEBCQTOD.js";
7
7
  import "./chunk-7DLZC73N.js";
8
8
  import {
9
9
  project
10
- } from "./chunk-3CA3NNVH.js";
10
+ } from "./chunk-MFPQDXUQ.js";
11
11
  import "./chunk-P4N7DBD5.js";
12
12
  import {
13
13
  renderFrontmatter,
14
14
  splitFrontmatter
15
- } from "./chunk-LFR245MZ.js";
16
- import "./chunk-R26RWSFW.js";
15
+ } from "./chunk-JAICIL6H.js";
16
+ import "./chunk-3CLLHFP7.js";
17
17
  import {
18
18
  RUNTIMES
19
- } from "./chunk-45Y3KZ3Q.js";
19
+ } from "./chunk-Y65MO2SS.js";
20
20
  import "./chunk-HQOB7OQS.js";
21
- import "./chunk-S3PIAMXV.js";
22
- import "./chunk-JS5RTH4I.js";
23
- import "./chunk-DCU2EXQV.js";
24
- import "./chunk-XELAZAIM.js";
25
- import "./chunk-QEW4J3IZ.js";
26
- import "./chunk-OPYFEHKG.js";
21
+ import "./chunk-J5XQW2CM.js";
22
+ import "./chunk-2Q6MNGU5.js";
23
+ import "./chunk-D5D3V6RU.js";
24
+ import "./chunk-UD3BEEBQ.js";
25
+ import "./chunk-ISNRDHSD.js";
26
+ import "./chunk-G7JONWL4.js";
27
27
  import "./chunk-EATCUWGG.js";
28
28
  import {
29
29
  ProjectError
30
30
  } from "./chunk-NRBQK6UX.js";
31
31
  import "./chunk-3PW4FI7U.js";
32
- import "./chunk-26WLNWDG.js";
33
- import "./chunk-LTZH5E3G.js";
32
+ import "./chunk-DHAPQUEF.js";
34
33
  import "./chunk-C4NHQGHL.js";
35
34
  import "./chunk-Q5H3L6Y4.js";
36
35
  import "./chunk-73AKO4UL.js";
@@ -41,13 +40,13 @@ import {
41
40
  kindOf
42
41
  } from "./chunk-4CRRLDDS.js";
43
42
  import "./chunk-YSAWTGNA.js";
44
- import "./chunk-MSOZPOPX.js";
43
+ import "./chunk-UOLV2AWA.js";
45
44
  import {
46
45
  recordProjector
47
- } from "./chunk-FBIDDE3N.js";
46
+ } from "./chunk-XKGS2FNF.js";
48
47
  import "./chunk-OEH47H6A.js";
49
48
  import "./chunk-IJBSOWHK.js";
50
- import "./chunk-MZCRCMEY.js";
49
+ import "./chunk-GPSOPGJA.js";
51
50
  import "./chunk-QPL7E2HW.js";
52
51
  import "./chunk-PMJG2CXF.js";
53
52
  import "./chunk-J6KL3COD.js";
@@ -240,4 +239,4 @@ export {
240
239
  projectOrCheck,
241
240
  removeAndProject
242
241
  };
243
- //# sourceMappingURL=apply-75UWIUVQ.js.map
242
+ //# sourceMappingURL=apply-IPTASVRS.js.map
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  change
3
- } from "./chunk-LBXO4VPG.js";
4
- import "./chunk-26WLNWDG.js";
5
- import "./chunk-LTZH5E3G.js";
3
+ } from "./chunk-E4FJOLPJ.js";
4
+ import "./chunk-DHAPQUEF.js";
6
5
  import "./chunk-C4NHQGHL.js";
7
6
  import "./chunk-A4PKLESO.js";
8
7
  import "./chunk-OEH47H6A.js";
@@ -15,4 +14,4 @@ var run = (context) => change(context, "broadcast");
15
14
  export {
16
15
  run
17
16
  };
18
- //# sourceMappingURL=broadcast-CBMVOV3G.js.map
17
+ //# sourceMappingURL=broadcast-56NPEJWM.js.map
@@ -1190,7 +1190,7 @@ function registerReadTool(server, tools) {
1190
1190
 
1191
1191
  // src/mcp.ts
1192
1192
  var SERVER_NAME = "pmcp";
1193
- var SERVER_VERSION = "0.18.4";
1193
+ var SERVER_VERSION = "0.19.1";
1194
1194
  function registerSkillTools(server, tools) {
1195
1195
  registerCatalogTool(server, tools);
1196
1196
  registerFindTool(server, tools);
@@ -1243,4 +1243,4 @@ export {
1243
1243
  registerSkillTools,
1244
1244
  createSkillServer
1245
1245
  };
1246
- //# sourceMappingURL=chunk-ARA4VDHD.js.map
1246
+ //# sourceMappingURL=chunk-2DAC45ZT.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  git,
3
3
  gitText
4
- } from "./chunk-OPYFEHKG.js";
4
+ } from "./chunk-G7JONWL4.js";
5
5
 
6
6
  // src/git/detect.ts
7
7
  import { createHash } from "crypto";
@@ -81,4 +81,4 @@ export {
81
81
  detect,
82
82
  listWorktrees
83
83
  };
84
- //# sourceMappingURL=chunk-JS5RTH4I.js.map
84
+ //# sourceMappingURL=chunk-2Q6MNGU5.js.map
@@ -5,7 +5,7 @@ import {
5
5
  POLICIES,
6
6
  RUNTIMES,
7
7
  customPolicy
8
- } from "./chunk-45Y3KZ3Q.js";
8
+ } from "./chunk-Y65MO2SS.js";
9
9
 
10
10
  // src/hooks/inspection/list.ts
11
11
  function policyRows(compiled) {
@@ -39,4 +39,4 @@ function policyRows(compiled) {
39
39
  export {
40
40
  policyRows
41
41
  };
42
- //# sourceMappingURL=chunk-ZWLUH3F2.js.map
42
+ //# sourceMappingURL=chunk-2W6CEJD7.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  HOST_MANIFEST,
3
3
  HOST_POLICY
4
- } from "./chunk-MSOZPOPX.js";
4
+ } from "./chunk-UOLV2AWA.js";
5
5
  import {
6
6
  projectStateDir
7
7
  } from "./chunk-OEH47H6A.js";
@@ -99,4 +99,4 @@ export {
99
99
  hostApprovalDoctor,
100
100
  writeApproval
101
101
  };
102
- //# sourceMappingURL=chunk-YRGDWUFY.js.map
102
+ //# sourceMappingURL=chunk-3BLHIEAK.js.map
@@ -2,7 +2,7 @@ import {
2
2
  MARK,
3
3
  blockOutput,
4
4
  jsonOutput
5
- } from "./chunk-45Y3KZ3Q.js";
5
+ } from "./chunk-Y65MO2SS.js";
6
6
  import {
7
7
  ProjectError
8
8
  } from "./chunk-NRBQK6UX.js";
@@ -393,4 +393,4 @@ export {
393
393
  serversForTool,
394
394
  mcpOutputs
395
395
  };
396
- //# sourceMappingURL=chunk-R26RWSFW.js.map
396
+ //# sourceMappingURL=chunk-3CLLHFP7.js.map
@@ -6,10 +6,10 @@ import {
6
6
  } from "./chunk-34DECPVC.js";
7
7
  import {
8
8
  ptyBinary
9
- } from "./chunk-MSOZPOPX.js";
9
+ } from "./chunk-UOLV2AWA.js";
10
10
  import {
11
11
  nativeBinary
12
- } from "./chunk-FBIDDE3N.js";
12
+ } from "./chunk-XKGS2FNF.js";
13
13
 
14
14
  // src/tui/rust.ts
15
15
  import { spawn } from "child_process";
@@ -64,4 +64,4 @@ export {
64
64
  runTui,
65
65
  dependencies
66
66
  };
67
- //# sourceMappingURL=chunk-HE2C2S5A.js.map
67
+ //# sourceMappingURL=chunk-3H5FZCKX.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assertNativeHost
3
- } from "./chunk-4JUSGIMX.js";
3
+ } from "./chunk-G7NN23YK.js";
4
4
  import {
5
5
  locateExecutable
6
6
  } from "./chunk-R2GPCZUX.js";
@@ -33,7 +33,7 @@ import {
33
33
  resourceClaim,
34
34
  resourceRunning,
35
35
  runtimeUnit
36
- } from "./chunk-LGO2SZAS.js";
36
+ } from "./chunk-IKJOXDCF.js";
37
37
  import {
38
38
  command
39
39
  } from "./chunk-34DECPVC.js";
@@ -1981,4 +1981,4 @@ export {
1981
1981
  isReadOnly,
1982
1982
  runOperation
1983
1983
  };
1984
- //# sourceMappingURL=chunk-TFRJ5QOS.js.map
1984
+ //# sourceMappingURL=chunk-7FAA32PB.js.map
@@ -2,15 +2,15 @@ import {
2
2
  installIfStale,
3
3
  movableSubmodules,
4
4
  updateToPins
5
- } from "./chunk-XELAZAIM.js";
5
+ } from "./chunk-UD3BEEBQ.js";
6
6
  import {
7
7
  cherry,
8
8
  distance
9
- } from "./chunk-QEW4J3IZ.js";
9
+ } from "./chunk-ISNRDHSD.js";
10
10
  import {
11
11
  git,
12
12
  gitText
13
- } from "./chunk-OPYFEHKG.js";
13
+ } from "./chunk-G7JONWL4.js";
14
14
 
15
15
  // src/git/worktrees/sync.ts
16
16
  function heldBy(root, upstream, ahead) {
@@ -75,4 +75,4 @@ function syncWorktree(options) {
75
75
  export {
76
76
  syncWorktree
77
77
  };
78
- //# sourceMappingURL=chunk-DCU2EXQV.js.map
78
+ //# sourceMappingURL=chunk-D5D3V6RU.js.map
@@ -9,6 +9,10 @@ import {
9
9
  isLive,
10
10
  leaseFile
11
11
  } from "./chunk-C4NHQGHL.js";
12
+ import {
13
+ expandPath,
14
+ projectStateDir
15
+ } from "./chunk-OEH47H6A.js";
12
16
  import {
13
17
  checkoutOf
14
18
  } from "./chunk-IJBSOWHK.js";
@@ -127,10 +131,10 @@ function filesBroadcast(dir, keep, registry) {
127
131
  return {
128
132
  list,
129
133
  unseen(session) {
130
- const record = registry.get(session);
131
- const own = new Set([session, record?.alias].filter(Boolean));
132
- const seen = Number(record?.seenBroadcast ?? 0);
133
- const started = Date.parse(record?.startedAt ?? "") || 0;
134
+ const record2 = registry.get(session);
135
+ const own = new Set([session, record2?.alias].filter(Boolean));
136
+ const seen = Number(record2?.seenBroadcast ?? 0);
137
+ const started = Date.parse(record2?.startedAt ?? "") || 0;
134
138
  const all = list();
135
139
  const latest = all.at(-1);
136
140
  const unseen = all.filter(
@@ -159,33 +163,59 @@ function filesBroadcast(dir, keep, registry) {
159
163
  }
160
164
 
161
165
  // src/sessions/files/leases.ts
162
- import { rmSync as rmSync2 } from "fs";
163
- import { join as join2 } from "path";
164
- var leasePath = (dir, name) => join2(dir, leaseFile(name));
165
- function filesLeases(dir) {
166
+ import {
167
+ linkSync,
168
+ mkdirSync as mkdirSync2,
169
+ renameSync as renameSync2,
170
+ rmSync as rmSync2,
171
+ writeFileSync as writeFileSync2
172
+ } from "fs";
173
+ import { dirname as dirname2, join as join2 } from "path";
174
+ function filesLeases(dir, files = {}) {
175
+ const leasePath = (name) => files[name]?.file ?? join2(dir, leaseFile(name));
166
176
  const read = (name) => {
167
- const lease = asLease(readJson(leasePath(dir, name)));
177
+ const lease = asLease(readJson(leasePath(name)));
168
178
  if (!lease || !alive(lease.pid)) return null;
169
179
  return lease;
170
180
  };
171
181
  return {
172
182
  read,
183
+ // Atomic against another process taking the same file (another tool may share it): the
184
+ // record is linked into place, and a dead holder's record is replaced and then re-read, so
185
+ // of two takers replacing it at once only the one whose record stays holds the lease.
173
186
  take(name, lease) {
174
- const held = read(name);
187
+ const path = leasePath(name);
175
188
  const pid = lease.pid ?? process.pid;
176
- if (held && held.pid !== pid) return false;
177
- writeJson(leasePath(dir, name), {
189
+ const record2 = {
178
190
  pid,
179
191
  subject: lease.subject,
180
192
  ...lease.cwd ? { cwd: lease.cwd } : {},
181
193
  since: (/* @__PURE__ */ new Date()).toISOString()
182
- });
183
- return true;
194
+ };
195
+ mkdirSync2(dirname2(path), { recursive: true });
196
+ const temp = `${path}.${process.pid}.${Date.now()}.tmp`;
197
+ writeFileSync2(temp, `${JSON.stringify(record2)}
198
+ `);
199
+ try {
200
+ try {
201
+ linkSync(temp, path);
202
+ return true;
203
+ } catch (error) {
204
+ if (error.code !== "EEXIST") throw error;
205
+ }
206
+ const held = read(name);
207
+ if (held && held.pid !== pid) return false;
208
+ renameSync2(temp, path);
209
+ return asLease(readJson(path))?.pid === pid;
210
+ } finally {
211
+ rmSync2(temp, { force: true });
212
+ }
184
213
  },
185
214
  release(name, pid = process.pid) {
186
- const held = asLease(readJson(leasePath(dir, name)));
215
+ const path = leasePath(name);
216
+ const held = asLease(readJson(path));
187
217
  if (!held || held.pid === pid || !alive(held.pid)) {
188
- rmSync2(leasePath(dir, name), { force: true });
218
+ rmSync2(path, { force: true });
189
219
  }
190
220
  }
191
221
  };
@@ -195,12 +225,12 @@ function filesLeases(dir) {
195
225
  import {
196
226
  appendFileSync,
197
227
  existsSync,
198
- linkSync,
199
- mkdirSync as mkdirSync2,
228
+ linkSync as linkSync2,
229
+ mkdirSync as mkdirSync3,
200
230
  readdirSync,
201
231
  rmSync as rmSync3,
202
232
  unlinkSync,
203
- writeFileSync as writeFileSync2
233
+ writeFileSync as writeFileSync3
204
234
  } from "fs";
205
235
  import { join as join3 } from "path";
206
236
 
@@ -265,9 +295,9 @@ function filesMailbox(dir, settings) {
265
295
  });
266
296
  };
267
297
  const touch = (path) => {
268
- mkdirSync2(join3(path, ".."), { recursive: true, mode: 448 });
298
+ mkdirSync3(join3(path, ".."), { recursive: true, mode: 448 });
269
299
  try {
270
- writeFileSync2(path, "", { flag: "wx", mode: 384 });
300
+ writeFileSync3(path, "", { flag: "wx", mode: 384 });
271
301
  return true;
272
302
  } catch {
273
303
  return false;
@@ -288,7 +318,7 @@ function filesMailbox(dir, settings) {
288
318
  return {
289
319
  settings,
290
320
  send(input) {
291
- mkdirSync2(messages, { recursive: true, mode: 448 });
321
+ mkdirSync3(messages, { recursive: true, mode: 448 });
292
322
  const created = Date.now();
293
323
  const ttl = input.ttlMinutes ?? settings.ttlMinutes;
294
324
  for (let attempt = 0; ; attempt += 1) {
@@ -308,12 +338,12 @@ function filesMailbox(dir, settings) {
308
338
  ...input.broadcastId ? { broadcastId: input.broadcastId } : {}
309
339
  };
310
340
  const temporary = `${pathOf(id)}.${process.pid}.tmp`;
311
- writeFileSync2(temporary, `${JSON.stringify(message, null, 2)}
341
+ writeFileSync3(temporary, `${JSON.stringify(message, null, 2)}
312
342
  `, {
313
343
  mode: 384
314
344
  });
315
345
  try {
316
- linkSync(temporary, pathOf(id));
346
+ linkSync2(temporary, pathOf(id));
317
347
  } catch {
318
348
  continue;
319
349
  } finally {
@@ -393,7 +423,7 @@ function filesRegistry(dir, staleMs) {
393
423
  } catch {
394
424
  return [];
395
425
  }
396
- return names.map((name) => asRecord(readJson(join5(fleetDir, name)))).filter((record) => record !== null).map((record) => ({ ...record, live: isLive(record, now, staleMs) }));
426
+ return names.map((name) => asRecord(readJson(join5(fleetDir, name)))).filter((record2) => record2 !== null).map((record2) => ({ ...record2, live: isLive(record2, now, staleMs) }));
397
427
  };
398
428
  const remove = (session) => {
399
429
  if (SESSION_ID.test(session)) rmSync5(pathOf(session), { force: true });
@@ -420,8 +450,8 @@ function filesRegistry(dir, staleMs) {
420
450
  return next;
421
451
  },
422
452
  sweep(now = Date.now()) {
423
- const stale = list(now).filter((record) => !record.live);
424
- stale.forEach((record) => remove(record.session));
453
+ const stale = list(now).filter((record2) => !record2.live);
454
+ stale.forEach((record2) => remove(record2.session));
425
455
  return stale.length;
426
456
  }
427
457
  };
@@ -442,7 +472,7 @@ function createFilesStore(dir, options = {}) {
442
472
  dir,
443
473
  registry,
444
474
  pause: filesPause(dir),
445
- leases: filesLeases(dir),
475
+ leases: filesLeases(dir, options.leaseFiles),
446
476
  // With the mailbox on, a broadcast is also a message to all, which the mailbox delivers;
447
477
  // broadcast.json stays the record status, snapshot and the Claude band read.
448
478
  broadcast: !mailbox.settings.enabled ? broadcast : {
@@ -466,6 +496,178 @@ function createFilesStore(dir, options = {}) {
466
496
  };
467
497
  }
468
498
 
499
+ // src/sessions/lease-files.ts
500
+ import { dirname as dirname3, isAbsolute, join as join6 } from "path";
501
+ var GATE_DIR = "${gate_dir}/";
502
+ function record(value, where) {
503
+ if (value === null || typeof value !== "object" || Array.isArray(value))
504
+ throw new Error(`${where} must be a table`);
505
+ return value;
506
+ }
507
+ function setting(value, where) {
508
+ if (value === void 0) return void 0;
509
+ if (typeof value !== "string" || value === "")
510
+ throw new Error(`${where} must be a path`);
511
+ if (value.startsWith(GATE_DIR)) return value;
512
+ const home = value === "~" || value.startsWith("~/") || value.startsWith("$HOME/");
513
+ const path = home ? expandPath("/", value) : value;
514
+ if (!isAbsolute(path))
515
+ throw new Error(
516
+ `${where} must be absolute, start with ~/ or start with \${gate_dir}/`
517
+ );
518
+ return path;
519
+ }
520
+ function readLeaseFiles(leases) {
521
+ if (leases === void 0) return {};
522
+ const out = {};
523
+ for (const [name, raw] of Object.entries(
524
+ record(leases, "[sessions.leases]")
525
+ )) {
526
+ const where = `[sessions.leases.${name}]`;
527
+ const table2 = record(raw, where);
528
+ const file = setting(table2["file"], `${where} file`);
529
+ const events = setting(table2["events"], `${where} events`);
530
+ if (file || events)
531
+ out[name] = { ...file ? { file } : {}, ...events ? { events } : {} };
532
+ }
533
+ return out;
534
+ }
535
+ function readGateLocation(git) {
536
+ if (git === null || typeof git !== "object") return {};
537
+ const mainline = git["mainline"];
538
+ if (mainline === null || typeof mainline !== "object") return {};
539
+ const gate = mainline["gate"];
540
+ if (gate === null || typeof gate !== "object") return {};
541
+ const { tree, tree_env: treeEnv } = gate;
542
+ return {
543
+ ...typeof tree === "string" ? { tree } : {},
544
+ ...typeof treeEnv === "string" ? { treeEnv } : {}
545
+ };
546
+ }
547
+ function gateTree(root, stateDir, gate, env) {
548
+ const override = gate.treeEnv ? env[gate.treeEnv] : void 0;
549
+ if (override) return override;
550
+ return gate.tree ? expandPath(root, gate.tree) : join6(stateDir, "gate", "tree");
551
+ }
552
+ function resolveLeaseFiles(files, gateDir) {
553
+ const resolve2 = (path) => path?.startsWith(GATE_DIR) ? join6(gateDir, path.slice(GATE_DIR.length)) : path;
554
+ return Object.fromEntries(
555
+ Object.entries(files ?? {}).map(([name, f]) => {
556
+ const file = resolve2(f.file);
557
+ const events = resolve2(f.events);
558
+ return [
559
+ name,
560
+ { ...file ? { file } : {}, ...events ? { events } : {} }
561
+ ];
562
+ })
563
+ );
564
+ }
565
+ function leaseFilesFor(root, stateDir, files, gate, env) {
566
+ if (!files || Object.keys(files).length === 0) return {};
567
+ return resolveLeaseFiles(
568
+ files,
569
+ dirname3(gateTree(root, stateDir, gate ?? {}, env))
570
+ );
571
+ }
572
+
573
+ // src/sessions/settings.ts
574
+ var MAILBOX_KEYS = [
575
+ "enabled",
576
+ "ttl_minutes",
577
+ "max_delivered",
578
+ "audit",
579
+ "wake"
580
+ ];
581
+ function flag(value, where, fallback) {
582
+ if (value === void 0) return fallback;
583
+ if (typeof value !== "boolean")
584
+ throw new Error(`${where} must be true or false`);
585
+ return value;
586
+ }
587
+ function readMailbox(raw) {
588
+ if (raw === void 0)
589
+ return { enabled: false, ttlMinutes: 1440, maxDelivered: 5, audit: true };
590
+ const mailbox = table(raw, "[sessions.mailbox]");
591
+ const unknown = Object.keys(mailbox).find(
592
+ (key) => !MAILBOX_KEYS.includes(key)
593
+ );
594
+ if (unknown) throw new Error(`[sessions.mailbox] unknown key ${unknown}`);
595
+ return {
596
+ enabled: flag(mailbox["enabled"], "[sessions.mailbox] enabled", true),
597
+ ttlMinutes: positiveInteger(
598
+ mailbox["ttl_minutes"],
599
+ "[sessions.mailbox] ttl_minutes",
600
+ 1440
601
+ ),
602
+ maxDelivered: positiveInteger(
603
+ mailbox["max_delivered"],
604
+ "[sessions.mailbox] max_delivered",
605
+ 5
606
+ ),
607
+ audit: flag(mailbox["audit"], "[sessions.mailbox] audit", true),
608
+ // Only when on, so mailboxes without wake keep the same compiled policy and hash.
609
+ ...flag(mailbox["wake"], "[sessions.mailbox] wake", false) ? { wake: true } : {}
610
+ };
611
+ }
612
+ function table(value, where) {
613
+ if (value === void 0) return {};
614
+ if (value === null || typeof value !== "object" || Array.isArray(value))
615
+ throw new Error(`${where} must be a table`);
616
+ return value;
617
+ }
618
+ function positiveInteger(value, where, fallback) {
619
+ if (value === void 0) return fallback;
620
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value <= 0) {
621
+ throw new Error(`${where} must be a positive integer`);
622
+ }
623
+ return value;
624
+ }
625
+ function readStoreSettings(raw, git) {
626
+ const sessions = table(raw, "[sessions]");
627
+ if ((sessions["store"] ?? "files") !== "files")
628
+ throw new Error('[sessions] store must be "files"');
629
+ const stateDir = sessions["state_dir"];
630
+ if (stateDir !== void 0 && (typeof stateDir !== "string" || stateDir === "")) {
631
+ throw new Error("[sessions] state_dir must be a path");
632
+ }
633
+ const registry = table(sessions["registry"], "[sessions.registry]");
634
+ const broadcast = table(sessions["broadcast"], "[sessions.broadcast]");
635
+ return {
636
+ ...typeof stateDir === "string" ? { stateDir } : {},
637
+ staleMs: positiveInteger(
638
+ registry["stale_minutes"],
639
+ "[sessions.registry] stale_minutes",
640
+ 30
641
+ ) * 6e4,
642
+ keepBroadcasts: positiveInteger(
643
+ broadcast["keep"],
644
+ "[sessions.broadcast] keep",
645
+ 10
646
+ ),
647
+ mailbox: readMailbox(sessions["mailbox"]),
648
+ ...leaseSettings(sessions["leases"], git)
649
+ };
650
+ }
651
+ function leaseSettings(leases, git) {
652
+ const leaseFiles = readLeaseFiles(leases);
653
+ if (Object.keys(leaseFiles).length === 0) return {};
654
+ const gate = readGateLocation(git);
655
+ return { leaseFiles, ...Object.keys(gate).length > 0 ? { gate } : {} };
656
+ }
657
+ function openStore(root, settings, env = process.env) {
658
+ const dir = projectStateDir(root, settings.stateDir, env);
659
+ return createFilesStore(dir, {
660
+ ...settings,
661
+ leaseFiles: leaseFilesFor(
662
+ root,
663
+ dir,
664
+ settings.leaseFiles,
665
+ settings.gate,
666
+ env
667
+ )
668
+ });
669
+ }
670
+
469
671
  export {
470
672
  noticeOf,
471
673
  normalizeSelector,
@@ -474,6 +676,9 @@ export {
474
676
  inboxKey,
475
677
  writeJson,
476
678
  SESSION_ID,
477
- createFilesStore
679
+ createFilesStore,
680
+ resolveLeaseFiles,
681
+ readStoreSettings,
682
+ openStore
478
683
  };
479
- //# sourceMappingURL=chunk-LTZH5E3G.js.map
684
+ //# sourceMappingURL=chunk-DHAPQUEF.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  openStore,
3
3
  readStoreSettings
4
- } from "./chunk-26WLNWDG.js";
4
+ } from "./chunk-DHAPQUEF.js";
5
5
  import {
6
6
  ArgumentError,
7
7
  one
@@ -20,7 +20,10 @@ function storeFrom(context) {
20
20
  const sessions = config.raw["sessions"] ?? {};
21
21
  const leases = Object.keys(sessions["leases"] ?? {});
22
22
  return {
23
- store: openStore(config.dir, readStoreSettings(sessions)),
23
+ store: openStore(
24
+ config.dir,
25
+ readStoreSettings(sessions, config.raw["git"])
26
+ ),
24
27
  leases,
25
28
  root: config.dir
26
29
  };
@@ -70,4 +73,4 @@ export {
70
73
  storeFrom,
71
74
  change
72
75
  };
73
- //# sourceMappingURL=chunk-LBXO4VPG.js.map
76
+ //# sourceMappingURL=chunk-E4FJOLPJ.js.map