@pushary/agent-hooks 0.66.0 → 0.67.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/CHANGELOG.md +34 -0
- package/data/vscode-plugin/.claude-plugin/plugin.json +28 -0
- package/data/vscode-plugin/.mcp.json +11 -0
- package/data/vscode-plugin/CHANGELOG.md +11 -0
- package/data/vscode-plugin/LICENSE +21 -0
- package/data/vscode-plugin/README.md +136 -0
- package/data/vscode-plugin/SECURITY.md +56 -0
- package/data/vscode-plugin/assets/logo.png +0 -0
- package/data/vscode-plugin/commands/notify-when-done.md +14 -0
- package/data/vscode-plugin/commands/pushary-test.md +13 -0
- package/data/vscode-plugin/hooks/hooks.json +11 -0
- package/data/vscode-plugin/scripts/pushary-gate.mjs +508 -0
- package/data/vscode-plugin/skills/pushary/SKILL.md +297 -0
- package/dist/bin/pushary-clean.js +29 -4
- package/dist/bin/pushary-doctor.js +42 -7
- package/dist/bin/pushary-logout.js +1 -1
- package/dist/bin/pushary-setup.js +129 -7
- package/dist/bin/pushary-upgrade.js +17 -5
- package/dist/{chunk-RU3CIBXY.js → chunk-7HG4WUIE.js} +4 -0
- package/dist/chunk-KB4ODLGB.js +332 -0
- package/package.json +1 -1
- package/dist/chunk-6G2BC4ET.js +0 -93
- package/dist/chunk-N7XJ4L2W.js +0 -79
|
@@ -20,8 +20,10 @@ import {
|
|
|
20
20
|
codexHooksJson,
|
|
21
21
|
cursorPluginDir,
|
|
22
22
|
geminiSettings,
|
|
23
|
-
hasCodexHooks
|
|
24
|
-
|
|
23
|
+
hasCodexHooks,
|
|
24
|
+
vscodePluginDir,
|
|
25
|
+
vscodePluginMcp
|
|
26
|
+
} from "../chunk-7HG4WUIE.js";
|
|
25
27
|
import {
|
|
26
28
|
readJsonSafe
|
|
27
29
|
} from "../chunk-6MTNS63X.js";
|
|
@@ -160,8 +162,7 @@ var reapplyGeminiSettings = (apiKey, paths = {}) => {
|
|
|
160
162
|
}
|
|
161
163
|
return { reapplied: hooks || mcp, hooks, mcp };
|
|
162
164
|
};
|
|
163
|
-
var
|
|
164
|
-
const mcpPath = paths.pluginMcpPath ?? join(homedir(), ".cursor", "plugins", "local", "pushary", "mcp.json");
|
|
165
|
+
var reapplyPluginMcp = (mcpPath, apiKey) => {
|
|
165
166
|
if (!apiKey) return { reapplied: false, hooks: false, mcp: false };
|
|
166
167
|
const mcpConfig = readJson(mcpPath);
|
|
167
168
|
if (mcpConfig == null) return { reapplied: false, hooks: false, mcp: false };
|
|
@@ -175,12 +176,18 @@ var reapplyCursorPlugin = (apiKey, paths = {}) => {
|
|
|
175
176
|
return { reapplied: false, hooks: false, mcp: false };
|
|
176
177
|
}
|
|
177
178
|
};
|
|
179
|
+
var reapplyCursorPlugin = (apiKey, paths = {}) => reapplyPluginMcp(
|
|
180
|
+
paths.pluginMcpPath ?? join(homedir(), ".cursor", "plugins", "local", "pushary", "mcp.json"),
|
|
181
|
+
apiKey
|
|
182
|
+
);
|
|
183
|
+
var reapplyVsCodePlugin = (apiKey, paths = {}) => reapplyPluginMcp(paths.pluginMcpPath ?? vscodePluginMcp(), apiKey);
|
|
178
184
|
var reapplyAllAgents = (apiKey) => {
|
|
179
185
|
const runners = [
|
|
180
186
|
{ label: "Claude Code", run: () => reapplyClaudeSettings(apiKey) },
|
|
181
187
|
{ label: "Codex", run: () => reapplyCodexSettings(apiKey) },
|
|
182
188
|
{ label: "Gemini CLI", run: () => reapplyGeminiSettings(apiKey) },
|
|
183
|
-
{ label: "Cursor", run: () => reapplyCursorPlugin(apiKey) }
|
|
189
|
+
{ label: "Cursor", run: () => reapplyCursorPlugin(apiKey) },
|
|
190
|
+
{ label: "VS Code", run: () => reapplyVsCodePlugin(apiKey) }
|
|
184
191
|
];
|
|
185
192
|
const done = [];
|
|
186
193
|
for (const runner of runners) {
|
|
@@ -202,6 +209,11 @@ var detectInstallModes = () => {
|
|
|
202
209
|
upgrade: "updates itself through Cursor",
|
|
203
210
|
present: existsSync2(cursorPluginDir())
|
|
204
211
|
},
|
|
212
|
+
{
|
|
213
|
+
label: "VS Code plugin",
|
|
214
|
+
upgrade: "npx @pushary/agent-hooks@latest setup --agents vscode",
|
|
215
|
+
present: existsSync2(vscodePluginDir())
|
|
216
|
+
},
|
|
205
217
|
{
|
|
206
218
|
label: "Codex config",
|
|
207
219
|
upgrade: "npx @pushary/agent-hooks@latest setup --agents codex",
|
|
@@ -158,6 +158,8 @@ var claudeSkillDir = () => join2(homedir2(), ".claude", "skills", "pushary");
|
|
|
158
158
|
var cursorPluginDir = () => join2(homedir2(), ".cursor", "plugins", "local", "pushary");
|
|
159
159
|
var cursorUserHooks = () => join2(homedir2(), ".cursor", "hooks.json");
|
|
160
160
|
var cursorUserMcp = () => join2(homedir2(), ".cursor", "mcp.json");
|
|
161
|
+
var vscodePluginDir = () => join2(homedir2(), ".pushary", "plugins", "vscode");
|
|
162
|
+
var vscodePluginMcp = () => join2(vscodePluginDir(), ".mcp.json");
|
|
161
163
|
var claudeSettingsLocal = () => join2(homedir2(), ".claude", "settings.local.json");
|
|
162
164
|
var pusharyDir = () => join2(homedir2(), ".pushary");
|
|
163
165
|
var codexSkillDir2 = () => join2(codexHome(), "skills", "pushary");
|
|
@@ -188,6 +190,8 @@ export {
|
|
|
188
190
|
cursorPluginDir,
|
|
189
191
|
cursorUserHooks,
|
|
190
192
|
cursorUserMcp,
|
|
193
|
+
vscodePluginDir,
|
|
194
|
+
vscodePluginMcp,
|
|
191
195
|
claudeSettingsLocal,
|
|
192
196
|
pusharyDir,
|
|
193
197
|
codexSkillDir2,
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import {
|
|
2
|
+
codexHomeFrom
|
|
3
|
+
} from "./chunk-7HG4WUIE.js";
|
|
4
|
+
|
|
5
|
+
// src/vscode-config.ts
|
|
6
|
+
import { homedir } from "os";
|
|
7
|
+
import { join } from "path";
|
|
8
|
+
var PLUGIN_LOCATIONS_KEY = "chat.pluginLocations";
|
|
9
|
+
var blankJsonComments = (text) => {
|
|
10
|
+
let out = "";
|
|
11
|
+
let i = 0;
|
|
12
|
+
let inString = false;
|
|
13
|
+
let escaped = false;
|
|
14
|
+
while (i < text.length) {
|
|
15
|
+
const ch = text[i];
|
|
16
|
+
if (inString) {
|
|
17
|
+
out += ch;
|
|
18
|
+
if (escaped) escaped = false;
|
|
19
|
+
else if (ch === "\\") escaped = true;
|
|
20
|
+
else if (ch === '"') inString = false;
|
|
21
|
+
i += 1;
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (ch === '"') {
|
|
25
|
+
inString = true;
|
|
26
|
+
out += ch;
|
|
27
|
+
i += 1;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (ch === "/" && text[i + 1] === "/") {
|
|
31
|
+
while (i < text.length && text[i] !== "\n") {
|
|
32
|
+
out += " ";
|
|
33
|
+
i += 1;
|
|
34
|
+
}
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (ch === "/" && text[i + 1] === "*") {
|
|
38
|
+
const end = text.indexOf("*/", i + 2);
|
|
39
|
+
const stop = end === -1 ? text.length : end + 2;
|
|
40
|
+
while (i < stop) {
|
|
41
|
+
out += text[i] === "\n" ? "\n" : " ";
|
|
42
|
+
i += 1;
|
|
43
|
+
}
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
out += ch;
|
|
47
|
+
i += 1;
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
};
|
|
51
|
+
var asRecord = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
52
|
+
var parseJsonc = (text) => {
|
|
53
|
+
const blanked = blankJsonComments(text);
|
|
54
|
+
const withoutTrailingCommas = blanked.replace(/,(\s*[}\]])/g, "$1");
|
|
55
|
+
try {
|
|
56
|
+
return asRecord(JSON.parse(withoutTrailingCommas));
|
|
57
|
+
} catch {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var rootBraceIndex = (text) => blankJsonComments(text).indexOf("{");
|
|
62
|
+
var detectIndent = (text) => {
|
|
63
|
+
const match = /\n([ \t]+)"/.exec(text);
|
|
64
|
+
return match?.[1] ?? " ";
|
|
65
|
+
};
|
|
66
|
+
var freshDocument = (pluginDir, indent = " ") => `${JSON.stringify({ [PLUGIN_LOCATIONS_KEY]: { [pluginDir]: true } }, null, indent)}
|
|
67
|
+
`;
|
|
68
|
+
var registerPluginLocation = (existing, pluginDir) => {
|
|
69
|
+
if (existing === null || existing.trim() === "") {
|
|
70
|
+
return { kind: "created", content: freshDocument(pluginDir) };
|
|
71
|
+
}
|
|
72
|
+
const indent = detectIndent(existing);
|
|
73
|
+
try {
|
|
74
|
+
const parsed2 = asRecord(JSON.parse(existing));
|
|
75
|
+
if (parsed2) {
|
|
76
|
+
const locations2 = asRecord(parsed2[PLUGIN_LOCATIONS_KEY]) ?? {};
|
|
77
|
+
if (locations2[pluginDir] === true) return { kind: "already" };
|
|
78
|
+
parsed2[PLUGIN_LOCATIONS_KEY] = { ...locations2, [pluginDir]: true };
|
|
79
|
+
return { kind: "merged", content: `${JSON.stringify(parsed2, null, indent)}
|
|
80
|
+
` };
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
const parsed = parseJsonc(existing);
|
|
85
|
+
if (!parsed) return { kind: "manual" };
|
|
86
|
+
const locations = asRecord(parsed[PLUGIN_LOCATIONS_KEY]);
|
|
87
|
+
if (locations?.[pluginDir] === true) return { kind: "already" };
|
|
88
|
+
if (parsed[PLUGIN_LOCATIONS_KEY] !== void 0) return { kind: "manual" };
|
|
89
|
+
const brace = rootBraceIndex(existing);
|
|
90
|
+
if (brace === -1) return { kind: "manual" };
|
|
91
|
+
const needsComma = Object.keys(parsed).length > 0;
|
|
92
|
+
const line = `
|
|
93
|
+
${indent}${JSON.stringify(PLUGIN_LOCATIONS_KEY)}: { ${JSON.stringify(pluginDir)}: true }${needsComma ? "," : ""}`;
|
|
94
|
+
return {
|
|
95
|
+
kind: "inserted",
|
|
96
|
+
content: `${existing.slice(0, brace + 1)}${line}${existing.slice(brace + 1)}`
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
var unregisterPluginLocation = (existing, pluginDir) => {
|
|
100
|
+
if (existing === null || existing.trim() === "") return { kind: "absent" };
|
|
101
|
+
const indent = detectIndent(existing);
|
|
102
|
+
try {
|
|
103
|
+
const parsed2 = asRecord(JSON.parse(existing));
|
|
104
|
+
if (parsed2) {
|
|
105
|
+
const locations2 = asRecord(parsed2[PLUGIN_LOCATIONS_KEY]);
|
|
106
|
+
if (!locations2 || !(pluginDir in locations2)) return { kind: "absent" };
|
|
107
|
+
const remaining = { ...locations2 };
|
|
108
|
+
delete remaining[pluginDir];
|
|
109
|
+
if (Object.keys(remaining).length === 0) delete parsed2[PLUGIN_LOCATIONS_KEY];
|
|
110
|
+
else parsed2[PLUGIN_LOCATIONS_KEY] = remaining;
|
|
111
|
+
return { kind: "removed", content: `${JSON.stringify(parsed2, null, indent)}
|
|
112
|
+
` };
|
|
113
|
+
}
|
|
114
|
+
} catch {
|
|
115
|
+
}
|
|
116
|
+
const parsed = parseJsonc(existing);
|
|
117
|
+
if (!parsed) return { kind: "manual" };
|
|
118
|
+
const locations = asRecord(parsed[PLUGIN_LOCATIONS_KEY]);
|
|
119
|
+
if (!locations || !(pluginDir in locations)) return { kind: "absent" };
|
|
120
|
+
const line = new RegExp(
|
|
121
|
+
`\\n[ \\t]*${escapeRegExp(JSON.stringify(PLUGIN_LOCATIONS_KEY))}\\s*:\\s*\\{\\s*${escapeRegExp(JSON.stringify(pluginDir))}\\s*:\\s*true\\s*\\},?`
|
|
122
|
+
);
|
|
123
|
+
if (!line.test(existing)) return { kind: "manual" };
|
|
124
|
+
return { kind: "removed", content: existing.replace(line, "") };
|
|
125
|
+
};
|
|
126
|
+
var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
127
|
+
var isPluginRegistered = (existing, pluginDir) => {
|
|
128
|
+
if (!existing) return false;
|
|
129
|
+
const parsed = parseJsonc(existing);
|
|
130
|
+
return asRecord(parsed?.[PLUGIN_LOCATIONS_KEY])?.[pluginDir] === true;
|
|
131
|
+
};
|
|
132
|
+
var pluginLocationSnippet = (pluginDir) => `"${PLUGIN_LOCATIONS_KEY}": {
|
|
133
|
+
${JSON.stringify(pluginDir)}: true
|
|
134
|
+
}`;
|
|
135
|
+
var VSCODE_PRODUCTS = ["Code", "Code - Insiders"];
|
|
136
|
+
var settingsRoot = (home, platform) => {
|
|
137
|
+
if (platform === "darwin") return join(home, "Library", "Application Support");
|
|
138
|
+
if (platform === "win32") return process.env.APPDATA?.trim() || join(home, "AppData", "Roaming");
|
|
139
|
+
return process.env.XDG_CONFIG_HOME?.trim() || join(home, ".config");
|
|
140
|
+
};
|
|
141
|
+
var vscodeSettingsCandidates = (home = homedir(), platform = process.platform) => {
|
|
142
|
+
const root = settingsRoot(home, platform);
|
|
143
|
+
return VSCODE_PRODUCTS.map((product) => join(root, product, "User", "settings.json"));
|
|
144
|
+
};
|
|
145
|
+
var vscodeSettingsTargets = (exists, home, platform) => {
|
|
146
|
+
const candidates = vscodeSettingsCandidates(home, platform);
|
|
147
|
+
const present = candidates.filter((path) => exists(path));
|
|
148
|
+
return present.length > 0 ? present : candidates.slice(0, 1);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/setup/detect.ts
|
|
152
|
+
import { execSync } from "child_process";
|
|
153
|
+
import { existsSync } from "fs";
|
|
154
|
+
import { homedir as homedir2 } from "os";
|
|
155
|
+
import { dirname, join as join2 } from "path";
|
|
156
|
+
var whichCommand = () => process.platform === "win32" ? "where" : "which";
|
|
157
|
+
var binaryOnPath = (binary) => {
|
|
158
|
+
try {
|
|
159
|
+
execSync(`${whichCommand()} ${binary}`, { stdio: "ignore", timeout: 5e3 });
|
|
160
|
+
return true;
|
|
161
|
+
} catch {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
var defaultDeps = { onPath: binaryOnPath, exists: existsSync };
|
|
166
|
+
var detectAgent = (probe, deps = defaultDeps) => {
|
|
167
|
+
const checked = [];
|
|
168
|
+
if (probe.binary) {
|
|
169
|
+
checked.push(`${whichCommand()} ${probe.binary}`);
|
|
170
|
+
if (deps.onPath(probe.binary)) {
|
|
171
|
+
return { kind: "installed", evidence: `${probe.binary} on PATH`, strong: true };
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
for (const path of probe.paths) {
|
|
175
|
+
checked.push(path);
|
|
176
|
+
if (deps.exists(path)) return { kind: "installed", evidence: path, strong: true };
|
|
177
|
+
}
|
|
178
|
+
for (const marker of probe.configMarkers) {
|
|
179
|
+
checked.push(marker);
|
|
180
|
+
if (deps.exists(marker)) return { kind: "installed", evidence: marker, strong: false };
|
|
181
|
+
}
|
|
182
|
+
if (probe.binary === null && probe.paths.length === 0 && probe.configMarkers.length === 0) {
|
|
183
|
+
return { kind: "unknown" };
|
|
184
|
+
}
|
|
185
|
+
return { kind: "not-found", checked };
|
|
186
|
+
};
|
|
187
|
+
var agentProbes = (home = homedir2()) => ({
|
|
188
|
+
claude_code: {
|
|
189
|
+
binary: "claude",
|
|
190
|
+
// The native installer puts it here, outside a default non-login PATH.
|
|
191
|
+
paths: [join2(home, ".local", "bin", "claude")],
|
|
192
|
+
configMarkers: [join2(home, ".claude")]
|
|
193
|
+
},
|
|
194
|
+
codex: {
|
|
195
|
+
binary: "codex",
|
|
196
|
+
paths: [],
|
|
197
|
+
configMarkers: [codexHomeFrom(home)]
|
|
198
|
+
},
|
|
199
|
+
gemini_cli: {
|
|
200
|
+
binary: "gemini",
|
|
201
|
+
paths: [],
|
|
202
|
+
configMarkers: [join2(home, ".gemini")]
|
|
203
|
+
},
|
|
204
|
+
hermes: {
|
|
205
|
+
binary: "hermes",
|
|
206
|
+
paths: [],
|
|
207
|
+
configMarkers: [join2(home, ".hermes")]
|
|
208
|
+
},
|
|
209
|
+
cursor: {
|
|
210
|
+
// GUI editor. `cursor` on PATH only exists if the user ran "Install 'cursor'
|
|
211
|
+
// command in PATH" from the command palette, which most never do.
|
|
212
|
+
binary: "cursor",
|
|
213
|
+
paths: process.platform === "darwin" ? ["/Applications/Cursor.app"] : process.platform === "win32" ? [join2(process.env.LOCALAPPDATA ?? join2(home, "AppData", "Local"), "Programs", "cursor")] : ["/usr/share/cursor", join2(home, ".local", "share", "cursor")],
|
|
214
|
+
configMarkers: [join2(home, ".cursor")]
|
|
215
|
+
},
|
|
216
|
+
vscode: {
|
|
217
|
+
// Like Cursor, a GUI editor: `code` on PATH only exists if the user ran
|
|
218
|
+
// "Shell Command: Install 'code' command in PATH", which on macOS is opt-in.
|
|
219
|
+
binary: "code",
|
|
220
|
+
paths: process.platform === "darwin" ? ["/Applications/Visual Studio Code.app"] : process.platform === "win32" ? [join2(process.env.LOCALAPPDATA ?? join2(home, "AppData", "Local"), "Programs", "Microsoft VS Code")] : ["/usr/share/code", join2(home, ".local", "share", "code")],
|
|
221
|
+
// The settings directory rather than ~/.vscode, because the settings
|
|
222
|
+
// directory is what this installer actually writes to. Insiders counts:
|
|
223
|
+
// someone running only Insiders still has VS Code.
|
|
224
|
+
configMarkers: vscodeSettingsCandidates(home).map((path) => dirname(path))
|
|
225
|
+
},
|
|
226
|
+
// "Other" is a set of printed instructions for any MCP or HTTP client. There is
|
|
227
|
+
// nothing to detect, and it must never be auto-selected.
|
|
228
|
+
custom: { binary: null, paths: [], configMarkers: [] }
|
|
229
|
+
});
|
|
230
|
+
var detectAllAgents = (deps = defaultDeps, home) => {
|
|
231
|
+
const probes = agentProbes(home);
|
|
232
|
+
return Object.keys(probes).map((agent) => ({
|
|
233
|
+
agent,
|
|
234
|
+
result: detectAgent(probes[agent], deps)
|
|
235
|
+
}));
|
|
236
|
+
};
|
|
237
|
+
var isDetected = (result) => result.kind === "installed";
|
|
238
|
+
var shortenHome = (path, home = homedir2()) => home && path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
239
|
+
var describeDetection = (result, home) => {
|
|
240
|
+
if (result.kind !== "installed") return null;
|
|
241
|
+
const evidence = shortenHome(result.evidence, home);
|
|
242
|
+
return result.strong ? evidence : `${evidence}, config only`;
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
// src/instruction-file.ts
|
|
246
|
+
import { existsSync as existsSync2, readFileSync, writeFileSync, mkdirSync, rmSync } from "fs";
|
|
247
|
+
import { dirname as dirname2 } from "path";
|
|
248
|
+
var PUSHARY_BEGIN = "<!-- BEGIN PUSHARY (managed by @pushary/agent-hooks; do not edit this block) -->";
|
|
249
|
+
var PUSHARY_END = "<!-- END PUSHARY -->";
|
|
250
|
+
var instructionBody = (label) => `## Pushary notifications and approvals
|
|
251
|
+
|
|
252
|
+
You have Pushary MCP tools that reach the user on their phone. Use them proactively. Do not wait for the user to ask.
|
|
253
|
+
|
|
254
|
+
- When you need the user to make a decision or answer a clarifying question, call \`ask_user\` instead of guessing or stalling. Use type "confirm" for yes/no, "select" for a fixed set of options, and "input" for free text. \`ask_user\` blocks until the user replies or it times out, so you do not need a separate wait step.
|
|
255
|
+
- Before any risky or irreversible step (deleting files, force pushing, spending money, sending external messages), call \`ask_user\` with type "confirm" and wait for approval.
|
|
256
|
+
- Before starting a multi-step run that will change several files, call \`propose_scope\` once with the paths you expect to change, anything you promise not to touch, and what done means. The user agrees to the boundary in one tap, and after that only work outside it needs approving. Skip it for a single quick edit, and do not propose a new scope mid-run just to widen one: if you need to go outside the agreed scope, do the work and let the approval that follows widen it.
|
|
257
|
+
- When you are blocked, stuck, or hit an error you cannot resolve on your own, call \`send_notification\` so the user knows, and call \`ask_user\` if you need a decision to continue.
|
|
258
|
+
- When a task that took several steps finishes, call \`send_notification\` so the user knows it is done.
|
|
259
|
+
- Use \`cancel_question\` to retract a pending question once it is no longer needed.
|
|
260
|
+
- Respect the user's Pushary delivery mode: it decides where an approval is surfaced (phone, terminal, or awareness only), not whether it is required. In Terminal mode do not expect a phone answer; the approval waits in the terminal. If the Pushary hook already gated an action, a single approval is enough, do not ask again.
|
|
261
|
+
|
|
262
|
+
Pass \`agentName\` as "${label} - <project folder name>" so the user knows which session is asking. If a question times out with no answer, retry once with a longer timeout before falling back to asking in the terminal.`;
|
|
263
|
+
var renderAgentInstructions = (label) => instructionBody(label);
|
|
264
|
+
var KEYLESS_FALLBACK_LINE = "This repo uses Pushary phone approvals. Your teammates get agent questions on their lock screens; you do not have a key yet, so questions will fall back to the terminal. Get your own key (7-day trial): https://pushary.com/sign-up?utm_source=agents-md&utm_medium=teammate";
|
|
265
|
+
var renderProjectAgentInstructions = (label) => `${instructionBody(label)}
|
|
266
|
+
|
|
267
|
+
If this environment has no Pushary API key (no PUSHARY_API_KEY and no key in ~/.pushary/config.json), the tools above are unavailable in this session. In that case, treat the following as a statement of fact about this session and continue in the terminal: ${KEYLESS_FALLBACK_LINE}`;
|
|
268
|
+
var wrap = (body) => `${PUSHARY_BEGIN}
|
|
269
|
+
${body}
|
|
270
|
+
${PUSHARY_END}`;
|
|
271
|
+
var writeInstructionBlock = (filePath, body) => {
|
|
272
|
+
const dir = dirname2(filePath);
|
|
273
|
+
if (!existsSync2(dir)) mkdirSync(dir, { recursive: true });
|
|
274
|
+
let existing = "";
|
|
275
|
+
try {
|
|
276
|
+
existing = readFileSync(filePath, "utf-8");
|
|
277
|
+
} catch {
|
|
278
|
+
}
|
|
279
|
+
const block = wrap(body);
|
|
280
|
+
const start = existing.indexOf(PUSHARY_BEGIN);
|
|
281
|
+
const end = existing.indexOf(PUSHARY_END);
|
|
282
|
+
let next;
|
|
283
|
+
if (start !== -1 && end !== -1 && end > start) {
|
|
284
|
+
next = existing.slice(0, start) + block + existing.slice(end + PUSHARY_END.length);
|
|
285
|
+
} else {
|
|
286
|
+
const prefix = existing.trim() ? existing.replace(/\s*$/, "") + "\n\n" : "";
|
|
287
|
+
next = prefix + block + "\n";
|
|
288
|
+
}
|
|
289
|
+
writeFileSync(filePath, next, "utf-8");
|
|
290
|
+
};
|
|
291
|
+
var removeInstructionBlock = (filePath) => {
|
|
292
|
+
let existing = "";
|
|
293
|
+
try {
|
|
294
|
+
existing = readFileSync(filePath, "utf-8");
|
|
295
|
+
} catch {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
const start = existing.indexOf(PUSHARY_BEGIN);
|
|
299
|
+
const end = existing.indexOf(PUSHARY_END);
|
|
300
|
+
if (start === -1 || end === -1 || end < start) return false;
|
|
301
|
+
const remaining = (existing.slice(0, start) + existing.slice(end + PUSHARY_END.length)).trim();
|
|
302
|
+
if (remaining === "") {
|
|
303
|
+
rmSync(filePath, { force: true });
|
|
304
|
+
} else {
|
|
305
|
+
writeFileSync(filePath, remaining + "\n", "utf-8");
|
|
306
|
+
}
|
|
307
|
+
return true;
|
|
308
|
+
};
|
|
309
|
+
var hasInstructionBlock = (filePath) => {
|
|
310
|
+
try {
|
|
311
|
+
return readFileSync(filePath, "utf-8").includes(PUSHARY_BEGIN);
|
|
312
|
+
} catch {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
|
|
317
|
+
export {
|
|
318
|
+
registerPluginLocation,
|
|
319
|
+
unregisterPluginLocation,
|
|
320
|
+
isPluginRegistered,
|
|
321
|
+
pluginLocationSnippet,
|
|
322
|
+
vscodeSettingsTargets,
|
|
323
|
+
detectAllAgents,
|
|
324
|
+
isDetected,
|
|
325
|
+
shortenHome,
|
|
326
|
+
describeDetection,
|
|
327
|
+
renderAgentInstructions,
|
|
328
|
+
renderProjectAgentInstructions,
|
|
329
|
+
writeInstructionBlock,
|
|
330
|
+
removeInstructionBlock,
|
|
331
|
+
hasInstructionBlock
|
|
332
|
+
};
|
package/package.json
CHANGED
package/dist/chunk-6G2BC4ET.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
codexHomeFrom
|
|
3
|
-
} from "./chunk-RU3CIBXY.js";
|
|
4
|
-
|
|
5
|
-
// src/setup/detect.ts
|
|
6
|
-
import { execSync } from "child_process";
|
|
7
|
-
import { existsSync } from "fs";
|
|
8
|
-
import { homedir } from "os";
|
|
9
|
-
import { join } from "path";
|
|
10
|
-
var whichCommand = () => process.platform === "win32" ? "where" : "which";
|
|
11
|
-
var binaryOnPath = (binary) => {
|
|
12
|
-
try {
|
|
13
|
-
execSync(`${whichCommand()} ${binary}`, { stdio: "ignore", timeout: 5e3 });
|
|
14
|
-
return true;
|
|
15
|
-
} catch {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
var defaultDeps = { onPath: binaryOnPath, exists: existsSync };
|
|
20
|
-
var detectAgent = (probe, deps = defaultDeps) => {
|
|
21
|
-
const checked = [];
|
|
22
|
-
if (probe.binary) {
|
|
23
|
-
checked.push(`${whichCommand()} ${probe.binary}`);
|
|
24
|
-
if (deps.onPath(probe.binary)) {
|
|
25
|
-
return { kind: "installed", evidence: `${probe.binary} on PATH`, strong: true };
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
for (const path of probe.paths) {
|
|
29
|
-
checked.push(path);
|
|
30
|
-
if (deps.exists(path)) return { kind: "installed", evidence: path, strong: true };
|
|
31
|
-
}
|
|
32
|
-
for (const marker of probe.configMarkers) {
|
|
33
|
-
checked.push(marker);
|
|
34
|
-
if (deps.exists(marker)) return { kind: "installed", evidence: marker, strong: false };
|
|
35
|
-
}
|
|
36
|
-
if (probe.binary === null && probe.paths.length === 0 && probe.configMarkers.length === 0) {
|
|
37
|
-
return { kind: "unknown" };
|
|
38
|
-
}
|
|
39
|
-
return { kind: "not-found", checked };
|
|
40
|
-
};
|
|
41
|
-
var agentProbes = (home = homedir()) => ({
|
|
42
|
-
claude_code: {
|
|
43
|
-
binary: "claude",
|
|
44
|
-
// The native installer puts it here, outside a default non-login PATH.
|
|
45
|
-
paths: [join(home, ".local", "bin", "claude")],
|
|
46
|
-
configMarkers: [join(home, ".claude")]
|
|
47
|
-
},
|
|
48
|
-
codex: {
|
|
49
|
-
binary: "codex",
|
|
50
|
-
paths: [],
|
|
51
|
-
configMarkers: [codexHomeFrom(home)]
|
|
52
|
-
},
|
|
53
|
-
gemini_cli: {
|
|
54
|
-
binary: "gemini",
|
|
55
|
-
paths: [],
|
|
56
|
-
configMarkers: [join(home, ".gemini")]
|
|
57
|
-
},
|
|
58
|
-
hermes: {
|
|
59
|
-
binary: "hermes",
|
|
60
|
-
paths: [],
|
|
61
|
-
configMarkers: [join(home, ".hermes")]
|
|
62
|
-
},
|
|
63
|
-
cursor: {
|
|
64
|
-
// GUI editor. `cursor` on PATH only exists if the user ran "Install 'cursor'
|
|
65
|
-
// command in PATH" from the command palette, which most never do.
|
|
66
|
-
binary: "cursor",
|
|
67
|
-
paths: process.platform === "darwin" ? ["/Applications/Cursor.app"] : process.platform === "win32" ? [join(process.env.LOCALAPPDATA ?? join(home, "AppData", "Local"), "Programs", "cursor")] : ["/usr/share/cursor", join(home, ".local", "share", "cursor")],
|
|
68
|
-
configMarkers: [join(home, ".cursor")]
|
|
69
|
-
},
|
|
70
|
-
// "Other" is a set of printed instructions for any MCP or HTTP client. There is
|
|
71
|
-
// nothing to detect, and it must never be auto-selected.
|
|
72
|
-
custom: { binary: null, paths: [], configMarkers: [] }
|
|
73
|
-
});
|
|
74
|
-
var detectAllAgents = (deps = defaultDeps, home) => {
|
|
75
|
-
const probes = agentProbes(home);
|
|
76
|
-
return Object.keys(probes).map((agent) => ({
|
|
77
|
-
agent,
|
|
78
|
-
result: detectAgent(probes[agent], deps)
|
|
79
|
-
}));
|
|
80
|
-
};
|
|
81
|
-
var isDetected = (result) => result.kind === "installed";
|
|
82
|
-
var shortenHome = (path, home = homedir()) => home && path.startsWith(home) ? `~${path.slice(home.length)}` : path;
|
|
83
|
-
var describeDetection = (result, home) => {
|
|
84
|
-
if (result.kind !== "installed") return null;
|
|
85
|
-
const evidence = shortenHome(result.evidence, home);
|
|
86
|
-
return result.strong ? evidence : `${evidence}, config only`;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export {
|
|
90
|
-
detectAllAgents,
|
|
91
|
-
isDetected,
|
|
92
|
-
describeDetection
|
|
93
|
-
};
|
package/dist/chunk-N7XJ4L2W.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
// src/instruction-file.ts
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync, mkdirSync, rmSync } from "fs";
|
|
3
|
-
import { dirname } from "path";
|
|
4
|
-
var PUSHARY_BEGIN = "<!-- BEGIN PUSHARY (managed by @pushary/agent-hooks; do not edit this block) -->";
|
|
5
|
-
var PUSHARY_END = "<!-- END PUSHARY -->";
|
|
6
|
-
var instructionBody = (label) => `## Pushary notifications and approvals
|
|
7
|
-
|
|
8
|
-
You have Pushary MCP tools that reach the user on their phone. Use them proactively. Do not wait for the user to ask.
|
|
9
|
-
|
|
10
|
-
- When you need the user to make a decision or answer a clarifying question, call \`ask_user\` instead of guessing or stalling. Use type "confirm" for yes/no, "select" for a fixed set of options, and "input" for free text. \`ask_user\` blocks until the user replies or it times out, so you do not need a separate wait step.
|
|
11
|
-
- Before any risky or irreversible step (deleting files, force pushing, spending money, sending external messages), call \`ask_user\` with type "confirm" and wait for approval.
|
|
12
|
-
- Before starting a multi-step run that will change several files, call \`propose_scope\` once with the paths you expect to change, anything you promise not to touch, and what done means. The user agrees to the boundary in one tap, and after that only work outside it needs approving. Skip it for a single quick edit, and do not propose a new scope mid-run just to widen one: if you need to go outside the agreed scope, do the work and let the approval that follows widen it.
|
|
13
|
-
- When you are blocked, stuck, or hit an error you cannot resolve on your own, call \`send_notification\` so the user knows, and call \`ask_user\` if you need a decision to continue.
|
|
14
|
-
- When a task that took several steps finishes, call \`send_notification\` so the user knows it is done.
|
|
15
|
-
- Use \`cancel_question\` to retract a pending question once it is no longer needed.
|
|
16
|
-
- Respect the user's Pushary delivery mode: it decides where an approval is surfaced (phone, terminal, or awareness only), not whether it is required. In Terminal mode do not expect a phone answer; the approval waits in the terminal. If the Pushary hook already gated an action, a single approval is enough, do not ask again.
|
|
17
|
-
|
|
18
|
-
Pass \`agentName\` as "${label} - <project folder name>" so the user knows which session is asking. If a question times out with no answer, retry once with a longer timeout before falling back to asking in the terminal.`;
|
|
19
|
-
var renderAgentInstructions = (label) => instructionBody(label);
|
|
20
|
-
var KEYLESS_FALLBACK_LINE = "This repo uses Pushary phone approvals. Your teammates get agent questions on their lock screens; you do not have a key yet, so questions will fall back to the terminal. Get your own key (7-day trial): https://pushary.com/sign-up?utm_source=agents-md&utm_medium=teammate";
|
|
21
|
-
var renderProjectAgentInstructions = (label) => `${instructionBody(label)}
|
|
22
|
-
|
|
23
|
-
If this environment has no Pushary API key (no PUSHARY_API_KEY and no key in ~/.pushary/config.json), the tools above are unavailable in this session. In that case, treat the following as a statement of fact about this session and continue in the terminal: ${KEYLESS_FALLBACK_LINE}`;
|
|
24
|
-
var wrap = (body) => `${PUSHARY_BEGIN}
|
|
25
|
-
${body}
|
|
26
|
-
${PUSHARY_END}`;
|
|
27
|
-
var writeInstructionBlock = (filePath, body) => {
|
|
28
|
-
const dir = dirname(filePath);
|
|
29
|
-
if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
|
|
30
|
-
let existing = "";
|
|
31
|
-
try {
|
|
32
|
-
existing = readFileSync(filePath, "utf-8");
|
|
33
|
-
} catch {
|
|
34
|
-
}
|
|
35
|
-
const block = wrap(body);
|
|
36
|
-
const start = existing.indexOf(PUSHARY_BEGIN);
|
|
37
|
-
const end = existing.indexOf(PUSHARY_END);
|
|
38
|
-
let next;
|
|
39
|
-
if (start !== -1 && end !== -1 && end > start) {
|
|
40
|
-
next = existing.slice(0, start) + block + existing.slice(end + PUSHARY_END.length);
|
|
41
|
-
} else {
|
|
42
|
-
const prefix = existing.trim() ? existing.replace(/\s*$/, "") + "\n\n" : "";
|
|
43
|
-
next = prefix + block + "\n";
|
|
44
|
-
}
|
|
45
|
-
writeFileSync(filePath, next, "utf-8");
|
|
46
|
-
};
|
|
47
|
-
var removeInstructionBlock = (filePath) => {
|
|
48
|
-
let existing = "";
|
|
49
|
-
try {
|
|
50
|
-
existing = readFileSync(filePath, "utf-8");
|
|
51
|
-
} catch {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
const start = existing.indexOf(PUSHARY_BEGIN);
|
|
55
|
-
const end = existing.indexOf(PUSHARY_END);
|
|
56
|
-
if (start === -1 || end === -1 || end < start) return false;
|
|
57
|
-
const remaining = (existing.slice(0, start) + existing.slice(end + PUSHARY_END.length)).trim();
|
|
58
|
-
if (remaining === "") {
|
|
59
|
-
rmSync(filePath, { force: true });
|
|
60
|
-
} else {
|
|
61
|
-
writeFileSync(filePath, remaining + "\n", "utf-8");
|
|
62
|
-
}
|
|
63
|
-
return true;
|
|
64
|
-
};
|
|
65
|
-
var hasInstructionBlock = (filePath) => {
|
|
66
|
-
try {
|
|
67
|
-
return readFileSync(filePath, "utf-8").includes(PUSHARY_BEGIN);
|
|
68
|
-
} catch {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export {
|
|
74
|
-
renderAgentInstructions,
|
|
75
|
-
renderProjectAgentInstructions,
|
|
76
|
-
writeInstructionBlock,
|
|
77
|
-
removeInstructionBlock,
|
|
78
|
-
hasInstructionBlock
|
|
79
|
-
};
|