cadre-ai 3.3.0 → 3.5.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 +2 -2
- package/.codex-plugin/plugin.json +2 -2
- package/CHANGELOG.md +83 -2
- package/README.md +52 -31
- package/dist/cadre-cli.mjs +395 -92
- package/dist/cadre-mcp.mjs +1191 -717
- package/package.json +3 -2
- package/skills/archive/SKILL.md +6 -6
- package/skills/create/SKILL.md +5 -4
- package/skills/implement/SKILL.md +34 -83
- package/skills/implement/references/conflict-handling.md +5 -0
- package/skills/implement/references/governed-mode.md +7 -0
- package/skills/implement/references/parallel-workers.md +9 -0
- package/skills/implement/references/resume-recovery.md +10 -0
- package/skills/refresh/SKILL.md +4 -4
- package/skills/revert/SKILL.md +6 -6
- package/skills/review/SKILL.md +7 -7
- package/skills/revise/SKILL.md +6 -6
- package/skills/status/SKILL.md +1 -1
- package/skills/track/SKILL.md +5 -5
- package/templates/v2/init/archive/.gitkeep +1 -0
- package/templates/v2/init/gitignore.template +8 -0
- package/templates/v2/init/guidelines.md +25 -0
- package/templates/v2/init/operations/.gitkeep +1 -0
- package/templates/v2/init/patterns/index.md +6 -0
- package/templates/v2/init/product.md +30 -0
- package/templates/v2/init/project.json +27 -0
- package/templates/v2/init/refreshes/.gitkeep +1 -0
- package/templates/v2/init/styleguides/general.md +14 -0
- package/templates/v2/init/styleguides/language.md +21 -0
- package/templates/v2/init/tech-stack.md +21 -0
- package/templates/v2/init/tracks/.gitkeep +1 -0
- package/templates/v2/init/tracks.md +6 -0
- package/templates/v2/init/wisps/.gitkeep +1 -0
- package/templates/v2/init/workflow.md +72 -0
- package/templates/v2/project/archive-operation.json +19 -0
- package/templates/v2/project/pattern.md +20 -0
- package/templates/v2/project/refresh-operation.json +18 -0
- package/templates/v2/project/refresh.md +21 -0
- package/templates/v2/styleguides/dart.md +27 -0
- package/templates/v2/styleguides/flutter.md +27 -0
- package/templates/v2/styleguides/go.md +29 -0
- package/templates/v2/styleguides/gradle.md +28 -0
- package/templates/v2/styleguides/html-css.md +39 -0
- package/templates/v2/styleguides/index.md +27 -0
- package/templates/v2/styleguides/java.md +27 -0
- package/templates/v2/styleguides/javascript.md +27 -0
- package/templates/v2/styleguides/kotlin.md +26 -0
- package/templates/v2/styleguides/maven.md +28 -0
- package/templates/v2/styleguides/python.md +27 -0
- package/templates/v2/styleguides/react.md +28 -0
- package/templates/v2/styleguides/swift.md +27 -0
- package/templates/v2/styleguides/swiftui.md +27 -0
- package/templates/v2/styleguides/typescript.md +26 -0
- package/templates/v2/track/bug.md +14 -0
- package/templates/v2/track/execution.json +19 -0
- package/templates/v2/track/learning.md +39 -0
- package/templates/v2/track/plan.md +39 -0
- package/templates/v2/track/revert-operation.json +17 -0
- package/templates/v2/track/revise-operation.json +18 -0
- package/templates/v2/track/revision.md +36 -0
- package/templates/v2/track/spec.md +38 -0
- package/templates/v2/track/state.json +31 -0
package/dist/cadre-cli.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// scripts/cli.ts
|
|
4
|
-
import { existsSync as
|
|
5
|
-
import { dirname as
|
|
4
|
+
import { existsSync as existsSync7, readFileSync as readFileSync7 } from "node:fs";
|
|
5
|
+
import { dirname as dirname7, join as join7, resolve as resolve7 } from "node:path";
|
|
6
6
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7
7
|
|
|
8
8
|
// scripts/install.ts
|
|
9
|
-
import { existsSync as
|
|
10
|
-
import { homedir as
|
|
11
|
-
import { basename as basename2, dirname as
|
|
9
|
+
import { existsSync as existsSync5, mkdtempSync, mkdirSync as mkdirSync4, readFileSync as readFileSync5, renameSync as renameSync2 } from "node:fs";
|
|
10
|
+
import { homedir as homedir3 } from "node:os";
|
|
11
|
+
import { basename as basename2, dirname as dirname5, join as join5, parse as parse4, resolve as resolve5 } from "node:path";
|
|
12
12
|
|
|
13
13
|
// scripts/cli-options.ts
|
|
14
14
|
import { homedir } from "node:os";
|
|
@@ -16,7 +16,7 @@ import { join, resolve } from "node:path";
|
|
|
16
16
|
|
|
17
17
|
// scripts/native-clients.ts
|
|
18
18
|
import { spawnSync } from "node:child_process";
|
|
19
|
-
var CLIENTS = ["codex", "claude"];
|
|
19
|
+
var CLIENTS = ["codex", "claude", "zed"];
|
|
20
20
|
function commandExists(command) {
|
|
21
21
|
const lookup = process.platform === "win32" ? "where" : "which";
|
|
22
22
|
return spawnSync(lookup, [command], { stdio: "ignore" }).status === 0;
|
|
@@ -47,7 +47,7 @@ function runJson(command, args) {
|
|
|
47
47
|
// scripts/cli-options.ts
|
|
48
48
|
function parseClient(value) {
|
|
49
49
|
if (value === "all" || value === "auto" || CLIENTS.includes(value)) return value;
|
|
50
|
-
throw new Error("--target/--agent must be auto, all, codex, or
|
|
50
|
+
throw new Error("--target/--agent must be auto, all, codex, claude, or zed");
|
|
51
51
|
}
|
|
52
52
|
function defaultMarketplaceRoot() {
|
|
53
53
|
const cadreHome = process.env.CADRE_HOME ? resolve(process.env.CADRE_HOME) : join(homedir(), ".cadre");
|
|
@@ -63,8 +63,8 @@ function marketplaceFromHome(home) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// scripts/package-plugin.ts
|
|
66
|
-
import { cpSync, existsSync as
|
|
67
|
-
import { dirname as
|
|
66
|
+
import { cpSync as cpSync2, existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
|
|
67
|
+
import { dirname as dirname3, join as join4, resolve as resolve4 } from "node:path";
|
|
68
68
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
69
69
|
|
|
70
70
|
// src/domain/templates.ts
|
|
@@ -74,8 +74,8 @@ import { dirname, extname, join as join2, relative, resolve as resolve2, sep } f
|
|
|
74
74
|
import { fileURLToPath } from "node:url";
|
|
75
75
|
|
|
76
76
|
// src/domain/version.ts
|
|
77
|
-
var CADRE_RUNTIME_VERSION = "3.
|
|
78
|
-
var TEMPLATE_SET_VERSION = "
|
|
77
|
+
var CADRE_RUNTIME_VERSION = "3.5.0";
|
|
78
|
+
var TEMPLATE_SET_VERSION = "v2";
|
|
79
79
|
|
|
80
80
|
// src/domain/templates.ts
|
|
81
81
|
var TEMPLATE_IDS = [
|
|
@@ -185,8 +185,127 @@ function templateCatalog() {
|
|
|
185
185
|
return catalogCache.map((template) => ({ ...template }));
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
// scripts/zed.ts
|
|
189
|
+
import {
|
|
190
|
+
cpSync,
|
|
191
|
+
existsSync as existsSync2,
|
|
192
|
+
lstatSync,
|
|
193
|
+
mkdirSync,
|
|
194
|
+
readFileSync as readFileSync2,
|
|
195
|
+
readlinkSync,
|
|
196
|
+
symlinkSync,
|
|
197
|
+
unlinkSync,
|
|
198
|
+
writeFileSync
|
|
199
|
+
} from "node:fs";
|
|
200
|
+
import { homedir as homedir2 } from "node:os";
|
|
201
|
+
import { dirname as dirname2, join as join3, resolve as resolve3 } from "node:path";
|
|
202
|
+
var CADRE_WORKFLOWS = [
|
|
203
|
+
"create",
|
|
204
|
+
"track",
|
|
205
|
+
"implement",
|
|
206
|
+
"review",
|
|
207
|
+
"revise",
|
|
208
|
+
"archive",
|
|
209
|
+
"refresh",
|
|
210
|
+
"revert",
|
|
211
|
+
"status",
|
|
212
|
+
"wisp"
|
|
213
|
+
];
|
|
214
|
+
var ZED_COMPATIBILITY = `## Zed compatibility
|
|
215
|
+
|
|
216
|
+
Zed Agent consumes Cadre templates through tools rather than MCP resource discovery. Whenever this workflow calls \`template_get_many\`, include \`contentMode: "text"\`. Use known template IDs and descriptor tools such as \`styleguide_resolve\`; do not attempt to list or read MCP resources directly.`;
|
|
217
|
+
function pathExists(path) {
|
|
218
|
+
try {
|
|
219
|
+
lstatSync(path);
|
|
220
|
+
return true;
|
|
221
|
+
} catch {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function zedSettingsPath() {
|
|
226
|
+
return join3(homedir2(), ".config", "zed", "settings.json");
|
|
227
|
+
}
|
|
228
|
+
function zedSkillsRoot() {
|
|
229
|
+
return join3(homedir2(), ".agents", "skills");
|
|
230
|
+
}
|
|
231
|
+
function zedAdapterRoot(marketplaceRoot) {
|
|
232
|
+
return join3(resolve3(marketplaceRoot), "plugins", "cadre", "zed-skills");
|
|
233
|
+
}
|
|
234
|
+
function createZedSkillAdapters(pluginRoot) {
|
|
235
|
+
const adapterRoot = join3(pluginRoot, "zed-skills");
|
|
236
|
+
if (existsSync2(adapterRoot)) throw new Error(`Zed skill adapter output already exists: ${adapterRoot}`);
|
|
237
|
+
mkdirSync(adapterRoot, { recursive: true });
|
|
238
|
+
for (const workflow of CADRE_WORKFLOWS) {
|
|
239
|
+
const source = join3(pluginRoot, "skills", workflow);
|
|
240
|
+
const target = join3(adapterRoot, `cadre-${workflow}`);
|
|
241
|
+
cpSync(source, target, { recursive: true });
|
|
242
|
+
const skillPath = join3(target, "SKILL.md");
|
|
243
|
+
const body = readFileSync2(skillPath, "utf8");
|
|
244
|
+
const expectedName = `name: ${workflow}`;
|
|
245
|
+
const namePattern = new RegExp(`^${expectedName}$`, "m");
|
|
246
|
+
if (!namePattern.test(body)) throw new Error(`${skillPath}: expected ${expectedName}`);
|
|
247
|
+
const renamed = body.replace(namePattern, `name: cadre-${workflow}`);
|
|
248
|
+
const frontmatterEnd = renamed.indexOf("\n---\n", 4);
|
|
249
|
+
if (frontmatterEnd === -1) throw new Error(`${skillPath}: invalid skill frontmatter`);
|
|
250
|
+
const insertionPoint = frontmatterEnd + "\n---\n".length;
|
|
251
|
+
const adapted = `${renamed.slice(0, insertionPoint)}
|
|
252
|
+
${ZED_COMPATIBILITY}
|
|
253
|
+
${renamed.slice(insertionPoint)}`;
|
|
254
|
+
writeFileSync(skillPath, adapted);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function expectedSkillLink(marketplaceRoot, workflow) {
|
|
258
|
+
return {
|
|
259
|
+
destination: join3(zedSkillsRoot(), `cadre-${workflow}`),
|
|
260
|
+
target: join3(zedAdapterRoot(marketplaceRoot), `cadre-${workflow}`)
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function linkTarget(path) {
|
|
264
|
+
if (!pathExists(path) || !lstatSync(path).isSymbolicLink()) return null;
|
|
265
|
+
return resolve3(dirname2(path), readlinkSync(path));
|
|
266
|
+
}
|
|
267
|
+
function preflightZedSkillLinks(marketplaceRoot) {
|
|
268
|
+
for (const workflow of CADRE_WORKFLOWS) {
|
|
269
|
+
const link = expectedSkillLink(marketplaceRoot, workflow);
|
|
270
|
+
if (!pathExists(link.destination)) continue;
|
|
271
|
+
if (linkTarget(link.destination) !== link.target) {
|
|
272
|
+
throw new Error(
|
|
273
|
+
`${link.destination} already exists and is not owned by Cadre; move it before installing Zed support`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function installZedSkillLinks(marketplaceRoot) {
|
|
279
|
+
preflightZedSkillLinks(marketplaceRoot);
|
|
280
|
+
mkdirSync(zedSkillsRoot(), { recursive: true });
|
|
281
|
+
const installed = [];
|
|
282
|
+
for (const workflow of CADRE_WORKFLOWS) {
|
|
283
|
+
const link = expectedSkillLink(marketplaceRoot, workflow);
|
|
284
|
+
if (!pathExists(link.destination)) {
|
|
285
|
+
symlinkSync(link.target, link.destination, process.platform === "win32" ? "junction" : "dir");
|
|
286
|
+
}
|
|
287
|
+
installed.push(link.destination);
|
|
288
|
+
}
|
|
289
|
+
return installed;
|
|
290
|
+
}
|
|
291
|
+
function removeZedSkillLinks(marketplaceRoot) {
|
|
292
|
+
const removed = [];
|
|
293
|
+
const retained = [];
|
|
294
|
+
for (const workflow of CADRE_WORKFLOWS) {
|
|
295
|
+
const link = expectedSkillLink(marketplaceRoot, workflow);
|
|
296
|
+
if (!pathExists(link.destination)) continue;
|
|
297
|
+
if (linkTarget(link.destination) === link.target) {
|
|
298
|
+
unlinkSync(link.destination);
|
|
299
|
+
removed.push(link.destination);
|
|
300
|
+
} else {
|
|
301
|
+
retained.push(link.destination);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return { removed, retained };
|
|
305
|
+
}
|
|
306
|
+
|
|
188
307
|
// scripts/package-plugin.ts
|
|
189
|
-
var sourceRoot =
|
|
308
|
+
var sourceRoot = resolve4(dirname3(fileURLToPath2(import.meta.url)), "..");
|
|
190
309
|
var requiredEntries = [
|
|
191
310
|
"skills",
|
|
192
311
|
"templates",
|
|
@@ -198,11 +317,11 @@ var requiredEntries = [
|
|
|
198
317
|
];
|
|
199
318
|
var optionalEntries = ["hooks", "hooks.json", ".app.json", "assets", "commands", "agents"];
|
|
200
319
|
function readJson(path) {
|
|
201
|
-
return JSON.parse(
|
|
320
|
+
return JSON.parse(readFileSync3(path, "utf8"));
|
|
202
321
|
}
|
|
203
322
|
function writeJson(path, value) {
|
|
204
|
-
|
|
205
|
-
|
|
323
|
+
mkdirSync2(dirname3(path), { recursive: true });
|
|
324
|
+
writeFileSync2(path, `${JSON.stringify(value, null, 2)}
|
|
206
325
|
`);
|
|
207
326
|
}
|
|
208
327
|
function withCachebuster(version, product, cachebuster) {
|
|
@@ -214,36 +333,37 @@ function defaultCachebuster() {
|
|
|
214
333
|
}
|
|
215
334
|
function packagePluginMarketplace(outputRoot, requestedCachebuster = defaultCachebuster()) {
|
|
216
335
|
templateCatalog();
|
|
217
|
-
const targetRoot =
|
|
336
|
+
const targetRoot = resolve4(outputRoot);
|
|
218
337
|
const cachebuster = requestedCachebuster.trim();
|
|
219
338
|
if (!/^[0-9A-Za-z-]+$/.test(cachebuster)) {
|
|
220
339
|
throw new Error("cachebuster must contain only letters, digits, and hyphens");
|
|
221
340
|
}
|
|
222
|
-
const pluginRoot =
|
|
223
|
-
if (
|
|
224
|
-
|
|
341
|
+
const pluginRoot = join4(targetRoot, "plugins", "cadre");
|
|
342
|
+
if (existsSync3(pluginRoot)) throw new Error(`plugin output already exists: ${pluginRoot}`);
|
|
343
|
+
mkdirSync2(pluginRoot, { recursive: true });
|
|
225
344
|
for (const entry of requiredEntries) {
|
|
226
|
-
const source =
|
|
227
|
-
if (!
|
|
228
|
-
|
|
345
|
+
const source = join4(sourceRoot, entry);
|
|
346
|
+
if (!existsSync3(source)) throw new Error(`required plugin entry is missing: ${entry}`);
|
|
347
|
+
cpSync2(source, join4(pluginRoot, entry), { recursive: true });
|
|
229
348
|
}
|
|
230
349
|
for (const entry of optionalEntries) {
|
|
231
|
-
const source =
|
|
232
|
-
if (
|
|
350
|
+
const source = join4(sourceRoot, entry);
|
|
351
|
+
if (existsSync3(source)) cpSync2(source, join4(pluginRoot, entry), { recursive: true });
|
|
233
352
|
}
|
|
234
|
-
|
|
353
|
+
createZedSkillAdapters(pluginRoot);
|
|
354
|
+
const codexManifest = readJson(join4(sourceRoot, ".codex-plugin", "plugin.json"));
|
|
235
355
|
codexManifest.version = withCachebuster(codexManifest.version, "codex", cachebuster);
|
|
236
|
-
writeJson(
|
|
237
|
-
const claudeManifest = readJson(
|
|
356
|
+
writeJson(join4(pluginRoot, ".codex-plugin", "plugin.json"), codexManifest);
|
|
357
|
+
const claudeManifest = readJson(join4(sourceRoot, ".claude-plugin", "plugin.json"));
|
|
238
358
|
claudeManifest.version = withCachebuster(claudeManifest.version, "claude", cachebuster);
|
|
239
|
-
writeJson(
|
|
359
|
+
writeJson(join4(pluginRoot, ".claude-plugin", "plugin.json"), claudeManifest);
|
|
240
360
|
writeJson(
|
|
241
|
-
|
|
242
|
-
readJson(
|
|
361
|
+
join4(targetRoot, ".agents", "plugins", "marketplace.json"),
|
|
362
|
+
readJson(join4(sourceRoot, "marketplace", "codex.json"))
|
|
243
363
|
);
|
|
244
364
|
writeJson(
|
|
245
|
-
|
|
246
|
-
readJson(
|
|
365
|
+
join4(targetRoot, ".claude-plugin", "marketplace.json"),
|
|
366
|
+
readJson(join4(sourceRoot, "marketplace", "claude.json"))
|
|
247
367
|
);
|
|
248
368
|
return { targetRoot, pluginRoot, cachebuster };
|
|
249
369
|
}
|
|
@@ -1660,17 +1780,17 @@ function applyEdits(text, edits) {
|
|
|
1660
1780
|
// scripts/permissions.ts
|
|
1661
1781
|
import {
|
|
1662
1782
|
chmodSync,
|
|
1663
|
-
existsSync as
|
|
1664
|
-
lstatSync,
|
|
1665
|
-
mkdirSync as
|
|
1783
|
+
existsSync as existsSync4,
|
|
1784
|
+
lstatSync as lstatSync2,
|
|
1785
|
+
mkdirSync as mkdirSync3,
|
|
1666
1786
|
realpathSync,
|
|
1667
1787
|
renameSync,
|
|
1668
1788
|
statSync,
|
|
1669
|
-
unlinkSync,
|
|
1670
|
-
writeFileSync as
|
|
1671
|
-
readFileSync as
|
|
1789
|
+
unlinkSync as unlinkSync2,
|
|
1790
|
+
writeFileSync as writeFileSync3,
|
|
1791
|
+
readFileSync as readFileSync4
|
|
1672
1792
|
} from "node:fs";
|
|
1673
|
-
import { basename, dirname as
|
|
1793
|
+
import { basename, dirname as dirname4 } from "node:path";
|
|
1674
1794
|
|
|
1675
1795
|
// ../node_modules/.pnpm/smol-toml@1.7.1/node_modules/smol-toml/dist/date.js
|
|
1676
1796
|
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
@@ -2354,25 +2474,53 @@ function parse3(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
2354
2474
|
return res;
|
|
2355
2475
|
}
|
|
2356
2476
|
|
|
2477
|
+
// src/mcp/tool-names.ts
|
|
2478
|
+
var CADRE_MCP_TOOLS = {
|
|
2479
|
+
workflowElicit: "workflow_elicit",
|
|
2480
|
+
templateGetMany: "template_get_many",
|
|
2481
|
+
styleguideResolve: "styleguide_resolve",
|
|
2482
|
+
projectStatus: "project_status",
|
|
2483
|
+
stateValidate: "state_validate",
|
|
2484
|
+
candidateStagePrepare: "candidate_stage_prepare",
|
|
2485
|
+
candidateInspect: "candidate_inspect",
|
|
2486
|
+
executionGraphValidate: "execution_graph_validate",
|
|
2487
|
+
reviewComplete: "review_complete",
|
|
2488
|
+
archiveBatchCandidate: "archive_batch_candidate",
|
|
2489
|
+
archiveBatchRecord: "archive_batch_record",
|
|
2490
|
+
executionStart: "execution_start",
|
|
2491
|
+
executionCheckpoint: "execution_checkpoint",
|
|
2492
|
+
executionStatus: "execution_status",
|
|
2493
|
+
executionFinish: "execution_finish",
|
|
2494
|
+
worktreeCreate: "worktree_create",
|
|
2495
|
+
integration: "integration",
|
|
2496
|
+
worktreeCleanup: "worktree_cleanup",
|
|
2497
|
+
projectInitCandidate: "project_init_candidate",
|
|
2498
|
+
setupRecordCommit: "setup_record_commit",
|
|
2499
|
+
setupRecordGitInitialized: "setup_record_git_initialized",
|
|
2500
|
+
tracksRender: "tracks_render"
|
|
2501
|
+
};
|
|
2502
|
+
var CADRE_MCP_TOOL_NAMES = Object.freeze(Object.values(CADRE_MCP_TOOLS));
|
|
2503
|
+
|
|
2357
2504
|
// scripts/permissions.ts
|
|
2358
2505
|
var CODEX_SECTION = '[plugins."cadre@cadre".mcp_servers.cadre]';
|
|
2359
2506
|
var CODEX_APPROVAL = 'default_tools_approval_mode = "approve"';
|
|
2360
2507
|
var CLAUDE_APPROVAL = "mcp__cadre__*";
|
|
2361
2508
|
var CLAUDE_SERVER_APPROVAL = "cadre";
|
|
2509
|
+
var ZED_MCP_PERMISSION_KEYS = CADRE_MCP_TOOL_NAMES.map((name) => `mcp:cadre:${name}`);
|
|
2362
2510
|
function isRecord(value) {
|
|
2363
2511
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2364
2512
|
}
|
|
2365
2513
|
function atomicWrite(path, content) {
|
|
2366
|
-
const effectivePath =
|
|
2367
|
-
const directory =
|
|
2368
|
-
|
|
2514
|
+
const effectivePath = existsSync4(path) && lstatSync2(path).isSymbolicLink() ? realpathSync(path) : path;
|
|
2515
|
+
const directory = dirname4(effectivePath);
|
|
2516
|
+
mkdirSync3(directory, { recursive: true });
|
|
2369
2517
|
const temporary = `${directory}/.${basename(effectivePath)}.cadre-${process.pid}-${Date.now()}`;
|
|
2370
2518
|
try {
|
|
2371
|
-
|
|
2372
|
-
if (
|
|
2519
|
+
writeFileSync3(temporary, content, { encoding: "utf8", flag: "wx" });
|
|
2520
|
+
if (existsSync4(effectivePath)) chmodSync(temporary, statSync(effectivePath).mode);
|
|
2373
2521
|
renameSync(temporary, effectivePath);
|
|
2374
2522
|
} finally {
|
|
2375
|
-
if (
|
|
2523
|
+
if (existsSync4(temporary)) unlinkSync2(temporary);
|
|
2376
2524
|
}
|
|
2377
2525
|
}
|
|
2378
2526
|
function cadreCodexPolicy(value) {
|
|
@@ -2385,7 +2533,7 @@ function cadreCodexPolicy(value) {
|
|
|
2385
2533
|
return isRecord(server) ? server : void 0;
|
|
2386
2534
|
}
|
|
2387
2535
|
function configureCodexMcpApproval(configPath) {
|
|
2388
|
-
const existing =
|
|
2536
|
+
const existing = existsSync4(configPath) ? readFileSync4(configPath, "utf8") : "";
|
|
2389
2537
|
let parsed;
|
|
2390
2538
|
try {
|
|
2391
2539
|
parsed = parse3(existing);
|
|
@@ -2459,7 +2607,7 @@ function deniesCadre(rule) {
|
|
|
2459
2607
|
return rule === "mcp__*" || rule === "mcp__cadre" || rule.startsWith("mcp__cadre__");
|
|
2460
2608
|
}
|
|
2461
2609
|
function configureClaudeMcpApproval(settingsPath) {
|
|
2462
|
-
const existing =
|
|
2610
|
+
const existing = existsSync4(settingsPath) ? readFileSync4(settingsPath, "utf8") : "{}\n";
|
|
2463
2611
|
const errors = [];
|
|
2464
2612
|
const parsed = parse2(existing, errors, { allowTrailingComma: true });
|
|
2465
2613
|
if (errors.length) {
|
|
@@ -2517,6 +2665,132 @@ function configureClaudeMcpApproval(settingsPath) {
|
|
|
2517
2665
|
`);
|
|
2518
2666
|
return { path: settingsPath, changed: true, rule: CLAUDE_APPROVAL };
|
|
2519
2667
|
}
|
|
2668
|
+
function parseJsoncSettings(settingsPath) {
|
|
2669
|
+
const existing = existsSync4(settingsPath) ? readFileSync4(settingsPath, "utf8") : "{}\n";
|
|
2670
|
+
const errors = [];
|
|
2671
|
+
const parsed = parse2(existing, errors, { allowTrailingComma: true });
|
|
2672
|
+
if (errors.length) {
|
|
2673
|
+
const detail = errors.map((error) => `${printParseErrorCode(error.error)} at ${error.offset}`).join(", ");
|
|
2674
|
+
throw new Error(`Cannot update invalid Zed settings ${settingsPath}: ${detail}`);
|
|
2675
|
+
}
|
|
2676
|
+
if (!isRecord(parsed)) throw new Error(`${settingsPath}: Zed settings root must be an object`);
|
|
2677
|
+
return { existing, root: parsed };
|
|
2678
|
+
}
|
|
2679
|
+
function assertRecordField(owner, field, settingsPath) {
|
|
2680
|
+
const value = owner[field];
|
|
2681
|
+
if (value === void 0) return {};
|
|
2682
|
+
if (!isRecord(value)) throw new Error(`${settingsPath}: ${field} must be an object`);
|
|
2683
|
+
return value;
|
|
2684
|
+
}
|
|
2685
|
+
function zedServerMatches(server, nodePath, mcpPath) {
|
|
2686
|
+
if (!isRecord(server) || server.command !== nodePath || !Array.isArray(server.args)) return false;
|
|
2687
|
+
return server.args.length === 1 && server.args[0] === mcpPath;
|
|
2688
|
+
}
|
|
2689
|
+
function zedServerTargetsMcp(server, mcpPath) {
|
|
2690
|
+
return isRecord(server) && Array.isArray(server.args) && server.args.length === 1 && server.args[0] === mcpPath;
|
|
2691
|
+
}
|
|
2692
|
+
function hasBlockingZedRule(rule, field) {
|
|
2693
|
+
const value = rule[field];
|
|
2694
|
+
return value !== void 0 && (!Array.isArray(value) || value.length > 0);
|
|
2695
|
+
}
|
|
2696
|
+
function configureZedCadre(settingsPath, nodePath, mcpPath, autoApproveMcp) {
|
|
2697
|
+
const { existing, root } = parseJsoncSettings(settingsPath);
|
|
2698
|
+
const contextServers = assertRecordField(root, "context_servers", settingsPath);
|
|
2699
|
+
const currentServer = contextServers.cadre;
|
|
2700
|
+
if (currentServer !== void 0 && !zedServerMatches(currentServer, nodePath, mcpPath)) {
|
|
2701
|
+
throw new Error(
|
|
2702
|
+
`${settingsPath}: context_servers.cadre is not the Cadre-managed server; remove or rename it before installation`
|
|
2703
|
+
);
|
|
2704
|
+
}
|
|
2705
|
+
if (isRecord(currentServer) && currentServer.enabled === false) {
|
|
2706
|
+
throw new Error(`${settingsPath}: context_servers.cadre is disabled; enable it before installation`);
|
|
2707
|
+
}
|
|
2708
|
+
const agent = assertRecordField(root, "agent", settingsPath);
|
|
2709
|
+
const toolPermissions = assertRecordField(agent, "tool_permissions", settingsPath);
|
|
2710
|
+
const tools = assertRecordField(toolPermissions, "tools", settingsPath);
|
|
2711
|
+
if (autoApproveMcp) {
|
|
2712
|
+
for (const key of ZED_MCP_PERMISSION_KEYS) {
|
|
2713
|
+
const current = tools[key];
|
|
2714
|
+
if (current === void 0) continue;
|
|
2715
|
+
if (!isRecord(current)) throw new Error(`${settingsPath}: agent.tool_permissions.tools.${key} must be an object`);
|
|
2716
|
+
if (hasBlockingZedRule(current, "always_deny") || hasBlockingZedRule(current, "always_confirm")) {
|
|
2717
|
+
throw new Error(
|
|
2718
|
+
`${settingsPath}: ${key} has a higher-precedence deny/confirm rule; remove it or rerun with --prompt-mcp-tools`
|
|
2719
|
+
);
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
}
|
|
2723
|
+
const formattingOptions = { insertSpaces: true, tabSize: 2, eol: "\n" };
|
|
2724
|
+
const serverChanged = currentServer === void 0;
|
|
2725
|
+
let proposed = existing;
|
|
2726
|
+
if (serverChanged) {
|
|
2727
|
+
proposed = applyEdits(proposed, modify(
|
|
2728
|
+
proposed,
|
|
2729
|
+
["context_servers", "cadre"],
|
|
2730
|
+
{ command: nodePath, args: [mcpPath], env: {} },
|
|
2731
|
+
{ formattingOptions }
|
|
2732
|
+
));
|
|
2733
|
+
}
|
|
2734
|
+
let permissionsChanged = false;
|
|
2735
|
+
if (autoApproveMcp) {
|
|
2736
|
+
for (const key of ZED_MCP_PERMISSION_KEYS) {
|
|
2737
|
+
const current = isRecord(tools[key]) ? tools[key] : {};
|
|
2738
|
+
if (current.default === "allow") continue;
|
|
2739
|
+
proposed = applyEdits(proposed, modify(
|
|
2740
|
+
proposed,
|
|
2741
|
+
["agent", "tool_permissions", "tools", key, "default"],
|
|
2742
|
+
"allow",
|
|
2743
|
+
{ formattingOptions }
|
|
2744
|
+
));
|
|
2745
|
+
permissionsChanged = true;
|
|
2746
|
+
}
|
|
2747
|
+
}
|
|
2748
|
+
const verificationErrors = [];
|
|
2749
|
+
const verified = parse2(proposed, verificationErrors, { allowTrailingComma: true });
|
|
2750
|
+
const verifiedRoot = isRecord(verified) ? verified : {};
|
|
2751
|
+
const verifiedServers = isRecord(verifiedRoot.context_servers) ? verifiedRoot.context_servers : {};
|
|
2752
|
+
if (verificationErrors.length || !zedServerMatches(verifiedServers.cadre, nodePath, mcpPath)) {
|
|
2753
|
+
throw new Error("Generated Zed settings did not contain the Cadre MCP server");
|
|
2754
|
+
}
|
|
2755
|
+
if (autoApproveMcp) {
|
|
2756
|
+
const verifiedAgent = isRecord(verifiedRoot.agent) ? verifiedRoot.agent : {};
|
|
2757
|
+
const verifiedPermissions = isRecord(verifiedAgent.tool_permissions) ? verifiedAgent.tool_permissions : {};
|
|
2758
|
+
const verifiedTools = isRecord(verifiedPermissions.tools) ? verifiedPermissions.tools : {};
|
|
2759
|
+
if (ZED_MCP_PERMISSION_KEYS.some((key) => !isRecord(verifiedTools[key]) || verifiedTools[key].default !== "allow")) {
|
|
2760
|
+
throw new Error("Generated Zed settings did not contain every exact Cadre MCP approval rule");
|
|
2761
|
+
}
|
|
2762
|
+
}
|
|
2763
|
+
const changed = serverChanged || permissionsChanged;
|
|
2764
|
+
if (changed) atomicWrite(settingsPath, proposed.endsWith("\n") ? proposed : `${proposed}
|
|
2765
|
+
`);
|
|
2766
|
+
return {
|
|
2767
|
+
path: settingsPath,
|
|
2768
|
+
changed,
|
|
2769
|
+
serverChanged,
|
|
2770
|
+
permissionsChanged,
|
|
2771
|
+
rule: `${ZED_MCP_PERMISSION_KEYS.length} exact Cadre MCP tools`
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
function removeZedCadreServer(settingsPath, mcpPath) {
|
|
2775
|
+
if (!existsSync4(settingsPath)) return { changed: false, retainedConflict: false };
|
|
2776
|
+
const { existing, root } = parseJsoncSettings(settingsPath);
|
|
2777
|
+
const contextServers = assertRecordField(root, "context_servers", settingsPath);
|
|
2778
|
+
const currentServer = contextServers.cadre;
|
|
2779
|
+
if (currentServer === void 0) return { changed: false, retainedConflict: false };
|
|
2780
|
+
if (!zedServerTargetsMcp(currentServer, mcpPath)) {
|
|
2781
|
+
return { changed: false, retainedConflict: true };
|
|
2782
|
+
}
|
|
2783
|
+
const formattingOptions = { insertSpaces: true, tabSize: 2, eol: "\n" };
|
|
2784
|
+
const proposed = applyEdits(existing, modify(
|
|
2785
|
+
existing,
|
|
2786
|
+
["context_servers", "cadre"],
|
|
2787
|
+
void 0,
|
|
2788
|
+
{ formattingOptions }
|
|
2789
|
+
));
|
|
2790
|
+
atomicWrite(settingsPath, proposed.endsWith("\n") ? proposed : `${proposed}
|
|
2791
|
+
`);
|
|
2792
|
+
return { changed: true, retainedConflict: false };
|
|
2793
|
+
}
|
|
2520
2794
|
|
|
2521
2795
|
// scripts/install.ts
|
|
2522
2796
|
var marketplaceName = "cadre";
|
|
@@ -2537,7 +2811,7 @@ function parseInstallOptions(args) {
|
|
|
2537
2811
|
options.selection = parseClient(optionValue(args, index, arg));
|
|
2538
2812
|
index += 1;
|
|
2539
2813
|
} else if (arg === "--marketplace-root") {
|
|
2540
|
-
options.marketplaceRoot =
|
|
2814
|
+
options.marketplaceRoot = resolve5(optionValue(args, index, arg));
|
|
2541
2815
|
index += 1;
|
|
2542
2816
|
} else if (arg === "--home") {
|
|
2543
2817
|
options.marketplaceRoot = marketplaceFromHome(optionValue(args, index, arg));
|
|
@@ -2574,7 +2848,7 @@ function claudeMarketplaces() {
|
|
|
2574
2848
|
function replaceMarketplaceIfNeeded(client, existing, targetRoot, allowReplacement) {
|
|
2575
2849
|
if (!existing) return false;
|
|
2576
2850
|
const currentPath = marketplacePath(existing);
|
|
2577
|
-
if (currentPath &&
|
|
2851
|
+
if (currentPath && resolve5(currentPath) === targetRoot) return true;
|
|
2578
2852
|
if (!allowReplacement) {
|
|
2579
2853
|
throw new Error(
|
|
2580
2854
|
`${client} already has a ${marketplaceName} marketplace at ${currentPath ?? "an unknown path"}; review it and rerun with --replace-marketplace`
|
|
@@ -2594,8 +2868,8 @@ function installCodex(targetRoot, allowReplacement, autoApproveMcp) {
|
|
|
2594
2868
|
throw new Error(`Codex did not report ${pluginId} as installed and enabled`);
|
|
2595
2869
|
}
|
|
2596
2870
|
if (autoApproveMcp) {
|
|
2597
|
-
const codexRoot = process.env.CODEX_HOME ?
|
|
2598
|
-
const update = configureCodexMcpApproval(
|
|
2871
|
+
const codexRoot = process.env.CODEX_HOME ? resolve5(process.env.CODEX_HOME) : join5(homedir3(), ".codex");
|
|
2872
|
+
const update = configureCodexMcpApproval(join5(codexRoot, "config.toml"));
|
|
2599
2873
|
process.stdout.write(`${update.changed ? "Added" : "Retained"} Codex Cadre MCP approval in ${update.path}
|
|
2600
2874
|
`);
|
|
2601
2875
|
}
|
|
@@ -2616,31 +2890,41 @@ function installClaude(targetRoot, allowReplacement, autoApproveMcp) {
|
|
|
2616
2890
|
throw new Error(`Claude did not report ${pluginId} as installed and enabled`);
|
|
2617
2891
|
}
|
|
2618
2892
|
if (autoApproveMcp) {
|
|
2619
|
-
const claudeRoot = process.env.CLAUDE_HOME ?? process.env.CLAUDE_CONFIG_DIR ??
|
|
2620
|
-
const update = configureClaudeMcpApproval(
|
|
2893
|
+
const claudeRoot = process.env.CLAUDE_HOME ?? process.env.CLAUDE_CONFIG_DIR ?? join5(homedir3(), ".claude");
|
|
2894
|
+
const update = configureClaudeMcpApproval(join5(resolve5(claudeRoot), "settings.json"));
|
|
2621
2895
|
process.stdout.write(`${update.changed ? "Added" : "Retained"} Claude Cadre MCP approval in ${update.path}
|
|
2622
2896
|
`);
|
|
2623
2897
|
}
|
|
2624
2898
|
}
|
|
2899
|
+
function installZed(targetRoot, autoApproveMcp) {
|
|
2900
|
+
const pluginRoot = join5(targetRoot, "plugins", "cadre");
|
|
2901
|
+
const mcpPath = join5(pluginRoot, "dist", "cadre-mcp.mjs");
|
|
2902
|
+
const links = installZedSkillLinks(targetRoot);
|
|
2903
|
+
const update = configureZedCadre(zedSettingsPath(), resolve5(process.execPath), mcpPath, autoApproveMcp);
|
|
2904
|
+
process.stdout.write(`${update.changed ? "Updated" : "Retained"} Zed Cadre MCP configuration in ${update.path}
|
|
2905
|
+
`);
|
|
2906
|
+
process.stdout.write(`Installed ${links.length} Cadre workflow skill links for Zed Agent.
|
|
2907
|
+
`);
|
|
2908
|
+
}
|
|
2625
2909
|
function assertSafeTarget(targetRoot) {
|
|
2626
|
-
if (targetRoot === parse4(targetRoot).root || targetRoot ===
|
|
2910
|
+
if (targetRoot === parse4(targetRoot).root || targetRoot === resolve5(homedir3())) {
|
|
2627
2911
|
throw new Error(`refusing to use broad marketplace root ${targetRoot}`);
|
|
2628
2912
|
}
|
|
2629
2913
|
if (basename2(targetRoot) !== "cadre") throw new Error("marketplace root must end in a directory named cadre");
|
|
2630
2914
|
}
|
|
2631
2915
|
function prepareMarketplace(targetRoot, cachebuster) {
|
|
2632
|
-
const parent =
|
|
2633
|
-
|
|
2634
|
-
const stagingRoot = mkdtempSync(
|
|
2916
|
+
const parent = dirname5(targetRoot);
|
|
2917
|
+
mkdirSync4(parent, { recursive: true });
|
|
2918
|
+
const stagingRoot = mkdtempSync(join5(parent, ".cadre-staging-"));
|
|
2635
2919
|
const packaged = packagePluginMarketplace(stagingRoot, cachebuster ?? void 0);
|
|
2636
2920
|
let backupRoot = null;
|
|
2637
|
-
if (
|
|
2921
|
+
if (existsSync5(targetRoot)) {
|
|
2638
2922
|
const catalogs = [
|
|
2639
|
-
|
|
2640
|
-
|
|
2923
|
+
join5(targetRoot, ".agents", "plugins", "marketplace.json"),
|
|
2924
|
+
join5(targetRoot, ".claude-plugin", "marketplace.json")
|
|
2641
2925
|
];
|
|
2642
|
-
const owned = catalogs.every((path) =>
|
|
2643
|
-
if (!owned) throw new Error(`${targetRoot} exists but is not a Cadre
|
|
2926
|
+
const owned = catalogs.every((path) => existsSync5(path) && JSON.parse(readFileSync5(path, "utf8")).name === marketplaceName);
|
|
2927
|
+
if (!owned) throw new Error(`${targetRoot} exists but is not a Cadre marketplace payload`);
|
|
2644
2928
|
backupRoot = `${targetRoot}.backup-${Date.now()}`;
|
|
2645
2929
|
renameSync2(targetRoot, backupRoot);
|
|
2646
2930
|
}
|
|
@@ -2652,7 +2936,7 @@ function runInstall(args) {
|
|
|
2652
2936
|
assertSafeTarget(options.marketplaceRoot);
|
|
2653
2937
|
const clients = selectedClients(options.selection);
|
|
2654
2938
|
if (!options.prepareOnly && clients.length === 0) {
|
|
2655
|
-
throw new Error("No supported client detected. Install Codex or
|
|
2939
|
+
throw new Error("No supported client detected. Install Codex, Claude, or Zed, or pass --target codex|claude|zed|all");
|
|
2656
2940
|
}
|
|
2657
2941
|
for (const client of clients) {
|
|
2658
2942
|
if (!commandExists(client) && !options.prepareOnly && !options.dryRun) {
|
|
@@ -2662,10 +2946,14 @@ function runInstall(args) {
|
|
|
2662
2946
|
if (options.dryRun) {
|
|
2663
2947
|
process.stdout.write(`Would prepare Cadre marketplace at ${options.marketplaceRoot}
|
|
2664
2948
|
`);
|
|
2665
|
-
for (const client of clients)
|
|
2949
|
+
for (const client of clients) {
|
|
2950
|
+
const identity = client === "zed" ? "Cadre skills and MCP server" : pluginId;
|
|
2951
|
+
process.stdout.write(`Would install ${identity} for ${client} at user scope
|
|
2666
2952
|
`);
|
|
2953
|
+
}
|
|
2667
2954
|
return 0;
|
|
2668
2955
|
}
|
|
2956
|
+
if (!options.prepareOnly && clients.includes("zed")) preflightZedSkillLinks(options.marketplaceRoot);
|
|
2669
2957
|
const backupRoot = prepareMarketplace(options.marketplaceRoot, options.cachebuster);
|
|
2670
2958
|
process.stdout.write(`Prepared Cadre plugin marketplace at ${options.marketplaceRoot}
|
|
2671
2959
|
`);
|
|
@@ -2675,17 +2963,18 @@ function runInstall(args) {
|
|
|
2675
2963
|
const autoApproveMcp = !options.promptMcpTools;
|
|
2676
2964
|
for (const client of clients) {
|
|
2677
2965
|
if (client === "codex") installCodex(options.marketplaceRoot, options.replaceMarketplace, autoApproveMcp);
|
|
2678
|
-
else installClaude(options.marketplaceRoot, options.replaceMarketplace, autoApproveMcp);
|
|
2966
|
+
else if (client === "claude") installClaude(options.marketplaceRoot, options.replaceMarketplace, autoApproveMcp);
|
|
2967
|
+
else installZed(options.marketplaceRoot, autoApproveMcp);
|
|
2679
2968
|
}
|
|
2680
|
-
process.stdout.write(`Installed
|
|
2969
|
+
process.stdout.write(`Installed Cadre for ${clients.join(", ")}.
|
|
2681
2970
|
`);
|
|
2682
|
-
process.stdout.write("Start a new
|
|
2971
|
+
process.stdout.write("Start a new client conversation; in Claude Code, run /reload-plugins first.\n");
|
|
2683
2972
|
return 0;
|
|
2684
2973
|
}
|
|
2685
2974
|
|
|
2686
2975
|
// scripts/uninstall.ts
|
|
2687
|
-
import { existsSync as
|
|
2688
|
-
import { basename as basename3, dirname as
|
|
2976
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6, readdirSync as readdirSync2, rmSync } from "node:fs";
|
|
2977
|
+
import { basename as basename3, dirname as dirname6, join as join6, resolve as resolve6 } from "node:path";
|
|
2689
2978
|
var marketplaceName2 = "cadre";
|
|
2690
2979
|
var pluginId2 = "cadre@cadre";
|
|
2691
2980
|
function parseUninstallOptions(args) {
|
|
@@ -2700,7 +2989,7 @@ function parseUninstallOptions(args) {
|
|
|
2700
2989
|
options.selection = parseClient(optionValue(args, index, arg));
|
|
2701
2990
|
index += 1;
|
|
2702
2991
|
} else if (arg === "--marketplace-root") {
|
|
2703
|
-
options.marketplaceRoot =
|
|
2992
|
+
options.marketplaceRoot = resolve6(optionValue(args, index, arg));
|
|
2704
2993
|
index += 1;
|
|
2705
2994
|
} else if (arg === "--home") {
|
|
2706
2995
|
options.marketplaceRoot = marketplaceFromHome(optionValue(args, index, arg));
|
|
@@ -2720,37 +3009,48 @@ function selectedClients2(selection) {
|
|
|
2720
3009
|
return [selection];
|
|
2721
3010
|
}
|
|
2722
3011
|
function ownedMarketplace(root) {
|
|
2723
|
-
if (!
|
|
3012
|
+
if (!existsSync6(root)) return false;
|
|
2724
3013
|
const catalogs = [
|
|
2725
|
-
|
|
2726
|
-
|
|
3014
|
+
join6(root, ".agents", "plugins", "marketplace.json"),
|
|
3015
|
+
join6(root, ".claude-plugin", "marketplace.json")
|
|
2727
3016
|
];
|
|
2728
3017
|
return catalogs.every((path) => {
|
|
2729
|
-
if (!
|
|
3018
|
+
if (!existsSync6(path)) return false;
|
|
2730
3019
|
try {
|
|
2731
|
-
return JSON.parse(
|
|
3020
|
+
return JSON.parse(readFileSync6(path, "utf8")).name === marketplaceName2;
|
|
2732
3021
|
} catch {
|
|
2733
3022
|
return false;
|
|
2734
3023
|
}
|
|
2735
3024
|
});
|
|
2736
3025
|
}
|
|
2737
|
-
function uninstallClient(client) {
|
|
3026
|
+
function uninstallClient(client, marketplaceRoot) {
|
|
2738
3027
|
if (client === "codex") {
|
|
2739
3028
|
runCommand("codex", ["plugin", "remove", pluginId2, "--json"]);
|
|
2740
3029
|
runCommand("codex", ["plugin", "marketplace", "remove", marketplaceName2]);
|
|
2741
|
-
} else {
|
|
3030
|
+
} else if (client === "claude") {
|
|
2742
3031
|
runCommand("claude", ["plugin", "uninstall", "--scope", "user", "--yes", pluginId2]);
|
|
2743
3032
|
runCommand("claude", ["plugin", "marketplace", "remove", "--scope", "user", marketplaceName2]);
|
|
3033
|
+
} else {
|
|
3034
|
+
const skills = removeZedSkillLinks(marketplaceRoot);
|
|
3035
|
+
const mcpPath = join6(marketplaceRoot, "plugins", "cadre", "dist", "cadre-mcp.mjs");
|
|
3036
|
+
const settings = removeZedCadreServer(zedSettingsPath(), mcpPath);
|
|
3037
|
+
if (skills.retained.length) {
|
|
3038
|
+
process.stderr.write(`Retained non-Cadre Zed skill paths: ${skills.retained.join(", ")}
|
|
3039
|
+
`);
|
|
3040
|
+
}
|
|
3041
|
+
if (settings.retainedConflict) {
|
|
3042
|
+
process.stderr.write("Retained Zed context_servers.cadre because it no longer matches the Cadre installation.\n");
|
|
3043
|
+
}
|
|
2744
3044
|
}
|
|
2745
3045
|
}
|
|
2746
3046
|
function removeOwnedMarketplaces(root) {
|
|
2747
3047
|
const removed = [];
|
|
2748
3048
|
const candidates = [root];
|
|
2749
|
-
const parent =
|
|
3049
|
+
const parent = dirname6(root);
|
|
2750
3050
|
const prefix = `${basename3(root)}.backup-`;
|
|
2751
|
-
if (
|
|
3051
|
+
if (existsSync6(parent)) {
|
|
2752
3052
|
for (const entry of readdirSync2(parent)) {
|
|
2753
|
-
if (entry.startsWith(prefix)) candidates.push(
|
|
3053
|
+
if (entry.startsWith(prefix)) candidates.push(join6(parent, entry));
|
|
2754
3054
|
}
|
|
2755
3055
|
}
|
|
2756
3056
|
for (const candidate of candidates) {
|
|
@@ -2764,22 +3064,25 @@ function runUninstall(args) {
|
|
|
2764
3064
|
const options = parseUninstallOptions(args);
|
|
2765
3065
|
const clients = selectedClients2(options.selection);
|
|
2766
3066
|
if (options.dryRun) {
|
|
2767
|
-
for (const client of clients)
|
|
3067
|
+
for (const client of clients) {
|
|
3068
|
+
const identity = client === "zed" ? "Cadre skills and MCP server" : pluginId2;
|
|
3069
|
+
process.stdout.write(`Would uninstall ${identity} from ${client} at user scope
|
|
2768
3070
|
`);
|
|
3071
|
+
}
|
|
2769
3072
|
if (options.selection === "all") process.stdout.write(`Would remove owned marketplace: ${options.marketplaceRoot}
|
|
2770
3073
|
`);
|
|
2771
3074
|
return 0;
|
|
2772
3075
|
}
|
|
2773
3076
|
let failed = false;
|
|
2774
3077
|
for (const client of clients) {
|
|
2775
|
-
if (!commandExists(client)) {
|
|
3078
|
+
if (client !== "zed" && !commandExists(client)) {
|
|
2776
3079
|
process.stderr.write(`${client} is not available; continuing local cleanup.
|
|
2777
3080
|
`);
|
|
2778
3081
|
continue;
|
|
2779
3082
|
}
|
|
2780
3083
|
try {
|
|
2781
|
-
uninstallClient(client);
|
|
2782
|
-
process.stdout.write(`Uninstalled
|
|
3084
|
+
uninstallClient(client, options.marketplaceRoot);
|
|
3085
|
+
process.stdout.write(`Uninstalled Cadre from ${client}.
|
|
2783
3086
|
`);
|
|
2784
3087
|
} catch (error) {
|
|
2785
3088
|
failed = true;
|
|
@@ -2792,7 +3095,7 @@ function runUninstall(args) {
|
|
|
2792
3095
|
if (removed.length) process.stdout.write(`Removed ${removed.join(", ")}
|
|
2793
3096
|
`);
|
|
2794
3097
|
else process.stdout.write("No owned Cadre marketplace files found to remove.\n");
|
|
2795
|
-
} else if (
|
|
3098
|
+
} else if (existsSync6(options.marketplaceRoot)) {
|
|
2796
3099
|
process.stdout.write(`Retained shared marketplace at ${options.marketplaceRoot} for other clients.
|
|
2797
3100
|
`);
|
|
2798
3101
|
}
|
|
@@ -2805,15 +3108,15 @@ function usage() {
|
|
|
2805
3108
|
"Cadre CLI",
|
|
2806
3109
|
"",
|
|
2807
3110
|
"Usage:",
|
|
2808
|
-
" cadre-ai install [--target auto|codex|claude|all] [--scope user] [--dry-run] [--replace-marketplace]",
|
|
2809
|
-
" cadre-ai uninstall [--target codex|claude|all] [--scope user] [--dry-run]",
|
|
3111
|
+
" cadre-ai install [--target auto|codex|claude|zed|all] [--scope user] [--dry-run] [--replace-marketplace]",
|
|
3112
|
+
" cadre-ai uninstall [--target codex|claude|zed|all] [--scope user] [--dry-run]",
|
|
2810
3113
|
" cadre-ai doctor",
|
|
2811
3114
|
" cadre-ai --version",
|
|
2812
3115
|
" cadre-ai help"
|
|
2813
3116
|
].join("\n");
|
|
2814
3117
|
}
|
|
2815
3118
|
function packageRoot() {
|
|
2816
|
-
return
|
|
3119
|
+
return resolve7(dirname7(fileURLToPath3(import.meta.url)), "..");
|
|
2817
3120
|
}
|
|
2818
3121
|
function runDoctor() {
|
|
2819
3122
|
const root = packageRoot();
|
|
@@ -2825,11 +3128,11 @@ function runDoctor() {
|
|
|
2825
3128
|
"skills",
|
|
2826
3129
|
"templates"
|
|
2827
3130
|
];
|
|
2828
|
-
const missing = required.filter((entry) => !
|
|
2829
|
-
const packageJson =
|
|
3131
|
+
const missing = required.filter((entry) => !existsSync7(join7(root, entry)));
|
|
3132
|
+
const packageJson = join7(root, "package.json");
|
|
2830
3133
|
let identity = `cadre-ai@${CADRE_RUNTIME_VERSION}`;
|
|
2831
|
-
if (
|
|
2832
|
-
const metadata = JSON.parse(
|
|
3134
|
+
if (existsSync7(packageJson)) {
|
|
3135
|
+
const metadata = JSON.parse(readFileSync7(packageJson, "utf8"));
|
|
2833
3136
|
identity = `${metadata.name ?? "cadre-ai"}@${metadata.version ?? CADRE_RUNTIME_VERSION}`;
|
|
2834
3137
|
}
|
|
2835
3138
|
process.stdout.write(`${identity}
|