@pushary/agent-hooks 0.84.1 → 0.85.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +24 -0
  3. package/data/cursor-plugin/CHANGELOG.md +21 -0
  4. package/data/cursor-plugin/scripts/pushary-gate.mjs +54 -222
  5. package/data/cursor-plugin/scripts/pushary-gate.test.mjs +11 -106
  6. package/data/vscode-plugin/CHANGELOG.md +26 -0
  7. package/data/vscode-plugin/scripts/pushary-gate.mjs +66 -74
  8. package/dist/bin/pushary-bell-hook.js +9 -7
  9. package/dist/bin/pushary-bell.js +12 -11
  10. package/dist/bin/pushary-claude.js +12 -11
  11. package/dist/bin/pushary-clean.js +8 -7
  12. package/dist/bin/pushary-codex-bridge.js +5 -5
  13. package/dist/bin/pushary-codex-hook.js +14 -20
  14. package/dist/bin/pushary-codex.js +3 -3
  15. package/dist/bin/pushary-connect.js +10 -10
  16. package/dist/bin/pushary-daemon.js +6 -6
  17. package/dist/bin/pushary-disconnect.d.ts +1 -0
  18. package/dist/bin/pushary-disconnect.js +125 -0
  19. package/dist/bin/pushary-doctor.js +16 -16
  20. package/dist/bin/pushary-gemini-bridge.js +5 -5
  21. package/dist/bin/pushary-gemini-hook.js +14 -20
  22. package/dist/bin/pushary-hook.js +16 -23
  23. package/dist/bin/pushary-login.js +6 -6
  24. package/dist/bin/pushary-logout.js +6 -6
  25. package/dist/bin/pushary-mode.js +5 -5
  26. package/dist/bin/pushary-notification-hook.js +8 -11
  27. package/dist/bin/pushary-permission-denied-hook.js +14 -12
  28. package/dist/bin/pushary-permission-hook.js +14 -12
  29. package/dist/bin/pushary-post-hook.js +8 -11
  30. package/dist/bin/pushary-prompt-hook.js +8 -11
  31. package/dist/bin/pushary-session-end-hook.js +8 -8
  32. package/dist/bin/pushary-session-start-hook.js +8 -8
  33. package/dist/bin/pushary-setup.js +29 -30
  34. package/dist/bin/pushary-stats.js +4 -4
  35. package/dist/bin/pushary-status.js +7 -7
  36. package/dist/bin/pushary-stop-hook.js +8 -8
  37. package/dist/bin/pushary-stopfailure-hook.js +8 -8
  38. package/dist/bin/pushary-suggestions.js +2 -2
  39. package/dist/bin/pushary-upgrade.js +15 -10
  40. package/dist/bin/pushary-wait.js +5 -5
  41. package/dist/bin/pushary.js +2 -1
  42. package/dist/{chunk-ILB6UOAF.js → chunk-55656H4Q.js} +1 -1
  43. package/dist/chunk-6CUUA7HO.js +59 -0
  44. package/dist/{chunk-6LC4WSCL.js → chunk-BZKTCOZQ.js} +1 -1
  45. package/dist/{chunk-K7CSRGKZ.js → chunk-CIVG746V.js} +1 -1
  46. package/dist/{chunk-FBGBJXVC.js → chunk-DNSIVHIA.js} +1 -1
  47. package/dist/{chunk-437T77TY.js → chunk-ES3FAX5X.js} +1 -1
  48. package/dist/chunk-EZPRY2ZY.js +70 -0
  49. package/dist/{chunk-MQMPG5X4.js → chunk-G3LXA2ZP.js} +207 -10
  50. package/dist/chunk-GM54KC62.js +187 -0
  51. package/dist/{chunk-MGJBC6DD.js → chunk-GOEXZ5QJ.js} +1 -0
  52. package/dist/chunk-HSGEEBBL.js +37 -0
  53. package/dist/{chunk-UXWEE3QI.js → chunk-IGV4KL7B.js} +1 -1
  54. package/dist/{chunk-GCKAWHFP.js → chunk-JDQY47OW.js} +1 -1
  55. package/dist/{chunk-7PZPJSWI.js → chunk-KTKIZEFT.js} +1 -1
  56. package/dist/{chunk-YR5TSPXB.js → chunk-LB6RSCLL.js} +12 -10
  57. package/dist/{chunk-DOXSWT4Q.js → chunk-OZKRF7MS.js} +6 -6
  58. package/dist/{chunk-SEAHGHCE.js → chunk-PHXEADSL.js} +40 -7
  59. package/dist/{chunk-F52SIIDG.js → chunk-QDKJTPAT.js} +1 -1
  60. package/dist/{chunk-J4KFVOCQ.js → chunk-SQOFGPNX.js} +1 -1
  61. package/dist/{chunk-NJ7JT26G.js → chunk-VGADRFG6.js} +1 -1
  62. package/dist/{chunk-HZNOAJGB.js → chunk-VKJUVPTJ.js} +2 -2
  63. package/dist/{chunk-ERYKGH4J.js → chunk-XIR6N66V.js} +1 -1
  64. package/dist/{chunk-CCH775Y6.js → chunk-XLM6COJA.js} +1 -1
  65. package/dist/{chunk-CCCJ6BPW.js → chunk-Y7BALRVB.js} +73 -134
  66. package/dist/chunk-YHG74UFF.js +12 -0
  67. package/dist/src/index.d.ts +7 -22
  68. package/dist/src/index.js +11 -8
  69. package/package.json +6 -3
  70. package/dist/chunk-BLDDXHHA.js +0 -66
  71. package/dist/chunk-UKSQWTBH.js +0 -208
