@pushary/agent-hooks 1.9.7 → 1.9.9

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 (111) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +3 -3
  3. package/data/cursor-plugin/README.md +3 -7
  4. package/data/vscode-plugin/README.md +1 -1
  5. package/dist/bin/pushary-bell-hook.js +22 -24
  6. package/dist/bin/pushary-bell.js +13 -13
  7. package/dist/bin/pushary-claude.js +28 -30
  8. package/dist/bin/pushary-clean.js +113 -94
  9. package/dist/bin/pushary-codex-bridge.js +20 -20
  10. package/dist/bin/pushary-codex-hook.js +36 -38
  11. package/dist/bin/pushary-codex.js +13 -13
  12. package/dist/bin/pushary-connect.js +48 -22
  13. package/dist/bin/pushary-cowork.js +5 -5
  14. package/dist/bin/pushary-daemon.js +50 -40
  15. package/dist/bin/pushary-disconnect.js +188 -56
  16. package/dist/bin/pushary-doctor.js +105 -85
  17. package/dist/bin/pushary-elicitation-hook.js +25 -27
  18. package/dist/bin/pushary-gemini-bridge.js +13 -13
  19. package/dist/bin/pushary-gemini-hook.js +31 -33
  20. package/dist/bin/pushary-hook.js +36 -39
  21. package/dist/bin/pushary-login.js +12 -12
  22. package/dist/bin/pushary-logout.js +105 -42
  23. package/dist/bin/pushary-mcp.js +9 -9
  24. package/dist/bin/pushary-mode.js +28 -31
  25. package/dist/bin/pushary-notification-hook.js +29 -32
  26. package/dist/bin/pushary-opencode-hook.js +30 -32
  27. package/dist/bin/pushary-permission-denied-hook.js +30 -33
  28. package/dist/bin/pushary-permission-hook.js +33 -36
  29. package/dist/bin/pushary-post-hook.js +30 -33
  30. package/dist/bin/pushary-prompt-hook.js +29 -32
  31. package/dist/bin/pushary-session-end-hook.js +29 -32
  32. package/dist/bin/pushary-session-start-hook.js +33 -36
  33. package/dist/bin/pushary-setup.js +168 -160
  34. package/dist/bin/pushary-stats.js +5 -5
  35. package/dist/bin/pushary-status.js +65 -19
  36. package/dist/bin/pushary-stop-hook.js +29 -32
  37. package/dist/bin/pushary-stopfailure-hook.js +29 -32
  38. package/dist/bin/pushary-suggestions.js +19 -21
  39. package/dist/bin/pushary-transcript-register.js +18 -20
  40. package/dist/bin/pushary-transcripts.js +7 -7
  41. package/dist/bin/pushary-upgrade.js +50 -26
  42. package/dist/bin/pushary-wait.js +23 -19
  43. package/dist/bin/pushary.js +15 -14
  44. package/dist/{chunk-4FK6RZVJ.js → chunk-462EQA6K.js} +1 -1
  45. package/dist/{chunk-STQRUH3S.js → chunk-5DCDQ5VW.js} +59 -15
  46. package/dist/{chunk-JXISQ7DT.js → chunk-5N5L6DNN.js} +3 -3
  47. package/dist/{chunk-QR6VE5ME.js → chunk-5RGA636G.js} +79 -17
  48. package/dist/{chunk-L76HTPU6.js → chunk-6AYSKVLL.js} +3 -3
  49. package/dist/{chunk-NIBFSARF.js → chunk-6EBGOHDJ.js} +33 -13
  50. package/dist/{chunk-QQ4HBXZC.js → chunk-6W5M3MSE.js} +84 -673
  51. package/dist/{chunk-R3YW55MY.js → chunk-AI7RMFVV.js} +29 -26
  52. package/dist/{chunk-AUUXS44H.js → chunk-APP43AW7.js} +1 -1
  53. package/dist/{chunk-RQGODFQN.js → chunk-AZOKPWVI.js} +1 -1
  54. package/dist/{chunk-3GNUXXDZ.js → chunk-B5NMSP3V.js} +2 -2
  55. package/dist/{chunk-4D2AYNSE.js → chunk-BNSKVIAW.js} +2 -2
  56. package/dist/chunk-BYLKCZ2G.js +367 -0
  57. package/dist/{chunk-X5NXPCIC.js → chunk-BZLHTMT6.js} +89 -7
  58. package/dist/{chunk-BTQGAXZ3.js → chunk-COQ64C4F.js} +10 -10
  59. package/dist/{chunk-N4EUSDKX.js → chunk-DCCSULXK.js} +14 -14
  60. package/dist/{chunk-JWKBDSPF.js → chunk-DP3WX7FW.js} +2 -2
  61. package/dist/chunk-E5HOHIUV.js +52 -0
  62. package/dist/{chunk-GU3EJCVV.js → chunk-EA5NWDK7.js} +4 -0
  63. package/dist/chunk-EIAEUG7G.js +46 -0
  64. package/dist/{chunk-EB4XGVBG.js → chunk-EUW7JL2K.js} +0 -32
  65. package/dist/{chunk-T7Y5EADL.js → chunk-F7R3SZ4Q.js} +2 -2
  66. package/dist/{chunk-H37L7TT3.js → chunk-G7RIDXAT.js} +2 -2
  67. package/dist/{chunk-W2KI5KPD.js → chunk-H5T27W7M.js} +2 -2
  68. package/dist/chunk-HBWYMRR5.js +94 -0
  69. package/dist/{chunk-CBQACHKY.js → chunk-IIVZZMSO.js} +1 -1
  70. package/dist/{chunk-Z6HPS67T.js → chunk-IRHABAQT.js} +1 -1
  71. package/dist/{chunk-QTO6HEZD.js → chunk-K545B734.js} +2 -2
  72. package/dist/{chunk-KYO45G5L.js → chunk-KOWFRUIT.js} +1 -1
  73. package/dist/{chunk-QFEM7R6T.js → chunk-KQFTBQ66.js} +11 -11
  74. package/dist/chunk-LENBKYRB.js +50 -0
  75. package/dist/{chunk-JCWZ23MJ.js → chunk-M3STIAGU.js} +3 -3
  76. package/dist/{chunk-6DJTDHBI.js → chunk-MD4SVNT6.js} +1 -1
  77. package/dist/{chunk-7264S5HZ.js → chunk-MLGIVVSG.js} +1 -1
  78. package/dist/{chunk-H7MMU64M.js → chunk-NGKUXZID.js} +2 -2
  79. package/dist/{chunk-JWQZSYCK.js → chunk-NUVGDBZC.js} +1 -1
  80. package/dist/{chunk-AQ55ZSSS.js → chunk-OAYWO5NP.js} +1 -1
  81. package/dist/chunk-Q6C6ILUS.js +49 -0
  82. package/dist/{chunk-MBK7N46B.js → chunk-QIOIO7VN.js} +6 -6
  83. package/dist/{chunk-KFKL3FHS.js → chunk-QRXPWW3M.js} +4 -3
  84. package/dist/{chunk-7OIWWZAD.js → chunk-QTIUJZRX.js} +3 -3
  85. package/dist/{chunk-XWAYAO3V.js → chunk-R5RIVOPL.js} +2 -2
  86. package/dist/{chunk-ADSQDYYG.js → chunk-REU2VQPH.js} +54 -5
  87. package/dist/{chunk-GKI6LFAV.js → chunk-RQ32ADJP.js} +2 -2
  88. package/dist/{chunk-VXRXFU6Q.js → chunk-SZ4Q6ZVS.js} +14 -7
  89. package/dist/{chunk-KT5E2RLS.js → chunk-T6ZN4TEF.js} +1 -1
  90. package/dist/{chunk-UFVGSEWH.js → chunk-TO3PS646.js} +2 -2
  91. package/dist/chunk-UAP5DS6P.js +599 -0
  92. package/dist/{chunk-MZPXVH4A.js → chunk-UF6RBP5V.js} +204 -28
  93. package/dist/{chunk-AVNKVF7N.js → chunk-UPIZSCYD.js} +4 -4
  94. package/dist/{chunk-3PVDOCFI.js → chunk-VHPFNLRS.js} +5 -5
  95. package/dist/{chunk-HPRZJKRO.js → chunk-VIIHC42X.js} +1 -1
  96. package/dist/{chunk-D6S5EKXA.js → chunk-WRPYCIV2.js} +8 -12
  97. package/dist/{chunk-ZUTU43FT.js → chunk-Z23ZBYDW.js} +6 -4
  98. package/dist/{chunk-SBLPHUEB.js → chunk-ZGADIZDS.js} +8 -6
  99. package/dist/{global-upgrade-E2HUEB4B.js → global-upgrade-H272QOGD.js} +6 -6
  100. package/dist/{paths-QVTEGNZV.js → paths-HMVOTFUN.js} +2 -2
  101. package/dist/reapply-Q5NHDTVU.js +55 -0
  102. package/dist/src/index.d.ts +1 -0
  103. package/dist/src/index.js +19 -20
  104. package/dist/{upgrade-lock-JCIDZMHF.js → upgrade-lock-L3GHFIRW.js} +3 -3
  105. package/package.json +1 -1
  106. package/dist/chunk-4YO4T5FV.js +0 -149
  107. package/dist/chunk-ANEAA37E.js +0 -197
  108. package/dist/chunk-MNWRUGMH.js +0 -86
  109. package/dist/chunk-RQSOEB4S.js +0 -44
  110. package/dist/chunk-SD3272LS.js +0 -143
  111. package/dist/reapply-5QVKM6LA.js +0 -38
