@modootoday/pmcp 0.30.1 → 0.32.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 (85) 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-4FILH743.js → affected-BHHN2Q3D.js} +3 -2
  6. package/dist/{apply-P2POBHIU.js → apply-SSYZGDJU.js} +10 -10
  7. package/dist/{chunk-HV43X72U.js → chunk-3DRV5KHZ.js} +2 -2
  8. package/dist/{chunk-NHQ5BWMO.js → chunk-6H3HN7E7.js} +4 -4
  9. package/dist/{chunk-I5BKHSVY.js → chunk-AALSWFPA.js} +5 -5
  10. package/dist/{chunk-T6C3TSTO.js → chunk-ESM7TFTO.js} +36 -2
  11. package/dist/{chunk-YP55H3V6.js → chunk-FALOBFE6.js} +3 -3
  12. package/dist/{chunk-N5RB4HU6.js → chunk-FFQA2R5P.js} +3 -3
  13. package/dist/{chunk-EINSPZVE.js → chunk-FGG7JJ5M.js} +2 -2
  14. package/dist/{chunk-UCTZ7LB2.js → chunk-IAR7BL5R.js} +2 -2
  15. package/dist/{chunk-ADIAVEVZ.js → chunk-IFFOJ3IE.js} +2 -2
  16. package/dist/chunk-KNIHXLDE.js +7 -0
  17. package/dist/{chunk-G5OL7NQS.js → chunk-KWCZKCTC.js} +110 -29
  18. package/dist/{chunk-XMCP4SGT.js → chunk-MUGHZ6QC.js} +2 -2
  19. package/dist/{chunk-4NR6F2G5.js → chunk-OIV44CYB.js} +2 -2
  20. package/dist/{chunk-WZGK5TPF.js → chunk-OIYZT4BG.js} +13 -4
  21. package/dist/{chunk-DLM2BQXY.js → chunk-OS5CYV27.js} +3 -3
  22. package/dist/{chunk-5GFNEL6I.js → chunk-PPWEOXIU.js} +14 -14
  23. package/dist/{chunk-RC7JRUM5.js → chunk-PRQICZXO.js} +3 -3
  24. package/dist/{chunk-LVCASOV4.js → chunk-QZY36KNT.js} +4 -2
  25. package/dist/{chunk-LESRSUYY.js → chunk-SMHHL25Y.js} +5 -5
  26. package/dist/{chunk-E5OBYCMP.js → chunk-SU6R4VWV.js} +3 -3
  27. package/dist/{chunk-5WAMDZHF.js → chunk-UKGO2RR7.js} +2 -2
  28. package/dist/{chunk-CO5DP2RP.js → chunk-UT2NACLW.js} +2 -2
  29. package/dist/{chunk-MWEE5HCH.js → chunk-VEJU5HXJ.js} +2 -2
  30. package/dist/{chunk-7YBS5S3F.js → chunk-XADROJFL.js} +2 -2
  31. package/dist/{cli-NSZLKKLU.js → cli-RHOETDBX.js} +5 -5
  32. package/dist/cli.js +3 -3
  33. package/dist/{completion-NLC6EB7Q.js → completion-PE6CHX4K.js} +2 -2
  34. package/dist/{diagnostics-5JG4WLRI.js → diagnostics-7Y5OFV44.js} +7 -7
  35. package/dist/{doctor-RLSWHJ2A.js → doctor-GBIPPKPD.js} +12 -12
  36. package/dist/{doctor-T647TNS5.js → doctor-XY6OMK7W.js} +6 -5
  37. package/dist/{entry-FAVK7RKI.js → entry-4WT2WM6C.js} +11 -11
  38. package/dist/{exec-mcp-7RZP3J3L.js → exec-mcp-BLTFBWND.js} +8 -8
  39. package/dist/{harness-BB6DSAVZ.js → harness-HGBKFIUT.js} +3 -3
  40. package/dist/harness-launch-gate.js +5 -5
  41. package/dist/harness-worker.js +7 -7
  42. package/dist/{heavy-AZSP6VEW.js → heavy-E55QD5LR.js} +5 -4
  43. package/dist/hook-body.js +131 -50
  44. package/dist/{hooks-Y22ODBFZ.js → hooks-MT3CGRSU.js} +3 -3
  45. package/dist/{host-RO54NJCQ.js → host-5AI4JAXD.js} +8 -8
  46. package/dist/{host-HG5BH2G6.js → host-AMKVSOYU.js} +10 -10
  47. package/dist/{host-5PO6OXNR.js → host-FXO4VGE6.js} +4 -4
  48. package/dist/{host-run-6NMZUNPQ.js → host-run-M2KMMU72.js} +6 -6
  49. package/dist/http.js +1 -1
  50. package/dist/{import-mcp-QV3QQA7S.js → import-mcp-QTUVK5GE.js} +7 -7
  51. package/dist/index.d.ts +1 -1
  52. package/dist/index.js +11 -11
  53. package/dist/{init-7YCITJBT.js → init-RAAQOP4D.js} +2 -2
  54. package/dist/{invoke-PWCH3QTK.js → invoke-D2CYSRFG.js} +9 -9
  55. package/dist/{list-ZBIXGLKJ.js → list-UG67V5EO.js} +9 -9
  56. package/dist/{logout-NWOB6FYU.js → logout-Z5KMKTTP.js} +8 -8
  57. package/dist/{mainline-HQPAQ5N2.js → mainline-Y4HOI5R7.js} +5 -4
  58. package/dist/{mcp-6I5I6VGZ.js → mcp-QARZ7L22.js} +2 -2
  59. package/dist/{measure-XD5UDZMJ.js → measure-K7D3GLC6.js} +6 -6
  60. package/dist/{plan-KGGJRUY5.js → plan-JAHYXJHP.js} +6 -5
  61. package/dist/{project-IKIRR3ZN.js → project-5SL2CE5F.js} +4 -4
  62. package/dist/{run-U2NQLEEM.js → run-EUU6TJBI.js} +4 -4
  63. package/dist/{run-VWETBSCC.js → run-H22CN65S.js} +7 -7
  64. package/dist/{serve-EYRBNRYW.js → serve-36VOPK47.js} +3 -3
  65. package/dist/{setup-V7QJKJ3M.js → setup-Y5SM4LKI.js} +4 -3
  66. package/dist/{start-login-S7TSV6U7.js → start-login-3CUVLBDP.js} +8 -8
  67. package/dist/{status-PXSKFHAJ.js → status-SLQQMCZP.js} +8 -8
  68. package/dist/{status-FL3BR362.js → status-ZGFOO5YT.js} +9 -9
  69. package/dist/stdio.js +2 -2
  70. package/dist/{test-PWBXC2D5.js → test-JKU4KELV.js} +8 -8
  71. package/dist/{tui-BNBDMV2M.js → tui-QB42W3XZ.js} +4 -4
  72. package/dist/{worker-6OGOG6E4.js → worker-VPP2HD6O.js} +9 -9
  73. package/docs/hooks.md +2 -1
  74. package/docs/project-configuration.md +3 -0
  75. package/docs/upgrading.md +10 -1
  76. package/gemini-extension.json +2 -2
  77. package/mcp.json +1 -1
  78. package/package.json +5 -5
  79. package/plugin.json +1 -1
  80. package/plugins/pmcp/.claude-plugin/plugin.json +1 -1
  81. package/plugins/pmcp/.mcp.json +1 -1
  82. package/plugins/pmcp/gemini-extension.json +2 -2
  83. package/plugins/pmcp/mcp.json +1 -1
  84. package/plugins/pmcp/plugin.json +1 -1
  85. package/dist/chunk-YPK3ZMDX.js +0 -7
