@pushary/agent-hooks 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/bin/pushary-bell-hook.js +23 -23
  3. package/dist/bin/pushary-bell.js +10 -10
  4. package/dist/bin/pushary-claude.js +46 -35
  5. package/dist/bin/pushary-clean.js +107 -60
  6. package/dist/bin/pushary-codex-bridge.js +18 -17
  7. package/dist/bin/pushary-codex-hook.js +53 -39
  8. package/dist/bin/pushary-codex.js +14 -12
  9. package/dist/bin/pushary-connect.js +16 -16
  10. package/dist/bin/pushary-cowork.js +5 -5
  11. package/dist/bin/pushary-daemon.js +27 -27
  12. package/dist/bin/pushary-disconnect.js +19 -17
  13. package/dist/bin/pushary-doctor.js +63 -35
  14. package/dist/bin/pushary-elicitation-hook.js +35 -26
  15. package/dist/bin/pushary-gemini-bridge.js +12 -12
  16. package/dist/bin/pushary-gemini-hook.js +47 -32
  17. package/dist/bin/pushary-hook.js +34 -32
  18. package/dist/bin/pushary-login.js +16 -16
  19. package/dist/bin/pushary-logout.js +8 -8
  20. package/dist/bin/pushary-mcp.js +9 -8
  21. package/dist/bin/pushary-mode.js +10 -10
  22. package/dist/bin/pushary-notification-hook.js +29 -27
  23. package/dist/bin/pushary-opencode-hook.js +46 -32
  24. package/dist/bin/pushary-permission-denied-hook.js +34 -32
  25. package/dist/bin/pushary-permission-hook.js +33 -31
  26. package/dist/bin/pushary-post-hook.js +29 -27
  27. package/dist/bin/pushary-prompt-hook.js +29 -27
  28. package/dist/bin/pushary-session-end-hook.js +29 -27
  29. package/dist/bin/pushary-session-start-hook.js +33 -31
  30. package/dist/bin/pushary-setup.js +69 -56
  31. package/dist/bin/pushary-stats.js +5 -5
  32. package/dist/bin/pushary-status.js +19 -19
  33. package/dist/bin/pushary-stop-hook.js +29 -27
  34. package/dist/bin/pushary-stopfailure-hook.js +29 -27
  35. package/dist/bin/pushary-suggestions.js +5 -5
  36. package/dist/bin/pushary-transcript-register.js +19 -19
  37. package/dist/bin/pushary-transcripts.js +7 -7
  38. package/dist/bin/pushary-upgrade.js +20 -20
  39. package/dist/bin/pushary-wait.js +10 -10
  40. package/dist/bin/pushary.js +6 -6
  41. package/dist/{chunk-WM3U2RUK.js → chunk-2B4XCMH6.js} +75 -232
  42. package/dist/{chunk-ZIIYTQHC.js → chunk-2XOHXZRC.js} +12 -4
  43. package/dist/{chunk-3QE3BHBW.js → chunk-3NSRL5E7.js} +2 -2
  44. package/dist/{chunk-7GI6QC3M.js → chunk-3RO2UWJQ.js} +2 -2
  45. package/dist/{chunk-AAGLDXH4.js → chunk-4S7CCOXB.js} +5 -5
  46. package/dist/{chunk-6SJQ442W.js → chunk-5GIBNUBD.js} +2 -2
  47. package/dist/chunk-5OP5MQI7.js +45 -0
  48. package/dist/{chunk-EIZW73P5.js → chunk-65RN6ZCO.js} +1 -1
  49. package/dist/{chunk-6PV2JQ64.js → chunk-6NHXKTQU.js} +2 -2
  50. package/dist/{chunk-KSNAAMU5.js → chunk-6QZK4O36.js} +4 -4
  51. package/dist/{chunk-WZWXBTRF.js → chunk-A6WQF7FQ.js} +3 -3
  52. package/dist/{chunk-62TEPRWQ.js → chunk-AWZNDM3B.js} +1 -1
  53. package/dist/{chunk-NQFGVAT6.js → chunk-D4OGEWLH.js} +19 -2
  54. package/dist/{chunk-SVEMF2VO.js → chunk-E3PLF7YB.js} +4 -4
  55. package/dist/{chunk-MCNS4725.js → chunk-F6BMJOSW.js} +1 -1
  56. package/dist/{chunk-P5CBNSYL.js → chunk-HOIGXMI7.js} +1 -1
  57. package/dist/{chunk-XMN37YJH.js → chunk-I7B2DNVU.js} +1 -1
  58. package/dist/{chunk-ZEMSCGDD.js → chunk-INR3RVQ3.js} +8 -3
  59. package/dist/{chunk-3QORH5EJ.js → chunk-IZVAVXHQ.js} +6 -4
  60. package/dist/{chunk-MWVCDP64.js → chunk-JMSB6CJT.js} +1 -1
  61. package/dist/{chunk-WSC53O7I.js → chunk-KAJT6HPI.js} +3 -3
  62. package/dist/{chunk-XPMOCJHN.js → chunk-KLXYMPTM.js} +1 -1
  63. package/dist/{chunk-XDASEYRS.js → chunk-L6IF4JOF.js} +3 -3
  64. package/dist/{chunk-UPKP67TA.js → chunk-LI3C2IQY.js} +2 -2
  65. package/dist/{chunk-H6JV44TE.js → chunk-M2JGLFFS.js} +1 -1
  66. package/dist/chunk-MY3UZO5U.js +99 -0
  67. package/dist/chunk-N6IOSZOE.js +185 -0
  68. package/dist/{chunk-454KMJHF.js → chunk-NYBZJ44G.js} +34 -1
  69. package/dist/{chunk-QPR33SHS.js → chunk-OJRB5QKN.js} +6 -6
  70. package/dist/{chunk-3T35OE7C.js → chunk-OXEF6JHD.js} +4 -4
  71. package/dist/{chunk-SNWNA3MQ.js → chunk-PWNQGITG.js} +1 -1
  72. package/dist/{chunk-XPTCPU6V.js → chunk-Q7CDBJXU.js} +1 -1
  73. package/dist/{chunk-OTZHT34O.js → chunk-QSZ37ROP.js} +1 -1
  74. package/dist/{chunk-O5JD7UI5.js → chunk-R7ZETVNR.js} +1 -1
  75. package/dist/{chunk-4C4NRDIC.js → chunk-RLRDPZG4.js} +1 -1
  76. package/dist/{chunk-IGBDOZUO.js → chunk-SEIZQZEE.js} +1 -1
  77. package/dist/{chunk-OAL44FM2.js → chunk-SJN64NJX.js} +1 -1
  78. package/dist/{chunk-NID4UZDN.js → chunk-SKEW3TQX.js} +1 -1
  79. package/dist/{chunk-NAAZCNKI.js → chunk-SKMWPXGV.js} +351 -37
  80. package/dist/{chunk-KBLIVEFJ.js → chunk-T3PRPFDY.js} +5 -5
  81. package/dist/{chunk-2FU43B5Q.js → chunk-TVJYGZXB.js} +2 -2
  82. package/dist/{chunk-Y6GKOZBT.js → chunk-U3MS6D5X.js} +1 -1
  83. package/dist/{chunk-O5PRIYFZ.js → chunk-U4TMAANR.js} +3 -0
  84. package/dist/{chunk-JTQDP4ZL.js → chunk-UFNBKYWT.js} +3 -3
  85. package/dist/{chunk-42XR73I2.js → chunk-UUTWHVSV.js} +35 -35
  86. package/dist/{chunk-43SSQCWO.js → chunk-VQDJ6KB3.js} +3 -3
  87. package/dist/{chunk-YZKS3ME3.js → chunk-VSGKQ3HI.js} +2 -2
  88. package/dist/{chunk-XFNVG3OV.js → chunk-WWTLAZQA.js} +24 -7
  89. package/dist/{chunk-VCMFKZON.js → chunk-WXIVUIXA.js} +2 -2
  90. package/dist/{chunk-AHWJHLG5.js → chunk-YLCSKVQQ.js} +7 -5
  91. package/dist/{chunk-Q7QRR6YL.js → chunk-YNJ2H2FD.js} +2 -2
  92. package/dist/{chunk-BYVB3RX3.js → chunk-YU4222G2.js} +2 -2
  93. package/dist/{chunk-YQN7S57T.js → chunk-YU54LNC6.js} +6 -6
  94. package/dist/{chunk-7GYGVQBU.js → chunk-ZMWX5SDA.js} +8 -8
  95. package/dist/{chunk-55RO62FV.js → chunk-ZUKZJQGR.js} +1 -1
  96. package/dist/{reapply-66GQIBXN.js → reapply-D6RSDYCK.js} +9 -9
  97. package/dist/src/index.d.ts +1 -0
  98. package/dist/src/index.js +22 -20
  99. package/package.json +2 -1
  100. package/dist/chunk-JMBG47WV.js +0 -336
  101. package/dist/chunk-YHG74UFF.js +0 -12