@@ -1,27 +1,24 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ readHookInput
4
+ } from "../chunk-6CUUA7HO.js";
2
5
  import {
3
6
  handleUserPrompt
4
- } from "../chunk-CCCJ6BPW.js";
7
+ } from "../chunk-Y7BALRVB.js";
5
8
  import "../chunk-RN3NOEJF.js";
6
9
  import "../chunk-BSZYIAZL.js";
7
10
  import "../chunk-SAF6HGAA.js";
8
- import "../chunk-437T77TY.js";
11
+ import "../chunk-ES3FAX5X.js";
9
12
  import "../chunk-7QLSKOSU.js";
10
13
  import "../chunk-KZERVKTD.js";
11
14
  import "../chunk-2UMNXADU.js";
12
- import "../chunk-MQMPG5X4.js";
15
+ import "../chunk-G3LXA2ZP.js";
13
16
 
14
17
  // bin/pushary-prompt-hook.ts
15
18
  var main = async () => {
16
- let rawInput = "";
17
- for await (const chunk of process.stdin) {
18
- rawInput += chunk;
19
- }
20
- if (!rawInput.trim()) {
21
- process.exit(0);
22
- }
19
+ const input = await readHookInput("claude", "UserPromptSubmit");
20
+ if (!input) return;
23
21
  try {
24
- const input = JSON.parse(rawInput);
25
22
  const additionalContext = await handleUserPrompt(input);
26
23
  if (additionalContext) {
27
24
  process.stdout.write(JSON.stringify({
@@ -1,24 +1,24 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ readHookInput
4
+ } from "../chunk-6CUUA7HO.js";
2
5
  import {
3
6
  handleSessionEnd
4
- } from "../chunk-CCCJ6BPW.js";
7
+ } from "../chunk-Y7BALRVB.js";
5
8
  import "../chunk-RN3NOEJF.js";
6
9
  import "../chunk-BSZYIAZL.js";
7
10
  import "../chunk-SAF6HGAA.js";
8
- import "../chunk-437T77TY.js";
11
+ import "../chunk-ES3FAX5X.js";
9
12
  import "../chunk-7QLSKOSU.js";
10
13
  import "../chunk-KZERVKTD.js";
11
14
  import "../chunk-2UMNXADU.js";
12
- import "../chunk-MQMPG5X4.js";
15
+ import "../chunk-G3LXA2ZP.js";
13
16
 
14
17
  // bin/pushary-session-end-hook.ts
15
18
  var main = async () => {
16
- let rawInput = "";
17
- for await (const chunk of process.stdin) {
18
- rawInput += chunk;
19
- }
19
+ const input = await readHookInput("claude", "SessionEnd");
20
+ if (!input) return;
20
21
  try {
21
- const input = rawInput.trim() ? JSON.parse(rawInput) : {};
22
22
  await handleSessionEnd(input);
23
23
  } catch {
24
24
  }
@@ -1,24 +1,24 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ readHookInput
4
+ } from "../chunk-6CUUA7HO.js";
2
5
  import {
3
6
  handleSessionStart
4
- } from "../chunk-CCCJ6BPW.js";
7
+ } from "../chunk-Y7BALRVB.js";
5
8
  import "../chunk-RN3NOEJF.js";
6
9
  import "../chunk-BSZYIAZL.js";
7
10
  import "../chunk-SAF6HGAA.js";
8
- import "../chunk-437T77TY.js";
11
+ import "../chunk-ES3FAX5X.js";
9
12
  import "../chunk-7QLSKOSU.js";
10
13
  import "../chunk-KZERVKTD.js";
11
14
  import "../chunk-2UMNXADU.js";
12
- import "../chunk-MQMPG5X4.js";
15
+ import "../chunk-G3LXA2ZP.js";
13
16
 
14
17
  // bin/pushary-session-start-hook.ts
15
18
  var main = async () => {
16
- let rawInput = "";
17
- for await (const chunk of process.stdin) {
18
- rawInput += chunk;
19
- }
19
+ const input = await readHookInput("claude", "SessionStart");
20
+ if (!input) return;
20
21
  try {
21
- const input = rawInput.trim() ? JSON.parse(rawInput) : {};
22
22
  await handleSessionStart(input);
23
23
  } catch {
24
24
  }
@@ -1,15 +1,18 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ detectClaudeVersion
4
+ } from "../chunk-EZPRY2ZY.js";
2
5
  import {
3
6
  claudeWired,
4
7
  codexWired,
5
8
  geminiWired
6
- } from "../chunk-HZNOAJGB.js";
9
+ } from "../chunk-VKJUVPTJ.js";
7
10
  import {
8
11
  runBrowserLogin
9
12
  } from "../chunk-Z3Z4VK5F.js";
10
13
  import {
11
14
  ensureDaemonRunning
12
- } from "../chunk-CCH775Y6.js";
15
+ } from "../chunk-XLM6COJA.js";
13
16
  import {
14
17
  describeDetection,
15
18
  detectAllAgents,
@@ -21,22 +24,27 @@ import {
21
24
  shortenHome,
22
25
  vscodeSettingsTargets,
23
26
  writeInstructionBlock
24
- } from "../chunk-UXWEE3QI.js";
27
+ } from "../chunk-IGV4KL7B.js";
25
28
  import {
26
29
  GEMINI_HOOK_BINARY,
27
30
  addGeminiHooks,
28
31
  addGeminiMcpServer
29
- } from "../chunk-DOXSWT4Q.js";
32
+ } from "../chunk-OZKRF7MS.js";
30
33
  import {
31
34
  addClaudeMcpServer,
32
35
  addPusharyHooks,
33
- addPusharyToolPermissions
34
- } from "../chunk-UKSQWTBH.js";
36
+ addPusharyToolPermissions,
37
+ compareVersion,
38
+ parseVersion
39
+ } from "../chunk-GM54KC62.js";
40
+ import {
41
+ guardBinary,
42
+ guardNodeScript
43
+ } from "../chunk-HSGEEBBL.js";
35
44
  import "../chunk-XHKBHWLX.js";