@@ -612,7 +612,7 @@
612
612
  },
613
613
  {
614
614
  "name": "pmcp",
615
- "version": "0.30.1",
615
+ "version": "0.32.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.30.1",
448
+ "version": "0.32.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.30.1",
3
+ "version": "0.32.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.30.1", "serve"]
6
+ "args": ["-y", "@modootoday/pmcp@0.32.0", "serve"]
7
7
  }
8
8
  }
9
9
  }
@@ -15,7 +15,8 @@ import {
15
15
  Reader,
16
16
  child,
17
17
  table
18
- } from "./chunk-T6C3TSTO.js";
18
+ } from "./chunk-ESM7TFTO.js";
19
+ import "./chunk-KNIHXLDE.js";
19
20
  import {
20
21
  ConfigError,
21
22
  findConfig,
@@ -1274,4 +1275,4 @@ export {
1274
1275
  AFFECTED_SCHEMA,
1275
1276
  gitAffected
1276
1277
  };
1277
- //# sourceMappingURL=affected-4FILH743.js.map
1278
+ //# sourceMappingURL=affected-BHHN2Q3D.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-2MX5C7B2.js";
4
4
  import {
5
5
  specFrom
6
- } from "./chunk-7YBS5S3F.js";
6
+ } from "./chunk-XADROJFL.js";
7
7
  import {
8
8
  printSmoke,
9
9
  runSmoke
@@ -15,14 +15,14 @@ import {
15
15
  describeHookProblem,
16
16
  project,
17
17
  unmanagedHookProblems
18
- } from "./chunk-NHQ5BWMO.js";
18
+ } from "./chunk-6H3HN7E7.js";
19
19
  import "./chunk-ANJMLKBR.js";
20
- import "./chunk-E5OBYCMP.js";
20
+ import "./chunk-SU6R4VWV.js";
21
21
  import {
22
22
  checkBudget,
23
23
  renderFrontmatter,
24
24
  splitFrontmatter
25
- } from "./chunk-G5OL7NQS.js";
25
+ } from "./chunk-KWCZKCTC.js";
26
26
  import "./chunk-YEO6I6XN.js";