@@ -4,18 +4,18 @@ import {
4
4
  } from "./chunk-POFBE6ZY.js";
5
5
  import {
6
6
  isNetworkFailure
7
- } from "./chunk-JTQDP4ZL.js";
7
+ } from "./chunk-UFNBKYWT.js";
8
8
  import {
9
9
  clientReportClaims
10
- } from "./chunk-454KMJHF.js";
10
+ } from "./chunk-NYBZJ44G.js";
11
11
  import {
12
12
  getApiKey,
13
13
  getBaseUrl
14
- } from "./chunk-OAL44FM2.js";
14
+ } from "./chunk-SJN64NJX.js";
15
15
  import {
16
16
  CLIENT_REPORT_PATH,
17
17
  degradedLine
18
- } from "./chunk-XFNVG3OV.js";
18
+ } from "./chunk-WWTLAZQA.js";
19
19
 
20
20
  // src/client-report-claim.ts
21
21
  import { createHash } from "crypto";
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  NOTIFICATION_MATCHED_TYPES,
3
3
  POSTTOOLUSE_MIRRORED_TOOLS
4
- } from "./chunk-4C4NRDIC.js";
4
+ } from "./chunk-RLRDPZG4.js";
5
5
  import {
6
6
  isProtectedByScope,
7
7
  registerHookEntry
8
- } from "./chunk-454KMJHF.js";
8
+ } from "./chunk-NYBZJ44G.js";
9
9
  import {
10
10
  CLAUDE_PRETOOLUSE_MATCHER,
11
11
  HOOK_BUDGETS,
12
12
  HOOK_LOCATOR_BINARY
13
- } from "./chunk-XFNVG3OV.js";
13
+ } from "./chunk-WWTLAZQA.js";
14
14
 
