@pushary/agent-hooks 0.84.0 → 0.85.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.
- package/CHANGELOG.md +63 -0
- package/README.md +24 -0
- package/dist/bin/pushary-bell-hook.js +5 -3
- package/dist/bin/pushary-bell.js +8 -7
- package/dist/bin/pushary-claude.js +29 -20
- package/dist/bin/pushary-clean.js +6 -5
- package/dist/bin/pushary-codex-bridge.js +8 -7
- package/dist/bin/pushary-codex-hook.js +11 -14
- package/dist/bin/pushary-codex.js +1 -1
- package/dist/bin/pushary-connect.js +5 -5
- package/dist/bin/pushary-daemon.js +36 -18
- package/dist/bin/pushary-disconnect.d.ts +1 -0
- package/dist/bin/pushary-disconnect.js +125 -0
- package/dist/bin/pushary-doctor.js +9 -9
- package/dist/bin/pushary-gemini-bridge.js +8 -7
- package/dist/bin/pushary-gemini-hook.js +12 -15
- package/dist/bin/pushary-hook.js +13 -20
- package/dist/bin/pushary-login.js +2 -2
- package/dist/bin/pushary-logout.js +3 -3
- package/dist/bin/pushary-mode.js +2 -2
- package/dist/bin/pushary-notification-hook.js +6 -9
- package/dist/bin/pushary-permission-denied-hook.js +11 -9
- package/dist/bin/pushary-permission-hook.js +11 -9
- package/dist/bin/pushary-post-hook.js +6 -9
- package/dist/bin/pushary-prompt-hook.js +6 -9
- package/dist/bin/pushary-session-end-hook.js +6 -6
- package/dist/bin/pushary-session-start-hook.js +6 -6
- package/dist/bin/pushary-setup.js +23 -24
- package/dist/bin/pushary-stats.js +2 -2
- package/dist/bin/pushary-status.js +2 -2
- package/dist/bin/pushary-stop-hook.js +6 -6
- package/dist/bin/pushary-stopfailure-hook.js +6 -6
- package/dist/bin/pushary-suggestions.js +2 -2
- package/dist/bin/pushary-upgrade.js +13 -8
- package/dist/bin/pushary-wait.js +2 -2
- package/dist/bin/pushary.js +2 -1
- package/dist/{chunk-HZNOAJGB.js → chunk-4QPOMJUB.js} +1 -1
- package/dist/chunk-64PXDATC.js +187 -0
- package/dist/chunk-6CUUA7HO.js +59 -0
- package/dist/{chunk-UXWEE3QI.js → chunk-ADISVXZL.js} +1 -1
- package/dist/chunk-AXRATIS6.js +70 -0
- package/dist/{chunk-YJCMI5GF.js → chunk-ERYKGH4J.js} +11 -4
- package/dist/{chunk-OPMSMF5R.js → chunk-EXMUM226.js} +21 -8
- package/dist/{chunk-NWYGW7HY.js → chunk-GCKAWHFP.js} +9 -2
- package/dist/{chunk-QNBA5OXQ.js → chunk-GFM3STWO.js} +3 -3
- package/dist/{chunk-MGJBC6DD.js → chunk-GOEXZ5QJ.js} +1 -0
- package/dist/{chunk-37AD5K7W.js → chunk-GXIFADGD.js} +1 -1
- package/dist/{chunk-SEAHGHCE.js → chunk-HVZIHTOO.js} +33 -0
- package/dist/chunk-PWTKKQQI.js +27 -0
- package/dist/{chunk-J4KFVOCQ.js → chunk-SQOFGPNX.js} +1 -1
- package/dist/{chunk-CCH775Y6.js → chunk-WEAQQSHQ.js} +1 -1
- package/dist/{chunk-EVJ6ULHN.js → chunk-YKW6JCWI.js} +68 -29
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +6 -4
- package/package.json +3 -2
- package/dist/chunk-UKSQWTBH.js +0 -208
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
detectClaudeVersion
|
|
4
|
+
} from "../chunk-AXRATIS6.js";
|
|
2
5
|
import {
|
|
3
6
|
claudeWired,
|
|
4
7
|
codexWired,
|
|
5
8
|
geminiWired
|
|
6
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-4QPOMJUB.js";
|
|
7
10
|
import {
|
|
8
11
|
runBrowserLogin
|
|
9
12
|
} from "../chunk-Z3Z4VK5F.js";
|
|
10
13
|
import {
|
|
11
14
|
ensureDaemonRunning
|
|
12
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-WEAQQSHQ.js";
|
|
13
16
|
import {
|
|
14
17
|
describeDetection,
|
|
15
18
|
detectAllAgents,
|
|
@@ -21,7 +24,7 @@ import {
|
|
|
21
24
|
shortenHome,
|
|
22
25
|
vscodeSettingsTargets,
|
|
23
26
|
writeInstructionBlock
|
|
24
|
-
} from "../chunk-
|
|
27
|
+
} from "../chunk-ADISVXZL.js";
|
|
25
28
|
import {
|
|
26
29
|
GEMINI_HOOK_BINARY,
|
|
27
30
|
addGeminiHooks,
|
|
@@ -30,13 +33,18 @@ import {
|
|
|
30
33
|
import {
|
|
31
34
|
addClaudeMcpServer,
|
|
32
35
|
addPusharyHooks,
|
|
33
|
-
addPusharyToolPermissions
|
|
34
|
-
|
|
36
|
+
addPusharyToolPermissions,
|
|
37
|
+
compareVersion,
|
|
38
|
+
parseVersion
|
|
39
|
+
} from "../chunk-64PXDATC.js";
|
|
40
|
+
import {
|
|
41
|
+
guardBinary,
|
|
42
|
+
guardNodeScript
|
|
43
|
+
} from "../chunk-PWTKKQQI.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-
|
|
68
|
+
} from "../chunk-HVZIHTOO.js";
|
|
61
69
|
import {
|
|
62
70
|
reportEvent
|
|
63
|
-
} from "../chunk-
|
|
71
|
+
} from "../chunk-EXMUM226.js";
|
|
64
72
|
import "../chunk-RN3NOEJF.js";
|
|
65
73
|
import {
|
|
66
74
|
confirmAppConnection,
|
|
@@ -92,7 +100,7 @@ import {
|
|
|
92
100
|
} from "../chunk-GMXKITVA.js";
|
|
93
101
|
import {
|
|
94
102
|
renderCommandHelp
|
|
95
|
-
} from "../chunk-
|
|
103
|
+
} from "../chunk-GOEXZ5QJ.js";
|
|
96
104
|
import {
|
|
97
105
|
installClaudeAlias,
|
|
98
106
|
resolveShellRc
|
|
@@ -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 =
|
|
238
|
-
|
|
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 =
|
|
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:
|
|
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,
|
|
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);
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
} from "../chunk-NJ7JT26G.js";
|
|
5
5
|
import {
|
|
6
6
|
exitOnHelpFlag
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
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 {
|
|
@@ -25,8 +25,8 @@ import {
|
|
|
25
25
|
} from "../chunk-GMXKITVA.js";
|
|
26
26
|
import {
|
|
27
27
|
exitOnHelpFlag
|
|
28
|
-
} from "../chunk-
|
|
29
|
-
import "../chunk-
|
|
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";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
readHookInput
|
|
4
|
+
} from "../chunk-6CUUA7HO.js";
|
|
2
5
|
import {
|
|
3
6
|
handleStop
|
|
4
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-EXMUM226.js";
|
|
5
8
|
import "../chunk-RN3NOEJF.js";
|
|
6
9
|
import "../chunk-BSZYIAZL.js";
|
|
7
10
|
import "../chunk-SAF6HGAA.js";
|
|
@@ -13,12 +16,9 @@ import "../chunk-MQMPG5X4.js";
|
|
|
13
16
|
|
|
14
17
|
// bin/pushary-stop-hook.ts
|
|
15
18
|
var main = async () => {
|
|
16
|
-
|
|
17
|
-
|
|
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,7 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
readHookInput
|
|
4
|
+
} from "../chunk-6CUUA7HO.js";
|
|
2
5
|
import {
|
|
3
6
|
handleStopFailure
|
|
4
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-EXMUM226.js";
|
|
5
8
|
import "../chunk-RN3NOEJF.js";
|
|
6
9
|
import "../chunk-BSZYIAZL.js";
|
|
7
10
|
import "../chunk-SAF6HGAA.js";
|
|
@@ -13,12 +16,9 @@ import "../chunk-MQMPG5X4.js";
|
|
|
13
16
|
|
|
14
17
|
// bin/pushary-stopfailure-hook.ts
|
|
15
18
|
var main = async () => {
|
|
16
|
-
|
|
17
|
-
|
|
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-
|
|
11
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-SQOFGPNX.js";
|
|
11
|
+
import "../chunk-GOEXZ5QJ.js";
|
|
12
12
|
import "../chunk-DINDL2CF.js";
|
|
13
13
|
import {
|
|
14
14
|
UsageError
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
detectClaudeVersion
|
|
4
|
+
} from "../chunk-AXRATIS6.js";
|
|
2
5
|
import {
|
|
3
6
|
GEMINI_HOOK_BINARY,
|
|
4
7
|
addGeminiHooks,
|
|
@@ -9,11 +12,13 @@ import {
|
|
|
9
12
|
addClaudeMcpServer,
|
|
10
13
|
addPusharyHooks,
|
|
11
14
|
addPusharyToolPermissions
|
|
12
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-64PXDATC.js";
|
|
16
|
+
import {
|
|
17
|
+
guardBinary
|
|
18
|
+
} from "../chunk-PWTKKQQI.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-
|
|
38
|
+
} from "../chunk-HVZIHTOO.js";
|
|
34
39
|
import {
|
|
35
40
|
exitOnHelpFlag
|
|
36
|
-
} from "../chunk-
|
|
37
|
-
import "../chunk-
|
|
41
|
+
} from "../chunk-SQOFGPNX.js";
|
|
42
|
+
import "../chunk-GOEXZ5QJ.js";
|
|
38
43
|
import {
|
|
39
44
|
isNewerVersion
|
|
40
45
|
} from "../chunk-DINDL2CF.js";
|
|
@@ -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 =
|
|
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,
|
|
160
|
+
addGeminiHooks(settings, guardBinary(resolveGlobalBinary(GEMINI_HOOK_BINARY) ?? GEMINI_HOOK_BINARY));
|
|
156
161
|
hooks = true;
|
|
157
162
|
if (apiKey) {
|
|
158
163
|
addGeminiMcpServer(settings, apiKey);
|
package/dist/bin/pushary-wait.js
CHANGED
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
} from "../chunk-GMXKITVA.js";
|
|
15
15
|
import {
|
|
16
16
|
exitOnHelpFlag
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-
|
|
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 {
|
package/dist/bin/pushary.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
COMMANDS,
|
|
4
4
|
isCommandName,
|
|
5
5
|
renderHelp
|
|
6
|
-
} from "../chunk-
|
|
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"),
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import {
|
|
2
|
+
guardBinary
|
|
3
|
+
} from "./chunk-PWTKKQQI.js";
|
|
4
|
+
import {
|
|
5
|
+
HOOK_BUDGETS
|
|
6
|
+
} from "./chunk-MQMPG5X4.js";
|
|
7
|
+
|
|
8
|
+
// src/claude-config.ts
|
|
9
|
+
import { join } from "path";
|
|
10
|
+
|
|
11
|
+
// src/agent-version.ts
|
|
12
|
+
var parseVersion = (raw) => {
|
|
13
|
+
const match = raw.match(/(\d+)\.(\d+)\.(\d+)/);
|
|
14
|
+
return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
|
|
15
|
+
};
|
|
16
|
+
var compareVersion = (a, b) => {
|
|
17
|
+
for (let index = 0; index < 3; index++) {
|
|
18
|
+
if (a[index] !== b[index]) return a[index] < b[index] ? -1 : 1;
|
|
19
|
+
}
|
|
20
|
+
return 0;
|
|
21
|
+
};
|
|
22
|
+
var atLeast = (version, floor) => compareVersion(version, floor) >= 0;
|
|
23
|
+
|
|
24
|
+
// src/claude-tools.ts
|
|
25
|
+
var PRETOOLUSE_GATED_TOOLS = [
|
|
26
|
+
"Bash",
|
|
27
|
+
"Write",
|
|
28
|
+
"Edit",
|
|
29
|
+
"MultiEdit",
|
|
30
|
+
"NotebookEdit",
|
|
31
|
+
"PowerShell",
|
|
32
|
+
"Monitor"
|
|
33
|
+
];
|
|
34
|
+
var POSTTOOLUSE_MIRRORED_TOOLS = [...PRETOOLUSE_GATED_TOOLS, "TodoWrite"];
|
|
35
|
+
var PRETOOLUSE_HANDLED_TOOLS = /* @__PURE__ */ new Set([...PRETOOLUSE_GATED_TOOLS, "AskUserQuestion"]);
|
|
36
|
+
|
|
37
|
+
// src/claude-events.ts
|
|
38
|
+
var GATED_TOOLS = [...PRETOOLUSE_GATED_TOOLS, "AskUserQuestion"].join("|");
|
|
39
|
+
var MIRRORED_TOOLS = [...PRETOOLUSE_GATED_TOOLS, "TodoWrite"].join("|");
|
|
40
|
+
var ESTABLISHED = [1, 0, 0];
|
|
41
|
+
var OBSERVED = [2, 0, 0];
|
|
42
|
+
var CLAUDE_HOOK_EVENTS = [
|
|
43
|
+
{ event: "PreToolUse", binary: "pushary-hook", matcher: GATED_TOOLS, timeout: HOOK_BUDGETS.claude.budgetSeconds, since: ESTABLISHED },
|
|
44
|
+
{ event: "PostToolUse", binary: "pushary-post-hook", matcher: MIRRORED_TOOLS, timeout: 10, since: ESTABLISHED },
|
|
45
|
+
{ event: "Stop", binary: "pushary-stop-hook", timeout: 10, since: ESTABLISHED },
|
|
46
|
+
{ event: "UserPromptSubmit", binary: "pushary-prompt-hook", timeout: 10, since: ESTABLISHED },
|
|
47
|
+
{ event: "Notification", binary: "pushary-notification-hook", matcher: "permission_prompt|idle_prompt|agent_needs_input|agent_completed", timeout: 10, since: ESTABLISHED },
|
|
48
|
+
{ event: "SessionStart", binary: "pushary-session-start-hook", matcher: "startup|resume|clear", timeout: 10, since: ESTABLISHED },
|
|
49
|
+
{ event: "SessionEnd", binary: "pushary-session-end-hook", timeout: 10, since: ESTABLISHED },
|
|
50
|
+
{ event: "StopFailure", binary: "pushary-stopfailure-hook", timeout: 10, since: ESTABLISHED },
|
|
51
|
+
{ event: "PermissionRequest", binary: "pushary-permission-hook", timeout: HOOK_BUDGETS.claude.budgetSeconds, since: ESTABLISHED },
|
|
52
|
+
{ event: "PermissionDenied", binary: "pushary-permission-denied-hook", timeout: 60, since: ESTABLISHED },
|
|
53
|
+
// Observability only. Each carries session shape the island cannot get any other
|
|
54
|
+
// way, and none of them decides anything.
|
|
55
|
+
{ event: "SubagentStart", binary: "pushary-session-start-hook", timeout: 10, since: OBSERVED },
|
|
56
|
+
{ event: "SubagentStop", binary: "pushary-stop-hook", timeout: 10, since: OBSERVED },
|
|
57
|
+
{ event: "PreCompact", binary: "pushary-post-hook", matcher: "manual|auto", timeout: 10, since: OBSERVED },
|
|
58
|
+
{ event: "PostCompact", binary: "pushary-post-hook", matcher: "manual|auto", timeout: 10, since: OBSERVED },
|
|
59
|
+
{ event: "TeammateIdle", binary: "pushary-notification-hook", timeout: 10, since: OBSERVED }
|
|
60
|
+
];
|
|
61
|
+
var supportedClaudeEvents = (version) => CLAUDE_HOOK_EVENTS.filter((hook) => version ? atLeast(version, hook.since) : hook.since === ESTABLISHED);
|
|
62
|
+
|
|
63
|
+
// src/claude-config.ts
|
|
64
|
+
var PUSHARY_MCP_URL = "https://pushary.com/api/mcp/mcp";
|
|
65
|
+
var PUSHARY_PERMISSION_RULE = "mcp__pushary__*";
|
|
66
|
+
var asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
67
|
+
var ensureRecord = (target, key) => {
|
|
68
|
+
const existing = asRecord(target[key]);
|
|
69
|
+
if (existing) return existing;
|
|
70
|
+
const created = {};
|
|
71
|
+
target[key] = created;
|
|
72
|
+
return created;
|
|
73
|
+
};
|
|
74
|
+
var isPusharyPermission = (rule) => typeof rule === "string" && (rule.includes("pushary") || rule.includes("MCP(pushary"));
|
|
75
|
+
var HOOK_BINARIES = new Set(CLAUDE_HOOK_EVENTS.map((hook) => hook.binary));
|
|
76
|
+
var namesPusharyBinary = (command) => command.split(/[\s/\\"']+/).some((segment) => HOOK_BINARIES.has(segment.replace(/\.(cmd|exe)$/i, "")));
|
|
77
|
+
var isPusharyHook = (entry2) => {
|
|
78
|
+
const hooks = asRecord(entry2)?.hooks;
|
|
79
|
+
if (!Array.isArray(hooks)) return false;
|
|
80
|
+
return hooks.some((hook) => namesPusharyBinary(String(asRecord(hook)?.command ?? "")));
|
|
81
|
+
};
|
|
82
|
+
var addClaudeMcpServer = (config, apiKey) => {
|
|
83
|
+
const mcpServers = ensureRecord(config, "mcpServers");
|
|
84
|
+
mcpServers.pushary = {
|
|
85
|
+
type: "http",
|
|
86
|
+
url: PUSHARY_MCP_URL,
|
|
87
|
+
headers: { Authorization: `Bearer ${apiKey}` }
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
var removeClaudeMcpServers = (config) => {
|
|
91
|
+
let changed = false;
|
|
92
|
+
const removeFrom = (target) => {
|
|
93
|
+
const mcpServers = asRecord(target.mcpServers);
|
|
94
|
+
if (!mcpServers?.pushary) return;
|
|
95
|
+
delete mcpServers.pushary;
|
|
96
|
+
if (Object.keys(mcpServers).length === 0) delete target.mcpServers;
|
|
97
|
+
changed = true;
|
|
98
|
+
};
|
|
99
|
+
removeFrom(config);
|
|
100
|
+
const projects = asRecord(config.projects);
|
|
101
|
+
if (projects) {
|
|
102
|
+
for (const project of Object.values(projects)) {
|
|
103
|
+
const projectConfig = asRecord(project);
|
|
104
|
+
if (projectConfig) removeFrom(projectConfig);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return changed;
|
|
108
|
+
};
|
|
109
|
+
var addPusharyToolPermissions = (settings) => {
|
|
110
|
+
const permissions = ensureRecord(settings, "permissions");
|
|
111
|
+
const allow = Array.isArray(permissions.allow) ? permissions.allow : [];
|
|
112
|
+
const filtered = allow.filter((rule) => !isPusharyPermission(rule));
|
|
113
|
+
if (!filtered.includes(PUSHARY_PERMISSION_RULE)) {
|
|
114
|
+
filtered.push(PUSHARY_PERMISSION_RULE);
|
|
115
|
+
}
|
|
116
|
+
permissions.allow = filtered;
|
|
117
|
+
};
|
|
118
|
+
var addPusharyHooks = (settings, binDir, version = null) => {
|
|
119
|
+
const resolve = (name) => guardBinary(binDir ? join(binDir, name) : name);
|
|
120
|
+
const hooks = ensureRecord(settings, "hooks");
|
|
121
|
+
const supported = new Map(supportedClaudeEvents(version).map((hook) => [hook.event, hook]));
|
|
122
|
+
for (const known of CLAUDE_HOOK_EVENTS) {
|
|
123
|
+
const current = hooks[known.event];
|
|
124
|
+
const others = (Array.isArray(current) ? current : []).filter((item) => !isPusharyHook(item));
|
|
125
|
+
const definition = supported.get(known.event);
|
|
126
|
+
if (definition) {
|
|
127
|
+
hooks[known.event] = [...others, entry(definition, resolve)];
|
|
128
|
+
} else if (others.length > 0) {
|
|
129
|
+
hooks[known.event] = others;
|
|
130
|
+
} else {
|
|
131
|
+
delete hooks[known.event];
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
var entry = (definition, resolve) => ({
|
|
136
|
+
...definition.matcher ? { matcher: definition.matcher } : {},
|
|
137
|
+
hooks: [{
|
|
138
|
+
type: "command",
|
|
139
|
+
command: resolve(definition.binary),
|
|
140
|
+
timeout: definition.timeout
|
|
141
|
+
}]
|
|
142
|
+
});
|
|
143
|
+
var removePusharySettings = (settings) => {
|
|
144
|
+
let changed = removeClaudeMcpServers(settings);
|
|
145
|
+
const permissions = asRecord(settings.permissions);
|
|
146
|
+
if (permissions && Array.isArray(permissions.allow)) {
|
|
147
|
+
const filtered = permissions.allow.filter((rule) => !isPusharyPermission(rule));
|
|
148
|
+
if (filtered.length !== permissions.allow.length) {
|
|
149
|
+
if (filtered.length === 0) {
|
|
150
|
+
delete permissions.allow;
|
|
151
|
+
} else {
|
|
152
|
+
permissions.allow = filtered;
|
|
153
|
+
}
|
|
154
|
+
if (Object.keys(permissions).length === 0) delete settings.permissions;
|
|
155
|
+
changed = true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const hooks = asRecord(settings.hooks);
|
|
159
|
+
if (hooks) {
|
|
160
|
+
for (const { event: key } of CLAUDE_HOOK_EVENTS) {
|
|
161
|
+
const entries = hooks[key];
|
|
162
|
+
if (!Array.isArray(entries)) continue;
|
|
163
|
+
const filtered = entries.filter((entry2) => !isPusharyHook(entry2));
|
|
164
|
+
if (filtered.length !== entries.length) {
|
|
165
|
+
if (filtered.length === 0) {
|
|
166
|
+
delete hooks[key];
|
|
167
|
+
} else {
|
|
168
|
+
hooks[key] = filtered;
|
|
169
|
+
}
|
|
170
|
+
changed = true;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (Object.keys(hooks).length === 0) delete settings.hooks;
|
|
174
|
+
}
|
|
175
|
+
return changed;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
export {
|
|
179
|
+
parseVersion,
|
|
180
|
+
compareVersion,
|
|
181
|
+
PRETOOLUSE_HANDLED_TOOLS,
|
|
182
|
+
addClaudeMcpServer,
|
|
183
|
+
removeClaudeMcpServers,
|
|
184
|
+
addPusharyToolPermissions,
|
|
185
|
+
addPusharyHooks,
|
|
186
|
+
removePusharySettings
|
|
187
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseVersion
|
|
3
|
+
} from "./chunk-64PXDATC.js";
|
|
4
|
+
|
|
5
|
+
// src/setup/agent-probe.ts
|
|
6
|
+
import { execSync } from "child_process";
|
|
7
|
+
import { readFileSync, realpathSync } from "fs";
|
|
8
|
+
|
|
9
|
+
// src/setup/claude-version.ts
|
|
10
|
+
import { dirname, basename, join } from "path";
|
|
11
|
+
var versionFromInstallPath = (path) => {
|
|
12
|
+
const name = basename(path);
|
|
13
|
+
return /^\d+\.\d+\.\d+$/.test(name) ? parseVersion(name) : null;
|
|
14
|
+
};
|
|
15
|
+
var versionFromManifest = (probe, binPath) => {
|
|
16
|
+
let dir = dirname(binPath);
|
|
17
|
+
for (let depth = 0; depth < 4; depth++) {
|
|
18
|
+
const raw = probe.readFile(join(dir, "package.json"));
|
|
19
|
+
if (raw) {
|
|
20
|
+
try {
|
|
21
|
+
const { version } = JSON.parse(raw);
|
|
22
|
+
if (typeof version === "string") {
|
|
23
|
+
const parsed = parseVersion(version);
|
|
24
|
+
if (parsed) return parsed;
|
|
25
|
+
}
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const parent = dirname(dir);
|
|
30
|
+
if (parent === dir) break;
|
|
31
|
+
dir = parent;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
};
|
|
35
|
+
var readClaudeVersion = (probe) => {
|
|
36
|
+
const onPath2 = probe.resolveOnPath();
|
|
37
|
+
if (!onPath2) return null;
|
|
38
|
+
const resolved = probe.realpath(onPath2) ?? onPath2;
|
|
39
|
+
return versionFromInstallPath(resolved) ?? versionFromManifest(probe, resolved);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/setup/agent-probe.ts
|
|
43
|
+
var onPath = (name) => {
|
|
44
|
+
const command = process.platform === "win32" ? "where" : "which";
|
|
45
|
+
try {
|
|
46
|
+
const found = execSync(`${command} ${name}`, { encoding: "utf-8", stdio: "pipe", timeout: 5e3 }).split("\n")[0].trim();
|
|
47
|
+
return found || null;
|
|
48
|
+
} catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var realpath = (path) => {
|
|
53
|
+
try {
|
|
54
|
+
return realpathSync(path);
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var readFile = (path) => {
|
|
60
|
+
try {
|
|
61
|
+
return readFileSync(path, "utf-8");
|
|
62
|
+
} catch {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var detectClaudeVersion = () => readClaudeVersion({ resolveOnPath: () => onPath("claude"), realpath, readFile });
|
|
67
|
+
|
|
68
|
+
export {
|
|
69
|
+
detectClaudeVersion
|
|
70
|
+
};
|