@modootoday/pmcp 0.24.1 → 0.26.0

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 (116) 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/{affected-IPFJM2KD.js → affected-4FILH743.js} +174 -77
  6. package/dist/{apply-CDJQJAZH.js → apply-HJUCYQDQ.js} +18 -15
  7. package/dist/{broadcast-VKZY7WSD.js → broadcast-U7ZYOJWE.js} +7 -4
  8. package/dist/{chunk-GEDRPMBH.js → chunk-2GL5L2G5.js} +2 -2
  9. package/dist/{chunk-AQM2JZMB.js → chunk-2JUHFM4V.js} +2 -2
  10. package/dist/{chunk-UKR64U7J.js → chunk-374AZ4J4.js} +2 -2
  11. package/dist/{chunk-MZ52S4YJ.js → chunk-3JOFDNL4.js} +2 -2
  12. package/dist/{chunk-264DIB5U.js → chunk-3KISMGVP.js} +4 -4
  13. package/dist/{chunk-V5PXMLLL.js → chunk-6XE3WW7S.js} +3 -3
  14. package/dist/{chunk-7CGGDX7X.js → chunk-7FHOSWNQ.js} +2 -2
  15. package/dist/{chunk-5NQZGNKT.js → chunk-7PBWLYCO.js} +3 -3
  16. package/dist/{chunk-2GZKA33O.js → chunk-A4P3IIPE.js} +2 -2
  17. package/dist/{chunk-3O3JZTUU.js → chunk-C7Y2MBCN.js} +3 -3
  18. package/dist/chunk-D7IDT7OA.js +21 -0
  19. package/dist/chunk-E272CFPS.js +14 -0
  20. package/dist/chunk-FLG7VRTC.js +1 -0
  21. package/dist/{chunk-X3RUXLAV.js → chunk-FXDGW2IH.js} +3 -3
  22. package/dist/{chunk-DLIO2D7S.js → chunk-GIL3RBRX.js} +27 -20
  23. package/dist/{chunk-ARXCYFFZ.js → chunk-GQRDEIQA.js} +22 -2
  24. package/dist/chunk-J43Z4O3G.js +7 -0
  25. package/dist/chunk-KLIYFD3W.js +32 -0
  26. package/dist/{chunk-PG62GOPU.js → chunk-KQV2EPAP.js} +2 -2
  27. package/dist/{chunk-LNKAR3IS.js → chunk-LCPCRZ7N.js} +2 -2
  28. package/dist/chunk-NQCAKDRY.js +156 -0
  29. package/dist/{chunk-3SEJNT6F.js → chunk-NQZMGQFG.js} +5 -5
  30. package/dist/{chunk-DGXZBQCA.js → chunk-OBCBCLS2.js} +7 -7
  31. package/dist/{chunk-D4FIBB2G.js → chunk-OG2ESRQP.js} +5 -5
  32. package/dist/{chunk-43MXRTKH.js → chunk-OHCUPXU4.js} +26 -8
  33. package/dist/chunk-OIKT4SYO.js +42 -0
  34. package/dist/{chunk-3V37OZQH.js → chunk-PAY6HEEY.js} +2 -2
  35. package/dist/{chunk-QY2P54Z2.js → chunk-PZ6D3WKD.js} +125 -8
  36. package/dist/{chunk-MOKZPZZO.js → chunk-Q5BQIRM3.js} +2 -2
  37. package/dist/{chunk-VYQJPT27.js → chunk-S2FUWBLO.js} +18 -4
  38. package/dist/{chunk-OGCJO6HQ.js → chunk-TQRLWO4F.js} +2 -2
  39. package/dist/{chunk-VBWB2T3C.js → chunk-UVPIVSZB.js} +14 -6
  40. package/dist/{chunk-MHKY6TNF.js → chunk-VN34GLGJ.js} +3 -3
  41. package/dist/chunk-WUFNKK3U.js +71 -0
  42. package/dist/{chunk-2ZH77O2D.js → chunk-Y7FYCVUK.js} +646 -103
  43. package/dist/{chunk-HES44LTA.js → chunk-YJVSN6UN.js} +29 -5
  44. package/dist/{chunk-EWYLWBKS.js → chunk-YKICVMF7.js} +22 -5
  45. package/dist/{cli-OV5LSSGE.js → cli-FVUHK2NB.js} +7 -7
  46. package/dist/{cli-GFDT4YXM.js → cli-ZOY2274X.js} +9 -9
  47. package/dist/cli.js +40 -6
  48. package/dist/{completion-QNDCU4MF.js → completion-ZKWGPMEK.js} +6 -5
  49. package/dist/{diagnostics-TPK3VC5F.js → diagnostics-IM2OPAPL.js} +7 -7
  50. package/dist/{doctor-K2LADSW2.js → doctor-VZTHEPVC.js} +32 -20
  51. package/dist/{entry-HFQHKL5L.js → entry-Q4EI4PNO.js} +13 -13
  52. package/dist/{exec-mcp-I2YGGWY4.js → exec-mcp-AWGUQVT2.js} +15 -12
  53. package/dist/{harness-BMWGAXCF.js → harness-L4C5XWKR.js} +3 -3
  54. package/dist/harness-launch-gate.js +5 -5
  55. package/dist/harness-worker.js +7 -7
  56. package/dist/{heavy-G6CYQQ7O.js → heavy-OG3UVZNY.js} +327 -131
  57. package/dist/hook-body.js +664 -161
  58. package/dist/{hook-spec-Bd24eo2L.d.ts → hook-spec-u7hnz571.d.ts} +10 -0
  59. package/dist/{hooks-R7AYQXHY.js → hooks-2E6PJJQK.js} +4 -4
  60. package/dist/{host-PLE2T55E.js → host-OQDBQJB2.js} +8 -8
  61. package/dist/{host-EUD6GLWV.js → host-RJJGTKWA.js} +20 -65
  62. package/dist/{host-run-QFNGIDL5.js → host-run-PWCIXJDN.js} +6 -6
  63. package/dist/http.js +1 -1
  64. package/dist/{import-mcp-DVKJOEOE.js → import-mcp-2H2NRUCL.js} +14 -11
  65. package/dist/index.d.ts +2 -2
  66. package/dist/index.js +18 -15
  67. package/dist/{init-DKWNL62M.js → init-O2UCU2WT.js} +2 -2
  68. package/dist/{invoke-U6JTPTXT.js → invoke-SJ3JHRJU.js} +9 -9
  69. package/dist/{list-YKQFJN3G.js → list-SJVXZGKK.js} +17 -14
  70. package/dist/{logout-5YSKC46N.js → logout-ROKXWR3T.js} +15 -12
  71. package/dist/{logs-2JEMSNSG.js → logs-J4W6GFMK.js} +4 -4
  72. package/dist/{mailbox-5FVFMQ2J.js → mailbox-6MHH6CUA.js} +22 -8
  73. package/dist/{mainline-D3PSR6AJ.js → mainline-SWZPKA7U.js} +19 -9
  74. package/dist/{mcp-CHKKXHBB.js → mcp-U7MVFAB4.js} +2 -2
  75. package/dist/owners-MPI22SFU.js +63 -0
  76. package/dist/{pause-CMZOIHTJ.js → pause-3IMVYXQQ.js} +7 -4
  77. package/dist/project/hook-adapter.d.ts +1 -1
  78. package/dist/{project-QEYXISHC.js → project-MGUYHUF7.js} +4 -4
  79. package/dist/{report-UB7MXAUB.js → report-MWXB5XKE.js} +5 -5
  80. package/dist/{resume-PAKIT4TT.js → resume-7LCSV4X3.js} +7 -4
  81. package/dist/{run-HKMYYEZJ.js → run-DDWLS6FY.js} +14 -11
  82. package/dist/{run-FYKDIW4C.js → run-TBO5JO4Y.js} +4 -4
  83. package/dist/{serve-QZNG5UUV.js → serve-RBQYB3FP.js} +3 -3
  84. package/dist/{setup-GRWLDBVB.js → setup-7JHWLV7K.js} +6 -4
  85. package/dist/{smoke-6X6IXQIQ.js → smoke-GZECLXOJ.js} +3 -3
  86. package/dist/{start-login-4GPM32RA.js → start-login-SOTNDUP6.js} +15 -12
  87. package/dist/{status-55CD352M.js → status-EBIUQIGY.js} +35 -30
  88. package/dist/{status-4PYPTYUB.js → status-QFMN7IUG.js} +8 -5
  89. package/dist/{status-W6SCF2GF.js → status-TSTOFNZU.js} +15 -12
  90. package/dist/stdio.js +2 -2
  91. package/dist/{sweep-VURZU6DI.js → sweep-BS7HVSNP.js} +7 -4
  92. package/dist/{test-XYEMYZ2P.js → test-4PZHHWOQ.js} +28 -16
  93. package/dist/{tui-FXSWN2PV.js → tui-QD2LMXHV.js} +4 -4
  94. package/dist/{unbroadcast-7AMLURCG.js → unbroadcast-GRGX3F6T.js} +7 -4
  95. package/dist/{worker-Q4I4EIAJ.js → worker-SPJ4HFWV.js} +11 -11
  96. package/dist/{worktree-list-2HV6ODBS.js → worktree-list-WZC75NLF.js} +8 -9
  97. package/dist/{worktree-sync-MUVKK2CV.js → worktree-sync-BQZD4J73.js} +5 -2
  98. package/docs/commands.md +18 -7
  99. package/docs/git-workflow.md +40 -5
  100. package/docs/glossary.md +1 -1
  101. package/docs/hooks.md +75 -16
  102. package/docs/project-configuration.md +136 -40
  103. package/docs/sessions.md +9 -2
  104. package/docs/upgrading.md +71 -0
  105. package/gemini-extension.json +2 -2
  106. package/mcp.json +1 -1
  107. package/package.json +5 -5
  108. package/plugin.json +1 -1
  109. package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
  110. package/plugins/pmcp/.mcp.json +1 -1
  111. package/plugins/pmcp/gemini-extension.json +2 -2
  112. package/plugins/pmcp/mcp.json +1 -1
  113. package/plugins/pmcp/plugin.json +1 -1
  114. package/dist/chunk-65H4PN33.js +0 -7
  115. package/dist/chunk-7TD53M7L.js +0 -13
  116. package/dist/chunk-FQLCD4HU.js +0 -24
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-Z6WRFOFT.js";
13
13
  import {
14
14
  projectStateDir
15
- } from "./chunk-FQLCD4HU.js";
15
+ } from "./chunk-KLIYFD3W.js";
16
16
  import {
17
17
  expandPath
18
18
  } from "./chunk-GUHOEIHP.js";
