@modootoday/pmcp 0.20.0 → 0.22.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 (124) 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-QJ6MGLBX.js → apply-3PR4UOES.js} +58 -24
  6. package/dist/{available-HYSDAFYH.js → available-BFXLII4A.js} +7 -7
  7. package/dist/{broadcast-LYOA6BEW.js → broadcast-ZALGUJVR.js} +4 -4
  8. package/dist/chunk-2GI5RM3M.js +53 -0
  9. package/dist/chunk-2QJGUR23.js +274 -0
  10. package/dist/{chunk-FD6VGFYZ.js → chunk-3LADLKAI.js} +207 -15
  11. package/dist/{chunk-MZEMLFFD.js → chunk-3OBJVG5R.js} +2 -2
  12. package/dist/{chunk-IQD4W53M.js → chunk-57Q75MS4.js} +18 -18
  13. package/dist/chunk-5YCKFU5Q.js +1672 -0
  14. package/dist/{chunk-IZABPDAO.js → chunk-5ZUDBC3P.js} +2 -2
  15. package/dist/{chunk-EKPMVEIA.js → chunk-73IDLWRI.js} +7 -4
  16. package/dist/{chunk-QYH2NR6G.js → chunk-7FV2LORT.js} +2 -2
  17. package/dist/{chunk-4VK5G3SV.js → chunk-E6YP2PMO.js} +3 -5
  18. package/dist/{chunk-RMHZFWHF.js → chunk-EPNTYTDZ.js} +33 -33
  19. package/dist/{chunk-5JPD6VIH.js → chunk-GBKRDRMZ.js} +22 -7
  20. package/dist/{chunk-T6GOWHK6.js → chunk-GFOQDLPL.js} +6 -1
  21. package/dist/{chunk-RBNMNKNN.js → chunk-JQVSDPFL.js} +3 -3
  22. package/dist/{chunk-OG7QR2DP.js → chunk-KEHB4FZP.js} +17 -2
  23. package/dist/chunk-KUBHGVTD.js +126 -0
  24. package/dist/chunk-L42U5XKC.js +7 -0
  25. package/dist/chunk-LFFIQBNY.js +115 -0
  26. package/dist/{chunk-O2JWF7ZM.js → chunk-LVNGMGOM.js} +2 -2
  27. package/dist/{chunk-PQTM27GU.js → chunk-MR5IBS6L.js} +6 -7
  28. package/dist/{chunk-OAIQ7A3R.js → chunk-NDED2O5B.js} +5 -5
  29. package/dist/{chunk-M2RYXWX2.js → chunk-NHUMPEPV.js} +2 -2
  30. package/dist/{chunk-ONP6JRFZ.js → chunk-OFJIMBTL.js} +2 -2
  31. package/dist/{chunk-YN5GQCHN.js → chunk-RHJEGLYM.js} +6 -1
  32. package/dist/{chunk-JBHGJKSL.js → chunk-RNC7PGW2.js} +2 -2
  33. package/dist/{chunk-J6HNP6HA.js → chunk-RNE4WPBS.js} +2 -2
  34. package/dist/{chunk-YDICIB2A.js → chunk-S4Y44CCC.js} +2 -2
  35. package/dist/{chunk-K2C3KFGB.js → chunk-SEM6WD7J.js} +29 -17
  36. package/dist/{chunk-CQZYQAAV.js → chunk-SLCNCAWY.js} +3 -3
  37. package/dist/{chunk-L4MFGGSI.js → chunk-SPZ42EWE.js} +2 -2
  38. package/dist/{chunk-QOFSPFJ6.js → chunk-TCW2H47H.js} +3405 -3395
  39. package/dist/{chunk-FQAJSNNU.js → chunk-TPGJXENR.js} +3 -3
  40. package/dist/chunk-UKR64U7J.js +20 -0
  41. package/dist/{chunk-66F3HLW4.js → chunk-XB363ZXT.js} +122 -4
  42. package/dist/{chunk-UD3BEEBQ.js → chunk-XZ2TDH3J.js} +80 -3
  43. package/dist/{chunk-QSIADSMQ.js → chunk-Z6WRFOFT.js} +3 -3
  44. package/dist/{claude-GT2BPXEL.js → claude-XVLF4N4S.js} +3 -3
  45. package/dist/{cli-IV5DJCXU.js → cli-6FWRBCWM.js} +8 -8
  46. package/dist/{cli-6HTAJ54L.js → cli-BEEDAD4E.js} +7 -7
  47. package/dist/cli.js +11 -11
  48. package/dist/{completion-PPM7MEI2.js → completion-LHYNCQ3N.js} +7 -7
  49. package/dist/{diagnostics-EWU2ROTG.js → diagnostics-ABTJUYZQ.js} +5 -6
  50. package/dist/{doctor-ZWZQMDKZ.js → doctor-GPPO5L4F.js} +36 -36
  51. package/dist/{entry-NDICBQ2F.js → entry-ARGY5CKA.js} +14 -15
  52. package/dist/{exec-mcp-AG4G7SG7.js → exec-mcp-JEF74XVP.js} +16 -14
  53. package/dist/{harness-JABSZCAA.js → harness-OCXW6YE4.js} +6 -6
  54. package/dist/harness-launch-gate.js +3 -4
  55. package/dist/harness-worker.js +5 -6
  56. package/dist/hook-body.js +247 -86
  57. package/dist/{hook-spec-C7umArqw.d.ts → hook-spec-hZL4MSgi.d.ts} +8 -3
  58. package/dist/hooks-JHXUN5MD.js +24 -0
  59. package/dist/{host-2SZRMHZX.js → host-OBRHBDRE.js} +6 -7
  60. package/dist/{host-BWZ5LA4Q.js → host-VI4ZFCZP.js} +18 -16
  61. package/dist/{host-run-SXLV4LHI.js → host-run-H7AITG7C.js} +5 -7
  62. package/dist/http.js +1 -1
  63. package/dist/{import-mcp-2M7SZRVQ.js → import-mcp-3Y33CUHF.js} +15 -12
  64. package/dist/index.d.ts +11 -2
  65. package/dist/index.js +25 -25
  66. package/dist/{init-HOOIFBAD.js → init-WZJHMWNJ.js} +3 -3
  67. package/dist/{install-HF6CROQP.js → install-7V6NIA7W.js} +4 -4
  68. package/dist/{invoke-JP4MILYY.js → invoke-GWWTXQLO.js} +7 -8
  69. package/dist/{list-UBSBUZKS.js → list-Y6UPLGNF.js} +21 -18
  70. package/dist/{logout-OO3DERRK.js → logout-KAUW4JZZ.js} +16 -13
  71. package/dist/{logs-K3QXKRD4.js → logs-74JGLQG6.js} +4 -4
  72. package/dist/{mailbox-DAJV6VAI.js → mailbox-VK5AVTHI.js} +7 -7
  73. package/dist/{mainline-6K5BA3WX.js → mainline-Q42M2GJ2.js} +173 -34
  74. package/dist/{mcp-JXNTKRJG.js → mcp-IDEUIY2F.js} +2 -2
  75. package/dist/{pause-GRVTSKOK.js → pause-CZ2OZYLC.js} +4 -4
  76. package/dist/project/hook-adapter.d.ts +1 -1
  77. package/dist/{project-M672MKQH.js → project-GVVWLDOJ.js} +5 -5
  78. package/dist/{pty-LHKJKY2E.js → pty-CDLQ4NP2.js} +3 -3
  79. package/dist/report-Z3JV2PCT.js +105 -0
  80. package/dist/{resume-6DMPGG3N.js → resume-DFIHT2RO.js} +4 -4
  81. package/dist/{run-ORBIERI3.js → run-HVNKQHVU.js} +4 -4
  82. package/dist/{run-5W566T3V.js → run-RRWB7U2Q.js} +15 -12
  83. package/dist/{serve-73SRPAV4.js → serve-KJSOU3BR.js} +3 -3
  84. package/dist/{session-XM2CR425.js → session-YZVX4NGN.js} +4 -4
  85. package/dist/{setup-ULKDPF5B.js → setup-3GET6K3J.js} +4 -4
  86. package/dist/smoke-FQQJOQBD.js +16 -0
  87. package/dist/{start-login-BGFAMCZL.js → start-login-RNHSEX5P.js} +16 -13
  88. package/dist/{status-YHXEAJ7U.js → status-3RTGDN2K.js} +10 -10
  89. package/dist/{status-YCW6YJ3S.js → status-RR4VZARJ.js} +40 -23
  90. package/dist/{status-73FEFQUQ.js → status-Y25ONHA5.js} +16 -13
  91. package/dist/stdio.js +2 -2
  92. package/dist/{sweep-XF2HG3EO.js → sweep-EPJMEZR6.js} +4 -4
  93. package/dist/{test-IMNBXOYW.js → test-7NYPQ6YU.js} +30 -20
  94. package/dist/{tui-5GDA22TB.js → tui-H5RPSF4B.js} +4 -4
  95. package/dist/{unbroadcast-XP3OCVN3.js → unbroadcast-NTOC3PY3.js} +4 -4
  96. package/dist/{worker-RV6NGSXT.js → worker-YWFTWIBP.js} +9 -10
  97. package/dist/{worktree-list-4PLE7K6L.js → worktree-list-EMKUMCTQ.js} +2 -2
  98. package/dist/{worktree-sync-GQVYAXGJ.js → worktree-sync-A277AF4M.js} +4 -6
  99. package/docs/commands.md +14 -7
  100. package/docs/git-workflow.md +53 -13
  101. package/docs/hooks.md +138 -10
  102. package/docs/project-configuration.md +31 -1
  103. package/docs/upgrading.md +58 -0
  104. package/gemini-extension.json +2 -2
  105. package/mcp.json +1 -1
  106. package/package.json +5 -5
  107. package/plugin.json +1 -1
  108. package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
  109. package/plugins/pmcp/.mcp.json +1 -1
  110. package/plugins/pmcp/gemini-extension.json +2 -2
  111. package/plugins/pmcp/mcp.json +1 -1
  112. package/plugins/pmcp/mod/sessions/format.ts +2 -2
  113. package/plugins/pmcp/plugin.json +1 -1
  114. package/plugins/pmcp/skills/agent-assets-migrate/SKILL.md +11 -8
  115. package/plugins/pmcp/skills/pmcp-project-init/SKILL.md +11 -7
  116. package/skills/agent-assets-migrate/SKILL.md +11 -8
  117. package/skills/pmcp-project-init/SKILL.md +11 -7
  118. package/dist/chunk-7SDOSTW7.js +0 -130
  119. package/dist/chunk-AWZF72SH.js +0 -1025
  120. package/dist/chunk-FGYFA6JY.js +0 -7
  121. package/dist/chunk-ICF2JZSN.js +0 -92
  122. package/dist/chunk-ISNRDHSD.js +0 -74
  123. package/dist/chunk-QDY6BWE6.js +0 -396
  124. package/dist/hooks-YVQSDQV3.js +0 -21
