@pushary/agent-hooks 0.52.0 → 0.53.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.
@@ -16,6 +16,8 @@ if (command === "setup") {
16
16
  await import("./pushary-wait.js");
17
17
  } else if (command === "stats") {
18
18
  await import("./pushary-stats.js");
19
+ } else if (command === "suggestions") {
20
+ await import("../pushary-suggestions-WIONM5ME.js");
19
21
  } else if (command === "upgrade") {
20
22
  await import("./pushary-upgrade.js");
21
23
  } else if (command === "claude") {
@@ -39,6 +41,8 @@ Commands:
39
41
  mode Switch approval mode (push_only, push_first, terminal_only)
40
42
  wait Show or set the "wait for your phone" ladder (pushary wait 45)
41
43
  stats Show the approval moments your agents hit while not connected
44
+ suggestions List rules mined from your own approvals; accept one with
45
+ 'pushary suggestions accept <id>' to always-allow that pattern
42
46
  upgrade Update the globally installed hooks to the latest version
43
47
  hook Run as a PreToolUse hook (reads stdin, writes stdout)
44
48
 
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ getApiKey,
4
+ getBaseUrl
5
+ } from "./chunk-NKXSILEW.js";
6
+
7
+ // bin/pushary-suggestions.ts
8
+ var dim = (s) => `\x1B[2m${s}\x1B[0m`;
9
+ var green = (s) => `\x1B[32m${s}\x1B[0m`;
10
+ var cyan = (s) => `\x1B[36m${s}\x1B[0m`;
11
+ var red = (s) => `\x1B[31m${s}\x1B[0m`;
12
+ var errorMessage = async (res) => {
13
+ try {
14
+ const body = await res.json();
15
+ return body.error ?? `HTTP ${res.status}`;
16
+ } catch {
17
+ return `HTTP ${res.status}`;
18
+ }
19
+ };
20
+ var main = async () => {
21
+ const apiKey = getApiKey();
22
+ const baseUrl = getBaseUrl();
23
+ const headers = { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" };
24
+ const rest = process.argv.slice(2);
25
+ const args = rest[0] === "suggestions" ? rest.slice(1) : rest;
26
+ const sub = args[0];
27
+ if (sub === "accept") {
28
+ const id = args[1];
29
+ if (!id) {
30
+ console.error("Usage: pushary suggestions accept <id>");
31
+ process.exit(1);
32
+ }
33
+ const res2 = await fetch(`${baseUrl}/api/mcp/suggestions`, {
34
+ method: "POST",
35
+ headers,
36
+ body: JSON.stringify({ id })
37
+ });
38
+ if (!res2.ok) {
39
+ console.error(` ${red("\u2717")} ${await errorMessage(res2)}`);
40
+ process.exit(1);
41
+ }
42
+ console.log(` ${green("\u2713")} Accepted. The rule is live now; your agents will pick it up on their next check.`);
43
+ return;
44
+ }
45
+ const res = await fetch(`${baseUrl}/api/mcp/suggestions`, { headers });
46
+ if (!res.ok) {
47
+ console.error(` ${red("\u2717")} ${await errorMessage(res)}`);
48
+ process.exit(1);
49
+ }
50
+ const { suggestions } = await res.json();
51
+ if (suggestions.length === 0) {
52
+ console.log(` ${dim("No pending suggestions. Keep approving; a rule is offered once a pattern is earned.")}`);
53
+ return;
54
+ }
55
+ console.log(` ${suggestions.length} pending suggestion${suggestions.length === 1 ? "" : "s"}:
56
+ `);
57
+ for (const s of suggestions) {
58
+ const verb = s.kind === "auto_approve" ? "Always allow" : "Always deny";
59
+ const evidence = s.kind === "auto_approve" ? `approved ${s.evidenceApproved}/${s.evidenceApproved + s.evidenceDenied} over ${s.windowDays}d` : `denied ${s.evidenceDenied}/${s.evidenceApproved + s.evidenceDenied} over ${s.windowDays}d`;
60
+ console.log(` ${cyan(s.toolPattern)} ${dim(s.id)}`);
61
+ console.log(` ${verb} \u2014 ${evidence}`);
62
+ console.log(` ${dim(`pushary suggestions accept ${s.id}`)}
63
+ `);
64
+ }
65
+ };
66
+ main().catch((err) => {
67
+ console.error(err instanceof Error ? err.message : String(err));
68
+ process.exit(1);
69
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushary/agent-hooks",
3
- "version": "0.52.0",
3
+ "version": "0.53.0",
4
4
  "description": "Permission hooks for AI coding agents: route tool approvals through Pushary push notifications",
5
5
  "keywords": [
6
6
  "pushary",