36
45
  import {
37
46
  installGlobally,
38
47
  npmErrorMessage,
39
- quoteIfNeeded,
40
48
  resolveGlobalBinDir,
41
49
  resolveGlobalBinary
42
50
  } from "../chunk-VT4IVERX.js";
@@ -57,10 +65,10 @@ import {
57
65
  geminiSettings,
58
66
  pusharyConfigFile,
59
67
  vscodePluginDir
60
- } from "../chunk-SEAHGHCE.js";
68
+ } from "../chunk-PHXEADSL.js";
61
69
  import {
62
70
  reportEvent
63
- } from "../chunk-CCCJ6BPW.js";
71
+ } from "../chunk-Y7BALRVB.js";
64
72
  import "../chunk-RN3NOEJF.js";
65
73
  import {
66
74
  confirmAppConnection,
@@ -70,12 +78,12 @@ import {
70
78
  printConnectInstructions,
71
79
  setHumanStream,
72
80
  verifyRoundTrip
73
- } from "../chunk-6LC4WSCL.js";
81
+ } from "../chunk-BZKTCOZQ.js";
74
82
  import "../chunk-3EGEA4KH.js";
75
83
  import {
76
84
  checkApiKey,
77
85
  describeKeyCheck
78
- } from "../chunk-F52SIIDG.js";
86
+ } from "../chunk-QDKJTPAT.js";
79
87
  import {
80
88
  useColor
81
89
  } from "../chunk-5RUIFDTP.js";
@@ -86,13 +94,13 @@ import {
86
94
  readConfigFileKey,
87
95
  readKeySource,
88
96
  writeKey
89
- } from "../chunk-K7CSRGKZ.js";
97
+ } from "../chunk-CIVG746V.js";
90
98
  import {
91
99
  parseFlags
92
100
  } from "../chunk-GMXKITVA.js";