15
15
  // src/gemini-config.ts
16
16
  var GEMINI_HOOK_BINARY = "pushary-gemini-hook";
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-3EGEA4KH.js";
10
10
  import {
11
11
  getBaseUrl
12
- } from "./chunk-OAL44FM2.js";
12
+ } from "./chunk-SJN64NJX.js";
13
13
 
14
14
  // src/cli/login-ui.ts
15
15
  import { hostname } from "os";
@@ -1,9 +1,12 @@
1
+ import {
2
+ keyCheckFromResponse
3
+ } from "./chunk-VQDJ6KB3.js";
1
4
  import {
2
5
  installNetworkDefaults
3
- } from "./chunk-JTQDP4ZL.js";
6
+ } from "./chunk-UFNBKYWT.js";
4
7
  import {
5
8
  getBaseUrl
6
- } from "./chunk-OAL44FM2.js";
9
+ } from "./chunk-SJN64NJX.js";
7
10
 
8
11
  // src/retry.ts
9
12
  var isRetryable = (err) => {
@@ -35,6 +38,17 @@ var withRetry = async (fn, options = {}) => {
35
38
 
36
39
  // src/mcp-http.ts
37
40
  installNetworkDefaults();
41
+ var SUBSCRIPTION_REQUIRED_MESSAGE = "Pushary MCP error: 403 Subscription required";
42
+ var SubscriptionRequiredError = class extends Error {
43
+ plan;
44
+ upgradeUrl;
45
+ constructor(plan, upgradeUrl) {
46
+ super(SUBSCRIPTION_REQUIRED_MESSAGE);
47
+ this.name = "SubscriptionRequiredError";
48
+ this.plan = plan;
49
+ this.upgradeUrl = upgradeUrl;
50
+ }
51
+ };
38
52
  var parseSseMessages = (body) => {
39
53
  const messages = [];
40
54
  for (const event of body.split(/\r?\n\r?\n/)) {
@@ -77,6 +91,8 @@ var sendMcpRequest = async (apiKey, message, options = {}) => {
77
91
  body: JSON.stringify(message),
78
92
  signal: options.timeoutMs ? AbortSignal.any([AbortSignal.timeout(options.timeoutMs), ...options.signal ? [options.signal] : []]) : options.signal
79
93
  });
94
+ const lock = response.ok ? null : await keyCheckFromResponse(response, baseUrl);
95
+ if (lock?.kind === "locked") throw new SubscriptionRequiredError(lock.plan, lock.upgradeUrl);
80
96
  const body = await response.text();
81
97
  const contentType = response.headers.get("content-type");
82
98
  let data = null;
@@ -115,6 +131,7 @@ var callMcpTool = async (apiKey, toolName, params, options = {}) => {
115
131
 
116
132
  export {
117
133
  withRetry,
134
+ SubscriptionRequiredError,
118
135
  parseSseMessages,
119
136
  sendMcpRequest,
120
137
  callMcpTool
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  AGENT_CHOICES
3
- } from "./chunk-XMN37YJH.js";
3
+ } from "./chunk-I7B2DNVU.js";
4
4
  import {
5
5
  isBridgeLocator
6
- } from "./chunk-MWVCDP64.js";
6
+ } from "./chunk-JMSB6CJT.js";
7
7
  import {
8
8
  pusharyHookExecutable
9
- } from "./chunk-XDASEYRS.js";
9
+ } from "./chunk-L6IF4JOF.js";
10
10
  import {
11
11
  BELL_HOOK_BINARY
12
- } from "./chunk-XPMOCJHN.js";
12
+ } from "./chunk-KLXYMPTM.js";
13
13
 
14
14
  // src/setup/hook-ownership.ts
