@pushary/agent-hooks 1.7.1 → 1.7.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/bin/pushary-bell-hook.js +23 -23
  3. package/dist/bin/pushary-bell.js +10 -10
  4. package/dist/bin/pushary-claude.js +46 -35
  5. package/dist/bin/pushary-clean.js +107 -60
  6. package/dist/bin/pushary-codex-bridge.js +18 -17
  7. package/dist/bin/pushary-codex-hook.js +53 -39
  8. package/dist/bin/pushary-codex.js +14 -12
  9. package/dist/bin/pushary-connect.js +16 -16
  10. package/dist/bin/pushary-cowork.js +5 -5
  11. package/dist/bin/pushary-daemon.js +27 -27
  12. package/dist/bin/pushary-disconnect.js +19 -17
  13. package/dist/bin/pushary-doctor.js +63 -35
  14. package/dist/bin/pushary-elicitation-hook.js +35 -26
  15. package/dist/bin/pushary-gemini-bridge.js +12 -12
  16. package/dist/bin/pushary-gemini-hook.js +47 -32
  17. package/dist/bin/pushary-hook.js +34 -32
  18. package/dist/bin/pushary-login.js +16 -16
  19. package/dist/bin/pushary-logout.js +8 -8
  20. package/dist/bin/pushary-mcp.js +9 -8
  21. package/dist/bin/pushary-mode.js +10 -10
  22. package/dist/bin/pushary-notification-hook.js +29 -27
  23. package/dist/bin/pushary-opencode-hook.js +46 -32
  24. package/dist/bin/pushary-permission-denied-hook.js +34 -32
  25. package/dist/bin/pushary-permission-hook.js +33 -31
  26. package/dist/bin/pushary-post-hook.js +29 -27
  27. package/dist/bin/pushary-prompt-hook.js +29 -27
  28. package/dist/bin/pushary-session-end-hook.js +29 -27
  29. package/dist/bin/pushary-session-start-hook.js +33 -31
  30. package/dist/bin/pushary-setup.js +69 -56
  31. package/dist/bin/pushary-stats.js +5 -5
  32. package/dist/bin/pushary-status.js +19 -19
  33. package/dist/bin/pushary-stop-hook.js +29 -27
  34. package/dist/bin/pushary-stopfailure-hook.js +29 -27
  35. package/dist/bin/pushary-suggestions.js +5 -5
  36. package/dist/bin/pushary-transcript-register.js +19 -19
  37. package/dist/bin/pushary-transcripts.js +7 -7
  38. package/dist/bin/pushary-upgrade.js +20 -20
  39. package/dist/bin/pushary-wait.js +10 -10
  40. package/dist/bin/pushary.js +6 -6
  41. package/dist/{chunk-WM3U2RUK.js → chunk-2B4XCMH6.js} +75 -232
  42. package/dist/{chunk-ZIIYTQHC.js → chunk-2XOHXZRC.js} +12 -4
  43. package/dist/{chunk-3QE3BHBW.js → chunk-3NSRL5E7.js} +2 -2
  44. package/dist/{chunk-7GI6QC3M.js → chunk-3RO2UWJQ.js} +2 -2
  45. package/dist/{chunk-AAGLDXH4.js → chunk-4S7CCOXB.js} +5 -5
  46. package/dist/{chunk-6SJQ442W.js → chunk-5GIBNUBD.js} +2 -2
  47. package/dist/chunk-5OP5MQI7.js +45 -0
  48. package/dist/{chunk-EIZW73P5.js → chunk-65RN6ZCO.js} +1 -1
  49. package/dist/{chunk-6PV2JQ64.js → chunk-6NHXKTQU.js} +2 -2
  50. package/dist/{chunk-KSNAAMU5.js → chunk-6QZK4O36.js} +4 -4
  51. package/dist/{chunk-WZWXBTRF.js → chunk-A6WQF7FQ.js} +3 -3
  52. package/dist/{chunk-62TEPRWQ.js → chunk-AWZNDM3B.js} +1 -1
  53. package/dist/{chunk-NQFGVAT6.js → chunk-D4OGEWLH.js} +19 -2
  54. package/dist/{chunk-SVEMF2VO.js → chunk-E3PLF7YB.js} +4 -4
  55. package/dist/{chunk-MCNS4725.js → chunk-F6BMJOSW.js} +1 -1
  56. package/dist/{chunk-P5CBNSYL.js → chunk-HOIGXMI7.js} +1 -1
  57. package/dist/{chunk-XMN37YJH.js → chunk-I7B2DNVU.js} +1 -1
  58. package/dist/{chunk-ZEMSCGDD.js → chunk-INR3RVQ3.js} +8 -3
  59. package/dist/{chunk-3QORH5EJ.js → chunk-IZVAVXHQ.js} +6 -4
  60. package/dist/{chunk-MWVCDP64.js → chunk-JMSB6CJT.js} +1 -1
  61. package/dist/{chunk-WSC53O7I.js → chunk-KAJT6HPI.js} +3 -3
  62. package/dist/{chunk-XPMOCJHN.js → chunk-KLXYMPTM.js} +1 -1
  63. package/dist/{chunk-XDASEYRS.js → chunk-L6IF4JOF.js} +3 -3
  64. package/dist/{chunk-UPKP67TA.js → chunk-LI3C2IQY.js} +2 -2
  65. package/dist/{chunk-H6JV44TE.js → chunk-M2JGLFFS.js} +1 -1
  66. package/dist/chunk-MY3UZO5U.js +99 -0
  67. package/dist/chunk-N6IOSZOE.js +185 -0
  68. package/dist/{chunk-454KMJHF.js → chunk-NYBZJ44G.js} +34 -1
  69. package/dist/{chunk-QPR33SHS.js → chunk-OJRB5QKN.js} +6 -6
  70. package/dist/{chunk-3T35OE7C.js → chunk-OXEF6JHD.js} +4 -4
  71. package/dist/{chunk-SNWNA3MQ.js → chunk-PWNQGITG.js} +1 -1
  72. package/dist/{chunk-XPTCPU6V.js → chunk-Q7CDBJXU.js} +1 -1
  73. package/dist/{chunk-OTZHT34O.js → chunk-QSZ37ROP.js} +1 -1
  74. package/dist/{chunk-O5JD7UI5.js → chunk-R7ZETVNR.js} +1 -1
  75. package/dist/{chunk-4C4NRDIC.js → chunk-RLRDPZG4.js} +1 -1
  76. package/dist/{chunk-IGBDOZUO.js → chunk-SEIZQZEE.js} +1 -1
  77. package/dist/{chunk-OAL44FM2.js → chunk-SJN64NJX.js} +1 -1
  78. package/dist/{chunk-NID4UZDN.js → chunk-SKEW3TQX.js} +1 -1
  79. package/dist/{chunk-NAAZCNKI.js → chunk-SKMWPXGV.js} +351 -37
  80. package/dist/{chunk-KBLIVEFJ.js → chunk-T3PRPFDY.js} +5 -5
  81. package/dist/{chunk-2FU43B5Q.js → chunk-TVJYGZXB.js} +2 -2
  82. package/dist/{chunk-Y6GKOZBT.js → chunk-U3MS6D5X.js} +1 -1
  83. package/dist/{chunk-O5PRIYFZ.js → chunk-U4TMAANR.js} +3 -0
  84. package/dist/{chunk-JTQDP4ZL.js → chunk-UFNBKYWT.js} +3 -3
  85. package/dist/{chunk-42XR73I2.js → chunk-UUTWHVSV.js} +35 -35
  86. package/dist/{chunk-43SSQCWO.js → chunk-VQDJ6KB3.js} +3 -3
  87. package/dist/{chunk-YZKS3ME3.js → chunk-VSGKQ3HI.js} +2 -2
  88. package/dist/{chunk-XFNVG3OV.js → chunk-WWTLAZQA.js} +24 -7
  89. package/dist/{chunk-VCMFKZON.js → chunk-WXIVUIXA.js} +2 -2
  90. package/dist/{chunk-AHWJHLG5.js → chunk-YLCSKVQQ.js} +7 -5
  91. package/dist/{chunk-Q7QRR6YL.js → chunk-YNJ2H2FD.js} +2 -2
  92. package/dist/{chunk-BYVB3RX3.js → chunk-YU4222G2.js} +2 -2
  93. package/dist/{chunk-YQN7S57T.js → chunk-YU54LNC6.js} +6 -6
  94. package/dist/{chunk-7GYGVQBU.js → chunk-ZMWX5SDA.js} +8 -8
  95. package/dist/{chunk-55RO62FV.js → chunk-ZUKZJQGR.js} +1 -1
  96. package/dist/{reapply-66GQIBXN.js → reapply-D6RSDYCK.js} +9 -9
  97. package/dist/src/index.d.ts +1 -0
  98. package/dist/src/index.js +22 -20
  99. package/package.json +2 -1
  100. package/dist/chunk-JMBG47WV.js +0 -336
  101. package/dist/chunk-YHG74UFF.js +0 -12
