@pushary/agent-hooks 1.9.63 → 1.9.65

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 (129) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +1 -1
  3. package/dist/{api-UHUUAONF.js → api-32B3XLJR.js} +10 -11
  4. package/dist/bin/pushary-bell-hook.js +27 -30
  5. package/dist/bin/pushary-bell.js +12 -13
  6. package/dist/bin/pushary-claude.js +28 -31
  7. package/dist/bin/pushary-clean.js +68 -43
  8. package/dist/bin/pushary-codex-bridge.js +22 -24
  9. package/dist/bin/pushary-codex-hook.js +34 -37
  10. package/dist/bin/pushary-codex-session.js +8 -8
  11. package/dist/bin/pushary-codex.js +13 -15
  12. package/dist/bin/pushary-connect.js +26 -29
  13. package/dist/bin/pushary-cowork.js +5 -5
  14. package/dist/bin/pushary-daemon.js +39 -42
  15. package/dist/bin/pushary-disconnect.js +62 -43
  16. package/dist/bin/pushary-doctor.js +109 -44
  17. package/dist/bin/pushary-elicitation-hook.js +27 -30
  18. package/dist/bin/pushary-gemini-bridge.js +16 -18
  19. package/dist/bin/pushary-gemini-hook.js +29 -32
  20. package/dist/bin/pushary-hook.js +31 -34
  21. package/dist/bin/pushary-login.js +19 -20
  22. package/dist/bin/pushary-logout.js +26 -29
  23. package/dist/bin/pushary-mcp.js +11 -12
  24. package/dist/bin/pushary-mode.js +14 -15
  25. package/dist/bin/pushary-notification-hook.js +26 -29
  26. package/dist/bin/pushary-opencode-hook.js +28 -31
  27. package/dist/bin/pushary-permission-denied-hook.js +31 -34
  28. package/dist/bin/pushary-permission-hook.js +30 -33
  29. package/dist/bin/pushary-post-hook.js +26 -29
  30. package/dist/bin/pushary-prompt-hook.js +26 -29
  31. package/dist/bin/pushary-session-end-hook.js +28 -31
  32. package/dist/bin/pushary-session-start-hook.js +35 -38
  33. package/dist/bin/pushary-setup.js +129 -74
  34. package/dist/bin/pushary-stats.js +5 -5
  35. package/dist/bin/pushary-status.js +31 -34
  36. package/dist/bin/pushary-stop-hook.js +26 -29
  37. package/dist/bin/pushary-stopfailure-hook.js +26 -29
  38. package/dist/bin/pushary-suggestions.js +14 -15
  39. package/dist/bin/pushary-transcript-register.js +18 -21
  40. package/dist/bin/pushary-transcripts.js +17 -18
  41. package/dist/bin/pushary-upgrade.js +40 -44
  42. package/dist/bin/pushary-wait.js +14 -15
  43. package/dist/bin/pushary.js +7 -8
  44. package/dist/{chunk-V5W3CK7F.js → chunk-2VADJ6JH.js} +2 -2
  45. package/dist/{chunk-3GVV7XVT.js → chunk-2Z7I7DHT.js} +1 -1
  46. package/dist/{chunk-7GRQGXF4.js → chunk-3KXBRSL3.js} +1 -1
  47. package/dist/{chunk-P6RF4RQN.js → chunk-3LF7T3NW.js} +6 -6
  48. package/dist/{chunk-PXAOEFJZ.js → chunk-3UNAPXED.js} +14 -16
  49. package/dist/{chunk-TMGJAFSD.js → chunk-4LUWNBGD.js} +3 -3
  50. package/dist/{chunk-CLABCSZC.js → chunk-6CZX6YOE.js} +5 -5
  51. package/dist/{chunk-VFJSVPNL.js → chunk-7ILQX47W.js} +3 -3
  52. package/dist/{chunk-4WFAP6QN.js → chunk-ADXHPGBZ.js} +9 -11
  53. package/dist/{chunk-75ODMNOM.js → chunk-AN7C3CHH.js} +1 -1
  54. package/dist/{chunk-BQFL2ECS.js → chunk-ANP3DIST.js} +3 -57
  55. package/dist/chunk-ATPJGHUP.js +1201 -0
  56. package/dist/{chunk-6Z2VR3BA.js → chunk-BAGBCSXA.js} +1 -1
  57. package/dist/{chunk-WUOOZE5S.js → chunk-BEQ3MEE3.js} +2 -2
  58. package/dist/{chunk-ELAK46NR.js → chunk-BKCI53W6.js} +4 -4
  59. package/dist/{chunk-HAIXS4OX.js → chunk-CSKABVSH.js} +3 -3
  60. package/dist/{chunk-GNUARBRZ.js → chunk-CU2PXLZ6.js} +4 -4
  61. package/dist/{chunk-FVERRWDP.js → chunk-CZ65D6Q5.js} +2 -2
  62. package/dist/{chunk-PJ34FOIV.js → chunk-DM24VZOI.js} +5 -5
  63. package/dist/{chunk-TBKHQWIH.js → chunk-DTVHZDYM.js} +5 -5
  64. package/dist/{chunk-PIQ4HHA2.js → chunk-DXMUJTYF.js} +4 -6
  65. package/dist/{chunk-IOH2T3CB.js → chunk-ED2SWTPC.js} +4 -4
  66. package/dist/{chunk-FAF5AW3P.js → chunk-EEVE7H5Z.js} +4 -4
  67. package/dist/{chunk-EHHTQURL.js → chunk-F56GTJFG.js} +5 -5
  68. package/dist/{chunk-GZS72NCF.js → chunk-FFSIYBBU.js} +4 -4
  69. package/dist/{chunk-L5CDGXPO.js → chunk-FWS2KLV2.js} +4 -4
  70. package/dist/{chunk-T3GHXR6N.js → chunk-GA257T2E.js} +5 -5
  71. package/dist/{chunk-SKUSGWFK.js → chunk-GTBWWCCM.js} +6 -6
  72. package/dist/{chunk-YK6GR4GU.js → chunk-HDGB6SQ4.js} +2 -2
  73. package/dist/{chunk-OY6Z4IKB.js → chunk-HIYLAC3C.js} +3 -3
  74. package/dist/{chunk-RAJ3QEIL.js → chunk-HVOQUPSO.js} +1 -1
  75. package/dist/{chunk-KUCL7ETL.js → chunk-I2UBF2SS.js} +1 -1
  76. package/dist/{chunk-VHZAJ6IB.js → chunk-ICFHMJTW.js} +3 -3
  77. package/dist/{chunk-HZ72EMJE.js → chunk-ITYKN2K3.js} +2 -2
  78. package/dist/{chunk-XBTWG2VL.js → chunk-IZVEBBDH.js} +5 -5
  79. package/dist/{chunk-VN7XH6TU.js → chunk-JCWHOB36.js} +2 -2
  80. package/dist/{chunk-5JK3DQGZ.js → chunk-JFKMPLNF.js} +2 -2
  81. package/dist/{chunk-FEAGK25K.js → chunk-LMC5UPL7.js} +1 -1
  82. package/dist/{chunk-7NCLUA65.js → chunk-MNKIR2ZB.js} +11 -0
  83. package/dist/{chunk-SARPHHTT.js → chunk-NOH3EJFH.js} +1 -1
  84. package/dist/{chunk-OP5IBEV7.js → chunk-NUEPJ5W6.js} +2 -2
  85. package/dist/{chunk-OU3BYBJ3.js → chunk-OA6EADFT.js} +3 -3
  86. package/dist/{chunk-LGZ545TA.js → chunk-ONBL2GCU.js} +12 -6
  87. package/dist/{chunk-LTT54NOU.js → chunk-P5HZEGT7.js} +65 -8
  88. package/dist/{chunk-YMZOM6BD.js → chunk-PP7FC3Y7.js} +10 -10
  89. package/dist/{chunk-T6XQNOZV.js → chunk-Q2BD4IBX.js} +12 -12
  90. package/dist/{chunk-DMNLFWGY.js → chunk-QNZ6G3LY.js} +210 -151
  91. package/dist/{chunk-BCVCUDFI.js → chunk-QSW3HAKI.js} +1 -1
  92. package/dist/{chunk-HOIO66DU.js → chunk-R4FL5JHK.js} +4 -4
  93. package/dist/{chunk-VUFHYMSP.js → chunk-RABLE5R6.js} +1 -1
  94. package/dist/{chunk-2MZ6ROWZ.js → chunk-RRHHWYPX.js} +6 -6
  95. package/dist/{chunk-5LOP4AVD.js → chunk-SCMEVDAR.js} +128 -26
  96. package/dist/{chunk-XE5N352V.js → chunk-SROWUG5W.js} +1 -1
  97. package/dist/{chunk-QW3FRUFB.js → chunk-SZBMTOUZ.js} +1 -1
  98. package/dist/{chunk-V7N5NOZV.js → chunk-TJUJAK5L.js} +1 -1
  99. package/dist/{chunk-OJEIS5L2.js → chunk-TK4JU2F7.js} +1 -1
  100. package/dist/{chunk-VDBXSUXP.js → chunk-U2P2LQ5B.js} +7 -7
  101. package/dist/{chunk-AB3VAQ25.js → chunk-UHS5MMAI.js} +3 -3
  102. package/dist/{chunk-OW6VBXXI.js → chunk-UM2X7HL6.js} +63 -36
  103. package/dist/{chunk-KL76XWZ7.js → chunk-UMTMFDL2.js} +1 -1
  104. package/dist/{chunk-MRCVYYPW.js → chunk-VHKK3US3.js} +3 -3
  105. package/dist/{chunk-S2Z6VWHH.js → chunk-W5L2ZLHE.js} +6 -7
  106. package/dist/{chunk-EQ26IKZM.js → chunk-WOHP7EL6.js} +7 -6
  107. package/dist/{chunk-3QLFB2EY.js → chunk-WY6YAMZW.js} +37 -214
  108. package/dist/{chunk-XO3KAH7K.js → chunk-XJIIU36L.js} +1 -1
  109. package/dist/{chunk-QC2W42DE.js → chunk-XZCJC3QO.js} +12 -12
  110. package/dist/{chunk-BUQU3OPX.js → chunk-Y64JGYTB.js} +1 -1
  111. package/dist/{chunk-KLZZI5TU.js → chunk-Z3M627TQ.js} +1 -1
  112. package/dist/{codex-app-cards-switch-LXMAIOFB.js → codex-app-cards-switch-HK4RMOBI.js} +11 -12
  113. package/dist/{codex-desktop-launch-VE5RLFUU.js → codex-desktop-launch-OCO6N7SA.js} +1 -1
  114. package/dist/{codex-session-launch-XZZWXCPK.js → codex-session-launch-ETZQTVFS.js} +19 -21
  115. package/dist/{config-PPX25AV5.js → config-YY54G3CC.js} +3 -3
  116. package/dist/{global-upgrade-NRMHNLNU.js → global-upgrade-5DN5G3ZQ.js} +10 -12
  117. package/dist/{identity-ZFQR7JNW.js → identity-EGL6HAWG.js} +4 -5
  118. package/dist/{live-capabilities-SJRYRKNB.js → live-capabilities-WU3FYJJG.js} +5 -7
  119. package/dist/{paths-7VTVOQXJ.js → paths-ZG6KDM6Y.js} +7 -3
  120. package/dist/reapply-AQLNCCTE.js +63 -0
  121. package/dist/src/index.js +20 -23
  122. package/dist/{upgrade-lock-VAYJZVTB.js → upgrade-lock-BIRXIKHJ.js} +4 -5
  123. package/dist/{usage-C4DIYUR6.js → usage-43C2DHDU.js} +3 -3
  124. package/package.json +1 -1
  125. package/dist/chunk-6ICPEJY5.js +0 -20
  126. package/dist/chunk-MK4USZYQ.js +0 -615
  127. package/dist/chunk-QENTGE75.js +0 -86
  128. package/dist/chunk-VC3HFFMQ.js +0 -41
  129. package/dist/reapply-WOANOIRZ.js +0 -64
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  announceSubscriptionRequired,
3
3
  isDeferAnswer
