@pushary/agent-hooks 0.61.0 → 0.62.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.
- package/CHANGELOG.md +76 -0
- package/dist/bin/pushary-claude.js +4 -4
- package/dist/bin/pushary-clean.js +82 -35
- package/dist/bin/pushary-codex-hook.js +4 -4
- package/dist/bin/pushary-codex.js +3 -3
- package/dist/bin/pushary-connect.js +7 -6
- package/dist/bin/pushary-daemon.js +37 -5
- package/dist/bin/pushary-doctor.js +114 -34
- package/dist/bin/pushary-gemini-hook.js +4 -4
- package/dist/bin/pushary-hook.js +5 -5
- package/dist/bin/pushary-login.js +5 -4
- package/dist/bin/pushary-logout.js +52 -9
- package/dist/bin/pushary-mode.js +4 -4
- package/dist/bin/pushary-notification-hook.js +2 -2
- package/dist/bin/pushary-permission-denied-hook.js +3 -3
- package/dist/bin/pushary-permission-hook.js +3 -3
- package/dist/bin/pushary-post-hook.js +2 -2
- package/dist/bin/pushary-prompt-hook.js +2 -2
- package/dist/bin/pushary-session-end-hook.js +2 -2
- package/dist/bin/pushary-session-start-hook.js +2 -2
- package/dist/bin/pushary-setup.js +97 -155
- package/dist/bin/pushary-stats.js +2 -2
- package/dist/bin/pushary-status.js +6 -5
- package/dist/bin/pushary-stop-hook.js +2 -2
- package/dist/bin/pushary-stopfailure-hook.js +2 -2
- package/dist/bin/pushary-suggestions.js +2 -2
- package/dist/bin/pushary-upgrade.js +189 -18
- package/dist/bin/pushary-wait.js +4 -4
- package/dist/bin/pushary.js +1 -1
- package/dist/{chunk-GX64YGU3.js → chunk-3O27ZSRE.js} +25 -0
- package/dist/{chunk-HI4AGGE6.js → chunk-5SO3CEGJ.js} +4 -4
- package/dist/chunk-6MTNS63X.js +55 -0
- package/dist/{chunk-B26DNXCA.js → chunk-COC6NPWG.js} +13 -59
- package/dist/chunk-E2U35RLD.js +108 -0
- package/dist/chunk-ER657KRJ.js +168 -0
- package/dist/{chunk-HUJQSP4F.js → chunk-IIZZYUWK.js} +1 -1
- package/dist/chunk-N7XJ4L2W.js +79 -0
- package/dist/{chunk-R6C4USIV.js → chunk-ONVEYEVR.js} +2 -2
- package/dist/{chunk-SML23YOT.js → chunk-SP7OZXCQ.js} +10 -2
- package/dist/chunk-UXXRRXUS.js +93 -0
- package/dist/{chunk-UKNAAVEE.js → chunk-YJ7YZRVV.js} +1 -1
- package/dist/src/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-S4TFBJ5O.js +0 -339
- package/dist/{chunk-VFBYRR2N.js → chunk-HIIBSYFJ.js} +3 -3
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HOOK_BUDGETS
|
|
3
|
+
} from "./chunk-DQAN3JQP.js";
|
|
4
|
+
|
|
5
|
+
// src/codex-config.ts
|
|
6
|
+
import { createHash } from "crypto";
|
|
7
|
+
import { homedir } from "os";
|
|
8
|
+
import { join } from "path";
|
|
9
|
+
var CODEX_HOOK_BINARY = "pushary-codex-hook";
|
|
10
|
+
var codexHome = () => codexHomeFrom(homedir());
|
|
11
|
+
var codexHomeFrom = (home) => process.env.CODEX_HOME?.trim() || join(home, ".codex");
|
|
12
|
+
var codexConfigToml = () => join(codexHome(), "config.toml");
|
|
13
|
+
var codexHooksJson = () => join(codexHome(), "hooks.json");
|
|
14
|
+
var codexAgentsMd = () => join(codexHome(), "AGENTS.md");
|
|
15
|
+
var codexSkillDir = () => join(codexHome(), "skills", "pushary");
|
|
16
|
+
var CODEX_HOOK_EVENTS = [
|
|
17
|
+
{ event: "PermissionRequest", matcher: "Bash|apply_patch", timeout: HOOK_BUDGETS.codex.budgetSeconds, statusMessage: "Waiting for your phone" },
|
|
18
|
+
{ event: "PreToolUse", matcher: "Bash|apply_patch", timeout: HOOK_BUDGETS.codex.budgetSeconds, statusMessage: "Checking Pushary policy" },
|
|
19
|
+
{ event: "PostToolUse", matcher: "Bash|apply_patch", timeout: 10 },
|
|
20
|
+
{ event: "UserPromptSubmit", timeout: 10 },
|
|
21
|
+
{ event: "Stop", timeout: 10 },
|
|
22
|
+
{ event: "SessionStart", matcher: "startup|resume", timeout: 10 }
|
|
23
|
+
];
|
|
24
|
+
var CODEX_EVENT_KEY = {
|
|
25
|
+
PermissionRequest: "permission_request",
|
|
26
|
+
PreToolUse: "pre_tool_use",
|
|
27
|
+
PostToolUse: "post_tool_use",
|
|
28
|
+
UserPromptSubmit: "user_prompt_submit",
|
|
29
|
+
Stop: "stop",
|
|
30
|
+
SessionStart: "session_start"
|
|
31
|
+
};
|
|
32
|
+
var asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
33
|
+
var ensureRecord = (target, key) => {
|
|
34
|
+
const existing = asRecord(target[key]);
|
|
35
|
+
if (existing) return existing;
|
|
36
|
+
const created = {};
|
|
37
|
+
target[key] = created;
|
|
38
|
+
return created;
|
|
39
|
+
};
|
|
40
|
+
var CODEX_MCP_URL = "https://pushary.com/api/mcp/mcp";
|
|
41
|
+
var addCodexMcpServer = (config, apiKey) => {
|
|
42
|
+
const servers = ensureRecord(config, "mcp_servers");
|
|
43
|
+
const pushary = ensureRecord(servers, "pushary");
|
|
44
|
+
pushary.url = CODEX_MCP_URL;
|
|
45
|
+
ensureRecord(pushary, "http_headers").Authorization = `Bearer ${apiKey}`;
|
|
46
|
+
pushary.default_tools_approval_mode = "approve";
|
|
47
|
+
delete pushary.bearer_token_env_var;
|
|
48
|
+
delete pushary.tools;
|
|
49
|
+
};
|
|
50
|
+
var readCodexMcpAuth = (config) => {
|
|
51
|
+
const pushary = asRecord(asRecord(config.mcp_servers)?.pushary);
|
|
52
|
+
if (!pushary) return void 0;
|
|
53
|
+
const authorization = asRecord(pushary.http_headers)?.Authorization;
|
|
54
|
+
if (typeof authorization === "string" && authorization.startsWith("Bearer ")) {
|
|
55
|
+
return { method: "embedded", key: authorization.slice("Bearer ".length).trim() };
|
|
56
|
+
}
|
|
57
|
+
if (typeof pushary.bearer_token_env_var === "string") {
|
|
58
|
+
return { method: "env", envVar: pushary.bearer_token_env_var };
|
|
59
|
+
}
|
|
60
|
+
if (typeof pushary.bearer_token === "string") return { method: "legacy-bearer" };
|
|
61
|
+
return void 0;
|
|
62
|
+
};
|
|
63
|
+
var isPusharyCodexHook = (entry) => {
|
|
64
|
+
const hooks = asRecord(entry)?.hooks;
|
|
65
|
+
if (!Array.isArray(hooks)) return false;
|
|
66
|
+
return hooks.some((hook) => String(asRecord(hook)?.command ?? "").includes(CODEX_HOOK_BINARY));
|
|
67
|
+
};
|
|
68
|
+
var addCodexHooks = (config, command) => {
|
|
69
|
+
const hooks = ensureRecord(config, "hooks");
|
|
70
|
+
for (const definition of CODEX_HOOK_EVENTS) {
|
|
71
|
+
const existing = Array.isArray(hooks[definition.event]) ? hooks[definition.event] : [];
|
|
72
|
+
const entries = existing.filter((entry) => !isPusharyCodexHook(entry));
|
|
73
|
+
entries.push({
|
|
74
|
+
...definition.matcher ? { matcher: definition.matcher } : {},
|
|
75
|
+
hooks: [{
|
|
76
|
+
type: "command",
|
|
77
|
+
command,
|
|
78
|
+
timeout: definition.timeout,
|
|
79
|
+
...definition.statusMessage ? { statusMessage: definition.statusMessage } : {}
|
|
80
|
+
}]
|
|
81
|
+
});
|
|
82
|
+
hooks[definition.event] = entries;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
var removeCodexHooks = (config) => {
|
|
86
|
+
const hooks = asRecord(config.hooks);
|
|
87
|
+
if (!hooks) return false;
|
|
88
|
+
let changed = false;
|
|
89
|
+
for (const definition of CODEX_HOOK_EVENTS) {
|
|
90
|
+
const entries = hooks[definition.event];
|
|
91
|
+
if (!Array.isArray(entries)) continue;
|
|
92
|
+
const filtered = entries.filter((entry) => !isPusharyCodexHook(entry));
|
|
93
|
+
if (filtered.length !== entries.length) {
|
|
94
|
+
if (filtered.length === 0) {
|
|
95
|
+
delete hooks[definition.event];
|
|
96
|
+
} else {
|
|
97
|
+
hooks[definition.event] = filtered;
|
|
98
|
+
}
|
|
99
|
+
changed = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (Object.keys(hooks).length === 0) delete config.hooks;
|
|
103
|
+
return changed;
|
|
104
|
+
};
|
|
105
|
+
var hasCodexHooks = (config) => {
|
|
106
|
+
const hooks = asRecord(config.hooks);
|
|
107
|
+
if (!hooks) return false;
|
|
108
|
+
return CODEX_HOOK_EVENTS.some((definition) => {
|
|
109
|
+
const entries = hooks[definition.event];
|
|
110
|
+
return Array.isArray(entries) && entries.some(isPusharyCodexHook);
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
var missingCodexHookEvents = (config) => {
|
|
114
|
+
const hooks = asRecord(config.hooks);
|
|
115
|
+
return CODEX_HOOK_EVENTS.filter((definition) => {
|
|
116
|
+
const entries = hooks?.[definition.event];
|
|
117
|
+
return !Array.isArray(entries) || !entries.some(isPusharyCodexHook);
|
|
118
|
+
}).map((definition) => definition.event);
|
|
119
|
+
};
|
|
120
|
+
var canonicalJson = (value) => {
|
|
121
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
122
|
+
if (Array.isArray(value)) return "[" + value.map(canonicalJson).join(",") + "]";
|
|
123
|
+
const obj = value;
|
|
124
|
+
return "{" + Object.keys(obj).sort().map((key) => JSON.stringify(key) + ":" + canonicalJson(obj[key])).join(",") + "}";
|
|
125
|
+
};
|
|
126
|
+
var codexHookTrustHash = (definition, command) => {
|
|
127
|
+
const hook = { async: false, command, timeout: definition.timeout, type: "command" };
|
|
128
|
+
if (definition.statusMessage) hook.statusMessage = definition.statusMessage;
|
|
129
|
+
const identity = { event_name: CODEX_EVENT_KEY[definition.event], hooks: [hook] };
|
|
130
|
+
if (definition.matcher) identity.matcher = definition.matcher;
|
|
131
|
+
return "sha256:" + createHash("sha256").update(canonicalJson(identity), "utf8").digest("hex");
|
|
132
|
+
};
|
|
133
|
+
var codexHookStateKey = (hooksJsonPath, event) => `${hooksJsonPath}:${CODEX_EVENT_KEY[event]}:0:0`;
|
|
134
|
+
var untrustedCodexHookEvents = (config, hooksJsonPath, command) => {
|
|
135
|
+
const state = asRecord(asRecord(config.hooks)?.state);
|
|
136
|
+
return CODEX_HOOK_EVENTS.filter((definition) => {
|
|
137
|
+
const entry = asRecord(state?.[codexHookStateKey(hooksJsonPath, definition.event)]);
|
|
138
|
+
const stored = entry?.trusted_hash;
|
|
139
|
+
return stored !== codexHookTrustHash(definition, command);
|
|
140
|
+
}).map((definition) => definition.event);
|
|
141
|
+
};
|
|
142
|
+
var addCodexHookTrust = (config, hooksJsonPath, command) => {
|
|
143
|
+
const hooks = ensureRecord(config, "hooks");
|
|
144
|
+
const state = ensureRecord(hooks, "state");
|
|
145
|
+
for (const definition of CODEX_HOOK_EVENTS) {
|
|
146
|
+
const key = codexHookStateKey(hooksJsonPath, definition.event);
|
|
147
|
+
const existing = asRecord(state[key]) ?? {};
|
|
148
|
+
state[key] = { ...existing, trusted_hash: codexHookTrustHash(definition, command) };
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
export {
|
|
153
|
+
CODEX_HOOK_BINARY,
|
|
154
|
+
codexHome,
|
|
155
|
+
codexHomeFrom,
|
|
156
|
+
codexConfigToml,
|
|
157
|
+
codexHooksJson,
|
|
158
|
+
codexAgentsMd,
|
|
159
|
+
codexSkillDir,
|
|
160
|
+
addCodexMcpServer,
|
|
161
|
+
readCodexMcpAuth,
|
|
162
|
+
addCodexHooks,
|
|
163
|
+
removeCodexHooks,
|
|
164
|
+
hasCodexHooks,
|
|
165
|
+
missingCodexHookEvents,
|
|
166
|
+
untrustedCodexHookEvents,
|
|
167
|
+
addCodexHookTrust
|
|
168
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// src/instruction-file.ts
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, rmSync } from "fs";
|
|
3
|
+
import { dirname } from "path";
|
|
4
|
+
var PUSHARY_BEGIN = "<!-- BEGIN PUSHARY (managed by @pushary/agent-hooks; do not edit this block) -->";
|
|
5
|
+
var PUSHARY_END = "<!-- END PUSHARY -->";
|
|
6
|
+
var instructionBody = (label) => `## Pushary notifications and approvals
|
|
7
|
+
|
|
8
|
+
You have Pushary MCP tools that reach the user on their phone. Use them proactively. Do not wait for the user to ask.
|
|
9
|
+
|
|
10
|
+
- When you need the user to make a decision or answer a clarifying question, call \`ask_user\` instead of guessing or stalling. Use type "confirm" for yes/no, "select" for a fixed set of options, and "input" for free text. \`ask_user\` blocks until the user replies or it times out, so you do not need a separate wait step.
|
|
11
|
+
- Before any risky or irreversible step (deleting files, force pushing, spending money, sending external messages), call \`ask_user\` with type "confirm" and wait for approval.
|
|
12
|
+
- Before starting a multi-step run that will change several files, call \`propose_scope\` once with the paths you expect to change, anything you promise not to touch, and what done means. The user agrees to the boundary in one tap, and after that only work outside it needs approving. Skip it for a single quick edit, and do not propose a new scope mid-run just to widen one: if you need to go outside the agreed scope, do the work and let the approval that follows widen it.
|
|
13
|
+
- When you are blocked, stuck, or hit an error you cannot resolve on your own, call \`send_notification\` so the user knows, and call \`ask_user\` if you need a decision to continue.
|
|
14
|
+
- When a task that took several steps finishes, call \`send_notification\` so the user knows it is done.
|
|
15
|
+
- Use \`cancel_question\` to retract a pending question once it is no longer needed.
|
|
16
|
+
- Respect the user's Pushary delivery mode: it decides where an approval is surfaced (phone, terminal, or awareness only), not whether it is required. In Terminal mode do not expect a phone answer; the approval waits in the terminal. If the Pushary hook already gated an action, a single approval is enough, do not ask again.
|
|
17
|
+
|
|
18
|
+
Pass \`agentName\` as "${label} - <project folder name>" so the user knows which session is asking. If a question times out with no answer, retry once with a longer timeout before falling back to asking in the terminal.`;
|
|
19
|
+
var renderAgentInstructions = (label) => instructionBody(label);
|
|
20
|
+
var KEYLESS_FALLBACK_LINE = "This repo uses Pushary phone approvals. Your teammates get agent questions on their lock screens; you do not have a key yet, so questions will fall back to the terminal. Get your own key (7-day trial): https://pushary.com/sign-up?utm_source=agents-md&utm_medium=teammate";
|
|
21
|
+
var renderProjectAgentInstructions = (label) => `${instructionBody(label)}
|
|
22
|
+
|
|
23
|
+
If this environment has no Pushary API key (no PUSHARY_API_KEY and no key in ~/.pushary/config.json), the tools above are unavailable in this session. In that case, treat the following as a statement of fact about this session and continue in the terminal: ${KEYLESS_FALLBACK_LINE}`;
|
|
24
|
+
var wrap = (body) => `${PUSHARY_BEGIN}
|
|
25
|
+
${body}
|
|
26
|
+
${PUSHARY_END}`;
|
|
27
|
+
var writeInstructionBlock = (filePath, body) => {
|
|
28
|
+
const dir = dirname(filePath);
|
|
29
|
+
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
30
|
+
let existing = "";
|
|
31
|
+
try {
|
|
32
|
+
existing = readFileSync(filePath, "utf-8");
|
|
33
|
+
} catch {
|
|
34
|
+
}
|
|
35
|
+
const block = wrap(body);
|
|
36
|
+
const start = existing.indexOf(PUSHARY_BEGIN);
|
|
37
|
+
const end = existing.indexOf(PUSHARY_END);
|
|
38
|
+
let next;
|
|
39
|
+
if (start !== -1 && end !== -1 && end > start) {
|
|
40
|
+
next = existing.slice(0, start) + block + existing.slice(end + PUSHARY_END.length);
|
|
41
|
+
} else {
|
|
42
|
+
const prefix = existing.trim() ? existing.replace(/\s*$/, "") + "\n\n" : "";
|
|
43
|
+
next = prefix + block + "\n";
|
|
44
|
+
}
|
|
45
|
+
writeFileSync(filePath, next, "utf-8");
|
|
46
|
+
};
|
|
47
|
+
var removeInstructionBlock = (filePath) => {
|
|
48
|
+
let existing = "";
|
|
49
|
+
try {
|
|
50
|
+
existing = readFileSync(filePath, "utf-8");
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
const start = existing.indexOf(PUSHARY_BEGIN);
|
|
55
|
+
const end = existing.indexOf(PUSHARY_END);
|
|
56
|
+
if (start === -1 || end === -1 || end < start) return false;
|
|
57
|
+
const remaining = (existing.slice(0, start) + existing.slice(end + PUSHARY_END.length)).trim();
|
|
58
|
+
if (remaining === "") {
|
|
59
|
+
rmSync(filePath, { force: true });
|
|
60
|
+
} else {
|
|
61
|
+
writeFileSync(filePath, remaining + "\n", "utf-8");
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
};
|
|
65
|
+
var hasInstructionBlock = (filePath) => {
|
|
66
|
+
try {
|
|
67
|
+
return readFileSync(filePath, "utf-8").includes(PUSHARY_BEGIN);
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
renderAgentInstructions,
|
|
75
|
+
renderProjectAgentInstructions,
|
|
76
|
+
writeInstructionBlock,
|
|
77
|
+
removeInstructionBlock,
|
|
78
|
+
hasInstructionBlock
|
|
79
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
describeKeyCheck,
|
|
3
3
|
keyCheckFromResponse
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-YJ7YZRVV.js";
|
|
5
5
|
import {
|
|
6
6
|
createIo
|
|
7
7
|
} from "./chunk-TX7KBKT7.js";
|
|
8
8
|
import {
|
|
9
9
|
EXIT
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-SP7OZXCQ.js";
|
|
11
11
|
|
|
12
12
|
// src/cli/report-key.ts
|
|
13
13
|
var { dim, yellow } = createIo();
|
|
@@ -65,7 +65,10 @@ var COMMANDS = COMMAND_LIST;
|
|
|
65
65
|
var findCommand = (name) => COMMANDS.find((command) => command.name === name);
|
|
66
66
|
var isCommandName = (name) => COMMANDS.some((command) => command.name === name);
|
|
67
67
|
var COMMAND_OPTIONS = {
|
|
68
|
-
clean: [
|
|
68
|
+
clean: [
|
|
69
|
+
["--dry-run", "List everything it would remove and change nothing"],
|
|
70
|
+
["--yes", "Remove everything without asking"]
|
|
71
|
+
],
|
|
69
72
|
mode: [
|
|
70
73
|
["<mode>", "One of: push_only, push_first, terminal_only, notify_only"],
|
|
71
74
|
["status", "Show the current override"],
|
|
@@ -78,10 +81,15 @@ var COMMAND_OPTIONS = {
|
|
|
78
81
|
["clear", "Reset the default window"]
|
|
79
82
|
],
|
|
80
83
|
status: [["--json", "Emit the whole report as one object instead of the screen"]],
|
|
84
|
+
logout: [
|
|
85
|
+
["--revoke", "Also kill the key server-side, so it stops working everywhere"],
|
|
86
|
+
["--json", "Emit the result as one object instead of the screen"]
|
|
87
|
+
],
|
|
81
88
|
doctor: [
|
|
82
89
|
["--json", "Emit every check as one object instead of the screen"],
|
|
83
90
|
["--roundtrip", "Also send a real question and wait for you to answer it on your phone"],
|
|
84
|
-
["--no-push", "Run every check without waking a device"]
|
|
91
|
+
["--no-push", "Run every check without waking a device"],
|
|
92
|
+
["--bundle", "Write a redacted diagnostics file you can attach to a support thread"]
|
|
85
93
|
],
|
|
86
94
|
suggestions: [["accept <id>", "Turn a mined suggestion into an always-allow rule"]],
|
|
87
95
|
claude: [
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codexHomeFrom
|
|
3
|
+
} from "./chunk-ER657KRJ.js";
|
|
4
|
+
|
|
5
|
+
// src/setup/detect.ts
|
|
6
|
+
import { execSync } from "child_process";
|
|
7
|
+
import { existsSync } from "fs";
|
|
8
|
+
import { homedir } from "os";
|
|
9
|
+
import { join } from "path";
|
|
10
|
+
var whichCommand = () => process.platform === "win32" ? "where" : "which";
|
|
11
|
+
var binaryOnPath = (binary) => {
|
|
12
|
+
try {
|
|
13
|
+
execSync(`${whichCommand()} ${binary}`, { stdio: "ignore", timeout: 5e3 });
|
|
14
|
+
return true;
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var defaultDeps = { onPath: binaryOnPath, exists: existsSync };
|
|
20
|
+
var detectAgent = (probe, deps = defaultDeps) => {
|
|
21
|
+
const checked = [];
|
|
22
|
+
if (probe.binary) {
|
|
23
|
+
checked.push(`${whichCommand()} ${probe.binary}`);
|
|
24
|
+
if (deps.onPath(probe.binary)) {
|
|
25
|
+
return { kind: "installed", evidence: `${probe.binary} on PATH`, strong: true };
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
for (const path of probe.paths) {
|
|
29
|
+
checked.push(path);
|
|
30
|
+
if (deps.exists(path)) return { kind: "installed", evidence: path, strong: true };
|
|
31
|
+
}
|
|
32
|
+
for (const marker of probe.configMarkers) {
|
|
33
|
+
checked.push(marker);
|
|
34
|
+
if (deps.exists(marker)) return { kind: "installed", evidence: marker, strong: false };
|
|
35
|
+
}
|
|
36
|
+
if (probe.binary === null && probe.paths.length === 0 && probe.configMarkers.length === 0) {
|
|
37
|
+
return { kind: "unknown" };
|
|
38
|
+
}
|
|
39
|
+
return { kind: "not-found", checked };
|
|
40
|
+
};
|
|
41
|
+
var agentProbes = (home = homedir()) => ({
|
|
42
|
+
claude_code: {
|
|
43
|
+
binary: "claude",
|
|
44
|
+
// The native installer puts it here, outside a default non-login PATH.
|
|
45
|
+
paths: [join(home, ".local", "bin", "claude")],
|
|
46
|
+
configMarkers: [join(home, ".claude")]
|
|
47
|
+
},
|
|
48
|
+
codex: {
|
|
49
|
+
binary: "codex",
|
|
50
|
+
paths: [],
|
|
51
|
+
configMarkers: [codexHomeFrom(home)]
|
|
52
|
+
},
|
|
53
|
+
gemini_cli: {
|
|
54
|
+
binary: "gemini",
|
|
55
|
+
paths: [],
|
|
56
|
+
configMarkers: [join(home, ".gemini")]
|
|
57
|
+
},
|
|
58
|
+
hermes: {
|
|
59
|
+
binary: "hermes",
|
|
60
|
+
paths: [],
|
|
61
|
+
configMarkers: [join(home, ".hermes")]
|
|
62
|
+
},
|
|
63
|
+
cursor: {
|
|
64
|
+
// GUI editor. `cursor` on PATH only exists if the user ran "Install 'cursor'
|
|
65
|
+
// command in PATH" from the command palette, which most never do.
|
|
66
|
+
binary: "cursor",
|
|
67
|
+
paths: process.platform === "darwin" ? ["/Applications/Cursor.app"] : process.platform === "win32" ? [join(process.env.LOCALAPPDATA ?? join(home, "AppData", "Local"), "Programs", "cursor")] : ["/usr/share/cursor", join(home, ".local", "share", "cursor")],
|
|
68
|
+
configMarkers: [join(home, ".cursor")]
|
|
69
|
+
},
|
|
70
|
+
// "Other" is a set of printed instructions for any MCP or HTTP client. There is
|
|
71
|
+
// nothing to detect, and it must never be auto-selected.
|
|
72
|
+
custom: { binary: null, paths: [], configMarkers: [] }
|
|
73
|
+
});
|
|
74
|
+
var detectAllAgents = (deps = defaultDeps, home) => {
|
|
75
|
+
const probes = agentProbes(home);
|
|
76
|
+
return Object.keys(probes).map((agent) => ({
|
|
77
|
+
agent,
|
|
78
|
+
result: detectAgent(probes[agent], deps)
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
var isDetected = (result) => result.kind === "installed";
|
|
82
|
+
var shortenHome = (path, home = homedir()) => home && path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
83
|
+
var describeDetection = (result, home) => {
|
|
84
|
+
if (result.kind !== "installed") return null;
|
|
85
|
+
const evidence = shortenHome(result.evidence, home);
|
|
86
|
+
return result.strong ? evidence : `${evidence}, config only`;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
detectAllAgents,
|
|
91
|
+
isDetected,
|
|
92
|
+
describeDetection
|
|
93
|
+
};
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
handlePreToolUse
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-5SO3CEGJ.js";
|
|
4
4
|
import "../chunk-CAJZAFVS.js";
|
|
5
5
|
import "../chunk-YHG74UFF.js";
|
|
6
6
|
import {
|
|
@@ -15,11 +15,11 @@ import {
|
|
|
15
15
|
reportEvent,
|
|
16
16
|
resolvePolicy,
|
|
17
17
|
waitForAnswer
|
|
18
|
-
} from "../chunk-
|
|
19
|
-
import "../chunk-RN3NOEJF.js";
|
|
18
|
+
} from "../chunk-HIIBSYFJ.js";
|
|
20
19
|
import "../chunk-WLGEY4UX.js";
|
|
21
20
|
import "../chunk-HNTKTK5B.js";
|
|
22
21
|
import "../chunk-DQAN3JQP.js";
|
|
22
|
+
import "../chunk-RN3NOEJF.js";
|
|
23
23
|
import {
|
|
24
24
|
getApiKey,
|
|
25
25
|
getBaseUrl
|