@pushary/agent-hooks 0.85.0 → 0.85.2
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 +29 -0
- package/data/cursor-plugin/CHANGELOG.md +21 -0
- package/data/cursor-plugin/scripts/pushary-gate.mjs +54 -222
- package/data/cursor-plugin/scripts/pushary-gate.test.mjs +11 -106
- package/data/vscode-plugin/CHANGELOG.md +26 -0
- package/data/vscode-plugin/scripts/pushary-gate.mjs +66 -74
- package/dist/bin/pushary-bell-hook.js +4 -4
- package/dist/bin/pushary-bell.js +6 -6
- package/dist/bin/pushary-claude.js +12 -11
- package/dist/bin/pushary-clean.js +6 -6
- package/dist/bin/pushary-codex-bridge.js +5 -5
- package/dist/bin/pushary-codex-hook.js +9 -9
- package/dist/bin/pushary-codex.js +3 -3
- package/dist/bin/pushary-connect.js +6 -6
- package/dist/bin/pushary-daemon.js +4 -4
- package/dist/bin/pushary-disconnect.js +5 -5
- package/dist/bin/pushary-doctor.js +11 -11
- package/dist/bin/pushary-gemini-bridge.js +5 -5
- package/dist/bin/pushary-gemini-hook.js +17 -12
- package/dist/bin/pushary-hook.js +8 -8
- package/dist/bin/pushary-login.js +4 -4
- package/dist/bin/pushary-logout.js +4 -4
- package/dist/bin/pushary-mode.js +3 -3
- package/dist/bin/pushary-notification-hook.js +3 -3
- package/dist/bin/pushary-permission-denied-hook.js +8 -8
- package/dist/bin/pushary-permission-hook.js +8 -8
- 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 +14 -14
- package/dist/bin/pushary-stats.js +2 -2
- package/dist/bin/pushary-status.js +5 -5
- package/dist/bin/pushary-stop-hook.js +3 -3
- package/dist/bin/pushary-stopfailure-hook.js +3 -3
- package/dist/bin/pushary-upgrade.js +6 -6
- package/dist/bin/pushary-wait.js +3 -3
- package/dist/{chunk-ADISVXZL.js → chunk-4U2YRHNF.js} +1 -1
- package/dist/{chunk-WEAQQSHQ.js → chunk-4YMWLMAP.js} +1 -1
- package/dist/{chunk-437T77TY.js → chunk-CWV4CMB6.js} +1 -1
- package/dist/{chunk-EXMUM226.js → chunk-DPDUB4XF.js} +62 -156
- package/dist/{chunk-7PZPJSWI.js → chunk-GM74DUMS.js} +1 -1
- package/dist/{chunk-DOXSWT4Q.js → chunk-GY3I353G.js} +6 -6
- package/dist/chunk-HSGEEBBL.js +37 -0
- package/dist/{chunk-ERYKGH4J.js → chunk-JBLRZGTT.js} +1 -1
- package/dist/{chunk-4QPOMJUB.js → chunk-JT5NQQCE.js} +2 -2
- package/dist/{chunk-MQMPG5X4.js → chunk-K337LIBD.js} +260 -10
- package/dist/{chunk-HVZIHTOO.js → chunk-KJW6NKF7.js} +7 -7
- package/dist/{chunk-K7CSRGKZ.js → chunk-KZIGJLOX.js} +1 -1
- package/dist/{chunk-6LC4WSCL.js → chunk-LCA2EQTK.js} +1 -1
- package/dist/{chunk-F52SIIDG.js → chunk-LSB6PFLN.js} +1 -1
- package/dist/{chunk-YKW6JCWI.js → chunk-LXWISFF3.js} +1 -1
- package/dist/{chunk-FBGBJXVC.js → chunk-NTIUQB3E.js} +1 -1
- package/dist/{chunk-NJ7JT26G.js → chunk-PKUNB3SN.js} +1 -1
- package/dist/{chunk-AXRATIS6.js → chunk-Q4URN3E7.js} +1 -1
- package/dist/{chunk-GCKAWHFP.js → chunk-T54OT7IY.js} +1 -1
- package/dist/{chunk-64PXDATC.js → chunk-XJDL3MUE.js} +17 -17
- package/dist/{chunk-GFM3STWO.js → chunk-Y7E2MC3G.js} +20 -49
- package/dist/chunk-YHG74UFF.js +12 -0
- package/dist/src/index.d.ts +7 -29
- package/dist/src/index.js +10 -9
- package/package.json +4 -2
- package/dist/chunk-GXIFADGD.js +0 -66
- package/dist/chunk-PWTKKQQI.js +0 -27
package/dist/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handlePreToolUse
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-Y7E2MC3G.js";
|
|
4
|
+
import "../chunk-XJDL3MUE.js";
|
|
5
|
+
import "../chunk-HSGEEBBL.js";
|
|
6
6
|
import "../chunk-VT4IVERX.js";
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-PKUNB3SN.js";
|
|
8
|
+
import "../chunk-YHG74UFF.js";
|
|
9
9
|
import {
|
|
10
10
|
askUser,
|
|
11
11
|
cancelQuestion,
|
|
@@ -16,20 +16,21 @@ import {
|
|
|
16
16
|
handlePostToolUse,
|
|
17
17
|
handleStop,
|
|
18
18
|
reportEvent,
|
|
19
|
-
resolvePolicy,
|
|
20
19
|
waitForAnswer
|
|
21
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-DPDUB4XF.js";
|
|
22
21
|
import "../chunk-RN3NOEJF.js";
|
|
23
22
|
import "../chunk-BSZYIAZL.js";
|
|
24
23
|
import "../chunk-SAF6HGAA.js";
|
|
25
|
-
import "../chunk-
|
|
24
|
+
import "../chunk-CWV4CMB6.js";
|
|
26
25
|
import "../chunk-7QLSKOSU.js";
|
|
27
26
|
import "../chunk-KZERVKTD.js";
|
|
28
27
|
import {
|
|
29
28
|
getApiKey,
|
|
30
29
|
getBaseUrl
|
|
31
30
|
} from "../chunk-2UMNXADU.js";
|
|
32
|
-
import
|
|
31
|
+
import {
|
|
32
|
+
resolvePolicy
|
|
33
|
+
} from "../chunk-K337LIBD.js";
|
|
33
34
|
export {
|
|
34
35
|
askUser,
|
|
35
36
|
cancelQuestion,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushary/agent-hooks",
|
|
3
|
-
"version": "0.85.
|
|
3
|
+
"version": "0.85.2",
|
|
4
4
|
"description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pushary",
|
|
@@ -80,7 +80,8 @@
|
|
|
80
80
|
"build": "node scripts/bundle-plugin.mjs && tsup",
|
|
81
81
|
"dev": "tsup --watch",
|
|
82
82
|
"test": "node ../../scripts/ci/run-tests.mjs src bin",
|
|
83
|
-
"typecheck": "tsc --noEmit"
|
|
83
|
+
"typecheck": "tsc --noEmit",
|
|
84
|
+
"gen:hooks-spec": "bun scripts/generate-hooks-spec.ts"
|
|
84
85
|
},
|
|
85
86
|
"dependencies": {
|
|
86
87
|
"@inquirer/prompts": "^8.4.2",
|
|
@@ -91,6 +92,7 @@
|
|
|
91
92
|
},
|
|
92
93
|
"devDependencies": {
|
|
93
94
|
"@pushary/contracts": "workspace:*",
|
|
95
|
+
"@pushary/hook-mapping": "workspace:*",
|
|
94
96
|
"tsup": "^8.0.0",
|
|
95
97
|
"typescript": "^5.0.0"
|
|
96
98
|
}
|
package/dist/chunk-GXIFADGD.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isModeStateDegraded,
|
|
3
|
-
resolveAutoResolveOrigin,
|
|
4
|
-
resolvePolicyAcross
|
|
5
|
-
} from "./chunk-EXMUM226.js";
|
|
6
|
-
import {
|
|
7
|
-
evaluateScope,
|
|
8
|
-
scopeChangeReason,
|
|
9
|
-
scopeRequiresHuman,
|
|
10
|
-
verdictForPolicy
|
|
11
|
-
} from "./chunk-MQMPG5X4.js";
|
|
12
|
-
|
|
13
|
-
// src/answer.ts
|
|
14
|
-
var denyReasonFrom = (value, note) => {
|
|
15
|
-
const trimmed = note?.trim();
|
|
16
|
-
if (trimmed) return `Denied from your phone: ${trimmed}`;
|
|
17
|
-
return value && value !== "no" && value !== "yes" ? `Denied from your phone: ${value}` : "Denied via push notification";
|
|
18
|
-
};
|
|
19
|
-
var isDeferAnswer = (value) => value === "defer";
|
|
20
|
-
|
|
21
|
-
// src/gate.ts
|
|
22
|
-
var KILL_REASON = "Stopped by user, this agent was halted from Pushary";
|
|
23
|
-
var strictestScopeVerdict = (scope, paths) => {
|
|
24
|
-
if (paths.length === 0) return evaluateScope(scope, void 0);
|
|
25
|
-
let worst = { outcome: "in_scope" };
|
|
26
|
-
for (const path of paths) {
|
|
27
|
-
const verdict = evaluateScope(scope, path);
|
|
28
|
-
if (verdict.outcome === "off_limits") return verdict;
|
|
29
|
-
if (verdict.outcome === "out_of_scope") worst = verdict;
|
|
30
|
-
}
|
|
31
|
-
return worst;
|
|
32
|
-
};
|
|
33
|
-
var survivesDegraded = (config, toolName, toolInputs, cwd, repoKey, sessionId) => toolInputs.length === 1 && resolveAutoResolveOrigin(config, toolName, toolInputs[0], cwd, repoKey, sessionId) === "safe_readonly";
|
|
34
|
-
var resolveGate = (input) => {
|
|
35
|
-
const { modeState, config, toolName, toolInputs, cwd, repoKey, sessionId } = input;
|
|
36
|
-
if (modeState.kill) return { kind: "kill", reason: KILL_REASON };
|
|
37
|
-
const policy = resolvePolicyAcross(config, toolName, modeState.mode, toolInputs, cwd, repoKey, sessionId);
|
|
38
|
-
const verdict = verdictForPolicy(policy);
|
|
39
|
-
const autoApproves = verdict === "allow";
|
|
40
|
-
const autoDenies = verdict === "deny";
|
|
41
|
-
if (autoDenies) return { kind: "deny", policy, reason: `Denied by policy for ${policy.tool}` };
|
|
42
|
-
if (isModeStateDegraded(modeState)) {
|
|
43
|
-
if (autoApproves) {
|
|
44
|
-
return survivesDegraded(config, toolName, toolInputs, cwd, repoKey, sessionId) ? { kind: "allow", policy } : { kind: "defer", policy };
|
|
45
|
-
}
|
|
46
|
-
return { kind: "gate", policy };
|
|
47
|
-
}
|
|
48
|
-
const scopeVerdict = modeState.scope ? strictestScopeVerdict(modeState.scope, input.scopePaths ?? []) : { outcome: "no_contract" };
|
|
49
|
-
if (autoApproves) {
|
|
50
|
-
if (!scopeRequiresHuman(scopeVerdict)) return { kind: "allow", policy };
|
|
51
|
-
}
|
|
52
|
-
const scopeReason = scopeChangeReason(scopeVerdict);
|
|
53
|
-
return {
|
|
54
|
-
kind: "gate",
|
|
55
|
-
policy,
|
|
56
|
-
scopeReason,
|
|
57
|
-
scopePath: scopeReason && "path" in scopeVerdict ? scopeVerdict.path : void 0
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
denyReasonFrom,
|
|
63
|
-
isDeferAnswer,
|
|
64
|
-
KILL_REASON,
|
|
65
|
-
resolveGate
|
|
66
|
-
};
|
package/dist/chunk-PWTKKQQI.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
quoteIfNeeded
|
|
3
|
-
} from "./chunk-VT4IVERX.js";
|
|
4
|
-
|
|
5
|
-
// src/hook-command.ts
|
|
6
|
-
var SHELL = "/bin/sh -c";
|
|
7
|
-
var LOCATE = 'B=$(command -v "$0") || exit 0; [ -f "$B" ] || exit 0; [ -x "$B" ] || exit 0';
|
|
8
|
-
var NODE_PRESENT = "command -v node >/dev/null 2>&1 || exit 0";
|
|
9
|
-
var RESOLVE = {
|
|
10
|
-
native: `${LOCATE}; exec "$B"`,
|
|
11
|
-
node: `${LOCATE}; ${NODE_PRESENT}; exec "$B"`
|
|
12
|
-
};
|
|
13
|
-
var guardHookCommand = (target, platform = process.platform) => {
|
|
14
|
-
if (target.kind === "node") {
|
|
15
|
-
const script = quoteIfNeeded(target.script);
|
|
16
|
-
return platform === "win32" ? `node ${script}` : `${SHELL} '[ -f "$0" ] || exit 0; command -v node >/dev/null 2>&1 || exit 0; exec node "$0"' ${script}`;
|
|
17
|
-
}
|
|
18
|
-
const path = quoteIfNeeded(target.path);
|
|
19
|
-
return platform === "win32" ? path : `${SHELL} '${RESOLVE[target.runtime]}' ${path}`;
|
|
20
|
-
};
|
|
21
|
-
var guardBinary = (path, platform) => guardHookCommand({ kind: "binary", path, runtime: "node" }, platform);
|
|
22
|
-
var guardNodeScript = (script, platform) => guardHookCommand({ kind: "node", script }, platform);
|
|
23
|
-
|
|
24
|
-
export {
|
|
25
|
-
guardBinary,
|
|
26
|
-
guardNodeScript
|
|
27
|
-
};
|