4
- } from "./chunk-KL76XWZ7.js";
4
+ } from "./chunk-UMTMFDL2.js";
5
5
  import {
6
6
  AUTO_DECISION_WINDOW_MS,
7
7
  DEFAULT_SESSION,
@@ -10,19 +10,19 @@ import {
10
10
  permissionDeniedAction,
11
11
  releaseThrottle,
12
12
  reportEvent
13
- } from "./chunk-PXAOEFJZ.js";
13
+ } from "./chunk-3UNAPXED.js";
14
14
  import {
15
15
  askUser,
16
16
  isDecisionStopped,
17
17
  isQuestionLimitRefusal,
18
18
  waitForQuestion
19
- } from "./chunk-TBKHQWIH.js";
19
+ } from "./chunk-DTVHZDYM.js";
20
20
  import {
21
21
  SubscriptionRequiredError
22
- } from "./chunk-ELAK46NR.js";
22
+ } from "./chunk-BKCI53W6.js";
23
23
  import {
24
24
  getMachineId
25
- } from "./chunk-L5CDGXPO.js";
25
+ } from "./chunk-FWS2KLV2.js";
26
26
  import {
27
27
  ASK_CONTEXT_MAX,
28
28
  agentQuestionContext,
@@ -34,7 +34,7 @@ import {
34
34
  questionsShownAsASet,
35
35
  shouldDeferToNativeMode,
36
36
  wireVerdictFor
37
- } from "./chunk-7NCLUA65.js";
37
+ } from "./chunk-MNKIR2ZB.js";
38
38
 