@@ -612,7 +612,7 @@
612
612
  },
613
613
  {
614
614
  "name": "pmcp",
615
- "version": "0.20.0",
615
+ "version": "0.22.0",
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.20.0",
448
+ "version": "0.22.0",
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.20.0",
3
+ "version": "0.22.0",
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.20.0", "serve"]
6
+ "args": ["-y", "@modootoday/pmcp@0.22.0", "serve"]
7
7
  }
8
8
  }
9
9
  }
@@ -3,51 +3,63 @@ import {
3
3
  } from "./chunk-PEMMV5YQ.js";
4
4
  import {
5
5
  specFrom
6
- } from "./chunk-JBHGJKSL.js";
7
- import "./chunk-RPCIROW7.js";
6
+ } from "./chunk-RNC7PGW2.js";
8
7
  import {
9
- project
10
- } from "./chunk-FD6VGFYZ.js";
8
+ printSmoke,
9
+ runSmoke
10
+ } from "./chunk-2GI5RM3M.js";
11
+ import {
12
+ configFrom
13
+ } from "./chunk-RPCIROW7.js";
14
+ import {
15
+ describeHookProblem,
16
+ project,
17
+ unmanagedHookProblems
18
+ } from "./chunk-3LADLKAI.js";
11
19
  import "./chunk-P4N7DBD5.js";