27
27
  import "./chunk-FLG7VRTC.js";
28
28
  import "./chunk-2GD7PQ7J.js";
@@ -33,7 +33,7 @@ import "./chunk-LFFIQBNY.js";
33
33
  import "./chunk-HQOB7OQS.js";
34
34
  import "./chunk-73AKO4UL.js";
35
35
  import "./chunk-VQBXWMLT.js";
36
- import "./chunk-5WAMDZHF.js";
36
+ import "./chunk-UKGO2RR7.js";
37
37
  import "./chunk-WUFNKK3U.js";
38
38
  import "./chunk-374AZ4J4.js";
39
39
  import "./chunk-SDFJJJB5.js";
@@ -57,18 +57,18 @@ import {
57
57
  import "./chunk-YSAWTGNA.js";
58
58
  import {
59
59
  recordProjector
60
- } from "./chunk-RC7JRUM5.js";
61
- import "./chunk-LVCASOV4.js";
60
+ } from "./chunk-PRQICZXO.js";
61
+ import "./chunk-QZY36KNT.js";
62
62
  import "./chunk-N7ANFMA5.js";
63
63
  import {
64
64
  ProjectError
65
65
  } from "./chunk-TYY5TYHF.js";
66
- import "./chunk-T6C3TSTO.js";
66
+ import "./chunk-ESM7TFTO.js";
67
67
  import "./chunk-KLIYFD3W.js";
68
68
  import "./chunk-GUHOEIHP.js";
69
69
  import "./chunk-IJBSOWHK.js";
70
70
  import "./chunk-XWLMZKH2.js";
71
- import "./chunk-YPK3ZMDX.js";
71
+ import "./chunk-KNIHXLDE.js";
72
72
  import "./chunk-GJXOFDJT.js";
73
73
  import "./chunk-PMJG2CXF.js";
74
74
  import "./chunk-J6KL3COD.js";
@@ -283,4 +283,4 @@ export {
283
283
  projectOrCheck,
284
284
  removeAndProject
285
285
  };
286
- //# sourceMappingURL=apply-P2POBHIU.js.map
286
+ //# sourceMappingURL=apply-SSYZGDJU.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.30.1";
1193
+ var SERVER_VERSION = "0.32.0";
1194
1194
  var MAX_TOOL_INPUT_ELEMENTS = 1e4;
1195
1195
  function registerSkillTools(server, tools) {
1196
1196
  registerCatalogTool(server, tools);
@@ -1247,4 +1247,4 @@ export {
1247
1247
  registerSkillTools,
1248
1248
  createSkillServer
1249
1249
  };
1250
- //# sourceMappingURL=chunk-HV43X72U.js.map
1250
+ //# sourceMappingURL=chunk-3DRV5KHZ.js.map
@@ -7,7 +7,7 @@ import {
7
7
  prepare,
8
8
  present,
9
9
  writeNative
10
- } from "./chunk-E5OBYCMP.js";
10
+ } from "./chunk-SU6R4VWV.js";
11
11
  import {
12
12
  ANTIGRAVITY_MCP_PLUGIN,
13
13
  BUNDLE_NATIVE_FILES,
@@ -21,7 +21,7 @@ import {
21
21
  same,
22
22
  splitKeyed,
23
23
  withoutBlock
24
- } from "./chunk-G5OL7NQS.js";
24
+ } from "./chunk-KWCZKCTC.js";
25
25
  import {
26
26
  HOOK_DIRECTORY
27
27
  } from "./chunk-GQRDEIQA.js";
@@ -30,7 +30,7 @@ import {
30
30
  replaceFile,
31
31
  replaceLink,
32
32
  writeLock
33
- } from "./chunk-RC7JRUM5.js";
33
+ } from "./chunk-PRQICZXO.js";
34
34
  import {
35
35
  RULES_DIR,
36
36
  legacyLinks
@@ -400,4 +400,4 @@ export {
400
400
  unmanagedHooks,
401
401
  describeHookProblem
402
402
  };
403
- //# sourceMappingURL=chunk-NHQ5BWMO.js.map
403
+ //# sourceMappingURL=chunk-6H3HN7E7.js.map
@@ -7,20 +7,20 @@ import {
7
7
  observeSession,
8
8
  openGroup,
9
9
  runOperation
10
- } from "./chunk-N5RB4HU6.js";
10
+ } from "./chunk-FFQA2R5P.js";
11
11
  import {
12
12
  nativeHostTools
13
- } from "./chunk-XMCP4SGT.js";
13
+ } from "./chunk-MUGHZ6QC.js";
14
14
  import {
15
15
  locateExecutable
16
16
  } from "./chunk-R2GPCZUX.js";