93
101
  import {
94
102
  renderCommandHelp
95
- } from "../chunk-MGJBC6DD.js";
103
+ } from "../chunk-GOEXZ5QJ.js";
96
104
  import {
97
105
  installClaudeAlias,
98
106
  resolveShellRc
@@ -109,7 +117,7 @@ import {
109
117
  } from "../chunk-6MTNS63X.js";
110
118
  import "../chunk-BSZYIAZL.js";
111
119
  import "../chunk-SAF6HGAA.js";
112
- import "../chunk-437T77TY.js";
120
+ import "../chunk-ES3FAX5X.js";
113
121
  import {
114
122
  UsageError
115
123
  } from "../chunk-7QLSKOSU.js";
@@ -119,7 +127,7 @@ import {
119
127
  import "../chunk-2UMNXADU.js";
120
128
  import {
121
129
  isValidApiKey
122
- } from "../chunk-MQMPG5X4.js";
130
+ } from "../chunk-G3LXA2ZP.js";
123
131
 
124
132
  // bin/pushary-setup.ts
125
133
  import { existsSync, readFileSync, writeFileSync, mkdirSync, cpSync, rmSync, renameSync, realpathSync, readdirSync, statSync } from "fs";
@@ -234,17 +242,8 @@ var describeClosing = (facts) => {
234
242
 
235
243
  // src/setup/codex-version.ts
236
244
  import { dirname, join } from "path";
237
- var parseCodexVersion = (raw) => {
238
- const match = raw.match(/(\d+)\.(\d+)\.(\d+)/);
239
- if (!match) return null;
240
- return [Number(match[1]), Number(match[2]), Number(match[3])];
241
- };
242
- var compareCodexVersion = (a, b) => {
243
- for (let i = 0; i < 3; i++) {
244
- if (a[i] !== b[i]) return a[i] < b[i] ? -1 : 1;
245
- }
246
- return 0;
247
- };
245
+ var parseCodexVersion = parseVersion;
246
+ var compareCodexVersion = compareVersion;
248
247
  var versionFromManifest = (probe, binPath) => {
249
248
  let dir = dirname(binPath);
250
249
  for (let depth = 0; depth < 4; depth++) {
@@ -714,7 +713,7 @@ var setupClaudeCode = async (apiKey) => {
714
713
  addPusharyToolPermissions(settings);
715
714
  });
716
715
  await spinner("Adding hooks (approvals, activity, presence, and lifecycle events)", async () => {
717
- addPusharyHooks(settings, resolveGlobalBinDir("pushary-hook"));
716
+ addPusharyHooks(settings, resolveGlobalBinDir("pushary-hook"), detectClaudeVersion());
718
717
  });
719
718
  await spinner(`Writing ${CLAUDE_JSON}`, async () => {
720
719
  writeJsonAtomic(CLAUDE_JSON, claudeJson2, 384);
@@ -940,7 +939,7 @@ var setupCodex = async (apiKey) => {
940
939
  const trustAuto = codexTrustAutoSupported(codexVersion);
941
940
  let trusted = false;
942
941
  if (hooksSupported) {
943
- const hookCommand = quoteIfNeeded(resolveGlobalBinary("pushary-codex-hook") ?? "pushary-codex-hook");
942
+ const hookCommand = guardBinary(resolveGlobalBinary("pushary-codex-hook") ?? "pushary-codex-hook");
944
943
  await spinner("Adding native hooks (~/.codex/hooks.json)", async () => {
945
944
  const hooksConfig = readAgentJson(CODEX_HOOKS_JSON);
946
945
  addCodexHooks(hooksConfig, hookCommand);
@@ -1022,7 +1021,7 @@ var resolveBundledPlugin = () => {
1022
1021
  var installCursorUserHooks = (gateScript) => {
1023
1022
  const template = readJson(join2(CURSOR_PLUGIN_DIR, "hooks", "hooks.json")).hooks?.beforeShellExecution?.[0];
1024
1023
  if (!template) throw new Error("bundled Cursor hooks.json missing a beforeShellExecution entry");
1025
- const entry = { ...template, command: `node "${gateScript}"` };
1024
+ const entry = { ...template, command: guardNodeScript(gateScript) };
1026
1025
  let userHooks = {};
1027
1026
  if (existsSync(CURSOR_USER_HOOKS)) {
1028
1027
  try {
@@ -1286,7 +1285,7 @@ var setupGemini = async (apiKey) => {
1286
1285
  addGeminiMcpServer(settings, apiKey);
1287
1286
  });
1288
1287
  await spinner("Adding hooks (BeforeTool, AfterTool, BeforeAgent, SessionStart, SessionEnd)", async () => {
1289
- addGeminiHooks(settings, quoteIfNeeded(resolveGlobalBinary(GEMINI_HOOK_BINARY) ?? GEMINI_HOOK_BINARY));
1288
+ addGeminiHooks(settings, guardBinary(resolveGlobalBinary(GEMINI_HOOK_BINARY) ?? GEMINI_HOOK_BINARY));
1290
1289
  });
1291
1290
  await spinner(`Writing ${GEMINI_SETTINGS}`, async () => {
1292
1291
  writeJsonAtomic(GEMINI_SETTINGS, settings, KEY_FILE_MODE);
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  readLedgerSummary
4
- } from "../chunk-NJ7JT26G.js";
4
+ } from "../chunk-VGADRFG6.js";
5
5
  import {
6
6
  exitOnHelpFlag
7
- } from "../chunk-J4KFVOCQ.js";
8
- import "../chunk-MGJBC6DD.js";
7
+ } from "../chunk-SQOFGPNX.js";
8
+ import "../chunk-GOEXZ5QJ.js";
9
9
  import "../chunk-DINDL2CF.js";
10
10
  import "../chunk-KZERVKTD.js";
11
11
  import {
12
12
  getApiKey
13
13
  } from "../chunk-2UMNXADU.js";
14
- import "../chunk-MQMPG5X4.js";
14
+ import "../chunk-G3LXA2ZP.js";
15
15
 
16
16
  // bin/pushary-stats.ts
17
17
  exitOnHelpFlag("stats");
@@ -8,31 +8,31 @@ import {
8
8
  describeReach,
9
9
  fetchChannels,
10
10
  reachVerdict
11
- } from "../chunk-6LC4WSCL.js";
11
+ } from "../chunk-BZKTCOZQ.js";
12
12
  import "../chunk-3EGEA4KH.js";
13
13
  import {
14
14
  checkApiKey,
15
15
  describeKeyCheck
16
- } from "../chunk-F52SIIDG.js";
16
+ } from "../chunk-QDKJTPAT.js";
17
17
  import {
18
18
  createIo
19
19
  } from "../chunk-5RUIFDTP.js";
20
20
  import {
21
21
  readKeySource
22
- } from "../chunk-K7CSRGKZ.js";
22
+ } from "../chunk-CIVG746V.js";
23
23
  import {
24
24
  rejectUnknownFlags
25
25
  } from "../chunk-GMXKITVA.js";
26
26
  import {
27
27
  exitOnHelpFlag
28
- } from "../chunk-J4KFVOCQ.js";
29
- import "../chunk-MGJBC6DD.js";
28
+ } from "../chunk-SQOFGPNX.js";
29
+ import "../chunk-GOEXZ5QJ.js";
30
30
  import "../chunk-BC3VCZ3E.js";
31
31
  import "../chunk-DINDL2CF.js";
32
32
  import "../chunk-6MTNS63X.js";
33
33
  import "../chunk-BSZYIAZL.js";
34
34
  import "../chunk-SAF6HGAA.js";
35
- import "../chunk-437T77TY.js";
35
+ import "../chunk-ES3FAX5X.js";
36
36
  import {
37
37
  UsageError
38
38
  } from "../chunk-7QLSKOSU.js";
@@ -40,7 +40,7 @@ import {
40
40
  EXIT
41
41
  } from "../chunk-KZERVKTD.js";
42
42
  import "../chunk-2UMNXADU.js";
43
- import "../chunk-MQMPG5X4.js";
43
+ import "../chunk-G3LXA2ZP.js";
44
44
 
45
45
  // src/status.ts
46
46
  var keySourceLine = (source) => {
@@ -1,24 +1,24 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ readHookInput
4
+ } from "../chunk-6CUUA7HO.js";
2
5
  import {
3
6
  handleStop
4
- } from "../chunk-CCCJ6BPW.js";
7
+ } from "../chunk-Y7BALRVB.js";
5
8
  import "../chunk-RN3NOEJF.js";
6
9
  import "../chunk-BSZYIAZL.js";
7
10
  import "../chunk-SAF6HGAA.js";
8
- import "../chunk-437T77TY.js";
11
+ import "../chunk-ES3FAX5X.js";
9
12
  import "../chunk-7QLSKOSU.js";
10
13
  import "../chunk-KZERVKTD.js";
11
14
  import "../chunk-2UMNXADU.js";
12
- import "../chunk-MQMPG5X4.js";
15
+ import "../chunk-G3LXA2ZP.js";
13
16
 
14
17
  // bin/pushary-stop-hook.ts
15
18
  var main = async () => {
16
- let rawInput = "";
17
- for await (const chunk of process.stdin) {
18
- rawInput += chunk;
19
- }
19
+ const input = await readHookInput("claude", "Stop");
20
+ if (!input) return;
20
21
  try {
21
- const input = rawInput.trim() ? JSON.parse(rawInput) : {};
22
22
  const output = await handleStop(input);
23
23
  if (output) process.stdout.write(JSON.stringify(output));
24
24
  } catch {
@@ -1,24 +1,24 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ readHookInput
4
+ } from "../chunk-6CUUA7HO.js";
2
5
  import {
3
6
  handleStopFailure
4
- } from "../chunk-CCCJ6BPW.js";
7
+ } from "../chunk-Y7BALRVB.js";
5
8
  import "../chunk-RN3NOEJF.js";
6
9
  import "../chunk-BSZYIAZL.js";
7
10
  import "../chunk-SAF6HGAA.js";
8
- import "../chunk-437T77TY.js";
11
+ import "../chunk-ES3FAX5X.js";
9
12
  import "../chunk-7QLSKOSU.js";
10
13
  import "../chunk-KZERVKTD.js";
11
14
  import "../chunk-2UMNXADU.js";
12
- import "../chunk-MQMPG5X4.js";
15
+ import "../chunk-G3LXA2ZP.js";
13
16
 
14
17
  // bin/pushary-stopfailure-hook.ts
15
18
  var main = async () => {
16
- let rawInput = "";
17
- for await (const chunk of process.stdin) {
18
- rawInput += chunk;
19
- }
19
+ const input = await readHookInput("claude", "StopFailure");
20
+ if (!input) return;
20
21
  try {
21
- const input = rawInput.trim() ? JSON.parse(rawInput) : {};
22
22
  await handleStopFailure(input);
23
23
  } catch {
24
24
  }
@@ -7,8 +7,8 @@ import {
7
7
  } from "../chunk-GMXKITVA.js";
8
8
  import {
9
9
  exitOnHelpFlag
10
- } from "../chunk-J4KFVOCQ.js";
11
- import "../chunk-MGJBC6DD.js";
10
+ } from "../chunk-SQOFGPNX.js";
11
+ import "../chunk-GOEXZ5QJ.js";
12
12
  import "../chunk-DINDL2CF.js";
13
13
  import {
14
14
  UsageError
@@ -1,19 +1,24 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ detectClaudeVersion
4
+ } from "../chunk-EZPRY2ZY.js";
2
5
  import {
3
6
  GEMINI_HOOK_BINARY,
4
7
  addGeminiHooks,
5
8
  addGeminiMcpServer,
6
9
  hasGeminiHooks
7
- } from "../chunk-DOXSWT4Q.js";
10
+ } from "../chunk-OZKRF7MS.js";
8
11
  import {
9
12
  addClaudeMcpServer,
10
13
  addPusharyHooks,
11
14
  addPusharyToolPermissions
12
- } from "../chunk-UKSQWTBH.js";
15
+ } from "../chunk-GM54KC62.js";
16
+ import {
17
+ guardBinary
18
+ } from "../chunk-HSGEEBBL.js";
13
19
  import {
14
20
  execNpm,
15
21
  npmErrorMessage,
16
- quoteIfNeeded,
17
22
  resolveGlobalBinDir,
18
23
  resolveGlobalBinary
19
24
  } from "../chunk-VT4IVERX.js";
@@ -30,11 +35,11 @@ import {
30
35
  hasCodexHooks,
31
36
  vscodePluginDir,
32
37
  vscodePluginMcp
33
- } from "../chunk-SEAHGHCE.js";
38
+ } from "../chunk-PHXEADSL.js";
34
39
  import {
35
40
  exitOnHelpFlag
36
- } from "../chunk-J4KFVOCQ.js";
37
- import "../chunk-MGJBC6DD.js";
41
+ } from "../chunk-SQOFGPNX.js";
42
+ import "../chunk-GOEXZ5QJ.js";
38
43
  import {
39
44
  isNewerVersion
40
45
  } from "../chunk-DINDL2CF.js";
@@ -45,7 +50,7 @@ import "../chunk-KZERVKTD.js";
45
50
  import {
46
51
  getApiKey
47
52
  } from "../chunk-2UMNXADU.js";
48
- import "../chunk-MQMPG5X4.js";
53
+ import "../chunk-G3LXA2ZP.js";
49
54
 
50
55
  // bin/pushary-upgrade.ts
51
56
  import { existsSync as existsSync2 } from "fs";
@@ -87,7 +92,7 @@ var reapplyClaudeSettings = (apiKey, paths = {}) => {
87
92
  if (!settingsWritable) throw new Error("settings.json could not be parsed");
88
93
  const s = settings;
89
94
  addPusharyToolPermissions(s);
90
- addPusharyHooks(s, resolveGlobalBinDir("pushary-hook"));
95
+ addPusharyHooks(s, resolveGlobalBinDir("pushary-hook"), detectClaudeVersion());
91
96
  writeJson(settingsPath, s);
92
97
  hooks = true;
93
98
  } catch {
@@ -119,7 +124,7 @@ var reapplyCodexSettings = (apiKey, paths = {}) => {
119
124
  const hooksConfig = readJson(hooksPath);
120
125
  const configured = config != null && !!config.mcp_servers?.pushary || hooksConfig != null && hasCodexHooks(hooksConfig);
121
126
  if (!configured) return { reapplied: false, hooks: false, mcp: false };
122
- const command = quoteIfNeeded(resolveGlobalBinary(CODEX_HOOK_BINARY) ?? CODEX_HOOK_BINARY);
127
+ const command = guardBinary(resolveGlobalBinary(CODEX_HOOK_BINARY) ?? CODEX_HOOK_BINARY);
123
128
  let hooks = false;
124
129
  let mcp = false;
125
130
  if (hooksConfig != null) {
@@ -152,7 +157,7 @@ var reapplyGeminiSettings = (apiKey, paths = {}) => {
152
157
  let hooks = false;
153
158
  let mcp = false;
154
159
  try {
155
- addGeminiHooks(settings, quoteIfNeeded(resolveGlobalBinary(GEMINI_HOOK_BINARY) ?? GEMINI_HOOK_BINARY));
160
+ addGeminiHooks(settings, guardBinary(resolveGlobalBinary(GEMINI_HOOK_BINARY) ?? GEMINI_HOOK_BINARY));
156
161
  hooks = true;
157
162
  if (apiKey) {
158
163
  addGeminiMcpServer(settings, apiKey);
@@ -4,8 +4,8 @@ import {
4
4
  } from "../chunk-IIENZE2J.js";
5
5
  import {
6
6
  exitOnFailedResponse
7
- } from "../chunk-FBGBJXVC.js";
8
- import "../chunk-F52SIIDG.js";
7
+ } from "../chunk-DNSIVHIA.js";
8
+ import "../chunk-QDKJTPAT.js";
9
9
  import {
10
10
  createIo
11
11
  } from "../chunk-5RUIFDTP.js";
@@ -14,8 +14,8 @@ import {
14
14
  } from "../chunk-GMXKITVA.js";
15
15
  import {
16
16
  exitOnHelpFlag
17
- } from "../chunk-J4KFVOCQ.js";
18
- import "../chunk-MGJBC6DD.js";
17
+ } from "../chunk-SQOFGPNX.js";
18
+ import "../chunk-GOEXZ5QJ.js";
19
19
  import "../chunk-DINDL2CF.js";
20
20
  import "../chunk-SAF6HGAA.js";
21
21
  import {
@@ -28,7 +28,7 @@ import {
28
28
  getApiKey,
29
29
  getBaseUrl
30
30
  } from "../chunk-2UMNXADU.js";
31
- import "../chunk-MQMPG5X4.js";
31
+ import "../chunk-G3LXA2ZP.js";
32
32
 
33
33
  // bin/pushary-wait.ts
34
34
  exitOnHelpFlag("wait");
@@ -3,7 +3,7 @@ import {
3
3
  COMMANDS,
4
4
  isCommandName,
5
5
  renderHelp
6
- } from "../chunk-MGJBC6DD.js";
6
+ } from "../chunk-GOEXZ5QJ.js";
7
7
  import {
8
8
  getPackageVersion
9
9
  } from "../chunk-DINDL2CF.js";
@@ -26,6 +26,7 @@ var LOADERS = {
26
26
  connect: () => import("./pushary-connect.js"),
27
27
  bell: () => import("./pushary-bell.js"),
28
28
  doctor: () => import("./pushary-doctor.js"),
29
+ disconnect: () => import("./pushary-disconnect.js"),
29
30
  clean: () => import("./pushary-clean.js"),
30
31
  mode: () => import("./pushary-mode.js"),
31
32
  wait: () => import("./pushary-wait.js"),
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pusharyDir
3
- } from "./chunk-SEAHGHCE.js";
3
+ } from "./chunk-PHXEADSL.js";
4
4
  import {
5
5
  readJsonSafe
6
6
  } from "./chunk-6MTNS63X.js";
@@ -0,0 +1,59 @@
1
+ // src/admission.ts
2
+ import { readFileSync } from "fs";
3
+ import { homedir } from "os";
4
+ import { join } from "path";
5
+ var NO_RULES = { version: 1, disabled: [] };
6
+ var SUPPORTED_VERSION = 1;
7
+ var parseAdmissionRules = (raw) => {
8
+ if (!raw) return NO_RULES;
9
+ try {
10
+ const parsed = JSON.parse(raw);
11
+ if (parsed.version !== SUPPORTED_VERSION) return NO_RULES;
12
+ if (!Array.isArray(parsed.disabled)) return NO_RULES;
13
+ return {
14
+ version: SUPPORTED_VERSION,
15
+ disabled: parsed.disabled.filter((rule) => typeof rule === "string")
16
+ };
17
+ } catch {
18
+ return NO_RULES;
19
+ }
20
+ };
21
+ var admissionRulesFile = () => process.env.PUSHARY_ADMISSION_FILE?.trim() || join(homedir(), ".pushary", "admission-rules.json");
22
+ var readAdmissionRules = () => {
23
+ try {
24
+ return parseAdmissionRules(readFileSync(admissionRulesFile(), "utf-8"));
25
+ } catch {
26
+ return NO_RULES;
27
+ }
28
+ };
29
+ var matches = (rule, source, event) => {
30
+ const colon = rule.indexOf(":");
31
+ if (colon <= 0 || colon === rule.length - 1) return false;
32
+ const ruleSource = rule.slice(0, colon);
33
+ const ruleEvent = rule.slice(colon + 1);
34
+ return (ruleSource === "*" || ruleSource === source) && (ruleEvent === "*" || ruleEvent === event);
35
+ };
36
+ var isAdmitted = (rules, source, event) => !rules.disabled.some((rule) => matches(rule, source, event));
37
+ var readHookInput = async (source, fallbackEvent = "", stdin = process.stdin) => {
38
+ let raw = "";
39
+ for await (const chunk of stdin) raw += chunk;
40
+ if (!raw.trim()) return null;
41
+ let parsed;
42
+ try {
43
+ parsed = JSON.parse(raw);
44
+ } catch {
45
+ return null;
46
+ }
47
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
48
+ const event = eventNameOf(parsed) ?? fallbackEvent;
49
+ return isAdmitted(readAdmissionRules(), source, event) ? parsed : null;
50
+ };
51
+ var eventNameOf = (input) => {
52
+ if (!("hook_event_name" in input)) return void 0;
53
+ const name = input.hook_event_name;
54
+ return typeof name === "string" && name.length > 0 ? name : void 0;
55
+ };
56
+
57
+ export {
58
+ readHookInput
59
+ };
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-BSZYIAZL.js";
12
12
  import {
13
13
  reportedInstallSource
14
- } from "./chunk-437T77TY.js";
14
+ } from "./chunk-ES3FAX5X.js";
15
15
 
16
16
  // src/reach.ts
17
17
  var reachVerdict = (channels) => {
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-6MTNS63X.js";
10
10
  import {
11
11
  resolveInstallSourceFor
12
- } from "./chunk-437T77TY.js";
12
+ } from "./chunk-ES3FAX5X.js";
13
13
  import {
14
14
  configFilePath
15
15
  } from "./chunk-2UMNXADU.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  describeKeyCheck,
3
3
  keyCheckFromResponse
4
- } from "./chunk-F52SIIDG.js";
4
+ } from "./chunk-QDKJTPAT.js";
5
5
  import {
6
6
  createIo
7
7
  } from "./chunk-5RUIFDTP.js";
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-2UMNXADU.js";
4
4
  import {
5
5
  normalizeInstallSource
6
- } from "./chunk-MQMPG5X4.js";
6
+ } from "./chunk-G3LXA2ZP.js";
7
7
 
8
8
  // src/install-source.ts
9
9
  import { readFileSync } from "fs";