15
15
  var commandsIn = (value) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isSafeReadOnlyCommand
3
- } from "./chunk-XFNVG3OV.js";
3
+ } from "./chunk-WWTLAZQA.js";
4
4
 
5
5
  // src/ledger.ts
6
6
  import { appendFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pusharyDir
3
- } from "./chunk-454KMJHF.js";
3
+ } from "./chunk-NYBZJ44G.js";
4
4
  import {
5
5
  writeFileAtomic
6
6
  } from "./chunk-T7E75EKA.js";
@@ -9,7 +9,7 @@ import {
9
9
  SETUP_CONNECT_MODES,
10
10
  isSetupConnectMode,
11
11
  isValidApiKey
12
- } from "./chunk-XFNVG3OV.js";
12
+ } from "./chunk-WWTLAZQA.js";
13
13
 
14
14
  // src/setup/options.ts
15
15
  var AGENT_CHOICES = SETUP_AGENT_CHOICES;
@@ -1,6 +1,9 @@
1
+ import {
2
+ NpmMissingError
3
+ } from "./chunk-NYBZJ44G.js";
1
4
  import {
2
5
  NPX_LATEST_COMMAND
3
- } from "./chunk-EIZW73P5.js";
6
+ } from "./chunk-65RN6ZCO.js";
4
7
 
5
8
  // src/setup/agent-failure.ts
6
9
  var AgentConfigError = class extends Error {
@@ -21,12 +24,14 @@ var AGENT_FAILURE_DETAILS = {
21
24
  var describedAgentFailure = (agent, kind) => ({
22
25
  agent,
23
26
  kind,
24
- detail: AGENT_FAILURE_DETAILS[kind]
27
+ detail: AGENT_FAILURE_DETAILS[kind],
28
+ remedy: "retry-agent"
25
29
  });
26
30
  var agentFailureFromError = (agent, error, describeError) => ({
27
31
  agent,
28
32
  kind: error instanceof AgentConfigError ? error.kind : "installer-error",
29
- detail: describeError(error)
33
+ detail: describeError(error),
34
+ remedy: error instanceof NpmMissingError ? "install-node" : "retry-agent"
30
35
  });
31
36
  var retryAgentCommand = (agent) => `${NPX_LATEST_COMMAND} setup --agents ${agent}`;
32
37
  var REMAINING_AGENTS_CONTINUE = "Other agents will continue. Re-run setup to retry.";
@@ -1,16 +1,18 @@
1
1
  import {
2
2
  AUTO_DECISION_WINDOW_MS,
3
- DEFAULT_SESSION,
4
3
  canonicalGateInputs,
5
4
  claimThrottle,
6
5
  deriveToolTarget,
7
6
  permissionDeniedAction,
8
7
  releaseThrottle,
9
8
  reportEvent
10
- } from "./chunk-WM3U2RUK.js";
9
+ } from "./chunk-2B4XCMH6.js";
10
+ import {
11
+ DEFAULT_SESSION
12
+ } from "./chunk-N6IOSZOE.js";
11
13
  import {
12
14
  canonicalJson
13
- } from "./chunk-454KMJHF.js";
15
+ } from "./chunk-NYBZJ44G.js";
14
16
  import {
15
17
  writeFileAtomic
16
18
  } from "./chunk-T7E75EKA.js";
@@ -20,7 +22,7 @@ import {
20
22
  machineDecisionFor,
21
23
  shouldDeferToNativeMode,
22
24
  wireVerdictFor
23
- } from "./chunk-XFNVG3OV.js";
25
+ } from "./chunk-WWTLAZQA.js";
24
26
 
25
27
  // src/machine-decision-audit.ts
26
28
  import { basename } from "path";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  HOOK_LOCATOR_BINARY
3
- } from "./chunk-XFNVG3OV.js";
3
+ } from "./chunk-WWTLAZQA.js";
4
4
 
5
5
  // src/diagnostics/bridge.ts
6
6
  import { execFileSync } from "child_process";
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  CLAUDE_HOOK_EVENTS,
3
3
  supportedClaudeEvents
4
- } from "./chunk-WZWXBTRF.js";
4
+ } from "./chunk-A6WQF7FQ.js";
5
5
  import {
6
6
  guardBinary,
7
7
  holdBudgetOf,
8
8
  isProtectedByScope,
9
9
  registerHookEntry
10
- } from "./chunk-454KMJHF.js";
10
+ } from "./chunk-NYBZJ44G.js";
11
11
  import {
12
12
  HOOK_LOCATOR_BINARY,
13
13
  withHookHoldBudget
14
- } from "./chunk-XFNVG3OV.js";
14
+ } from "./chunk-WWTLAZQA.js";
15
15
 
16
16
  // src/claude-config.ts
17
17
  import { join } from "path";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  guardBinary
3
- } from "./chunk-454KMJHF.js";
3
+ } from "./chunk-NYBZJ44G.js";
4
4
 