39
39
  // src/machine-decision-audit.ts
40
40
  import { basename } from "path";
@@ -12,14 +12,91 @@ import {
12
12
  ownPackageName
13
13
  } from "./chunk-QTOLNRET.js";
14
14
 
15
+ // src/cli/fsx.ts
16
+ import { copyFileSync, lstatSync, realpathSync, existsSync, fchmodSync, fsyncSync, mkdirSync, openSync, closeSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync } from "fs";
17
+ import { dirname, join } from "path";
18
+ var readJsonSafe = (filePath) => {
19
+ let raw;
20
+ try {
21
+ raw = readFileSync(filePath, "utf-8");
22
+ } catch (err) {
23
+ const error = err;
24
+ if (error.code === "ENOENT") return { kind: "missing" };
25
+ return { kind: "unreadable", error };
26
+ }
27
+ if (raw.trim() === "") return { kind: "ok", value: {} };
28
+ try {
29
+ const value = JSON.parse(raw);
30
+ return { kind: "ok", value };
31
+ } catch (err) {
32
+ return { kind: "unparseable", error: err, raw };
33
+ }
34
+ };
35
+ var isFile = (path) => {
36
+ try {
37
+ return statSync(path).isFile();
38
+ } catch {
39
+ return false;
40
+ }
41
+ };
42
+ var readFileOrMissing = (path) => {
43
+ try {
44
+ return readFileSync(path, "utf-8");
45
+ } catch (error) {
46
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
47
+ throw error;
48
+ }
49
+ };
50
+ var stamp = () => (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
51
+ var backupFile = (filePath) => {
52
+ const target = `${filePath}.pushary-backup-${stamp()}`;
53
+ copyFileSync(filePath, target);
54
+ return target;
55
+ };
56
+ var writeFileAtomic = (filePath, contents, mode, encoding = "utf-8") => {
57
+ const target = lstatSync(filePath, { throwIfNoEntry: false })?.isSymbolicLink() ? realpathSync(filePath) : filePath;
58
+ const dir = dirname(target);
59
+ if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
60
+ const temp = join(dir, `.${process.pid}-${stamp()}.pushary-tmp`);
61
+ try {
62
+ writeFileSync(temp, contents, mode === void 0 ? encoding : { encoding, mode });
63
+ const handle = openSync(temp, "r+");
64
+ try {
65
+ if (mode !== void 0) fchmodSync(handle, mode);
66
+ fsyncSync(handle);
67
+ } finally {
68
+ closeSync(handle);
69
+ }
70
+ renameSync(temp, target);
71
+ } catch (err) {
72
+ try {
73
+ if (existsSync(temp)) unlinkSync(temp);
74
+ } catch {
75
+ }
76
+ throw err;
77
+ }
78
+ };
79
+ var writeJsonAtomic = (filePath, data, mode) => writeFileAtomic(filePath, `${JSON.stringify(data, null, 2)}
80
+ `, mode);
81
+ var writeJsonAtomicDurable = (filePath, data, mode) => {
82
+ writeJsonAtomic(filePath, data, mode);
83
+ if (process.platform === "win32") return;
84
+ const directory = openSync(dirname(filePath), "r");
85
+ try {
86
+ fsyncSync(directory);
87
+ } finally {
88
+ closeSync(directory);
89
+ }
90
+ };
91
+
15
92
  // src/shell-quote.ts
16
93
  var shellDoubleQuoted = (text) => `"${text.replace(/(["\\$`])/g, "\\$1")}"`;