@@ -730,4 +730,4 @@ export {
730
730
  readStoreSettings,
731
731
  openStore
732
732
  };
733
- //# sourceMappingURL=chunk-3V37OZQH.js.map
733
+ //# sourceMappingURL=chunk-PAY6HEEY.js.map
@@ -15,8 +15,92 @@ import {
15
15
  readConfig
16
16
  } from "./chunk-GJXOFDJT.js";
17
17
 
18
+ // src/lease/job-log.ts
19
+ import {
20
+ closeSync,
21
+ existsSync,
22
+ fstatSync,
23
+ openSync,
24
+ readFileSync,
25
+ renameSync,
26
+ writeSync
27
+ } from "fs";
28
+ var DEFAULT_JOB_LOG_BYTES = 4 * 1024 * 1024;
29
+ var JobLog = class {
30
+ constructor(path, cap) {
31
+ this.path = path;
32
+ this.cap = cap;
33
+ this.fd = openSync(path, "a");
34
+ this.size = fstatSync(this.fd).size;
35
+ }
36
+ path;
37
+ cap;
38
+ fd;
39
+ size;
40
+ write(chunk) {
41
+ const bytes = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
42
+ try {
43
+ if (this.size > 0 && this.size + bytes.length > this.cap) {
44
+ closeSync(this.fd);
45
+ renameSync(this.path, `${this.path}.1`);
46
+ this.fd = openSync(this.path, "a");
47
+ this.size = 0;
48
+ }
49
+ const kept = bytes.length > this.cap ? bytes.subarray(bytes.length - this.cap) : bytes;
50
+ writeSync(this.fd, kept);
51
+ this.size += kept.length;
52
+ } catch {
53
+ }
54
+ }
55
+ close() {
56
+ try {
57
+ closeSync(this.fd);
58
+ } catch {
59
+ }
60
+ }
61
+ };
62
+ function readJobLog(path, tail) {
63
+ const parts = [`${path}.1`, path].filter((file) => existsSync(file)).map((file) => readFileSync(file, "utf8"));
64
+ const text = parts.join("");
65
+ if (tail === void 0) return text;
66
+ const lines = text.split("\n");
67
+ if (lines[lines.length - 1] === "") lines.pop();
68
+ return lines.slice(-tail).join("\n") + (lines.length > 0 ? "\n" : "");
69
+ }
70
+
18
71
  // src/lease/config.ts
