@pushary/agent-hooks 0.3.0 → 0.4.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.
package/data/SKILL.md ADDED
@@ -0,0 +1,293 @@
1
+ ---
2
+ name: pushary
3
+ version: 0.1.0
4
+ description: Push notifications and human-in-the-loop for AI coding agents. Send alerts when tasks finish, ask questions (yes/no, multiple choice, or free text) via push, and get answers from the user's lock screen. Use these tools proactively — do not wait for the user to ask for notifications. Works with Cursor, Claude Code, Windsurf, Hermes, and any MCP client.
5
+ metadata:
6
+ hermes:
7
+ tags: [notifications, push, human-in-the-loop, alerts, permissions, mcp]
8
+ category: productivity
9
+ requires_toolsets: []
10
+ tags: notifications, push, mcp, human-in-the-loop, cursor, claude, windsurf, hermes, alerts, permissions
11
+ ---
12
+
13
+ # Pushary — Push Notifications for AI Agents
14
+
15
+ Pushary is an MCP server that gives you three capabilities:
16
+
17
+ 1. **Send push notifications** to the user's phone or desktop when a task finishes or an error occurs.
18
+ 2. **Ask questions** via push — yes/no, multiple choice, or free text — and wait for the user's answer.
19
+ 3. **Send rich context notifications** with file changes, error details, next steps, and embedded questions.
20
+
21
+ Use these tools proactively. Do not wait for the user to ask for notifications.
22
+
23
+ ## When to Use
24
+
25
+ **Send a notification when:**
26
+ - You finish a task that took 3 or more steps — use `context.type = "task_complete"`
27
+ - A build, test suite, or deployment fails — use `context.type = "error"` with `errorMessage`
28
+ - A long-running process completes (migration, refactor, generation)
29
+ - A status update is worth sharing — use `context.type = "info"`
30
+
31
+ **Ask with type "confirm" when:**
32
+ - You need confirmation before a destructive or irreversible action
33
+ - Binary decision: proceed or abort
34
+
35
+ **Ask with type "select" when:**
36
+ - Multiple implementation approaches exist (2-6 options)
37
+ - The user needs to pick from a known set
38
+
39
+ **Ask with type "input" when:**
40
+ - You need a name, path, value, or free-text decision
41
+ - The options cannot be enumerated in advance
42
+
43
+ **Do NOT notify when:**
44
+ - The task is trivial or single-step
45
+ - The question can be answered from context without user input
46
+ - You already sent 3 notifications for the current task (unless the user explicitly asked for more)
47
+
48
+ ## Setup
49
+
50
+ Add Pushary to your MCP configuration:
51
+
52
+ ```json
53
+ {
54
+ "mcpServers": {
55
+ "pushary": {
56
+ "url": "https://pushary.com/api/mcp/mcp"
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ Sign up at https://pushary.com/sign-up?from=ai-coding to get your API key.
63
+
64
+ ## Tools
65
+
66
+ ### send_notification
67
+
68
+ Send a one-way push notification to the user. Optionally include structured context for a rich detail page.
69
+
70
+ **Parameters:**
71
+
72
+ | Name | Type | Required | Description |
73
+ |------|------|----------|-------------|
74
+ | title | string | Yes | Notification title (max 100 chars, aim for under 60) |
75
+ | body | string | Yes | Notification body (max 500 chars, aim for under 200) |
76
+ | url | string | No | URL opened when tapped. Ignored if context is provided. |
77
+ | agentName | string | No | Identifies which agent sent this (e.g., "Claude Code - myproject") |
78
+ | iconUrl | string | No | Custom notification icon URL |
79
+ | imageUrl | string | No | Large image shown in the notification |
80
+ | subscriberIds | string[] | No | Target specific subscriber IDs |
81
+ | externalIds | string[] | No | Target by external IDs |
82
+ | tags | string[] | No | Target by subscriber tags |
83
+ | context | object | No | Structured context for a rich detail page (see below) |
84
+
85
+ **Context object:**
86
+
87
+ | Name | Type | Description |
88
+ |------|------|-------------|
89
+ | type | "task_complete" / "error" / "info" | The kind of notification |
90
+ | summary | string | Short summary of what happened |
91
+ | details | string[] | Bullet-point details |
92
+ | filesChanged | string[] | List of files that were changed |
93
+ | errorMessage | string | Error message (for error type) |
94
+ | errorFile | string | File path where the error occurred |
95
+ | nextSteps | string | Suggested next steps for the user |
96
+ | askQuestion | object | Embed a decision prompt in the notification (see below) |
97
+
98
+ **Embedded askQuestion:**
99
+
100
+ | Name | Type | Description |
101
+ |------|------|-------------|
102
+ | question | string | A follow-up question shown below the context |
103
+ | type | "confirm" / "select" / "input" | Question type (default: confirm) |
104
+ | options | string[] | Options for select type (2-6 items) |
105
+
106
+ When `askQuestion` is provided, the response includes a `linkedCorrelationId` you pass to `wait_for_answer`.
107
+
108
+ **Example — task completed with context:**
109
+
110
+ ```json
111
+ {
112
+ "title": "Refactoring complete",
113
+ "body": "Extracted 3 shared components across 12 files",
114
+ "agentName": "Claude Code - pushary repo",
115
+ "context": {
116
+ "type": "task_complete",
117
+ "summary": "Extracted shared Button, Modal, and Card components from 12 files",
118
+ "filesChanged": ["src/components/Button.tsx", "src/components/Modal.tsx", "src/components/Card.tsx"],
119
+ "nextSteps": "Run the test suite to verify no regressions"
120
+ }
121
+ }
122
+ ```
123
+
124
+ **Example — error with embedded question:**
125
+
126
+ ```json
127
+ {
128
+ "title": "Build failed",
129
+ "body": "TypeScript error in auth.ts:42",
130
+ "agentName": "Claude Code - api-server",
131
+ "context": {
132
+ "type": "error",
133
+ "errorMessage": "Type 'string' is not assignable to type 'AuthToken'",
134
+ "errorFile": "src/auth.ts:42",
135
+ "summary": "The auth token type changed upstream and this file needs updating",
136
+ "askQuestion": {
137
+ "question": "Should I update the type or revert the upstream change?",
138
+ "type": "select",
139
+ "options": ["Update the type in auth.ts", "Revert the upstream change", "Skip for now"]
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ ### ask_user
146
+
147
+ Send a question to the user via push notification. Supports three question types. Returns a `correlationId` that you pass to `wait_for_answer` to get the response.
148
+
149
+ **Parameters:**
150
+
151
+ | Name | Type | Required | Description |
152
+ |------|------|----------|-------------|
153
+ | question | string | Yes | The question to ask (max 500 chars) |
154
+ | type | "confirm" / "select" / "input" | No | Question type (default: confirm) |
155
+ | options | string[] | No | Choices for select type (2-6 options). Required when type is select. |
156
+ | placeholder | string | No | Placeholder text for input type (max 200 chars) |
157
+ | context | string | No | What the agent is working on, shown above the question (max 500 chars) |
158
+ | agentName | string | No | Identifies which agent is asking (e.g., "Claude Code - myproject") |
159
+ | callbackUrl | string | No | Webhook URL to POST the answer to when the user responds |
160
+ | subscriberIds | string[] | No | Target specific subscriber IDs |
161
+ | externalIds | string[] | No | Target by external IDs |
162
+ | tags | string[] | No | Target by subscriber tags |
163
+
164
+ **Returns:** `{ "correlationId": "uuid", "status": "pending", "expiresInSeconds": 600 }`
165
+
166
+ **Example — confirm (yes/no):**
167
+
168
+ ```json
169
+ {
170
+ "question": "Delete the 3 unused migration files?",
171
+ "type": "confirm",
172
+ "context": "Cleaning up old database migrations in db/migrate/",
173
+ "agentName": "Claude Code - myproject"
174
+ }
175
+ ```
176
+
177
+ **Example — select (multiple choice):**
178
+
179
+ ```json
180
+ {
181
+ "question": "Which auth strategy should I use?",
182
+ "type": "select",
183
+ "options": ["JWT tokens", "Session cookies", "OAuth2 + PKCE"],
184
+ "context": "Setting up authentication for the new API endpoints",
185
+ "agentName": "Claude Code - api-server"
186
+ }
187
+ ```
188
+
189
+ **Example — input (free text):**
190
+
191
+ ```json
192
+ {
193
+ "question": "What should the new API endpoint path be?",
194
+ "type": "input",
195
+ "placeholder": "/api/v2/...",
196
+ "context": "Creating a new REST endpoint for user preferences",
197
+ "agentName": "Cursor - frontend"
198
+ }
199
+ ```
200
+
201
+ ### wait_for_answer
202
+
203
+ Long-poll for the user's response to a question sent via `ask_user`. Blocks until the user responds or the timeout is reached.
204
+
205
+ **Parameters:**
206
+
207
+ | Name | Type | Required | Description |
208
+ |------|------|----------|-------------|
209
+ | correlationId | string (uuid) | Yes | The correlationId from ask_user |
210
+ | timeoutMs | integer | No | How long to wait (default 30000, max 55000) |
211
+
212
+ **Returns:**
213
+ - `{ "answered": true, "value": "yes" }` — user responded
214
+ - `{ "answered": false }` — timeout reached, no answer yet
215
+
216
+ ### cancel_question
217
+
218
+ Cancel a pending question so it can no longer be answered. Use when the question becomes irrelevant (e.g., you found the answer another way or the user responded in chat).
219
+
220
+ **Parameters:**
221
+
222
+ | Name | Type | Required | Description |
223
+ |------|------|----------|-------------|
224
+ | correlationId | string (uuid) | Yes | The correlationId of the question to cancel |
225
+
226
+ ## Permission Gating (REQUIRED)
227
+
228
+ Before executing any of the following, you MUST call `ask_user` with type "confirm" and wait for approval. Do NOT proceed without an explicit "yes" from the user:
229
+
230
+ - File deletion (`rm`, `unlink`, any destructive file operation)
231
+ - Database mutations (`DROP`, `DELETE`, `TRUNCATE`, migrations)
232
+ - Deployment commands (`deploy`, `push`, `publish`, `release`)
233
+ - System administration (`systemctl`, `service`, package install/remove)
234
+ - Git operations that rewrite history (`reset --hard`, `push --force`, `rebase`)
235
+ - Network configuration changes (firewall, DNS, proxy)
236
+ - Any command the user has flagged as dangerous
237
+
238
+ If `wait_for_answer` returns `answered: false` after 3 attempts, do NOT execute the command. Notify the user that the operation was skipped due to no response.
239
+
240
+ This is not optional. Treat it as a hard constraint, not a suggestion.
241
+
242
+ ## Human-in-the-Loop Flow
243
+
244
+ Follow this exact sequence when you need a decision from the user:
245
+
246
+ 1. Call `ask_user` with a clear, concise question and the appropriate type.
247
+ 2. Immediately call `wait_for_answer` with the returned `correlationId` and `timeoutMs: 55000`.
248
+ 3. If `wait_for_answer` returns `{ "answered": false }`, retry the same `wait_for_answer` call up to 3 times. The answer persists in Redis for 10 minutes, so it will be there when the user responds.
249
+ 4. Once you receive `{ "answered": true, "value": "..." }`, act on the decision.
250
+ 5. If the user answers in chat before the push response arrives, continue normally and call `cancel_question` to clean up.
251
+
252
+ **Pseudocode:**
253
+
254
+ ```
255
+ result = ask_user({
256
+ question: "Which auth strategy should I use?",
257
+ type: "select",
258
+ options: ["JWT tokens", "Session cookies", "OAuth2 + PKCE"],
259
+ context: "Setting up authentication for the new API",
260
+ agentName: "Claude Code - myproject"
261
+ })
262
+ correlationId = result.correlationId
263
+
264
+ for attempt in 1..3:
265
+ answer = wait_for_answer({ correlationId, timeoutMs: 55000 })
266
+ if answer.answered:
267
+ // answer.value = "JWT tokens" (the selected option)
268
+ // proceed with the chosen approach
269
+ break
270
+
271
+ if not answer.answered after 3 attempts:
272
+ // user did not respond — pick the safe default or ask in chat
273
+ ```
274
+
275
+ ## Identifying Your Agent
276
+
277
+ Always pass `agentName` when you are one of multiple possible agents the user may be running. The user sees this in the notification title to know which agent is asking.
278
+
279
+ **Format:** `{Agent Type} - {project or context}`
280
+
281
+ **Examples:**
282
+ - `"Claude Code - pushary repo"`
283
+ - `"Hermes - daily-briefing"`
284
+ - `"Cursor - frontend refactor"`
285
+
286
+ ## Notification Etiquette
287
+
288
+ - **Titles under 60 characters.** They get truncated on phone lock screens.
289
+ - **Bodies under 200 characters.** Concise summaries, not full explanations.
290
+ - **Max 3 notifications per task** unless the user explicitly requests more.
291
+ - **Use context for detail.** Put file lists, error traces, and next steps in the context object — not the notification body.
292
+ - **Write questions as if talking to a busy person.** The user is on their phone, possibly away from their computer. Be specific: "Delete the 3 unused migration files?" is better than "Should I clean up?"
293
+ - **Pick the right question type.** Use confirm for binary decisions, select when options are known, input when they are not.
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env node
2
+
3
+ // bin/pushary-clean.ts
4
+ import { existsSync, readFileSync, writeFileSync, rmSync } from "fs";
5
+ import { join } from "path";
6
+ import { homedir } from "os";
7
+ import { execSync } from "child_process";
8
+ var dim = (s) => `\x1B[2m${s}\x1B[0m`;
9
+ var bold = (s) => `\x1B[1m${s}\x1B[0m`;
10
+ var green = (s) => `\x1B[32m${s}\x1B[0m`;
11
+ var yellow = (s) => `\x1B[33m${s}\x1B[0m`;
12
+ var check = green("\u2713");
13
+ var skip = yellow("\u2013");
14
+ var CLAUDE_SETTINGS = join(homedir(), ".claude", "settings.json");
15
+ var CLAUDE_SETTINGS_LOCAL = join(homedir(), ".claude", "settings.local.json");
16
+ var SKILL_DIR = join(homedir(), ".claude", "skills", "pushary");
17
+ var CURSOR_MCP = join(".cursor", "mcp.json");
18
+ var SHELL_FILES = [".zshrc", ".bashrc"].map((f) => join(homedir(), f));
19
+ var readJson = (path) => {
20
+ try {
21
+ return JSON.parse(readFileSync(path, "utf-8"));
22
+ } catch {
23
+ return null;
24
+ }
25
+ };
26
+ var writeJson = (path, data) => {
27
+ writeFileSync(path, JSON.stringify(data, null, 2) + "\n", "utf-8");
28
+ };
29
+ var isPusharyPermission = (rule) => rule.includes("pushary") || rule.includes("MCP(pushary");
30
+ var isPusharyHook = (entry) => {
31
+ const hooks = entry.hooks;
32
+ if (!hooks) return false;
33
+ return hooks.some((h) => {
34
+ const cmd = String(h.command ?? "");
35
+ return cmd.includes("pushary-hook") || cmd.includes("pushary-post-hook") || cmd.includes("pushary-stop-hook");
36
+ });
37
+ };
38
+ var cleanSettingsFile = (path, label) => {
39
+ const data = readJson(path);
40
+ if (!data) {
41
+ console.log(` ${skip} ${label} ${dim("(not found)")}`);
42
+ return;
43
+ }
44
+ let changed = false;
45
+ const mcpServers = data.mcpServers;
46
+ if (mcpServers?.pushary) {
47
+ delete mcpServers.pushary;
48
+ if (Object.keys(mcpServers).length === 0) delete data.mcpServers;
49
+ changed = true;
50
+ }
51
+ const permissions = data.permissions;
52
+ if (permissions?.allow) {
53
+ const allow = permissions.allow;
54
+ const filtered = allow.filter((r) => !isPusharyPermission(r));
55
+ if (filtered.length !== allow.length) {
56
+ permissions.allow = filtered;
57
+ if (filtered.length === 0) delete permissions.allow;
58
+ if (Object.keys(permissions).length === 0) delete data.permissions;
59
+ changed = true;
60
+ }
61
+ }
62
+ const hooks = data.hooks;
63
+ if (hooks) {
64
+ for (const key of ["PreToolUse", "PostToolUse", "Stop"]) {
65
+ const entries = hooks[key];
66
+ if (!entries) continue;
67
+ const filtered = entries.filter((e) => !isPusharyHook(e));
68
+ if (filtered.length !== entries.length) {
69
+ if (filtered.length === 0) {
70
+ delete hooks[key];
71
+ } else {
72
+ hooks[key] = filtered;
73
+ }
74
+ changed = true;
75
+ }
76
+ }
77
+ if (Object.keys(hooks).length === 0) delete data.hooks;
78
+ }
79
+ if (changed) {
80
+ writeJson(path, data);
81
+ console.log(` ${check} ${label} ${dim("(cleaned)")}`);
82
+ } else {
83
+ console.log(` ${skip} ${label} ${dim("(no pushary entries)")}`);
84
+ }
85
+ };
86
+ var main = async () => {
87
+ console.log();
88
+ console.log(` ${bold("Pushary Clean")}`);
89
+ console.log(` ${dim("Removes all Pushary configuration")}`);
90
+ console.log();
91
+ cleanSettingsFile(CLAUDE_SETTINGS, "Claude Code settings");
92
+ cleanSettingsFile(CLAUDE_SETTINGS_LOCAL, "Claude Code settings.local");
93
+ const cursorData = readJson(CURSOR_MCP);
94
+ if (cursorData) {
95
+ const mcpServers = cursorData.mcpServers;
96
+ if (mcpServers?.pushary) {
97
+ delete mcpServers.pushary;
98
+ writeJson(CURSOR_MCP, cursorData);
99
+ console.log(` ${check} Cursor MCP config ${dim("(cleaned)")}`);
100
+ } else {
101
+ console.log(` ${skip} Cursor MCP config ${dim("(no pushary entries)")}`);
102
+ }
103
+ } else {
104
+ console.log(` ${skip} Cursor MCP config ${dim("(not found)")}`);
105
+ }
106
+ if (existsSync(SKILL_DIR)) {
107
+ rmSync(SKILL_DIR, { recursive: true });
108
+ console.log(` ${check} Skill directory ${dim("(removed)")}`);
109
+ } else {
110
+ console.log(` ${skip} Skill directory ${dim("(not found)")}`);
111
+ }
112
+ const codexConfig = join(homedir(), ".codex", "config.toml");
113
+ try {
114
+ let config = readFileSync(codexConfig, "utf-8");
115
+ if (config.includes("pushary-codex")) {
116
+ config = config.split("\n").filter((l) => !l.includes("pushary-codex")).join("\n");
117
+ writeFileSync(codexConfig, config, "utf-8");
118
+ console.log(` ${check} Codex config ${dim("(cleaned)")}`);
119
+ } else {
120
+ console.log(` ${skip} Codex config ${dim("(no pushary entries)")}`);
121
+ }
122
+ } catch {
123
+ console.log(` ${skip} Codex config ${dim("(not found)")}`);
124
+ }
125
+ for (const shellFile of SHELL_FILES) {
126
+ try {
127
+ const content = readFileSync(shellFile, "utf-8");
128
+ if (content.includes("PUSHARY_API_KEY")) {
129
+ const cleaned = content.split("\n").filter((l) => !l.includes("PUSHARY_API_KEY")).join("\n");
130
+ writeFileSync(shellFile, cleaned, "utf-8");
131
+ console.log(` ${check} ${shellFile.split("/").pop()} ${dim("(removed API key)")}`);
132
+ }
133
+ } catch {
134
+ }
135
+ }
136
+ try {
137
+ execSync("npm uninstall -g @pushary/agent-hooks", { stdio: "ignore" });
138
+ console.log(` ${check} Global package ${dim("(uninstalled)")}`);
139
+ } catch {
140
+ console.log(` ${skip} Global package ${dim("(not installed)")}`);
141
+ }
142
+ console.log();
143
+ console.log(` ${green(bold("Clean complete."))}`);
144
+ console.log(` ${dim("Run")} npx @pushary/agent-hooks@latest setup ${dim("to reinstall.")}`);
145
+ console.log();
146
+ };
147
+ main();
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node