17
94
 
18
95
  // src/npm.ts
19
96
  import { promisify } from "util";
20
97
  import { exec, execFile, execFileSync, execSync } from "child_process";
21
- import { existsSync, readFileSync, readlinkSync, realpathSync } from "fs";
22
- import { dirname, isAbsolute, join, relative, resolve } from "path";
98
+ import { existsSync as existsSync2, readFileSync as readFileSync2, readlinkSync, realpathSync as realpathSync2 } from "fs";
99
+ import { dirname as dirname2, isAbsolute, join as join2, relative, resolve } from "path";
23
100
  var latestReleaseUrl = (packageName) => `https://registry.npmjs.org/${packageName}/latest`;
24
101
  var REGISTRY_TIMEOUT_MS = 5e3;
25
102
  var LATEST_TAG = "latest";
@@ -61,8 +138,8 @@ var resolveGlobalBinary = (name) => {
61
138
  return resolveGlobalBinaryAt(name, prefix);
62
139
  };
63
140
  var resolveGlobalBinaryAt = (name, prefix, platform = process.platform) => {
64
- const candidates = platform === "win32" ? [join(prefix, `${name}.cmd`), join(prefix, name)] : [join(prefix, "bin", name)];
65
- return candidates.find(existsSync);
141
+ const candidates = platform === "win32" ? [join2(prefix, `${name}.cmd`), join2(prefix, name)] : [join2(prefix, "bin", name)];
142
+ return candidates.find(existsSync2);
66
143
  };