17
17
  import {
18
18
  artifact,
19
19
  stateDirectory
20
- } from "./chunk-EINSPZVE.js";
20
+ } from "./chunk-FGG7JJ5M.js";
21
21
  import {
22
22
  ptyBinary
23
- } from "./chunk-RC7JRUM5.js";
23
+ } from "./chunk-PRQICZXO.js";
24
24
  import {
25
25
  GroupStore,
26
26
  privateJson
@@ -249,4 +249,4 @@ async function invoke(operation) {
249
249
  export {
250
250
  invoke
251
251
  };
252
- //# sourceMappingURL=chunk-I5BKHSVY.js.map
252
+ //# sourceMappingURL=chunk-AALSWFPA.js.map
@@ -1,7 +1,38 @@
1
+ import {
2
+ VERSION
3
+ } from "./chunk-KNIHXLDE.js";
1
4
  import {
2
5
  ConfigError
3
6
  } from "./chunk-GJXOFDJT.js";
4
7
 
8
+ // src/git/config/newer-pin.ts
9
+ import { readFileSync } from "fs";
10
+ import { dirname, join } from "path";
11
+ import semver from "semver";
12
+ var PACKAGE = "@modootoday/pmcp";
13
+ var FIELDS = ["dependencies", "devDependencies", "optionalDependencies"];
14
+ function pinnedVersion(configPath) {
15
+ let manifest;
16
+ try {
17
+ manifest = JSON.parse(
18
+ readFileSync(join(dirname(configPath), "package.json"), "utf8")
19
+ );
20
+ } catch {
21
+ return null;
22
+ }
23
+ for (const field of FIELDS) {
24
+ const deps = manifest[field];
25
+ const pin = deps?.[PACKAGE];
26
+ if (typeof pin === "string") return semver.valid(pin);
27
+ }
28
+ return null;
29
+ }
30
+ function newerPinHint(configPath) {
31
+ const pin = pinnedVersion(configPath);
32
+ if (!pin || !semver.gt(pin, VERSION)) return "";
33
+ return `; this checkout pins ${PACKAGE} ${pin} but runs ${VERSION}: install the pinned version (for example bun install --frozen-lockfile, or npm ci) and run the command again`;
34
+ }
35
+
5
36
  // src/git/config/reader.ts
6
37
  var Reader = class {
7
38
  constructor(path, name, table2, keys) {
@@ -10,7 +41,10 @@ var Reader = class {
10
41
  this.table = table2;
11
42
  for (const key of Object.keys(table2)) {
12
43
  if (!keys.includes(key))
13
- throw new ConfigError(path, `unknown key [${name}] ${key}`);
44
+ throw new ConfigError(
45
+ path,
46
+ `unknown key [${name}] ${key}${newerPinHint(path)}`
47
+ );
14
48
  }
15
49
  }
16
50
  path;
@@ -96,4 +130,4 @@ export {
96
130
  table,
97
131
  child
98
132
  };
99
- //# sourceMappingURL=chunk-T6C3TSTO.js.map
133
+ //# sourceMappingURL=chunk-ESM7TFTO.js.map
@@ -3,13 +3,13 @@ import {
3
3
  } from "./chunk-5ZABTVSW.js";
4
4
  import {
5
5
  dependencies
6
- } from "./chunk-UCTZ7LB2.js";
6
+ } from "./chunk-IAR7BL5R.js";
7
7
  import {
8
8
  interactiveEntry
9
9
  } from "./chunk-LMT3PPXJ.js";
10
10
  import {
11
11
  assertNativeHost
12
- } from "./chunk-XMCP4SGT.js";
12
+ } from "./chunk-MUGHZ6QC.js";
13
13
 
14
14
  // src/tui/startup/host.ts
15
15
  function terminalSupport() {
@@ -42,4 +42,4 @@ export {
42
42
  terminalSupport,
43
43
  requireTerminal
44
44
  };
45
- //# sourceMappingURL=chunk-YP55H3V6.js.map
45
+ //# sourceMappingURL=chunk-FALOBFE6.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  assertNativeHost
3
- } from "./chunk-XMCP4SGT.js";
3
+ } from "./chunk-MUGHZ6QC.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-EINSPZVE.js";
36
+ } from "./chunk-FGG7JJ5M.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-N5RB4HU6.js.map
1984
+ //# sourceMappingURL=chunk-FFQA2R5P.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-34DECPVC.js";
4
4
  import {
5
5
  ptyBinary
6
- } from "./chunk-RC7JRUM5.js";
6
+ } from "./chunk-PRQICZXO.js";
7
7
  import {
8
8
  GroupStore,
9
9
  egressPolicy,
@@ -775,4 +775,4 @@ export {
775
775
  prepareBridge,
776
776
  assertBridge
777
777
  };
778
- //# sourceMappingURL=chunk-EINSPZVE.js.map
778
+ //# sourceMappingURL=chunk-FGG7JJ5M.js.map
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  nativeBinary,
9
9
  ptyBinary
10
- } from "./chunk-RC7JRUM5.js";
10
+ } from "./chunk-PRQICZXO.js";
11
11
 
