@pushary/agent-hooks 0.5.0 → 0.5.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/dist/bin/pushary-clean.js +2 -2
- package/dist/bin/pushary-doctor.js +17 -0
- package/dist/bin/pushary-setup.js +121 -15
- package/package.json +1 -1
|
@@ -98,11 +98,11 @@ var main = async () => {
|
|
|
98
98
|
const cleaned = [];
|
|
99
99
|
let skipping = false;
|
|
100
100
|
for (const line of lines) {
|
|
101
|
-
if (line.trim()
|
|
101
|
+
if (/^\[mcp_servers\.pushary(?:\.|]$)/.test(line.trim())) {
|
|
102
102
|
skipping = true;
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
|
-
if (skipping &&
|
|
105
|
+
if (skipping && line.startsWith("[") && !/^\[mcp_servers\.pushary/.test(line.trim())) {
|
|
106
106
|
skipping = false;
|
|
107
107
|
}
|
|
108
108
|
if (skipping) continue;
|
|
@@ -68,6 +68,23 @@ var main = async () => {
|
|
|
68
68
|
} else {
|
|
69
69
|
check(false, "Claude Code: settings.json", "not found");
|
|
70
70
|
}
|
|
71
|
+
const codexConfigPath = join(homedir(), ".codex", "config.toml");
|
|
72
|
+
if (existsSync(codexConfigPath)) {
|
|
73
|
+
const codexConfig = readFileSync(codexConfigPath, "utf-8");
|
|
74
|
+
const hasPusharyMcp = codexConfig.includes("[mcp_servers.pushary]");
|
|
75
|
+
check(hasPusharyMcp, "Codex: MCP server configured");
|
|
76
|
+
if (hasPusharyMcp) {
|
|
77
|
+
const hasAutoApprove = codexConfig.includes('default_tools_approval_mode = "approve"');
|
|
78
|
+
check(hasAutoApprove, "Codex: tools auto-allowed", hasAutoApprove ? 'default_tools_approval_mode = "approve"' : "missing \u2014 MCP calls will prompt for approval");
|
|
79
|
+
const hasPerToolOverrides = /\[mcp_servers\.pushary\.tools\./.test(codexConfig);
|
|
80
|
+
if (hasPerToolOverrides) {
|
|
81
|
+
console.log(` ${warn} Codex: per-tool approval overrides detected ${dim("(redundant with default_tools_approval_mode)")}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
check(codexConfig.includes("pushary-codex"), "Codex: notify handler configured");
|
|
85
|
+
const codexSkillPath = join(homedir(), ".codex", "skills", "pushary", "SKILL.md");
|
|
86
|
+
check(existsSync(codexSkillPath), "Codex: skill installed");
|
|
87
|
+
}
|
|
71
88
|
check(existsSync(SKILL_PATH), "Skill installed", existsSync(SKILL_PATH) ? SKILL_PATH : "not found");
|
|
72
89
|
let globalVersion = "";
|
|
73
90
|
try {
|
|
@@ -146,29 +146,86 @@ var setupClaudeCode = async (apiKey) => {
|
|
|
146
146
|
console.log(` ${dim("\u2022")} Hooks: route permission approvals through push notifications`);
|
|
147
147
|
console.log(` ${dim("\u2022")} Auto-allowed tools: no permission prompts for Pushary MCP calls`);
|
|
148
148
|
};
|
|
149
|
+
var findPython310Plus = () => {
|
|
150
|
+
const candidates = ["python3.13", "python3.12", "python3.11", "python3.10", "python3", "python"];
|
|
151
|
+
for (const py of candidates) {
|
|
152
|
+
try {
|
|
153
|
+
const version = execSync(`${py} --version 2>&1`, { encoding: "utf-8", stdio: "pipe" }).trim();
|
|
154
|
+
const match = version.match(/Python (\d+)\.(\d+)/);
|
|
155
|
+
if (match && (Number(match[1]) > 3 || Number(match[1]) === 3 && Number(match[2]) >= 10)) {
|
|
156
|
+
return py;
|
|
157
|
+
}
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return null;
|
|
162
|
+
};
|
|
163
|
+
var installPythonPlugin = (pythonBin) => {
|
|
164
|
+
execSync(`${pythonBin} -m pip install --upgrade hermes-plugin-pushary`, { stdio: "pipe" });
|
|
165
|
+
};
|
|
149
166
|
var setupHermes = async (_apiKey) => {
|
|
150
167
|
console.log(`
|
|
151
168
|
${bold("Setting up Hermes Agent")}
|
|
152
169
|
`);
|
|
153
|
-
|
|
170
|
+
const whichCmd = process.platform === "win32" ? "where" : "which";
|
|
171
|
+
const hasHermes = (() => {
|
|
172
|
+
try {
|
|
173
|
+
execSync(`${whichCmd} hermes`, { stdio: "ignore" });
|
|
174
|
+
return true;
|
|
175
|
+
} catch {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
})();
|
|
179
|
+
if (!hasHermes) {
|
|
180
|
+
console.log(` ${yellow("!")} Hermes CLI not found. Skipping.`);
|
|
181
|
+
console.log(` ${dim("Install Hermes and re-run setup to configure.")}`);
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
154
184
|
await spinner("Installing hermes-plugin-pushary", async () => {
|
|
185
|
+
try {
|
|
186
|
+
execSync("uv pip install hermes-plugin-pushary", { stdio: "pipe" });
|
|
187
|
+
return;
|
|
188
|
+
} catch {
|
|
189
|
+
}
|
|
190
|
+
let python = findPython310Plus();
|
|
191
|
+
if (!python) {
|
|
192
|
+
if (process.platform === "darwin") {
|
|
193
|
+
try {
|
|
194
|
+
execSync("which brew", { stdio: "ignore" });
|
|
195
|
+
execSync("brew install python@3.12", { stdio: "pipe" });
|
|
196
|
+
python = findPython310Plus();
|
|
197
|
+
} catch {
|
|
198
|
+
}
|
|
199
|
+
} else if (process.platform === "linux") {
|
|
200
|
+
for (const [check2, install] of [
|
|
201
|
+
["which apt-get", "sudo apt-get update -qq && sudo apt-get install -y -qq python3 python3-pip"],
|
|
202
|
+
["which dnf", "sudo dnf install -y -q python3 python3-pip"],
|
|
203
|
+
["which yum", "sudo yum install -y -q python3 python3-pip"],
|
|
204
|
+
["which pacman", "sudo pacman -S --noconfirm python python-pip"]
|
|
205
|
+
]) {
|
|
206
|
+
try {
|
|
207
|
+
execSync(check2, { stdio: "ignore" });
|
|
208
|
+
execSync(install, { stdio: "pipe" });
|
|
209
|
+
python = findPython310Plus();
|
|
210
|
+
if (python) break;
|
|
211
|
+
} catch {
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (python) {
|
|
217
|
+
installPythonPlugin(python);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
155
220
|
for (const pip of ["pip3", "pip"]) {
|
|
156
221
|
try {
|
|
157
222
|
execSync(`${pip} install hermes-plugin-pushary`, { stdio: "pipe" });
|
|
158
|
-
pipInstalled = true;
|
|
159
223
|
return;
|
|
160
|
-
} catch
|
|
161
|
-
const msg = err instanceof Error ? err.stderr?.toString() ?? "" : "";
|
|
162
|
-
if (msg.includes("No matching distribution")) {
|
|
163
|
-
throw new Error("requires Python 3.10+ (your pip uses an older version)");
|
|
164
|
-
}
|
|
224
|
+
} catch {
|
|
165
225
|
}
|
|
166
226
|
}
|
|
167
|
-
throw new Error("
|
|
227
|
+
throw new Error("Python 3.10+ not found and could not be installed");
|
|
168
228
|
});
|
|
169
|
-
if (!pipInstalled) {
|
|
170
|
-
console.log(` ${dim(" Install Python 3.10+ and re-run setup to fix.")}`);
|
|
171
|
-
}
|
|
172
229
|
await spinner("Enabling plugin", async () => {
|
|
173
230
|
execSync("hermes plugins enable pushary", { stdio: "ignore" });
|
|
174
231
|
});
|
|
@@ -181,9 +238,10 @@ var setupCodex = async (_apiKey) => {
|
|
|
181
238
|
console.log(`
|
|
182
239
|
${bold("Setting up Codex")}
|
|
183
240
|
`);
|
|
241
|
+
const whichCmd = process.platform === "win32" ? "where" : "which";
|
|
184
242
|
const hasCodex = (() => {
|
|
185
243
|
try {
|
|
186
|
-
execSync(
|
|
244
|
+
execSync(`${whichCmd} codex`, { stdio: "ignore" });
|
|
187
245
|
return true;
|
|
188
246
|
} catch {
|
|
189
247
|
return false;
|
|
@@ -195,6 +253,7 @@ var setupCodex = async (_apiKey) => {
|
|
|
195
253
|
return;
|
|
196
254
|
}
|
|
197
255
|
await installGlobally();
|
|
256
|
+
const codexConfig = join(homedir(), ".codex", "config.toml");
|
|
198
257
|
await spinner("Adding Pushary MCP server to Codex", async () => {
|
|
199
258
|
try {
|
|
200
259
|
execSync(
|
|
@@ -204,7 +263,42 @@ var setupCodex = async (_apiKey) => {
|
|
|
204
263
|
} catch {
|
|
205
264
|
}
|
|
206
265
|
});
|
|
207
|
-
|
|
266
|
+
await spinner("Auto-allowing all Pushary tools", async () => {
|
|
267
|
+
let config = "";
|
|
268
|
+
try {
|
|
269
|
+
config = readFileSync(codexConfig, "utf-8");
|
|
270
|
+
} catch {
|
|
271
|
+
}
|
|
272
|
+
const lines = config.split("\n");
|
|
273
|
+
const cleaned = [];
|
|
274
|
+
let skippingToolSection = false;
|
|
275
|
+
for (const line of lines) {
|
|
276
|
+
if (/^\[mcp_servers\.pushary\.tools\./.test(line.trim())) {
|
|
277
|
+
skippingToolSection = true;
|
|
278
|
+
continue;
|
|
279
|
+
}
|
|
280
|
+
if (skippingToolSection) {
|
|
281
|
+
if (line.startsWith("[") || line.trim() === "") {
|
|
282
|
+
skippingToolSection = false;
|
|
283
|
+
if (line.startsWith("[")) {
|
|
284
|
+
cleaned.push(line);
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
cleaned.push(line);
|
|
292
|
+
}
|
|
293
|
+
config = cleaned.join("\n");
|
|
294
|
+
if (!config.includes("default_tools_approval_mode")) {
|
|
295
|
+
config = config.replace(
|
|
296
|
+
/(\[mcp_servers\.pushary\]\n)/,
|
|
297
|
+
'$1default_tools_approval_mode = "approve"\n'
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
writeFileSync(codexConfig, config, "utf-8");
|
|
301
|
+
});
|
|
208
302
|
await spinner("Adding notify handler for Codex events", async () => {
|
|
209
303
|
const globalPrefix = execSync("npm prefix -g", { encoding: "utf-8" }).trim();
|
|
210
304
|
const pusharyCodexPath = join(globalPrefix, "bin", "pushary-codex");
|
|
@@ -225,6 +319,7 @@ notify = ["${pusharyCodexPath}"]
|
|
|
225
319
|
console.log();
|
|
226
320
|
console.log(` ${dim("What this configured:")}`);
|
|
227
321
|
console.log(` ${dim("\u2022")} MCP server: Codex can send notifications and ask questions`);
|
|
322
|
+
console.log(` ${dim("\u2022")} Auto-allowed tools: no permission prompts for Pushary MCP calls`);
|
|
228
323
|
console.log(` ${dim("\u2022")} Notify handler: captures turn completions and approval requests`);
|
|
229
324
|
};
|
|
230
325
|
var setupCursor = async (apiKey) => {
|
|
@@ -324,7 +419,7 @@ var main = async () => {
|
|
|
324
419
|
message: "Which agents do you use? " + dim("(space = toggle, enter = confirm)"),
|
|
325
420
|
choices: [
|
|
326
421
|
{ name: `Claude Code ${dim("MCP + hooks + auto-allowed tools")}`, value: "claude_code" },
|
|
327
|
-
{ name: `Codex ${dim("MCP
|
|
422
|
+
{ name: `Codex ${dim("MCP + notify handler + auto-allowed tools")}`, value: "codex" },
|
|
328
423
|
{ name: `Hermes ${dim("native plugin + auto-error notifications")}`, value: "hermes" },
|
|
329
424
|
{ name: `Cursor ${dim("MCP server")}`, value: "cursor" }
|
|
330
425
|
]
|
|
@@ -334,8 +429,19 @@ var main = async () => {
|
|
|
334
429
|
console.log(`
|
|
335
430
|
${dim("No agents selected. API key saved.")}`);
|
|
336
431
|
} else {
|
|
432
|
+
const failed = [];
|
|
337
433
|
for (const agent of agents) {
|
|
338
|
-
|
|
434
|
+
try {
|
|
435
|
+
await AGENT_SETUP[agent](trimmedKey);
|
|
436
|
+
} catch (err) {
|
|
437
|
+
failed.push(agent.replace("_", " "));
|
|
438
|
+
console.log(` ${yellow("!")} ${agent.replace("_", " ")} setup failed: ${formatError(err)}`);
|
|
439
|
+
console.log(` ${dim("Other agents will continue. Re-run setup to retry.")}`);
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
if (failed.length > 0) {
|
|
443
|
+
console.log();
|
|
444
|
+
console.log(` ${yellow("!")} Failed: ${failed.join(", ")} ${dim("(others completed successfully)")}`);
|
|
339
445
|
}
|
|
340
446
|
}
|
|
341
447
|
const sendTest = await confirm({ message: "Send a test notification?", default: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushary/agent-hooks",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
|
|
5
5
|
"author": "Pushary <business@pushary.com>",
|
|
6
6
|
"homepage": "https://pushary.com",
|