19
72
  import { availableParallelism } from "os";
73
+
74
+ // src/lease/heavy-preset.ts
75
+ var SCRIPTS = ["test", "build", "typecheck"];
76
+ function scripts(manager, direct) {
77
+ return [
78
+ ...direct.map((verb) => [manager, verb]),
79
+ ...SCRIPTS.map((script) => [manager, "run", script])
80
+ ];
81
+ }
82
+ var DEFAULT_HEAVY = [
83
+ ["npm", "install"],
84
+ ["npm", "i"],
85
+ ["npm", "ci"],
86
+ ["npm", "test"],
87
+ ...scripts("npm", []),
88
+ ["pnpm", "install"],
89
+ ["pnpm", "i"],
90
+ ...scripts("pnpm", SCRIPTS),
91
+ ["yarn", "install"],
92
+ ...scripts("yarn", SCRIPTS),
93
+ ["bun", "install"],
94
+ ["bun", "i"],
95
+ ["bun", "test"],
96
+ ...scripts("bun", []),
97
+ ["cargo", "build"],
98
+ ["cargo", "test"],
99
+ ["cargo", "check"]
100
+ ];
101
+ var HEAVY_PRESET = "default";
102
+
103
+ // src/lease/config.ts
20
104
  var DISABLE_ENV = "PMCP_HEAVY_DISABLE";
