pushary 1.8.0

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 (186) hide show
  1. package/CHANGELOG.md +1943 -0
  2. package/LICENSE +21 -0
  3. package/README.md +330 -0
  4. package/data/SKILL.md +591 -0
  5. package/data/cowork/SKILL.md +77 -0
  6. package/data/cursor-plugin/.cursor-plugin/plugin.json +25 -0
  7. package/data/cursor-plugin/CHANGELOG.md +70 -0
  8. package/data/cursor-plugin/CONTRIBUTING.md +40 -0
  9. package/data/cursor-plugin/LICENSE +21 -0
  10. package/data/cursor-plugin/README.md +113 -0
  11. package/data/cursor-plugin/SECURITY.md +33 -0
  12. package/data/cursor-plugin/assets/logo.png +0 -0
  13. package/data/cursor-plugin/commands/notify-when-done.md +14 -0
  14. package/data/cursor-plugin/commands/pushary-test.md +13 -0
  15. package/data/cursor-plugin/hooks/hooks.json +75 -0
  16. package/data/cursor-plugin/mcp.json +11 -0
  17. package/data/cursor-plugin/rules/pushary.mdc +40 -0
  18. package/data/cursor-plugin/scripts/pushary-gate.mjs +724 -0
  19. package/data/cursor-plugin/scripts/pushary-gate.test.mjs +137 -0
  20. package/data/cursor-plugin/scripts/redaction.mjs +51 -0
  21. package/data/cursor-plugin/skills/pushary/SKILL.md +584 -0
  22. package/data/vscode-plugin/.claude-plugin/plugin.json +28 -0
  23. package/data/vscode-plugin/.mcp.json +11 -0
  24. package/data/vscode-plugin/CHANGELOG.md +49 -0
  25. package/data/vscode-plugin/CONTRIBUTING.md +40 -0
  26. package/data/vscode-plugin/LICENSE +21 -0
  27. package/data/vscode-plugin/README.md +128 -0
  28. package/data/vscode-plugin/SECURITY.md +56 -0
  29. package/data/vscode-plugin/assets/logo.png +0 -0
  30. package/data/vscode-plugin/commands/notify-when-done.md +14 -0
  31. package/data/vscode-plugin/commands/pushary-test.md +13 -0
  32. package/data/vscode-plugin/hooks/hooks.json +60 -0
  33. package/data/vscode-plugin/scripts/pushary-gate.mjs +762 -0
  34. package/data/vscode-plugin/scripts/redaction.mjs +51 -0
  35. package/data/vscode-plugin/skills/pushary/SKILL.md +584 -0
  36. package/dist/bin/pushary-bell-hook.d.ts +1 -0
  37. package/dist/bin/pushary-bell-hook.js +46 -0
  38. package/dist/bin/pushary-bell.d.ts +1 -0
  39. package/dist/bin/pushary-bell.js +146 -0
  40. package/dist/bin/pushary-claude.d.ts +1 -0
  41. package/dist/bin/pushary-claude.js +1916 -0
  42. package/dist/bin/pushary-clean.d.ts +1 -0
  43. package/dist/bin/pushary-clean.js +1300 -0
  44. package/dist/bin/pushary-codex-bridge.d.ts +1 -0
  45. package/dist/bin/pushary-codex-bridge.js +599 -0
  46. package/dist/bin/pushary-codex-hook.d.ts +1 -0
  47. package/dist/bin/pushary-codex-hook.js +886 -0
  48. package/dist/bin/pushary-codex.d.ts +1 -0
  49. package/dist/bin/pushary-codex.js +125 -0
  50. package/dist/bin/pushary-connect.d.ts +1 -0
  51. package/dist/bin/pushary-connect.js +100 -0
  52. package/dist/bin/pushary-cowork.d.ts +1 -0
  53. package/dist/bin/pushary-cowork.js +36 -0
  54. package/dist/bin/pushary-daemon-supervisor.d.ts +1 -0
  55. package/dist/bin/pushary-daemon-supervisor.js +27 -0
  56. package/dist/bin/pushary-daemon.d.ts +1 -0
  57. package/dist/bin/pushary-daemon.js +878 -0
  58. package/dist/bin/pushary-disconnect.d.ts +1 -0
  59. package/dist/bin/pushary-disconnect.js +264 -0
  60. package/dist/bin/pushary-doctor.d.ts +1 -0
  61. package/dist/bin/pushary-doctor.js +1433 -0
  62. package/dist/bin/pushary-elicitation-hook.d.ts +1 -0
  63. package/dist/bin/pushary-elicitation-hook.js +149 -0
  64. package/dist/bin/pushary-gemini-bridge.d.ts +1 -0
  65. package/dist/bin/pushary-gemini-bridge.js +339 -0
  66. package/dist/bin/pushary-gemini-hook.d.ts +1 -0
  67. package/dist/bin/pushary-gemini-hook.js +381 -0
  68. package/dist/bin/pushary-hook.d.ts +1 -0
  69. package/dist/bin/pushary-hook.js +95 -0
  70. package/dist/bin/pushary-login.d.ts +1 -0
  71. package/dist/bin/pushary-login.js +198 -0
  72. package/dist/bin/pushary-logout.d.ts +1 -0
  73. package/dist/bin/pushary-logout.js +147 -0
  74. package/dist/bin/pushary-mcp.d.ts +1 -0
  75. package/dist/bin/pushary-mcp.js +114 -0
  76. package/dist/bin/pushary-mode.d.ts +1 -0
  77. package/dist/bin/pushary-mode.js +130 -0
  78. package/dist/bin/pushary-notification-hook.d.ts +1 -0
  79. package/dist/bin/pushary-notification-hook.js +56 -0
  80. package/dist/bin/pushary-opencode-hook.d.ts +1 -0
  81. package/dist/bin/pushary-opencode-hook.js +338 -0
  82. package/dist/bin/pushary-permission-denied-hook.d.ts +1 -0
  83. package/dist/bin/pushary-permission-denied-hook.js +60 -0
  84. package/dist/bin/pushary-permission-hook.d.ts +1 -0
  85. package/dist/bin/pushary-permission-hook.js +65 -0
  86. package/dist/bin/pushary-post-hook.d.ts +1 -0
  87. package/dist/bin/pushary-post-hook.js +70 -0
  88. package/dist/bin/pushary-prompt-hook.d.ts +1 -0
  89. package/dist/bin/pushary-prompt-hook.js +61 -0
  90. package/dist/bin/pushary-session-end-hook.d.ts +1 -0
  91. package/dist/bin/pushary-session-end-hook.js +59 -0
  92. package/dist/bin/pushary-session-start-hook.d.ts +1 -0
  93. package/dist/bin/pushary-session-start-hook.js +72 -0
  94. package/dist/bin/pushary-setup.d.ts +1 -0
  95. package/dist/bin/pushary-setup.js +2660 -0
  96. package/dist/bin/pushary-stats.d.ts +1 -0
  97. package/dist/bin/pushary-stats.js +44 -0
  98. package/dist/bin/pushary-status.d.ts +1 -0
  99. package/dist/bin/pushary-status.js +262 -0
  100. package/dist/bin/pushary-stop-hook.d.ts +1 -0
  101. package/dist/bin/pushary-stop-hook.js +63 -0
  102. package/dist/bin/pushary-stopfailure-hook.d.ts +1 -0
  103. package/dist/bin/pushary-stopfailure-hook.js +56 -0
  104. package/dist/bin/pushary-suggestions.d.ts +1 -0
  105. package/dist/bin/pushary-suggestions.js +100 -0
  106. package/dist/bin/pushary-transcript-register.d.ts +1 -0
  107. package/dist/bin/pushary-transcript-register.js +40 -0
  108. package/dist/bin/pushary-transcripts.d.ts +1 -0
  109. package/dist/bin/pushary-transcripts.js +77 -0
  110. package/dist/bin/pushary-upgrade.d.ts +1 -0
  111. package/dist/bin/pushary-upgrade.js +599 -0
  112. package/dist/bin/pushary-wait.d.ts +1 -0
  113. package/dist/bin/pushary-wait.js +122 -0
  114. package/dist/bin/pushary.d.ts +1 -0
  115. package/dist/bin/pushary.js +74 -0
  116. package/dist/chunk-2ABTSGFT.js +173 -0
  117. package/dist/chunk-2OY3ZZ5N.js +124 -0
  118. package/dist/chunk-3EGEA4KH.js +44 -0
  119. package/dist/chunk-3EVPNIBE.js +185 -0
  120. package/dist/chunk-5OP5MQI7.js +45 -0
  121. package/dist/chunk-6J2JC2RT.js +149 -0
  122. package/dist/chunk-7QLSKOSU.js +19 -0
  123. package/dist/chunk-7Z7Q4GGS.js +88 -0
  124. package/dist/chunk-A2A2YTMG.js +835 -0
  125. package/dist/chunk-AHV4LNB5.js +377 -0
  126. package/dist/chunk-AXPCESYO.js +197 -0
  127. package/dist/chunk-C2WCPBF7.js +86 -0
  128. package/dist/chunk-CJVVKOSR.js +73 -0
  129. package/dist/chunk-CULUZTWQ.js +2117 -0
  130. package/dist/chunk-CVQYGMSR.js +142 -0
  131. package/dist/chunk-CVWG2N3Y.js +16 -0
  132. package/dist/chunk-D2FX3EPW.js +15 -0
  133. package/dist/chunk-DB3ONZB4.js +44 -0
  134. package/dist/chunk-DE4Y6TCC.js +160 -0
  135. package/dist/chunk-E4FJTUH4.js +249 -0
  136. package/dist/chunk-EPCXUP3P.js +41 -0
  137. package/dist/chunk-EX3GAPA4.js +44 -0
  138. package/dist/chunk-EYK3GSRH.js +143 -0
  139. package/dist/chunk-GMXKITVA.js +70 -0
  140. package/dist/chunk-GPEGOGRJ.js +49 -0
  141. package/dist/chunk-GU3EJCVV.js +43 -0
  142. package/dist/chunk-HQ6G3B5R.js +59 -0
  143. package/dist/chunk-HZVVNGEW.js +22 -0
  144. package/dist/chunk-IPVKH2ST.js +231 -0
  145. package/dist/chunk-J5TIV3J6.js +238 -0
  146. package/dist/chunk-JU6W3XAU.js +64 -0
  147. package/dist/chunk-JYG4B33G.js +227 -0
  148. package/dist/chunk-JZTHGAPA.js +503 -0
  149. package/dist/chunk-KGDWDSNL.js +102 -0
  150. package/dist/chunk-KVQBWI5T.js +99 -0
  151. package/dist/chunk-KZERVKTD.js +16 -0
  152. package/dist/chunk-LXQ5FBBD.js +47 -0
  153. package/dist/chunk-M5ICYGHT.js +138 -0
  154. package/dist/chunk-M5JDZ45W.js +943 -0
  155. package/dist/chunk-MDEPU45E.js +1226 -0
  156. package/dist/chunk-MPWXGONV.js +157 -0
  157. package/dist/chunk-N6IOSZOE.js +185 -0
  158. package/dist/chunk-NGDD6TXY.js +192 -0
  159. package/dist/chunk-NQTHFF4W.js +2830 -0
  160. package/dist/chunk-OKXS7WDZ.js +68 -0
  161. package/dist/chunk-OLQRRFBX.js +21 -0
  162. package/dist/chunk-P7WQEVWA.js +307 -0
  163. package/dist/chunk-POFBE6ZY.js +12 -0
  164. package/dist/chunk-PQ4K74WL.js +30 -0
  165. package/dist/chunk-PUZZELE6.js +37 -0
  166. package/dist/chunk-Q7E4I6UA.js +767 -0
  167. package/dist/chunk-QCGNGEGE.js +15 -0
  168. package/dist/chunk-R7437YI3.js +151 -0
  169. package/dist/chunk-RHR6NARM.js +305 -0
  170. package/dist/chunk-SAXBC4AZ.js +60 -0
  171. package/dist/chunk-SGZJ5LYH.js +76 -0
  172. package/dist/chunk-SIFVFP6T.js +70 -0
  173. package/dist/chunk-SLFABHW3.js +150 -0
  174. package/dist/chunk-T7E75EKA.js +67 -0
  175. package/dist/chunk-TY4JT7W3.js +38 -0
  176. package/dist/chunk-U4TMAANR.js +111 -0
  177. package/dist/chunk-UI36QSBI.js +177 -0
  178. package/dist/chunk-VQKRG3AC.js +339 -0
  179. package/dist/chunk-WE2J62NC.js +1131 -0
  180. package/dist/chunk-XHKBHWLX.js +14 -0
  181. package/dist/chunk-ZSZSSJCV.js +275 -0
  182. package/dist/chunk-ZVSKMPBZ.js +135 -0
  183. package/dist/reapply-CW3MA66V.js +34 -0
  184. package/dist/src/index.d.ts +204 -0
  185. package/dist/src/index.js +64 -0
  186. package/package.json +108 -0
