@aligndottech/cli 0.7.0 → 0.8.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/README.md +24 -8
- package/dist/commands/check.d.ts +10 -0
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +50 -15
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/import/confluence.d.ts.map +1 -1
- package/dist/commands/import/confluence.js +3 -1
- package/dist/commands/import/confluence.js.map +1 -1
- package/dist/commands/import/git.d.ts.map +1 -1
- package/dist/commands/import/git.js +3 -1
- package/dist/commands/import/git.js.map +1 -1
- package/dist/commands/import/github.d.ts.map +1 -1
- package/dist/commands/import/github.js +3 -1
- package/dist/commands/import/github.js.map +1 -1
- package/dist/commands/import/gitlab.d.ts.map +1 -1
- package/dist/commands/import/gitlab.js +3 -1
- package/dist/commands/import/gitlab.js.map +1 -1
- package/dist/commands/import/jira.d.ts.map +1 -1
- package/dist/commands/import/jira.js +3 -1
- package/dist/commands/import/jira.js.map +1 -1
- package/dist/commands/import/linear.d.ts.map +1 -1
- package/dist/commands/import/linear.js +3 -1
- package/dist/commands/import/linear.js.map +1 -1
- package/dist/commands/import/notion.d.ts.map +1 -1
- package/dist/commands/import/notion.js +3 -1
- package/dist/commands/import/notion.js.map +1 -1
- package/dist/commands/import/slack.d.ts.map +1 -1
- package/dist/commands/import/slack.js +3 -1
- package/dist/commands/import/slack.js.map +1 -1
- package/dist/commands/import/teams.d.ts.map +1 -1
- package/dist/commands/import/teams.js +3 -1
- package/dist/commands/import/teams.js.map +1 -1
- package/dist/commands/import/zoom.d.ts.map +1 -1
- package/dist/commands/import/zoom.js +3 -1
- package/dist/commands/import/zoom.js.map +1 -1
- package/dist/commands/import.d.ts.map +1 -1
- package/dist/commands/import.js +7 -3
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +20 -1
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/setup.js +1 -1
- package/dist/commands/setup.js.map +1 -1
- package/dist/lib/agent-rules.d.ts +4 -0
- package/dist/lib/agent-rules.d.ts.map +1 -1
- package/dist/lib/agent-rules.js +264 -1
- package/dist/lib/agent-rules.js.map +1 -1
- package/dist/lib/command-opts.d.ts +15 -0
- package/dist/lib/command-opts.d.ts.map +1 -0
- package/dist/lib/command-opts.js +16 -0
- package/dist/lib/command-opts.js.map +1 -0
- package/dist/lib/hook-payload.d.ts +1 -0
- package/dist/lib/hook-payload.d.ts.map +1 -1
- package/dist/lib/hook-payload.js +107 -5
- package/dist/lib/hook-payload.js.map +1 -1
- package/dist/lib/local-embeddings.d.ts.map +1 -1
- package/dist/lib/local-embeddings.js +10 -4
- package/dist/lib/local-embeddings.js.map +1 -1
- package/dist/lib/mcp-setup.d.ts +2 -1
- package/dist/lib/mcp-setup.d.ts.map +1 -1
- package/dist/lib/mcp-setup.js +23 -2
- package/dist/lib/mcp-setup.js.map +1 -1
- package/package.json +2 -2
package/dist/lib/agent-rules.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { alignServerEntry } from './mcp-setup.js';
|
|
3
4
|
// ALI-121: the deterministic auto-alignment layer. ALI-120 gave the MCP server
|
|
4
5
|
// instructions (model discretion); these project-local, committed files make the
|
|
5
6
|
// alignment context fire regardless of which agent/model the user runs:
|
|
@@ -141,6 +142,252 @@ export function writeCursorRule(cwd) {
|
|
|
141
142
|
mkdirSync(dir, { recursive: true });
|
|
142
143
|
writeFileSync(path.join(dir, 'align.md'), cursorRuleBody(), 'utf8');
|
|
143
144
|
}
|
|
145
|
+
// .mcp.json - the tool-agnostic, project-local MCP config. pi reads it (via
|
|
146
|
+
// pi-mcp-adapter), so does Claude Code, and it is committed, so one write covers the
|
|
147
|
+
// whole team rather than each person's per-host config. Deliberately host-NEUTRAL: pi's
|
|
148
|
+
// `directTools` goes in the Pi-owned override that mcp-setup.ts writes, never here.
|
|
149
|
+
export function writeProjectMcpConfig(cwd, env) {
|
|
150
|
+
const file = path.join(cwd, '.mcp.json');
|
|
151
|
+
let raw = '';
|
|
152
|
+
try {
|
|
153
|
+
raw = readFileSync(file, 'utf8');
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
if (err.code !== 'ENOENT')
|
|
157
|
+
throw err;
|
|
158
|
+
}
|
|
159
|
+
let config = {};
|
|
160
|
+
if (raw.trim()) {
|
|
161
|
+
try {
|
|
162
|
+
config = JSON.parse(raw);
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
throw new Error(`${file} contains invalid JSON - fix it manually before running align setup`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const servers = (config['mcpServers'] ?? {});
|
|
169
|
+
servers['align'] = alignServerEntry('mcpServers', env);
|
|
170
|
+
config['mcpServers'] = servers;
|
|
171
|
+
writeFileSync(file, `${JSON.stringify(config, null, 2)}\n`, 'utf8');
|
|
172
|
+
}
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
// Per-host hook shims (the agent-agnostic guardrail)
|
|
175
|
+
// ---------------------------------------------------------------------------
|
|
176
|
+
// One advisory engine, N hosts. `align check --advisory --format <host>` reads the
|
|
177
|
+
// host's payload on stdin and prints the shape that host reads back. All a shim does
|
|
178
|
+
// is register that command and move the bytes. Which hosts can do what, and why, is
|
|
179
|
+
// the table in docs/agent-hooks.md - the differences are the hosts', not ours.
|
|
180
|
+
// pi discovers project extensions at .pi/extensions/*.ts and loads them with jiti, so
|
|
181
|
+
// this ships as TypeScript and is never compiled by us.
|
|
182
|
+
//
|
|
183
|
+
// Two events, because pi splits the two halves of what Claude Code does in one:
|
|
184
|
+
// tool_call fires BEFORE the edit, but its only return channel is {block, reason}
|
|
185
|
+
// tool_result fires after, and CAN patch the content the model reads
|
|
186
|
+
// So the check runs pre-edit (the point of ALI-122) and its finding is replayed into
|
|
187
|
+
// that same call's result - non-blocking by default, exactly like the Claude hook.
|
|
188
|
+
//
|
|
189
|
+
// The extension deliberately declares its own structural types instead of importing
|
|
190
|
+
// them from pi: an unresolved import would throw at load and take the session with it,
|
|
191
|
+
// and pi's package scope has already moved once (@mariozechner -> @earendil-works).
|
|
192
|
+
function piExtensionBody(env) {
|
|
193
|
+
const envArgs = env && env !== 'prod' ? `, "--env", "${env}"` : '';
|
|
194
|
+
return `// Align decision graph - managed by \`align setup\`, do not edit.
|
|
195
|
+
// Checks each proposed edit against your team's prior decisions and feeds any
|
|
196
|
+
// conflict back to the model. Non-blocking and fail-open by design: if align is
|
|
197
|
+
// missing, slow or unhappy, the edit proceeds untouched.
|
|
198
|
+
import { execFile } from "node:child_process";
|
|
199
|
+
|
|
200
|
+
type PiEvent = { toolName?: string; toolCallId?: string; input?: unknown; content?: unknown[] };
|
|
201
|
+
type Verdict = { block?: boolean; reason?: string; context?: string };
|
|
202
|
+
|
|
203
|
+
const MUTATING_TOOLS = new Set(["edit", "write"]);
|
|
204
|
+
const TIMEOUT_MS = 10000;
|
|
205
|
+
|
|
206
|
+
// Findings from the pre-edit check, held until that call's result comes back.
|
|
207
|
+
const pending = new Map<string, string>();
|
|
208
|
+
|
|
209
|
+
function askAlign(payload: unknown): Promise<Verdict | null> {
|
|
210
|
+
return new Promise((resolve) => {
|
|
211
|
+
try {
|
|
212
|
+
const child = execFile(
|
|
213
|
+
"align",
|
|
214
|
+
["check", "--advisory", "--format", "pi"${envArgs}],
|
|
215
|
+
{ timeout: TIMEOUT_MS },
|
|
216
|
+
(err, stdout) => {
|
|
217
|
+
if (err || !stdout || !stdout.trim()) return resolve(null);
|
|
218
|
+
try {
|
|
219
|
+
const last = stdout.trim().split("\\n").pop() as string;
|
|
220
|
+
resolve(JSON.parse(last) as Verdict);
|
|
221
|
+
} catch {
|
|
222
|
+
resolve(null);
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
);
|
|
226
|
+
child.stdin?.end(JSON.stringify(payload));
|
|
227
|
+
} catch {
|
|
228
|
+
resolve(null);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export default function (pi: { on: (e: string, h: (ev: PiEvent) => unknown) => void }) {
|
|
234
|
+
pi.on("tool_call", async (event: PiEvent) => {
|
|
235
|
+
if (!event.toolName || !MUTATING_TOOLS.has(event.toolName)) return;
|
|
236
|
+
const verdict = await askAlign({ type: "tool_call", toolName: event.toolName, input: event.input });
|
|
237
|
+
if (!verdict) return;
|
|
238
|
+
if (verdict.block) return { block: true, reason: String(verdict.reason ?? "Conflicts with a prior decision") };
|
|
239
|
+
if (verdict.context && event.toolCallId) pending.set(event.toolCallId, String(verdict.context));
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
pi.on("tool_result", async (event: PiEvent) => {
|
|
243
|
+
const found = event.toolCallId ? pending.get(event.toolCallId) : undefined;
|
|
244
|
+
if (!found) return;
|
|
245
|
+
pending.delete(event.toolCallId as string);
|
|
246
|
+
return { content: [...(event.content ?? []), { type: "text", text: found }] };
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
`;
|
|
250
|
+
}
|
|
251
|
+
// pi extension. Fully managed - overwritten each run.
|
|
252
|
+
export function writePiExtension(cwd, env) {
|
|
253
|
+
const dir = path.join(cwd, '.pi', 'extensions');
|
|
254
|
+
if (!existsSync(dir))
|
|
255
|
+
mkdirSync(dir, { recursive: true });
|
|
256
|
+
writeFileSync(path.join(dir, 'align.ts'), piExtensionBody(env), 'utf8');
|
|
257
|
+
}
|
|
258
|
+
// Gemini CLI hooks. BeforeTool can only deny (no additionalContext channel), so the
|
|
259
|
+
// non-blocking finding is carried by AfterTool - the same split as pi, for the same
|
|
260
|
+
// reason. `replace` and `write_file` are Gemini's built-in file-mutating tools; the
|
|
261
|
+
// matcher is a regex.
|
|
262
|
+
const GEMINI_MATCHER = 'write_file|replace';
|
|
263
|
+
function geminiHookGroup(event, env) {
|
|
264
|
+
const envArg = env && env !== 'prod' ? ` --env ${env}` : '';
|
|
265
|
+
return {
|
|
266
|
+
matcher: GEMINI_MATCHER,
|
|
267
|
+
hooks: [{
|
|
268
|
+
type: 'command',
|
|
269
|
+
name: 'align-decision-graph',
|
|
270
|
+
description: `Align: check the ${event === 'BeforeTool' ? 'proposed' : 'applied'} change against prior decisions`,
|
|
271
|
+
command: `align check --advisory --format gemini${envArg}`,
|
|
272
|
+
}],
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
function isAlignGeminiHook(group) {
|
|
276
|
+
const hooks = group?.hooks;
|
|
277
|
+
return Array.isArray(hooks) && hooks.some((h) => String(h?.command ?? '').includes('align check --advisory'));
|
|
278
|
+
}
|
|
279
|
+
export function writeGeminiHooks(cwd, env) {
|
|
280
|
+
const dir = path.join(cwd, '.gemini');
|
|
281
|
+
const file = path.join(dir, 'settings.json');
|
|
282
|
+
let raw = '';
|
|
283
|
+
try {
|
|
284
|
+
raw = readFileSync(file, 'utf8');
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
if (err.code !== 'ENOENT')
|
|
288
|
+
throw err;
|
|
289
|
+
}
|
|
290
|
+
let settings = {};
|
|
291
|
+
if (raw.trim()) {
|
|
292
|
+
try {
|
|
293
|
+
settings = JSON.parse(raw);
|
|
294
|
+
}
|
|
295
|
+
catch {
|
|
296
|
+
throw new Error(`${file} contains invalid JSON - fix it manually before running align setup`);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
const hooks = (settings['hooks'] ?? {});
|
|
300
|
+
// Strip any prior align-managed group from each event first, so a re-run replaces
|
|
301
|
+
// it (and picks up an env change) instead of stacking a second one.
|
|
302
|
+
for (const event of ['BeforeTool', 'AfterTool']) {
|
|
303
|
+
const existing = (Array.isArray(hooks[event]) ? hooks[event] : []);
|
|
304
|
+
const preserved = existing.filter((g) => !isAlignGeminiHook(g));
|
|
305
|
+
preserved.push(geminiHookGroup(event, env));
|
|
306
|
+
hooks[event] = preserved;
|
|
307
|
+
}
|
|
308
|
+
settings['hooks'] = hooks;
|
|
309
|
+
if (!existsSync(dir))
|
|
310
|
+
mkdirSync(dir, { recursive: true });
|
|
311
|
+
writeFileSync(file, `${JSON.stringify(settings, null, 2)}\n`, 'utf8');
|
|
312
|
+
}
|
|
313
|
+
// OpenCode discovers project plugins at .opencode/plugins/*.{js,ts} and loads them at
|
|
314
|
+
// startup. Ships as plain JS so nothing depends on a type package resolving.
|
|
315
|
+
//
|
|
316
|
+
// The two halves work differently from pi's, verified against OpenCode's own caller in
|
|
317
|
+
// packages/opencode/src/session/tools.ts rather than from the type signatures:
|
|
318
|
+
// tool.execute.before runs BEFORE `item.execute(...)`, so throwing prevents the call.
|
|
319
|
+
// That is the only way to stop an edit - there is no {block} return.
|
|
320
|
+
// tool.execute.after is handed the result object and the caller does `return output`
|
|
321
|
+
// on the next line, so mutating output.output reaches the model.
|
|
322
|
+
// Both hooks are declared `=> Promise<void>`; mutation is in place, not by return value.
|
|
323
|
+
function openCodePluginBody(env) {
|
|
324
|
+
const envArgs = env && env !== 'prod' ? `, "--env", "${env}"` : '';
|
|
325
|
+
return `// Align decision graph - managed by \`align setup\`, do not edit.
|
|
326
|
+
// Checks each proposed edit against your team's prior decisions and feeds any conflict
|
|
327
|
+
// back to the model. Non-blocking and fail-open by design: if align is missing, slow or
|
|
328
|
+
// unhappy, the edit proceeds untouched.
|
|
329
|
+
import { execFile } from "node:child_process";
|
|
330
|
+
|
|
331
|
+
const MUTATING_TOOLS = new Set(["edit", "write", "apply_patch"]);
|
|
332
|
+
const TIMEOUT_MS = 10000;
|
|
333
|
+
|
|
334
|
+
// Findings from the pre-edit check, held until that call's result comes back.
|
|
335
|
+
const pending = new Map();
|
|
336
|
+
|
|
337
|
+
function askAlign(payload) {
|
|
338
|
+
return new Promise((resolve) => {
|
|
339
|
+
try {
|
|
340
|
+
const child = execFile(
|
|
341
|
+
"align",
|
|
342
|
+
["check", "--advisory", "--format", "opencode"${envArgs}],
|
|
343
|
+
{ timeout: TIMEOUT_MS },
|
|
344
|
+
(err, stdout) => {
|
|
345
|
+
if (err || !stdout || !stdout.trim()) return resolve(null);
|
|
346
|
+
try {
|
|
347
|
+
resolve(JSON.parse(stdout.trim().split("\\n").pop()));
|
|
348
|
+
} catch {
|
|
349
|
+
resolve(null);
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
);
|
|
353
|
+
child.stdin?.end(JSON.stringify(payload));
|
|
354
|
+
} catch {
|
|
355
|
+
resolve(null);
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export const AlignPlugin = async () => ({
|
|
361
|
+
"tool.execute.before": async (input, output) => {
|
|
362
|
+
if (!MUTATING_TOOLS.has(input.tool)) return;
|
|
363
|
+
const verdict = await askAlign({
|
|
364
|
+
type: "tool.execute.before",
|
|
365
|
+
tool: input.tool,
|
|
366
|
+
args: output.args,
|
|
367
|
+
});
|
|
368
|
+
if (!verdict) return;
|
|
369
|
+
// Throwing is the only way to stop the call - the hook runs before item.execute.
|
|
370
|
+
if (verdict.block) throw new Error(String(verdict.reason ?? "Conflicts with a prior decision"));
|
|
371
|
+
if (verdict.context) pending.set(input.callID, String(verdict.context));
|
|
372
|
+
},
|
|
373
|
+
|
|
374
|
+
"tool.execute.after": async (input, output) => {
|
|
375
|
+
const found = pending.get(input.callID);
|
|
376
|
+
if (!found) return;
|
|
377
|
+
pending.delete(input.callID);
|
|
378
|
+
// The caller returns this same object, so appending here reaches the model.
|
|
379
|
+
output.output = \`\${output.output}\\n\\n\${found}\`;
|
|
380
|
+
},
|
|
381
|
+
});
|
|
382
|
+
`;
|
|
383
|
+
}
|
|
384
|
+
// OpenCode plugin. Fully managed - overwritten each run.
|
|
385
|
+
export function writeOpenCodePlugin(cwd, env) {
|
|
386
|
+
const dir = path.join(cwd, '.opencode', 'plugins');
|
|
387
|
+
if (!existsSync(dir))
|
|
388
|
+
mkdirSync(dir, { recursive: true });
|
|
389
|
+
writeFileSync(path.join(dir, 'align.js'), openCodePluginBody(env), 'utf8');
|
|
390
|
+
}
|
|
144
391
|
// Write every deterministic-alignment artifact into the project. Returns the
|
|
145
392
|
// repo-relative paths written, for the caller to report.
|
|
146
393
|
export function setupAgentAlignment(opts) {
|
|
@@ -148,6 +395,22 @@ export function setupAgentAlignment(opts) {
|
|
|
148
395
|
writeManagedNudge(opts.cwd);
|
|
149
396
|
writeAgentsNudge(opts.cwd);
|
|
150
397
|
writeCursorRule(opts.cwd);
|
|
151
|
-
|
|
398
|
+
// prod is the default env, so leave it off to keep the committed file portable -
|
|
399
|
+
// the same rule advisoryCommand() applies to the hook.
|
|
400
|
+
const env = opts.env === 'prod' ? undefined : opts.env;
|
|
401
|
+
writeProjectMcpConfig(opts.cwd, env);
|
|
402
|
+
writePiExtension(opts.cwd, env);
|
|
403
|
+
writeGeminiHooks(opts.cwd, env);
|
|
404
|
+
writeOpenCodePlugin(opts.cwd, env);
|
|
405
|
+
return [
|
|
406
|
+
'.claude/settings.json',
|
|
407
|
+
'CLAUDE.md',
|
|
408
|
+
'AGENTS.md',
|
|
409
|
+
'.cursor/rules/align.md',
|
|
410
|
+
'.mcp.json',
|
|
411
|
+
'.pi/extensions/align.ts',
|
|
412
|
+
'.gemini/settings.json',
|
|
413
|
+
'.opencode/plugins/align.js',
|
|
414
|
+
];
|
|
152
415
|
}
|
|
153
416
|
//# sourceMappingURL=agent-rules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-rules.js","sourceRoot":"","sources":["../../src/lib/agent-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-rules.js","sourceRoot":"","sources":["../../src/lib/agent-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACnC,OAAO;QACL,uBAAuB;QACvB,WAAW;QACX,WAAW;QACX,wBAAwB;QACxB,WAAW;QACX,yBAAyB;QACzB,uBAAuB;QACvB,4BAA4B;KAC7B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Read a subcommand's options including any inherited from its parent.
|
|
4
|
+
*
|
|
5
|
+
* The parent `import` command declares `--env` (and `--approve`) alongside every
|
|
6
|
+
* subcommand that also declares them. Commander resolves that name collision in
|
|
7
|
+
* the parent's favour, so `align import git --approve --env local` leaves the
|
|
8
|
+
* subcommand's own `opts` with neither: `--approve` never skips the confirm and
|
|
9
|
+
* `--env local` never routes to the local graph.
|
|
10
|
+
*
|
|
11
|
+
* `optsWithGlobals()` merges the ancestors' parsed values back in, with the
|
|
12
|
+
* subcommand's own values winning, so its defaults are preserved.
|
|
13
|
+
*/
|
|
14
|
+
export declare function subcommandOpts<T>(cmd: Command): T;
|
|
15
|
+
//# sourceMappingURL=command-opts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-opts.d.ts","sourceRoot":"","sources":["../../src/lib/command-opts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,GAAG,CAAC,CAEjD"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read a subcommand's options including any inherited from its parent.
|
|
3
|
+
*
|
|
4
|
+
* The parent `import` command declares `--env` (and `--approve`) alongside every
|
|
5
|
+
* subcommand that also declares them. Commander resolves that name collision in
|
|
6
|
+
* the parent's favour, so `align import git --approve --env local` leaves the
|
|
7
|
+
* subcommand's own `opts` with neither: `--approve` never skips the confirm and
|
|
8
|
+
* `--env local` never routes to the local graph.
|
|
9
|
+
*
|
|
10
|
+
* `optsWithGlobals()` merges the ancestors' parsed values back in, with the
|
|
11
|
+
* subcommand's own values winning, so its defaults are preserved.
|
|
12
|
+
*/
|
|
13
|
+
export function subcommandOpts(cmd) {
|
|
14
|
+
return cmd.optsWithGlobals();
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=command-opts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-opts.js","sourceRoot":"","sources":["../../src/lib/command-opts.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,cAAc,CAAI,GAAY;IAC5C,OAAO,GAAG,CAAC,eAAe,EAAO,CAAC;AACpC,CAAC"}
|
|
@@ -14,6 +14,7 @@ export interface HookPayload {
|
|
|
14
14
|
tool_name?: string;
|
|
15
15
|
tool_input?: HookToolInput;
|
|
16
16
|
}
|
|
17
|
+
export declare function normalizeHookPayload(raw: unknown): HookPayload | null;
|
|
17
18
|
export declare function readHookPayload(stream?: Readable & {
|
|
18
19
|
isTTY?: boolean;
|
|
19
20
|
}): Promise<HookPayload | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-payload.d.ts","sourceRoot":"","sources":["../../src/lib/hook-payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,WAAW;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B;
|
|
1
|
+
{"version":3,"file":"hook-payload.d.ts","sourceRoot":"","sources":["../../src/lib/hook-payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,WAAW;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,aAAa,CAAC;CAC5B;AAsDD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CA+CrE;AAOD,wBAAsB,eAAe,CACnC,MAAM,GAAE,QAAQ,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAkB,GACrD,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAS7B"}
|
package/dist/lib/hook-payload.js
CHANGED
|
@@ -1,7 +1,109 @@
|
|
|
1
|
-
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
const asRecord = (v) => v !== null && typeof v === 'object' && !Array.isArray(v) ? v : null;
|
|
2
|
+
// pi's edit tool takes edits[{oldText,newText}] (and still accepts a legacy top-level
|
|
3
|
+
// oldText/newText pair - see prepareEditArguments in pi's core/tools/edit.ts). Rename
|
|
4
|
+
// into the canonical shape proposedChangeText() reads.
|
|
5
|
+
function fromPiInput(input) {
|
|
6
|
+
const out = {};
|
|
7
|
+
if (typeof input['path'] === 'string')
|
|
8
|
+
out.file_path = input['path'];
|
|
9
|
+
if (typeof input['content'] === 'string')
|
|
10
|
+
out.content = input['content'];
|
|
11
|
+
if (Array.isArray(input['edits'])) {
|
|
12
|
+
out.edits = input['edits'].map((e) => ({
|
|
13
|
+
old_string: typeof e?.['oldText'] === 'string' ? e['oldText'] : undefined,
|
|
14
|
+
new_string: typeof e?.['newText'] === 'string' ? e['newText'] : undefined,
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
else if (typeof input['oldText'] === 'string' || typeof input['newText'] === 'string') {
|
|
18
|
+
if (typeof input['oldText'] === 'string')
|
|
19
|
+
out.old_string = input['oldText'];
|
|
20
|
+
if (typeof input['newText'] === 'string')
|
|
21
|
+
out.new_string = input['newText'];
|
|
22
|
+
}
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
// OpenCode passes each tool's own parameter names straight through to the plugin.
|
|
26
|
+
// Taken from packages/opencode/src/tool/*.ts:
|
|
27
|
+
// edit {filePath, oldString, newString, replaceAll?}
|
|
28
|
+
// write {content, filePath}
|
|
29
|
+
// apply_patch {patchText} - one blob describing the whole change
|
|
30
|
+
function fromOpenCodeArgs(args) {
|
|
31
|
+
const out = {};
|
|
32
|
+
if (typeof args['filePath'] === 'string')
|
|
33
|
+
out.file_path = args['filePath'];
|
|
34
|
+
if (typeof args['content'] === 'string')
|
|
35
|
+
out.content = args['content'];
|
|
36
|
+
// The patch text IS the proposed change, so it maps to `content` - the first field
|
|
37
|
+
// proposedChangeText() reads.
|
|
38
|
+
if (typeof args['patchText'] === 'string')
|
|
39
|
+
out.content = args['patchText'];
|
|
40
|
+
if (typeof args['oldString'] === 'string')
|
|
41
|
+
out.old_string = args['oldString'];
|
|
42
|
+
if (typeof args['newString'] === 'string')
|
|
43
|
+
out.new_string = args['newString'];
|
|
44
|
+
return out;
|
|
45
|
+
}
|
|
46
|
+
// Normalize whichever host's hook payload arrived on stdin into the canonical
|
|
47
|
+
// HookPayload, so runAdvisory never learns which agent it is serving. Every field name
|
|
48
|
+
// below comes from that host's published schema:
|
|
49
|
+
// Claude Code {hook_event_name, tool_name, tool_input} - already canonical
|
|
50
|
+
// pi {type:'tool_call'|'tool_result', toolName, input} - extension events
|
|
51
|
+
// Gemini CLI {tool_name, tool_input, tool_response?} - AfterTool is the
|
|
52
|
+
// one carrying tool_response, which is what derives the event
|
|
53
|
+
// Cursor {hook_event_name:'afterFileEdit', file_path, edits} - fields sit at the
|
|
54
|
+
// TOP level rather than under tool_input
|
|
55
|
+
// Returns null when nothing tool-shaped is present, so callers fall back rather than
|
|
56
|
+
// checking an empty change.
|
|
57
|
+
export function normalizeHookPayload(raw) {
|
|
58
|
+
const p = asRecord(raw);
|
|
59
|
+
if (!p)
|
|
60
|
+
return null;
|
|
61
|
+
// pi: the event type is explicit on the payload.
|
|
62
|
+
if (p['type'] === 'tool_call' || p['type'] === 'tool_result') {
|
|
63
|
+
const input = asRecord(p['input']) ?? {};
|
|
64
|
+
return {
|
|
65
|
+
hook_event_name: p['type'] === 'tool_call' ? 'PreToolUse' : 'PostToolUse',
|
|
66
|
+
tool_name: typeof p['toolName'] === 'string' ? p['toolName'] : undefined,
|
|
67
|
+
tool_input: fromPiInput(input),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// OpenCode: the plugin hook name is the event.
|
|
71
|
+
if (p['type'] === 'tool.execute.before' || p['type'] === 'tool.execute.after') {
|
|
72
|
+
return {
|
|
73
|
+
hook_event_name: p['type'] === 'tool.execute.before' ? 'PreToolUse' : 'PostToolUse',
|
|
74
|
+
tool_name: typeof p['tool'] === 'string' ? p['tool'] : undefined,
|
|
75
|
+
tool_input: fromOpenCodeArgs(asRecord(p['args']) ?? {}),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// Cursor: afterFileEdit is observational and flat. (There is no beforeFileEdit.)
|
|
79
|
+
if (p['hook_event_name'] === 'afterFileEdit') {
|
|
80
|
+
const tool_input = {};
|
|
81
|
+
if (typeof p['file_path'] === 'string')
|
|
82
|
+
tool_input.file_path = p['file_path'];
|
|
83
|
+
if (Array.isArray(p['edits']))
|
|
84
|
+
tool_input.edits = p['edits'];
|
|
85
|
+
return { hook_event_name: 'PostToolUse', tool_name: 'Edit', tool_input };
|
|
86
|
+
}
|
|
87
|
+
// Claude Code / Gemini CLI: both already speak tool_name + tool_input.
|
|
88
|
+
if (p['tool_name'] !== undefined || p['tool_input'] !== undefined) {
|
|
89
|
+
const event = typeof p['hook_event_name'] === 'string'
|
|
90
|
+
? p['hook_event_name']
|
|
91
|
+
: p['tool_response'] !== undefined
|
|
92
|
+
? 'PostToolUse'
|
|
93
|
+
: 'PreToolUse';
|
|
94
|
+
return {
|
|
95
|
+
hook_event_name: event,
|
|
96
|
+
tool_name: typeof p['tool_name'] === 'string' ? p['tool_name'] : undefined,
|
|
97
|
+
tool_input: (asRecord(p['tool_input']) ?? {}),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
// Read and parse the JSON payload the host agent pipes to a hook command on stdin,
|
|
103
|
+
// normalizing whichever shape it sent (see normalizeHookPayload). Returns null when
|
|
104
|
+
// there is no usable payload - a TTY (manual `align check --advisory` run), empty
|
|
105
|
+
// stdin, invalid JSON, or nothing tool-shaped - so callers fall back to their
|
|
106
|
+
// non-hook behaviour.
|
|
5
107
|
export async function readHookPayload(stream = process.stdin) {
|
|
6
108
|
if (stream.isTTY)
|
|
7
109
|
return null;
|
|
@@ -9,7 +111,7 @@ export async function readHookPayload(stream = process.stdin) {
|
|
|
9
111
|
if (!raw.trim())
|
|
10
112
|
return null;
|
|
11
113
|
try {
|
|
12
|
-
return JSON.parse(raw);
|
|
114
|
+
return normalizeHookPayload(JSON.parse(raw));
|
|
13
115
|
}
|
|
14
116
|
catch {
|
|
15
117
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook-payload.js","sourceRoot":"","sources":["../../src/lib/hook-payload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hook-payload.js","sourceRoot":"","sources":["../../src/lib/hook-payload.ts"],"names":[],"mappings":"AAkBA,MAAM,QAAQ,GAAG,CAAC,CAAU,EAAc,EAAE,CAC1C,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAE,CAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AAE/E,sFAAsF;AACtF,sFAAsF;AACtF,uDAAuD;AACvD,SAAS,WAAW,CAAC,KAAU;IAC7B,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,IAAI,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,QAAQ;QAAE,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IACrE,IAAI,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,QAAQ;QAAE,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;IACzE,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QAClC,GAAG,CAAC,KAAK,GAAI,KAAK,CAAC,OAAO,CAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAChD,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,CAAC,CAAC,SAAS,CAAY,CAAC,CAAC,CAAC,SAAS;YACrF,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAE,CAAC,CAAC,SAAS,CAAY,CAAC,CAAC,CAAC,SAAS;SACtF,CAAC,CAAC,CAAC;IACN,CAA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@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-embeddings.d.ts","sourceRoot":"","sources":["../../src/lib/local-embeddings.ts"],"names":[],"mappings":"AAGA,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"local-embeddings.d.ts","sourceRoot":"","sources":["../../src/lib/local-embeddings.ts"],"names":[],"mappings":"AAGA,wBAAsB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAkCtE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,GAAG,MAAM,CASzE"}
|
|
@@ -3,19 +3,25 @@ export async function getEmbedding(text) {
|
|
|
3
3
|
if (!_pipe) {
|
|
4
4
|
let mod;
|
|
5
5
|
try {
|
|
6
|
-
// @
|
|
6
|
+
// @huggingface/transformers is an optionalDependency - its native deps (sharp,
|
|
7
7
|
// onnxruntime) can fail to install on Alpine/ARM/behind a proxy. If it's
|
|
8
8
|
// missing, point the user at cloud mode rather than a raw "Cannot find module".
|
|
9
|
-
mod = (await import('@
|
|
9
|
+
mod = (await import('@huggingface/transformers'));
|
|
10
10
|
}
|
|
11
11
|
catch (err) {
|
|
12
|
-
throw new Error('Local mode needs the on-device embedding model (@
|
|
12
|
+
throw new Error('Local mode needs the on-device embedding model (@huggingface/transformers), which is not installed on this platform. ' +
|
|
13
13
|
'Use cloud mode (`align login`), or reinstall on a supported platform (macOS, glibc Linux, or Windows x64/arm64). ' +
|
|
14
14
|
`(${err.message})`);
|
|
15
15
|
}
|
|
16
16
|
try {
|
|
17
17
|
// First call downloads the ~90MB model from the Hugging Face Hub.
|
|
18
|
-
|
|
18
|
+
// dtype 'q8' is load-bearing, not a perf tweak: @xenova/transformers@2 loaded
|
|
19
|
+
// quantized weights by default and v3+ default to fp32, which shifts pairwise
|
|
20
|
+
// cosine by up to 2.3e-02 against vectors already persisted in a user's local
|
|
21
|
+
// graph. Pinning q8 holds that to 6.6e-04. See local-embeddings-dtype.test.ts.
|
|
22
|
+
_pipe = (await mod.pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2', {
|
|
23
|
+
dtype: 'q8',
|
|
24
|
+
}));
|
|
19
25
|
}
|
|
20
26
|
catch (err) {
|
|
21
27
|
throw new Error('Could not load the local embedding model (~90MB, Xenova/all-MiniLM-L6-v2). ' +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-embeddings.js","sourceRoot":"","sources":["../../src/lib/local-embeddings.ts"],"names":[],"mappings":"AACA,IAAI,KAAK,GAA6B,IAAI,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAY;IAC7C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,IAAI,
|
|
1
|
+
{"version":3,"file":"local-embeddings.js","sourceRoot":"","sources":["../../src/lib/local-embeddings.ts"],"names":[],"mappings":"AACA,IAAI,KAAK,GAA6B,IAAI,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,IAAY;IAC7C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,IAAI,GAAoG,CAAC;QACzG,IAAI,CAAC;YACH,+EAA+E;YAC/E,yEAAyE;YACzE,gFAAgF;YAChF,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,2BAA2B,CAAC,CAA0B,CAAC;QAC7E,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,uHAAuH;gBACvH,mHAAmH;gBACnH,IAAK,GAAa,CAAC,OAAO,GAAG,CAC9B,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;YACH,kEAAkE;YAClE,8EAA8E;YAC9E,8EAA8E;YAC9E,8EAA8E;YAC9E,+EAA+E;YAC/E,KAAK,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAAC,oBAAoB,EAAE,yBAAyB,EAAE;gBAC3E,KAAK,EA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ers' | 'vscode' | 'zed' | 'codex' | 'pi';
|
|
2
2
|
export interface EditorTarget {
|
|
3
3
|
name: string;
|
|
4
4
|
configPath: string;
|
|
5
5
|
format: McpFormat;
|
|
6
6
|
}
|
|
7
|
+
export declare function alignServerEntry(format: McpFormat, env?: string): Record<string, unknown>;
|
|
7
8
|
export declare function detectEditors(): EditorTarget[];
|
|
8
9
|
export declare function writeMcpConfig(target: EditorTarget, env?: string): void;
|
|
9
10
|
//# sourceMappingURL=mcp-setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-setup.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-setup.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcp-setup.d.ts","sourceRoot":"","sources":["../../src/lib/mcp-setup.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,KAAK,GAAG,OAAO,GAAG,IAAI,CAAC;AAEzE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;CACnB;AAUD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAgBzF;AAmBD,wBAAgB,aAAa,IAAI,YAAY,EAAE,CA4E9C;AA8ED,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAMvE"}
|
package/dist/lib/mcp-setup.js
CHANGED
|
@@ -5,14 +5,22 @@ function alignArgs(env) {
|
|
|
5
5
|
return env ? ['mcp', '--env', env] : ['mcp'];
|
|
6
6
|
}
|
|
7
7
|
// The per-format entry shape for the `align` server. VS Code requires `type`;
|
|
8
|
-
// Zed silently drops entries without `source: "custom"`.
|
|
9
|
-
|
|
8
|
+
// Zed silently drops entries without `source: "custom"`. Exported so the shared
|
|
9
|
+
// project-local .mcp.json (agent-rules.ts) builds the entry from here rather than
|
|
10
|
+
// keeping a second copy that can drift from this one.
|
|
11
|
+
export function alignServerEntry(format, env) {
|
|
10
12
|
const args = alignArgs(env);
|
|
11
13
|
switch (format) {
|
|
12
14
|
case 'vscode':
|
|
13
15
|
return { type: 'stdio', command: 'align', args };
|
|
14
16
|
case 'zed':
|
|
15
17
|
return { source: 'custom', command: 'align', args };
|
|
18
|
+
case 'pi':
|
|
19
|
+
// pi's MCP adapter is lazy by default: every server hides behind one proxy tool
|
|
20
|
+
// the agent has to search before it can call anything. That directly undercuts
|
|
21
|
+
// ALIGN_MCP_INSTRUCTIONS' "call align_check_alignment BEFORE writing code", so
|
|
22
|
+
// ask for the tools to be registered directly.
|
|
23
|
+
return { command: 'align', args, directTools: true };
|
|
16
24
|
default:
|
|
17
25
|
return { command: 'align', args };
|
|
18
26
|
}
|
|
@@ -84,6 +92,19 @@ export function detectEditors() {
|
|
|
84
92
|
if (existsSync(path.join(home, '.codex'))) {
|
|
85
93
|
found.push({ name: 'Codex', configPath: path.join(home, '.codex', 'config.toml'), format: 'codex' });
|
|
86
94
|
}
|
|
95
|
+
// pi (pi.dev) - MCP comes from the `pi-mcp-adapter` package, which reads the Pi agent
|
|
96
|
+
// dir (~/.pi/agent by default, relocatable via $PI_CODING_AGENT_DIR). Write the Pi-owned
|
|
97
|
+
// override rather than a shared file: it is where adapter-only settings like directTools
|
|
98
|
+
// belong, and it never rewrites another host's config.
|
|
99
|
+
const piAgentDir = process.env['PI_CODING_AGENT_DIR'];
|
|
100
|
+
const piRoot = piAgentDir ?? path.join(home, '.pi');
|
|
101
|
+
if (existsSync(piRoot)) {
|
|
102
|
+
found.push({
|
|
103
|
+
name: 'pi',
|
|
104
|
+
configPath: path.join(piAgentDir ?? path.join(home, '.pi', 'agent'), 'mcp.json'),
|
|
105
|
+
format: 'pi',
|
|
106
|
+
});
|
|
107
|
+
}
|
|
87
108
|
// Gemini CLI (~/.gemini/settings.json, `mcpServers`)
|
|
88
109
|
if (existsSync(path.join(home, '.gemini'))) {
|
|
89
110
|
found.push({ name: 'Gemini CLI', configPath: path.join(home, '.gemini', 'settings.json'), format: 'mcpServers' });
|