@pushary/agent-hooks 0.18.2 → 0.18.3
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.
|
@@ -324,7 +324,14 @@ const main = async () => {
|
|
|
324
324
|
diag('no input on stdin. Cursor did not pipe the command to this hook (a known Cursor issue on Windows). Handing off to Cursor\'s own prompt; the push approval cannot run without the command.')
|
|
325
325
|
return respond(ask())
|
|
326
326
|
}
|
|
327
|
-
|
|
327
|
+
// Windows: Cursor prepends a BOM/encoding prefix to the hook's stdin, so raw
|
|
328
|
+
// arrives as e.g. "���{...}" and a bare JSON.parse throws,
|
|
329
|
+
// silently dropping us to "ask" with no push (the script works when run
|
|
330
|
+
// manually because there is no BOM). The payload is always a JSON object, so
|
|
331
|
+
// parse from the first "{" — robust to a BOM or whatever prefix bytes Cursor
|
|
332
|
+
// emits. Verified on Windows + Cursor 3.8.11.
|
|
333
|
+
const jsonStart = raw.indexOf('{')
|
|
334
|
+
input = JSON.parse(jsonStart > 0 ? raw.slice(jsonStart) : raw)
|
|
328
335
|
} catch {
|
|
329
336
|
diag('stdin was not valid JSON (often empty or corrupted, a known Cursor Windows stdin issue). Handing off to Cursor\'s own prompt.')
|
|
330
337
|
return respond(ask())
|
|
@@ -720,6 +720,15 @@ var installCursorUserHooks = (gateScript) => {
|
|
|
720
720
|
hooks.beforeShellExecution = [...others, entry];
|
|
721
721
|
writeJson(CURSOR_USER_HOOKS, { ...userHooks, version: userHooks.version ?? 1, hooks });
|
|
722
722
|
};
|
|
723
|
+
var neutralizePluginGate = () => {
|
|
724
|
+
const path = join(CURSOR_PLUGIN_DIR, "hooks", "hooks.json");
|
|
725
|
+
if (!existsSync(path)) return;
|
|
726
|
+
const data = readJson(path);
|
|
727
|
+
if (data.hooks && "beforeShellExecution" in data.hooks) {
|
|
728
|
+
delete data.hooks.beforeShellExecution;
|
|
729
|
+
writeJson(path, { version: data.version ?? 1, hooks: data.hooks });
|
|
730
|
+
}
|
|
731
|
+
};
|
|
723
732
|
var setupCursor = async (apiKey) => {
|
|
724
733
|
console.log(`
|
|
725
734
|
${bold2("Setting up Cursor")}
|
|
@@ -745,13 +754,14 @@ var setupCursor = async (apiKey) => {
|
|
|
745
754
|
});
|
|
746
755
|
await spinner("Registering permission gate (~/.cursor/hooks.json)", async () => {
|
|
747
756
|
installCursorUserHooks(join(CURSOR_PLUGIN_DIR, "scripts", "pushary-gate.mjs"));
|
|
757
|
+
neutralizePluginGate();
|
|
748
758
|
});
|
|
749
759
|
console.log();
|
|
750
760
|
console.log(` ${dim2("What this configured:")}`);
|
|
751
761
|
console.log(` ${dim2("\u2022")} Plugin installed to ~/.cursor/plugins/local/pushary (MCP tools, rule, skill)`);
|
|
752
|
-
console.log(` ${dim2("\u2022")} Permission gate registered in ~/.cursor/hooks.json
|
|
762
|
+
console.log(` ${dim2("\u2022")} Permission gate registered once in ~/.cursor/hooks.json`);
|
|
753
763
|
console.log(` ${dim2("\u2022")} Risky shell commands route to push approval before they run`);
|
|
754
|
-
console.log(` ${dim2("\u2022")}
|
|
764
|
+
console.log(` ${dim2("\u2022")} Fully quit and reopen Cursor to load it (a Reload Window may not be enough)`);
|
|
755
765
|
};
|
|
756
766
|
var saveApiKey = async (apiKey) => {
|
|
757
767
|
await spinner("Saving your API key", async () => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushary/agent-hooks",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.3",
|
|
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",
|