@@ -0,0 +1,339 @@
1
+ import {
2
+ detectClaudeVersion
3
+ } from "./chunk-SIFVFP6T.js";
4
+ import {
5
+ ensureCodexTrustsPusharyHooks
6
+ } from "./chunk-RHR6NARM.js";
7
+ import {
8
+ addClaudeMcpServer,
9
+ addPusharyHooks,
10
+ addPusharyToolPermissions
11
+ } from "./chunk-AXPCESYO.js";
12
+ import {
13
+ claudeUnprovenHolds,
14
+ claudeWired,
15
+ codexUnprovenHolds,
16
+ codexWired,
17
+ geminiWired
18
+ } from "./chunk-6J2JC2RT.js";
19
+ import {
20
+ CLAUDE_HOOK_BINARY,
21
+ CLAUDE_HOOK_EVENTS,
22
+ GEMINI_HOOK_BINARY,
23
+ addGeminiHooks,
24
+ addGeminiMcpServer,
25
+ formatVersion,
26
+ hasGeminiHooks,
27
+ needsReregistration,
28
+ registrationSignatures,
29
+ supportedClaudeEvents
30
+ } from "./chunk-3EVPNIBE.js";
31
+ import {
32
+ CODEX_HOOK_BINARY,
33
+ addCodexHookTrust,
34
+ addCodexHooks,
35
+ addCodexMcpServer,
36
+ claudeRegistrationReceipt,
37
+ codexConfigToml,
38
+ codexHookPositions,
39
+ codexHooksJson,
40
+ codexRegistrationHolder,
41
+ codexVacatedIndexes,
42
+ dropVacatedCodexHookTrust,
43
+ guardBinary,
44
+ hasCodexHooks,
45
+ namesOurBinary,
46
+ registeredCommands,
47
+ registrationHolderOf,
48
+ resolveGlobalBinary,
49
+ vscodePluginMcp
50
+ } from "./chunk-A2A2YTMG.js";
51
+ import {
52
+ readJsonSafe,
53
+ writeFileAtomic,
54
+ writeJsonAtomic
55
+ } from "./chunk-T7E75EKA.js";
56
+
57
+ // src/reapply.ts
58
+ import { dirname, join } from "path";
59
+ import { homedir } from "os";
60
+ import { readFileSync, statSync } from "fs";
61
+ import { parse as parseTOML, stringify as stringifyTOML } from "smol-toml";
62
+
63
+ // src/reregister.ts
64
+ var asRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
65
+ var CLAUDE_CLI_BINARIES = new Set(CLAUDE_HOOK_EVENTS.map((hook) => hook.binary));
66
+ var registrationHolder = (settings) => registrationHolderOf(settings, CLAUDE_CLI_BINARIES);
67
+ var registeredPusharyEvents = (settings) => new Set(
68
+ registeredCommands(settings).filter(({ command }) => namesOurBinary(command, CLAUDE_CLI_BINARIES)).map(({ event }) => event)
69
+ );
70
+ var reregisterVerdict = ({ settings, stored, version }) => {
71
+ const holder = registrationHolder(settings);
72
+ if (holder === "none") return { kind: "not_wired" };
73
+ if (holder === "app") return { kind: "app_owned" };
74
+ const unproven = claudeUnprovenHolds(settings);
75
+ if (unproven.length === 0 && !needsReregistration(stored, version)) return { kind: "current" };
76
+ const supported = new Set(supportedClaudeEvents(version).map((hook) => hook.event));
77
+ const present = registeredPusharyEvents(settings);
78
+ const missing = [...supported].filter((event) => !present.has(event));
79
+ const extra = [...present].filter((event) => !supported.has(event));
80
+ const repairable = unproven.filter((event) => supported.has(event));
81
+ return missing.length > 0 || extra.length > 0 || repairable.length > 0 ? { kind: "stale", version, missing, extra, unproven: repairable } : { kind: "record_only", version };
82
+ };
83
+ var receiptFor = (version, now = /* @__PURE__ */ new Date()) => ({
84
+ signatures: registrationSignatures(supportedClaudeEvents(version), version),
85
+ version: version ? formatVersion(version) : null,
86
+ recordedAt: now.toISOString()
87
+ });
88
+ var storedSignatures = (raw) => {
89
+ const signatures = asRecord(asRecord(raw)?.signatures);
90
+ if (!signatures) return void 0;
91
+ const entries = Object.entries(signatures).filter(
92
+ (pair) => typeof pair[1] === "string"
93
+ );
94
+ return entries.length > 0 ? Object.fromEntries(entries) : void 0;
95
+ };
96
+
97
+ // src/reapply.ts
98
+ var CLAUDE_SETTINGS = join(homedir(), ".claude", "settings.json");
99
+ var CLAUDE_JSON = join(homedir(), ".claude.json");
100
+ var readJson = (filePath) => {
101
+ const result = readJsonSafe(filePath);
102
+ if (result.kind === "ok") return result.value;
103
+ if (result.kind === "missing") return {};
104
+ return null;
105
+ };
106
+ var writeJson = (filePath, data) => writeJsonAtomic(filePath, data);
107
+ var hasPusharyClaudeHooks = (settings) => JSON.stringify(settings.hooks ?? {}).includes(CLAUDE_HOOK_BINARY);
108
+ var hasPusharyMcp = (claudeJson) => !!claudeJson.mcpServers?.pushary;
109
+ var PRIVATE_TO_OWNER = 384;
110
+ var modeToPreserve = (filePath) => {
111
+ try {
112
+ return statSync(filePath).mode & 511;
113
+ } catch {
114
+ return PRIVATE_TO_OWNER;
115
+ }
116
+ };
117
+ var wouldWriteBareNames = (resolve, probe) => resolve(probe) === void 0;
118
+ var reapplyClaudeSettings = (apiKey, paths = {}) => {
119
+ const settingsPath = paths.settingsPath ?? CLAUDE_SETTINGS;
120
+ const claudeJsonPath = paths.claudeJsonPath ?? CLAUDE_JSON;
121
+ const settings = readJson(settingsPath);
122
+ const claudeJson = readJson(claudeJsonPath);
123
+ const configured = settings != null && hasPusharyClaudeHooks(settings) || claudeJson != null && hasPusharyMcp(claudeJson);
124
+ if (!configured) return { configured: false, reapplied: false, hooks: false, mcp: false };
125
+ const settingsWritable = settings != null;
126
+ const claudeJsonWritable = claudeJson != null;
127
+ let hooks = false;
128
+ let mcp = false;
129
+ let failed = false;
130
+ try {
131
+ if (!settingsWritable) throw new Error("settings.json could not be parsed");
132
+ const s = settings;
133
+ addPusharyToolPermissions(s);
134
+ const binary = (paths.resolveBinary ?? resolveGlobalBinary)(CLAUDE_HOOK_BINARY);
135
+ addPusharyHooks(s, binary ? dirname(binary) : void 0, (paths.detectVersion ?? detectClaudeVersion)());
136
+ writeJson(settingsPath, s);
137
+ hooks = true;
138
+ } catch {
139
+ failed = true;
140
+ }
141
+ if (apiKey) {
142
+ try {
143
+ if (!claudeJsonWritable) throw new Error(".claude.json could not be parsed");
144
+ const cj = claudeJson;
145
+ addClaudeMcpServer(cj, apiKey);
146
+ writeJson(claudeJsonPath, cj);
147
+ mcp = true;
148
+ } catch {
149
+ failed = true;
150
+ }
151
+ }
152
+ return { configured: true, reapplied: hooks || mcp, hooks, mcp, failed };
153
+ };
154
+ var reapplyClaudeForVersion = (apiKey, paths = {}) => {
155
+ const idle = { verdict: "current", rewrote: false, missing: [] };
156
+ try {
157
+ const settingsPath = paths.settingsPath ?? CLAUDE_SETTINGS;
158
+ const receiptPath = paths.receiptPath ?? claudeRegistrationReceipt();
159
+ const version = (paths.detectVersion ?? detectClaudeVersion)();
160
+ const receipt = readJsonSafe(receiptPath);
161
+ const verdict = reregisterVerdict({
162
+ settings: readJson(settingsPath),
163
+ stored: storedSignatures(receipt.kind === "ok" ? receipt.value : void 0),
164
+ version
165
+ });
166
+ if (verdict.kind === "not_wired" || verdict.kind === "app_owned" || verdict.kind === "current") {
167
+ return { verdict: verdict.kind, rewrote: false, missing: [] };
168
+ }
169
+ const resolveBinary = paths.resolveBinary ?? resolveGlobalBinary;
170
+ if (verdict.kind === "stale" && wouldWriteBareNames(resolveBinary, CLAUDE_HOOK_BINARY)) {
171
+ return { verdict: "stale", rewrote: false, missing: verdict.missing };
172
+ }
173
+ const rewrote = verdict.kind === "stale" ? reapplyClaudeSettings(apiKey, { ...paths, settingsPath }).hooks : false;
174
+ if (verdict.kind === "stale" && !rewrote) return { verdict: "stale", rewrote: false, missing: verdict.missing };
175
+ writeJsonAtomic(receiptPath, receiptFor(version));
176
+ return {
177
+ verdict: verdict.kind,
178
+ rewrote,
179
+ missing: verdict.kind === "stale" ? verdict.missing : []
180
+ };
181
+ } catch {
182
+ return idle;
183
+ }
184
+ };
185
+ var readToml = (filePath) => {
186
+ try {
187
+ const raw = readFileSync(filePath, "utf-8");
188
+ return raw.trim() === "" ? {} : parseTOML(raw);
189
+ } catch {
190
+ return null;
191
+ }
192
+ };
193
+ var inspectConfiguredManagedProviders = (paths = {}) => {
194
+ const providers = [];
195
+ const claudeSettings = readJson(paths.claudeSettingsPath ?? CLAUDE_SETTINGS);
196
+ const claudeJson = readJson(paths.claudeJsonPath ?? CLAUDE_JSON);
197
+ if (claudeWired({ claudeJson, settings: claudeSettings, skillExists: false })) {
198
+ providers.push("claude");
199
+ }
200
+ const codexConfig = readToml(paths.codexConfigPath ?? codexConfigToml());
201
+ const codexHooks = readJson(paths.codexHooksPath ?? codexHooksJson());
202
+ if (codexWired({ config: codexConfig, hooks: codexHooks, skillExists: false })) {
203
+ providers.push("codex");
204
+ }
205
+ const gemini = readJson(paths.geminiSettingsPath ?? join(homedir(), ".gemini", "settings.json"));
206
+ if (geminiWired({ settings: gemini })) {
207
+ providers.push("gemini");
208
+ }
209
+ return providers;
210
+ };
211
+ var reapplyCodexSettings = (apiKey, paths = {}) => {
212
+ const configPath = paths.configPath ?? codexConfigToml();
213
+ const hooksPath = paths.hooksPath ?? codexHooksJson();
214
+ const config = readToml(configPath);
215
+ const hooksConfig = readJson(hooksPath);
216
+ const configured = config != null && !!config.mcp_servers?.pushary || hooksConfig != null && hasCodexHooks(hooksConfig);
217
+ if (!configured) return { configured: false, reapplied: false, hooks: false, mcp: false };
218
+ const command = guardBinary((paths.resolveBinary ?? resolveGlobalBinary)(CODEX_HOOK_BINARY) ?? CODEX_HOOK_BINARY);
219
+ let hooks = false;
220
+ let mcp = false;
221
+ let failed = hooksConfig === null || config === null;
222
+ const vacated = codexVacatedIndexes(hooksConfig ?? void 0);
223
+ if (hooksConfig != null) {
224
+ try {
225
+ addCodexHooks(hooksConfig, command);
226
+ writeJson(hooksPath, hooksConfig);
227
+ hooks = true;
228
+ } catch {
229
+ failed = true;
230
+ }
231
+ }
232
+ if (config != null) {
233
+ try {
234
+ if (hooks) {
235
+ dropVacatedCodexHookTrust(config, hooksPath, vacated);
236
+ addCodexHookTrust(config, hooksPath, command, codexHookPositions(hooksConfig ?? void 0));
237
+ }
238
+ if (apiKey) {
239
+ addCodexMcpServer(config, apiKey);
240
+ }
241
+ if (hooks || apiKey) {
242
+ writeFileAtomic(configPath, stringifyTOML(config), modeToPreserve(configPath), "utf-8");
243
+ mcp = Boolean(apiKey);
244
+ }
245
+ } catch {
246
+ failed = true;
247
+ hooks = false;
248
+ }
249
+ }
250
+ if (config === null) hooks = false;
251
+ return { configured: true, reapplied: hooks || mcp, hooks, mcp, failed };
252
+ };
253
+ var repairCodexHolds = (paths = {}) => {
254
+ const idle = { configured: false, reapplied: false, hooks: false, mcp: false };
255
+ try {
256
+ const hooksPath = paths.hooksPath ?? codexHooksJson();
257
+ const hooksConfig = readJson(hooksPath);
258
+ if (!hooksConfig || codexRegistrationHolder(hooksConfig) !== "cli") return idle;
259
+ if (codexUnprovenHolds(hooksConfig).length === 0) return idle;
260
+ if (wouldWriteBareNames(paths.resolveBinary ?? resolveGlobalBinary, CODEX_HOOK_BINARY)) return idle;
261
+ return reapplyCodexSettings(void 0, paths);
262
+ } catch {
263
+ return idle;
264
+ }
265
+ };
266
+ var reapplyGeminiSettings = (apiKey, paths = {}) => {
267
+ const settingsPath = paths.settingsPath ?? join(homedir(), ".gemini", "settings.json");
268
+ const settings = readJson(settingsPath);
269
+ if (settings == null) return { configured: false, reapplied: false, hooks: false, mcp: false };
270
+ const configured = hasGeminiHooks(settings) || !!settings.mcpServers?.pushary;
271
+ if (!configured) return { configured: false, reapplied: false, hooks: false, mcp: false };
272
+ let hooks = false;
273
+ let mcp = false;
274
+ try {
275
+ addGeminiHooks(settings, guardBinary(resolveGlobalBinary(GEMINI_HOOK_BINARY) ?? GEMINI_HOOK_BINARY));
276
+ if (apiKey) {
277
+ addGeminiMcpServer(settings, apiKey);
278
+ }
279
+ writeJson(settingsPath, settings);
280
+ hooks = true;
281
+ mcp = Boolean(apiKey);
282
+ } catch {
283
+ return { configured: true, reapplied: false, hooks: false, mcp: false, failed: true };
284
+ }
285
+ return { configured: true, reapplied: hooks || mcp, hooks, mcp };
286
+ };
287
+ var reapplyPluginMcp = (mcpPath, apiKey) => {
288
+ const mcpConfig = readJson(mcpPath);
289
+ if (mcpConfig == null) return { configured: false, reapplied: false, hooks: false, mcp: false };
290
+ const servers = mcpConfig.mcpServers;
291
+ if (!servers?.pushary) return { configured: false, reapplied: false, hooks: false, mcp: false };
292
+ if (!apiKey) return { configured: true, reapplied: false, hooks: false, mcp: false };
293
+ try {
294
+ addClaudeMcpServer(mcpConfig, apiKey);
295
+ writeJson(mcpPath, mcpConfig);
296
+ return { configured: true, reapplied: true, hooks: false, mcp: true };
297
+ } catch {
298
+ return { configured: true, reapplied: false, hooks: false, mcp: false, failed: true };
299
+ }
300
+ };
301
+ var reapplyCursorPlugin = (apiKey, paths = {}) => reapplyPluginMcp(
302
+ paths.pluginMcpPath ?? join(homedir(), ".cursor", "plugins", "local", "pushary", "mcp.json"),
303
+ apiKey
304
+ );
305
+ var reapplyVsCodePlugin = (apiKey, paths = {}) => reapplyPluginMcp(paths.pluginMcpPath ?? vscodePluginMcp(), apiKey);
306
+ var reapplyAllAgents = (apiKey) => {
307
+ const runners = [
308
+ { id: "claude", label: "Claude Code", run: () => reapplyClaudeSettings(apiKey) },
309
+ { id: "codex", label: "Codex", run: () => reapplyCodexSettings(apiKey) },
310
+ { id: "gemini", label: "Gemini CLI", run: () => reapplyGeminiSettings(apiKey) },
311
+ { id: "cursor", label: "Cursor", run: () => reapplyCursorPlugin(apiKey) },
312
+ { id: "vscode", label: "VS Code", run: () => reapplyVsCodePlugin(apiKey) }
313
+ ];
314
+ const done = [];
315
+ for (const runner of runners) {
316
+ try {
317
+ const result = runner.run();
318
+ if (result.configured) done.push({ id: runner.id, label: runner.label, result });
319
+ } catch {
320
+ done.push({ id: runner.id, label: runner.label, result: { configured: false, reapplied: false, hooks: false, mcp: false, failed: true } });
321
+ }
322
+ }
323
+ return done;
324
+ };
325
+ var isRewrittenCodex = (agent) => agent.id === "codex" && agent.result.hooks;
326
+ var ensureCodexTrustAfterReapply = async (agents, options = {}) => agents.some(isRewrittenCodex) ? ensureCodexTrustsPusharyHooks(options) : null;
327
+
328
+ export {
329
+ reapplyClaudeSettings,
330
+ reapplyClaudeForVersion,
331
+ inspectConfiguredManagedProviders,
332
+ reapplyCodexSettings,
333
+ repairCodexHolds,
334
+ reapplyGeminiSettings,
335
+ reapplyCursorPlugin,
336
+ reapplyVsCodePlugin,
337
+ reapplyAllAgents,
338
+ ensureCodexTrustAfterReapply
339
+ };