20
+ import "./chunk-2QJGUR23.js";
12
21
  import {
22
+ checkBudget,
13
23
  renderFrontmatter,
14
24
  splitFrontmatter
15
- } from "./chunk-AWZF72SH.js";
16
- import "./chunk-QDY6BWE6.js";
17
- import "./chunk-73AKO4UL.js";
18
- import {
19
- RUNTIMES
20
- } from "./chunk-QOFSPFJ6.js";
21
- import "./chunk-HQOB7OQS.js";
22
- import "./chunk-ICF2JZSN.js";
23
- import "./chunk-UD3BEEBQ.js";
24
- import "./chunk-ISNRDHSD.js";
25
+ } from "./chunk-TCW2H47H.js";
26
+ import "./chunk-UKR64U7J.js";
27
+ import "./chunk-XZ2TDH3J.js";
28
+ import "./chunk-KUBHGVTD.js";
25
29
  import "./chunk-EATCUWGG.js";
30
+ import "./chunk-OFJIMBTL.js";
26
31
  import {
27
32
  ProjectError
28
33
  } from "./chunk-NRBQK6UX.js";
29
- import "./chunk-ONP6JRFZ.js";
34
+ import "./chunk-LFFIQBNY.js";
35
+ import "./chunk-HQOB7OQS.js";
36
+ import "./chunk-73AKO4UL.js";
30
37
  import "./chunk-P6LNYYYH.js";
