@pushary/agent-hooks 0.84.1 → 0.85.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 (54) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +24 -0
  3. package/dist/bin/pushary-bell-hook.js +5 -3
  4. package/dist/bin/pushary-bell.js +8 -7
  5. package/dist/bin/pushary-claude.js +5 -5
  6. package/dist/bin/pushary-clean.js +6 -5
  7. package/dist/bin/pushary-codex-bridge.js +2 -2
  8. package/dist/bin/pushary-codex-hook.js +7 -13
  9. package/dist/bin/pushary-codex.js +1 -1
  10. package/dist/bin/pushary-connect.js +5 -5
  11. package/dist/bin/pushary-daemon.js +5 -5
  12. package/dist/bin/pushary-disconnect.d.ts +1 -0
  13. package/dist/bin/pushary-disconnect.js +125 -0
  14. package/dist/bin/pushary-doctor.js +9 -9
  15. package/dist/bin/pushary-gemini-bridge.js +2 -2
  16. package/dist/bin/pushary-gemini-hook.js +7 -13
  17. package/dist/bin/pushary-hook.js +13 -20
  18. package/dist/bin/pushary-login.js +2 -2
  19. package/dist/bin/pushary-logout.js +3 -3
  20. package/dist/bin/pushary-mode.js +2 -2
  21. package/dist/bin/pushary-notification-hook.js +6 -9
  22. package/dist/bin/pushary-permission-denied-hook.js +11 -9
  23. package/dist/bin/pushary-permission-hook.js +11 -9
  24. package/dist/bin/pushary-post-hook.js +6 -9
  25. package/dist/bin/pushary-prompt-hook.js +6 -9
  26. package/dist/bin/pushary-session-end-hook.js +6 -6
  27. package/dist/bin/pushary-session-start-hook.js +6 -6
  28. package/dist/bin/pushary-setup.js +23 -24
  29. package/dist/bin/pushary-stats.js +2 -2
  30. package/dist/bin/pushary-status.js +2 -2
  31. package/dist/bin/pushary-stop-hook.js +6 -6
  32. package/dist/bin/pushary-stopfailure-hook.js +6 -6
  33. package/dist/bin/pushary-suggestions.js +2 -2
  34. package/dist/bin/pushary-upgrade.js +13 -8
  35. package/dist/bin/pushary-wait.js +2 -2
  36. package/dist/bin/pushary.js +2 -1
  37. package/dist/{chunk-HZNOAJGB.js → chunk-4QPOMJUB.js} +1 -1
  38. package/dist/chunk-64PXDATC.js +187 -0
  39. package/dist/chunk-6CUUA7HO.js +59 -0
  40. package/dist/{chunk-UXWEE3QI.js → chunk-ADISVXZL.js} +1 -1
  41. package/dist/chunk-AXRATIS6.js +70 -0
  42. package/dist/{chunk-CCCJ6BPW.js → chunk-EXMUM226.js} +19 -7
  43. package/dist/{chunk-YR5TSPXB.js → chunk-GFM3STWO.js} +3 -3
  44. package/dist/{chunk-MGJBC6DD.js → chunk-GOEXZ5QJ.js} +1 -0
  45. package/dist/{chunk-BLDDXHHA.js → chunk-GXIFADGD.js} +1 -1
  46. package/dist/{chunk-SEAHGHCE.js → chunk-HVZIHTOO.js} +33 -0
  47. package/dist/chunk-PWTKKQQI.js +27 -0
  48. package/dist/{chunk-J4KFVOCQ.js → chunk-SQOFGPNX.js} +1 -1
  49. package/dist/{chunk-CCH775Y6.js → chunk-WEAQQSHQ.js} +1 -1
  50. package/dist/{chunk-ILB6UOAF.js → chunk-YKW6JCWI.js} +1 -1
  51. package/dist/src/index.d.ts +1 -1
  52. package/dist/src/index.js +6 -4
  53. package/package.json +3 -2
  54. package/dist/chunk-UKSQWTBH.js +0 -208
