cadre-ai 2.1.0 → 3.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/.claude-plugin/plugin.json +10 -0
- package/.codex-plugin/plugin.json +19 -0
- package/.mcp.codex.json +9 -0
- package/.mcp.json +8 -0
- package/LICENSE +21 -202
- package/README.md +348 -107
- package/agents/cadre-phase-worker.md +17 -0
- package/agents/cadre-task-worker.md +16 -0
- package/dist/cadre-cli.mjs +2756 -0
- package/dist/cadre-mcp.mjs +33680 -0
- package/marketplace/claude.json +16 -0
- package/marketplace/codex.json +20 -0
- package/package.json +36 -34
- package/skills/archive/SKILL.md +28 -0
- package/skills/archive/agents/openai.yaml +4 -0
- package/skills/create/SKILL.md +33 -0
- package/skills/create/agents/openai.yaml +4 -0
- package/skills/implement/SKILL.md +91 -0
- package/skills/implement/agents/openai.yaml +4 -0
- package/skills/refresh/SKILL.md +18 -0
- package/skills/refresh/agents/openai.yaml +4 -0
- package/skills/revert/SKILL.md +20 -0
- package/skills/revert/agents/openai.yaml +4 -0
- package/skills/review/SKILL.md +32 -0
- package/skills/review/agents/openai.yaml +4 -0
- package/skills/revise/SKILL.md +32 -0
- package/skills/revise/agents/openai.yaml +4 -0
- package/skills/status/SKILL.md +21 -0
- package/skills/status/agents/openai.yaml +4 -0
- package/skills/track/SKILL.md +33 -0
- package/skills/track/agents/openai.yaml +4 -0
- package/skills/wisp/SKILL.md +16 -0
- package/skills/wisp/agents/openai.yaml +4 -0
- package/templates/v1/init/archive/.gitkeep +1 -0
- package/templates/v1/init/guidelines.md +25 -0
- package/templates/v1/init/operations/.gitkeep +1 -0
- package/templates/v1/init/patterns/index.md +6 -0
- package/templates/v1/init/product.md +30 -0
- package/templates/v1/init/project.json +26 -0
- package/templates/v1/init/refreshes/.gitkeep +1 -0
- package/templates/v1/init/styleguides/general.md +14 -0
- package/templates/v1/init/styleguides/language.md +21 -0
- package/templates/v1/init/tech-stack.md +21 -0
- package/templates/v1/init/tracks/.gitkeep +1 -0
- package/templates/v1/init/tracks.md +6 -0
- package/templates/v1/init/workflow.md +163 -0
- package/templates/v1/project/archive-operation.json +15 -0
- package/templates/v1/project/pattern.md +20 -0
- package/templates/v1/project/refresh-operation.json +14 -0
- package/templates/v1/project/refresh.md +21 -0
- package/templates/v1/styleguides/dart.md +27 -0
- package/templates/v1/styleguides/flutter.md +27 -0
- package/templates/v1/styleguides/go.md +29 -0
- package/templates/v1/styleguides/gradle.md +28 -0
- package/templates/v1/styleguides/html-css.md +39 -0
- package/templates/v1/styleguides/index.md +27 -0
- package/templates/v1/styleguides/java.md +27 -0
- package/templates/v1/styleguides/javascript.md +27 -0
- package/templates/v1/styleguides/kotlin.md +26 -0
- package/templates/v1/styleguides/maven.md +28 -0
- package/templates/v1/styleguides/python.md +27 -0
- package/templates/v1/styleguides/react.md +28 -0
- package/templates/v1/styleguides/swift.md +27 -0
- package/templates/v1/styleguides/swiftui.md +27 -0
- package/templates/v1/styleguides/typescript.md +26 -0
- package/templates/v1/track/bug.md +14 -0
- package/templates/v1/track/execution.json +18 -0
- package/templates/v1/track/learning.md +39 -0
- package/templates/v1/track/plan.md +39 -0
- package/templates/v1/track/revert-operation.json +13 -0
- package/templates/v1/track/revise-operation.json +14 -0
- package/templates/v1/track/revision.md +36 -0
- package/templates/v1/track/spec.md +38 -0
- package/templates/v1/track/state.json +25 -0
- package/scripts/cadre-cli.js +0 -869
- package/scripts/cadre-core.js +0 -14031
- package/scripts/cadre-job-runner.js +0 -3365
- package/scripts/cadre-lsp-daemon.js +0 -1212
- package/scripts/cadre-lsp-review.js +0 -1067
- package/scripts/cadre-lsp-setup.js +0 -470
- package/scripts/mcp/cadre-server.js +0 -16837
package/scripts/cadre-cli.js
DELETED
|
@@ -1,869 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// AUTO-GENERATED by pnpm build from src/*.ts -- do not edit by hand.
|
|
3
|
-
// Edit TypeScript sources under src/ instead.
|
|
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
|
-
"use strict";
|
|
6
|
-
var __create = Object.create;
|
|
7
|
-
var __defProp = Object.defineProperty;
|
|
8
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
|
|
29
|
-
// src/cli/install.ts
|
|
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"));
|
|
33
|
-
|
|
34
|
-
// src/cli/client-approvals.ts
|
|
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
|
|
40
|
-
var import_node_os = __toESM(require("node:os"));
|
|
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
|
|
146
|
-
var CADRE_MCP_TOOLS = [
|
|
147
|
-
"cadre_workflow",
|
|
148
|
-
"cadre_action",
|
|
149
|
-
"cadre_read"
|
|
150
|
-
];
|
|
151
|
-
var CLAUDE_CADRE_ALLOW_RULES = [
|
|
152
|
-
"mcp__plugin_cadre_cadre__*",
|
|
153
|
-
"mcp__cadre__*"
|
|
154
|
-
];
|
|
155
|
-
var ANTIGRAVITY_CADRE_ALLOW_RULES = [
|
|
156
|
-
"mcp(cadre/*)"
|
|
157
|
-
];
|
|
158
|
-
function approvalConfigPath(target) {
|
|
159
|
-
if (target === "codex") {
|
|
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");
|
|
164
|
-
}
|
|
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");
|
|
167
|
-
}
|
|
168
|
-
function bootstrapClientApprovals(target) {
|
|
169
|
-
if (target === "codex") return bootstrapCodexApprovals();
|
|
170
|
-
if (target === "claude") return bootstrapClaudeApprovals();
|
|
171
|
-
if (target === "antigravity") return bootstrapAntigravityApprovals();
|
|
172
|
-
return copilotPromptResult();
|
|
173
|
-
}
|
|
174
|
-
function checkClientApprovals(target) {
|
|
175
|
-
if (target === "codex") return checkCodexApprovals();
|
|
176
|
-
if (target === "claude") return checkClaudeApprovals();
|
|
177
|
-
if (target === "antigravity") return checkAntigravityApprovals();
|
|
178
|
-
return copilotPromptResult();
|
|
179
|
-
}
|
|
180
|
-
function approvalSummary(target) {
|
|
181
|
-
const file = approvalConfigPath(target);
|
|
182
|
-
if (target === "codex") return `Cadre codex 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";
|
|
186
|
-
}
|
|
187
|
-
function codexToolSection(tool) {
|
|
188
|
-
return `[plugins."cadre@cadre".mcp_servers.cadre.tools.${tool}]`;
|
|
189
|
-
}
|
|
190
|
-
function codexApprovalSnippet(tool) {
|
|
191
|
-
return `${codexToolSection(tool)}
|
|
192
|
-
approval_mode = "approve"
|
|
193
|
-
`;
|
|
194
|
-
}
|
|
195
|
-
function bootstrapCodexApprovals() {
|
|
196
|
-
const file = approvalConfigPath("codex");
|
|
197
|
-
let text = "";
|
|
198
|
-
if (import_node_fs.default.existsSync(file)) text = import_node_fs.default.readFileSync(file, "utf8");
|
|
199
|
-
const before = text;
|
|
200
|
-
for (const tool of CADRE_MCP_TOOLS) text = upsertCodexApproval(text, tool);
|
|
201
|
-
if (text !== before) {
|
|
202
|
-
import_node_fs.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
203
|
-
import_node_fs.default.writeFileSync(file, text);
|
|
204
|
-
}
|
|
205
|
-
return { ok: true, target: "codex", path: file, changed: text !== before, configured: true, rules: [...CADRE_MCP_TOOLS] };
|
|
206
|
-
}
|
|
207
|
-
function checkCodexApprovals() {
|
|
208
|
-
const file = approvalConfigPath("codex");
|
|
209
|
-
if (!import_node_fs.default.existsSync(file)) {
|
|
210
|
-
return { ok: false, target: "codex", path: file, changed: false, configured: false, rules: [...CADRE_MCP_TOOLS], error: `missing ${file}` };
|
|
211
|
-
}
|
|
212
|
-
const text = import_node_fs.default.readFileSync(file, "utf8");
|
|
213
|
-
const missing = CADRE_MCP_TOOLS.filter((tool) => !codexToolApproved(text, tool));
|
|
214
|
-
const result = {
|
|
215
|
-
ok: missing.length === 0,
|
|
216
|
-
target: "codex",
|
|
217
|
-
path: file,
|
|
218
|
-
changed: false,
|
|
219
|
-
configured: missing.length === 0,
|
|
220
|
-
rules: missing.length === 0 ? [...CADRE_MCP_TOOLS] : missing
|
|
221
|
-
};
|
|
222
|
-
if (missing.length > 0) result.error = `missing Codex Cadre tool approvals: ${missing.join(", ")}`;
|
|
223
|
-
return result;
|
|
224
|
-
}
|
|
225
|
-
function upsertCodexApproval(text, tool) {
|
|
226
|
-
let next = text.endsWith("\n") || text.length === 0 ? text : `${text}
|
|
227
|
-
`;
|
|
228
|
-
const header = codexToolSection(tool);
|
|
229
|
-
const lines = next.split("\n");
|
|
230
|
-
const start = lines.findIndex((line) => line.trim() === header);
|
|
231
|
-
if (start === -1) {
|
|
232
|
-
const spacer = next.trim().length > 0 && !next.endsWith("\n\n") ? "\n" : "";
|
|
233
|
-
return `${next}${spacer}${codexApprovalSnippet(tool)}`;
|
|
234
|
-
}
|
|
235
|
-
let end = lines.length;
|
|
236
|
-
for (let index = start + 1; index < lines.length; index += 1) {
|
|
237
|
-
if (lines[index]?.trim().startsWith("[")) {
|
|
238
|
-
end = index;
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
for (let index = start + 1; index < end; index += 1) {
|
|
243
|
-
if (/^\s*approval_mode\s*=/.test(lines[index] || "")) {
|
|
244
|
-
lines[index] = 'approval_mode = "approve"';
|
|
245
|
-
return lines.join("\n");
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
lines.splice(start + 1, 0, 'approval_mode = "approve"');
|
|
249
|
-
return lines.join("\n");
|
|
250
|
-
}
|
|
251
|
-
function codexToolApproved(text, tool) {
|
|
252
|
-
const lines = text.split(/\r?\n/);
|
|
253
|
-
const header = codexToolSection(tool);
|
|
254
|
-
const start = lines.findIndex((line) => line.trim() === header);
|
|
255
|
-
if (start === -1) return false;
|
|
256
|
-
for (let index = start + 1; index < lines.length; index += 1) {
|
|
257
|
-
const line = lines[index]?.trim() || "";
|
|
258
|
-
if (line.startsWith("[")) return false;
|
|
259
|
-
if (line === 'approval_mode = "approve"' || line === "approval_mode = 'approve'") return true;
|
|
260
|
-
}
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
263
|
-
function bootstrapClaudeApprovals() {
|
|
264
|
-
const file = approvalConfigPath("claude");
|
|
265
|
-
const parsed = readClaudeSettings(file);
|
|
266
|
-
if (!parsed.ok) return parsed.result;
|
|
267
|
-
const settings = parsed.settings;
|
|
268
|
-
const permissions = isRecord(settings.permissions) ? settings.permissions : {};
|
|
269
|
-
const currentAllow = Array.isArray(permissions.allow) ? permissions.allow.filter((item) => typeof item === "string") : [];
|
|
270
|
-
const nextAllow = [...currentAllow];
|
|
271
|
-
for (const rule of CLAUDE_CADRE_ALLOW_RULES) {
|
|
272
|
-
if (!nextAllow.includes(rule)) nextAllow.push(rule);
|
|
273
|
-
}
|
|
274
|
-
const changed = nextAllow.length !== currentAllow.length || !isRecord(settings.permissions) || !Array.isArray(permissions.allow);
|
|
275
|
-
if (changed) {
|
|
276
|
-
settings.permissions = { ...permissions, allow: nextAllow };
|
|
277
|
-
import_node_fs.default.mkdirSync(import_node_path2.default.dirname(file), { recursive: true });
|
|
278
|
-
import_node_fs.default.writeFileSync(file, `${JSON.stringify(settings, null, 2)}
|
|
279
|
-
`);
|
|
280
|
-
}
|
|
281
|
-
return { ok: true, target: "claude", path: file, changed, configured: true, rules: [...CLAUDE_CADRE_ALLOW_RULES] };
|
|
282
|
-
}
|
|
283
|
-
function checkClaudeApprovals() {
|
|
284
|
-
const file = approvalConfigPath("claude");
|
|
285
|
-
const parsed = readClaudeSettings(file);
|
|
286
|
-
if (!parsed.ok) return parsed.result;
|
|
287
|
-
const permissions = isRecord(parsed.settings.permissions) ? parsed.settings.permissions : {};
|
|
288
|
-
const allow = Array.isArray(permissions.allow) ? permissions.allow.filter((item) => typeof item === "string") : [];
|
|
289
|
-
const missing = CLAUDE_CADRE_ALLOW_RULES.filter((rule) => !allow.includes(rule));
|
|
290
|
-
const result = {
|
|
291
|
-
ok: missing.length === 0,
|
|
292
|
-
target: "claude",
|
|
293
|
-
path: file,
|
|
294
|
-
changed: false,
|
|
295
|
-
configured: missing.length === 0,
|
|
296
|
-
rules: missing.length === 0 ? [...CLAUDE_CADRE_ALLOW_RULES] : missing
|
|
297
|
-
};
|
|
298
|
-
if (missing.length > 0) result.error = `missing Claude Cadre tool allow rules: ${missing.join(", ")}`;
|
|
299
|
-
return result;
|
|
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
|
-
}
|
|
349
|
-
function readClaudeSettings(file) {
|
|
350
|
-
return readJsonSettings(file, "claude", CLAUDE_CADRE_ALLOW_RULES);
|
|
351
|
-
}
|
|
352
|
-
function readJsonSettings(file, target, rules) {
|
|
353
|
-
if (!import_node_fs.default.existsSync(file)) return { ok: true, settings: {} };
|
|
354
|
-
try {
|
|
355
|
-
const parsed = JSON.parse(import_node_fs.default.readFileSync(file, "utf8"));
|
|
356
|
-
if (isRecord(parsed)) return { ok: true, settings: parsed };
|
|
357
|
-
return {
|
|
358
|
-
ok: false,
|
|
359
|
-
result: { ok: false, target, path: file, changed: false, configured: false, rules: [...rules], error: `${file} must contain a JSON object` }
|
|
360
|
-
};
|
|
361
|
-
} catch (error) {
|
|
362
|
-
return {
|
|
363
|
-
ok: false,
|
|
364
|
-
result: {
|
|
365
|
-
ok: false,
|
|
366
|
-
target,
|
|
367
|
-
path: file,
|
|
368
|
-
changed: false,
|
|
369
|
-
configured: false,
|
|
370
|
-
rules: [...rules],
|
|
371
|
-
error: error instanceof Error ? error.message : String(error)
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
function isRecord(value) {
|
|
377
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
378
|
-
}
|
|
379
|
-
|
|
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 || "" };
|
|
387
|
-
}
|
|
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" } }
|
|
395
|
-
};
|
|
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) };
|
|
414
|
-
}
|
|
415
|
-
}
|
|
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}`);
|
|
418
|
-
}
|
|
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") };
|
|
430
|
-
}
|
|
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;
|
|
443
|
-
}
|
|
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
|
-
`);
|
|
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";
|
|
477
|
-
function readPackageMetadata(runtimeRoot) {
|
|
478
|
-
try {
|
|
479
|
-
const json = JSON.parse(import_node_fs3.default.readFileSync(import_node_path4.default.join(runtimeRoot, "package.json"), "utf8"));
|
|
480
|
-
return {
|
|
481
|
-
version: typeof json.version === "string" ? json.version : "0.0.0",
|
|
482
|
-
description: typeof json.description === "string" ? json.description : "MCP-first Cadre workflows.",
|
|
483
|
-
homepage: typeof json.homepage === "string" ? json.homepage : "https://cadre-docs.pages.dev/",
|
|
484
|
-
repository: typeof json.repository === "string" ? json.repository : "https://github.com/vishal-kr-barnwal/cadre",
|
|
485
|
-
license: typeof json.license === "string" ? json.license : "Apache-2.0"
|
|
486
|
-
};
|
|
487
|
-
} catch {
|
|
488
|
-
return {
|
|
489
|
-
version: "0.0.0",
|
|
490
|
-
description: "MCP-first Cadre workflows.",
|
|
491
|
-
homepage: "https://cadre-docs.pages.dev/",
|
|
492
|
-
repository: "https://github.com/vishal-kr-barnwal/cadre",
|
|
493
|
-
license: "Apache-2.0"
|
|
494
|
-
};
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
function baseManifest(runtime) {
|
|
498
|
-
const metadata = readPackageMetadata(runtime.runtimeRoot);
|
|
499
|
-
return {
|
|
500
|
-
name: PACKAGE_PLUGIN_NAME,
|
|
501
|
-
version: metadata.version,
|
|
502
|
-
description: metadata.description,
|
|
503
|
-
author: { name: "Vishal Kumar", url: "https://github.com/vishal-kr-barnwal" },
|
|
504
|
-
homepage: metadata.homepage,
|
|
505
|
-
repository: metadata.repository,
|
|
506
|
-
license: metadata.license,
|
|
507
|
-
keywords: ["cadre", "context-driven-development", "skills", "mcp"],
|
|
508
|
-
skills: "./skills/"
|
|
509
|
-
};
|
|
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
|
-
};
|
|
521
|
-
}
|
|
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"
|
|
532
|
-
};
|
|
533
|
-
return target === "copilot" ? { ...base, mcpServers } : { ...base, mcpServers, interface: codexInterface };
|
|
534
|
-
}
|
|
535
|
-
function mcpConfig(target, runtime) {
|
|
536
|
-
const server = {
|
|
537
|
-
command: runtime.nodePath,
|
|
538
|
-
args: [runtime.mcpServer],
|
|
539
|
-
cwd: runtime.runtimeRoot
|
|
540
|
-
};
|
|
541
|
-
if (target === "copilot") {
|
|
542
|
-
server.type = "local";
|
|
543
|
-
server.tools = ["*"];
|
|
544
|
-
}
|
|
545
|
-
return { mcpServers: { cadre: server } };
|
|
546
|
-
}
|
|
547
|
-
function marketplace(target, runtime) {
|
|
548
|
-
const metadata = readPackageMetadata(runtime.runtimeRoot);
|
|
549
|
-
if (target === "codex") {
|
|
550
|
-
return {
|
|
551
|
-
name: PACKAGE_PLUGIN_NAME,
|
|
552
|
-
interface: { displayName: PACKAGE_DISPLAY_NAME },
|
|
553
|
-
plugins: [{
|
|
554
|
-
name: PACKAGE_PLUGIN_NAME,
|
|
555
|
-
source: { source: "local", path: MARKETPLACE_PLUGIN_SOURCE },
|
|
556
|
-
policy: { installation: "AVAILABLE", authentication: "ON_INSTALL" },
|
|
557
|
-
category: "Productivity"
|
|
558
|
-
}]
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
return {
|
|
562
|
-
name: PACKAGE_PLUGIN_NAME,
|
|
563
|
-
owner: { name: "Vishal Kumar" },
|
|
564
|
-
description: "Cadre MCP-first workflows for Claude Code.",
|
|
565
|
-
plugins: [{
|
|
566
|
-
name: PACKAGE_PLUGIN_NAME,
|
|
567
|
-
source: MARKETPLACE_PLUGIN_SOURCE,
|
|
568
|
-
description: metadata.description,
|
|
569
|
-
version: metadata.version,
|
|
570
|
-
author: { name: "Vishal Kumar" },
|
|
571
|
-
category: "productivity",
|
|
572
|
-
tags: ["cadre", "skills", "mcp", "context-driven-development"]
|
|
573
|
-
}]
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
function writeJson(file, value) {
|
|
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)}
|
|
579
|
-
`);
|
|
580
|
-
}
|
|
581
|
-
function writeText(file, text) {
|
|
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}
|
|
584
|
-
`);
|
|
585
|
-
}
|
|
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);
|
|
589
|
-
if (target === "codex") {
|
|
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));
|
|
598
|
-
} else {
|
|
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));
|
|
601
|
-
}
|
|
602
|
-
}
|
|
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);
|
|
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() {
|
|
629
|
-
return [
|
|
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");
|
|
638
|
-
}
|
|
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");
|
|
644
|
-
}
|
|
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");
|
|
648
|
-
}
|
|
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")
|
|
658
|
-
};
|
|
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
|
-
}
|
|
679
|
-
}
|
|
680
|
-
return parsed;
|
|
681
|
-
}
|
|
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
|
-
`);
|
|
689
|
-
}
|
|
690
|
-
}
|
|
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}
|
|
710
|
-
`);
|
|
711
|
-
for (const skillRoot of paths.skillRoots) process.stdout.write(`Would remove: ${skillRoot}
|
|
712
|
-
`);
|
|
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.
|
|
716
|
-
`);
|
|
717
|
-
}
|
|
718
|
-
function missingInstallCommandIsWarning(options, target, optional) {
|
|
719
|
-
return optional === true || options.target === "all" && target === "copilot";
|
|
720
|
-
}
|
|
721
|
-
function runInstall(argv, context) {
|
|
722
|
-
const options = parseInstall(argv);
|
|
723
|
-
const runtime = runtimePaths();
|
|
724
|
-
const targets = selectedTargets(options);
|
|
725
|
-
if (targets.length === 0) {
|
|
726
|
-
process.stderr.write("No supported client detected. Install Codex, Claude, Copilot, or Antigravity, or pass --target codex|claude|copilot|antigravity.\n");
|
|
727
|
-
return 1;
|
|
728
|
-
}
|
|
729
|
-
const ping = pingMcp(runtime);
|
|
730
|
-
if (!ping.ok) {
|
|
731
|
-
process.stderr.write(`Cadre MCP check failed: ${ping.reason}
|
|
732
|
-
`);
|
|
733
|
-
return 1;
|
|
734
|
-
}
|
|
735
|
-
let ok = true;
|
|
736
|
-
for (const target of targets) {
|
|
737
|
-
let targetOk = true;
|
|
738
|
-
const paths = targetPaths(options.cadreHome, target, options.scope);
|
|
739
|
-
const commands = installCommands(target, paths, options.scope);
|
|
740
|
-
if (options.dryRun) {
|
|
741
|
-
printPlan(target, paths, commands);
|
|
742
|
-
process.stdout.write(`Would configure: ${approvalSummary(target)}
|
|
743
|
-
`);
|
|
744
|
-
continue;
|
|
745
|
-
}
|
|
746
|
-
if (!options.check) writeTarget(target, paths, runtime, context.skillShim);
|
|
747
|
-
const errors = checkTarget(target, paths, runtime);
|
|
748
|
-
if (!options.check) {
|
|
749
|
-
const approvals = bootstrapClientApprovals(target);
|
|
750
|
-
if (!approvals.ok) errors.push(`${target} approval bootstrap failed: ${approvals.error || approvals.path}`);
|
|
751
|
-
}
|
|
752
|
-
const approvalCheck = checkClientApprovals(target);
|
|
753
|
-
if (!approvalCheck.ok) errors.push(`${target} approval check failed: ${approvalCheck.error || approvalCheck.path}`);
|
|
754
|
-
if (errors.length > 0) {
|
|
755
|
-
ok = false;
|
|
756
|
-
targetOk = false;
|
|
757
|
-
for (const error of errors) process.stderr.write(`${error}
|
|
758
|
-
`);
|
|
759
|
-
continue;
|
|
760
|
-
}
|
|
761
|
-
if (options.check) {
|
|
762
|
-
process.stdout.write(`Cadre ${target} ${installedNoun(paths)} is installed and points at ${runtime.mcpServer}
|
|
763
|
-
`);
|
|
764
|
-
printApprovalResult(target, approvalCheck.path, approvalCheck.configured);
|
|
765
|
-
continue;
|
|
766
|
-
}
|
|
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
|
-
}
|
|
779
|
-
const result = runCommand(command);
|
|
780
|
-
if (!result.ok) {
|
|
781
|
-
targetOk = false;
|
|
782
|
-
ok = false;
|
|
783
|
-
process.stderr.write(`${command.command} ${command.args.join(" ")} failed: ${result.stderr}
|
|
784
|
-
`);
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
if (targetOk) {
|
|
788
|
-
process.stdout.write(`Installed Cadre ${target} ${installedNoun(paths)} through ${paths.primaryRoot}
|
|
789
|
-
`);
|
|
790
|
-
printApprovalResult(target, approvalCheck.path, approvalCheck.configured);
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
return ok ? 0 : 1;
|
|
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
|
-
}
|
|
832
|
-
function runDoctor() {
|
|
833
|
-
const runtime = runtimePaths();
|
|
834
|
-
const ping = pingMcp(runtime);
|
|
835
|
-
const checks = [
|
|
836
|
-
`package root: ${runtime.runtimeRoot}`,
|
|
837
|
-
`node: ${runtime.nodePath}`,
|
|
838
|
-
`cadre-mcp: ${runtime.mcpServer}`,
|
|
839
|
-
`mcp ping: ${ping.ok ? "ok" : `failed (${ping.reason})`}`
|
|
840
|
-
];
|
|
841
|
-
process.stdout.write(`${checks.join("\n")}
|
|
842
|
-
`);
|
|
843
|
-
return ping.ok ? 0 : 1;
|
|
844
|
-
}
|
|
845
|
-
async function runCli(argv, context) {
|
|
846
|
-
const command = argv[0] || "help";
|
|
847
|
-
let code = 0;
|
|
848
|
-
if (command === "install") code = runInstall(argv.slice(1), context);
|
|
849
|
-
else if (command === "uninstall" || command === "remove") code = runUninstall(argv.slice(1));
|
|
850
|
-
else if (command === "doctor") code = runDoctor();
|
|
851
|
-
else if (command === "help" || command === "--help" || command === "-h") process.stdout.write(`${usage()}
|
|
852
|
-
`);
|
|
853
|
-
else {
|
|
854
|
-
process.stderr.write(`${usage()}
|
|
855
|
-
`);
|
|
856
|
-
code = 1;
|
|
857
|
-
}
|
|
858
|
-
if (code !== 0) process.exit(code);
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
// src/cli.ts
|
|
862
|
-
runCli(process.argv.slice(2), {
|
|
863
|
-
skillShim: typeof __CADRE_SKILL_SHIM__ === "string" ? __CADRE_SKILL_SHIM__ : ""
|
|
864
|
-
}).catch((error) => {
|
|
865
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
866
|
-
process.stderr.write(`${message}
|
|
867
|
-
`);
|
|
868
|
-
process.exit(1);
|
|
869
|
-
});
|