31
- import "./chunk-5JPD6VIH.js";
38
+ import "./chunk-GBKRDRMZ.js";
32
39
  import "./chunk-2Q6MNGU5.js";
33
- import "./chunk-PQTM27GU.js";
34
- import "./chunk-QSIADSMQ.js";
40
+ import "./chunk-MR5IBS6L.js";
41
+ import "./chunk-Z6WRFOFT.js";
35
42
  import "./chunk-G7JONWL4.js";
36
43
  import "./chunk-Q5H3L6Y4.js";
44
+ import {
45
+ RUNTIMES,
46
+ readTestTable
47
+ } from "./chunk-5YCKFU5Q.js";
37
48
  import "./chunk-JEL35P7S.js";
38
- import "./chunk-A4PKLESO.js";
49
+ import {
50
+ ArgumentError
51
+ } from "./chunk-A4PKLESO.js";
39
52
  import "./chunk-V4NPDK6X.js";
40
53
  import {
41
54
  kindOf
42
55
  } from "./chunk-4CRRLDDS.js";
43
56
  import "./chunk-YSAWTGNA.js";
44
- import "./chunk-7SDOSTW7.js";
45
57
  import {
46
58
  recordProjector
47
- } from "./chunk-66F3HLW4.js";
59
+ } from "./chunk-XB363ZXT.js";
48
60
  import "./chunk-OEH47H6A.js";
49
61
  import "./chunk-IJBSOWHK.js";
50
- import "./chunk-FGYFA6JY.js";
62
+ import "./chunk-L42U5XKC.js";
51
63
  import "./chunk-GJXOFDJT.js";
52
64
  import "./chunk-PMJG2CXF.js";
53
65
  import "./chunk-J6KL3COD.js";
@@ -204,9 +216,23 @@ function reproject(context, spec) {
204
216
  }
205
217
  return 0;
206
218
  }
219
+ function smokeCheck(context, spec) {
220
+ const config = configFrom(context);
221
+ const hooks = config?.raw.hooks ?? {};
222
+ const file = readTestTable(hooks["test"]);
223
+ if (file === void 0) {
224
+ context.ui.error("--smoke needs [hooks.test] fixtures in pmcp.toml");
225
+ return 2;
226
+ }
227
+ const result = runSmoke(spec.root, file, context.env);
228
+ printSmoke(context.ui, result);
229
+ return result.findings.length === 0 ? 0 : 2;
230
+ }
207
231
  function projectOrCheck(context) {
208
232
  const spec = specFrom(context);
233
+ const smoke = context.args.flags.has("smoke");
209
234
  if (!context.args.flags.has("check")) {
235
+ if (smoke) throw new ArgumentError("--smoke needs --check");
210
236
  return reproject(context, spec);
211
237
  }
212
238
  const result = project(spec, { check: true });
@@ -220,7 +246,15 @@ function projectOrCheck(context) {
220
246
  return 2;
221
247
  }
222
248
  context.ui.success(`${result.outputs} outputs match`);
223
- return 0;
249
+ const broken = unmanagedHookProblems(spec.root, context.env);
250
+ for (const problem of broken)
251
+ context.ui.error(
252
+ `native hook entry pmcp does not own: ${describeHookProblem(problem)}`
253
+ );
254
+ const over = spec.budget ? checkBudget(spec, spec.budget).problems : [];
255
+ for (const problem of over) context.ui.error(problem);
256
+ if (broken.length > 0 || over.length > 0) return 2;
257
+ return smoke ? smokeCheck(context, spec) : 0;
224
258
  }
