cadre-ai 1.1.2 → 2.0.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 +4 -3
- package/package.json +4 -2
- package/scripts/cadre-cli.js +493 -195
- package/scripts/cadre-core.js +3808 -878
- package/scripts/cadre-job-runner.js +789 -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 +4079 -1086
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: |\n Context-driven development methodology for organized, spec-first coding. Use when:\n - Project has a `cadre/` directory\n - User mentions specs, plans, tracks, or context-driven development\n - Files like `cadre/tracks.json`, `cadre/product.json`, or `cadre/workflow.json` exist\n - User asks about project status, implementation progress, or track management\n - User wants to organize development work with TDD practices\n - User asks for a `cadre-*` workflow (setup, newtrack, implement, status, revert, validate, flag, revise, review, ship, land, archive, release, handoff, refresh, formula, artifacts)\n - User mentions documentation is outdated or wants to sync context with codebase changes\n - Project is a polyrepo control repo (`cadre/repos.json` with mode \"polyrepo\") spanning git-submodule product repos\n\n Interoperable across Claude Code
|
|
4
|
+
const __CADRE_SKILL_SHIM__ = "---\nname: cadre\ndescription: |\n Context-driven development methodology for organized, spec-first coding. Use when:\n - Project has a `cadre/` directory\n - User mentions specs, plans, tracks, or context-driven development\n - Files like `cadre/tracks.json`, `cadre/product.json`, or `cadre/workflow.json` exist\n - User asks about project status, implementation progress, or track management\n - User wants to organize development work with TDD practices\n - User asks for a `cadre-*` workflow (setup, newtrack, implement, debug, status, revert, validate, flag, revise, review, ship, land, archive, release, handoff, refresh, formula, artifacts)\n - User mentions documentation is outdated or wants to sync context with codebase changes\n - Project is a polyrepo control repo (`cadre/repos.json` with mode \"polyrepo\") spanning git-submodule product repos\n\n Interoperable across Claude Code, OpenAI Codex, Copilot, and Antigravity.\n Uses native Cadre state for persistent task memory across sessions.\n---\n\n# Cadre Skill Shim\n\nCadre MCP is required for every Cadre workflow. Before acting, verify the MCP\nruntime with `cadre_project` using `{\"action\":\"ping\"}`. If Cadre MCP tools or\nresources are unavailable, halt and ask the user to install, enable, or restart\nthe Cadre plugin.\n\nLoad `cadre://skill-contract` for the authoritative `cadre.skill.v1` contract.\nUse `cadre://workflow-protocols` to discover workflow protocol resources, then\nload `cadre://workflow-protocol?workflow=<name>` for the active workflow.\nReferences and template inventory are also MCP-served through Cadre resources.\n\nFor staged approvals, stay on Cadre's packet-led review path: use the returned\n`approval.current_stage` and current review output first. Target mode may have\n`manifest_path:null`, `mutates_worktree:true`, and `files[].target_path` /\n`review_path`; bundle mode uses the manifest and temp review paths. Ask for\nexplicit user approval before sending approval fields. Avoid extra inspection\nunless packet evidence cannot answer the current stage question.\n";
|
|
5
5
|
"use strict";
|
|
6
6
|
var __create = Object.create;
|
|
7
7
|
var __defProp = Object.defineProperty;
|
|
@@ -27,15 +27,122 @@ 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
147
|
"cadre_resource",
|
|
41
148
|
"cadre_workflow",
|
|
@@ -54,22 +161,37 @@ var CLAUDE_CADRE_ALLOW_RULES = [
|
|
|
54
161
|
"mcp__plugin_cadre_cadre__*",
|
|
55
162
|
"mcp__cadre__*"
|
|
56
163
|
];
|
|
164
|
+
var ANTIGRAVITY_CADRE_ALLOW_RULES = [
|
|
165
|
+
"mcp(cadre/*)"
|
|
166
|
+
];
|
|
57
167
|
function approvalConfigPath(target) {
|
|
58
168
|
if (target === "codex") {
|
|
59
|
-
return
|
|
169
|
+
return import_node_path2.default.join(process.env.CODEX_HOME || import_node_path2.default.join(import_node_os2.default.homedir(), ".codex"), "config.toml");
|
|
170
|
+
}
|
|
171
|
+
if (target === "claude") {
|
|
172
|
+
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
173
|
}
|
|
61
|
-
|
|
174
|
+
if (target === "antigravity") return import_node_path2.default.join(antigravityCliHome(), "settings.json");
|
|
175
|
+
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
176
|
}
|
|
63
177
|
function bootstrapClientApprovals(target) {
|
|
64
|
-
|
|
178
|
+
if (target === "codex") return bootstrapCodexApprovals();
|
|
179
|
+
if (target === "claude") return bootstrapClaudeApprovals();
|
|
180
|
+
if (target === "antigravity") return bootstrapAntigravityApprovals();
|
|
181
|
+
return copilotPromptResult();
|
|
65
182
|
}
|
|
66
183
|
function checkClientApprovals(target) {
|
|
67
|
-
|
|
184
|
+
if (target === "codex") return checkCodexApprovals();
|
|
185
|
+
if (target === "claude") return checkClaudeApprovals();
|
|
186
|
+
if (target === "antigravity") return checkAntigravityApprovals();
|
|
187
|
+
return copilotPromptResult();
|
|
68
188
|
}
|
|
69
189
|
function approvalSummary(target) {
|
|
70
190
|
const file = approvalConfigPath(target);
|
|
71
191
|
if (target === "codex") return `Cadre codex MCP tool approvals: ${file}`;
|
|
72
|
-
return `Cadre claude MCP tool approvals: ${file}`;
|
|
192
|
+
if (target === "claude") return `Cadre claude MCP tool approvals: ${file}`;
|
|
193
|
+
if (target === "antigravity") return `Cadre antigravity CLI MCP allow rule: ${file}`;
|
|
194
|
+
return "Cadre copilot MCP tools may prompt on first use; no approval file is edited";
|
|
73
195
|
}
|
|
74
196
|
function codexToolSection(tool) {
|
|
75
197
|
return `[plugins."cadre@cadre".mcp_servers.cadre.tools.${tool}]`;
|
|
@@ -86,7 +208,7 @@ function bootstrapCodexApprovals() {
|
|
|
86
208
|
const before = text;
|
|
87
209
|
for (const tool of CADRE_MCP_TOOLS) text = upsertCodexApproval(text, tool);
|
|
88
210
|
if (text !== before) {
|
|
89
|
-
import_node_fs.default.mkdirSync(
|
|
211
|
+
import_node_fs.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
90
212
|
import_node_fs.default.writeFileSync(file, text);
|
|
91
213
|
}
|
|
92
214
|
return { ok: true, target: "codex", path: file, changed: text !== before, configured: true, rules: [...CADRE_MCP_TOOLS] };
|
|
@@ -161,7 +283,7 @@ function bootstrapClaudeApprovals() {
|
|
|
161
283
|
const changed = nextAllow.length !== currentAllow.length || !isRecord(settings.permissions) || !Array.isArray(permissions.allow);
|
|
162
284
|
if (changed) {
|
|
163
285
|
settings.permissions = { ...permissions, allow: nextAllow };
|
|
164
|
-
import_node_fs.default.mkdirSync(
|
|
286
|
+
import_node_fs.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
165
287
|
import_node_fs.default.writeFileSync(file, `${JSON.stringify(settings, null, 2)}
|
|
166
288
|
`);
|
|
167
289
|
}
|
|
@@ -185,25 +307,76 @@ function checkClaudeApprovals() {
|
|
|
185
307
|
if (missing.length > 0) result.error = `missing Claude Cadre tool allow rules: ${missing.join(", ")}`;
|
|
186
308
|
return result;
|
|
187
309
|
}
|
|
310
|
+
function bootstrapAntigravityApprovals() {
|
|
311
|
+
const file = approvalConfigPath("antigravity");
|
|
312
|
+
const parsed = readJsonSettings(file, "antigravity", ANTIGRAVITY_CADRE_ALLOW_RULES);
|
|
313
|
+
if (!parsed.ok) return parsed.result;
|
|
314
|
+
const settings = parsed.settings;
|
|
315
|
+
const permissions = isRecord(settings.permissions) ? settings.permissions : {};
|
|
316
|
+
const currentAllow = Array.isArray(permissions.allow) ? permissions.allow.filter((item) => typeof item === "string") : [];
|
|
317
|
+
const nextAllow = [...currentAllow];
|
|
318
|
+
for (const rule of ANTIGRAVITY_CADRE_ALLOW_RULES) {
|
|
319
|
+
if (!nextAllow.includes(rule)) nextAllow.push(rule);
|
|
320
|
+
}
|
|
321
|
+
const changed = nextAllow.length !== currentAllow.length || !isRecord(settings.permissions) || !Array.isArray(permissions.allow);
|
|
322
|
+
if (changed) {
|
|
323
|
+
settings.permissions = { ...permissions, allow: nextAllow };
|
|
324
|
+
import_node_fs.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
325
|
+
import_node_fs.default.writeFileSync(file, `${JSON.stringify(settings, null, 2)}
|
|
326
|
+
`);
|
|
327
|
+
}
|
|
328
|
+
return { ok: true, target: "antigravity", path: file, changed, configured: true, rules: [...ANTIGRAVITY_CADRE_ALLOW_RULES] };
|
|
329
|
+
}
|
|
330
|
+
function checkAntigravityApprovals() {
|
|
331
|
+
const file = approvalConfigPath("antigravity");
|
|
332
|
+
const parsed = readJsonSettings(file, "antigravity", ANTIGRAVITY_CADRE_ALLOW_RULES);
|
|
333
|
+
if (!parsed.ok) return parsed.result;
|
|
334
|
+
const permissions = isRecord(parsed.settings.permissions) ? parsed.settings.permissions : {};
|
|
335
|
+
const allow = Array.isArray(permissions.allow) ? permissions.allow.filter((item) => typeof item === "string") : [];
|
|
336
|
+
const missing = ANTIGRAVITY_CADRE_ALLOW_RULES.filter((rule) => !allow.includes(rule));
|
|
337
|
+
const result = {
|
|
338
|
+
ok: missing.length === 0,
|
|
339
|
+
target: "antigravity",
|
|
340
|
+
path: file,
|
|
341
|
+
changed: false,
|
|
342
|
+
configured: missing.length === 0,
|
|
343
|
+
rules: missing.length === 0 ? [...ANTIGRAVITY_CADRE_ALLOW_RULES] : missing
|
|
344
|
+
};
|
|
345
|
+
if (missing.length > 0) result.error = `missing Antigravity Cadre tool allow rules: ${missing.join(", ")}`;
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
348
|
+
function copilotPromptResult() {
|
|
349
|
+
return {
|
|
350
|
+
ok: true,
|
|
351
|
+
target: "copilot",
|
|
352
|
+
path: approvalConfigPath("copilot"),
|
|
353
|
+
changed: false,
|
|
354
|
+
configured: false,
|
|
355
|
+
rules: []
|
|
356
|
+
};
|
|
357
|
+
}
|
|
188
358
|
function readClaudeSettings(file) {
|
|
359
|
+
return readJsonSettings(file, "claude", CLAUDE_CADRE_ALLOW_RULES);
|
|
360
|
+
}
|
|
361
|
+
function readJsonSettings(file, target, rules) {
|
|
189
362
|
if (!import_node_fs.default.existsSync(file)) return { ok: true, settings: {} };
|
|
190
363
|
try {
|
|
191
364
|
const parsed = JSON.parse(import_node_fs.default.readFileSync(file, "utf8"));
|
|
192
365
|
if (isRecord(parsed)) return { ok: true, settings: parsed };
|
|
193
366
|
return {
|
|
194
367
|
ok: false,
|
|
195
|
-
result: { ok: false, target
|
|
368
|
+
result: { ok: false, target, path: file, changed: false, configured: false, rules: [...rules], error: `${file} must contain a JSON object` }
|
|
196
369
|
};
|
|
197
370
|
} catch (error) {
|
|
198
371
|
return {
|
|
199
372
|
ok: false,
|
|
200
373
|
result: {
|
|
201
374
|
ok: false,
|
|
202
|
-
target
|
|
375
|
+
target,
|
|
203
376
|
path: file,
|
|
204
377
|
changed: false,
|
|
205
378
|
configured: false,
|
|
206
|
-
rules: [...
|
|
379
|
+
rules: [...rules],
|
|
207
380
|
error: error instanceof Error ? error.message : String(error)
|
|
208
381
|
}
|
|
209
382
|
};
|
|
@@ -213,85 +386,106 @@ function isRecord(value) {
|
|
|
213
386
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
214
387
|
}
|
|
215
388
|
|
|
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");
|
|
389
|
+
// src/cli/install-checks.ts
|
|
390
|
+
var import_node_fs2 = __toESM(require("node:fs"));
|
|
391
|
+
var import_node_path3 = __toESM(require("node:path"));
|
|
392
|
+
var import_node_child_process2 = require("node:child_process");
|
|
393
|
+
function runCommand(plan) {
|
|
394
|
+
const result = (0, import_node_child_process2.spawnSync)(plan.command, plan.args, { encoding: "utf8" });
|
|
395
|
+
return { ok: result.status === 0, status: result.status, stderr: result.stderr || "" };
|
|
229
396
|
}
|
|
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")
|
|
397
|
+
function pingMcp(runtime) {
|
|
398
|
+
if (!import_node_fs2.default.existsSync(runtime.mcpServer)) return { ok: false, reason: `missing MCP server: ${runtime.mcpServer}` };
|
|
399
|
+
const request = {
|
|
400
|
+
jsonrpc: "2.0",
|
|
401
|
+
id: 1,
|
|
402
|
+
method: "tools/call",
|
|
403
|
+
params: { name: "cadre_project", arguments: { action: "ping" } }
|
|
239
404
|
};
|
|
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
|
-
}
|
|
405
|
+
const result = (0, import_node_child_process2.spawnSync)(runtime.nodePath, [runtime.mcpServer], {
|
|
406
|
+
cwd: runtime.runtimeRoot,
|
|
407
|
+
input: `${JSON.stringify(request)}
|
|
408
|
+
`,
|
|
409
|
+
encoding: "utf8",
|
|
410
|
+
timeout: 3e3
|
|
411
|
+
});
|
|
412
|
+
if (result.status !== 0 && !result.stdout.trim()) return { ok: false, reason: result.stderr || `MCP exited with ${result.status}` };
|
|
413
|
+
const line = result.stdout.split(/\r?\n/).find((entry) => entry.trim());
|
|
414
|
+
if (!line) return { ok: false, reason: "MCP returned no JSON-RPC response" };
|
|
415
|
+
try {
|
|
416
|
+
const parsed = JSON.parse(line);
|
|
417
|
+
if (parsed.error) return { ok: false, reason: parsed.error.message || "MCP returned an error" };
|
|
418
|
+
const text = parsed.result?.content?.[0]?.text;
|
|
419
|
+
const body = text ? JSON.parse(text) : null;
|
|
420
|
+
return body?.data?.ok === true ? { ok: true } : { ok: false, reason: "MCP ping did not return ok:true" };
|
|
421
|
+
} catch (error) {
|
|
422
|
+
return { ok: false, reason: error instanceof Error ? error.message : String(error) };
|
|
264
423
|
}
|
|
265
|
-
return parsed;
|
|
266
424
|
}
|
|
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
|
-
};
|
|
425
|
+
function forbiddenThinPayload(root) {
|
|
426
|
+
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
427
|
}
|
|
275
|
-
function
|
|
276
|
-
|
|
277
|
-
|
|
428
|
+
function pluginConfigFiles(target, pluginRoot) {
|
|
429
|
+
if (target === "codex") {
|
|
430
|
+
return { manifest: import_node_path3.default.join(pluginRoot, ".codex-plugin", "plugin.json"), mcp: import_node_path3.default.join(pluginRoot, ".mcp.json") };
|
|
431
|
+
}
|
|
432
|
+
if (target === "claude") {
|
|
433
|
+
return { manifest: import_node_path3.default.join(pluginRoot, ".claude-plugin", "plugin.json"), mcp: import_node_path3.default.join(pluginRoot, "mcp-config.json") };
|
|
434
|
+
}
|
|
435
|
+
if (target === "copilot") {
|
|
436
|
+
return { manifest: import_node_path3.default.join(pluginRoot, "plugin.json"), mcp: import_node_path3.default.join(pluginRoot, ".mcp.json") };
|
|
437
|
+
}
|
|
438
|
+
return { manifest: import_node_path3.default.join(pluginRoot, "plugin.json"), mcp: import_node_path3.default.join(pluginRoot, "mcp_config.json") };
|
|
278
439
|
}
|
|
279
|
-
function
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
440
|
+
function checkMcpConfig(target, file, runtime) {
|
|
441
|
+
const errors = [];
|
|
442
|
+
const config = JSON.parse(import_node_fs2.default.readFileSync(file, "utf8"));
|
|
443
|
+
const server = config.mcpServers?.cadre;
|
|
444
|
+
if (server?.command !== runtime.nodePath) errors.push(`${file} does not point at the current Node runtime`);
|
|
445
|
+
if (server?.args?.[0] !== runtime.mcpServer) errors.push(`${file} does not point at ${runtime.mcpServer}`);
|
|
446
|
+
if (server?.cwd !== runtime.runtimeRoot) errors.push(`${file} has wrong cwd`);
|
|
447
|
+
if (target === "copilot") {
|
|
448
|
+
if (server?.type !== "local") errors.push(`${file} must declare Copilot local MCP type`);
|
|
449
|
+
if (!server?.tools?.includes("*")) errors.push(`${file} must allow Copilot MCP tools`);
|
|
450
|
+
}
|
|
451
|
+
return errors;
|
|
283
452
|
}
|
|
284
|
-
function
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
453
|
+
function checkTarget(target, paths, runtime) {
|
|
454
|
+
const errors = [];
|
|
455
|
+
for (const skillRoot of paths.skillRoots) {
|
|
456
|
+
const skill = import_node_path3.default.join(skillRoot, "SKILL.md");
|
|
457
|
+
if (!import_node_fs2.default.existsSync(skill)) errors.push(`missing ${skill}`);
|
|
458
|
+
}
|
|
459
|
+
for (const pluginRoot of paths.pluginRoots) {
|
|
460
|
+
const skill = import_node_path3.default.join(pluginRoot, "skills", "cadre", "SKILL.md");
|
|
461
|
+
if (!import_node_fs2.default.existsSync(skill)) errors.push(`missing ${skill}`);
|
|
462
|
+
const files = pluginConfigFiles(target, pluginRoot);
|
|
463
|
+
if (!import_node_fs2.default.existsSync(files.manifest)) errors.push(`missing ${files.manifest}`);
|
|
464
|
+
if (!import_node_fs2.default.existsSync(files.mcp)) errors.push(`missing ${files.mcp}`);
|
|
465
|
+
errors.push(...forbiddenThinPayload(pluginRoot).map((entry) => `thin plugin contains forbidden payload ${entry}`));
|
|
466
|
+
if (import_node_fs2.default.existsSync(files.mcp)) errors.push(...checkMcpConfig(target, files.mcp, runtime));
|
|
467
|
+
}
|
|
468
|
+
if (paths.marketplaceFile && !import_node_fs2.default.existsSync(paths.marketplaceFile)) errors.push(`missing ${paths.marketplaceFile}`);
|
|
469
|
+
return errors;
|
|
470
|
+
}
|
|
471
|
+
function printPlan(target, paths, commands) {
|
|
472
|
+
if (paths.pluginRoots.length > 0) process.stdout.write(`Cadre ${target} plugin: ${paths.pluginRoots.join(", ")}
|
|
473
|
+
`);
|
|
474
|
+
if (paths.skillRoots.length > 0) process.stdout.write(`Cadre ${target} skill: ${paths.skillRoots.join(", ")}
|
|
475
|
+
`);
|
|
476
|
+
if (paths.marketplaceRoot) process.stdout.write(`Cadre ${target} marketplace: ${paths.marketplaceRoot}
|
|
477
|
+
`);
|
|
478
|
+
for (const command of commands) process.stdout.write(`Would run: ${command.command} ${command.args.join(" ")}
|
|
479
|
+
`);
|
|
291
480
|
}
|
|
481
|
+
|
|
482
|
+
// src/cli/install-writers.ts
|
|
483
|
+
var import_node_fs3 = __toESM(require("node:fs"));
|
|
484
|
+
var import_node_path4 = __toESM(require("node:path"));
|
|
485
|
+
var MARKETPLACE_PLUGIN_SOURCE = "./plugins/cadre";
|
|
292
486
|
function readPackageMetadata(runtimeRoot) {
|
|
293
487
|
try {
|
|
294
|
-
const json = JSON.parse(
|
|
488
|
+
const json = JSON.parse(import_node_fs3.default.readFileSync(import_node_path4.default.join(runtimeRoot, "package.json"), "utf8"));
|
|
295
489
|
return {
|
|
296
490
|
version: typeof json.version === "string" ? json.version : "0.0.0",
|
|
297
491
|
description: typeof json.description === "string" ? json.description : "MCP-first Cadre workflows.",
|
|
@@ -309,9 +503,9 @@ function readPackageMetadata(runtimeRoot) {
|
|
|
309
503
|
};
|
|
310
504
|
}
|
|
311
505
|
}
|
|
312
|
-
function
|
|
506
|
+
function baseManifest(runtime) {
|
|
313
507
|
const metadata = readPackageMetadata(runtime.runtimeRoot);
|
|
314
|
-
|
|
508
|
+
return {
|
|
315
509
|
name: PACKAGE_PLUGIN_NAME,
|
|
316
510
|
version: metadata.version,
|
|
317
511
|
description: metadata.description,
|
|
@@ -322,34 +516,42 @@ function pluginManifest(target, runtime) {
|
|
|
322
516
|
keywords: ["cadre", "context-driven-development", "skills", "mcp"],
|
|
323
517
|
skills: "./skills/"
|
|
324
518
|
};
|
|
325
|
-
|
|
326
|
-
|
|
519
|
+
}
|
|
520
|
+
function pluginManifest(target, runtime) {
|
|
521
|
+
const base = baseManifest(runtime);
|
|
522
|
+
if (target === "claude") return { ...base, displayName: PACKAGE_DISPLAY_NAME, mcpServers: "./mcp-config.json" };
|
|
523
|
+
if (target === "antigravity") {
|
|
524
|
+
return {
|
|
525
|
+
$schema: "https://antigravity.google/schemas/v1/plugin.json",
|
|
526
|
+
name: PACKAGE_PLUGIN_NAME,
|
|
527
|
+
description: base.description,
|
|
528
|
+
version: base.version
|
|
529
|
+
};
|
|
327
530
|
}
|
|
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
|
-
}
|
|
531
|
+
const mcpServers = "./.mcp.json";
|
|
532
|
+
const codexInterface = {
|
|
533
|
+
displayName: PACKAGE_DISPLAY_NAME,
|
|
534
|
+
shortDescription: "MCP-first planning, tracks, reviews, and packet tools.",
|
|
535
|
+
longDescription: "Cadre packages context-driven development workflows through one global MCP runtime.",
|
|
536
|
+
developerName: "Vishal Kumar",
|
|
537
|
+
category: "Productivity",
|
|
538
|
+
capabilities: ["Read", "Write", "Interactive"],
|
|
539
|
+
defaultPrompt: ["Set up this repo with Cadre.", "Show Cadre team status.", "Review the current Cadre track."],
|
|
540
|
+
brandColor: "#10A37F"
|
|
341
541
|
};
|
|
542
|
+
return target === "copilot" ? { ...base, mcpServers } : { ...base, mcpServers, interface: codexInterface };
|
|
342
543
|
}
|
|
343
|
-
function mcpConfig(runtime) {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
args: [runtime.mcpServer],
|
|
349
|
-
cwd: runtime.runtimeRoot
|
|
350
|
-
}
|
|
351
|
-
}
|
|
544
|
+
function mcpConfig(target, runtime) {
|
|
545
|
+
const server = {
|
|
546
|
+
command: runtime.nodePath,
|
|
547
|
+
args: [runtime.mcpServer],
|
|
548
|
+
cwd: runtime.runtimeRoot
|
|
352
549
|
};
|
|
550
|
+
if (target === "copilot") {
|
|
551
|
+
server.type = "local";
|
|
552
|
+
server.tools = ["*"];
|
|
553
|
+
}
|
|
554
|
+
return { mcpServers: { cadre: server } };
|
|
353
555
|
}
|
|
354
556
|
function marketplace(target, runtime) {
|
|
355
557
|
const metadata = readPackageMetadata(runtime.runtimeRoot);
|
|
@@ -381,108 +583,156 @@ function marketplace(target, runtime) {
|
|
|
381
583
|
};
|
|
382
584
|
}
|
|
383
585
|
function writeJson(file, value) {
|
|
384
|
-
|
|
385
|
-
|
|
586
|
+
import_node_fs3.default.mkdirSync(import_node_path4.default.dirname(file), { recursive: true });
|
|
587
|
+
import_node_fs3.default.writeFileSync(file, `${JSON.stringify(value, null, 2)}
|
|
386
588
|
`);
|
|
387
589
|
}
|
|
388
590
|
function writeText(file, text) {
|
|
389
|
-
|
|
390
|
-
|
|
591
|
+
import_node_fs3.default.mkdirSync(import_node_path4.default.dirname(file), { recursive: true });
|
|
592
|
+
import_node_fs3.default.writeFileSync(file, text.endsWith("\n") ? text : `${text}
|
|
391
593
|
`);
|
|
392
594
|
}
|
|
393
|
-
function
|
|
394
|
-
|
|
395
|
-
writeText(
|
|
595
|
+
function writePluginRoot(target, pluginRoot, runtime, skillShim) {
|
|
596
|
+
import_node_fs3.default.rmSync(pluginRoot, { recursive: true, force: true });
|
|
597
|
+
writeText(import_node_path4.default.join(pluginRoot, "skills", "cadre", "SKILL.md"), skillShim);
|
|
396
598
|
if (target === "codex") {
|
|
397
|
-
writeJson(
|
|
398
|
-
writeJson(
|
|
599
|
+
writeJson(import_node_path4.default.join(pluginRoot, ".codex-plugin", "plugin.json"), pluginManifest(target, runtime));
|
|
600
|
+
writeJson(import_node_path4.default.join(pluginRoot, ".mcp.json"), mcpConfig(target, runtime));
|
|
601
|
+
} else if (target === "claude") {
|
|
602
|
+
writeJson(import_node_path4.default.join(pluginRoot, ".claude-plugin", "plugin.json"), pluginManifest(target, runtime));
|
|
603
|
+
writeJson(import_node_path4.default.join(pluginRoot, "mcp-config.json"), mcpConfig(target, runtime));
|
|
604
|
+
} else if (target === "copilot") {
|
|
605
|
+
writeJson(import_node_path4.default.join(pluginRoot, "plugin.json"), pluginManifest(target, runtime));
|
|
606
|
+
writeJson(import_node_path4.default.join(pluginRoot, ".mcp.json"), mcpConfig(target, runtime));
|
|
399
607
|
} else {
|
|
400
|
-
writeJson(
|
|
401
|
-
writeJson(
|
|
608
|
+
writeJson(import_node_path4.default.join(pluginRoot, "plugin.json"), pluginManifest(target, runtime));
|
|
609
|
+
writeJson(import_node_path4.default.join(pluginRoot, "mcp_config.json"), mcpConfig(target, runtime));
|
|
402
610
|
}
|
|
403
|
-
writeJson(paths.marketplaceFile, marketplace(target, runtime));
|
|
404
611
|
}
|
|
405
|
-
function
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
];
|
|
612
|
+
function writeTarget(target, paths, runtime, skillShim) {
|
|
613
|
+
for (const pluginRoot of paths.pluginRoots) writePluginRoot(target, pluginRoot, runtime, skillShim);
|
|
614
|
+
for (const skillRoot of paths.skillRoots) {
|
|
615
|
+
import_node_fs3.default.rmSync(skillRoot, { recursive: true, force: true });
|
|
616
|
+
writeText(import_node_path4.default.join(skillRoot, "SKILL.md"), skillShim);
|
|
411
617
|
}
|
|
618
|
+
if (paths.marketplaceFile && (target === "codex" || target === "claude")) {
|
|
619
|
+
writeJson(paths.marketplaceFile, marketplace(target, runtime));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
function removeTarget(paths) {
|
|
623
|
+
const roots = /* @__PURE__ */ new Set();
|
|
624
|
+
if (paths.marketplaceRoot) roots.add(paths.marketplaceRoot);
|
|
625
|
+
for (const pluginRoot of paths.pluginRoots) roots.add(pluginRoot);
|
|
626
|
+
for (const skillRoot of paths.skillRoots) roots.add(skillRoot);
|
|
627
|
+
const removed = [];
|
|
628
|
+
for (const root of roots) {
|
|
629
|
+
if (!import_node_fs3.default.existsSync(root)) continue;
|
|
630
|
+
import_node_fs3.default.rmSync(root, { recursive: true, force: true });
|
|
631
|
+
removed.push(root);
|
|
632
|
+
}
|
|
633
|
+
return removed;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// src/cli/install.ts
|
|
637
|
+
function usage() {
|
|
412
638
|
return [
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
]
|
|
639
|
+
"Cadre CLI",
|
|
640
|
+
"",
|
|
641
|
+
"Usage:",
|
|
642
|
+
" cadre install [--target codex|claude|copilot|antigravity|all] [--scope user|project|local] [--dry-run] [--check] [--force] [--yes]",
|
|
643
|
+
" cadre uninstall [--target codex|claude|copilot|antigravity|all] [--scope user|project|local] [--dry-run] [--yes]",
|
|
644
|
+
" cadre doctor",
|
|
645
|
+
" cadre help"
|
|
646
|
+
].join("\n");
|
|
417
647
|
}
|
|
418
|
-
function
|
|
419
|
-
|
|
420
|
-
|
|
648
|
+
function parseTarget(value) {
|
|
649
|
+
if (!value) throw new Error("--target requires a value");
|
|
650
|
+
if (value === "all") return value;
|
|
651
|
+
if (INSTALL_TARGETS.includes(value)) return value;
|
|
652
|
+
throw new Error("--target must be codex, claude, copilot, antigravity, or all");
|
|
421
653
|
}
|
|
422
|
-
function
|
|
423
|
-
|
|
424
|
-
|
|
654
|
+
function parseScope(value) {
|
|
655
|
+
if (value === "user" || value === "project" || value === "local") return value;
|
|
656
|
+
throw new Error("--scope must be user, project, or local");
|
|
425
657
|
}
|
|
426
|
-
function
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
658
|
+
function parseInstall(argv) {
|
|
659
|
+
const parsed = {
|
|
660
|
+
target: "auto",
|
|
661
|
+
scope: "user",
|
|
662
|
+
dryRun: false,
|
|
663
|
+
check: false,
|
|
664
|
+
force: false,
|
|
665
|
+
yes: false,
|
|
666
|
+
cadreHome: process.env.CADRE_HOME || import_node_path5.default.join(import_node_os3.default.homedir(), ".cadre")
|
|
433
667
|
};
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
if (
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
668
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
669
|
+
const arg = argv[index];
|
|
670
|
+
if (arg === "--dry-run") parsed.dryRun = true;
|
|
671
|
+
else if (arg === "--check") parsed.check = true;
|
|
672
|
+
else if (arg === "--force") parsed.force = true;
|
|
673
|
+
else if (arg === "--yes" || arg === "-y") parsed.yes = true;
|
|
674
|
+
else if (arg === "--target") {
|
|
675
|
+
parsed.target = parseTarget(argv[index + 1]);
|
|
676
|
+
index += 1;
|
|
677
|
+
} else if (arg === "--scope") {
|
|
678
|
+
parsed.scope = parseScope(argv[index + 1]);
|
|
679
|
+
index += 1;
|
|
680
|
+
} else if (arg === "--home") {
|
|
681
|
+
const value = argv[index + 1];
|
|
682
|
+
if (!value) throw new Error("--home requires a path");
|
|
683
|
+
parsed.cadreHome = import_node_path5.default.resolve(value);
|
|
684
|
+
index += 1;
|
|
685
|
+
} else {
|
|
686
|
+
throw new Error(`Unknown install option: ${arg}`);
|
|
687
|
+
}
|
|
452
688
|
}
|
|
689
|
+
return parsed;
|
|
453
690
|
}
|
|
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`);
|
|
691
|
+
function printApprovalResult(target, path6, configured) {
|
|
692
|
+
if (configured) {
|
|
693
|
+
process.stdout.write(`Cadre ${target} MCP tool approvals are configured in ${path6}
|
|
694
|
+
`);
|
|
695
|
+
} else {
|
|
696
|
+
process.stdout.write(`Cadre ${target} MCP tools may prompt on first use; no approval file was changed.
|
|
697
|
+
`);
|
|
469
698
|
}
|
|
470
|
-
return errors;
|
|
471
699
|
}
|
|
472
|
-
function
|
|
473
|
-
|
|
700
|
+
function installedNoun(paths) {
|
|
701
|
+
return paths.pluginRoots.length > 0 ? "plugin" : "skill";
|
|
702
|
+
}
|
|
703
|
+
function pathsExist(paths) {
|
|
704
|
+
return Boolean(
|
|
705
|
+
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))
|
|
706
|
+
);
|
|
707
|
+
}
|
|
708
|
+
function selectedUninstallTargets(options) {
|
|
709
|
+
if (options.target !== "auto" && options.target !== "all") return [options.target];
|
|
710
|
+
if (options.target === "all") return [...INSTALL_TARGETS];
|
|
711
|
+
return INSTALL_TARGETS.filter(
|
|
712
|
+
(target) => commandExists(target === "antigravity" ? "agy" : target) || pathsExist(targetPaths(options.cadreHome, target, options.scope))
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
function printUninstallPlan(target, paths, commands) {
|
|
716
|
+
if (paths.marketplaceRoot) process.stdout.write(`Would remove: ${paths.marketplaceRoot}
|
|
717
|
+
`);
|
|
718
|
+
for (const pluginRoot of paths.pluginRoots) process.stdout.write(`Would remove: ${pluginRoot}
|
|
474
719
|
`);
|
|
475
|
-
process.stdout.write(`
|
|
720
|
+
for (const skillRoot of paths.skillRoots) process.stdout.write(`Would remove: ${skillRoot}
|
|
476
721
|
`);
|
|
477
722
|
for (const command of commands) process.stdout.write(`Would run: ${command.command} ${command.args.join(" ")}
|
|
723
|
+
`);
|
|
724
|
+
if (!pathsExist(paths) && commands.length === 0) process.stdout.write(`No Cadre ${target} files or native uninstall commands found.
|
|
478
725
|
`);
|
|
479
726
|
}
|
|
727
|
+
function missingInstallCommandIsWarning(options, target, optional) {
|
|
728
|
+
return optional === true || options.target === "all" && target === "copilot";
|
|
729
|
+
}
|
|
480
730
|
function runInstall(argv, context) {
|
|
481
731
|
const options = parseInstall(argv);
|
|
482
732
|
const runtime = runtimePaths();
|
|
483
733
|
const targets = selectedTargets(options);
|
|
484
734
|
if (targets.length === 0) {
|
|
485
|
-
process.stderr.write("No supported client detected. Install Codex or
|
|
735
|
+
process.stderr.write("No supported client detected. Install Codex, Claude, Copilot, or Antigravity, or pass --target codex|claude|copilot|antigravity.\n");
|
|
486
736
|
return 1;
|
|
487
737
|
}
|
|
488
738
|
const ping = pingMcp(runtime);
|
|
@@ -493,7 +743,8 @@ function runInstall(argv, context) {
|
|
|
493
743
|
}
|
|
494
744
|
let ok = true;
|
|
495
745
|
for (const target of targets) {
|
|
496
|
-
|
|
746
|
+
let targetOk = true;
|
|
747
|
+
const paths = targetPaths(options.cadreHome, target, options.scope);
|
|
497
748
|
const commands = installCommands(target, paths, options.scope);
|
|
498
749
|
if (options.dryRun) {
|
|
499
750
|
printPlan(target, paths, commands);
|
|
@@ -501,7 +752,7 @@ function runInstall(argv, context) {
|
|
|
501
752
|
`);
|
|
502
753
|
continue;
|
|
503
754
|
}
|
|
504
|
-
if (!options.check)
|
|
755
|
+
if (!options.check) writeTarget(target, paths, runtime, context.skillShim);
|
|
505
756
|
const errors = checkTarget(target, paths, runtime);
|
|
506
757
|
if (!options.check) {
|
|
507
758
|
const approvals = bootstrapClientApprovals(target);
|
|
@@ -511,36 +762,82 @@ function runInstall(argv, context) {
|
|
|
511
762
|
if (!approvalCheck.ok) errors.push(`${target} approval check failed: ${approvalCheck.error || approvalCheck.path}`);
|
|
512
763
|
if (errors.length > 0) {
|
|
513
764
|
ok = false;
|
|
765
|
+
targetOk = false;
|
|
514
766
|
for (const error of errors) process.stderr.write(`${error}
|
|
515
767
|
`);
|
|
516
768
|
continue;
|
|
517
769
|
}
|
|
518
770
|
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.
|
|
771
|
+
process.stdout.write(`Cadre ${target} ${installedNoun(paths)} is installed and points at ${runtime.mcpServer}
|
|
528
772
|
`);
|
|
773
|
+
printApprovalResult(target, approvalCheck.path, approvalCheck.configured);
|
|
529
774
|
continue;
|
|
530
775
|
}
|
|
531
776
|
for (const command of commands) {
|
|
777
|
+
if (!commandExists(command.command)) {
|
|
778
|
+
const message = `${command.command} command not found; plugin files were written but native registration was skipped.
|
|
779
|
+
`;
|
|
780
|
+
if (missingInstallCommandIsWarning(options, target, command.optional)) process.stderr.write(message);
|
|
781
|
+
else {
|
|
782
|
+
targetOk = false;
|
|
783
|
+
ok = false;
|
|
784
|
+
process.stderr.write(message);
|
|
785
|
+
}
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
532
788
|
const result = runCommand(command);
|
|
533
789
|
if (!result.ok) {
|
|
790
|
+
targetOk = false;
|
|
534
791
|
ok = false;
|
|
535
792
|
process.stderr.write(`${command.command} ${command.args.join(" ")} failed: ${result.stderr}
|
|
536
793
|
`);
|
|
537
794
|
}
|
|
538
795
|
}
|
|
539
|
-
if (
|
|
796
|
+
if (targetOk) {
|
|
797
|
+
process.stdout.write(`Installed Cadre ${target} ${installedNoun(paths)} through ${paths.primaryRoot}
|
|
540
798
|
`);
|
|
799
|
+
printApprovalResult(target, approvalCheck.path, approvalCheck.configured);
|
|
800
|
+
}
|
|
541
801
|
}
|
|
542
802
|
return ok ? 0 : 1;
|
|
543
803
|
}
|
|
804
|
+
function runUninstall(argv) {
|
|
805
|
+
const options = parseInstall(argv);
|
|
806
|
+
const targets = selectedUninstallTargets(options);
|
|
807
|
+
if (targets.length === 0) {
|
|
808
|
+
process.stderr.write("No Cadre client install found. Pass --target codex|claude|copilot|antigravity to remove a specific generated target.\n");
|
|
809
|
+
return 1;
|
|
810
|
+
}
|
|
811
|
+
for (const target of targets) {
|
|
812
|
+
const paths = targetPaths(options.cadreHome, target, options.scope);
|
|
813
|
+
const commands = uninstallCommands(target, paths, options.scope);
|
|
814
|
+
if (options.dryRun) {
|
|
815
|
+
printUninstallPlan(target, paths, commands);
|
|
816
|
+
continue;
|
|
817
|
+
}
|
|
818
|
+
for (const command of commands) {
|
|
819
|
+
if (!commandExists(command.command)) {
|
|
820
|
+
process.stderr.write(`${command.command} command not found; removing generated Cadre ${target} files only.
|
|
821
|
+
`);
|
|
822
|
+
continue;
|
|
823
|
+
}
|
|
824
|
+
const result = runCommand(command);
|
|
825
|
+
if (!result.ok) {
|
|
826
|
+
process.stderr.write(`${command.command} ${command.args.join(" ")} failed; continuing local cleanup: ${result.stderr}
|
|
827
|
+
`);
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
const removed = removeTarget(paths);
|
|
831
|
+
if (removed.length > 0) {
|
|
832
|
+
process.stdout.write(`Uninstalled Cadre ${target} ${installedNoun(paths)} and removed ${removed.join(", ")}
|
|
833
|
+
`);
|
|
834
|
+
} else {
|
|
835
|
+
process.stdout.write(`No generated Cadre ${target} files found to remove.
|
|
836
|
+
`);
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
return 0;
|
|
840
|
+
}
|
|
544
841
|
function runDoctor() {
|
|
545
842
|
const runtime = runtimePaths();
|
|
546
843
|
const ping = pingMcp(runtime);
|
|
@@ -558,6 +855,7 @@ async function runCli(argv, context) {
|
|
|
558
855
|
const command = argv[0] || "help";
|
|
559
856
|
let code = 0;
|
|
560
857
|
if (command === "install") code = runInstall(argv.slice(1), context);
|
|
858
|
+
else if (command === "uninstall" || command === "remove") code = runUninstall(argv.slice(1));
|
|
561
859
|
else if (command === "doctor") code = runDoctor();
|
|
562
860
|
else if (command === "help" || command === "--help" || command === "-h") process.stdout.write(`${usage()}
|
|
563
861
|
`);
|