cadre-ai 1.1.2 → 2.1.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 +11 -3
- package/package.json +5 -3
- package/scripts/cadre-cli.js +495 -206
- package/scripts/cadre-core.js +5795 -1723
- package/scripts/cadre-job-runner.js +799 -142
- package/scripts/cadre-lsp-daemon.js +5 -1
- package/scripts/cadre-lsp-review.js +5 -1
- package/scripts/cadre-lsp-setup.js +5 -1
- package/scripts/mcp/cadre-server.js +6366 -2482
package/scripts/cadre-cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// AUTO-GENERATED by pnpm build from src/*.ts -- do not edit by hand.
|
|
3
3
|
// Edit TypeScript sources under src/ instead.
|
|
4
|
-
const __CADRE_SKILL_SHIM__ = "---\nname: cadre\ndescription:
|
|
4
|
+
const __CADRE_SKILL_SHIM__ = "---\nname: cadre\ndescription: Packet-led context-driven development for Cadre projects and workflows.\n---\n\n# Cadre\n\nCall `cadre_workflow` directly with the current root candidate, workflow name,\nand structured `input`. The call itself verifies Cadre and resolves the root.\nFollow the returned `decision`, load only returned resource URIs, and execute at\nmost the single returned `next` call.\n\nUse `cadre_action` only for a namespaced action returned by a packet and\n`cadre_read` only for a relevant resource. Cadre owns control-plane, approval,\nprovider, worker, merge, and generated-projection state. Never recreate that\nstate with shell commands or treat Markdown projections as canonical.\n\nSend `approval` only after explicit user approval of the current stage. If a\npacket is blocked, report its error or requested narrowing; do not truncate or\ninvent required project-skill rules.\n";
|
|
5
5
|
"use strict";
|
|
6
6
|
var __create = Object.create;
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
@@ -27,49 +27,162 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
));
|
|
28
28
|
|
|
29
29
|
// src/cli/install.ts
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var import_node_child_process = require("node:child_process");
|
|
30
|
+
var import_node_fs4 = __toESM(require("node:fs"));
|
|
31
|
+
var import_node_os3 = __toESM(require("node:os"));
|
|
32
|
+
var import_node_path5 = __toESM(require("node:path"));
|
|
34
33
|
|
|
35
34
|
// src/cli/client-approvals.ts
|
|
36
35
|
var import_node_fs = __toESM(require("node:fs"));
|
|
36
|
+
var import_node_os2 = __toESM(require("node:os"));
|
|
37
|
+
var import_node_path2 = __toESM(require("node:path"));
|
|
38
|
+
|
|
39
|
+
// src/cli/install-targets.ts
|
|
37
40
|
var import_node_os = __toESM(require("node:os"));
|
|
38
41
|
var import_node_path = __toESM(require("node:path"));
|
|
42
|
+
var import_node_child_process = require("node:child_process");
|
|
43
|
+
var INSTALL_TARGETS = ["codex", "claude", "copilot", "antigravity"];
|
|
44
|
+
var TARGET_COMMANDS = {
|
|
45
|
+
codex: "codex",
|
|
46
|
+
claude: "claude",
|
|
47
|
+
copilot: "copilot",
|
|
48
|
+
antigravity: "agy"
|
|
49
|
+
};
|
|
50
|
+
var PACKAGE_PLUGIN_NAME = "cadre";
|
|
51
|
+
var PACKAGE_DISPLAY_NAME = "Cadre";
|
|
52
|
+
function runtimePaths() {
|
|
53
|
+
const runtimeRoot = import_node_path.default.resolve(__dirname, "..");
|
|
54
|
+
return {
|
|
55
|
+
runtimeRoot,
|
|
56
|
+
nodePath: process.execPath,
|
|
57
|
+
mcpServer: import_node_path.default.join(runtimeRoot, "scripts", "mcp", "cadre-server.js")
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function commandExists(command) {
|
|
61
|
+
const result = process.platform === "win32" ? (0, import_node_child_process.spawnSync)("where", [command], { stdio: "ignore" }) : (0, import_node_child_process.spawnSync)("which", [command], { stdio: "ignore" });
|
|
62
|
+
return result.status === 0;
|
|
63
|
+
}
|
|
64
|
+
function selectedTargets(options) {
|
|
65
|
+
if (options.target !== "auto" && options.target !== "all") return [options.target];
|
|
66
|
+
if (options.target === "all") return [...INSTALL_TARGETS];
|
|
67
|
+
return INSTALL_TARGETS.filter((target) => commandExists(TARGET_COMMANDS[target]));
|
|
68
|
+
}
|
|
69
|
+
function antigravityCliHome() {
|
|
70
|
+
return process.env.ANTIGRAVITY_CLI_HOME || import_node_path.default.join(process.env.GEMINI_HOME || import_node_path.default.join(import_node_os.default.homedir(), ".gemini"), "antigravity-cli");
|
|
71
|
+
}
|
|
72
|
+
function antigravityIdeHome() {
|
|
73
|
+
return process.env.ANTIGRAVITY_IDE_HOME || import_node_path.default.join(process.env.GEMINI_HOME || import_node_path.default.join(import_node_os.default.homedir(), ".gemini"), "config");
|
|
74
|
+
}
|
|
75
|
+
function targetPaths(home, target, scope, cwd = process.cwd()) {
|
|
76
|
+
if (target === "copilot" && scope !== "user") {
|
|
77
|
+
const skillRoot = import_node_path.default.join(cwd, ".github", "skills", PACKAGE_PLUGIN_NAME);
|
|
78
|
+
return { primaryRoot: skillRoot, pluginRoots: [], skillRoots: [skillRoot] };
|
|
79
|
+
}
|
|
80
|
+
if (target === "antigravity") {
|
|
81
|
+
if (scope !== "user") {
|
|
82
|
+
const pluginRoot2 = import_node_path.default.join(cwd, ".agents", "plugins", PACKAGE_PLUGIN_NAME);
|
|
83
|
+
return { primaryRoot: pluginRoot2, pluginRoots: [pluginRoot2], skillRoots: [] };
|
|
84
|
+
}
|
|
85
|
+
const cliPlugin = import_node_path.default.join(antigravityCliHome(), "plugins", PACKAGE_PLUGIN_NAME);
|
|
86
|
+
const idePlugin = import_node_path.default.join(antigravityIdeHome(), "plugins", PACKAGE_PLUGIN_NAME);
|
|
87
|
+
return { primaryRoot: cliPlugin, pluginRoots: [cliPlugin, idePlugin], skillRoots: [] };
|
|
88
|
+
}
|
|
89
|
+
const marketplaceRoot = import_node_path.default.join(home, "marketplaces", target);
|
|
90
|
+
const pluginRoot = import_node_path.default.join(marketplaceRoot, "plugins", PACKAGE_PLUGIN_NAME);
|
|
91
|
+
const marketplaceFile = target === "codex" ? import_node_path.default.join(marketplaceRoot, ".agents", "plugins", "marketplace.json") : target === "claude" ? import_node_path.default.join(marketplaceRoot, ".claude-plugin", "marketplace.json") : void 0;
|
|
92
|
+
const paths = {
|
|
93
|
+
primaryRoot: pluginRoot,
|
|
94
|
+
marketplaceRoot,
|
|
95
|
+
pluginRoots: [pluginRoot],
|
|
96
|
+
skillRoots: []
|
|
97
|
+
};
|
|
98
|
+
if (marketplaceFile) paths.marketplaceFile = marketplaceFile;
|
|
99
|
+
return paths;
|
|
100
|
+
}
|
|
101
|
+
function installCommands(target, paths, scope) {
|
|
102
|
+
if (target === "codex") {
|
|
103
|
+
return [
|
|
104
|
+
{ command: "codex", args: ["plugin", "marketplace", "add", paths.marketplaceRoot || ""] },
|
|
105
|
+
{ command: "codex", args: ["plugin", "add", "cadre@cadre"] }
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
if (target === "claude") {
|
|
109
|
+
return [
|
|
110
|
+
{ command: "claude", args: ["plugin", "marketplace", "add", "--scope", scope, paths.marketplaceRoot || ""] },
|
|
111
|
+
{ command: "claude", args: ["plugin", "install", "--scope", scope, "cadre@cadre"] },
|
|
112
|
+
{ command: "claude", args: ["plugin", "update", "--scope", scope, "cadre@cadre"] }
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
if (target === "copilot" && scope === "user") {
|
|
116
|
+
return [{ command: "copilot", args: ["plugin", "install", paths.primaryRoot] }];
|
|
117
|
+
}
|
|
118
|
+
if (target === "antigravity" && scope === "user") {
|
|
119
|
+
return [{ command: "agy", args: ["plugin", "install", paths.primaryRoot], optional: true }];
|
|
120
|
+
}
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
function uninstallCommands(target, paths, scope) {
|
|
124
|
+
if (target === "codex") {
|
|
125
|
+
return [
|
|
126
|
+
{ command: "codex", args: ["plugin", "remove", "cadre@cadre"], optional: true },
|
|
127
|
+
{ command: "codex", args: ["plugin", "marketplace", "remove", PACKAGE_PLUGIN_NAME], optional: true }
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
if (target === "claude") {
|
|
131
|
+
return [
|
|
132
|
+
{ command: "claude", args: ["plugin", "uninstall", "--scope", scope, "--yes", "cadre@cadre"], optional: true },
|
|
133
|
+
{ command: "claude", args: ["plugin", "marketplace", "remove", "--scope", scope, PACKAGE_PLUGIN_NAME], optional: true }
|
|
134
|
+
];
|
|
135
|
+
}
|
|
136
|
+
if (target === "copilot" && scope === "user") {
|
|
137
|
+
return [{ command: "copilot", args: ["plugin", "uninstall", paths.primaryRoot], optional: true }];
|
|
138
|
+
}
|
|
139
|
+
if (target === "antigravity" && scope === "user") {
|
|
140
|
+
return [{ command: "agy", args: ["plugin", "uninstall", PACKAGE_PLUGIN_NAME], optional: true }];
|
|
141
|
+
}
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// src/cli/client-approvals.ts
|
|
39
146
|
var CADRE_MCP_TOOLS = [
|
|
40
|
-
"cadre_resource",
|
|
41
147
|
"cadre_workflow",
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"cadre_track",
|
|
45
|
-
"cadre_parallel",
|
|
46
|
-
"cadre_mutate",
|
|
47
|
-
"cadre_complete_task",
|
|
48
|
-
"cadre_job",
|
|
49
|
-
"cadre_review",
|
|
50
|
-
"cadre_intel",
|
|
51
|
-
"cadre_artifact"
|
|
148
|
+
"cadre_action",
|
|
149
|
+
"cadre_read"
|
|
52
150
|
];
|
|
53
151
|
var CLAUDE_CADRE_ALLOW_RULES = [
|
|
54
152
|
"mcp__plugin_cadre_cadre__*",
|
|
55
153
|
"mcp__cadre__*"
|
|
56
154
|
];
|
|
155
|
+
var ANTIGRAVITY_CADRE_ALLOW_RULES = [
|
|
156
|
+
"mcp(cadre/*)"
|
|
157
|
+
];
|
|
57
158
|
function approvalConfigPath(target) {
|
|
58
159
|
if (target === "codex") {
|
|
59
|
-
return
|
|
160
|
+
return import_node_path2.default.join(process.env.CODEX_HOME || import_node_path2.default.join(import_node_os2.default.homedir(), ".codex"), "config.toml");
|
|
161
|
+
}
|
|
162
|
+
if (target === "claude") {
|
|
163
|
+
return import_node_path2.default.join(process.env.CLAUDE_HOME || process.env.CLAUDE_CONFIG_DIR || import_node_path2.default.join(import_node_os2.default.homedir(), ".claude"), "settings.json");
|
|
60
164
|
}
|
|
61
|
-
|
|
165
|
+
if (target === "antigravity") return import_node_path2.default.join(antigravityCliHome(), "settings.json");
|
|
166
|
+
return import_node_path2.default.join(process.env.COPILOT_HOME || import_node_path2.default.join(import_node_os2.default.homedir(), ".copilot"), "permissions-config.json");
|
|
62
167
|
}
|
|
63
168
|
function bootstrapClientApprovals(target) {
|
|
64
|
-
|
|
169
|
+
if (target === "codex") return bootstrapCodexApprovals();
|
|
170
|
+
if (target === "claude") return bootstrapClaudeApprovals();
|
|
171
|
+
if (target === "antigravity") return bootstrapAntigravityApprovals();
|
|
172
|
+
return copilotPromptResult();
|
|
65
173
|
}
|
|
66
174
|
function checkClientApprovals(target) {
|
|
67
|
-
|
|
175
|
+
if (target === "codex") return checkCodexApprovals();
|
|
176
|
+
if (target === "claude") return checkClaudeApprovals();
|
|
177
|
+
if (target === "antigravity") return checkAntigravityApprovals();
|
|
178
|
+
return copilotPromptResult();
|
|
68
179
|
}
|
|
69
180
|
function approvalSummary(target) {
|
|
70
181
|
const file = approvalConfigPath(target);
|
|
71
182
|
if (target === "codex") return `Cadre codex MCP tool approvals: ${file}`;
|
|
72
|
-
return `Cadre claude MCP tool approvals: ${file}`;
|
|
183
|
+
if (target === "claude") return `Cadre claude MCP tool approvals: ${file}`;
|
|
184
|
+
if (target === "antigravity") return `Cadre antigravity CLI MCP allow rule: ${file}`;
|
|
185
|
+
return "Cadre copilot MCP tools may prompt on first use; no approval file is edited";
|
|
73
186
|
}
|
|
74
187
|
function codexToolSection(tool) {
|
|
75
188
|
return `[plugins."cadre@cadre".mcp_servers.cadre.tools.${tool}]`;
|
|
@@ -86,7 +199,7 @@ function bootstrapCodexApprovals() {
|
|
|
86
199
|
const before = text;
|
|
87
200
|
for (const tool of CADRE_MCP_TOOLS) text = upsertCodexApproval(text, tool);
|
|
88
201
|
if (text !== before) {
|
|
89
|
-
import_node_fs.default.mkdirSync(
|
|
202
|
+
import_node_fs.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
90
203
|
import_node_fs.default.writeFileSync(file, text);
|
|
91
204
|
}
|
|
92
205
|
return { ok: true, target: "codex", path: file, changed: text !== before, configured: true, rules: [...CADRE_MCP_TOOLS] };
|
|
@@ -161,7 +274,7 @@ function bootstrapClaudeApprovals() {
|
|
|
161
274
|
const changed = nextAllow.length !== currentAllow.length || !isRecord(settings.permissions) || !Array.isArray(permissions.allow);
|
|
162
275
|
if (changed) {
|
|
163
276
|
settings.permissions = { ...permissions, allow: nextAllow };
|
|
164
|
-
import_node_fs.default.mkdirSync(
|
|
277
|
+
import_node_fs.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
165
278
|
import_node_fs.default.writeFileSync(file, `${JSON.stringify(settings, null, 2)}
|
|
166
279
|
`);
|
|
167
280
|
}
|
|
@@ -185,25 +298,76 @@ function checkClaudeApprovals() {
|
|
|
185
298
|
if (missing.length > 0) result.error = `missing Claude Cadre tool allow rules: ${missing.join(", ")}`;
|
|
186
299
|
return result;
|
|
187
300
|
}
|
|
301
|
+
function bootstrapAntigravityApprovals() {
|
|
302
|
+
const file = approvalConfigPath("antigravity");
|
|
303
|
+
const parsed = readJsonSettings(file, "antigravity", ANTIGRAVITY_CADRE_ALLOW_RULES);
|
|
304
|
+
if (!parsed.ok) return parsed.result;
|
|
305
|
+
const settings = parsed.settings;
|
|
306
|
+
const permissions = isRecord(settings.permissions) ? settings.permissions : {};
|
|
307
|
+
const currentAllow = Array.isArray(permissions.allow) ? permissions.allow.filter((item) => typeof item === "string") : [];
|
|
308
|
+
const nextAllow = [...currentAllow];
|
|
309
|
+
for (const rule of ANTIGRAVITY_CADRE_ALLOW_RULES) {
|
|
310
|
+
if (!nextAllow.includes(rule)) nextAllow.push(rule);
|
|
311
|
+
}
|
|
312
|
+
const changed = nextAllow.length !== currentAllow.length || !isRecord(settings.permissions) || !Array.isArray(permissions.allow);
|
|
313
|
+
if (changed) {
|
|
314
|
+
settings.permissions = { ...permissions, allow: nextAllow };
|
|
315
|
+
import_node_fs.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
316
|
+
import_node_fs.default.writeFileSync(file, `${JSON.stringify(settings, null, 2)}
|
|
317
|
+
`);
|
|
318
|
+
}
|
|
319
|
+
return { ok: true, target: "antigravity", path: file, changed, configured: true, rules: [...ANTIGRAVITY_CADRE_ALLOW_RULES] };
|
|
320
|
+
}
|
|
321
|
+
function checkAntigravityApprovals() {
|
|
322
|
+
const file = approvalConfigPath("antigravity");
|
|
323
|
+
const parsed = readJsonSettings(file, "antigravity", ANTIGRAVITY_CADRE_ALLOW_RULES);
|
|
324
|
+
if (!parsed.ok) return parsed.result;
|
|
325
|
+
const permissions = isRecord(parsed.settings.permissions) ? parsed.settings.permissions : {};
|
|
326
|
+
const allow = Array.isArray(permissions.allow) ? permissions.allow.filter((item) => typeof item === "string") : [];
|
|
327
|
+
const missing = ANTIGRAVITY_CADRE_ALLOW_RULES.filter((rule) => !allow.includes(rule));
|
|
328
|
+
const result = {
|
|
329
|
+
ok: missing.length === 0,
|
|
330
|
+
target: "antigravity",
|
|
331
|
+
path: file,
|
|
332
|
+
changed: false,
|
|
333
|
+
configured: missing.length === 0,
|
|
334
|
+
rules: missing.length === 0 ? [...ANTIGRAVITY_CADRE_ALLOW_RULES] : missing
|
|
335
|
+
};
|
|
336
|
+
if (missing.length > 0) result.error = `missing Antigravity Cadre tool allow rules: ${missing.join(", ")}`;
|
|
337
|
+
return result;
|
|
338
|
+
}
|
|
339
|
+
function copilotPromptResult() {
|
|
340
|
+
return {
|
|
341
|
+
ok: true,
|
|
342
|
+
target: "copilot",
|
|
343
|
+
path: approvalConfigPath("copilot"),
|
|
344
|
+
changed: false,
|
|
345
|
+
configured: false,
|
|
346
|
+
rules: []
|
|
347
|
+
};
|
|
348
|
+
}
|
|
188
349
|
function readClaudeSettings(file) {
|
|
350
|
+
return readJsonSettings(file, "claude", CLAUDE_CADRE_ALLOW_RULES);
|
|
351
|
+
}
|
|
352
|
+
function readJsonSettings(file, target, rules) {
|
|
189
353
|
if (!import_node_fs.default.existsSync(file)) return { ok: true, settings: {} };
|
|
190
354
|
try {
|
|
191
355
|
const parsed = JSON.parse(import_node_fs.default.readFileSync(file, "utf8"));
|
|
192
356
|
if (isRecord(parsed)) return { ok: true, settings: parsed };
|
|
193
357
|
return {
|
|
194
358
|
ok: false,
|
|
195
|
-
result: { ok: false, target
|
|
359
|
+
result: { ok: false, target, path: file, changed: false, configured: false, rules: [...rules], error: `${file} must contain a JSON object` }
|
|
196
360
|
};
|
|
197
361
|
} catch (error) {
|
|
198
362
|
return {
|
|
199
363
|
ok: false,
|
|
200
364
|
result: {
|
|
201
365
|
ok: false,
|
|
202
|
-
target
|
|
366
|
+
target,
|
|
203
367
|
path: file,
|
|
204
368
|
changed: false,
|
|
205
369
|
configured: false,
|
|
206
|
-
rules: [...
|
|
370
|
+
rules: [...rules],
|
|
207
371
|
error: error instanceof Error ? error.message : String(error)
|
|
208
372
|
}
|
|
209
373
|
};
|
|
@@ -213,85 +377,106 @@ function isRecord(value) {
|
|
|
213
377
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
214
378
|
}
|
|
215
379
|
|
|
216
|
-
// src/cli/install.ts
|
|
217
|
-
var
|
|
218
|
-
var
|
|
219
|
-
var
|
|
220
|
-
function
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
"",
|
|
224
|
-
"Usage:",
|
|
225
|
-
" cadre install [--target codex|claude|all] [--scope user|project|local] [--dry-run] [--check] [--force] [--yes]",
|
|
226
|
-
" cadre doctor",
|
|
227
|
-
" cadre help"
|
|
228
|
-
].join("\n");
|
|
380
|
+
// src/cli/install-checks.ts
|
|
381
|
+
var import_node_fs2 = __toESM(require("node:fs"));
|
|
382
|
+
var import_node_path3 = __toESM(require("node:path"));
|
|
383
|
+
var import_node_child_process2 = require("node:child_process");
|
|
384
|
+
function runCommand(plan) {
|
|
385
|
+
const result = (0, import_node_child_process2.spawnSync)(plan.command, plan.args, { encoding: "utf8" });
|
|
386
|
+
return { ok: result.status === 0, status: result.status, stderr: result.stderr || "" };
|
|
229
387
|
}
|
|
230
|
-
function
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
yes: false,
|
|
238
|
-
cadreHome: process.env.CADRE_HOME || import_node_path2.default.join(import_node_os2.default.homedir(), ".cadre")
|
|
388
|
+
function pingMcp(runtime) {
|
|
389
|
+
if (!import_node_fs2.default.existsSync(runtime.mcpServer)) return { ok: false, reason: `missing MCP server: ${runtime.mcpServer}` };
|
|
390
|
+
const request = {
|
|
391
|
+
jsonrpc: "2.0",
|
|
392
|
+
id: 1,
|
|
393
|
+
method: "tools/call",
|
|
394
|
+
params: { name: "cadre_action", arguments: { action: "project.ping" } }
|
|
239
395
|
};
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
if (!value) throw new Error("--home requires a path");
|
|
259
|
-
parsed.cadreHome = import_node_path2.default.resolve(value);
|
|
260
|
-
index += 1;
|
|
261
|
-
} else {
|
|
262
|
-
throw new Error(`Unknown install option: ${arg}`);
|
|
263
|
-
}
|
|
396
|
+
const result = (0, import_node_child_process2.spawnSync)(runtime.nodePath, [runtime.mcpServer], {
|
|
397
|
+
cwd: runtime.runtimeRoot,
|
|
398
|
+
input: `${JSON.stringify(request)}
|
|
399
|
+
`,
|
|
400
|
+
encoding: "utf8",
|
|
401
|
+
timeout: 3e3
|
|
402
|
+
});
|
|
403
|
+
if (result.status !== 0 && !result.stdout.trim()) return { ok: false, reason: result.stderr || `MCP exited with ${result.status}` };
|
|
404
|
+
const line = result.stdout.split(/\r?\n/).find((entry) => entry.trim());
|
|
405
|
+
if (!line) return { ok: false, reason: "MCP returned no JSON-RPC response" };
|
|
406
|
+
try {
|
|
407
|
+
const parsed = JSON.parse(line);
|
|
408
|
+
if (parsed.error) return { ok: false, reason: parsed.error.message || "MCP returned an error" };
|
|
409
|
+
const text = parsed.result?.content?.[0]?.text;
|
|
410
|
+
const body = text ? JSON.parse(text) : null;
|
|
411
|
+
return body?.data?.ok === true ? { ok: true } : { ok: false, reason: "MCP ping did not return ok:true" };
|
|
412
|
+
} catch (error) {
|
|
413
|
+
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
|
|
264
414
|
}
|
|
265
|
-
return parsed;
|
|
266
415
|
}
|
|
267
|
-
function
|
|
268
|
-
|
|
269
|
-
return {
|
|
270
|
-
runtimeRoot,
|
|
271
|
-
nodePath: process.execPath,
|
|
272
|
-
mcpServer: import_node_path2.default.join(runtimeRoot, "scripts", "mcp", "cadre-server.js")
|
|
273
|
-
};
|
|
416
|
+
function forbiddenThinPayload(root) {
|
|
417
|
+
return ["assets", "agents", "scripts", "references", "templates"].filter((name) => import_node_fs2.default.existsSync(import_node_path3.default.join(root, name))).map((name) => `${root}/${name}`);
|
|
274
418
|
}
|
|
275
|
-
function
|
|
276
|
-
|
|
277
|
-
|
|
419
|
+
function pluginConfigFiles(target, pluginRoot) {
|
|
420
|
+
if (target === "codex") {
|
|
421
|
+
return { manifest: import_node_path3.default.join(pluginRoot, ".codex-plugin", "plugin.json"), mcp: import_node_path3.default.join(pluginRoot, ".mcp.json") };
|
|
422
|
+
}
|
|
423
|
+
if (target === "claude") {
|
|
424
|
+
return { manifest: import_node_path3.default.join(pluginRoot, ".claude-plugin", "plugin.json"), mcp: import_node_path3.default.join(pluginRoot, "mcp-config.json") };
|
|
425
|
+
}
|
|
426
|
+
if (target === "copilot") {
|
|
427
|
+
return { manifest: import_node_path3.default.join(pluginRoot, "plugin.json"), mcp: import_node_path3.default.join(pluginRoot, ".mcp.json") };
|
|
428
|
+
}
|
|
429
|
+
return { manifest: import_node_path3.default.join(pluginRoot, "plugin.json"), mcp: import_node_path3.default.join(pluginRoot, "mcp_config.json") };
|
|
278
430
|
}
|
|
279
|
-
function
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
431
|
+
function checkMcpConfig(target, file, runtime) {
|
|
432
|
+
const errors = [];
|
|
433
|
+
const config = JSON.parse(import_node_fs2.default.readFileSync(file, "utf8"));
|
|
434
|
+
const server = config.mcpServers?.cadre;
|
|
435
|
+
if (server?.command !== runtime.nodePath) errors.push(`${file} does not point at the current Node runtime`);
|
|
436
|
+
if (server?.args?.[0] !== runtime.mcpServer) errors.push(`${file} does not point at ${runtime.mcpServer}`);
|
|
437
|
+
if (server?.cwd !== runtime.runtimeRoot) errors.push(`${file} has wrong cwd`);
|
|
438
|
+
if (target === "copilot") {
|
|
439
|
+
if (server?.type !== "local") errors.push(`${file} must declare Copilot local MCP type`);
|
|
440
|
+
if (!server?.tools?.includes("*")) errors.push(`${file} must allow Copilot MCP tools`);
|
|
441
|
+
}
|
|
442
|
+
return errors;
|
|
283
443
|
}
|
|
284
|
-
function
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
444
|
+
function checkTarget(target, paths, runtime) {
|
|
445
|
+
const errors = [];
|
|
446
|
+
for (const skillRoot of paths.skillRoots) {
|
|
447
|
+
const skill = import_node_path3.default.join(skillRoot, "SKILL.md");
|
|
448
|
+
if (!import_node_fs2.default.existsSync(skill)) errors.push(`missing ${skill}`);
|
|
449
|
+
}
|
|
450
|
+
for (const pluginRoot of paths.pluginRoots) {
|
|
451
|
+
const skill = import_node_path3.default.join(pluginRoot, "skills", "cadre", "SKILL.md");
|
|
452
|
+
if (!import_node_fs2.default.existsSync(skill)) errors.push(`missing ${skill}`);
|
|
453
|
+
const files = pluginConfigFiles(target, pluginRoot);
|
|
454
|
+
if (!import_node_fs2.default.existsSync(files.manifest)) errors.push(`missing ${files.manifest}`);
|
|
455
|
+
if (!import_node_fs2.default.existsSync(files.mcp)) errors.push(`missing ${files.mcp}`);
|
|
456
|
+
errors.push(...forbiddenThinPayload(pluginRoot).map((entry) => `thin plugin contains forbidden payload ${entry}`));
|
|
457
|
+
if (import_node_fs2.default.existsSync(files.mcp)) errors.push(...checkMcpConfig(target, files.mcp, runtime));
|
|
458
|
+
}
|
|
459
|
+
if (paths.marketplaceFile && !import_node_fs2.default.existsSync(paths.marketplaceFile)) errors.push(`missing ${paths.marketplaceFile}`);
|
|
460
|
+
return errors;
|
|
461
|
+
}
|
|
462
|
+
function printPlan(target, paths, commands) {
|
|
463
|
+
if (paths.pluginRoots.length > 0) process.stdout.write(`Cadre ${target} plugin: ${paths.pluginRoots.join(", ")}
|
|
464
|
+
`);
|
|
465
|
+
if (paths.skillRoots.length > 0) process.stdout.write(`Cadre ${target} skill: ${paths.skillRoots.join(", ")}
|
|
466
|
+
`);
|
|
467
|
+
if (paths.marketplaceRoot) process.stdout.write(`Cadre ${target} marketplace: ${paths.marketplaceRoot}
|
|
468
|
+
`);
|
|
469
|
+
for (const command of commands) process.stdout.write(`Would run: ${command.command} ${command.args.join(" ")}
|
|
470
|
+
`);
|
|
291
471
|
}
|
|
472
|
+
|
|
473
|
+
// src/cli/install-writers.ts
|
|
474
|
+
var import_node_fs3 = __toESM(require("node:fs"));
|
|
475
|
+
var import_node_path4 = __toESM(require("node:path"));
|
|
476
|
+
var MARKETPLACE_PLUGIN_SOURCE = "./plugins/cadre";
|
|
292
477
|
function readPackageMetadata(runtimeRoot) {
|
|
293
478
|
try {
|
|
294
|
-
const json = JSON.parse(
|
|
479
|
+
const json = JSON.parse(import_node_fs3.default.readFileSync(import_node_path4.default.join(runtimeRoot, "package.json"), "utf8"));
|
|
295
480
|
return {
|
|
296
481
|
version: typeof json.version === "string" ? json.version : "0.0.0",
|
|
297
482
|
description: typeof json.description === "string" ? json.description : "MCP-first Cadre workflows.",
|
|
@@ -309,9 +494,9 @@ function readPackageMetadata(runtimeRoot) {
|
|
|
309
494
|
};
|
|
310
495
|
}
|
|
311
496
|
}
|
|
312
|
-
function
|
|
497
|
+
function baseManifest(runtime) {
|
|
313
498
|
const metadata = readPackageMetadata(runtime.runtimeRoot);
|
|
314
|
-
|
|
499
|
+
return {
|
|
315
500
|
name: PACKAGE_PLUGIN_NAME,
|
|
316
501
|
version: metadata.version,
|
|
317
502
|
description: metadata.description,
|
|
@@ -322,34 +507,42 @@ function pluginManifest(target, runtime) {
|
|
|
322
507
|
keywords: ["cadre", "context-driven-development", "skills", "mcp"],
|
|
323
508
|
skills: "./skills/"
|
|
324
509
|
};
|
|
325
|
-
|
|
326
|
-
|
|
510
|
+
}
|
|
511
|
+
function pluginManifest(target, runtime) {
|
|
512
|
+
const base = baseManifest(runtime);
|
|
513
|
+
if (target === "claude") return { ...base, displayName: PACKAGE_DISPLAY_NAME, mcpServers: "./mcp-config.json" };
|
|
514
|
+
if (target === "antigravity") {
|
|
515
|
+
return {
|
|
516
|
+
$schema: "https://antigravity.google/schemas/v1/plugin.json",
|
|
517
|
+
name: PACKAGE_PLUGIN_NAME,
|
|
518
|
+
description: base.description,
|
|
519
|
+
version: base.version
|
|
520
|
+
};
|
|
327
521
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
defaultPrompt: ["Set up this repo with Cadre.", "Show Cadre team status.", "Review the current Cadre track."],
|
|
339
|
-
brandColor: "#10A37F"
|
|
340
|
-
}
|
|
522
|
+
const mcpServers = "./.mcp.json";
|
|
523
|
+
const codexInterface = {
|
|
524
|
+
displayName: PACKAGE_DISPLAY_NAME,
|
|
525
|
+
shortDescription: "MCP-first planning, tracks, reviews, and packet tools.",
|
|
526
|
+
longDescription: "Cadre packages context-driven development workflows through one global MCP runtime.",
|
|
527
|
+
developerName: "Vishal Kumar",
|
|
528
|
+
category: "Productivity",
|
|
529
|
+
capabilities: ["Read", "Write", "Interactive"],
|
|
530
|
+
defaultPrompt: ["Set up this repo with Cadre.", "Show Cadre team status.", "Review the current Cadre track."],
|
|
531
|
+
brandColor: "#10A37F"
|
|
341
532
|
};
|
|
533
|
+
return target === "copilot" ? { ...base, mcpServers } : { ...base, mcpServers, interface: codexInterface };
|
|
342
534
|
}
|
|
343
|
-
function mcpConfig(runtime) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
args: [runtime.mcpServer],
|
|
349
|
-
cwd: runtime.runtimeRoot
|
|
350
|
-
}
|
|
351
|
-
}
|
|
535
|
+
function mcpConfig(target, runtime) {
|
|
536
|
+
const server = {
|
|
537
|
+
command: runtime.nodePath,
|
|
538
|
+
args: [runtime.mcpServer],
|
|
539
|
+
cwd: runtime.runtimeRoot
|
|
352
540
|
};
|
|
541
|
+
if (target === "copilot") {
|
|
542
|
+
server.type = "local";
|
|
543
|
+
server.tools = ["*"];
|
|
544
|
+
}
|
|
545
|
+
return { mcpServers: { cadre: server } };
|
|
353
546
|
}
|
|
354
547
|
function marketplace(target, runtime) {
|
|
355
548
|
const metadata = readPackageMetadata(runtime.runtimeRoot);
|
|
@@ -381,108 +574,156 @@ function marketplace(target, runtime) {
|
|
|
381
574
|
};
|
|
382
575
|
}
|
|
383
576
|
function writeJson(file, value) {
|
|
384
|
-
|
|
385
|
-
|
|
577
|
+
import_node_fs3.default.mkdirSync(import_node_path4.default.dirname(file), { recursive: true });
|
|
578
|
+
import_node_fs3.default.writeFileSync(file, `${JSON.stringify(value, null, 2)}
|
|
386
579
|
`);
|
|
387
580
|
}
|
|
388
581
|
function writeText(file, text) {
|
|
389
|
-
|
|
390
|
-
|
|
582
|
+
import_node_fs3.default.mkdirSync(import_node_path4.default.dirname(file), { recursive: true });
|
|
583
|
+
import_node_fs3.default.writeFileSync(file, text.endsWith("\n") ? text : `${text}
|
|
391
584
|
`);
|
|
392
585
|
}
|
|
393
|
-
function
|
|
394
|
-
|
|
395
|
-
writeText(
|
|
586
|
+
function writePluginRoot(target, pluginRoot, runtime, skillShim) {
|
|
587
|
+
import_node_fs3.default.rmSync(pluginRoot, { recursive: true, force: true });
|
|
588
|
+
writeText(import_node_path4.default.join(pluginRoot, "skills", "cadre", "SKILL.md"), skillShim);
|
|
396
589
|
if (target === "codex") {
|
|
397
|
-
writeJson(
|
|
398
|
-
writeJson(
|
|
590
|
+
writeJson(import_node_path4.default.join(pluginRoot, ".codex-plugin", "plugin.json"), pluginManifest(target, runtime));
|
|
591
|
+
writeJson(import_node_path4.default.join(pluginRoot, ".mcp.json"), mcpConfig(target, runtime));
|
|
592
|
+
} else if (target === "claude") {
|
|
593
|
+
writeJson(import_node_path4.default.join(pluginRoot, ".claude-plugin", "plugin.json"), pluginManifest(target, runtime));
|
|
594
|
+
writeJson(import_node_path4.default.join(pluginRoot, "mcp-config.json"), mcpConfig(target, runtime));
|
|
595
|
+
} else if (target === "copilot") {
|
|
596
|
+
writeJson(import_node_path4.default.join(pluginRoot, "plugin.json"), pluginManifest(target, runtime));
|
|
597
|
+
writeJson(import_node_path4.default.join(pluginRoot, ".mcp.json"), mcpConfig(target, runtime));
|
|
399
598
|
} else {
|
|
400
|
-
writeJson(
|
|
401
|
-
writeJson(
|
|
599
|
+
writeJson(import_node_path4.default.join(pluginRoot, "plugin.json"), pluginManifest(target, runtime));
|
|
600
|
+
writeJson(import_node_path4.default.join(pluginRoot, "mcp_config.json"), mcpConfig(target, runtime));
|
|
402
601
|
}
|
|
403
|
-
writeJson(paths.marketplaceFile, marketplace(target, runtime));
|
|
404
602
|
}
|
|
405
|
-
function
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
];
|
|
603
|
+
function writeTarget(target, paths, runtime, skillShim) {
|
|
604
|
+
for (const pluginRoot of paths.pluginRoots) writePluginRoot(target, pluginRoot, runtime, skillShim);
|
|
605
|
+
for (const skillRoot of paths.skillRoots) {
|
|
606
|
+
import_node_fs3.default.rmSync(skillRoot, { recursive: true, force: true });
|
|
607
|
+
writeText(import_node_path4.default.join(skillRoot, "SKILL.md"), skillShim);
|
|
411
608
|
}
|
|
609
|
+
if (paths.marketplaceFile && (target === "codex" || target === "claude")) {
|
|
610
|
+
writeJson(paths.marketplaceFile, marketplace(target, runtime));
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
function removeTarget(paths) {
|
|
614
|
+
const roots = /* @__PURE__ */ new Set();
|
|
615
|
+
if (paths.marketplaceRoot) roots.add(paths.marketplaceRoot);
|
|
616
|
+
for (const pluginRoot of paths.pluginRoots) roots.add(pluginRoot);
|
|
617
|
+
for (const skillRoot of paths.skillRoots) roots.add(skillRoot);
|
|
618
|
+
const removed = [];
|
|
619
|
+
for (const root of roots) {
|
|
620
|
+
if (!import_node_fs3.default.existsSync(root)) continue;
|
|
621
|
+
import_node_fs3.default.rmSync(root, { recursive: true, force: true });
|
|
622
|
+
removed.push(root);
|
|
623
|
+
}
|
|
624
|
+
return removed;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// src/cli/install.ts
|
|
628
|
+
function usage() {
|
|
412
629
|
return [
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
]
|
|
630
|
+
"Cadre CLI",
|
|
631
|
+
"",
|
|
632
|
+
"Usage:",
|
|
633
|
+
" cadre install [--target codex|claude|copilot|antigravity|all] [--scope user|project|local] [--dry-run] [--check] [--force] [--yes]",
|
|
634
|
+
" cadre uninstall [--target codex|claude|copilot|antigravity|all] [--scope user|project|local] [--dry-run] [--yes]",
|
|
635
|
+
" cadre doctor",
|
|
636
|
+
" cadre help"
|
|
637
|
+
].join("\n");
|
|
417
638
|
}
|
|
418
|
-
function
|
|
419
|
-
|
|
420
|
-
|
|
639
|
+
function parseTarget(value) {
|
|
640
|
+
if (!value) throw new Error("--target requires a value");
|
|
641
|
+
if (value === "all") return value;
|
|
642
|
+
if (INSTALL_TARGETS.includes(value)) return value;
|
|
643
|
+
throw new Error("--target must be codex, claude, copilot, antigravity, or all");
|
|
421
644
|
}
|
|
422
|
-
function
|
|
423
|
-
|
|
424
|
-
|
|
645
|
+
function parseScope(value) {
|
|
646
|
+
if (value === "user" || value === "project" || value === "local") return value;
|
|
647
|
+
throw new Error("--scope must be user, project, or local");
|
|
425
648
|
}
|
|
426
|
-
function
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
649
|
+
function parseInstall(argv) {
|
|
650
|
+
const parsed = {
|
|
651
|
+
target: "auto",
|
|
652
|
+
scope: "user",
|
|
653
|
+
dryRun: false,
|
|
654
|
+
check: false,
|
|
655
|
+
force: false,
|
|
656
|
+
yes: false,
|
|
657
|
+
cadreHome: process.env.CADRE_HOME || import_node_path5.default.join(import_node_os3.default.homedir(), ".cadre")
|
|
433
658
|
};
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
if (
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
659
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
660
|
+
const arg = argv[index];
|
|
661
|
+
if (arg === "--dry-run") parsed.dryRun = true;
|
|
662
|
+
else if (arg === "--check") parsed.check = true;
|
|
663
|
+
else if (arg === "--force") parsed.force = true;
|
|
664
|
+
else if (arg === "--yes" || arg === "-y") parsed.yes = true;
|
|
665
|
+
else if (arg === "--target") {
|
|
666
|
+
parsed.target = parseTarget(argv[index + 1]);
|
|
667
|
+
index += 1;
|
|
668
|
+
} else if (arg === "--scope") {
|
|
669
|
+
parsed.scope = parseScope(argv[index + 1]);
|
|
670
|
+
index += 1;
|
|
671
|
+
} else if (arg === "--home") {
|
|
672
|
+
const value = argv[index + 1];
|
|
673
|
+
if (!value) throw new Error("--home requires a path");
|
|
674
|
+
parsed.cadreHome = import_node_path5.default.resolve(value);
|
|
675
|
+
index += 1;
|
|
676
|
+
} else {
|
|
677
|
+
throw new Error(`Unknown install option: ${arg}`);
|
|
678
|
+
}
|
|
452
679
|
}
|
|
680
|
+
return parsed;
|
|
453
681
|
}
|
|
454
|
-
function
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if (!import_node_fs2.default.existsSync(mcp)) errors.push(`missing ${mcp}`);
|
|
462
|
-
errors.push(...assertNoThinPluginPayload(paths).map((entry) => `thin plugin contains forbidden payload ${entry}`));
|
|
463
|
-
if (import_node_fs2.default.existsSync(mcp)) {
|
|
464
|
-
const config = JSON.parse(import_node_fs2.default.readFileSync(mcp, "utf8"));
|
|
465
|
-
const server = config.mcpServers?.cadre;
|
|
466
|
-
if (server?.command !== runtime.nodePath) errors.push(`${mcp} does not point at the current Node runtime`);
|
|
467
|
-
if (server?.args?.[0] !== runtime.mcpServer) errors.push(`${mcp} does not point at ${runtime.mcpServer}`);
|
|
468
|
-
if (server?.cwd !== runtime.runtimeRoot) errors.push(`${mcp} has wrong cwd`);
|
|
682
|
+
function printApprovalResult(target, path6, configured) {
|
|
683
|
+
if (configured) {
|
|
684
|
+
process.stdout.write(`Cadre ${target} MCP tool approvals are configured in ${path6}
|
|
685
|
+
`);
|
|
686
|
+
} else {
|
|
687
|
+
process.stdout.write(`Cadre ${target} MCP tools may prompt on first use; no approval file was changed.
|
|
688
|
+
`);
|
|
469
689
|
}
|
|
470
|
-
return errors;
|
|
471
690
|
}
|
|
472
|
-
function
|
|
473
|
-
|
|
691
|
+
function installedNoun(paths) {
|
|
692
|
+
return paths.pluginRoots.length > 0 ? "plugin" : "skill";
|
|
693
|
+
}
|
|
694
|
+
function pathsExist(paths) {
|
|
695
|
+
return Boolean(
|
|
696
|
+
paths.marketplaceRoot && import_node_fs4.default.existsSync(paths.marketplaceRoot) || paths.pluginRoots.some((root) => import_node_fs4.default.existsSync(root)) || paths.skillRoots.some((root) => import_node_fs4.default.existsSync(root))
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
function selectedUninstallTargets(options) {
|
|
700
|
+
if (options.target !== "auto" && options.target !== "all") return [options.target];
|
|
701
|
+
if (options.target === "all") return [...INSTALL_TARGETS];
|
|
702
|
+
return INSTALL_TARGETS.filter(
|
|
703
|
+
(target) => commandExists(target === "antigravity" ? "agy" : target) || pathsExist(targetPaths(options.cadreHome, target, options.scope))
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
function printUninstallPlan(target, paths, commands) {
|
|
707
|
+
if (paths.marketplaceRoot) process.stdout.write(`Would remove: ${paths.marketplaceRoot}
|
|
708
|
+
`);
|
|
709
|
+
for (const pluginRoot of paths.pluginRoots) process.stdout.write(`Would remove: ${pluginRoot}
|
|
474
710
|
`);
|
|
475
|
-
process.stdout.write(`
|
|
711
|
+
for (const skillRoot of paths.skillRoots) process.stdout.write(`Would remove: ${skillRoot}
|
|
476
712
|
`);
|
|
477
713
|
for (const command of commands) process.stdout.write(`Would run: ${command.command} ${command.args.join(" ")}
|
|
714
|
+
`);
|
|
715
|
+
if (!pathsExist(paths) && commands.length === 0) process.stdout.write(`No Cadre ${target} files or native uninstall commands found.
|
|
478
716
|
`);
|
|
479
717
|
}
|
|
718
|
+
function missingInstallCommandIsWarning(options, target, optional) {
|
|
719
|
+
return optional === true || options.target === "all" && target === "copilot";
|
|
720
|
+
}
|
|
480
721
|
function runInstall(argv, context) {
|
|
481
722
|
const options = parseInstall(argv);
|
|
482
723
|
const runtime = runtimePaths();
|
|
483
724
|
const targets = selectedTargets(options);
|
|
484
725
|
if (targets.length === 0) {
|
|
485
|
-
process.stderr.write("No supported client detected. Install Codex or
|
|
726
|
+
process.stderr.write("No supported client detected. Install Codex, Claude, Copilot, or Antigravity, or pass --target codex|claude|copilot|antigravity.\n");
|
|
486
727
|
return 1;
|
|
487
728
|
}
|
|
488
729
|
const ping = pingMcp(runtime);
|
|
@@ -493,7 +734,8 @@ function runInstall(argv, context) {
|
|
|
493
734
|
}
|
|
494
735
|
let ok = true;
|
|
495
736
|
for (const target of targets) {
|
|
496
|
-
|
|
737
|
+
let targetOk = true;
|
|
738
|
+
const paths = targetPaths(options.cadreHome, target, options.scope);
|
|
497
739
|
const commands = installCommands(target, paths, options.scope);
|
|
498
740
|
if (options.dryRun) {
|
|
499
741
|
printPlan(target, paths, commands);
|
|
@@ -501,7 +743,7 @@ function runInstall(argv, context) {
|
|
|
501
743
|
`);
|
|
502
744
|
continue;
|
|
503
745
|
}
|
|
504
|
-
if (!options.check)
|
|
746
|
+
if (!options.check) writeTarget(target, paths, runtime, context.skillShim);
|
|
505
747
|
const errors = checkTarget(target, paths, runtime);
|
|
506
748
|
if (!options.check) {
|
|
507
749
|
const approvals = bootstrapClientApprovals(target);
|
|
@@ -511,36 +753,82 @@ function runInstall(argv, context) {
|
|
|
511
753
|
if (!approvalCheck.ok) errors.push(`${target} approval check failed: ${approvalCheck.error || approvalCheck.path}`);
|
|
512
754
|
if (errors.length > 0) {
|
|
513
755
|
ok = false;
|
|
756
|
+
targetOk = false;
|
|
514
757
|
for (const error of errors) process.stderr.write(`${error}
|
|
515
758
|
`);
|
|
516
759
|
continue;
|
|
517
760
|
}
|
|
518
761
|
if (options.check) {
|
|
519
|
-
process.stdout.write(`Cadre ${target}
|
|
520
|
-
`);
|
|
521
|
-
process.stdout.write(`Cadre ${target} MCP tool approvals are configured in ${approvalCheck.path}
|
|
522
|
-
`);
|
|
523
|
-
continue;
|
|
524
|
-
}
|
|
525
|
-
if (!commandExists(target)) {
|
|
526
|
-
ok = false;
|
|
527
|
-
process.stderr.write(`${target} command not found; plugin files were written but native registration was skipped.
|
|
762
|
+
process.stdout.write(`Cadre ${target} ${installedNoun(paths)} is installed and points at ${runtime.mcpServer}
|
|
528
763
|
`);
|
|
764
|
+
printApprovalResult(target, approvalCheck.path, approvalCheck.configured);
|
|
529
765
|
continue;
|
|
530
766
|
}
|
|
531
767
|
for (const command of commands) {
|
|
768
|
+
if (!commandExists(command.command)) {
|
|
769
|
+
const message = `${command.command} command not found; plugin files were written but native registration was skipped.
|
|
770
|
+
`;
|
|
771
|
+
if (missingInstallCommandIsWarning(options, target, command.optional)) process.stderr.write(message);
|
|
772
|
+
else {
|
|
773
|
+
targetOk = false;
|
|
774
|
+
ok = false;
|
|
775
|
+
process.stderr.write(message);
|
|
776
|
+
}
|
|
777
|
+
continue;
|
|
778
|
+
}
|
|
532
779
|
const result = runCommand(command);
|
|
533
780
|
if (!result.ok) {
|
|
781
|
+
targetOk = false;
|
|
534
782
|
ok = false;
|
|
535
783
|
process.stderr.write(`${command.command} ${command.args.join(" ")} failed: ${result.stderr}
|
|
536
784
|
`);
|
|
537
785
|
}
|
|
538
786
|
}
|
|
539
|
-
if (
|
|
787
|
+
if (targetOk) {
|
|
788
|
+
process.stdout.write(`Installed Cadre ${target} ${installedNoun(paths)} through ${paths.primaryRoot}
|
|
540
789
|
`);
|
|
790
|
+
printApprovalResult(target, approvalCheck.path, approvalCheck.configured);
|
|
791
|
+
}
|
|
541
792
|
}
|
|
542
793
|
return ok ? 0 : 1;
|
|
543
794
|
}
|
|
795
|
+
function runUninstall(argv) {
|
|
796
|
+
const options = parseInstall(argv);
|
|
797
|
+
const targets = selectedUninstallTargets(options);
|
|
798
|
+
if (targets.length === 0) {
|
|
799
|
+
process.stderr.write("No Cadre client install found. Pass --target codex|claude|copilot|antigravity to remove a specific generated target.\n");
|
|
800
|
+
return 1;
|
|
801
|
+
}
|
|
802
|
+
for (const target of targets) {
|
|
803
|
+
const paths = targetPaths(options.cadreHome, target, options.scope);
|
|
804
|
+
const commands = uninstallCommands(target, paths, options.scope);
|
|
805
|
+
if (options.dryRun) {
|
|
806
|
+
printUninstallPlan(target, paths, commands);
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
for (const command of commands) {
|
|
810
|
+
if (!commandExists(command.command)) {
|
|
811
|
+
process.stderr.write(`${command.command} command not found; removing generated Cadre ${target} files only.
|
|
812
|
+
`);
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
const result = runCommand(command);
|
|
816
|
+
if (!result.ok) {
|
|
817
|
+
process.stderr.write(`${command.command} ${command.args.join(" ")} failed; continuing local cleanup: ${result.stderr}
|
|
818
|
+
`);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
const removed = removeTarget(paths);
|
|
822
|
+
if (removed.length > 0) {
|
|
823
|
+
process.stdout.write(`Uninstalled Cadre ${target} ${installedNoun(paths)} and removed ${removed.join(", ")}
|
|
824
|
+
`);
|
|
825
|
+
} else {
|
|
826
|
+
process.stdout.write(`No generated Cadre ${target} files found to remove.
|
|
827
|
+
`);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
return 0;
|
|
831
|
+
}
|
|
544
832
|
function runDoctor() {
|
|
545
833
|
const runtime = runtimePaths();
|
|
546
834
|
const ping = pingMcp(runtime);
|
|
@@ -558,6 +846,7 @@ async function runCli(argv, context) {
|
|
|
558
846
|
const command = argv[0] || "help";
|
|
559
847
|
let code = 0;
|
|
560
848
|
if (command === "install") code = runInstall(argv.slice(1), context);
|
|
849
|
+
else if (command === "uninstall" || command === "remove") code = runUninstall(argv.slice(1));
|
|
561
850
|
else if (command === "doctor") code = runDoctor();
|
|
562
851
|
else if (command === "help" || command === "--help" || command === "-h") process.stdout.write(`${usage()}
|
|
563
852
|
`);
|