225
259
  function addAndProject(context, name) {
226
260
  const spec = specFrom(context);
@@ -240,4 +274,4 @@ export {
240
274
  projectOrCheck,
241
275
  removeAndProject
242
276
  };
243
- //# sourceMappingURL=apply-QJ6MGLBX.js.map
277
+ //# sourceMappingURL=apply-3PR4UOES.js.map
@@ -1,18 +1,18 @@
1
+ import {
2
+ sayStanding
3
+ } from "./chunk-4NDEP7HU.js";
1
4
  import {
2
5
  matchingSkills,
3
6
  readInstalledDependencies
4
7
  } from "./chunk-F5WBMUOT.js";
5
- import {
6
- invocation
7
- } from "./chunk-J7UYNJCR.js";
8
- import {
9
- sayStanding
10
- } from "./chunk-4NDEP7HU.js";
11
8
  import {
12
9
  projectFrom,
13
10
  remoteCatalog
14
11
  } from "./chunk-R5MT42JS.js";
15
12
  import "./chunk-RMATE45Z.js";
13
+ import {
14
+ invocation
15
+ } from "./chunk-J7UYNJCR.js";
16
16
  import "./chunk-73AKO4UL.js";
17
17
  import {
18
18
  availableSpec
@@ -70,4 +70,4 @@ var availableCommand = {
70
70
  export {
71
71
  availableCommand
72
72
  };
73
- //# sourceMappingURL=available-HYSDAFYH.js.map
73
+ //# sourceMappingURL=available-BFXLII4A.js.map
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  change
3
- } from "./chunk-QYH2NR6G.js";
4
- import "./chunk-PQTM27GU.js";
5
- import "./chunk-QSIADSMQ.js";
3
+ } from "./chunk-7FV2LORT.js";
4
+ import "./chunk-MR5IBS6L.js";
5
+ import "./chunk-Z6WRFOFT.js";
6
6
  import "./chunk-A4PKLESO.js";
7
7
  import "./chunk-OEH47H6A.js";
8
8
  import "./chunk-IJBSOWHK.js";
@@ -14,4 +14,4 @@ var run = (context) => change(context, "broadcast");
14
14
  export {
15
15
  run
16
16
  };
17
- //# sourceMappingURL=broadcast-LYOA6BEW.js.map
17
+ //# sourceMappingURL=broadcast-ZALGUJVR.js.map
@@ -0,0 +1,53 @@
1
+ import {
2
+ configFrom
3
+ } from "./chunk-RPCIROW7.js";
4
+ import {
5
+ readFixtures,
6
+ smoke
7
+ } from "./chunk-5YCKFU5Q.js";
8
+ import {
9
+ ArgumentError
10
+ } from "./chunk-A4PKLESO.js";
11
+
12
+ // src/commands/hooks/smoke.ts
13
+ import { readFileSync } from "fs";
14
+ import { resolve } from "path";
15
+ function runSmoke(root, file, env) {
16
+ let text;
17
+ try {
18
+ text = readFileSync(resolve(root, file), "utf8");
19
+ } catch {
20
+ throw new ArgumentError(`cannot read fixtures ${file}`);
21
+ }
22
+ try {
23
+ return smoke(root, readFixtures(text), env);
24
+ } catch (error) {
25
+ throw new ArgumentError(
26
+ error instanceof Error ? error.message : String(error)
27
+ );
28
+ }
29
+ }
30
+ function printSmoke(ui, result) {
31
+ for (const finding of result.findings)
32
+ ui.line(` \u2717 ${finding.where}: ${finding.message}`);
33
+ ui.line(
34
+ result.findings.length === 0 ? ` \u2713 ${result.cases} run(s) on ${result.runtimes.join(", ")}; ${result.guards.length} enforced guard(s) covered` : ` \u2717 ${result.findings.length} finding(s) in ${result.cases} run(s)`
35
+ );
36
+ }
37
+ async function run(context, file) {
38
+ const config = configFrom(context);
39
+ if (!config)
40
+ throw new ArgumentError("no pmcp.toml here or above; pass --config");
41
+ const result = runSmoke(config.dir, file, context.env);
42
+ if (context.args.flags.has("json"))
43
+ context.ui.data(JSON.stringify({ version: 1, ...result }) + "\n");
44
+ else printSmoke(context.ui, result);
45
+ return result.findings.length === 0 ? 0 : 1;
46
+ }
47
+
48
+ export {
49
+ runSmoke,
50
+ printSmoke,
51
+ run
52
+ };
53
+ //# sourceMappingURL=chunk-2GI5RM3M.js.map
@@ -0,0 +1,274 @@
1
+ import {
2
+ SETTINGS,
3
+ block,
4
+ censusDirs,
5
+ changedSincePlan,
6
+ deleteKey,
7
+ fingerprint,
8
+ getKey,
9
+ isPermissionPath,
10
+ linkOf,
11
+ permissionProblems,
12
+ permissionWarnings,
13
+ plan,
14
+ programVersion,
15
+ readJson,
16
+ same,
17
+ setKey,
18
+ splitFrontmatter,
19
+ splitKeyed,
20
+ versionMatches,
21
+ withoutBlock
22
+ } from "./chunk-TCW2H47H.js";
23
+ import {
24
+ ProjectError,
25
+ RULES_DIR,
26
+ trackedFiles
27
+ } from "./chunk-NRBQK6UX.js";
28
+ import {
29
+ lockVersionProblem,
30
+ readLock,
31
+ replaceFile
32
+ } from "./chunk-XB363ZXT.js";
33
+
34
+ // src/project/apply/census.ts
35
+ import { existsSync, readFileSync, readdirSync } from "fs";
36
+ import { join, posix } from "path";
37
+ function undeclared(spec, outputs) {
38
+ const declared = new Set(outputs.map((o) => o.path));
39
+ const found = [];
40
+ for (const dir of censusDirs(spec)) {
41
+ const abs = join(spec.root, dir);
42
+ if (!existsSync(abs)) continue;
43
+ for (const entry of readdirSync(abs)) {
44
+ const path = `${dir}/${entry}`;
45
+ if (!declared.has(path)) found.push(path);
46
+ }
47
+ }
48
+ const rules = join(spec.root, RULES_DIR);
49
+ if (spec.tools.has("grok") && existsSync(rules)) {
50
+ for (const entry of readdirSync(rules, { withFileTypes: true })) {
51
+ if (entry.isDirectory()) continue;
52
+ found.push(`${RULES_DIR}/${entry.name}`);
53
+ }
54
+ }
55
+ return found.sort();
56
+ }
57
+ function deadGlobs(root, outputs) {
58
+ const rules = outputs.filter(
59
+ (o) => (o.kind === "link" || o.kind === "file") && o.path.startsWith(`${RULES_DIR}/`)
60
+ );
61
+ if (rules.length === 0) return [];
62
+ const tracked = trackedFiles(root, true);
63
+ if (tracked.length === 0) return [];
64
+ const seen = /* @__PURE__ */ new Set();
65
+ for (const file of tracked) {
66
+ const parts = file.split("/");
67
+ for (let i = 1; i <= parts.length; i += 1)
68
+ seen.add(parts.slice(0, i).join("/"));
69
+ }
70
+ const dead = [];
71
+ for (const rule of rules) {
72
+ let text;
73
+ if (rule.kind === "file") {
74
+ text = rule.content;
75
+ } else if (rule.kind === "link") {
76
+ const abs = join(root, posix.join(posix.dirname(rule.path), rule.target));
77
+ if (!existsSync(abs)) continue;
78
+ text = readFileSync(abs, "utf8");
79
+ } else {
80
+ continue;
81
+ }
82
+ const paths = splitFrontmatter(text).meta["paths"];
83
+ for (const glob of [paths ?? []].flat()) {
84
+ if (typeof glob !== "string") continue;
85
+ const prefix = glob.replace(/\*.*$/u, "").replace(/\/$/u, "");
86
+ if (prefix !== "" && !seen.has(prefix))
87
+ dead.push(`${rule.path}: ${glob}`);
88
+ }
89
+ }
90
+ return dead;
91
+ }
92
+
93
+ // src/project/guard-versions.ts
94
+ function guardVersionProblems(spec, env = process.env) {
95
+ const problems = [];
96
+ for (const entry of spec.hookBundle?.policy?.custom ?? []) {
97
+ if (entry.version === void 0) continue;
98
+ const program = entry.command[0] ?? "";
99
+ const output = programVersion(program, spec.root, env);
100
+ if (output === null)
101
+ problems.push(
102
+ `custom guard ${entry.name}: ${program} --version did not run; install ${program} ${entry.version}`
103
+ );
104
+ else if (!versionMatches(output, entry.version))
105
+ problems.push(
106
+ `custom guard ${entry.name}: ${program} --version reports "${output.split("\n")[0]}", not ${entry.version}; review the program and update version`
107
+ );
108
+ }
109
+ return problems;
110
+ }
111
+
112
+ // src/project/apply/native.ts
113
+ import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, rmSync } from "fs";
114
+ import { dirname, join as join2 } from "path";
115
+ function readNativeJson(root, outputs, stale) {
116
+ const jsonPaths = new Set(
117
+ outputs.filter((output) => output.kind === "json").map((output) => output.file)
118
+ );
119
+ for (const entry of stale) {
120
+ const keyed = splitKeyed(entry.path);
121
+ if (entry.kind === "json" && keyed) {
122
+ jsonPaths.add(keyed.file);
123
+ }
124
+ }
125
+ for (const path of jsonPaths) {
126
+ readJson(join2(root, path));
127
+ }
128
+ }
129
+ function writeJson(root, file, sets, drops) {
130
+ const abs = join2(root, file);
131
+ const before = readJson(abs);
132
+ const after = structuredClone(before);
133
+ for (const key of drops) deleteKey(after, key);
134
+ for (const output of sets) {
135
+ if (output.kind !== "json") {
136
+ continue;
137
+ }
138
+ if (output.managed && Array.isArray(output.value) && output.value.length === 0) {
139
+ deleteKey(after, output.key);
140
+ } else {
141
+ setKey(after, output.key, output.value);
142
+ }
143
+ }
144
+ if (same(before, after)) return;
145
+ if (!existsSync2(abs) && Object.keys(after).length === 0) return;
146
+ mkdirSync(dirname(abs), { recursive: true });
147
+ replaceFile(abs, `${JSON.stringify(after, null, 2)}
148
+ `);
149
+ }
150
+ function separator(before) {
151
+ if (before === "" || before.endsWith("\n\n")) return "";
152
+ return before.endsWith("\n") ? "\n" : "\n\n";
153
+ }
154
+ function writeBlock(root, file, content) {
155
+ const abs = join2(root, file);
156
+ const before = existsSync2(abs) ? readFileSync2(abs, "utf8") : "";
157
+ let after = withoutBlock(before);
158
+ if (content !== null) {
159
+ const sep = separator(after);
160
+ after = `${after}${sep}${block(content)}`;
161
+ }
162
+ if (after === before) return;
163
+ mkdirSync(dirname(abs), { recursive: true });
164
+ replaceFile(abs, after);
165
+ }
166
+ function writeNative(root, outputs, stale, basis = /* @__PURE__ */ new Map()) {
167
+ const moved = changedSincePlan(root, basis);
168
+ if (moved.length > 0) throw new ProjectError(moved.join("; "));
169
+ let pruned = 0;
170
+ const jsonFiles = /* @__PURE__ */ new Map();
171
+ const blockFiles = /* @__PURE__ */ new Map();
172
+ for (const output of outputs) {
173
+ if (output.kind === "json") {
174
+ const entry = jsonFiles.get(output.file) ?? { sets: [], drops: [] };
175
+ entry.sets.push(output);
176
+ jsonFiles.set(output.file, entry);
177
+ }
178
+ if (output.kind === "block") blockFiles.set(output.file, output.content);
179
+ }
180
+ for (const entry of stale) {
181
+ const keyed = splitKeyed(entry.path);
182
+ if (keyed && keyed.key.length === 1 && keyed.key[0] === "pmcp") {
183
+ if (!blockFiles.has(keyed.file)) blockFiles.set(keyed.file, null);
184
+ } else if (keyed) {
185
+ const group = jsonFiles.get(keyed.file) ?? { sets: [], drops: [] };
186
+ group.drops.push(keyed.key);
187
+ jsonFiles.set(keyed.file, group);
188
+ } else {
189
+ rmSync(join2(root, entry.path), { force: true, recursive: true });
190
+ }
191
+ pruned += 1;
192
+ }
193
+ for (const [file, { sets, drops }] of jsonFiles)
194
+ writeJson(root, file, sets, drops);
195
+ for (const [file, content] of blockFiles) writeBlock(root, file, content);
196
+ return pruned;
197
+ }
198
+
199
+ // src/project/apply/prepare.ts
200
+ import { join as join3 } from "path";
201
+ function prepare(spec) {
202
+ const basis = /* @__PURE__ */ new Map([
203
+ [SETTINGS, fingerprint(join3(spec.root, SETTINGS))]
204
+ ]);
205
+ const lock = readLock(spec.root);
206
+ const ownedTargets = new Map(
207
+ lock.filter((entry) => entry.kind === "link" && entry.target !== void 0).map((entry) => [entry.path, entry.target])
208
+ );
209
+ const outputs = plan(spec, ownedTargets);
210
+ const owned = new Set(lock.map((entry) => entry.path));
211
+ const planned = new Set(outputs.map((output) => output.path));
212
+ const stale = lock.filter((entry) => !planned.has(entry.path));
213
+ readNativeJson(spec.root, outputs, stale);
214
+ return { outputs, owned, stale, basis };
215
+ }
216
+
217
+ // src/project/apply/present.ts
218
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
219
+ import { join as join4 } from "path";
220
+ function present(root, output) {
221
+ const abs = join4(root, "file" in output ? output.file : output.path);
222
+ switch (output.kind) {
223
+ case "link":
224
+ return linkOf(abs) === output.target;
225
+ case "file":
226
+ return existsSync3(abs) && linkOf(abs) === null && readFileSync3(abs, "utf8") === output.content;
227
+ case "json":
228
+ if (output.managed && Array.isArray(output.value) && output.value.length === 0) {
229
+ return getKey(readJson(abs), output.key) === void 0;
230
+ }
231
+ return same(getKey(readJson(abs), output.key), output.value);
232
+ case "block":
233
+ return existsSync3(abs) && readFileSync3(abs, "utf8").includes(block(output.content));
234
+ }
235
+ }
236
+
237
+ // src/project/apply/check.ts
238
+ function checkProblems(spec, outputs, stale) {
239
+ return [
240
+ ...outputs.filter((o) => !isPermissionPath(o.path) && !present(spec.root, o)).map((o) => `drift: ${o.path}`),
241
+ ...permissionProblems(spec),
242
+ ...stale.map((e) => `stale: ${e.path}`),
243
+ ...undeclared(spec, outputs).map((p) => `undeclared: ${p}`),
244
+ ...deadGlobs(spec.root, outputs).map((p) => `dead glob: ${p}`),
245
+ ...[lockVersionProblem(spec.root)].filter((p) => p !== null)
246
+ ];
247
+ }
248
+
249
+ // src/project/apply/check-project.ts
250
+ function checkProject(spec) {
251
+ const { outputs, stale } = prepare(spec);
252
+ const problems = [
253
+ ...checkProblems(spec, outputs, stale),
254
+ ...guardVersionProblems(spec)
255
+ ];
256
+ const warnings = [...permissionWarnings(spec), ...spec.deprecations ?? []];
257
+ return {
258
+ code: problems.length > 0 ? 2 : 0,
259
+ problems,
260
+ ...warnings.length > 0 ? { warnings } : {},
261
+ outputs: outputs.length,
262
+ pruned: 0
263
+ };
264
+ }
265
+
266
+ export {
267
+ guardVersionProblems,
268
+ deadGlobs,
269
+ present,
270
+ writeNative,
271
+ prepare,
272
+ checkProject
273
+ };
274
+ //# sourceMappingURL=chunk-2QJGUR23.js.map