5
5
  // src/bell/install.ts
6
6
  import { join } from "path";
@@ -2,17 +2,17 @@ import {
2
2
  CLAUDE_HOOK_EVENTS,
3
3
  GEMINI_HOOK_EVENTS,
4
4
  hasGeminiHooks
5
- } from "./chunk-WZWXBTRF.js";
5
+ } from "./chunk-A6WQF7FQ.js";
6
6
  import {
7
7
  CODEX_HOOK_EVENTS,
8
8
  hasCodexHooks,
9
9
  holdBudgetOf
10
- } from "./chunk-454KMJHF.js";
10
+ } from "./chunk-NYBZJ44G.js";
11
11
  import {
12
12
  CURSOR_GATE_EVENTS,
13
13
  HOOK_LOCATOR_BINARY,
14
14
  hookCommandHoldBudget
15
- } from "./chunk-XFNVG3OV.js";
15
+ } from "./chunk-WWTLAZQA.js";
16
16
 
17
17
  // src/diagnostics/wiring.ts
18
18
  var record = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : null;
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  configFilePath
3
- } from "./chunk-OAL44FM2.js";
3
+ } from "./chunk-SJN64NJX.js";
4
4
  import {
5
5
  normalizeInstallSource
6
- } from "./chunk-XFNVG3OV.js";
6
+ } from "./chunk-WWTLAZQA.js";
7
7
 
8
8
  // src/install-source.ts
9
9
  import { readFileSync } from "fs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  NPX_LATEST_COMMAND
3
- } from "./chunk-EIZW73P5.js";
3
+ } from "./chunk-65RN6ZCO.js";
4
4
 
5
5
  // src/setup/codex-trust.ts