@@ -1,17 +1,12 @@
1
1
  import {
2
2
  MCP_BRIDGE_BINARY
3
- } from "./chunk-W2KI5KPD.js";
4
- import {
5
- openCodeConfigDirFrom
6
- } from "./chunk-X5NXPCIC.js";
3
+ } from "./chunk-H5T27W7M.js";
7
4
  import {
8
5
  KEY_FILE_MODE
9
- } from "./chunk-ADSQDYYG.js";
6
+ } from "./chunk-REU2VQPH.js";
10
7
  import {
11
- NpmMissingError,
12
- codexHomeFrom,
13
- resolvePathBinary
14
- } from "./chunk-ZUTU43FT.js";
8
+ NpmMissingError
9
+ } from "./chunk-Z23ZBYDW.js";
15
10
  import {
16
11
  readJsonSafe,
17
12
  writeFileAtomic,
@@ -19,316 +14,83 @@ import {
19
14
  } from "./chunk-T7E75EKA.js";
20
15
  import {
21
16
  NPX_LATEST_COMMAND
22
- } from "./chunk-STQRUH3S.js";
23
- import {
24
- HOOK_COMPATIBLE_PROFILES
25
- } from "./chunk-QR6VE5ME.js";
26
-
27
- // src/hermes-config.ts
28
- import { execFileSync } from "child_process";
29
- import { existsSync, readFileSync, rmSync, writeFileSync } from "fs";
30
- import { homedir, tmpdir } from "os";
31
- import { join } from "path";
32
- var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
33
- var isSnapshot = (value) => isRecord(value) && typeof value.present === "boolean" && Object.hasOwn(value, "value");
34
- var isHermesConfigReceipt = (value) => {
35
- if (!isRecord(value)) return false;
36
- return ["security", "approval", "transport", "fallback", "plugins", "enabled", "agent", "disabled"].every((key) => isSnapshot(value[key])) && typeof value.pushary_enabled === "boolean" && typeof value.clarify_disabled === "boolean";
37
- };
38
- var HERMES_PIP_PACKAGE = "hermes-plugin-pushary";
39
- var HERMES_PLUGIN_NAME = "pushary";
40
- var HERMES_CONFIG_SCRIPT = String.raw`
41
- import copy, importlib.util, json, os, sys
42
- from hermes_cli.config import load_config, save_config
43
-
44
- PUSHARY_TRANSPORT = "pushary"
45
- PUSHARY_FALLBACK = "builtin"
46
- PUSHARY_PLUGIN = "pushary"
47
- PUSHARY_PLUGIN_MODULE = "pushary_plugin"
48
- QUESTION_TOOLSET = "clarify"
49
-
50
- mode = sys.argv[1]
51
- receipt_path = sys.argv[2] if len(sys.argv) > 2 else None
52
- c = load_config()
53
- original = copy.deepcopy(c)
54
-
55
- def section(obj, key):
56
- value = obj.get(key)
57
- return value if isinstance(value, dict) else {}
58
-
59
- def members(obj, key):
60
- value = obj.get(key)
61
- return value if isinstance(value, list) else []
62
-
63
- if mode == "status":
64
- print(json.dumps({
65
- "plugin_installed": importlib.util.find_spec(PUSHARY_PLUGIN_MODULE) is not None,
66
- "plugin_enabled": PUSHARY_PLUGIN in members(section(c, "plugins"), "enabled"),
67
- "approvals_routed": section(section(c, "security"), "approval").get("transport") == PUSHARY_TRANSPORT,
68
- "questions_routed": QUESTION_TOOLSET in members(section(c, "agent"), "disabled_toolsets"),
69
- }))
70
- sys.exit(0)
71
-
72
- def recorded(snapshot, value):
73
- return bool(snapshot.get("present")) and snapshot.get("value") == value
74
-
75
- def pop_if(obj, key, value):
76
- if obj.get(key) == value:
77
- obj.pop(key, None)
78
-
79
- def snap(obj, key):
80
- return {"present": key in obj, "value": obj.get(key)}
81
-
82
- restore_conflicts = []
17
+ } from "./chunk-5DCDQ5VW.js";
83
18
 
84
- def restore(obj, key, before, ours):
85
- if before.get("present") and before.get("value") == ours:
86
- return
87
- if before.get("present"):
88
- if key in obj and obj.get(key) == before.get("value"):
89
- return
90
- elif key not in obj:
91
- return
92
- if obj.get(key) != ours:
93
- restore_conflicts.append(key)
94
- return
95
- if before.get("present"):
96
- obj[key] = before.get("value")
97
- else:
98
- obj.pop(key, None)
99
-
100
- def restore_container(obj, key, before, current, changed):
101
- raw = obj.get(key)
102
- if isinstance(before.get("value"), dict):
103
- if not isinstance(raw, dict):
104
- if changed:
105
- restore_conflicts.append(key)
106
- return
107
- if current or before.get("present"):
108
- obj[key] = current
109
- else:
110
- obj.pop(key, None)
111
- elif isinstance(raw, dict) and current:
112
- restore_conflicts.append(key)
113
- else:
114
- restore(obj, key, before, {})
115
-
116
- def restore_list_member(obj, key, before, ours, ours_before):
117
- raw = obj.get(key)
118
- if isinstance(before.get("value"), list):
119
- if ours_before:
120
- return
121
- if not isinstance(raw, list):
122
- restore_conflicts.append(key)
123
- return
124
- remaining = [item for item in raw if item != ours]
125
- if remaining or before.get("present"):
126
- obj[key] = remaining
127
- else:
128
- obj.pop(key, None)
129
- return
130
- if before.get("present") and raw == before.get("value"):
131
- return
132
- if not before.get("present") and key not in obj:
133
- return
134
- if not isinstance(raw, list):
135
- restore_conflicts.append(key)
136
- return
137
- remaining = [item for item in raw if item != ours]
138
- if remaining:
139
- restore_conflicts.append(key)
140
- else:
141
- restore(obj, key, before, raw)
142
-
143
- def valid_snapshot(value):
144
- return isinstance(value, dict) and isinstance(value.get("present"), bool) and "value" in value
145
-
146
- def valid_receipt(value):
147
- snapshots = ["security", "approval", "transport", "fallback", "plugins", "enabled", "agent", "disabled"]
148
- return (isinstance(value, dict)
149
- and all(valid_snapshot(value.get(key)) for key in snapshots)
150
- and isinstance(value.get("pushary_enabled"), bool)
151
- and isinstance(value.get("clarify_disabled"), bool))
152
-
153
- if mode == "setup":
154
- security_before = snap(c, "security")
155
- s = section(c, "security")
156
- approval_before = snap(s, "approval")
157
- ap = section(s, "approval")
158
- plugins_before = snap(c, "plugins")
159
- p = section(c, "plugins")
160
- agent_before = snap(c, "agent")
161
- a = section(c, "agent")
162
- enabled = members(p, "enabled")
163
- disabled = members(a, "disabled_toolsets")
164
- receipt = {
165
- "security": security_before,
166
- "approval": approval_before,
167
- "transport": snap(ap, "transport"),
168
- "fallback": snap(ap, "transport_fallback"),
169
- "plugins": plugins_before,
170
- "enabled": snap(p, "enabled"),
171
- "pushary_enabled": PUSHARY_PLUGIN in enabled,
172
- "agent": agent_before,
173
- "disabled": snap(a, "disabled_toolsets"),
174
- "clarify_disabled": QUESTION_TOOLSET in disabled,
175
- }
176
- if os.path.exists(receipt_path):
177
- with open(receipt_path, encoding="utf-8") as handle:
178
- existing_receipt = json.load(handle)
179
- if not valid_receipt(existing_receipt):
180
- raise ValueError("invalid Pushary Hermes setup receipt")
181
- else:
182
- os.makedirs(os.path.dirname(receipt_path), exist_ok=True)
183
- temp = receipt_path + ".tmp"
184
- with open(temp, "x", encoding="utf-8") as handle:
185
- json.dump(receipt, handle)
186
- os.chmod(temp, 0o600)
187
- os.replace(temp, receipt_path)
188
- ap["transport"] = PUSHARY_TRANSPORT
189
- ap["transport_fallback"] = PUSHARY_FALLBACK
190
- s["approval"] = ap
191
- c["security"] = s
192
- p["enabled"] = enabled if PUSHARY_PLUGIN in enabled else enabled + [PUSHARY_PLUGIN]
193
- c["plugins"] = p
194
- a["disabled_toolsets"] = disabled if QUESTION_TOOLSET in disabled else disabled + [QUESTION_TOOLSET]
195
- c["agent"] = a
196
- else:
197
- receipt_exists = os.path.exists(receipt_path)
198
- try:
199
- with open(receipt_path, encoding="utf-8") as handle:
200
- receipt = json.load(handle)
201
- except (OSError, ValueError):
202
- if receipt_exists:
203
- raise
204
- receipt = None
205
- s = section(c, "security")
206
- ap = section(s, "approval")
207
- if receipt:
208
- if not valid_receipt(receipt):
209
- raise ValueError("invalid Pushary Hermes setup receipt")
210
- approval_changed = (not receipt["transport"].get("present")
211
- or receipt["transport"].get("value") != PUSHARY_TRANSPORT
212
- or not receipt["fallback"].get("present")
213
- or receipt["fallback"].get("value") != PUSHARY_FALLBACK)
214
- plugins_changed = not (isinstance(receipt["enabled"].get("value"), list)
215
- and receipt["pushary_enabled"])
216
- agent_changed = not (isinstance(receipt["disabled"].get("value"), list)
217
- and receipt["clarify_disabled"])
218
- transport_left_over = recorded(receipt["transport"], PUSHARY_TRANSPORT)
219
- if transport_left_over:
220
- pop_if(ap, "transport", PUSHARY_TRANSPORT)
221
- else:
222
- restore(ap, "transport", receipt["transport"], PUSHARY_TRANSPORT)
223
- if transport_left_over and recorded(receipt["fallback"], PUSHARY_FALLBACK):
224
- pop_if(ap, "transport_fallback", PUSHARY_FALLBACK)
225
- else:
226
- restore(ap, "transport_fallback", receipt["fallback"], PUSHARY_FALLBACK)
227
- else:
228
- pop_if(ap, "transport", PUSHARY_TRANSPORT)
229
- pop_if(ap, "transport_fallback", PUSHARY_FALLBACK)
230
- if receipt:
231
- restore_container(s, "approval", receipt["approval"], ap, approval_changed)
232
- restore_container(c, "security", receipt["security"], s, approval_changed)
233
- else:
234
- if ap: s["approval"] = ap
235
- else: s.pop("approval", None)
236
- if s: c["security"] = s
237
- else: c.pop("security", None)
19
+ // src/instruction-file.ts
20
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, rmSync } from "fs";
21
+ import { dirname } from "path";
22
+ var PUSHARY_BEGIN = "<!-- BEGIN PUSHARY (managed by @pushary/agent-hooks; do not edit this block) -->";
23
+ var PUSHARY_END = "<!-- END PUSHARY -->";
24
+ var instructionBody = (label) => `## Pushary notifications and approvals
238
25
 
239
- p = section(c, "plugins")
240
- if receipt:
241
- restore_list_member(p, "enabled", receipt["enabled"], PUSHARY_PLUGIN, False)
242
- restore_container(c, "plugins", receipt["plugins"], p, plugins_changed)
243
- else:
244
- enabled = [item for item in members(p, "enabled") if item != PUSHARY_PLUGIN]
245
- if enabled: p["enabled"] = enabled
246
- else: p.pop("enabled", None)
247
- if p: c["plugins"] = p
248
- else: c.pop("plugins", None)
26
+ You have Pushary MCP tools that reach the user on their phone. Use them proactively. Do not wait for the user to ask.
249
27
 
250
- a = section(c, "agent")
251
- if receipt:
252
- clarify_was_users = receipt["clarify_disabled"] and not recorded(receipt["transport"], PUSHARY_TRANSPORT)
253
- restore_list_member(a, "disabled_toolsets", receipt["disabled"], QUESTION_TOOLSET, clarify_was_users)
254
- restore_container(c, "agent", receipt["agent"], a, agent_changed)
255
- else:
256
- disabled = [item for item in members(a, "disabled_toolsets") if item != QUESTION_TOOLSET]
257
- if disabled: a["disabled_toolsets"] = disabled
258
- else: a.pop("disabled_toolsets", None)
259
- if a: c["agent"] = a
260
- else: c.pop("agent", None)
28
+ - 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. Read \`answered\`, \`status\` and the returned handoff instead of assuming the tool blocked. Silence is not consent; choice/text answers do not authorize a separate action.
29
+ - Ask once, on one channel. If you also have a built-in way to prompt the user, use that or \`ask_user\` for a given question, never both. \`ask_user\` is the one that reaches the user when they are away from this machine, so prefer it. Raising both strands the user in whichever prompt you are not waiting on.
30
+ - Honor authorization already granted in this session. Ask before a risky or irreversible action outside that authorization, or when an enforced host policy requires it. Do not ask again for an already authorized step, and never bypass an enforced gate. When a Pushary hook result says the user approved a specific command after a denial, rerunning that exact command is the approved path and not a bypass of that gate.
31
+ - Call \`propose_scope\` only for an unresolved or requested file boundary. A ratified scope narrows what may proceed; it does not bypass other approval rules. Do not add a plan approval merely because work spans several files, and do not propose a new scope mid-run just to widen it. Let the installed gate request any scope expansion before the edit executes. Only file paths are checked, and only on tool calls that carry one, so put a boundary that is not a path (recipients, channels, spend, systems you will not open) in \`promises\` and never in \`allowedPaths\`. Read the \`enforces\` field that comes back: an empty array means nothing in that contract is checked automatically, and you must say so rather than report that a scope is in force. \`hookSeen: false\` means no hook has reported that sessionId, so the gate will never find the contract: fix the session id rather than proceeding as if a scope were in force.
32
+ - Before a task of more than two steps, break it into steps and find the forks. Settle by yourself every fork that a file, a command or a tool call can answer, then ask the rest as one numbered round with your recommended answer against each. A question in the terminal is free; a push is not. When the user is at the terminal, ask the whole round there. When the user is away, send only the fork that stops the run, and decide the rest on your recommendation.
33
+ - 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.
34
+ - When meaningful work finishes while the user is away, or they requested an alert, call \`send_notification\` so the user knows it is done. Skip trivial completions and duplicate reports to someone already reading. Always pass \`context\` with a \`type\` of "task_complete", "error" or "info": it is what tells Pushary this is a task update, so the user's own setting for where updates land can route it.
35
+ - Confirm notifications can offer lock-screen actions; arbitrary choices and text open the app. The Mac notch handles personal account questions, not Partner customer enrollment.
36
+ - Use \`cancel_question\` to retract a pending question once it is no longer needed.
37
+ - 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.
261
38
 
262
- if receipt and restore_conflicts:
263
- raise ValueError("Hermes config changed after Pushary setup")
39
+ Pass \`agentName\` as "${label} - <project folder name>" so the user knows which session is asking. If a question times out, follow \`handoffAction\` when present, otherwise \`nextAction\`: poll once, then cancel a live phone question before asking in the current client. If cancellation returns \`handoffAction: "stop"\`, stop. Otherwise, if cancellation returns false, poll once for 1 second and honor the answer that won the race.`;
40
+ var SHARED_AGENTS_MD_LABEL = "<your agent's name, such as Codex or Hermes>";
41
+ var renderAgentInstructions = (label) => instructionBody(label);
42
+ 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 (3-day trial): https://pushary.com/sign-up?utm_source=agents-md&utm_medium=teammate";
43
+ var renderProjectAgentInstructions = (label) => `${instructionBody(label)}
264
44
 
265
- changed = c != original
266
- if changed and mode != "clean-preview":
267
- save_config(c)
268
- print(json.dumps({"changed": changed}))
269
- `;
270
- var resolveHermesPython = () => {
271
- const launcher = resolvePathBinary("hermes");
272
- if (launcher && process.platform !== "win32") {
273
- try {
274
- const shebang = readFileSync(launcher, "utf-8").split("\n", 1)[0];
275
- const interpreter = shebang?.startsWith("#!") ? shebang.slice(2).trim().split(/\s+/)[0] : void 0;
276
- if (interpreter && /python/i.test(interpreter) && existsSync(interpreter)) return interpreter;
277
- } catch {
278
- }
45
+ 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}`;
46
+ var wrap = (body) => `${PUSHARY_BEGIN}
47
+ ${body}
48
+ ${PUSHARY_END}`;
49
+ var writeInstructionBlock = (filePath, body) => {
50
+ const dir = dirname(filePath);
51
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
52
+ let existing = "";
53
+ try {
54
+ existing = readFileSync(filePath, "utf-8");
55
+ } catch {
279
56
  }
280
- const root = join(homedir(), ".hermes", "hermes-agent", "venv");
281
- const candidates = process.platform === "win32" ? [join(root, "Scripts", "python.exe"), join(root, "Scripts", "python3.exe")] : [join(root, "bin", "python3"), join(root, "bin", "python")];
282
- return candidates.find(existsSync) ?? null;
57
+ const block = wrap(body);
58
+ const start = existing.indexOf(PUSHARY_BEGIN);
59
+ const end = existing.indexOf(PUSHARY_END);
60
+ let next;
61
+ if (start !== -1 && end !== -1 && end > start) {
62
+ next = existing.slice(0, start) + block + existing.slice(end + PUSHARY_END.length);
63
+ } else {
64
+ const prefix = existing.trim() ? existing.replace(/\s*$/, "") + "\n\n" : "";
65
+ next = prefix + block + "\n";
66
+ }
67
+ writeFileSync(filePath, next, "utf-8");
283
68
  };
284
- var HERMES_SCRIPT_TIMEOUT_MS = 15e3;
285
- var runPythonScript = (python, script, args) => {
286
- const path = join(tmpdir(), `pushary-hermes-${process.pid}-${Date.now()}.py`);
69
+ var removeInstructionBlock = (filePath) => {
70
+ let existing = "";
287
71
  try {
288
- writeFileSync(path, script, { encoding: "utf-8", mode: 384 });
289
- return execFileSync(python, [path, ...args], {
290
- env: { ...process.env },
291
- encoding: "utf-8",
292
- stdio: "pipe",
293
- timeout: HERMES_SCRIPT_TIMEOUT_MS
294
- });
72
+ existing = readFileSync(filePath, "utf-8");
295
73
  } catch {
296
- return null;
297
- } finally {
298
- try {
299
- rmSync(path, { force: true });
300
- } catch {
301
- }
74
+ return false;
302
75
  }
76
+ const start = existing.indexOf(PUSHARY_BEGIN);
77
+ const end = existing.indexOf(PUSHARY_END);
78
+ if (start === -1 || end === -1 || end < start) return false;
79
+ const remaining = (existing.slice(0, start) + existing.slice(end + PUSHARY_END.length)).trim();
80
+ if (remaining === "") {
81
+ rmSync(filePath, { force: true });
82
+ } else {
83
+ writeFileSync(filePath, remaining + "\n", "utf-8");
84
+ }
85
+ return true;
303
86
  };
304
- var lastReport = (stdout) => {
305
- const line = stdout.trim().split("\n").at(-1) ?? "";
87
+ var hasInstructionBlock = (filePath) => {
306
88
  try {
307
- return JSON.parse(line);
89
+ return readFileSync(filePath, "utf-8").includes(PUSHARY_BEGIN);
308
90
  } catch {
309
- return void 0;
91
+ return false;
310
92
  }
311
93
  };
312
- var configRunFrom = (stdout) => {
313
- const report = stdout === null ? void 0 : lastReport(stdout);
314
- if (!isRecord(report) || typeof report.changed !== "boolean") return "failed";
315
- return report.changed ? "changed" : "unchanged";
316
- };
317
- var runHermesConfigScript = (python, mode, receiptPath) => configRunFrom(runPythonScript(python, HERMES_CONFIG_SCRIPT, [mode, receiptPath]));
318
- var HERMES_STATUS_FIELDS = ["plugin_installed", "plugin_enabled", "approvals_routed", "questions_routed"];
319
- var isHermesStatusReport = (value) => isRecord(value) && HERMES_STATUS_FIELDS.every((field) => typeof value[field] === "boolean");
320
- var hermesWiredByPushary = (status, setupRecorded) => setupRecorded || status.pluginEnabled || status.approvalsRouted;
321
- var readHermesStatus = (python) => {
322
- const stdout = runPythonScript(python, HERMES_CONFIG_SCRIPT, ["status"]);
323
- const report = stdout === null ? void 0 : lastReport(stdout);
324
- if (!isHermesStatusReport(report)) return null;
325
- return {
326
- pluginInstalled: report.plugin_installed,
327
- pluginEnabled: report.plugin_enabled,
328
- approvalsRouted: report.approvals_routed,
329
- questionsRouted: report.questions_routed
330
- };
331
- };
332
94
 
333
95
  // src/fx-config.ts
334
96
  var FX_SERVER_NAME = "pushary";
@@ -337,6 +99,10 @@ var FX_PROFILE_MAX_BYTES = 1024 * 1024 - 1;
337
99
  var FX_SETTINGS_MAX_BYTES = 64 * 1024;
338
100
  var FX_PUSHARY_TOOLS_RULE = "mcp_pushary_*";
339
101
  var FX_TOOL_DISCOVERY_NOTE = 'In fx, these tools are named mcp_pushary_ask_user, mcp_pushary_send_notification, mcp_pushary_wait_for_answer, mcp_pushary_cancel_question and mcp_pushary_propose_scope. fx does not load them at the start of a turn: call mcp_select_tool with the exact name, for example {"name": "mcp_pushary_ask_user"}, then call the tool. For fx this replaces the guidance above to ask the whole round in the terminal while the user is there: ask every question through mcp_pushary_ask_user, even while the user is at this terminal, rather than through ask_user_question. fx cannot show its own question prompt in the Mac notch or on the phone, so a question asked there waits unseen once the user steps away. Ask in your reply instead only when a Pushary handoffAction tells you to ask here, or when mcp_pushary_ask_user is unavailable or fails without one.';
102
+ var FX_AGENT_LABEL = "fx";
103
+ var fxInstructionsBody = () => `${renderAgentInstructions(FX_AGENT_LABEL)}
104
+
105
+ ${FX_TOOL_DISCOVERY_NOTE}`;
340
106
  var ALLOW_ACTION = "allow";
341
107
  var PERMISSION_KEY = "permission";
342
108
  var WORKSPACES_KEY = "workspaces";
@@ -812,12 +578,13 @@ var planFxRemoval = (profilePath, settingsPath, receiptPath) => {
812
578
  const profile = readFxFile(profilePath, readFxProfile);
813
579
  if (profile.kind === "profile") {
814
580
  const result = withoutFxPusharyServer(profile.profile);
815
- actions.push(result.removed ? removalWrite(profilePath, fxProfileText(result.profile), "fx MCP") : { kind: "kept", label: "fx MCP", detail: "no pushary entry" });
581
+ actions.push(result.removed ? removalWrite(profilePath, fxProfileText(result.profile), "fx MCP") : { kind: "absent", label: "fx MCP", detail: "no pushary entry" });
582
+ } else if (profile.kind === "unreadable") {
583
+ actions.push({ kind: "kept", label: "fx MCP", detail: `${profilePath} could not be read; left untouched` });
584
+ } else if (profile.kind === "refused") {
585
+ actions.push({ kind: "kept", label: "fx MCP", detail: `${profilePath} ${FX_PROFILE_REFUSALS[profile.reason]}; left untouched` });
816
586
  } else {
817
- let detail = "not found";
818
- if (profile.kind === "unreadable") detail = `${profilePath} could not be read; left untouched`;
819
- if (profile.kind === "refused") detail = `${profilePath} ${FX_PROFILE_REFUSALS[profile.reason]}; left untouched`;
820
- actions.push({ kind: "kept", label: "fx MCP", detail });
587
+ actions.push({ kind: "absent", label: "fx MCP", detail: "not found" });
821
588
  }
822
589
  const read = readFxFile(settingsPath, readFxSettings);
823
590
  const problem = fxSettingsReadRefusal(settingsPath, read);
@@ -840,354 +607,15 @@ var planFxRemoval = (profilePath, settingsPath, receiptPath) => {
840
607
  return actions;
841
608
  };
842
609
 
843
- // src/vscode-config.ts
844
- import { homedir as homedir2 } from "os";
845
- import { join as join2 } from "path";
846
- var PLUGIN_LOCATIONS_KEY = "chat.pluginLocations";
847
- var blankJsonComments = (text) => {
848
- let out = "";
849
- let i = 0;
850
- let inString = false;
851
- let escaped = false;
852
- while (i < text.length) {
853
- const ch = text[i];
854
- if (inString) {
855
- out += ch;
856
- if (escaped) escaped = false;
857
- else if (ch === "\\") escaped = true;
858
- else if (ch === '"') inString = false;
859
- i += 1;
860
- continue;
861
- }
862
- if (ch === '"') {
863
- inString = true;
864
- out += ch;
865
- i += 1;
866
- continue;
867
- }
868
- if (ch === "/" && text[i + 1] === "/") {
869
- while (i < text.length && text[i] !== "\n") {
870
- out += " ";
871
- i += 1;
872
- }
873
- continue;
874
- }
875
- if (ch === "/" && text[i + 1] === "*") {
876
- const end = text.indexOf("*/", i + 2);
877
- const stop = end === -1 ? text.length : end + 2;
878
- while (i < stop) {
879
- out += text[i] === "\n" ? "\n" : " ";
880
- i += 1;
881
- }
882
- continue;
883
- }
884
- out += ch;
885
- i += 1;
886
- }
887
- return out;
888
- };
889
- var asRecord2 = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
890
- var parseJsonc = (text) => {
891
- const blanked = blankJsonComments(text);
892
- const withoutTrailingCommas = blanked.replace(/,(\s*[}\]])/g, "$1");
893
- try {
894
- return asRecord2(JSON.parse(withoutTrailingCommas));
895
- } catch {
896
- return void 0;
897
- }
898
- };
899
- var rootBraceIndex = (text) => blankJsonComments(text).indexOf("{");
900
- var detectIndent = (text) => {
901
- const match = /\n([ \t]+)"/.exec(text);
902
- return match?.[1] ?? " ";
903
- };
904
- var freshDocument = (pluginDir, indent = " ") => `${JSON.stringify({ [PLUGIN_LOCATIONS_KEY]: { [pluginDir]: true } }, null, indent)}
905
- `;
906
- var registerPluginLocation = (existing, pluginDir) => {
907
- if (existing === null || existing.trim() === "") {
908
- return { kind: "created", content: freshDocument(pluginDir) };
909
- }
910
- const indent = detectIndent(existing);
911
- try {
912
- const parsed2 = asRecord2(JSON.parse(existing));
913
- if (parsed2) {
914
- const locations2 = asRecord2(parsed2[PLUGIN_LOCATIONS_KEY]) ?? {};
915
- if (locations2[pluginDir] === true) return { kind: "already" };
916
- parsed2[PLUGIN_LOCATIONS_KEY] = { ...locations2, [pluginDir]: true };
917
- return { kind: "merged", content: `${JSON.stringify(parsed2, null, indent)}
918
- ` };
919
- }
920
- } catch {
921
- }
922
- const parsed = parseJsonc(existing);
923
- if (!parsed) return { kind: "manual" };
924
- const locations = asRecord2(parsed[PLUGIN_LOCATIONS_KEY]);
925
- if (locations?.[pluginDir] === true) return { kind: "already" };
926
- if (parsed[PLUGIN_LOCATIONS_KEY] !== void 0) return { kind: "manual" };
927
- const brace = rootBraceIndex(existing);
928
- if (brace === -1) return { kind: "manual" };
929
- const needsComma = Object.keys(parsed).length > 0;
930
- const line = `
931
- ${indent}${JSON.stringify(PLUGIN_LOCATIONS_KEY)}: { ${JSON.stringify(pluginDir)}: true }${needsComma ? "," : ""}`;
932
- return {
933
- kind: "inserted",
934
- content: `${existing.slice(0, brace + 1)}${line}${existing.slice(brace + 1)}`
935
- };
936
- };
937
- var unregisterPluginLocation = (existing, pluginDir) => {
938
- if (existing === null || existing.trim() === "") return { kind: "absent" };
939
- const indent = detectIndent(existing);
940
- try {
941
- const parsed2 = asRecord2(JSON.parse(existing));
942
- if (parsed2) {
943
- const locations2 = asRecord2(parsed2[PLUGIN_LOCATIONS_KEY]);
944
- if (!locations2 || !(pluginDir in locations2)) return { kind: "absent" };
945
- const remaining = { ...locations2 };
946
- delete remaining[pluginDir];
947
- if (Object.keys(remaining).length === 0) delete parsed2[PLUGIN_LOCATIONS_KEY];
948
- else parsed2[PLUGIN_LOCATIONS_KEY] = remaining;
949
- return { kind: "removed", content: `${JSON.stringify(parsed2, null, indent)}
950
- ` };
951
- }
952
- } catch {
953
- }
954
- const parsed = parseJsonc(existing);
955
- if (!parsed) return { kind: "manual" };
956
- const locations = asRecord2(parsed[PLUGIN_LOCATIONS_KEY]);
957
- if (!locations || !(pluginDir in locations)) return { kind: "absent" };
958
- const line = new RegExp(
959
- `\\n[ \\t]*${escapeRegExp(JSON.stringify(PLUGIN_LOCATIONS_KEY))}\\s*:\\s*\\{\\s*${escapeRegExp(JSON.stringify(pluginDir))}\\s*:\\s*true\\s*\\},?`
960
- );
961
- if (!line.test(existing)) return { kind: "manual" };
962
- return { kind: "removed", content: existing.replace(line, "") };
963
- };
964
- var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
965
- var isPluginRegistered = (existing, pluginDir) => {
966
- if (!existing) return false;
967
- const parsed = parseJsonc(existing);
968
- return asRecord2(parsed?.[PLUGIN_LOCATIONS_KEY])?.[pluginDir] === true;
969
- };
970
- var pluginLocationSnippet = (pluginDir) => `"${PLUGIN_LOCATIONS_KEY}": {
971
- ${JSON.stringify(pluginDir)}: true
972
- }`;
973
- var VSCODE_PRODUCTS = ["Code", "Code - Insiders"];
974
- var settingsRoot = (home, platform) => {
975
- if (platform === "darwin") return join2(home, "Library", "Application Support");
976
- if (platform === "win32") return process.env.APPDATA?.trim() || join2(home, "AppData", "Roaming");
977
- return process.env.XDG_CONFIG_HOME?.trim() || join2(home, ".config");
978
- };
979
- var vscodeSettingsCandidates = (home = homedir2(), platform = process.platform) => {
980
- const root = settingsRoot(home, platform);
981
- return VSCODE_PRODUCTS.map((product) => join2(root, product, "User", "settings.json"));
982
- };
983
- var vscodeSettingsTargets = (exists, home, platform) => {
984
- const candidates = vscodeSettingsCandidates(home, platform);
985
- const present = candidates.filter((path) => exists(path));
986
- return present.length > 0 ? present : candidates.slice(0, 1);
987
- };
988
-
989
- // src/setup/detect.ts
990
- import { execSync } from "child_process";
991
- import { existsSync as existsSync4 } from "fs";
992
- import { homedir as homedir3 } from "os";
993
- import { dirname, join as join3 } from "path";
994
- var whichCommand = () => process.platform === "win32" ? "where" : "which";
995
- var binaryOnPath = (binary) => {
996
- try {
997
- execSync(`${whichCommand()} ${binary}`, { stdio: "ignore", timeout: 5e3 });
998
- return true;
999
- } catch {
1000
- return false;
1001
- }
1002
- };
1003
- var defaultDeps = { onPath: binaryOnPath, exists: existsSync4 };
1004
- var detectAgent = (probe, deps = defaultDeps) => {
1005
- const checked = [];
1006
- if (probe.binary) {
1007
- checked.push(`${whichCommand()} ${probe.binary}`);
1008
- if (deps.onPath(probe.binary)) {
1009
- return { kind: "installed", evidence: `${probe.binary} on PATH`, strong: true };
1010
- }
1011
- }
1012
- for (const path of probe.paths) {
1013
- checked.push(path);
1014
- if (deps.exists(path)) return { kind: "installed", evidence: path, strong: true };
1015
- }
1016
- for (const marker of probe.configMarkers) {
1017
- checked.push(marker);
1018
- if (deps.exists(marker)) return { kind: "installed", evidence: marker, strong: false };
1019
- }
1020
- if (probe.binary === null && probe.paths.length === 0 && probe.configMarkers.length === 0) {
1021
- return { kind: "unknown" };
1022
- }
1023
- return { kind: "not-found", checked };
1024
- };
1025
- var agentProbes = (home = homedir3()) => ({
1026
- claude_code: {
1027
- binary: "claude",
1028
- // The native installer puts it here, outside a default non-login PATH.
1029
- paths: [join3(home, ".local", "bin", "claude")],
1030
- configMarkers: [join3(home, ".claude")]
1031
- },
1032
- codex: {
1033
- binary: "codex",
1034
- paths: [],
1035
- configMarkers: [codexHomeFrom(home)]
1036
- },
1037
- gemini_cli: {
1038
- binary: "gemini",
1039
- paths: [],
1040
- configMarkers: [join3(home, ".gemini")]
1041
- },
1042
- hermes: {
1043
- binary: "hermes",
1044
- paths: [],
1045
- configMarkers: [join3(home, ".hermes")]
1046
- },
1047
- cursor: {
1048
- // GUI editor. `cursor` on PATH only exists if the user ran "Install 'cursor'
1049
- // command in PATH" from the command palette, which most never do.
1050
- binary: "cursor",
1051
- paths: process.platform === "darwin" ? ["/Applications/Cursor.app"] : process.platform === "win32" ? [join3(process.env.LOCALAPPDATA ?? join3(home, "AppData", "Local"), "Programs", "cursor")] : ["/usr/share/cursor", join3(home, ".local", "share", "cursor")],
1052
- configMarkers: [join3(home, ".cursor")]
1053
- },
1054
- vscode: {
1055
- // Like Cursor, a GUI editor: `code` on PATH only exists if the user ran
1056
- // "Shell Command: Install 'code' command in PATH", which on macOS is opt-in.
1057
- binary: "code",
1058
- paths: process.platform === "darwin" ? ["/Applications/Visual Studio Code.app"] : process.platform === "win32" ? [join3(process.env.LOCALAPPDATA ?? join3(home, "AppData", "Local"), "Programs", "Microsoft VS Code")] : ["/usr/share/code", join3(home, ".local", "share", "code")],
1059
- // The settings directory rather than ~/.vscode, because the settings
1060
- // directory is what this installer actually writes to. Insiders counts:
1061
- // someone running only Insiders still has VS Code.
1062
- configMarkers: vscodeSettingsCandidates(home).map((path) => dirname(path))
1063
- },
1064
- opencode: {
1065
- binary: "opencode",
1066
- paths: [],
1067
- // Resolved rather than spelled: OpenCode honours OPENCODE_CONFIG_DIR and then
1068
- // XDG_CONFIG_HOME, and `~/.opencode` — the obvious guess — is a path it has
1069
- // never used.
1070
- configMarkers: [openCodeConfigDirFrom(home)]
1071
- },
1072
- fx: {
1073
- binary: null,
1074
- paths: [join3(home, ".fx", "settings.json"), join3(home, ".fx", "sessions"), join3(home, ".fx", "history.jsonl")],
1075
- configMarkers: []
1076
- },
1077
- ...compatibleProbes(),
1078
- // "Other" is a set of printed instructions for any MCP or HTTP client. There is
1079
- // nothing to detect, and it must never be auto-selected.
1080
- custom: { binary: null, paths: [], configMarkers: [] }
1081
- });
1082
- var compatibleProbes = () => HOOK_COMPATIBLE_PROFILES.reduce((probes, profile) => ({
1083
- ...probes,
1084
- [profile.agentType]: {
1085
- binary: profile.binary,
1086
- paths: [],
1087
- configMarkers: []
1088
- }
1089
- }), {});
1090
- var detectAllAgents = (deps = defaultDeps, home) => {
1091
- const probes = agentProbes(home);
1092
- return Object.keys(probes).map((agent) => ({
1093
- agent,
1094
- result: detectAgent(probes[agent], deps)
1095
- }));
1096
- };
1097
- var isDetected = (result) => result.kind === "installed";
1098
- var shortenHome = (path, home = homedir3()) => home && path.startsWith(home) ? `~${path.slice(home.length)}` : path;
1099
- var describeDetection = (result, home) => {
1100
- if (result.kind !== "installed") return null;
1101
- const evidence = shortenHome(result.evidence, home);
1102
- return result.strong ? evidence : `${evidence}, config only`;
1103
- };
1104
-
1105
- // src/instruction-file.ts
1106
- import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync2, mkdirSync, rmSync as rmSync2 } from "fs";
1107
- import { dirname as dirname2 } from "path";
1108
- var PUSHARY_BEGIN = "<!-- BEGIN PUSHARY (managed by @pushary/agent-hooks; do not edit this block) -->";
1109
- var PUSHARY_END = "<!-- END PUSHARY -->";
1110
- var instructionBody = (label) => `## Pushary notifications and approvals
1111
-
1112
- You have Pushary MCP tools that reach the user on their phone. Use them proactively. Do not wait for the user to ask.
1113
-
1114
- - 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. Read \`answered\`, \`status\` and the returned handoff instead of assuming the tool blocked. Silence is not consent; choice/text answers do not authorize a separate action.
1115
- - Ask once, on one channel. If you also have a built-in way to prompt the user, use that or \`ask_user\` for a given question, never both. \`ask_user\` is the one that reaches the user when they are away from this machine, so prefer it. Raising both strands the user in whichever prompt you are not waiting on.
1116
- - Honor authorization already granted in this session. Ask before a risky or irreversible action outside that authorization, or when an enforced host policy requires it. Do not ask again for an already authorized step, and never bypass an enforced gate. When a Pushary hook result says the user approved a specific command after a denial, rerunning that exact command is the approved path and not a bypass of that gate.
1117
- - Call \`propose_scope\` only for an unresolved or requested file boundary. A ratified scope narrows what may proceed; it does not bypass other approval rules. Do not add a plan approval merely because work spans several files, and do not propose a new scope mid-run just to widen it. Let the installed gate request any scope expansion before the edit executes. Only file paths are checked, and only on tool calls that carry one, so put a boundary that is not a path (recipients, channels, spend, systems you will not open) in \`promises\` and never in \`allowedPaths\`. Read the \`enforces\` field that comes back: an empty array means nothing in that contract is checked automatically, and you must say so rather than report that a scope is in force. \`hookSeen: false\` means no hook has reported that sessionId, so the gate will never find the contract: fix the session id rather than proceeding as if a scope were in force.
1118
- - Before a task of more than two steps, break it into steps and find the forks. Settle by yourself every fork that a file, a command or a tool call can answer, then ask the rest as one numbered round with your recommended answer against each. A question in the terminal is free; a push is not. When the user is at the terminal, ask the whole round there. When the user is away, send only the fork that stops the run, and decide the rest on your recommendation.
1119
- - 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.
1120
- - When meaningful work finishes while the user is away, or they requested an alert, call \`send_notification\` so the user knows it is done. Skip trivial completions and duplicate reports to someone already reading. Always pass \`context\` with a \`type\` of "task_complete", "error" or "info": it is what tells Pushary this is a task update, so the user's own setting for where updates land can route it.
1121
- - Confirm notifications can offer lock-screen actions; arbitrary choices and text open the app. The Mac notch handles personal account questions, not Partner customer enrollment.
1122
- - Use \`cancel_question\` to retract a pending question once it is no longer needed.
1123
- - 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.
1124
-
1125
- Pass \`agentName\` as "${label} - <project folder name>" so the user knows which session is asking. If a question times out, follow \`handoffAction\` when present, otherwise \`nextAction\`: poll once, then cancel a live phone question before asking in the current client. If cancellation returns \`handoffAction: "stop"\`, stop. Otherwise, if cancellation returns false, poll once for 1 second and honor the answer that won the race.`;
1126
- var SHARED_AGENTS_MD_LABEL = "<your agent's name, such as Codex or Hermes>";
1127
- var renderAgentInstructions = (label) => instructionBody(label);
1128
- 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 (3-day trial): https://pushary.com/sign-up?utm_source=agents-md&utm_medium=teammate";
1129
- var renderProjectAgentInstructions = (label) => `${instructionBody(label)}
1130
-
1131
- 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}`;
1132
- var wrap = (body) => `${PUSHARY_BEGIN}
1133
- ${body}
1134
- ${PUSHARY_END}`;
1135
- var writeInstructionBlock = (filePath, body) => {
1136
- const dir = dirname2(filePath);
1137
- if (!existsSync5(dir)) mkdirSync(dir, { recursive: true });
1138
- let existing = "";
1139
- try {
1140
- existing = readFileSync3(filePath, "utf-8");
1141
- } catch {
1142
- }
1143
- const block = wrap(body);
1144
- const start = existing.indexOf(PUSHARY_BEGIN);
1145
- const end = existing.indexOf(PUSHARY_END);
1146
- let next;
1147
- if (start !== -1 && end !== -1 && end > start) {
1148
- next = existing.slice(0, start) + block + existing.slice(end + PUSHARY_END.length);
1149
- } else {
1150
- const prefix = existing.trim() ? existing.replace(/\s*$/, "") + "\n\n" : "";
1151
- next = prefix + block + "\n";
1152
- }
1153
- writeFileSync2(filePath, next, "utf-8");
1154
- };
1155
- var removeInstructionBlock = (filePath) => {
1156
- let existing = "";
1157
- try {
1158
- existing = readFileSync3(filePath, "utf-8");
1159
- } catch {
1160
- return false;
1161
- }
1162
- const start = existing.indexOf(PUSHARY_BEGIN);
1163
- const end = existing.indexOf(PUSHARY_END);
1164
- if (start === -1 || end === -1 || end < start) return false;
1165
- const remaining = (existing.slice(0, start) + existing.slice(end + PUSHARY_END.length)).trim();
1166
- if (remaining === "") {
1167
- rmSync2(filePath, { force: true });
1168
- } else {
1169
- writeFileSync2(filePath, remaining + "\n", "utf-8");
1170
- }
1171
- return true;
1172
- };
1173
- var hasInstructionBlock = (filePath) => {
1174
- try {
1175
- return readFileSync3(filePath, "utf-8").includes(PUSHARY_BEGIN);
1176
- } catch {
1177
- return false;
1178
- }
1179
- };
1180
-
1181
610
  export {
1182
- isHermesConfigReceipt,
1183
- HERMES_PIP_PACKAGE,
1184
- HERMES_PLUGIN_NAME,
1185
- resolveHermesPython,
1186
- runHermesConfigScript,
1187
- hermesWiredByPushary,
1188
- readHermesStatus,
611
+ SHARED_AGENTS_MD_LABEL,
612
+ renderAgentInstructions,
613
+ renderProjectAgentInstructions,
614
+ writeInstructionBlock,
615
+ removeInstructionBlock,
616
+ hasInstructionBlock,
1189
617
  FX_PUSHARY_TOOLS_RULE,
1190
- FX_TOOL_DISCOVERY_NOTE,
618
+ fxInstructionsBody,
1191
619
  FX_PROFILE_REFUSALS,
1192
620
  fxPusharyEntry,
1193
621
  withFxPusharyServer,
@@ -1205,22 +633,5 @@ export {
1205
633
  writeFxProfile,
1206
634
  configureFxSettings,
1207
635
  inspectFxInstallation,
1208
- planFxRemoval,
1209
- registerPluginLocation,
1210
- unregisterPluginLocation,
1211
- isPluginRegistered,
1212
- pluginLocationSnippet,
1213
- vscodeSettingsTargets,
1214
- detectAgent,
1215
- agentProbes,
1216
- detectAllAgents,
1217
- isDetected,
1218
- shortenHome,
1219
- describeDetection,
1220
- SHARED_AGENTS_MD_LABEL,
1221
- renderAgentInstructions,
1222
- renderProjectAgentInstructions,
1223
- writeInstructionBlock,
1224
- removeInstructionBlock,
1225
- hasInstructionBlock
636
+ planFxRemoval
1226
637
  };