67
144
  var resolvePathBinary = (name, platform = process.platform) => {
68
145
  try {
@@ -169,20 +246,20 @@ var npmInstallFailure = (err, platform = process.platform) => {
169
246
  var resolveBinary = (name) => resolveGlobalBinary(name) ?? resolvePathBinary(name);
170
247
  var resolvePackageVersionFromBinary = (binary, packageName) => {
171
248
  try {
172
- let dir = dirname(realpathSync(binary));
249
+ let dir = dirname2(realpathSync2(binary));
173
250
  const packagePath = packageName.split("/");
174
251
  for (let depth = 0; depth < 8; depth++) {
175
252
  for (const manifest of [
176
- join(dir, "package.json"),
177
- join(dir, "node_modules", ...packagePath, "package.json")
253
+ join2(dir, "package.json"),
254
+ join2(dir, "node_modules", ...packagePath, "package.json")
178
255
  ]) {
179
256
  try {
180
- const value = JSON.parse(readFileSync(manifest, "utf8"));
257
+ const value = JSON.parse(readFileSync2(manifest, "utf8"));
181
258
  if (value.name === packageName && typeof value.version === "string") return value.version;
182
259
  } catch {
183
260
  }
184
261
  }
185
- const parent = dirname(dir);
262
+ const parent = dirname2(dir);
186
263
  if (parent === dir) break;
187
264
  dir = parent;
188
265
  }
@@ -218,11 +295,11 @@ var localImportsPresent = (entry, packageDir, seen = /* @__PURE__ */ new Set())
218
295
  if (seen.has(entry)) return true;
219
296
  seen.add(entry);
220
297
  try {
221
- const source = readFileSync(entry, "utf8");
298
+ const source = readFileSync2(entry, "utf8");
222
299
  for (const match of source.matchAll(/\b(?:import|export)\s+(?:[^"'()]*?\s+from\s+)?["'](\.{1,2}\/[^"']+)["']|\bimport\s*\(\s*["'](\.{1,2}\/[^"']+)["']/g)) {
223
- const dependency = resolve(dirname(entry), match[1] ?? match[2]);
300
+ const dependency = resolve(dirname2(entry), match[1] ?? match[2]);
224
301
  const localPath = relative(packageDir, dependency);
225
- if (localPath.startsWith("..") || isAbsolute(localPath) || !existsSync(dependency)) return false;
302
+ if (localPath.startsWith("..") || isAbsolute(localPath) || !existsSync2(dependency)) return false;
226
303
  if (/\.[cm]?js$/.test(dependency) && !localImportsPresent(dependency, packageDir, seen)) return false;
227
304
  }
228
305
  return true;
@@ -232,17 +309,17 @@ var localImportsPresent = (entry, packageDir, seen = /* @__PURE__ */ new Set())
232
309
  };
233
310
  var packageBinsPresent = (packageDir, prefix, platform = process.platform, requiredFiles = []) => {
234
311
  try {
235
- const manifest = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf8"));
312
+ const manifest = JSON.parse(readFileSync2(join2(packageDir, "package.json"), "utf8"));
236
313
  if (!manifest.bin || typeof manifest.bin !== "object" || Array.isArray(manifest.bin)) return false;
237
314
  const bins = Object.entries(manifest.bin);
238
315
  if (bins.length === 0) return false;
239
- if (!requiredFiles.every((path) => existsSync(join(packageDir, path)))) return false;
316
+ if (!requiredFiles.every((path) => existsSync2(join2(packageDir, path)))) return false;
240
317
  const seen = /* @__PURE__ */ new Set();
241
318
  return bins.every(([name, target]) => {
242
319
  if (typeof target !== "string") return false;
243
- const shims = platform === "win32" ? [join(prefix, `${name}.cmd`), join(prefix, name)] : [join(prefix, "bin", name)];
244
- const entry = join(packageDir, target);
245
- return existsSync(entry) && shims.some(existsSync) && localImportsPresent(entry, packageDir, seen);
320
+ const shims = platform === "win32" ? [join2(prefix, `${name}.cmd`), join2(prefix, name)] : [join2(prefix, "bin", name)];
321
+ const entry = join2(packageDir, target);
322
+ return existsSync2(entry) && shims.some(existsSync2) && localImportsPresent(entry, packageDir, seen);
246
323
  });
247
324
  } catch {
248
325
  return false;
@@ -265,16 +342,16 @@ var globalPackageBinsPresent = (name, prefix, platform) => packageBinsPresent(gl
265
342
  var errorCode = (error) => typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
266
343
  var realpathOrUndefined = (path) => {
267
344
  try {
268
- return realpathSync(path);
345
+ return realpathSync2(path);
269
346
  } catch {
270
347
  return void 0;
271
348
  }
272
349
  };
273
350
  var definedPaths = (paths) => paths.filter((path) => path !== void 0);
274
351
  var readPosixCommandLink = (prefix) => {
275
- const command = join(prefix, "bin", OWNERSHIP_PROBE_COMMAND);
352
+ const command = join2(prefix, "bin", OWNERSHIP_PROBE_COMMAND);
276
353
  try {
277
- const target = resolve(dirname(command), readlinkSync(command));
354
+ const target = resolve(dirname2(command), readlinkSync(command));
278
355
  return { kind: "resolved", targets: definedPaths([target, realpathOrUndefined(command)]) };
279
356
  } catch (error) {
280
357
  if (errorCode(error) === "ENOENT") return { kind: "absent" };
@@ -283,9 +360,9 @@ var readPosixCommandLink = (prefix) => {
283
360
  }
284
361
  };
285
362
  var readWindowsCommandLink = (prefix) => {
286
- const shim = join(prefix, `${OWNERSHIP_PROBE_COMMAND}.cmd`);
363
+ const shim = join2(prefix, `${OWNERSHIP_PROBE_COMMAND}.cmd`);
287
364
  try {
288
- const target = cmdShimTarget(prefix, readFileSync(shim, "utf8"));
365
+ const target = cmdShimTarget(prefix, readFileSync2(shim, "utf8"));
289
366
  return target === void 0 ? { kind: "unreadable" } : { kind: "resolved", targets: [target] };
290
367
  } catch (error) {
291
368
  return errorCode(error) === "ENOENT" ? { kind: "absent" } : { kind: "unreadable" };
@@ -294,7 +371,7 @@ var readWindowsCommandLink = (prefix) => {
294
371
  var readCommandLink = (prefix, platform) => platform === "win32" ? readWindowsCommandLink(prefix) : readPosixCommandLink(prefix);
295
372
  var readFolderManifest = (folder) => {
296
373
  try {
297
- return { kind: "read", manifest: JSON.parse(readFileSync(join(folder, "package.json"), "utf8")) };
374
+ return { kind: "read", manifest: JSON.parse(readFileSync2(join2(folder, "package.json"), "utf8")) };
298
375
  } catch {
299
376
  return { kind: "unreadable" };
300
377
  }
@@ -366,9 +443,9 @@ var installGlobally = (options) => {
366
443
  }
367
444
  const started = (async () => {
368
445
  if (!npmIsOnPath()) throw new NpmMissingError();
369
- const { withUpgradeLock } = await import("./global-upgrade-NRMHNLNU.js");
370
- const { installWithUpgradeLock, ownsUpgradeLock } = await import("./upgrade-lock-VAYJZVTB.js");
371
- const { autoUpdateLock } = await import("./paths-7VTVOQXJ.js");
446
+ const { withUpgradeLock } = await import("./global-upgrade-5DN5G3ZQ.js");
447
+ const { installWithUpgradeLock, ownsUpgradeLock } = await import("./upgrade-lock-BIRXIKHJ.js");
448
+ const { autoUpdateLock } = await import("./paths-ZG6KDM6Y.js");
372
449
  let result = "skipped";
373
450
  const install = async () => {
374
451
  const platform = process.platform;
@@ -400,8 +477,33 @@ var installGlobally = (options) => {
400
477
  return started;
401
478
  };
402
479
 
480
+ // src/agent-version.ts
481
+ var parseVersion = (raw) => {
482
+ const match = raw.match(/(\d+)\.(\d+)\.(\d+)/);
483
+ return match ? [Number(match[1]), Number(match[2]), Number(match[3])] : null;
484
+ };
485
+ var compareVersion = (a, b) => {
486
+ for (let index = 0; index < 3; index++) {
487
+ if (a[index] !== b[index]) return a[index] < b[index] ? -1 : 1;
488
+ }
489
+ return 0;
490
+ };
491
+ var atLeast = (version, floor) => compareVersion(version, floor) >= 0;
492
+ var formatVersion = (version) => version.join(".");
493
+
403
494
  export {
495
+ readJsonSafe,
496
+ isFile,
497
+ readFileOrMissing,
498
+ backupFile,
499
+ writeFileAtomic,
500
+ writeJsonAtomic,
501
+ writeJsonAtomicDurable,
404
502
  shellDoubleQuoted,
503
+ parseVersion,
504
+ compareVersion,
505
+ atLeast,
506
+ formatVersion,
405
507
  LATEST_TAG,
406
508
  cleanNpmEnv,
407
509
  npmErrorMessage,
@@ -10,7 +10,7 @@ import {
10
10
  isSetupConnectMode,
11
11
  isValidApiKey,
12
12
  normalizeAgentId
13
- } from "./chunk-7NCLUA65.js";
13
+ } from "./chunk-MNKIR2ZB.js";
14
14
 
15
15
  // src/setup/options.ts
16
16
  var AGENT_CHOICES = SETUP_AGENT_CHOICES;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  writeJsonAtomicDurable
3
- } from "./chunk-QENTGE75.js";
3
+ } from "./chunk-SCMEVDAR.js";
4
4
 
5
5
  // src/transcript-recipient-pin.ts
6
6
  import { existsSync, mkdirSync, readFileSync, rmSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getBaseUrl
3
- } from "./chunk-BUQU3OPX.js";
3
+ } from "./chunk-Y64JGYTB.js";
4
4
 
5
5
  // src/transcript-api.ts
6
6
  var fetchTranscriptRecipients = async (apiKey, baseUrl = getBaseUrl()) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  readTranscriptPreference
3
- } from "./chunk-IOH2T3CB.js";
3
+ } from "./chunk-ED2SWTPC.js";
4
4
 
5
5
  // src/transcript-setting.ts
6
6
  var transcriptEnvironmentPreference = () => {
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  macAppBridgeAvailable
3
- } from "./chunk-LTT54NOU.js";
3
+ } from "./chunk-P5HZEGT7.js";
4
4
  import {
5
5
  keyPrefix
6
- } from "./chunk-IOH2T3CB.js";
7
- import {
8
- readJsonSafe
9
- } from "./chunk-QENTGE75.js";
6
+ } from "./chunk-ED2SWTPC.js";
10
7
  import {
11
8
  bridgeAgentKey
12
- } from "./chunk-MK4USZYQ.js";
9
+ } from "./chunk-ATPJGHUP.js";
10
+ import {
11
+ readJsonSafe
12
+ } from "./chunk-SCMEVDAR.js";
13
13
  import {
14
14
  isValidApiKey
15
- } from "./chunk-7NCLUA65.js";
15
+ } from "./chunk-MNKIR2ZB.js";
16
16
 
17
17
  // src/shared-mcp-key.ts
18
18
  var asRecord = (value) => value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pusharyFetch
3
- } from "./chunk-VFJSVPNL.js";
3
+ } from "./chunk-7ILQX47W.js";
4
4
  import {
5
5
  NetworkError
6
6
  } from "./chunk-PPY5N2E6.js";
@@ -9,11 +9,11 @@ import {
9
9
  } from "./chunk-KZERVKTD.js";
10
10
  import {
11
11
  getBaseUrl
12
- } from "./chunk-BUQU3OPX.js";
12
+ } from "./chunk-Y64JGYTB.js";
13
13
  import {
14
14
  isValidApiKey,
15
15
  normalizeKeyScope
16
- } from "./chunk-7NCLUA65.js";
16
+ } from "./chunk-MNKIR2ZB.js";
17
17
 
18
18
  // src/session.ts
19
19
  var samePusharyAccount = (left, right) => left.kind === "ok" && right.kind === "ok" && left.identity.workspaceId !== "" && left.identity.workspaceId === right.identity.workspaceId && left.identity.siteId === right.identity.siteId;
@@ -1,39 +1,34 @@
1
1
  import {
2
2
  ensureCodexTrustsPusharyHooks
3
- } from "./chunk-YK6GR4GU.js";
3
+ } from "./chunk-HDGB6SQ4.js";
4
4
  import {
5
- CODEX_INSTRUCTIONS_LABEL,
6
- GEMINI_INSTRUCTIONS_LABEL,
7
- OPENCODE_INSTRUCTIONS_LABEL,
8
5
  fxIgnoresInstructionsFile,
9
6
  fxInstructionsBody,
10
7
  fxServerHolder,
11
8
  macAppFxBridge,
12
- refreshInstructionBlock,
13
- renderAgentInstructions
14
- } from "./chunk-DMNLFWGY.js";
9
+ refreshClineKey
10
+ } from "./chunk-QNZ6G3LY.js";
15
11
  import {
16
12
  OPENCODE_HOOK_BINARY,
17
13
  agentHookOwner,
18
14
  installOpenCodePlugin,
19
15
  macAppBridgeAvailable,
16
+ openCodeConfigFile,
20
17
  openCodeHookArgv,
21
18
  openCodeInstructionsFile,
22
19
  openCodePluginDir,
23
- openCodeWired
24
- } from "./chunk-LTT54NOU.js";
20
+ openCodeWired,
21
+ withOpenCodeAskRules
22
+ } from "./chunk-P5HZEGT7.js";
25
23
  import {
26
24
  detectClaudeVersion
27
- } from "./chunk-OY6Z4IKB.js";
25
+ } from "./chunk-HIYLAC3C.js";
28
26
  import {
29
- addClaudeMcpServer,
30
27
  addCompatibleHooks,
31
- addPusharyHooks,
32
- addPusharyToolPermissions,
33
28
  compatibleConfigFile,
34
29
  compatibleInstructionsFile,
35
30
  hasCompatibleHooks
36
- } from "./chunk-3QLFB2EY.js";
31
+ } from "./chunk-WY6YAMZW.js";
37
32
  import {
38
33
  claudeUnprovenHolds,
39
34
  claudeWired,
@@ -41,34 +36,33 @@ import {
41
36
  codexWired,
42
37
  geminiWired,
43
38
  planHooks
44
- } from "./chunk-SKUSGWFK.js";
39
+ } from "./chunk-GTBWWCCM.js";
45
40
  import {
46
- CLAUDE_HOOK_BINARY,
47
- CLAUDE_HOOK_EVENTS,
48
41
  GEMINI_HOOK_BINARY,
49
42
  addGeminiHooks,
50
43
  addGeminiMcpServer,
51
- hasGeminiHooks,
52
- needsReregistration,
53
- registrationSignatures,
54
- supportedClaudeEvents
55
- } from "./chunk-BQFL2ECS.js";
56
- import {
57
- formatVersion
58
- } from "./chunk-6ICPEJY5.js";
59
- import {
60
- readJsonSafe,
61
- writeFileAtomic,
62
- writeJsonAtomic
63
- } from "./chunk-QENTGE75.js";
44
+ hasGeminiHooks
45
+ } from "./chunk-ANP3DIST.js";
64
46
  import {
47
+ CLAUDE_HOOK_BINARY,
48
+ CLAUDE_HOOK_EVENTS,
49
+ CLINE_LABEL,
65
50
  CODEX_HOOK_BINARY,
51
+ CODEX_INSTRUCTIONS_LABEL,
52
+ GEMINI_INSTRUCTIONS_LABEL,
53
+ OPENCODE_INSTRUCTIONS_LABEL,
54
+ addClaudeMcpServer,
66
55
  addCodexHookTrust,
67
56
  addCodexHooks,
68
57
  addCodexMcpServer,
58
+ addPusharyHooks,
59
+ addPusharyToolPermissions,
69
60
  claudeJson,
70
61
  claudeRegistrationReceipt,
71
62
  claudeSettings,
63
+ clineInstructionsBody,
64
+ clineMcpSettings,
65
+ clineRules,
72
66
  codexAgentsMd,
73
67
  codexConfigToml,
74
68
  codexHookPositions,
@@ -84,20 +78,29 @@ import {
84
78
  guardBinary,
85
79
  hasCodexHooks,
86
80
  namesOurBinary,
81
+ needsReregistration,
87
82
  pusharyDir,
83
+ refreshInstructionBlock,
88
84
  registeredCommands,
89
85
  registrationHolderOf,
86
+ registrationSignatures,
87
+ renderAgentInstructions,
88
+ supportedClaudeEvents,
90
89
  vscodePluginMcp
91
- } from "./chunk-MK4USZYQ.js";
90
+ } from "./chunk-ATPJGHUP.js";
92
91
  import {
92
+ formatVersion,
93
+ readJsonSafe,
93
94
  resolveGlobalBinDir,
94
- resolveGlobalBinary
95
- } from "./chunk-5LOP4AVD.js";
95
+ resolveGlobalBinary,
96
+ writeFileAtomic,
97
+ writeJsonAtomic
98
+ } from "./chunk-SCMEVDAR.js";
96
99
  import {
97
100
  HOOK_COMPATIBLE_PROFILES,
98
101
  isCompatibleAgentType,
99
102
  isRecord
100
- } from "./chunk-7NCLUA65.js";
103
+ } from "./chunk-MNKIR2ZB.js";
101
104
 
