@modootoday/pmcp 0.17.3 → 0.17.4

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.
@@ -612,7 +612,7 @@
612
612
  },
613
613
  {
614
614
  "name": "pmcp",
615
- "version": "0.17.3",
615
+ "version": "0.17.4",
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.17.3",
448
+ "version": "0.17.4",
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.17.3",
3
+ "version": "0.17.4",
4
4
  "description": "Find package skills and use native runtime project configuration.",
5
5
  "author": { "name": "modootoday" },
6
6
  "license": "Elastic-2.0",
package/dist/cli.js CHANGED
@@ -9887,7 +9887,7 @@ function registerMailboxTools(server, service) {
9887
9887
 
9888
9888
  // src/mcp.ts
9889
9889
  var SERVER_NAME = "pmcp";
9890
- var SERVER_VERSION = "0.17.3";
9890
+ var SERVER_VERSION = "0.17.4";
9891
9891
  function registerSkillTools(server, tools) {
9892
9892
  registerCatalogTool(server, tools);
9893
9893
  registerFindTool(server, tools);
@@ -12626,13 +12626,19 @@ function evaluateShellHook(root, policy, tool, payload) {
12626
12626
  if (typeof name !== "string") {
12627
12627
  return denied();
12628
12628
  }
12629
- if (!shellNames[tool].includes(name)) {
12629
+ const afterEdit = policy.event === "after_edit";
12630
+ if (afterEdit && tool !== "codex") {
12631
+ return denied();
12632
+ }
12633
+ const matches2 = afterEdit ? name === "apply_patch" : shellNames[tool].includes(name);
12634
+ if (!matches2) {
12630
12635
  return { decision: "allow" };
12631
12636
  }
12632
12637
  const command3 = scalar(
12633
12638
  input[tool === "antigravity" ? "CommandLine" : "command"]
12634
12639
  );
12635
- if (command3 === void 0 || command3.length > 65536) {
12640
+ const limit = afterEdit ? 16 * 1024 * 1024 : 65536;
12641
+ if (command3 === void 0 || command3.length > limit) {
12636
12642
  return denied();
12637
12643
  }
12638
12644
  const cwd = scalar(input["Cwd"]) ?? scalar(value["cwd"]) ?? root;
@@ -12652,7 +12658,7 @@ function evaluateShellHook(root, policy, tool, payload) {
12652
12658
  env: { PATH: process.env["PATH"], LANG: "C.UTF-8" },
12653
12659
  input: JSON.stringify({
12654
12660
  runtime: tool,
12655
- event: "before_shell",
12661
+ event: afterEdit ? "after_edit" : "before_shell",
12656
12662
  command: command3,
12657
12663
  cwd
12658
12664
  }),
@@ -12678,7 +12684,14 @@ function evaluateShellHook(root, policy, tool, payload) {
12678
12684
  return denied();
12679
12685
  }
12680
12686
  }
12681
- function nativeHookDecision(tool, decision) {
12687
+ function nativeHookDecision(tool, decision, event) {
12688
+ if (tool === "codex" && event === "after_edit") {
12689
+ if (decision.decision === "allow") return {};
12690
+ return {
12691
+ decision: "block",
12692
+ reason: decision.reason ?? "Edit guard failed validation or execution"
12693
+ };
12694
+ }
12682
12695
  if (tool === "codex") {
12683
12696
  return {
12684
12697
  hookSpecificOutput: {
@@ -12691,7 +12704,8 @@ function nativeHookDecision(tool, decision) {
12691
12704
  return decision;
12692
12705
  }
12693
12706
  async function main() {
12694
- const [, , , tool, file2, integrity2] = process.argv;
12707
+ const [, , , tool, file2, integrity2, event] = process.argv;
12708
+ const afterEdit = event === "after_edit";
12695
12709
  const supported = tool === "codex" || tool === "gemini" || tool === "antigravity";
12696
12710
  if (!supported) {
12697
12711
  process.exitCode = 2;
@@ -12699,6 +12713,9 @@ async function main() {
12699
12713
  }
12700
12714
  let decision = denied();
12701
12715
  try {
12716
+ if (event !== void 0 && !afterEdit) {
12717
+ throw new Error("Unknown hook event");
12718
+ }
12702
12719
  if (!file2) {
12703
12720
  throw new Error("Missing hook policy");
12704
12721
  }
@@ -12709,7 +12726,7 @@ async function main() {
12709
12726
  throw new Error("Hook integrity mismatch");
12710
12727
  }
12711
12728
  const policy = JSON.parse(bytes.toString("utf8"));
12712
- if (!policy.targets.includes(tool)) {
12729
+ if (!policy.targets.includes(tool) || policy.event !== event) {
12713
12730
  throw new Error("Hook target mismatch");
12714
12731
  }
12715
12732
  const chunks = [];
@@ -12717,7 +12734,7 @@ async function main() {
12717
12734
  for await (const chunk of process.stdin) {
12718
12735
  const bytes2 = Buffer.from(chunk);
12719
12736
  size += bytes2.length;
12720
- if (size > 131072) {
12737
+ if (size > (afterEdit ? 16 * 1024 * 1024 : 131072)) {
12721
12738
  throw new Error("Hook input too large");
12722
12739
  }
12723
12740
  chunks.push(bytes2);
@@ -12739,7 +12756,7 @@ async function main() {
12739
12756
  decision = denied();
12740
12757
  }
12741
12758
  process.stdout.write(
12742
- `${JSON.stringify(nativeHookDecision(tool, decision))}
12759
+ `${JSON.stringify(nativeHookDecision(tool, decision, afterEdit ? "after_edit" : void 0))}
12743
12760
  `
12744
12761
  );
12745
12762
  }
@@ -12767,6 +12784,11 @@ var native = {
12767
12784
  matcher: "run_command"
12768
12785
  }
12769
12786
  };
12787
+ var editNative = {
12788
+ file: ".codex/hooks.json",
12789
+ key: ["hooks", "PostToolUse"],
12790
+ matcher: "^apply_patch$"
12791
+ };
12770
12792
  function object4(value) {
12771
12793
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
12772
12794
  throw new ProjectError(
@@ -12840,8 +12862,12 @@ function hookOutputs(spec) {
12840
12862
  if (!spec.tools.has(tool)) {
12841
12863
  continue;
12842
12864
  }
12843
- const target2 = native[tool];
12844
- const command3 = `d="$PWD"; while [ ! -f "$d/pmcp.toml" ]; do [ "$d" = / ] && exit 1; d=$(dirname "$d"); done; exec node "$d/${ADAPTER}" --pmcp-shell-hook ${tool} "$d/${policyFile}" ${integrity2}`;
12865
+ if (hook.event === "after_edit" && tool !== "codex") {
12866
+ throw new ProjectError("Edit hooks currently support codex only");
12867
+ }
12868
+ const target2 = hook.event === "after_edit" ? editNative : native[tool];
12869
+ const eventArgument = hook.event === "after_edit" ? " after_edit" : "";
12870
+ const command3 = `d="$PWD"; while [ ! -f "$d/pmcp.toml" ]; do [ "$d" = / ] && exit 1; d=$(dirname "$d"); done; exec node "$d/${ADAPTER}" --pmcp-shell-hook ${tool} "$d/${policyFile}" ${integrity2}${eventArgument}`;
12845
12871
  const timeout = tool === "gemini" ? hook.timeoutMs + 2e3 : Math.ceil(hook.timeoutMs / 1e3) + 2;
12846
12872
  const value = {
12847
12873
  matcher: target2.matcher,
@@ -12861,7 +12887,7 @@ function hookOutputs(spec) {
12861
12887
  const same2 = (left, right) => JSON.stringify(left) === JSON.stringify(right);
12862
12888
  for (const path of /* @__PURE__ */ new Set([...desired.keys(), ...previous.keys()])) {
12863
12889
  const parts = splitKeyed(path);
12864
- if (!parts || !Object.values(native).some(
12890
+ if (!parts || ![...Object.values(native), editNative].some(
12865
12891
  (entry2) => entry2.file === parts.file && entry2.key.join(".") === parts.key.join(".")
12866
12892
  )) {
12867
12893
  throw new ProjectError("Unknown managed hook path in pmcp.lock");
@@ -13568,11 +13594,18 @@ function readHooks(path, root, raw) {
13568
13594
  return fail2("must be a table");
13569
13595
  }
13570
13596
  const table2 = raw;
13571
- if (Object.keys(table2).some((key) => key !== "shell") || !Array.isArray(table2["shell"])) {
13572
- return fail2("only [[hooks.shell]] declarations are supported");
13597
+ if (Object.keys(table2).some((key) => key !== "shell" && key !== "edit") || !["shell", "edit"].some((key) => table2[key] !== void 0) || ["shell", "edit"].some(
13598
+ (key) => table2[key] !== void 0 && !Array.isArray(table2[key])
13599
+ )) {
13600
+ return fail2(
13601
+ "only [[hooks.shell]] and [[hooks.edit]] declarations are supported"
13602
+ );
13573
13603
  }
13574
13604
  const names = /* @__PURE__ */ new Set();
13575
- return table2["shell"].map((value) => {
13605
+ const entries = ["shell", "edit"].flatMap(
13606
+ (kind2) => (table2[kind2] ?? []).map((value) => ({ kind: kind2, value }))
13607
+ );
13608
+ return entries.map(({ kind: kind2, value }) => {
13576
13609
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
13577
13610
  return fail2("shell entry must be a table");
13578
13611
  }
@@ -13599,6 +13632,9 @@ function readHooks(path, root, raw) {
13599
13632
  ) || new Set(targets).size !== targets.length) {
13600
13633
  return fail2("targets must select unique supported shell adapters");
13601
13634
  }
13635
+ if (kind2 === "edit" && targets.some((tool) => tool !== "codex")) {
13636
+ return fail2("edit hooks currently support codex only");
13637
+ }
13602
13638
  if (typeof timeoutMs !== "number" || !Number.isSafeInteger(timeoutMs) || timeoutMs < 100 || timeoutMs > 6e4) {
13603
13639
  return fail2("timeout_ms must be an integer from 100 to 60000");
13604
13640
  }
@@ -13614,7 +13650,8 @@ function readHooks(path, root, raw) {
13614
13650
  name,
13615
13651
  command: command3,
13616
13652
  targets,
13617
- timeoutMs
13653
+ timeoutMs,
13654
+ ...kind2 === "edit" ? { event: "after_edit" } : {}
13618
13655
  };
13619
13656
  }).sort((a, b) => a.name.localeCompare(b.name, "en"));
13620
13657
  }
@@ -16189,7 +16226,7 @@ function dispatch(argv, options2 = {}) {
16189
16226
  }
16190
16227
  return run(command3, rest, { ui, env, cwd });
16191
16228
  }
16192
- var VERSION = "0.17.3";
16229
+ var VERSION = "0.17.4";
16193
16230
  async function defaultEntry(options2, context) {
16194
16231
  const terminal = options2.terminal ?? {
16195
16232
  stdin: process.stdin.isTTY === true,
@@ -5,6 +5,7 @@ interface ShellHookSpec {
5
5
  readonly command: readonly string[];
6
6
  readonly targets: readonly HookTool[];
7
7
  readonly timeoutMs: number;
8
+ readonly event?: "after_edit";
8
9
  }
9
10
 
10
11
  export type { HookTool as H, ShellHookSpec as S };
package/dist/http.js CHANGED
@@ -2322,7 +2322,7 @@ function registerMailboxTools(server, service) {
2322
2322
 
2323
2323
  // src/mcp.ts
2324
2324
  var SERVER_NAME = "pmcp";
2325
- var SERVER_VERSION = "0.17.3";
2325
+ var SERVER_VERSION = "0.17.4";
2326
2326
  function registerSkillTools(server, tools) {
2327
2327
  registerCatalogTool(server, tools);
2328
2328
  registerFindTool(server, tools);
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { E as EntryVectorStore, e as encodeEntries, l as loadEmbedder, o as open
5
5
  export { D as DEFAULT_MODEL_ID, a as EmbeddingModel, b as EncoderDtype, E as EncoderOptions, c as EncoderSpec, R as ResolvedEncoder, e as embeddingModels, d as encoderSpec, r as resolveEncoder } from './encoder-DGRy9skC.js';
6
6
  import { P as ProjectConfig } from './config-BkSpjUG6.js';
7
7
  export { C as CONFIG_FILE, a as CatalogSection, b as ConfigError, E as EmbeddingSection, f as findConfig, r as readConfig } from './config-BkSpjUG6.js';
8
- import { S as ShellHookSpec } from './hook-spec-PRSnYGLV.js';
8
+ import { S as ShellHookSpec } from './hook-spec-CSJJySsH.js';
9
9
  import { McpServer } from '@modelcontextprotocol/server';
10
10
  import { M as MailboxService } from './service-qpCsOXkQ.js';
11
11
  import 'zod';
@@ -275,7 +275,7 @@ declare function resolveSkillFileUri(uri: string, entries: readonly SkillEntry[]
275
275
 
276
276
  /** Reported to the host on connect. */
277
277
  declare const SERVER_NAME = "pmcp";
278
- declare const SERVER_VERSION = "0.17.3";
278
+ declare const SERVER_VERSION = "0.17.4";
279
279
  /**
280
280
  * Registers the skill_* tools on a server.
281
281
  *
package/dist/index.js CHANGED
@@ -1790,13 +1790,19 @@ function evaluateShellHook(root, policy, tool, payload) {
1790
1790
  if (typeof name !== "string") {
1791
1791
  return denied();
1792
1792
  }
1793
- if (!shellNames[tool].includes(name)) {
1793
+ const afterEdit = policy.event === "after_edit";
1794
+ if (afterEdit && tool !== "codex") {
1795
+ return denied();
1796
+ }
1797
+ const matches2 = afterEdit ? name === "apply_patch" : shellNames[tool].includes(name);
1798
+ if (!matches2) {
1794
1799
  return { decision: "allow" };
1795
1800
  }
1796
1801
  const command = scalar(
1797
1802
  input[tool === "antigravity" ? "CommandLine" : "command"]
1798
1803
  );
1799
- if (command === void 0 || command.length > 65536) {
1804
+ const limit = afterEdit ? 16 * 1024 * 1024 : 65536;
1805
+ if (command === void 0 || command.length > limit) {
1800
1806
  return denied();
1801
1807
  }
1802
1808
  const cwd = scalar(input["Cwd"]) ?? scalar(value["cwd"]) ?? root;
@@ -1816,7 +1822,7 @@ function evaluateShellHook(root, policy, tool, payload) {
1816
1822
  env: { PATH: process.env["PATH"], LANG: "C.UTF-8" },
1817
1823
  input: JSON.stringify({
1818
1824
  runtime: tool,
1819
- event: "before_shell",
1825
+ event: afterEdit ? "after_edit" : "before_shell",
1820
1826
  command,
1821
1827
  cwd
1822
1828
  }),
@@ -1842,7 +1848,14 @@ function evaluateShellHook(root, policy, tool, payload) {
1842
1848
  return denied();
1843
1849
  }
1844
1850
  }
1845
- function nativeHookDecision(tool, decision) {
1851
+ function nativeHookDecision(tool, decision, event) {
1852
+ if (tool === "codex" && event === "after_edit") {
1853
+ if (decision.decision === "allow") return {};
1854
+ return {
1855
+ decision: "block",
1856
+ reason: decision.reason ?? "Edit guard failed validation or execution"
1857
+ };
1858
+ }
1846
1859
  if (tool === "codex") {
1847
1860
  return {
1848
1861
  hookSpecificOutput: {
@@ -1855,7 +1868,8 @@ function nativeHookDecision(tool, decision) {
1855
1868
  return decision;
1856
1869
  }
1857
1870
  async function main() {
1858
- const [, , , tool, file, integrity] = process.argv;
1871
+ const [, , , tool, file, integrity, event] = process.argv;
1872
+ const afterEdit = event === "after_edit";
1859
1873
  const supported = tool === "codex" || tool === "gemini" || tool === "antigravity";
1860
1874
  if (!supported) {
1861
1875
  process.exitCode = 2;
@@ -1863,6 +1877,9 @@ async function main() {
1863
1877
  }
1864
1878
  let decision = denied();
1865
1879
  try {
1880
+ if (event !== void 0 && !afterEdit) {
1881
+ throw new Error("Unknown hook event");
1882
+ }
1866
1883
  if (!file) {
1867
1884
  throw new Error("Missing hook policy");
1868
1885
  }
@@ -1873,7 +1890,7 @@ async function main() {
1873
1890
  throw new Error("Hook integrity mismatch");
1874
1891
  }
1875
1892
  const policy = JSON.parse(bytes.toString("utf8"));
1876
- if (!policy.targets.includes(tool)) {
1893
+ if (!policy.targets.includes(tool) || policy.event !== event) {
1877
1894
  throw new Error("Hook target mismatch");
1878
1895
  }
1879
1896
  const chunks = [];
@@ -1881,7 +1898,7 @@ async function main() {
1881
1898
  for await (const chunk of process.stdin) {
1882
1899
  const bytes2 = Buffer.from(chunk);
1883
1900
  size += bytes2.length;
1884
- if (size > 131072) {
1901
+ if (size > (afterEdit ? 16 * 1024 * 1024 : 131072)) {
1885
1902
  throw new Error("Hook input too large");
1886
1903
  }
1887
1904
  chunks.push(bytes2);
@@ -1903,7 +1920,7 @@ async function main() {
1903
1920
  decision = denied();
1904
1921
  }
1905
1922
  process.stdout.write(
1906
- `${JSON.stringify(nativeHookDecision(tool, decision))}
1923
+ `${JSON.stringify(nativeHookDecision(tool, decision, afterEdit ? "after_edit" : void 0))}
1907
1924
  `
1908
1925
  );
1909
1926
  }
@@ -1924,11 +1941,18 @@ function readHooks(path, root, raw) {
1924
1941
  return fail2("must be a table");
1925
1942
  }
1926
1943
  const table2 = raw;
1927
- if (Object.keys(table2).some((key) => key !== "shell") || !Array.isArray(table2["shell"])) {
1928
- return fail2("only [[hooks.shell]] declarations are supported");
1944
+ if (Object.keys(table2).some((key) => key !== "shell" && key !== "edit") || !["shell", "edit"].some((key) => table2[key] !== void 0) || ["shell", "edit"].some(
1945
+ (key) => table2[key] !== void 0 && !Array.isArray(table2[key])
1946
+ )) {
1947
+ return fail2(
1948
+ "only [[hooks.shell]] and [[hooks.edit]] declarations are supported"
1949
+ );
1929
1950
  }
1930
1951
  const names = /* @__PURE__ */ new Set();
1931
- return table2["shell"].map((value) => {
1952
+ const entries = ["shell", "edit"].flatMap(
1953
+ (kind2) => (table2[kind2] ?? []).map((value) => ({ kind: kind2, value }))
1954
+ );
1955
+ return entries.map(({ kind: kind2, value }) => {
1932
1956
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
1933
1957
  return fail2("shell entry must be a table");
1934
1958
  }
@@ -1955,6 +1979,9 @@ function readHooks(path, root, raw) {
1955
1979
  ) || new Set(targets).size !== targets.length) {
1956
1980
  return fail2("targets must select unique supported shell adapters");
1957
1981
  }
1982
+ if (kind2 === "edit" && targets.some((tool) => tool !== "codex")) {
1983
+ return fail2("edit hooks currently support codex only");
1984
+ }
1958
1985
  if (typeof timeoutMs !== "number" || !Number.isSafeInteger(timeoutMs) || timeoutMs < 100 || timeoutMs > 6e4) {
1959
1986
  return fail2("timeout_ms must be an integer from 100 to 60000");
1960
1987
  }
@@ -1970,7 +1997,8 @@ function readHooks(path, root, raw) {
1970
1997
  name,
1971
1998
  command,
1972
1999
  targets,
1973
- timeoutMs
2000
+ timeoutMs,
2001
+ ...kind2 === "edit" ? { event: "after_edit" } : {}
1974
2002
  };
1975
2003
  }).sort((a, b) => a.name.localeCompare(b.name, "en"));
1976
2004
  }
@@ -2579,6 +2607,11 @@ var native = {
2579
2607
  matcher: "run_command"
2580
2608
  }
2581
2609
  };
2610
+ var editNative = {
2611
+ file: ".codex/hooks.json",
2612
+ key: ["hooks", "PostToolUse"],
2613
+ matcher: "^apply_patch$"
2614
+ };
2582
2615
  function object4(value) {
2583
2616
  if (value === null || typeof value !== "object" || Array.isArray(value)) {
2584
2617
  throw new ProjectError(
@@ -2652,8 +2685,12 @@ function hookOutputs(spec) {
2652
2685
  if (!spec.tools.has(tool)) {
2653
2686
  continue;
2654
2687
  }
2655
- const target = native[tool];
2656
- const command = `d="$PWD"; while [ ! -f "$d/pmcp.toml" ]; do [ "$d" = / ] && exit 1; d=$(dirname "$d"); done; exec node "$d/${ADAPTER}" --pmcp-shell-hook ${tool} "$d/${policyFile}" ${integrity}`;
2688
+ if (hook.event === "after_edit" && tool !== "codex") {
2689
+ throw new ProjectError("Edit hooks currently support codex only");
2690
+ }
2691
+ const target = hook.event === "after_edit" ? editNative : native[tool];
2692
+ const eventArgument = hook.event === "after_edit" ? " after_edit" : "";
2693
+ const command = `d="$PWD"; while [ ! -f "$d/pmcp.toml" ]; do [ "$d" = / ] && exit 1; d=$(dirname "$d"); done; exec node "$d/${ADAPTER}" --pmcp-shell-hook ${tool} "$d/${policyFile}" ${integrity}${eventArgument}`;
2657
2694
  const timeout = tool === "gemini" ? hook.timeoutMs + 2e3 : Math.ceil(hook.timeoutMs / 1e3) + 2;
2658
2695
  const value = {
2659
2696
  matcher: target.matcher,
@@ -2673,7 +2710,7 @@ function hookOutputs(spec) {
2673
2710
  const same2 = (left, right) => JSON.stringify(left) === JSON.stringify(right);
2674
2711
  for (const path of /* @__PURE__ */ new Set([...desired.keys(), ...previous.keys()])) {
2675
2712
  const parts = splitKeyed(path);
2676
- if (!parts || !Object.values(native).some(
2713
+ if (!parts || ![...Object.values(native), editNative].some(
2677
2714
  (entry) => entry.file === parts.file && entry.key.join(".") === parts.key.join(".")
2678
2715
  )) {
2679
2716
  throw new ProjectError("Unknown managed hook path in pmcp.lock");
@@ -4869,7 +4906,7 @@ function registerMailboxTools(server, service) {
4869
4906
 
4870
4907
  // src/mcp.ts
4871
4908
  var SERVER_NAME = "pmcp";
4872
- var SERVER_VERSION = "0.17.3";
4909
+ var SERVER_VERSION = "0.17.4";
4873
4910
  function registerSkillTools(server, tools) {
4874
4911
  registerCatalogTool(server, tools);
4875
4912
  registerFindTool(server, tools);
@@ -1,4 +1,4 @@
1
- import { S as ShellHookSpec, H as HookTool } from '../hook-spec-PRSnYGLV.js';
1
+ import { S as ShellHookSpec, H as HookTool } from '../hook-spec-CSJJySsH.js';
2
2
 
3
3
  type Decision = {
4
4
  readonly decision: "allow" | "deny";
@@ -6,6 +6,6 @@ type Decision = {
6
6
  };
7
7
  declare function guardPath(root: string, command: readonly string[]): string;
8
8
  declare function evaluateShellHook(root: string, policy: ShellHookSpec, tool: HookTool, payload: unknown): Decision;
9
- declare function nativeHookDecision(tool: HookTool, decision: Decision): object;
9
+ declare function nativeHookDecision(tool: HookTool, decision: Decision, event?: ShellHookSpec["event"]): object;
10
10
 
11
11
  export { evaluateShellHook, guardPath, nativeHookDecision };
@@ -63,13 +63,19 @@ function evaluateShellHook(root, policy, tool, payload) {
63
63
  if (typeof name !== "string") {
64
64
  return denied();
65
65
  }
66
- if (!shellNames[tool].includes(name)) {
66
+ const afterEdit = policy.event === "after_edit";
67
+ if (afterEdit && tool !== "codex") {
68
+ return denied();
69
+ }
70
+ const matches = afterEdit ? name === "apply_patch" : shellNames[tool].includes(name);
71
+ if (!matches) {
67
72
  return { decision: "allow" };
68
73
  }
69
74
  const command = scalar(
70
75
  input[tool === "antigravity" ? "CommandLine" : "command"]
71
76
  );
72
- if (command === void 0 || command.length > 65536) {
77
+ const limit = afterEdit ? 16 * 1024 * 1024 : 65536;
78
+ if (command === void 0 || command.length > limit) {
73
79
  return denied();
74
80
  }
75
81
  const cwd = scalar(input["Cwd"]) ?? scalar(value["cwd"]) ?? root;
@@ -89,7 +95,7 @@ function evaluateShellHook(root, policy, tool, payload) {
89
95
  env: { PATH: process.env["PATH"], LANG: "C.UTF-8" },
90
96
  input: JSON.stringify({
91
97
  runtime: tool,
92
- event: "before_shell",
98
+ event: afterEdit ? "after_edit" : "before_shell",
93
99
  command,
94
100
  cwd
95
101
  }),
@@ -115,7 +121,14 @@ function evaluateShellHook(root, policy, tool, payload) {
115
121
  return denied();
116
122
  }
117
123
  }
118
- function nativeHookDecision(tool, decision) {
124
+ function nativeHookDecision(tool, decision, event) {
125
+ if (tool === "codex" && event === "after_edit") {
126
+ if (decision.decision === "allow") return {};
127
+ return {
128
+ decision: "block",
129
+ reason: decision.reason ?? "Edit guard failed validation or execution"
130
+ };
131
+ }
119
132
  if (tool === "codex") {
120
133
  return {
121
134
  hookSpecificOutput: {
@@ -128,7 +141,8 @@ function nativeHookDecision(tool, decision) {
128
141
  return decision;
129
142
  }
130
143
  async function main() {
131
- const [, , , tool, file, integrity] = process.argv;
144
+ const [, , , tool, file, integrity, event] = process.argv;
145
+ const afterEdit = event === "after_edit";
132
146
  const supported = tool === "codex" || tool === "gemini" || tool === "antigravity";
133
147
  if (!supported) {
134
148
  process.exitCode = 2;
@@ -136,6 +150,9 @@ async function main() {
136
150
  }
137
151
  let decision = denied();
138
152
  try {
153
+ if (event !== void 0 && !afterEdit) {
154
+ throw new Error("Unknown hook event");
155
+ }
139
156
  if (!file) {
140
157
  throw new Error("Missing hook policy");
141
158
  }
@@ -146,7 +163,7 @@ async function main() {
146
163
  throw new Error("Hook integrity mismatch");
147
164
  }
148
165
  const policy = JSON.parse(bytes.toString("utf8"));
149
- if (!policy.targets.includes(tool)) {
166
+ if (!policy.targets.includes(tool) || policy.event !== event) {
150
167
  throw new Error("Hook target mismatch");
151
168
  }
152
169
  const chunks = [];
@@ -154,7 +171,7 @@ async function main() {
154
171
  for await (const chunk of process.stdin) {
155
172
  const bytes2 = Buffer.from(chunk);
156
173
  size += bytes2.length;
157
- if (size > 131072) {
174
+ if (size > (afterEdit ? 16 * 1024 * 1024 : 131072)) {
158
175
  throw new Error("Hook input too large");
159
176
  }
160
177
  chunks.push(bytes2);
@@ -176,7 +193,7 @@ async function main() {
176
193
  decision = denied();
177
194
  }
178
195
  process.stdout.write(
179
- `${JSON.stringify(nativeHookDecision(tool, decision))}
196
+ `${JSON.stringify(nativeHookDecision(tool, decision, afterEdit ? "after_edit" : void 0))}
180
197
  `
181
198
  );
182
199
  }
package/dist/stdio.js CHANGED
@@ -1969,7 +1969,7 @@ function registerMailboxTools(server, service) {
1969
1969
 
1970
1970
  // src/mcp.ts
1971
1971
  var SERVER_NAME = "pmcp";
1972
- var SERVER_VERSION = "0.17.3";
1972
+ var SERVER_VERSION = "0.17.4";
1973
1973
  function registerSkillTools(server, tools) {
1974
1974
  registerCatalogTool(server, tools);
1975
1975
  registerFindTool(server, tools);
@@ -215,6 +215,29 @@ contain no trust bypass. Grok can load Claude project hooks, so this first scope
215
215
  does not generate a second Grok guard. Hooks do not force pmcp catalog use,
216
216
  inject reminders or replace the runtime's execution sandbox.
217
217
 
218
+ ## Operator edit guards
219
+
220
+ Codex edit guards run after apply_patch through native PostToolUse hooks:
221
+
222
+ ```toml
223
+ [[hooks.edit]]
224
+ name = "edit-policy"
225
+ command = ["node", ".agents/guards/edit-policy.mjs"]
226
+ targets = ["codex"]
227
+ timeout_ms = 15000
228
+ ```
229
+
230
+ The guard receives runtime=codex, event=after_edit, the patch in command and cwd.
231
+ It returns the same allow/deny response as a shell guard. A denial becomes
232
+ native blocking feedback with the reason; the completed file edit remains on disk
233
+ for correction. Other tools do not invoke this guard. Edit targets currently
234
+ support Codex only, and names must be unique across shell and edit declarations.
235
+
236
+ Run pmcp project after declaring or changing the guard, then review and trust
237
+ the generated native definition in /hooks. Peer entries and shell guards are
238
+ preserved. Fingerprints and failure handling follow the shell-guard contract.
239
+ See the [native hooks documentation](https://learn.chatgpt.com/docs/hooks).
240
+
218
241
  ## Native memory metadata
219
242
 
220
243
  ```sh
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcp",
3
- "version": "0.17.3",
3
+ "version": "0.17.4",
4
4
  "mcpServers": {
5
5
  "pmcp": {
6
6
  "type": "stdio",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modootoday/pmcp",
3
- "version": "0.17.3",
3
+ "version": "0.17.4",
4
4
  "license": "Elastic-2.0",
5
5
  "author": "modootoday",
6
6
  "description": "Use the skills your packages already ship, and keep your AI tools' project configuration in one place.",
package/plugin.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "pmcp",
4
- "version": "0.17.3",
4
+ "version": "0.17.4",
5
5
  "description": "Find package skills and use native runtime project configuration.",
6
6
  "author": { "name": "modootoday" },
7
7
  "license": "Elastic-2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcp",
3
- "version": "0.17.3",
3
+ "version": "0.17.4",
4
4
  "description": "Find package skills and use native runtime project configuration.",
5
5
  "author": { "name": "modootoday" },
6
6
  "license": "Elastic-2.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmcp",
3
- "version": "0.17.3",
3
+ "version": "0.17.4",
4
4
  "mcpServers": {
5
5
  "pmcp": {
6
6
  "type": "stdio",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
3
3
  "name": "pmcp",
4
- "version": "0.17.3",
4
+ "version": "0.17.4",
5
5
  "description": "Find package skills and use native runtime project configuration.",
6
6
  "author": { "name": "modootoday" },
7
7
  "license": "Elastic-2.0",