6
6
  var CODEX_TRUST_TELEMETRY = {
@@ -0,0 +1,99 @@
1
+ import {
2
+ pusharyHookExecutable
3
+ } from "./chunk-L6IF4JOF.js";
4
+ import {
5
+ isProtectedByScope,
6
+ registerHookEntry
7
+ } from "./chunk-NYBZJ44G.js";
8
+
9
+ // src/skills-cli.ts
10
+ import { execSync } from "child_process";
11
+ var PUSHARY_SKILL_SOURCE = "Pushary/pushary-skill";
12
+ var PUSHARY_SKILL_NAME = "pushary";
13
+ var installSkillViaSkillsCli = (agent) => {
14
+ try {
15
+ execSync(`npx -y skills@latest add ${PUSHARY_SKILL_SOURCE}@${PUSHARY_SKILL_NAME} -y -g --agent ${agent}`, {
16
+ stdio: "pipe",
17
+ timeout: 9e4
18
+ });
19
+ return true;
20
+ } catch {
21
+ return false;
22
+ }
23
+ };
24
+ var installAgentSkill = async (request, effects) => {
25
+ if (request.skillsCliInUse) {
26
+ const startedAt = effects.now();
27
+ if (effects.runSkillsCli(request.agent)) {
28
+ const modifiedAt = effects.skillModifiedAt(request.agentSkillDir);
29
+ if (modifiedAt !== null && modifiedAt >= startedAt) return "skills-cli";
30
+ }
31
+ }
32
+ await effects.writePackagedSkill(request.agentSkillDir);
33
+ return "packaged-copy";
34
+ };
35
+
36
+ // src/cursor-config.ts
37
+ var hookCommandOf = (entry) => {
38
+ const command = entry && typeof entry === "object" && !Array.isArray(entry) ? entry.command : void 0;
39
+ return typeof command === "string" ? command : "";
40
+ };
41
+ var isPusharyCursorEntry = (entry) => pusharyHookExecutable(hookCommandOf(entry)) !== null;
42
+ var registerCursorGate = (existing, entry) => registerHookEntry(existing, isPusharyCursorEntry, entry);
43
+ var withoutPusharyCursorHooks = (hooks, scope) => {
44
+ let removed = 0;
45
+ const kept = {};
46
+ for (const [event, entries] of Object.entries(hooks)) {
47
+ if (!Array.isArray(entries)) {
48
+ kept[event] = entries;
49
+ continue;
50
+ }
51
+ const others = entries.filter((entry) => !isPusharyCursorEntry(entry) || isProtectedByScope(hookCommandOf(entry), scope));
52
+ removed += entries.length - others.length;
53
+ if (others.length > 0 || entries.length === 0) kept[event] = others;
54
+ }
55
+ return { hooks: kept, removed };
56
+ };
57
+
58
+ // src/cli/dry-run.ts
59
+ import { execFileSync } from "child_process";
60
+ import { rmSync, writeFileSync } from "fs";
61
+ var createGuards = (isDryRun, note) => ({
62
+ write: (path, contents) => {
63
+ if (isDryRun()) return note("rewrite", path);
64
+ writeFileSync(path, contents, "utf-8");
65
+ },
66
+ remove: (path, options = {}) => {
67
+ if (isDryRun()) return note("remove ", path);
68
+ rmSync(path, { recursive: true, force: options.force ?? false });
69
+ },
70
+ execFile: (file, args, options, describe) => {
71
+ if (isDryRun()) return note("run ", describe);
72
+ execFileSync(file, args, options);
73
+ }
74
+ });
75
+ var describeService = (effects) => {
76
+ if (effects.controlMode === "off") return "skip the phone-start background service (--control off)";
77
+ const where = effects.serviceDefinitionPath ?? "the phone-start service definition";
78
+ const condition = effects.controlMode === "on" ? "" : ", when a supported agent and a service manager are present";
79
+ return `write ${where} and register it with the OS${condition}`;
80
+ };
81
+ var describeSetupSideEffects = (effects) => [
82
+ `run npm install -g @pushary/agent-hooks@${effects.version} (the hooks run from the global copy; up to two minutes)`,
83
+ `write ${effects.configFile} (the API key, mode 600)`,
84
+ effects.rcPath ? `edit ${effects.rcPath} (export PUSHARY_API_KEY)` : "print the export line for your shell, since no rc file was found",
85
+ describeService(effects),
86
+ "ask Add Pushary instructions to this project's CLAUDE.md/AGENTS.md? (default no)",
87
+ "ask Alias claude to pushary claude? (default no)"
88
+ ];
89
+
90
+ export {
91
+ PUSHARY_SKILL_SOURCE,
92
+ PUSHARY_SKILL_NAME,
93
+ installSkillViaSkillsCli,
94
+ installAgentSkill,
95
+ registerCursorGate,
96
+ withoutPusharyCursorHooks,
97
+ createGuards,
98
+ describeSetupSideEffects
99
+ };
@@ -0,0 +1,185 @@
1
+ // src/pending.ts
2
+ import { join } from "path";
3
+ import { homedir, tmpdir } from "os";
4
+ import { createHash } from "crypto";
5
+ import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, renameSync, unlinkSync, rmSync, statSync } from "fs";
6
+ var PENDING_DIR = join(tmpdir(), "pushary-pending");
7
+ var commandRoot = () => process.env.PUSHARY_COMMAND_DIR?.trim() || join(homedir(), ".pushary", "run", "commands");
8
+ var DEFAULT_SESSION = "_no_session";
9
+ var GRACE_MS = 10 * 60 * 1e3;
10
+ var sanitize = (sessionId) => sessionId.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 128) || DEFAULT_SESSION;
11
+ var dirFor = (sessionId) => join(PENDING_DIR, sanitize(sessionId));
12
+ var commandDirFor = (sessionId, namespace = "") => join(
13
+ commandRoot(),
14
+ createHash("sha256").update(namespace).digest("hex").slice(0, 16),
15
+ sanitize(sessionId)
16
+ );
17
+ var legacyCommandFile = (sessionId, namespace = "") => join(commandDirFor(sessionId, namespace), "command.json");
18
+ var commandFile = (sessionId, id, namespace = "") => join(commandDirFor(sessionId, namespace), `${createHash("sha256").update(id).digest("hex")}.json`);
19
+ var readCommandFile = (file) => {
20
+ try {
21
+ const value = JSON.parse(readFileSync(file, "utf-8"));
22
+ if (typeof value.id !== "string" || typeof value.text !== "string" || typeof value.expiresAtMs !== "number") return null;
23
+ if (value.expiresAtMs <= Date.now()) {
24
+ unlinkSync(file);
25
+ return null;
26
+ }
27
+ return {
28
+ ...value,
29
+ delivered: value.delivered === true,
30
+ ...value.failed === true ? { failed: true } : {}
31
+ };
32
+ } catch {
33
+ return null;
34
+ }
35
+ };
36
+ var readPendingCommandById = (sessionId, id, namespace = "") => {
37
+ const current = readCommandFile(commandFile(sessionId, id, namespace));
38
+ if (current?.id === id) return current;
39
+ const legacy = readCommandFile(legacyCommandFile(sessionId, namespace));
40
+ return legacy?.id === id ? legacy : null;
41
+ };
42
+ var pruneExpiredCommands = (dir) => {
43
+ let files;
44
+ try {
45
+ files = readdirSync(dir).filter((file) => file.endsWith(".json"));
46
+ } catch {
47
+ return [];
48
+ }
49
+ return files.flatMap((file) => {
50
+ const command = readCommandFile(join(dir, file));
51
+ return command ? [command] : [];
52
+ });
53
+ };
54
+ var pruneExpiredCommandStore = () => {
55
+ let namespaces;
56
+ try {
57
+ namespaces = readdirSync(commandRoot(), { withFileTypes: true });
58
+ } catch {
59
+ return;
60
+ }
61
+ for (const namespace of namespaces.filter((entry) => entry.isDirectory())) {
62
+ const namespaceDir = join(commandRoot(), namespace.name);
63
+ let sessions;
64
+ try {
65
+ sessions = readdirSync(namespaceDir, { withFileTypes: true });
66
+ } catch {
67
+ continue;
68
+ }
69
+ for (const session of sessions.filter((entry) => entry.isDirectory())) {
70
+ pruneExpiredCommands(join(namespaceDir, session.name));
71
+ }
72
+ }
73
+ };
74
+ var readPendingCommand = (sessionId, namespace = "") => {
75
+ const commands = pruneExpiredCommands(commandDirFor(sessionId, namespace));
76
+ return commands.find((command) => !command.delivered && !command.failed) ?? commands[0] ?? null;
77
+ };
78
+ var savePendingCommand = (sessionId, command, namespace = "") => {
79
+ const dir = commandDirFor(sessionId, namespace);
80
+ try {
81
+ mkdirSync(dir, { recursive: true, mode: 448 });
82
+ pruneExpiredCommandStore();
83
+ if (readPendingCommandById(sessionId, command.id, namespace)) return false;
84
+ writeFileSync(commandFile(sessionId, command.id, namespace), JSON.stringify(command), { encoding: "utf-8", mode: 384, flag: "wx" });
85
+ return true;
86
+ } catch {
87
+ return false;
88
+ }
89
+ };
90
+ var updatePendingCommand = (sessionId, id, update, namespace = "") => {
91
+ const command = readPendingCommandById(sessionId, id, namespace);
92
+ if (!command) return false;
93
+ const currentFile = commandFile(sessionId, id, namespace);
94
+ const file = existsSync(currentFile) ? currentFile : legacyCommandFile(sessionId, namespace);
95
+ const temporary = `${file}.${process.pid}.tmp`;
96
+ try {
97
+ writeFileSync(temporary, JSON.stringify({ ...command, ...update, text: "" }), { encoding: "utf-8", mode: 384 });
98
+ renameSync(temporary, file);
99
+ return true;
100
+ } catch {
101
+ try {
102
+ unlinkSync(temporary);
103
+ } catch {
104
+ }
105
+ return false;
106
+ }
107
+ };
108
+ var markPendingCommandDelivered = (sessionId, id, namespace = "") => updatePendingCommand(sessionId, id, { delivered: true, failed: void 0 }, namespace);
109
+ var markPendingCommandFailed = (sessionId, id, namespace = "") => updatePendingCommand(sessionId, id, { delivered: false, failed: true }, namespace);
110
+ var removePendingCommand = (sessionId, id, namespace = "") => {
111
+ if (!readPendingCommandById(sessionId, id, namespace)) return;
112
+ try {
113
+ unlinkSync(commandFile(sessionId, id, namespace));
114
+ } catch {
115
+ }
116
+ try {
117
+ if (readCommandFile(legacyCommandFile(sessionId, namespace))?.id === id) {
118
+ unlinkSync(legacyCommandFile(sessionId, namespace));
119
+ }
120
+ } catch {
121
+ }
122
+ };
123
+ var isDefaultSession = (sessionId) => sanitize(sessionId) === DEFAULT_SESSION;
124
+ var listPendingQuestionsForToolUse = (sessionId, toolUseId) => {
125
+ if (!toolUseId) return [];
126
+ const dir = dirFor(sessionId);
127
+ let files;
128
+ try {
129
+ files = readdirSync(dir);
130
+ } catch {
131
+ return [];
132
+ }
133
+ return files.filter((name) => {
134
+ try {
135
+ return readFileSync(join(dir, name), "utf-8") === toolUseId;
136
+ } catch {
137
+ return false;
138
+ }
139
+ });
140
+ };
141
+ var listPendingQuestions = (sessionId) => {
142
+ const dir = dirFor(sessionId);
143
+ let files;
144
+ try {
145
+ files = readdirSync(dir);
146
+ } catch {
147
+ return [];
148
+ }
149
+ if (!isDefaultSession(sessionId)) return files;
150
+ const cutoff = Date.now() - GRACE_MS;
151
+ return files.filter((name) => {
152
+ try {
153
+ return statSync(join(dir, name)).mtimeMs < cutoff;
154
+ } catch {
155
+ return false;
156
+ }
157
+ });
158
+ };
159
+ var removePendingQuestion = (sessionId, correlationId) => {
160
+ try {
161
+ unlinkSync(join(dirFor(sessionId), correlationId));
162
+ } catch {
163
+ }
164
+ };
165
+ var removePendingSession = (sessionId) => {
166
+ try {
167
+ rmSync(dirFor(sessionId), { recursive: true, force: true });
168
+ } catch {
169
+ }
170
+ };
171
+
172
+ export {
173
+ DEFAULT_SESSION,
174
+ readPendingCommandById,
175
+ readPendingCommand,
176
+ savePendingCommand,
177
+ markPendingCommandDelivered,
178
+ markPendingCommandFailed,
179
+ removePendingCommand,
180
+ isDefaultSession,
181
+ listPendingQuestionsForToolUse,
182
+ listPendingQuestions,
183
+ removePendingQuestion,
184
+ removePendingSession
185
+ };
@@ -3,7 +3,7 @@ import {
3
3
  HOOK_LOCATOR_BINARY,
4
4
  isReleaseVersion,
5
5
  withHookHoldBudget
6
- } from "./chunk-XFNVG3OV.js";
6
+ } from "./chunk-WWTLAZQA.js";
7
7
 