102
105
  // src/reapply.ts
103
106
  import { dirname, join } from "path";
@@ -353,15 +356,28 @@ var reapplyCursorPlugin = (apiKey, paths = {}) => reapplyPluginMcp(
353
356
  apiKey
354
357
  );
355
358
  var reapplyVsCodePlugin = (apiKey, paths = {}) => reapplyPluginMcp(paths.pluginMcpPath ?? vscodePluginMcp(), apiKey);
359
+ var addOpenCodeAskRulesWhereUnset = (configFile) => {
360
+ const read = readJsonSafe(configFile);
361
+ if (read.kind !== "ok" || !isRecord(read.value)) return false;
362
+ const { config: withRules, change } = withOpenCodeAskRules(read.value);
363
+ if (change.kind !== "added") return false;
364
+ writeJsonAtomic(configFile, withRules, modeToPreserve(configFile));
365
+ return true;
366
+ };
356
367
  var reapplyOpenCodePlugin = (paths = {}) => {
357
368
  const pluginDir = paths.pluginDir ?? openCodePluginDir();
358
369
  if (!openCodeWired(pluginDir)) return { configured: false, reapplied: false, hooks: false, mcp: false };
359
370
  try {
360
371
  installOpenCodePlugin(openCodeHookArgv((paths.resolveBinary ?? resolveGlobalBinary)(OPENCODE_HOOK_BINARY)), pluginDir);
361
- return { configured: true, reapplied: true, hooks: true, mcp: false };
362
372
  } catch {
363
373
  return { configured: true, reapplied: false, hooks: false, mcp: false, failed: true };
364
374
  }
375
+ try {
376
+ const addedRules = addOpenCodeAskRulesWhereUnset(paths.configFile ?? openCodeConfigFile());
377
+ return { configured: true, reapplied: true, hooks: true, mcp: false, ...addedRules ? { approvalRules: true } : {} };
378
+ } catch {
379
+ return { configured: true, reapplied: true, hooks: true, mcp: false, failed: true };
380
+ }
365
381
  };