12
12
  // src/tui/rust.ts
13
13
  import { spawn } from "child_process";
@@ -62,4 +62,4 @@ export {
62
62
  runTui,
63
63
  dependencies
64
64
  };
65
- //# sourceMappingURL=chunk-UCTZ7LB2.js.map
65
+ //# sourceMappingURL=chunk-IAR7BL5R.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-7CHUMF3E.js";
4
4
  import {
5
5
  readSpec
6
- } from "./chunk-G5OL7NQS.js";
6
+ } from "./chunk-KWCZKCTC.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-ADIAVEVZ.js.map
28
+ //# sourceMappingURL=chunk-IFFOJ3IE.js.map
@@ -0,0 +1,7 @@
1
+ // src/commands/version.ts
2
+ var VERSION = "0.32.0";
3
+
4
+ export {
5
+ VERSION
6
+ };
7
+ //# sourceMappingURL=chunk-KNIHXLDE.js.map
@@ -28,7 +28,7 @@ import {
28
28
  import {
29
29
  leaseSpecs,
30
30
  readGitConfig
31
- } from "./chunk-5WAMDZHF.js";
31
+ } from "./chunk-UKGO2RR7.js";
32
32
  import {
33
33
  ownerLine,
34
34
  ownersOf,
@@ -77,11 +77,11 @@ import {
77
77
  readHost,
78
78
  readLock,
79
79
  readLockFile
80
- } from "./chunk-RC7JRUM5.js";
80
+ } from "./chunk-PRQICZXO.js";
81
81
  import {
82
82
  DISABLE_ENV,
83
83
  readLeaseSettings
84
- } from "./chunk-LVCASOV4.js";
84
+ } from "./chunk-QZY36KNT.js";
85
85
  import {
86
86
  ProjectError,
87
87
  RULES_DIR,
@@ -2033,7 +2033,7 @@ function readMcp(path, value) {
2033
2033
  return servers;
2034
2034
  }
2035
2035
 
2036
- // src/hooks/policies/git/forced-branch-move.ts
2036
+ // src/hooks/policies/git/discard-work.ts
2037
2037
  import { resolve as resolve3 } from "path";
2038
2038
 
2039
2039
  // src/hooks/shell/commands.ts
@@ -3299,7 +3299,87 @@ function onlyKeys(raw, keys) {
3299
3299
  if (unknown) throw new Error(`unknown option ${unknown}`);
3300
3300
  }
3301
3301
 
3302
+ // src/hooks/policies/git/discard-work.ts
3303
+ var STASH_READS = /* @__PURE__ */ new Set(["list", "show"]);
3304
+ var STASH_SHARED = ", and the stash is shared by every worktree of this repository";
3305
+ function shortFlag(args, letter) {
3306
+ return args.some((arg) => /^-[a-zA-Z]+$/u.test(arg) && arg.includes(letter));
3307
+ }
3308
+ function checkoutDiscards(args) {
3309
+ if (args.includes("-f") || args.includes("--force")) return true;
3310
+ const paths = args.indexOf("--");
3311
+ if (paths >= 0) return paths < args.length - 1;
3312
+ return args.filter((arg) => !arg.startsWith("-")).includes(".");
3313
+ }
3314
+ function restoreDiscards(args) {
3315
+ const staged = args.includes("--staged") || shortFlag(args, "S");
3316
+ const worktree = args.includes("--worktree") || shortFlag(args, "W");
3317
+ return worktree || !staged;
3318
+ }
3319
+ function discardingCommand(argv) {
3320
+ if (program(argv[0]) !== "git") return null;
3321
+ const call = gitCall(argv);
3322
+ const args = argv.slice(call.at + 1);
3323
+ const named2 = (command) => ({ command, dir: call.dir });
3324
+ if (call.sub === "reset" && args.includes("--hard"))
3325
+ return named2("git reset --hard");
3326
+ if (call.sub === "checkout" && checkoutDiscards(args))
3327
+ return named2("git checkout of paths");
3328
+ if (call.sub === "restore" && restoreDiscards(args))
3329
+ return named2("git restore of the working tree");
3330
+ if (call.sub === "clean" && (args.includes("--force") || shortFlag(args, "f")))
3331
+ return named2("git clean -f");
3332
+ if (call.sub === "stash" && !STASH_READS.has(call.next))
3333
+ return named2("git stash");
3334
+ return null;
3335
+ }
3336
+ function placeOf(git, sessionCwd, target) {
3337
+ const top = git.toplevel(target);
3338
+ if (!top) return null;
3339
+ const trees = git.worktrees(target);
3340
+ if (trees.length < 2) return "own";
3341
+ if (top === trees[0]?.path) return "shared";
3342
+ return top === git.toplevel(sessionCwd) ? "own" : "other";
3343
+ }
3344
+ var WHERE = {
3345
+ shared: "the shared checkout, which other sessions read and land from",
3346
+ other: "another session's worktree"
3347
+ };
3348
+ var discardWork = {
3349
+ id: "git.discard_work",
3350
+ events: ["before_tool"],
3351
+ tools: ["shell"],
3352
+ fail: "closed",
3353
+ defaultMode: "graded",
3354
+ options: noOptions,
3355
+ evaluate(input, ctx) {
3356
+ const call = shellCall(input);
3357
+ if (!call) return pass;
3358
+ for (const step of realSteps(call.steps)) {
3359
+ const found2 = discardingCommand(step.argv);
3360
+ if (!found2) continue;
3361
+ const target = resolve3(input.cwd, step.dir, found2.dir);
3362
+ const place = placeOf(ctx.git, input.cwd, target);
3363
+ if (!place) continue;
3364
+ if (place === "own") {
3365
+ const shared2 = found2.command === "git stash" ? STASH_SHARED : "";
3366
+ return {
3367
+ context: [
3368
+ `pmcp git.discard_work: ${found2.command} throws away uncommitted work in this worktree; commit it first, or name the paths you mean${shared2}.`
3369
+ ]
3370
+ };
3371
+ }
3372
+ return {
3373
+ verdict: "deny",
3374
+ reason: `${found2.command} in ${WHERE[place]} throws away work that is not yours. Work in your own worktree, or ask its owner.`
3375
+ };
3376
+ }
3377
+ return pass;
3378
+ }
3379
+ };
3380
+
3302
3381
  // src/hooks/policies/git/forced-branch-move.ts
3382
+ import { resolve as resolve4 } from "path";
3303
3383
  var FORCE = /* @__PURE__ */ new Set(["-f", "-M", "--force"]);
3304
3384
  function forcedTarget(argv) {
3305
3385
  if (program(argv[0]) !== "git") return null;
@@ -3328,7 +3408,7 @@ var forcedBranchMove = {
3328
3408
  for (const step of realSteps(call.steps)) {
3329
3409
  const target = forcedTarget(step.argv);
3330
3410
  if (!target) continue;
3331
- const cwd = resolve3(input.cwd, step.dir, target.dir);
3411
+ const cwd = resolve4(input.cwd, step.dir, target.dir);
3332
3412
  if (!checkedOutElsewhere(ctx.git, cwd, target.branch)) continue;
3333
3413
  return {
3334
3414
  verdict: "deny",
@@ -3545,7 +3625,7 @@ function stopOptions(raw) {
3545
3625
 
3546
3626
  // src/hooks/checks/validators.ts
3547
3627
  import { globSync, realpathSync as realpathSync2, statSync as statSync2 } from "fs";
3548
- import { dirname as dirname2, isAbsolute as isAbsolute6, relative as relative4, resolve as resolve4, sep } from "path";
3628
+ import { dirname as dirname2, isAbsolute as isAbsolute6, relative as relative4, resolve as resolve5, sep } from "path";
3549
3629
  function contains(root, target) {
3550
3630
  const rest = relative4(root, target);
3551
3631
  return !isAbsolute6(rest) && rest !== ".." && !rest.startsWith(`..${sep}`);
@@ -3557,14 +3637,14 @@ function owner(validator) {
3557
3637
  }
3558
3638
  function validators(root, pattern, paths) {
3559
3639
  const realRoot = realpathSync2(root);
3560
- const edits = paths.map((path) => resolve4(path)).filter((path) => contains(root, path));
3640
+ const edits = paths.map((path) => resolve5(path)).filter((path) => contains(root, path));
3561
3641
  if (edits.length === 0) return [];
3562
3642
  const candidates = [
3563
3643
  ...globSync(pattern, {
3564
3644
  cwd: root,
3565
3645
  exclude: ["**/node_modules/**", "**/.git/**"]
3566
3646
  })
3567
- ].map((path) => resolve4(root, path)).filter((path) => {
3647
+ ].map((path) => resolve5(root, path)).filter((path) => {
3568
3648
  if (!contains(realRoot, realpathSync2(path)) || !statSync2(path).isFile())
3569
3649
  return false;
3570
3650
  return edits.some((edit) => contains(owner(path), edit));
@@ -4901,12 +4981,12 @@ function claimantNotice(root, names4) {
4901
4981
 
4902
4982
  // src/hooks/policies/workspace/leftovers.ts
4903
4983
  import { spawnSync as spawnSync4 } from "child_process";
4904
- import { isAbsolute as isAbsolute7, relative as relative6, resolve as resolve5 } from "path";
4984
+ import { isAbsolute as isAbsolute7, relative as relative6, resolve as resolve6 } from "path";
4905
4985
  var TOUCHED_KEPT = 50;
4906
4986
  function addTouched(touched, root, target) {
4907
4987
  const path = relative6(
4908
4988
  root,
4909
- isAbsolute7(target) ? target : resolve5(root, target)
4989
+ isAbsolute7(target) ? target : resolve6(root, target)
4910
4990
  );
4911
4991
  if (!path || path.startsWith("..") || touched.some((entry) => entry.path === path))
4912
4992
  return [...touched];
@@ -5046,7 +5126,7 @@ var sharedCheckout = {
5046
5126
 
5047
5127
  // src/hooks/policies/workspace/mainline-deliver.ts
5048
5128
  import { spawnSync as spawnSync5 } from "child_process";
5049
- import { resolve as resolve6 } from "path";
5129
+ import { resolve as resolve7 } from "path";
5050
5130
  var REASON7 = "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.";
5051
5131
  var UNRESOLVED = "This push runs in a directory named by a variable the hook cannot resolve (one set by read, a substitution or a loop over computed items), so it is taken as this repository's. Name the directory literally, or loop over literal words (for h in a b; do ...), and pushes to other repositories pass.";
5052
5132
  var VALUE_OPTIONS = /* @__PURE__ */ new Set([
@@ -5148,7 +5228,7 @@ var mainlineDeliver = {
5148
5228
  if (program(step.argv[0]) !== "git") continue;
5149
5229
  const git = gitCall(step.argv);
5150
5230
  if (git.sub !== "push") continue;
5151
- const dir = resolve6(input.cwd, step.dir, git.dir);
5231
+ const dir = resolve7(input.cwd, step.dir, git.dir);
5152
5232
  if (!sameRepository(dir, project.commonDir)) continue;
5153
5233
  if (movesMainline(dir, step.argv.slice(git.at + 1), ctx.options))
5154
5234
  return {
@@ -5162,7 +5242,7 @@ var mainlineDeliver = {
5162
5242
 
5163
5243
  // src/hooks/policies/workspace/worktree-sync.ts
5164
5244
  import { spawn } from "child_process";
5165
- import { relative as relative7, resolve as resolve7 } from "path";
5245
+ import { relative as relative7, resolve as resolve8 } from "path";
5166
5246
  function options(raw) {
5167
5247
  if (typeof raw["root"] !== "string") throw new Error("root must be a string");
5168
5248
  return raw;
@@ -5170,7 +5250,7 @@ function options(raw) {
5170
5250
  function desk(input, opts) {
5171
5251
  const checkout = checkoutOf(input.cwd);
5172
5252
  if (!checkout || checkout.main) return null;
5173
- const desks = resolve7(checkout.commonDir, "..", opts.root);
5253
+ const desks = resolve8(checkout.commonDir, "..", opts.root);
5174
5254
  const inside2 = relative7(desks, checkout.root);
5175
5255
  if (!inside2 || inside2.startsWith("..")) return null;
5176
5256
  return detect(checkout.root, {
@@ -5270,11 +5350,11 @@ var worktreeSync = {
5270
5350
  };
5271
5351
 
5272
5352
  // src/hooks/policies/workspace/owners.ts
5273
- import { isAbsolute as isAbsolute8, relative as relative8, resolve as resolve8 } from "path";
5353
+ import { isAbsolute as isAbsolute8, relative as relative8, resolve as resolve9 } from "path";
5274
5354
  function projectPaths(input) {
5275
5355
  const found2 = [];
5276
5356
  for (const path of input.tool?.paths ?? []) {
5277
- const rest = relative8(input.projectRoot, resolve8(input.cwd, path));
5357
+ const rest = relative8(input.projectRoot, resolve9(input.cwd, path));
5278
5358
  if (rest === "" || rest.startsWith("..") || isAbsolute8(rest)) continue;
5279
5359
  found2.push(rest.split("\\").join("/"));
5280
5360
  }
@@ -5441,7 +5521,7 @@ var operatorVerbs = {
5441
5521
  import { spawnSync as spawnSync6 } from "child_process";
5442
5522
  import { createHash as createHash5 } from "crypto";
5443
5523
  import { existsSync as existsSync9, readFileSync as readFileSync9, realpathSync as realpathSync3 } from "fs";
5444
- import { isAbsolute as isAbsolute9, relative as relative9, resolve as resolve9 } from "path";
5524
+ import { isAbsolute as isAbsolute9, relative as relative9, resolve as resolve10 } from "path";
5445
5525
  var FAILED = "Guard failed validation or execution";
5446
5526
  var GUARD_PROTOCOL = "pmcp.guard.v1";
5447
5527
  var MAX_FINDINGS = 20;
@@ -5476,12 +5556,12 @@ function guardScript(root, command) {
5476
5556
  "Hook command must execute a script under .agents/guards/, or name an installed program with version"
5477
5557
  );
5478
5558
  }
5479
- const base = resolve9(root, ".agents/guards");
5480
- if (!inside(base, resolve9(root, script)))
5559
+ const base = resolve10(root, ".agents/guards");
5560
+ if (!inside(base, resolve10(root, script)))
5481
5561
  throw new Error("Hook guard must stay under .agents/guards/");
5482
- if (!existsSync9(resolve9(root, script)))
5562
+ if (!existsSync9(resolve10(root, script)))
5483
5563
  throw new Error("Hook guard script must exist");
5484
- const real = realpathSync3(resolve9(root, script));
5564
+ const real = realpathSync3(resolve10(root, script));
5485
5565
  if (!inside(realpathSync3(base), real))
5486
5566
  throw new Error("Hook guard cannot resolve outside .agents/guards/");
5487
5567
  return real;
@@ -5561,7 +5641,7 @@ function run2(entry, input, log) {
5561
5641
  };
5562
5642
  }
5563
5643
  const args = entry.command.map(
5564
- (part) => part.startsWith(".agents/guards/") ? resolve9(root, part) : part
5644
+ (part) => part.startsWith(".agents/guards/") ? resolve10(root, part) : part
5565
5645
  );
5566
5646
  const result = spawnSync6(args[0], args.slice(1), {
5567
5647
  cwd: root,
@@ -5616,7 +5696,7 @@ function customPolicy(entry) {
5616
5696
  // src/hooks/policies/external.ts
5617
5697
  import { spawnSync as spawnSync7 } from "child_process";
5618
5698
  import { readFileSync as readFileSync10 } from "fs";
5619
- import { isAbsolute as isAbsolute10, relative as relative10, resolve as resolve10 } from "path";
5699
+ import { isAbsolute as isAbsolute10, relative as relative10, resolve as resolve11 } from "path";
5620
5700
  var MAX_LINES = 20;
5621
5701
  var MAX_REASON2 = 2e3;
5622
5702
  var MAX_OUTPUT = 1 << 20;
@@ -5624,7 +5704,7 @@ function externalId(entry) {
5624
5704
  return `external.${entry.name}`;
5625
5705
  }
5626
5706
  function inProject(input, path) {
5627
- const rest = relative10(input.projectRoot, resolve10(input.cwd, path));
5707
+ const rest = relative10(input.projectRoot, resolve11(input.cwd, path));
5628
5708
  if (rest === "" || rest.startsWith("..") || isAbsolute10(rest)) return null;
5629
5709
  return rest.split("\\").join("/");
5630
5710
  }
@@ -5643,7 +5723,7 @@ function previewText(edit, cwd) {
5643
5723
  if (!edit.replacements) return null;
5644
5724
  let text;
5645
5725
  try {
5646
- text = readFileSync10(resolve10(cwd, edit.path), "utf8");
5726
+ text = readFileSync10(resolve11(cwd, edit.path), "utf8");
5647
5727
  } catch {
5648
5728
  return null;
5649
5729
  }
@@ -5712,7 +5792,7 @@ function bodies(entry, input, paths) {
5712
5792
  continue;
5713
5793
  }
5714
5794
  try {
5715
- found2.set(path, readFileSync10(resolve10(input.projectRoot, path), "utf8"));
5795
+ found2.set(path, readFileSync10(resolve11(input.projectRoot, path), "utf8"));
5716
5796
  } catch {
5717
5797
  }
5718
5798
  }
@@ -5792,6 +5872,7 @@ var GUARDS = byId([
5792
5872
  selfMatchingWait,
5793
5873
  pushWithoutVerify,
5794
5874
  forcedBranchMove,
5875
+ discardWork,
5795
5876
  gateBypassEnv,
5796
5877
  stageAll,
5797
5878
  operatorVerbs
@@ -6184,7 +6265,7 @@ function readChecks(raw) {
6184
6265
  }
6185
6266
 
6186
6267
  // src/hooks/dispatch/failure.ts
6187
- import { isAbsolute as isAbsolute11, relative as relative11, resolve as resolve11 } from "path";
6268
+ import { isAbsolute as isAbsolute11, relative as relative11, resolve as resolve12 } from "path";
6188
6269
  var PASS_KINDS = ["read", "edit-own-worktree"];
6189
6270
  function readFailure(value) {
6190
6271
  if (value === void 0) return void 0;
@@ -6218,7 +6299,7 @@ function ownWorktree(input) {
6218
6299
  if (!checkout || checkout.main) return false;
6219
6300
  const paths = input.tool?.paths ?? [];
6220
6301
  return paths.length > 0 && paths.every((path) => {
6221
- const rest = relative11(checkout.root, resolve11(input.cwd, path));
6302
+ const rest = relative11(checkout.root, resolve12(input.cwd, path));
6222
6303
  return rest !== "" && !rest.startsWith("..") && !isAbsolute11(rest);
6223
6304
  });
6224
6305
  }
@@ -6910,4 +6991,4 @@ export {
6910
6991
  checkBudget,
6911
6992
  readSpec
6912
6993
  };
6913
- //# sourceMappingURL=chunk-G5OL7NQS.js.map
6994
+ //# sourceMappingURL=chunk-KWCZKCTC.js.map