@@ -1,208 +0,0 @@
1
- import {
2
- HOOK_BUDGETS
3
- } from "./chunk-MQMPG5X4.js";
4
-
5
- // src/claude-config.ts
6
- import { join } from "path";
7
- var PUSHARY_MCP_URL = "https://pushary.com/api/mcp/mcp";
8
- var PUSHARY_PERMISSION_RULE = "mcp__pushary__*";
9
- var PRETOOLUSE_GATED_TOOLS = ["Bash", "Write", "Edit", "MultiEdit", "NotebookEdit", "PowerShell", "Monitor"];
10
- var PRETOOLUSE_HANDLED_TOOLS = /* @__PURE__ */ new Set([...PRETOOLUSE_GATED_TOOLS, "AskUserQuestion"]);
11
- var asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
12
- var ensureRecord = (target, key) => {
13
- const existing = asRecord(target[key]);
14
- if (existing) return existing;
15
- const created = {};
16
- target[key] = created;
17
- return created;
18
- };
19
- var isPusharyPermission = (rule) => typeof rule === "string" && (rule.includes("pushary") || rule.includes("MCP(pushary"));
20
- var isPusharyHook = (entry) => {
21
- const hooks = asRecord(entry)?.hooks;
22
- if (!Array.isArray(hooks)) return false;
23
- return hooks.some((hook) => {
24
- const command = String(asRecord(hook)?.command ?? "");
25
- return command.includes("pushary-hook") || command.includes("pushary-post-hook") || command.includes("pushary-stop-hook") || command.includes("pushary-prompt-hook") || command.includes("pushary-notification-hook") || command.includes("pushary-session-start-hook") || command.includes("pushary-session-end-hook") || command.includes("pushary-stopfailure-hook") || command.includes("pushary-permission-hook") || command.includes("pushary-permission-denied-hook");
26
- });
27
- };
28
- var addClaudeMcpServer = (config, apiKey) => {
29
- const mcpServers = ensureRecord(config, "mcpServers");
30
- mcpServers.pushary = {
31
- type: "http",
32
- url: PUSHARY_MCP_URL,
33
- headers: { Authorization: `Bearer ${apiKey}` }
34
- };
35
- };
36
- var removeClaudeMcpServers = (config) => {
37
- let changed = false;
38
- const removeFrom = (target) => {
39
- const mcpServers = asRecord(target.mcpServers);
40
- if (!mcpServers?.pushary) return;
41
- delete mcpServers.pushary;
42
- if (Object.keys(mcpServers).length === 0) delete target.mcpServers;
43
- changed = true;
44
- };
45
- removeFrom(config);
46
- const projects = asRecord(config.projects);
47
- if (projects) {
48
- for (const project of Object.values(projects)) {
49
- const projectConfig = asRecord(project);
50
- if (projectConfig) removeFrom(projectConfig);
51
- }
52
- }
53
- return changed;
54
- };
55
- var addPusharyToolPermissions = (settings) => {
56
- const permissions = ensureRecord(settings, "permissions");
57
- const allow = Array.isArray(permissions.allow) ? permissions.allow : [];
58
- const filtered = allow.filter((rule) => !isPusharyPermission(rule));
59
- if (!filtered.includes(PUSHARY_PERMISSION_RULE)) {
60
- filtered.push(PUSHARY_PERMISSION_RULE);
61
- }
62
- permissions.allow = filtered;
63
- };
64
- var addPusharyHooks = (settings, binDir) => {
65
- const resolve = (name) => {
66
- const path = binDir ? join(binDir, name) : name;
67
- return /\s/.test(path) ? `"${path}"` : path;
68
- };
69
- const hooks = ensureRecord(settings, "hooks");
70
- const SHELL_AND_FILE_TOOLS = PRETOOLUSE_GATED_TOOLS.join("|");
71
- const preToolUse = (Array.isArray(hooks.PreToolUse) ? hooks.PreToolUse : []).filter((entry) => !isPusharyHook(entry));
72
- preToolUse.push({
73
- matcher: `${SHELL_AND_FILE_TOOLS}|AskUserQuestion`,
74
- hooks: [{
75
- type: "command",
76
- command: resolve("pushary-hook"),
77
- timeout: HOOK_BUDGETS.claude.budgetSeconds
78
- }]
79
- });
80
- hooks.PreToolUse = preToolUse;
81
- const postToolUse = (Array.isArray(hooks.PostToolUse) ? hooks.PostToolUse : []).filter((entry) => !isPusharyHook(entry));
82
- postToolUse.push({
83
- matcher: `${SHELL_AND_FILE_TOOLS}|TodoWrite`,
84
- hooks: [{
85
- type: "command",
86
- command: resolve("pushary-post-hook"),
87
- timeout: 10
88
- }]
89
- });
90
- hooks.PostToolUse = postToolUse;
91
- const stop = (Array.isArray(hooks.Stop) ? hooks.Stop : []).filter((entry) => !isPusharyHook(entry));
92
- stop.push({
93
- hooks: [{
94
- type: "command",
95
- command: resolve("pushary-stop-hook"),
96
- timeout: 10
97
- }]
98
- });
99
- hooks.Stop = stop;
100
- const userPromptSubmit = (Array.isArray(hooks.UserPromptSubmit) ? hooks.UserPromptSubmit : []).filter((entry) => !isPusharyHook(entry));
101
- userPromptSubmit.push({
102
- hooks: [{
103
- type: "command",
104
- command: resolve("pushary-prompt-hook"),
105
- timeout: 10
106
- }]
107
- });
108
- hooks.UserPromptSubmit = userPromptSubmit;
109
- const notification = (Array.isArray(hooks.Notification) ? hooks.Notification : []).filter((entry) => !isPusharyHook(entry));
110
- notification.push({
111
- matcher: "permission_prompt|idle_prompt|agent_needs_input|agent_completed",
112
- hooks: [{
113
- type: "command",
114
- command: resolve("pushary-notification-hook"),
115
- timeout: 10
116
- }]
117
- });
118
- hooks.Notification = notification;
119
- const sessionStart = (Array.isArray(hooks.SessionStart) ? hooks.SessionStart : []).filter((entry) => !isPusharyHook(entry));
120
- sessionStart.push({
121
- matcher: "startup|resume|clear",
122
- hooks: [{
123
- type: "command",
124
- command: resolve("pushary-session-start-hook"),
125
- timeout: 10
126
- }]
127
- });
128
- hooks.SessionStart = sessionStart;
129
- const sessionEnd = (Array.isArray(hooks.SessionEnd) ? hooks.SessionEnd : []).filter((entry) => !isPusharyHook(entry));
130
- sessionEnd.push({
131
- hooks: [{
132
- type: "command",
133
- command: resolve("pushary-session-end-hook"),
134
- timeout: 10
135
- }]
136
- });
137
- hooks.SessionEnd = sessionEnd;
138
- const stopFailure = (Array.isArray(hooks.StopFailure) ? hooks.StopFailure : []).filter((entry) => !isPusharyHook(entry));
139
- stopFailure.push({
140
- hooks: [{
141
- type: "command",
142
- command: resolve("pushary-stopfailure-hook"),
143
- timeout: 10
144
- }]
145
- });
146
- hooks.StopFailure = stopFailure;
147
- const permissionRequest = (Array.isArray(hooks.PermissionRequest) ? hooks.PermissionRequest : []).filter((entry) => !isPusharyHook(entry));
148
- permissionRequest.push({
149
- hooks: [{
150
- type: "command",
151
- command: resolve("pushary-permission-hook"),
152
- timeout: HOOK_BUDGETS.claude.budgetSeconds
153
- }]
154
- });
155
- hooks.PermissionRequest = permissionRequest;
156
- const permissionDenied = (Array.isArray(hooks.PermissionDenied) ? hooks.PermissionDenied : []).filter((entry) => !isPusharyHook(entry));
157
- permissionDenied.push({
158
- hooks: [{
159
- type: "command",
160
- command: resolve("pushary-permission-denied-hook"),
161
- timeout: 60
162
- }]
163
- });
164
- hooks.PermissionDenied = permissionDenied;
165
- };
166
- var removePusharySettings = (settings) => {
167
- let changed = removeClaudeMcpServers(settings);
168
- const permissions = asRecord(settings.permissions);
169
- if (permissions && Array.isArray(permissions.allow)) {
170
- const filtered = permissions.allow.filter((rule) => !isPusharyPermission(rule));
171
- if (filtered.length !== permissions.allow.length) {
172
- if (filtered.length === 0) {
173
- delete permissions.allow;
174
- } else {
175
- permissions.allow = filtered;
176
- }
177
- if (Object.keys(permissions).length === 0) delete settings.permissions;
178
- changed = true;
179
- }
180
- }
181
- const hooks = asRecord(settings.hooks);
182
- if (hooks) {
183
- for (const key of ["PreToolUse", "PostToolUse", "Stop", "StopFailure", "UserPromptSubmit", "Notification", "SessionStart", "SessionEnd", "PermissionRequest", "PermissionDenied"]) {
184
- const entries = hooks[key];
185
- if (!Array.isArray(entries)) continue;
186
- const filtered = entries.filter((entry) => !isPusharyHook(entry));
187
- if (filtered.length !== entries.length) {
188
- if (filtered.length === 0) {
189
- delete hooks[key];
190
- } else {
191
- hooks[key] = filtered;
192
- }
193
- changed = true;
194
- }
195
- }
196
- if (Object.keys(hooks).length === 0) delete settings.hooks;
197
- }
198
- return changed;
199
- };
200
-
201
- export {
202
- PRETOOLUSE_HANDLED_TOOLS,
203
- addClaudeMcpServer,
204
- removeClaudeMcpServers,
205
- addPusharyToolPermissions,
206
- addPusharyHooks,
207
- removePusharySettings
208
- };