366
382
  var NOT_CONFIGURED = { configured: false, reapplied: false, hooks: false, mcp: false };
367
383
  var CONFIGURED_BUT_FAILED = { configured: true, reapplied: false, hooks: false, mcp: false, failed: true };
@@ -382,11 +398,19 @@ var reapplyCompatibleHooks = (profile, paths = {}) => {
382
398
  var CONFIGURED_AND_UNCHANGED = { configured: true, reapplied: false, hooks: false, mcp: false };
383
399
  var fxHolder = () => fxServerHolder(fxMcpProfile(), macAppFxBridge(pusharyDir()));
384
400
  var inspectFxWiring = () => fxHolder() === "cli" ? CONFIGURED_AND_UNCHANGED : NOT_CONFIGURED;
401
+ var REFRESHED_MCP = { configured: true, reapplied: true, hooks: false, mcp: true };
402
+ var CLINE_REAPPLY_RESULTS = {
403
+ refreshed: REFRESHED_MCP,
404
+ unchanged: CONFIGURED_AND_UNCHANGED,
405
+ "not-configured": NOT_CONFIGURED
406
+ };
407
+ var reapplyClineSettings = (apiKey, settingsPath = clineMcpSettings()) => CLINE_REAPPLY_RESULTS[refreshClineKey(settingsPath, apiKey)];
385
408
  var compatibleInstructionTarget = (profile) => {
386
409
  const file = compatibleInstructionsFile(profile);
387
410
  return file && profile.instructions ? { file, body: renderAgentInstructions(profile.instructions.label) } : null;
388
411
  };
389
412
  var fxInstructionTarget = () => fxIgnoresInstructionsFile(fxAgentsMd(), fxConfigDir()) ? null : { file: fxAgentsMd(), body: fxInstructionsBody() };
413
+ var clineInstructionTarget = () => ({ file: clineRules(), body: clineInstructionsBody() });
390
414
  var instructionTargetOrNull = (target) => {
391
415
  try {
392
416
  return target();
@@ -405,7 +429,8 @@ var SETUP_CHOICE_BY_REAPPLY_ID = {
405
429
  cursor: "cursor",
406
430
  vscode: "vscode",
407
431
  opencode: "opencode",
408
- fx: "fx"
432
+ fx: "fx",
433
+ cline: "cline"
409
434
  };
410
435
  var setupChoiceOf = (id) => isCompatibleAgentType(id) ? id : SETUP_CHOICE_BY_REAPPLY_ID[id];
411
436
  var reapplyHookOwner = (id, appAvailable) => agentHookOwner(setupChoiceOf(id), appAvailable);
@@ -440,6 +465,7 @@ var reapplyAllAgents = (apiKey, options = {}) => {
440
465
  instructions: () => ({ file: openCodeInstructionsFile(), body: renderAgentInstructions(OPENCODE_INSTRUCTIONS_LABEL) })
441
466
  },
442
467
  { id: "fx", label: "fx", run: inspectFxWiring, instructions: fxInstructionTarget },
468
+ { id: "cline", label: CLINE_LABEL, run: () => reapplyClineSettings(apiKey), instructions: clineInstructionTarget },
443
469
  ...HOOK_COMPATIBLE_PROFILES.map((profile) => ({
444
470
  id: profile.agentType,
445
471
  label: profile.label,
@@ -478,6 +504,7 @@ export {
478
504
  reapplyVsCodePlugin,
479
505
  reapplyOpenCodePlugin,
480
506
  reapplyCompatibleHooks,
507
+ reapplyClineSettings,
481
508
  reapplyAllAgents,
482
509
  ensureCodexTrustAfterReapply
483
510
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DEFAULT_SESSION
3
- } from "./chunk-PXAOEFJZ.js";
3
+ } from "./chunk-3UNAPXED.js";
4
4
 
5
5
  // src/answer.ts
6
6
  var isDeferAnswer = (value) => value === "defer";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  SETUP_FLAGS
3
- } from "./chunk-XE5N352V.js";
3
+ } from "./chunk-SROWUG5W.js";
4
4
  import {
5
5
  parseFlags
6
6
  } from "./chunk-NMUI3ZWG.js";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-PPY5N2E6.js";
10
10
  import {
11
11
  NPX_LATEST_COMMAND
12
- } from "./chunk-6Z2VR3BA.js";
12
+ } from "./chunk-BAGBCSXA.js";
13
13
  import {
14
14
  CLAUDE_CONNECTOR_GUIDE,
15
15
  CLAUDE_CONNECTOR_STEPS,
@@ -17,7 +17,7 @@ import {
17
17
  CLAUDE_CONNECTOR_URL,
18
18
  COWORK_CONNECTOR_LIMIT,
19
19
  COWORK_STANDING_INSTRUCTIONS
20
- } from "./chunk-7NCLUA65.js";
20
+ } from "./chunk-MNKIR2ZB.js";
21
21
 
22
22
  // src/cli/cowork.ts
23
23
  import { readFileSync } from "fs";
@@ -1,17 +1,15 @@
1
- import {
2
- writeFileAtomic
3
- } from "./chunk-QENTGE75.js";
4
1
  import {
5
2
  NpmInstallError,
6
3
  NpmMissingError,
7
- NpmPermissionError
8
- } from "./chunk-5LOP4AVD.js";
4
+ NpmPermissionError,
5
+ writeFileAtomic
6
+ } from "./chunk-SCMEVDAR.js";
9
7
  import {
10
8
  NPX_LATEST_COMMAND
11
- } from "./chunk-6Z2VR3BA.js";
9
+ } from "./chunk-BAGBCSXA.js";
12
10
  import {
13
11
  readSetupAgentFailures
14
- } from "./chunk-7NCLUA65.js";
12
+ } from "./chunk-MNKIR2ZB.js";
15
13
 
16
14
  // src/setup/config-write.ts
17
15
  var AgentConfigWriteError = class extends Error {
@@ -97,6 +95,7 @@ var failedAgentsContext = (configuredAgentNames) => configuredAgentNames.length
97
95
  var agentFailureWire = (failures) => readSetupAgentFailures(failures);
98
96
 
99
97
  export {
98
+ AgentConfigWriteError,
100
99
  writeSetupConfigFile,
101
100
  writeSetupConfigJson,
102
101
  AgentConfigError,