8
8
  // src/npm.ts
9
9
  import { execFileSync, execSync } from "child_process";
@@ -56,6 +56,32 @@ var resolvePathBinary = (name, platform = process.platform) => {
56
56
  return void 0;
57
57
  }
58
58
  };
59
+ var NPM_MISSING_MESSAGE = "npm is not on PATH, and the hooks run from a global npm install.";
60
+ var NPM_LOOKUP = process.platform === "win32" ? "where npm" : "command -v npm";
61
+ var npmIsOnPath = () => {
62
+ try {
63
+ execSync(NPM_LOOKUP, { env: cleanNpmEnv(), stdio: "ignore", timeout: 5e3 });
64
+ return true;
65
+ } catch {
66
+ return false;
67
+ }
68
+ };
69
+ var GLOBAL_LIST_TIMEOUT_MS = 3e4;
70
+ var globalPackageState = (name) => {
71
+ try {
72
+ const listing = JSON.parse(execNpm("list -g --depth=0 --json --no-workspaces", { timeout: GLOBAL_LIST_TIMEOUT_MS }).toString());
73
+ const dependencies = typeof listing === "object" && listing !== null && "dependencies" in listing ? listing.dependencies : void 0;
74
+ return typeof dependencies === "object" && dependencies !== null && name in dependencies ? "installed" : "absent";
75
+ } catch {
76
+ return "unknown";
77
+ }
78
+ };
79
+ var NpmMissingError = class extends Error {
80
+ constructor() {
81
+ super(NPM_MISSING_MESSAGE);
82
+ this.name = "NpmMissingError";
83
+ }
84
+ };
59
85
  var resolveBinary = (name) => resolveGlobalBinary(name) ?? resolvePathBinary(name);
