@pushary/agent-hooks 0.89.5 → 0.89.7
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 +26 -0
- package/dist/bin/pushary-bell.js +1 -1
- package/dist/bin/pushary-claude.js +5 -5
- package/dist/bin/pushary-clean.js +128 -24
- package/dist/bin/pushary-codex-bridge.js +3 -3
- package/dist/bin/pushary-codex-hook.js +3 -3
- package/dist/bin/pushary-codex.js +3 -3
- package/dist/bin/pushary-daemon.js +47 -9
- package/dist/bin/pushary-disconnect.js +2 -2
- package/dist/bin/pushary-doctor.js +6 -6
- package/dist/bin/pushary-elicitation-hook.js +2 -2
- package/dist/bin/pushary-gemini-bridge.js +3 -3
- package/dist/bin/pushary-gemini-hook.js +3 -3
- package/dist/bin/pushary-hook.js +4 -4
- package/dist/bin/pushary-logout.js +1 -1
- package/dist/bin/pushary-notification-hook.js +3 -3
- package/dist/bin/pushary-opencode-hook.js +3 -3
- package/dist/bin/pushary-permission-denied-hook.js +4 -4
- package/dist/bin/pushary-permission-hook.js +4 -4
- package/dist/bin/pushary-post-hook.js +3 -3
- package/dist/bin/pushary-prompt-hook.js +3 -3
- package/dist/bin/pushary-session-end-hook.js +3 -3
- package/dist/bin/pushary-session-start-hook.js +3 -3
- package/dist/bin/pushary-setup.js +46 -16
- package/dist/bin/pushary-status.js +3 -3
- package/dist/bin/pushary-stop-hook.js +3 -3
- package/dist/bin/pushary-stopfailure-hook.js +3 -3
- package/dist/bin/pushary-upgrade.js +38 -198
- package/dist/{chunk-2HYPZLYY.js → chunk-2M66JVZM.js} +1 -1
- package/dist/chunk-2MEJBUOI.js +210 -0
- package/dist/{chunk-4ZHQNBDP.js → chunk-42TTFZLV.js} +1 -1
- package/dist/{chunk-MZBT2LXW.js → chunk-5YUVKPTS.js} +2 -2
- package/dist/{chunk-QH4AA7QV.js → chunk-A4O5ROZK.js} +1 -1
- package/dist/{chunk-OBI4YMCT.js → chunk-BAE45YLP.js} +2 -2
- package/dist/{chunk-NFI2K2ZQ.js → chunk-BPKMGE7L.js} +1 -1
- package/dist/{chunk-V37ZXMH3.js → chunk-GMI5QZLG.js} +15 -9
- package/dist/{chunk-475T3XIO.js → chunk-J2JZJZKB.js} +1 -1
- package/dist/{chunk-VP7SDXYG.js → chunk-TESGYWEM.js} +1 -1
- package/dist/{chunk-7TS2G4QG.js → chunk-VA7VUNRD.js} +22 -14
- package/dist/{chunk-TRQ46MXR.js → chunk-ZH7TWAYK.js} +8 -5
- package/dist/src/index.js +4 -4
- package/package.json +1 -1
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
guardBinary
|
|
7
7
|
} from "./chunk-AIGDBRIJ.js";
|
|
8
|
+
import {
|
|
9
|
+
isProtectedByScope
|
|
10
|
+
} from "./chunk-GMI5QZLG.js";
|
|
8
11
|
import {
|
|
9
12
|
HOOK_BUDGETS,
|
|
10
13
|
HOOK_LOCATOR_BINARY
|
|
@@ -73,10 +76,14 @@ var HOOK_BINARIES = /* @__PURE__ */ new Set([
|
|
|
73
76
|
HOOK_LOCATOR_BINARY
|
|
74
77
|
]);
|
|
75
78
|
var namesPusharyBinary = (command) => command.split(/[\s/\\"']+/).some((segment) => HOOK_BINARIES.has(segment.replace(/\.(cmd|exe)$/i, "")));
|
|
76
|
-
var isPusharyHook = (entry2) => {
|
|
79
|
+
var isPusharyHook = (entry2, scope) => {
|
|
77
80
|
const hooks = asRecord(entry2)?.hooks;
|
|
78
81
|
if (!Array.isArray(hooks)) return false;
|
|
79
|
-
return hooks.some((hook) =>
|
|
82
|
+
return hooks.some((hook) => {
|
|
83
|
+
const command = String(asRecord(hook)?.command ?? "");
|
|
84
|
+
if (isProtectedByScope(command, scope)) return false;
|
|
85
|
+
return namesPusharyBinary(command);
|
|
86
|
+
});
|
|
80
87
|
};
|
|
81
88
|
var addClaudeMcpServer = (config, apiKey) => {
|
|
82
89
|
const mcpServers = ensureRecord(config, "mcpServers");
|
|
@@ -139,9 +146,9 @@ var entry = (definition, resolve) => ({
|
|
|
139
146
|
timeout: definition.timeout
|
|
140
147
|
}]
|
|
141
148
|
});
|
|
142
|
-
var removePusharySettings = (settings) => {
|
|
143
|
-
let changed = removeClaudeMcpServers(settings);
|
|
144
|
-
const permissions = asRecord(settings.permissions);
|
|
149
|
+
var removePusharySettings = (settings, scope) => {
|
|
150
|
+
let changed = scope?.keepMcpServer === true ? false : removeClaudeMcpServers(settings);
|
|
151
|
+
const permissions = scope?.keepMcpServer === true ? void 0 : asRecord(settings.permissions);
|
|
145
152
|
if (permissions && Array.isArray(permissions.allow)) {
|
|
146
153
|
const filtered = permissions.allow.filter((rule) => !isPusharyPermission(rule));
|
|
147
154
|
if (filtered.length !== permissions.allow.length) {
|
|
@@ -159,7 +166,7 @@ var removePusharySettings = (settings) => {
|
|
|
159
166
|
for (const { event: key } of CLAUDE_HOOK_EVENTS) {
|
|
160
167
|
const entries = hooks[key];
|
|
161
168
|
if (!Array.isArray(entries)) continue;
|
|
162
|
-
const filtered = entries.filter((entry2) => !isPusharyHook(entry2));
|
|
169
|
+
const filtered = entries.filter((entry2) => !isPusharyHook(entry2, scope));
|
|
163
170
|
if (filtered.length !== entries.length) {
|
|
164
171
|
if (filtered.length === 0) {
|
|
165
172
|
delete hooks[key];
|
|
@@ -192,11 +199,12 @@ var ensureRecord2 = (target, key) => {
|
|
|
192
199
|
target[key] = created;
|
|
193
200
|
return created;
|
|
194
201
|
};
|
|
195
|
-
var isPusharyGeminiHook = (entry2) => {
|
|
202
|
+
var isPusharyGeminiHook = (entry2, scope) => {
|
|
196
203
|
const hooks = asRecord2(entry2)?.hooks;
|
|
197
204
|
if (!Array.isArray(hooks)) return false;
|
|
198
205
|
return hooks.some((hook) => {
|
|
199
206
|
const command = String(asRecord2(hook)?.command ?? "");
|
|
207
|
+
if (isProtectedByScope(command, scope)) return false;
|
|
200
208
|
return command.includes(GEMINI_HOOK_BINARY) || command.includes(HOOK_LOCATOR_BINARY);
|
|
201
209
|
});
|
|
202
210
|
};
|
|
@@ -225,14 +233,14 @@ var addGeminiHooks = (settings, command) => {
|
|
|
225
233
|
hooks[definition.event] = entries;
|
|
226
234
|
}
|
|
227
235
|
};
|
|
228
|
-
var removeGeminiHooks = (settings) => {
|
|
236
|
+
var removeGeminiHooks = (settings, scope) => {
|
|
229
237
|
const hooks = asRecord2(settings.hooks);
|
|
230
238
|
if (!hooks) return false;
|
|
231
239
|
let changed = false;
|
|
232
240
|
for (const definition of GEMINI_HOOK_EVENTS) {
|
|
233
241
|
const entries = hooks[definition.event];
|
|
234
242
|
if (!Array.isArray(entries)) continue;
|
|
235
|
-
const filtered = entries.filter((entry2) => !isPusharyGeminiHook(entry2));
|
|
243
|
+
const filtered = entries.filter((entry2) => !isPusharyGeminiHook(entry2, scope));
|
|
236
244
|
if (filtered.length !== entries.length) {
|
|
237
245
|
if (filtered.length === 0) {
|
|
238
246
|
delete hooks[definition.event];
|
|
@@ -252,9 +260,9 @@ var removeGeminiMcpServer = (settings) => {
|
|
|
252
260
|
if (Object.keys(mcpServers).length === 0) delete settings.mcpServers;
|
|
253
261
|
return true;
|
|
254
262
|
};
|
|
255
|
-
var removeGeminiSettings = (settings) => {
|
|
256
|
-
const mcpRemoved = removeGeminiMcpServer(settings);
|
|
257
|
-
const hooksRemoved = removeGeminiHooks(settings);
|
|
263
|
+
var removeGeminiSettings = (settings, scope) => {
|
|
264
|
+
const mcpRemoved = scope?.keepMcpServer === true ? false : removeGeminiMcpServer(settings);
|
|
265
|
+
const hooksRemoved = removeGeminiHooks(settings, scope);
|
|
258
266
|
return mcpRemoved || hooksRemoved;
|
|
259
267
|
};
|
|
260
268
|
var hasGeminiHooks = (settings) => {
|
|
@@ -262,14 +270,14 @@ var hasGeminiHooks = (settings) => {
|
|
|
262
270
|
if (!hooks) return false;
|
|
263
271
|
return GEMINI_HOOK_EVENTS.some((definition) => {
|
|
264
272
|
const entries = hooks[definition.event];
|
|
265
|
-
return Array.isArray(entries) && entries.some(isPusharyGeminiHook);
|
|
273
|
+
return Array.isArray(entries) && entries.some((entry2) => isPusharyGeminiHook(entry2));
|
|
266
274
|
});
|
|
267
275
|
};
|
|
268
276
|
var missingGeminiHookEvents = (settings) => {
|
|
269
277
|
const hooks = asRecord2(settings.hooks);
|
|
270
278
|
return GEMINI_HOOK_EVENTS.filter((definition) => {
|
|
271
279
|
const entries = hooks?.[definition.event];
|
|
272
|
-
return !Array.isArray(entries) || !entries.some(isPusharyGeminiHook);
|
|
280
|
+
return !Array.isArray(entries) || !entries.some((entry2) => isPusharyGeminiHook(entry2));
|
|
273
281
|
}).map((definition) => definition.event);
|
|
274
282
|
};
|
|
275
283
|
|
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
} from "./chunk-PZA7G4CN.js";
|
|
8
8
|
import {
|
|
9
9
|
getMachineId
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2M66JVZM.js";
|
|
11
11
|
import {
|
|
12
12
|
pusharyDir
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-GMI5QZLG.js";
|
|
14
14
|
import {
|
|
15
15
|
getPackageVersion
|
|
16
16
|
} from "./chunk-DINDL2CF.js";
|
|
@@ -265,7 +265,7 @@ var parseDaemonAction = (argv) => {
|
|
|
265
265
|
return DAEMON_ACTIONS.has(action) ? action : null;
|
|
266
266
|
};
|
|
267
267
|
var manageDaemonService = (action, options = {}) => {
|
|
268
|
-
const definition = action === "uninstall" ? buildDaemonService({
|
|
268
|
+
const definition = action === "uninstall" || action === "stop" ? buildDaemonService({
|
|
269
269
|
platform: options.platform ?? process.platform,
|
|
270
270
|
homeDir: options.homeDir ?? homedir(),
|
|
271
271
|
stateDir: options.stateDir ?? pusharyDir(),
|
|
@@ -559,12 +559,12 @@ var stopDaemonRunning = async (options = {}) => {
|
|
|
559
559
|
safeUnlink(lockPath(dir));
|
|
560
560
|
return { kind: "stopped" };
|
|
561
561
|
};
|
|
562
|
-
var
|
|
562
|
+
var deactivateDaemonService = async (action, options) => {
|
|
563
563
|
const platform = options.platform ?? process.platform;
|
|
564
564
|
const supported = ["darwin", "linux", "win32"].includes(platform);
|
|
565
565
|
const managerAvailable = supported && daemonServiceManagerAvailable(options);
|
|
566
566
|
const definitionPresent = supported && hasDaemonServiceDefinition(options);
|
|
567
|
-
const service = definitionPresent && !managerAvailable ? { kind: "failed", detail: "Native background-service manager is unavailable" } : managerAvailable ? manageDaemonService(
|
|
567
|
+
const service = definitionPresent && !managerAvailable ? { kind: "failed", detail: "Native background-service manager is unavailable" } : managerAvailable ? manageDaemonService(action, options) : { kind: "ok" };
|
|
568
568
|
const stopped = await stopDaemonRunning(options);
|
|
569
569
|
const failures = [
|
|
570
570
|
service.kind === "ok" ? null : service.detail,
|
|
@@ -572,6 +572,8 @@ var disableDaemonService = async (options = {}) => {
|
|
|
572
572
|
].filter((detail) => detail !== null);
|
|
573
573
|
return failures.length > 0 ? { kind: "failed", detail: failures.join("; ") } : { kind: "ok" };
|
|
574
574
|
};
|
|
575
|
+
var stopDaemonService = async (options = {}) => deactivateDaemonService("stop", options);
|
|
576
|
+
var disableDaemonService = async (options = {}) => deactivateDaemonService("uninstall", options);
|
|
575
577
|
var replaceDaemonService = async (options = {}) => {
|
|
576
578
|
const stopped = await stopDaemonRunning(options);
|
|
577
579
|
return stopped.kind === "unavailable" ? stopped : manageDaemonService("install", options);
|
|
@@ -642,6 +644,7 @@ export {
|
|
|
642
644
|
acquireDaemonLease,
|
|
643
645
|
requestDaemonHandoff,
|
|
644
646
|
stopDaemonRunning,
|
|
647
|
+
stopDaemonService,
|
|
645
648
|
disableDaemonService,
|
|
646
649
|
replaceDaemonService,
|
|
647
650
|
ensureDaemonRunning
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handlePreToolUse
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-5YUVKPTS.js";
|
|
4
4
|
import "../chunk-ATBKJNWS.js";
|
|
5
5
|
import "../chunk-VZKXBFUA.js";
|
|
6
6
|
import "../chunk-YHG74UFF.js";
|
|
@@ -12,15 +12,15 @@ import {
|
|
|
12
12
|
handlePostToolUse,
|
|
13
13
|
handleStop,
|
|
14
14
|
reportEvent
|
|
15
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-BPKMGE7L.js";
|
|
16
16
|
import {
|
|
17
17
|
askUser,
|
|
18
18
|
cancelQuestion,
|
|
19
19
|
waitForAnswer
|
|
20
20
|
} from "../chunk-GKAKAOKC.js";
|
|
21
21
|
import "../chunk-KOPUTJQC.js";
|
|
22
|
-
import "../chunk-
|
|
23
|
-
import "../chunk-
|
|
22
|
+
import "../chunk-2M66JVZM.js";
|
|
23
|
+
import "../chunk-GMI5QZLG.js";
|
|
24
24
|
import "../chunk-BSZYIAZL.js";
|
|
25
25
|
import "../chunk-SAF6HGAA.js";
|
|
26
26
|
import "../chunk-OFRNZWC4.js";
|