21
105
  var NOW_ENV = "PMCP_HEAVY_NOW";
22
106
  var BUSY_EXIT = 75;
@@ -48,8 +132,10 @@ var KEYS = [
48
132
  "guard",
49
133
  "io",
50
134
  "usage_cap",
135
+ "job_log_bytes",
51
136
  "settle_window",
52
- "skip_always"
137
+ "skip_always",
138
+ "skip_reasons"
53
139
  ];
54
140
  var SIZE = /^[1-9]\d*[KMGT]$/u;
55
141
  function fail(path, message) {
@@ -178,12 +264,31 @@ function ioSettings(path, raw) {
178
264
  }
179
265
  return { enabled, weights, max };
180
266
  }
181
- function reasons(path, value) {
267
+ var REASON = /^[a-z][a-z0-9_.:-]{0,63}$/u;
268
+ function reasons(path, key, value) {
182
269
  if (value === void 0) return [];
183
- if (!Array.isArray(value) || !value.every((item) => typeof item === "string" && item !== ""))
184
- fail(path, "[host.lease] skip_always must be a list of skip reasons");
270
+ if (!Array.isArray(value) || !value.every((item) => typeof item === "string" && REASON.test(item)))
271
+ fail(
272
+ path,
273
+ `[host.lease] ${key} must be a list of skip reasons: lower-case words such as "git-hook"`
274
+ );
185
275
  return value;
186
276
  }
277
+ function heavyList(path, value, declared) {
278
+ if (value === void 0) return declared ? [...DEFAULT_HEAVY] : [];
279
+ const items = value === HEAVY_PRESET ? [value] : value;
280
+ if (!Array.isArray(items))
281
+ fail(
282
+ path,
283
+ `[host.lease] heavy must be "${HEAVY_PRESET}" or a list of argv prefixes`
284
+ );
285
+ const preset = items.includes(HEAVY_PRESET);
286
+ const own = argvList(
287
+ path,
288
+ items.filter((item) => item !== HEAVY_PRESET)
289
+ );
290
+ return [...preset ? DEFAULT_HEAVY : [], ...own];
291
+ }
187
292
  function hardFactor(path, value) {
188
293
  if (value === void 0) return 2;
189
294
  if (typeof value !== "number" || !(value >= 1))
@@ -192,7 +297,8 @@ function hardFactor(path, value) {
192
297
  }
193
298
  function readLeaseSettings(path, dir, host) {
194
299
  const root = table(path, "host", host) ?? {};
195
- const raw = child(path, root, "host", "lease") ?? {};
300
+ const declared = child(path, root, "host", "lease");
301
+ const raw = declared ?? {};
196
302
  const read = new Reader(path, "host.lease", raw, KEYS);
197
303
  const memoryMax = memory(path, "host.lease", raw["memory_max"]);
198
304
  const base = {
@@ -211,7 +317,8 @@ function readLeaseSettings(path, dir, host) {
211
317
  markerEnv: read.envName("marker_env") ?? "PMCP_HEAVY_LEASE",
212
318
  ...legacyMarkerEnv ? { legacyMarkerEnv } : {},
213
319
  ...legacySkipEnv ? { legacySkipEnv } : {},
214
- skipAlways: reasons(path, raw["skip_always"]),
320
+ skipAlways: reasons(path, "skip_always", raw["skip_always"]),
321
+ skipReasons: reasons(path, "skip_reasons", raw["skip_reasons"]),
215
322
  maxLoad: read.positive("max_load") ?? availableParallelism(),
216
323
  maxIo: read.positive("max_io") ?? 8,
217
324
  ioWindow: read.oneOf("io_window", ["avg10", "avg60", "avg300"], "avg60"),
@@ -239,10 +346,17 @@ function readLeaseSettings(path, dir, host) {
239
346
  tiny: argvList(path, raw["tiny"]),
240
347
  perSession: whole(path, "host.lease", "per_session", raw["per_session"], 1),
241
348
  profiles: profiles(path, child(path, raw, "host.lease", "profiles"), base),
242
- heavy: argvList(path, raw["heavy"]),
349
+ heavy: heavyList(path, raw["heavy"], declared !== void 0),
243
350
  guard: read.oneOf("guard", ["observe", "warn", "deny", "off"], "observe"),
244
351
  io: ioSettings(path, child(path, raw, "host.lease", "io")),
245
352
  usageCap: read.int("usage_cap", 5e6),
353
+ jobLogBytes: whole(
354
+ path,
355
+ "host.lease",
356
+ "job_log_bytes",
357
+ raw["job_log_bytes"],
358
+ DEFAULT_JOB_LOG_BYTES
359
+ ),
246
360
  settleWindow: whole(
247
361
  path,
248
362
  "host.lease",
@@ -260,10 +374,13 @@ function leaseSettingsFor(cwd, configPath) {
260
374
  }
261
375
 
262
376
  export {
377
+ DEFAULT_JOB_LOG_BYTES,
378
+ JobLog,
379
+ readJobLog,
263
380
  DISABLE_ENV,
264
381
  NOW_ENV,
265
382
  BUSY_EXIT,
266
383
  readLeaseSettings,
267
384
  leaseSettingsFor
268
385
  };
269
- //# sourceMappingURL=chunk-QY2P54Z2.js.map
386
+ //# sourceMappingURL=chunk-PZ6D3WKD.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-7CHUMF3E.js";
4
4
  import {
5
5
  readSpec
6
- } from "./chunk-2ZH77O2D.js";
6
+ } from "./chunk-Y7FYCVUK.js";
7
7
  import {
8
8
  ArgumentError
9
9
  } from "./chunk-Y6NFETNG.js";
@@ -25,4 +25,4 @@ function serverFrom(context) {
25
25
  export {
26
26
  serverFrom
27
27
  };
28
- //# sourceMappingURL=chunk-MOKZPZZO.js.map
28
+ //# sourceMappingURL=chunk-Q5BQIRM3.js.map
@@ -16,6 +16,9 @@ import {
16
16
  gitWithInput,
17
17
  runCommand
18
18
  } from "./chunk-23PE3HZB.js";
19
+ import {
20
+ displacedDir
21
+ } from "./chunk-KLIYFD3W.js";
19
22
 
20
23
  // src/git/install.ts
21
24
  import { createHash } from "crypto";
@@ -88,6 +91,7 @@ function installIfStale(root, spec, report) {
88
91
 
89
92
  // src/git/added-submodules.ts
90
93
  import {
94
+ cpSync,
91
95
  existsSync as existsSync2,
92
96
  mkdirSync as mkdirSync2,
93
97
  readdirSync,
@@ -199,11 +203,21 @@ function restoreIgnoreFiles(root, path, from) {
199
203
  return restored;
200
204
  }
201
205
  function displace(root, path) {
202
- const gitDir = gitText(root, ["rev-parse", "--absolute-git-dir"]);
203
206
  const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/gu, "-");
204
- const target = join2(gitDir, "pmcp-displaced", stamp, path);
207
+ const target = join2(displacedDir(root), stamp, path);
205
208
  mkdirSync2(dirname2(target), { recursive: true });
206
- renameSync(join2(root, path), target);
209
+ const source = join2(root, path);
210
+ try {
211
+ renameSync(source, target);
212
+ } catch (error) {
213
+ if (error.code !== "EXDEV") throw error;
214
+ cpSync(source, target, {
215
+ recursive: true,
216
+ verbatimSymlinks: true,
217
+ preserveTimestamps: true
218
+ });
219
+ rmSync(source, { recursive: true, force: true });
220
+ }
207
221
  return target;
208
222
  }
209
223
 
@@ -388,4 +402,4 @@ export {
388
402
  followPins,
389
403
  syncWorktree
390
404
  };
391
- //# sourceMappingURL=chunk-VYQJPT27.js.map
405
+ //# sourceMappingURL=chunk-S2FUWBLO.js.map
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  readFixtures,
6
6
  smoke
7
- } from "./chunk-ARXCYFFZ.js";
7
+ } from "./chunk-GQRDEIQA.js";
8
8
  import {
9
9
  ArgumentError,
10
10
  EXIT,
@@ -51,4 +51,4 @@ export {
51
51
  printSmoke,
52
52
  run
53
53
  };
54
- //# sourceMappingURL=chunk-OGCJO6HQ.js.map
54
+ //# sourceMappingURL=chunk-TQRLWO4F.js.map
@@ -1,14 +1,16 @@
1
1
  import {
2
2
  sourceFor
3
- } from "./chunk-7TD53M7L.js";
3
+ } from "./chunk-E272CFPS.js";
4
4
  import {
5
5
  POLICIES,
6
6
  customMode,
7
- customPolicy
8
- } from "./chunk-2ZH77O2D.js";
7
+ customPolicy,
8
+ externalId,
9
+ externalPolicy
10
+ } from "./chunk-Y7FYCVUK.js";
9
11
  import {
10
12
  RUNTIMES
11
- } from "./chunk-ARXCYFFZ.js";
13
+ } from "./chunk-GQRDEIQA.js";
12
14
 
13
15
  // src/hooks/inspection/list.ts
14
16
  function policyRows(compiled) {
@@ -24,7 +26,13 @@ function policyRows(compiled) {
24
26
  options: {},
25
27
  mode: customMode(entry)
26
28
  }));
27
- return [...guards, ...custom].flatMap((entry) => {
29
+ const external = (compiled.external ?? []).map((entry) => ({
30
+ id: externalId(entry),
31
+ policy: externalPolicy(entry),
32
+ options: {},
33
+ mode: entry.mode
34
+ }));
35
+ return [...guards, ...custom, ...external].flatMap((entry) => {
28
36
  const events = entry.policy.eventsFor?.(entry.policy.options(entry.options)) ?? entry.policy.events;
29
37
  return events.filter(
30
38
  (event) => RUNTIMES[runtime].capabilities.events[event] !== "unsupported"
@@ -42,4 +50,4 @@ function policyRows(compiled) {
42
50
  export {
43
51
  policyRows
44
52
  };
45
- //# sourceMappingURL=chunk-VBWB2T3C.js.map
53
+ //# sourceMappingURL=chunk-UVPIVSZB.js.map
@@ -5,10 +5,10 @@ import {
5
5
  } from "./chunk-HQOB7OQS.js";
6
6
  import {
7
7
  readStoreSettings
8
- } from "./chunk-3V37OZQH.js";
8
+ } from "./chunk-PAY6HEEY.js";
9
9
  import {
10
10
  projectStateDir
11
- } from "./chunk-FQLCD4HU.js";
11
+ } from "./chunk-KLIYFD3W.js";
12
12
  import {
13
13
  expandPath
14
14
  } from "./chunk-GUHOEIHP.js";
@@ -154,4 +154,4 @@ export {
154
154
  tail,
155
155
  logLocation
156
156
  };
157
- //# sourceMappingURL=chunk-MHKY6TNF.js.map
157
+ //# sourceMappingURL=chunk-VN34GLGJ.js.map
@@ -0,0 +1,71 @@
1
+ import {
2
+ globPattern
3
+ } from "./chunk-374AZ4J4.js";
4
+
5
+ // src/hooks/owners.ts
6
+ var FIELDS = ["paths", "owner", "note", "mode"];
7
+ function readEntry(value, at) {
8
+ const where = `[[owners]] entry ${at + 1}`;
9
+ if (!value || typeof value !== "object" || Array.isArray(value))
10
+ throw new Error(`${where} must be a table`);
11
+ const entry = value;
12
+ const unknown = Object.keys(entry).find((key) => !FIELDS.includes(key));
13
+ if (unknown) throw new Error(`${where}: unknown key ${unknown}`);
14
+ const paths = entry["paths"];
15
+ if (!Array.isArray(paths) || paths.length === 0 || !paths.every(
16
+ (glob) => typeof glob === "string" && glob !== "" && !glob.startsWith("/") && !glob.split("/").includes("..")
17
+ ))
18
+ throw new Error(
19
+ `${where}: paths must be a nonempty list of globs inside the project`
20
+ );
21
+ const owner = entry["owner"];
22
+ if (typeof owner !== "string" || owner.trim() === "")
23
+ throw new Error(`${where}: owner must be a name`);
24
+ const note = entry["note"];
25
+ if (note !== void 0 && typeof note !== "string")
26
+ throw new Error(`${where}: note must be a string`);
27
+ const mode = entry["mode"] ?? "warn";
28
+ if (mode !== "warn" && mode !== "observe")
29
+ throw new Error(`${where}: mode must be warn or observe`);
30
+ return {
31
+ paths,
32
+ owner,
33
+ ...note !== void 0 && note !== "" ? { note } : {},
34
+ mode
35
+ };
36
+ }
37
+ function readOwners(value) {
38
+ if (value === void 0) return [];
39
+ if (!Array.isArray(value))
40
+ throw new Error("[[owners]] must be an array of tables");
41
+ return value.map(readEntry);
42
+ }
43
+ function ownersOf(entries, path) {
44
+ return entries.filter(
45
+ (entry) => entry.paths.some((glob) => globPattern(glob).test(path))
46
+ );
47
+ }
48
+ function ownerLine(entry, path) {
49
+ return `${path} belongs to ${entry.owner}${entry.note ? `: ${entry.note}` : ""}`;
50
+ }
51
+ function ownerNotices(entries, paths) {
52
+ const hits = /* @__PURE__ */ new Map();
53
+ for (const path of paths)
54
+ for (const entry of ownersOf(entries, path)) {
55
+ if (entry.mode !== "warn") continue;
56
+ hits.set(entry, [...hits.get(entry) ?? [], path]);
57
+ }
58
+ return [...hits].map(([entry, matched]) => {
59
+ const sorted = [...matched].sort();
60
+ const more = sorted.length > 1 ? ` (and ${sorted.length - 1} more)` : "";
61
+ return `${ownerLine(entry, sorted[0])}${more}`;
62
+ });
63
+ }
64
+
65
+ export {
66
+ readOwners,
67
+ ownersOf,
68
+ ownerLine,
69
+ ownerNotices
70
+ };
71
+ //# sourceMappingURL=chunk-WUFNKK3U.js.map