60
86
  var resolvePackageVersionFromBinary = (binary, packageName) => {
61
87
  try {
@@ -176,6 +202,7 @@ var installGlobally = (options) => {
176
202
  return installState.then((result) => result === "installed" ? "cached" : result);
177
203
  }
178
204
  const started = (async () => {
205
+ if (!npmIsOnPath()) throw new NpmMissingError();
179
206
  const pinned = process.env.PUSHARY_PIN_GLOBAL_VERSION !== "0";
180
207
  if (pinned && !needsGlobalInstall(
181
208
  options.version,
@@ -625,6 +652,7 @@ var autoUpdateLock = () => join3(pusharyDir(), "auto-update.lock");
625
652
  var autoUpdateLog = () => join3(pusharyDir(), "logs", "auto-update.log");
626
653
  var clientReportClaims = () => join3(pusharyDir(), "client-reports");
627
654
  var claudeRegistrationReceipt = () => join3(pusharyDir(), "setup", "claude-registration.json");
655
+ var hermesConfig = () => join3(homedir2(), ".hermes", "config.yaml");
628
656
  var hermesConfigReceipt = () => join3(pusharyDir(), "setup", "hermes-config.json");
629
657
  var fxQuestionRuleReceipt = () => join3(pusharyDir(), "setup", "fx-question-rule.json");
630
658
  var hookTakeoverReceipt = (agent) => join3(pusharyDir(), "setup", `hook-takeover-${agent}.json`);
@@ -642,11 +670,15 @@ export {
642
670
  registeredCommands,
643
671
  namesOurBinary,
644
672
  registrationHolderOf,
673
+ AGENT_HOOKS_PACKAGE,
645
674
  LATEST_TAG,
646
675
  npmErrorMessage,
647
676
  execNpm,
648
677
  resolveGlobalBinary,
649
678
  resolvePathBinary,
679
+ npmIsOnPath,
680
+ globalPackageState,
681
+ NpmMissingError,
650
682
  resolveBinary,
651
683
  resolvePackageVersionFromBinary,
652
684
  resolveGlobalPackageVersion,
@@ -704,6 +736,7 @@ export {
704
736
  autoUpdateLog,
705
737
  clientReportClaims,
706
738
  claudeRegistrationReceipt,
739
+ hermesConfig,
707
740
  hermesConfigReceipt,
708
741
  fxQuestionRuleReceipt,
709
742
  hookTakeoverReceipt,