@@ -1,336 +0,0 @@
1
- import {
2
- pusharyHookExecutable
3
- } from "./chunk-XDASEYRS.js";
4
- import {
5
- isProtectedByScope,
6
- registerHookEntry,
7
- resolvePathBinary
8
- } from "./chunk-454KMJHF.js";
9
-
10
- // src/hermes-config.ts
11
- import { execFileSync } from "child_process";
12
- import { existsSync, readFileSync, rmSync, writeFileSync } from "fs";
13
- import { homedir, tmpdir } from "os";
14
- import { join } from "path";
15
- var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
16
- var isSnapshot = (value) => isRecord(value) && typeof value.present === "boolean" && Object.hasOwn(value, "value");
17
- var isHermesConfigReceipt = (value) => {
18
- if (!isRecord(value)) return false;
19
- return ["security", "approval", "transport", "fallback", "plugins", "enabled", "agent", "disabled"].every((key) => isSnapshot(value[key])) && typeof value.pushary_enabled === "boolean" && typeof value.clarify_disabled === "boolean";
20
- };
21
- var HERMES_PIP_PACKAGE = "hermes-plugin-pushary";
22
- var HERMES_CONFIG_SCRIPT = String.raw`
23
- import json, os, sys
24
- from hermes_cli.config import load_config, save_config
25
-
26
- mode, receipt_path = sys.argv[1], sys.argv[2]
27
- c = load_config()
28
-
29
- def snap(obj, key):
30
- return {"present": key in obj, "value": obj.get(key)}
31
-
32
- restore_conflicts = []
33
-
34
- def restore(obj, key, before, ours):
35
- if before.get("present") and before.get("value") == ours:
36
- return
37
- if before.get("present"):
38
- if key in obj and obj.get(key) == before.get("value"):
39
- return
40
- elif key not in obj:
41
- return
42
- if obj.get(key) != ours:
43
- restore_conflicts.append(key)
44
- return
45
- if before.get("present"):
46
- obj[key] = before.get("value")
47
- else:
48
- obj.pop(key, None)
49
-
50
- def restore_container(obj, key, before, current, changed):
51
- raw = obj.get(key)
52
- if isinstance(before.get("value"), dict):
53
- if not isinstance(raw, dict):
54
- if changed:
55
- restore_conflicts.append(key)
56
- return
57
- if current or before.get("present"):
58
- obj[key] = current
59
- else:
60
- obj.pop(key, None)
61
- elif isinstance(raw, dict) and current:
62
- restore_conflicts.append(key)
63
- else:
64
- restore(obj, key, before, {})
65
-
66
- def restore_list_member(obj, key, before, ours, ours_before):
67
- raw = obj.get(key)
68
- if isinstance(before.get("value"), list):
69
- if ours_before:
70
- return
71
- if not isinstance(raw, list):
72
- restore_conflicts.append(key)
73
- return
74
- remaining = [item for item in raw if item != ours]
75
- if remaining or before.get("present"):
76
- obj[key] = remaining
77
- else:
78
- obj.pop(key, None)
79
- return
80
- if before.get("present") and raw == before.get("value"):
81
- return
82
- if not before.get("present") and key not in obj:
83
- return
84
- if not isinstance(raw, list):
85
- restore_conflicts.append(key)
86
- return
87
- remaining = [item for item in raw if item != ours]
88
- if remaining:
89
- restore_conflicts.append(key)
90
- else:
91
- restore(obj, key, before, raw)
92
-
93
- def valid_snapshot(value):
94
- return isinstance(value, dict) and isinstance(value.get("present"), bool) and "value" in value
95
-
96
- def valid_receipt(value):
97
- snapshots = ["security", "approval", "transport", "fallback", "plugins", "enabled", "agent", "disabled"]
98
- return (isinstance(value, dict)
99
- and all(valid_snapshot(value.get(key)) for key in snapshots)
100
- and isinstance(value.get("pushary_enabled"), bool)
101
- and isinstance(value.get("clarify_disabled"), bool))
102
-
103
- if mode == "setup":
104
- security_before = snap(c, "security")
105
- s = c.get("security") if isinstance(c.get("security"), dict) else {}
106
- approval_before = snap(s, "approval")
107
- ap = s.get("approval") if isinstance(s.get("approval"), dict) else {}
108
- plugins_before = snap(c, "plugins")
109
- p = c.get("plugins") if isinstance(c.get("plugins"), dict) else {}
110
- agent_before = snap(c, "agent")
111
- a = c.get("agent") if isinstance(c.get("agent"), dict) else {}
112
- enabled = p.get("enabled") if isinstance(p.get("enabled"), list) else []
113
- disabled = a.get("disabled_toolsets") if isinstance(a.get("disabled_toolsets"), list) else []
114
- receipt = {
115
- "security": security_before,
116
- "approval": approval_before,
117
- "transport": snap(ap, "transport"),
118
- "fallback": snap(ap, "transport_fallback"),
119
- "plugins": plugins_before,
120
- "enabled": snap(p, "enabled"),
121
- "pushary_enabled": "pushary" in enabled,
122
- "agent": agent_before,
123
- "disabled": snap(a, "disabled_toolsets"),
124
- "clarify_disabled": "clarify" in disabled,
125
- }
126
- if os.path.exists(receipt_path):
127
- with open(receipt_path, encoding="utf-8") as handle:
128
- existing_receipt = json.load(handle)
129
- if not valid_receipt(existing_receipt):
130
- raise ValueError("invalid Pushary Hermes setup receipt")
131
- else:
132
- os.makedirs(os.path.dirname(receipt_path), exist_ok=True)
133
- temp = receipt_path + ".tmp"
134
- with open(temp, "x", encoding="utf-8") as handle:
135
- json.dump(receipt, handle)
136
- os.chmod(temp, 0o600)
137
- os.replace(temp, receipt_path)
138
- ap["transport"] = "pushary"
139
- ap["transport_fallback"] = "builtin"
140
- s["approval"] = ap
141
- c["security"] = s
142
- p["enabled"] = enabled if "pushary" in enabled else enabled + ["pushary"]
143
- c["plugins"] = p
144
- a["disabled_toolsets"] = disabled if "clarify" in disabled else disabled + ["clarify"]
145
- c["agent"] = a
146
- else:
147
- receipt_exists = os.path.exists(receipt_path)
148
- try:
149
- with open(receipt_path, encoding="utf-8") as handle:
150
- receipt = json.load(handle)
151
- except (OSError, ValueError):
152
- if receipt_exists:
153
- raise
154
- receipt = None
155
- s = c.get("security") if isinstance(c.get("security"), dict) else {}
156
- ap = s.get("approval") if isinstance(s.get("approval"), dict) else {}
157
- if receipt:
158
- if not valid_receipt(receipt):
159
- raise ValueError("invalid Pushary Hermes setup receipt")
160
- approval_changed = (not receipt["transport"].get("present")
161
- or receipt["transport"].get("value") != "pushary"
162
- or not receipt["fallback"].get("present")
163
- or receipt["fallback"].get("value") != "builtin")
164
- plugins_changed = not (isinstance(receipt["enabled"].get("value"), list)
165
- and receipt["pushary_enabled"])
166
- agent_changed = not (isinstance(receipt["disabled"].get("value"), list)
167
- and receipt["clarify_disabled"])
168
- restore(ap, "transport", receipt["transport"], "pushary")
169
- restore(ap, "transport_fallback", receipt["fallback"], "builtin")
170
- else:
171
- if ap.get("transport") == "pushary": ap.pop("transport", None)
172
- if ap.get("transport_fallback") == "builtin": ap.pop("transport_fallback", None)
173
- if receipt:
174
- restore_container(s, "approval", receipt["approval"], ap, approval_changed)
175
- restore_container(c, "security", receipt["security"], s, approval_changed)
176
- else:
177
- if ap: s["approval"] = ap
178
- else: s.pop("approval", None)
179
- if s: c["security"] = s
180
- else: c.pop("security", None)
181
-
182
- p = c.get("plugins") if isinstance(c.get("plugins"), dict) else {}
183
- if receipt:
184
- restore_list_member(p, "enabled", receipt["enabled"], "pushary", receipt["pushary_enabled"])
185
- restore_container(c, "plugins", receipt["plugins"], p, plugins_changed)
186
- else:
187
- enabled = p.get("enabled") if isinstance(p.get("enabled"), list) else []
188
- enabled = [item for item in enabled if item != "pushary"]
189
- if enabled: p["enabled"] = enabled
190
- else: p.pop("enabled", None)
191
- if p: c["plugins"] = p
192
- else: c.pop("plugins", None)
193
-
194
- a = c.get("agent") if isinstance(c.get("agent"), dict) else {}
195
- if receipt:
196
- restore_list_member(a, "disabled_toolsets", receipt["disabled"], "clarify", receipt["clarify_disabled"])
197
- restore_container(c, "agent", receipt["agent"], a, agent_changed)
198
- else:
199
- disabled = a.get("disabled_toolsets") if isinstance(a.get("disabled_toolsets"), list) else []
200
- disabled = [item for item in disabled if item != "clarify"]
201
- if disabled: a["disabled_toolsets"] = disabled
202
- else: a.pop("disabled_toolsets", None)
203
- if a: c["agent"] = a
204
- else: c.pop("agent", None)
205
-
206
- if receipt and restore_conflicts:
207
- raise ValueError("Hermes config changed after Pushary setup")
208
-
209
- save_config(c)
210
- `;
211
- var resolveHermesPython = () => {
212
- const launcher = resolvePathBinary("hermes");
213
- if (launcher && process.platform !== "win32") {
214
- try {
215
- const shebang = readFileSync(launcher, "utf-8").split("\n", 1)[0];
216
- const interpreter = shebang?.startsWith("#!") ? shebang.slice(2).trim().split(/\s+/)[0] : void 0;
217
- if (interpreter && /python/i.test(interpreter) && existsSync(interpreter)) return interpreter;
218
- } catch {
219
- }
220
- }
221
- const root = join(homedir(), ".hermes", "hermes-agent", "venv");
222
- const candidates = process.platform === "win32" ? [join(root, "Scripts", "python.exe"), join(root, "Scripts", "python3.exe")] : [join(root, "bin", "python3"), join(root, "bin", "python")];
223
- return candidates.find(existsSync) ?? null;
224
- };
225
- var runHermesPythonScript = (python, script, ...args) => {
226
- const path = join(tmpdir(), `pushary-hermes-${process.pid}-${Date.now()}.py`);
227
- try {
228
- writeFileSync(path, script, { encoding: "utf-8", mode: 384 });
229
- execFileSync(python, [path, ...args], { env: { ...process.env }, stdio: "pipe", timeout: 15e3 });
230
- return true;
231
- } catch {
232
- return false;
233
- } finally {
234
- try {
235
- rmSync(path, { force: true });
236
- } catch {
237
- }
238
- }
239
- };
240
-
241
- // src/skills-cli.ts
242
- import { execSync } from "child_process";
243
- var PUSHARY_SKILL_SOURCE = "Pushary/pushary-skill";
244
- var PUSHARY_SKILL_NAME = "pushary";
245
- var installSkillViaSkillsCli = (agent) => {
246
- try {
247
- execSync(`npx -y skills@latest add ${PUSHARY_SKILL_SOURCE}@${PUSHARY_SKILL_NAME} -y -g --agent ${agent}`, {
248
- stdio: "pipe",
249
- timeout: 9e4
250
- });
251
- return true;
252
- } catch {
253
- return false;
254
- }
255
- };
256
- var installAgentSkill = async (request, effects) => {
257
- if (request.skillsCliInUse) {
258
- const startedAt = effects.now();
259
- if (effects.runSkillsCli(request.agent)) {
260
- const modifiedAt = effects.skillModifiedAt(request.agentSkillDir);
261
- if (modifiedAt !== null && modifiedAt >= startedAt) return "skills-cli";
262
- }
263
- }
264
- await effects.writePackagedSkill(request.agentSkillDir);
265
- return "packaged-copy";
266
- };
267
-
268
- // src/cursor-config.ts
269
- var hookCommandOf = (entry) => {
270
- const command = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.command : void 0;
271
- return typeof command === "string" ? command : "";
272
- };
273
- var isPusharyCursorEntry = (entry) => pusharyHookExecutable(hookCommandOf(entry)) !== null;
274
- var registerCursorGate = (existing, entry) => registerHookEntry(existing, isPusharyCursorEntry, entry);
275
- var withoutPusharyCursorHooks = (hooks, scope) => {
276
- let removed = 0;
277
- const kept = {};
278
- for (const [event, entries] of Object.entries(hooks)) {
279
- if (!Array.isArray(entries)) {
280
- kept[event] = entries;
281
- continue;
282
- }
283
- const others = entries.filter((entry) => !isPusharyCursorEntry(entry) || isProtectedByScope(hookCommandOf(entry), scope));
284
- removed += entries.length - others.length;
285
- if (others.length > 0 || entries.length === 0) kept[event] = others;
286
- }
287
- return { hooks: kept, removed };
288
- };
289
-
290
- // src/cli/dry-run.ts
291
- import { execFileSync as execFileSync2 } from "child_process";
292
- import { rmSync as rmSync2, writeFileSync as writeFileSync2 } from "fs";
293
- var createGuards = (isDryRun, note) => ({
294
- write: (path, contents) => {
295
- if (isDryRun()) return note("rewrite", path);
296
- writeFileSync2(path, contents, "utf-8");
297
- },
298
- remove: (path, options = {}) => {
299
- if (isDryRun()) return note("remove ", path);
300
- rmSync2(path, { recursive: true, force: options.force ?? false });
301
- },
302
- execFile: (file, args, options, describe) => {
303
- if (isDryRun()) return note("run ", describe);
304
- execFileSync2(file, args, options);
305
- }
306
- });
307
- var describeService = (effects) => {
308
- if (effects.controlMode === "off") return "skip the phone-start background service (--control off)";
309
- const where = effects.serviceDefinitionPath ?? "the phone-start service definition";
310
- const condition = effects.controlMode === "on" ? "" : ", when a supported agent and a service manager are present";
311
- return `write ${where} and register it with the OS${condition}`;
312
- };
313
- var describeSetupSideEffects = (effects) => [
314
- `run npm install -g @pushary/agent-hooks@${effects.version} (the hooks run from the global copy; up to two minutes)`,
315
- `write ${effects.configFile} (the API key, mode 600)`,
316
- effects.rcPath ? `edit ${effects.rcPath} (export PUSHARY_API_KEY)` : "print the export line for your shell, since no rc file was found",
317
- describeService(effects),
318
- "ask Add Pushary instructions to this project's CLAUDE.md/AGENTS.md? (default no)",
319
- "ask Alias claude to pushary claude? (default no)"
320
- ];
321
-
322
- export {
323
- isHermesConfigReceipt,
324
- HERMES_PIP_PACKAGE,
325
- HERMES_CONFIG_SCRIPT,
326
- resolveHermesPython,
327
- runHermesPythonScript,
328
- PUSHARY_SKILL_SOURCE,
329
- PUSHARY_SKILL_NAME,
330
- installSkillViaSkillsCli,
331
- installAgentSkill,
332
- registerCursorGate,
333
- withoutPusharyCursorHooks,
334
- createGuards,
335
- describeSetupSideEffects
336
- };
@@ -1,12 +0,0 @@
1
- // src/answer.ts
2
- var denyReasonFrom = (value, note) => {
3
- const trimmed = note?.trim();
4
- if (trimmed) return `Denied from your phone: ${trimmed}`;
5
- return value && value !== "no" && value !== "yes" ? `Denied from your phone: ${value}` : "Denied via push notification";
6
- };
7
- var isDeferAnswer = (value) => value === "defer";
8
-
9
- export {
10
- denyReasonFrom,
11
- isDeferAnswer
12
- };