cadre-ai 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@ Cadre is a human-governed, Git-aware delivery harness for Codex and Claude Code.
|
|
|
4
4
|
|
|
5
5
|
Cadre is installed as a user plugin. Its bundled TypeScript MCP server provides deterministic state operations and immutable, versioned templates. A project keeps only approved, mutable delivery state under `.cadre/`; runtime code and template catalogs are not copied into the project.
|
|
6
6
|
|
|
7
|
+
**Documentation:** [cadre-docs.pages.dev](https://cadre-docs.pages.dev/) ·
|
|
8
|
+
[Quickstart](https://cadre-docs.pages.dev/quickstart/) ·
|
|
9
|
+
[Release notes](https://cadre-docs.pages.dev/release-notes/)
|
|
10
|
+
|
|
7
11
|
## Capabilities
|
|
8
12
|
|
|
9
13
|
- Greenfield and brownfield project onboarding, with an explicit classification gate when the repository is ambiguous.
|
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
|
|
6
|
-
import { fileURLToPath as
|
|
4
|
+
import { existsSync as existsSync6, readFileSync as readFileSync6 } from "node:fs";
|
|
5
|
+
import { dirname as dirname6, join as join6, resolve as resolve6 } from "node:path";
|
|
6
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7
7
|
|
|
8
8
|
// scripts/install.ts
|
|
9
|
-
import { existsSync as
|
|
9
|
+
import { existsSync as existsSync4, mkdtempSync, mkdirSync as mkdirSync3, readFileSync as readFileSync4, renameSync as renameSync2 } from "node:fs";
|
|
10
10
|
import { homedir as homedir2 } from "node:os";
|
|
11
|
-
import { basename as basename2, dirname as
|
|
11
|
+
import { basename as basename2, dirname as dirname4, join as join4, parse as parse4, resolve as resolve4 } from "node:path";
|
|
12
12
|
|
|
13
13
|
// scripts/cli-options.ts
|
|
14
14
|
import { homedir } from "node:os";
|
|
@@ -63,10 +63,130 @@ function marketplaceFromHome(home) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
// scripts/package-plugin.ts
|
|
66
|
-
import { cpSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
67
|
-
import { dirname, join as
|
|
66
|
+
import { cpSync, existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
|
|
67
|
+
import { dirname as dirname2, join as join3, resolve as resolve3 } from "node:path";
|
|
68
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
69
|
+
|
|
70
|
+
// src/domain/templates.ts
|
|
71
|
+
import { createHash } from "node:crypto";
|
|
72
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
73
|
+
import { dirname, extname, join as join2, relative, resolve as resolve2, sep } from "node:path";
|
|
68
74
|
import { fileURLToPath } from "node:url";
|
|
69
|
-
|
|
75
|
+
|
|
76
|
+
// src/domain/version.ts
|
|
77
|
+
var CADRE_RUNTIME_VERSION = "3.0.1";
|
|
78
|
+
var TEMPLATE_SET_VERSION = "v1";
|
|
79
|
+
|
|
80
|
+
// src/domain/templates.ts
|
|
81
|
+
var TEMPLATE_IDS = [
|
|
82
|
+
"project/archive-operation",
|
|
83
|
+
"project/gitignore",
|
|
84
|
+
"project/guidelines",
|
|
85
|
+
"project/pattern",
|
|
86
|
+
"project/patterns/index",
|
|
87
|
+
"project/product",
|
|
88
|
+
"project/project",
|
|
89
|
+
"project/refresh",
|
|
90
|
+
"project/refresh-operation",
|
|
91
|
+
"project/styleguides/general",
|
|
92
|
+
"project/styleguides/language",
|
|
93
|
+
"project/tech-stack",
|
|
94
|
+
"project/tracks",
|
|
95
|
+
"project/workflow",
|
|
96
|
+
"styleguide/dart",
|
|
97
|
+
"styleguide/flutter",
|
|
98
|
+
"styleguide/go",
|
|
99
|
+
"styleguide/gradle",
|
|
100
|
+
"styleguide/html-css",
|
|
101
|
+
"styleguide/index",
|
|
102
|
+
"styleguide/java",
|
|
103
|
+
"styleguide/javascript",
|
|
104
|
+
"styleguide/kotlin",
|
|
105
|
+
"styleguide/maven",
|
|
106
|
+
"styleguide/python",
|
|
107
|
+
"styleguide/react",
|
|
108
|
+
"styleguide/swift",
|
|
109
|
+
"styleguide/swiftui",
|
|
110
|
+
"styleguide/typescript",
|
|
111
|
+
"track/bug",
|
|
112
|
+
"track/execution",
|
|
113
|
+
"track/learning",
|
|
114
|
+
"track/plan",
|
|
115
|
+
"track/revert-operation",
|
|
116
|
+
"track/revise-operation",
|
|
117
|
+
"track/revision",
|
|
118
|
+
"track/spec",
|
|
119
|
+
"track/state"
|
|
120
|
+
];
|
|
121
|
+
var catalogCache = null;
|
|
122
|
+
function locateTemplateRoot() {
|
|
123
|
+
const moduleDirectory = dirname(fileURLToPath(import.meta.url));
|
|
124
|
+
const candidates = [
|
|
125
|
+
process.env.CADRE_TEMPLATE_ROOT,
|
|
126
|
+
resolve2(moduleDirectory, "../../templates", TEMPLATE_SET_VERSION),
|
|
127
|
+
resolve2(moduleDirectory, "../templates", TEMPLATE_SET_VERSION)
|
|
128
|
+
].filter((candidate) => Boolean(candidate));
|
|
129
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
130
|
+
if (!found) throw new Error(`Cadre template set ${TEMPLATE_SET_VERSION} is unavailable`);
|
|
131
|
+
return found;
|
|
132
|
+
}
|
|
133
|
+
function walk(root, directory = root) {
|
|
134
|
+
return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
135
|
+
const path = join2(directory, entry.name);
|
|
136
|
+
return entry.isDirectory() ? walk(root, path) : [relative(root, path).split(sep).join("/")];
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function templateId(path) {
|
|
140
|
+
if (path.endsWith("/.gitkeep")) return null;
|
|
141
|
+
if (path === "init/gitignore.template") return "project/gitignore";
|
|
142
|
+
const withoutExtension = path.slice(0, -extname(path).length);
|
|
143
|
+
const styleguidePrefix = "styleguides/";
|
|
144
|
+
if (path.startsWith(styleguidePrefix)) return `styleguide/${withoutExtension.slice(styleguidePrefix.length)}`;
|
|
145
|
+
if (path.startsWith("init/")) return `project/${withoutExtension.slice("init/".length)}`;
|
|
146
|
+
return withoutExtension;
|
|
147
|
+
}
|
|
148
|
+
function mimeType(path) {
|
|
149
|
+
if (path === "init/gitignore.template") return "text/plain";
|
|
150
|
+
return path.endsWith(".json") ? "application/json" : "text/markdown";
|
|
151
|
+
}
|
|
152
|
+
function assertCompleteCatalog(catalog) {
|
|
153
|
+
const actual = new Set(catalog.map((template) => template.id));
|
|
154
|
+
if (actual.size !== catalog.length) throw new Error(`Cadre template set ${TEMPLATE_SET_VERSION} has duplicate identifiers`);
|
|
155
|
+
const expected = new Set(TEMPLATE_IDS);
|
|
156
|
+
const missing = TEMPLATE_IDS.filter((id) => !actual.has(id));
|
|
157
|
+
const unexpected = [...actual].filter((id) => !expected.has(id)).sort();
|
|
158
|
+
if (missing.length || unexpected.length) {
|
|
159
|
+
const details = [
|
|
160
|
+
missing.length ? `missing ${missing.join(", ")}` : "",
|
|
161
|
+
unexpected.length ? `unexpected ${unexpected.join(", ")}` : ""
|
|
162
|
+
].filter(Boolean).join("; ");
|
|
163
|
+
throw new Error(`Cadre template set ${TEMPLATE_SET_VERSION} is incomplete: ${details}`);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function templateCatalog() {
|
|
167
|
+
if (!catalogCache) {
|
|
168
|
+
const root = locateTemplateRoot();
|
|
169
|
+
const catalog = walk(root).map((relativePath) => {
|
|
170
|
+
const id = templateId(relativePath);
|
|
171
|
+
if (!id) return null;
|
|
172
|
+
const content = readFileSync(join2(root, relativePath), "utf8");
|
|
173
|
+
return {
|
|
174
|
+
id,
|
|
175
|
+
uri: `cadre://templates/${TEMPLATE_SET_VERSION}/${id}`,
|
|
176
|
+
relativePath,
|
|
177
|
+
mimeType: mimeType(relativePath),
|
|
178
|
+
content,
|
|
179
|
+
sha256: createHash("sha256").update(content).digest("hex")
|
|
180
|
+
};
|
|
181
|
+
}).filter((entry) => entry !== null).sort((left, right) => left.id.localeCompare(right.id));
|
|
182
|
+
assertCompleteCatalog(catalog);
|
|
183
|
+
catalogCache = catalog;
|
|
184
|
+
}
|
|
185
|
+
return catalogCache.map((template) => ({ ...template }));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// scripts/package-plugin.ts
|
|
189
|
+
var sourceRoot = resolve3(dirname2(fileURLToPath2(import.meta.url)), "..");
|
|
70
190
|
var requiredEntries = [
|
|
71
191
|
"skills",
|
|
72
192
|
"templates",
|
|
@@ -78,10 +198,10 @@ var requiredEntries = [
|
|
|
78
198
|
];
|
|
79
199
|
var optionalEntries = ["hooks", "hooks.json", ".app.json", "assets", "commands", "agents"];
|
|
80
200
|
function readJson(path) {
|
|
81
|
-
return JSON.parse(
|
|
201
|
+
return JSON.parse(readFileSync2(path, "utf8"));
|
|
82
202
|
}
|
|
83
203
|
function writeJson(path, value) {
|
|
84
|
-
mkdirSync(
|
|
204
|
+
mkdirSync(dirname2(path), { recursive: true });
|
|
85
205
|
writeFileSync(path, `${JSON.stringify(value, null, 2)}
|
|
86
206
|
`);
|
|
87
207
|
}
|
|
@@ -93,36 +213,37 @@ function defaultCachebuster() {
|
|
|
93
213
|
return `local-${(/* @__PURE__ */ new Date()).toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z")}`;
|
|
94
214
|
}
|
|
95
215
|
function packagePluginMarketplace(outputRoot, requestedCachebuster = defaultCachebuster()) {
|
|
96
|
-
|
|
216
|
+
templateCatalog();
|
|
217
|
+
const targetRoot = resolve3(outputRoot);
|
|
97
218
|
const cachebuster = requestedCachebuster.trim();
|
|
98
219
|
if (!/^[0-9A-Za-z-]+$/.test(cachebuster)) {
|
|
99
220
|
throw new Error("cachebuster must contain only letters, digits, and hyphens");
|
|
100
221
|
}
|
|
101
|
-
const pluginRoot =
|
|
102
|
-
if (
|
|
222
|
+
const pluginRoot = join3(targetRoot, "plugins", "cadre");
|
|
223
|
+
if (existsSync2(pluginRoot)) throw new Error(`plugin output already exists: ${pluginRoot}`);
|
|
103
224
|
mkdirSync(pluginRoot, { recursive: true });
|
|
104
225
|
for (const entry of requiredEntries) {
|
|
105
|
-
const source =
|
|
106
|
-
if (!
|
|
107
|
-
cpSync(source,
|
|
226
|
+
const source = join3(sourceRoot, entry);
|
|
227
|
+
if (!existsSync2(source)) throw new Error(`required plugin entry is missing: ${entry}`);
|
|
228
|
+
cpSync(source, join3(pluginRoot, entry), { recursive: true });
|
|
108
229
|
}
|
|
109
230
|
for (const entry of optionalEntries) {
|
|
110
|
-
const source =
|
|
111
|
-
if (
|
|
231
|
+
const source = join3(sourceRoot, entry);
|
|
232
|
+
if (existsSync2(source)) cpSync(source, join3(pluginRoot, entry), { recursive: true });
|
|
112
233
|
}
|
|
113
|
-
const codexManifest = readJson(
|
|
234
|
+
const codexManifest = readJson(join3(sourceRoot, ".codex-plugin", "plugin.json"));
|
|
114
235
|
codexManifest.version = withCachebuster(codexManifest.version, "codex", cachebuster);
|
|
115
|
-
writeJson(
|
|
116
|
-
const claudeManifest = readJson(
|
|
236
|
+
writeJson(join3(pluginRoot, ".codex-plugin", "plugin.json"), codexManifest);
|
|
237
|
+
const claudeManifest = readJson(join3(sourceRoot, ".claude-plugin", "plugin.json"));
|
|
117
238
|
claudeManifest.version = withCachebuster(claudeManifest.version, "claude", cachebuster);
|
|
118
|
-
writeJson(
|
|
239
|
+
writeJson(join3(pluginRoot, ".claude-plugin", "plugin.json"), claudeManifest);
|
|
119
240
|
writeJson(
|
|
120
|
-
|
|
121
|
-
readJson(
|
|
241
|
+
join3(targetRoot, ".agents", "plugins", "marketplace.json"),
|
|
242
|
+
readJson(join3(sourceRoot, "marketplace", "codex.json"))
|
|
122
243
|
);
|
|
123
244
|
writeJson(
|
|
124
|
-
|
|
125
|
-
readJson(
|
|
245
|
+
join3(targetRoot, ".claude-plugin", "marketplace.json"),
|
|
246
|
+
readJson(join3(sourceRoot, "marketplace", "claude.json"))
|
|
126
247
|
);
|
|
127
248
|
return { targetRoot, pluginRoot, cachebuster };
|
|
128
249
|
}
|
|
@@ -903,11 +1024,11 @@ function parseTree(text, errors = [], options = ParseOptions.DEFAULT) {
|
|
|
903
1024
|
onValue({ type: getNodeType(value), offset, length, parent: currentParent, value });
|
|
904
1025
|
ensurePropertyComplete(offset + length);
|
|
905
1026
|
},
|
|
906
|
-
onSeparator: (
|
|
1027
|
+
onSeparator: (sep2, offset, length) => {
|
|
907
1028
|
if (currentParent.type === "property") {
|
|
908
|
-
if (
|
|
1029
|
+
if (sep2 === ":") {
|
|
909
1030
|
currentParent.colonOffset = offset;
|
|
910
|
-
} else if (
|
|
1031
|
+
} else if (sep2 === ",") {
|
|
911
1032
|
ensurePropertyComplete(offset);
|
|
912
1033
|
}
|
|
913
1034
|
}
|
|
@@ -1539,7 +1660,7 @@ function applyEdits(text, edits) {
|
|
|
1539
1660
|
// scripts/permissions.ts
|
|
1540
1661
|
import {
|
|
1541
1662
|
chmodSync,
|
|
1542
|
-
existsSync as
|
|
1663
|
+
existsSync as existsSync3,
|
|
1543
1664
|
lstatSync,
|
|
1544
1665
|
mkdirSync as mkdirSync2,
|
|
1545
1666
|
realpathSync,
|
|
@@ -1547,9 +1668,9 @@ import {
|
|
|
1547
1668
|
statSync,
|
|
1548
1669
|
unlinkSync,
|
|
1549
1670
|
writeFileSync as writeFileSync2,
|
|
1550
|
-
readFileSync as
|
|
1671
|
+
readFileSync as readFileSync3
|
|
1551
1672
|
} from "node:fs";
|
|
1552
|
-
import { basename, dirname as
|
|
1673
|
+
import { basename, dirname as dirname3 } from "node:path";
|
|
1553
1674
|
|
|
1554
1675
|
// ../node_modules/.pnpm/smol-toml@1.7.1/node_modules/smol-toml/dist/date.js
|
|
1555
1676
|
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
@@ -1876,7 +1997,7 @@ function skipVoid(str, ptr, banNewLines, banComments) {
|
|
|
1876
1997
|
}
|
|
1877
1998
|
return ptr;
|
|
1878
1999
|
}
|
|
1879
|
-
function skipUntil(str, ptr,
|
|
2000
|
+
function skipUntil(str, ptr, sep2, end, banNewLines = false) {
|
|
1880
2001
|
if (!end) {
|
|
1881
2002
|
ptr = indexOfNewline(str, ptr);
|
|
1882
2003
|
return ptr < 0 ? str.length : ptr;
|
|
@@ -1887,7 +2008,7 @@ function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
|
1887
2008
|
i = indexOfNewline(str, i);
|
|
1888
2009
|
if (i < 0)
|
|
1889
2010
|
break;
|
|
1890
|
-
} else if (c ===
|
|
2011
|
+
} else if (c === sep2) {
|
|
1891
2012
|
return i + 1;
|
|
1892
2013
|
} else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
|
|
1893
2014
|
return i;
|
|
@@ -2242,16 +2363,16 @@ function isRecord(value) {
|
|
|
2242
2363
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2243
2364
|
}
|
|
2244
2365
|
function atomicWrite(path, content) {
|
|
2245
|
-
const effectivePath =
|
|
2246
|
-
const directory =
|
|
2366
|
+
const effectivePath = existsSync3(path) && lstatSync(path).isSymbolicLink() ? realpathSync(path) : path;
|
|
2367
|
+
const directory = dirname3(effectivePath);
|
|
2247
2368
|
mkdirSync2(directory, { recursive: true });
|
|
2248
2369
|
const temporary = `${directory}/.${basename(effectivePath)}.cadre-${process.pid}-${Date.now()}`;
|
|
2249
2370
|
try {
|
|
2250
2371
|
writeFileSync2(temporary, content, { encoding: "utf8", flag: "wx" });
|
|
2251
|
-
if (
|
|
2372
|
+
if (existsSync3(effectivePath)) chmodSync(temporary, statSync(effectivePath).mode);
|
|
2252
2373
|
renameSync(temporary, effectivePath);
|
|
2253
2374
|
} finally {
|
|
2254
|
-
if (
|
|
2375
|
+
if (existsSync3(temporary)) unlinkSync(temporary);
|
|
2255
2376
|
}
|
|
2256
2377
|
}
|
|
2257
2378
|
function cadreCodexPolicy(value) {
|
|
@@ -2264,7 +2385,7 @@ function cadreCodexPolicy(value) {
|
|
|
2264
2385
|
return isRecord(server) ? server : void 0;
|
|
2265
2386
|
}
|
|
2266
2387
|
function configureCodexMcpApproval(configPath) {
|
|
2267
|
-
const existing =
|
|
2388
|
+
const existing = existsSync3(configPath) ? readFileSync3(configPath, "utf8") : "";
|
|
2268
2389
|
let parsed;
|
|
2269
2390
|
try {
|
|
2270
2391
|
parsed = parse3(existing);
|
|
@@ -2338,7 +2459,7 @@ function deniesCadre(rule) {
|
|
|
2338
2459
|
return rule === "mcp__*" || rule === "mcp__cadre" || rule.startsWith("mcp__cadre__");
|
|
2339
2460
|
}
|
|
2340
2461
|
function configureClaudeMcpApproval(settingsPath) {
|
|
2341
|
-
const existing =
|
|
2462
|
+
const existing = existsSync3(settingsPath) ? readFileSync3(settingsPath, "utf8") : "{}\n";
|
|
2342
2463
|
const errors = [];
|
|
2343
2464
|
const parsed = parse2(existing, errors, { allowTrailingComma: true });
|
|
2344
2465
|
if (errors.length) {
|
|
@@ -2416,7 +2537,7 @@ function parseInstallOptions(args) {
|
|
|
2416
2537
|
options.selection = parseClient(optionValue(args, index, arg));
|
|
2417
2538
|
index += 1;
|
|
2418
2539
|
} else if (arg === "--marketplace-root") {
|
|
2419
|
-
options.marketplaceRoot =
|
|
2540
|
+
options.marketplaceRoot = resolve4(optionValue(args, index, arg));
|
|
2420
2541
|
index += 1;
|
|
2421
2542
|
} else if (arg === "--home") {
|
|
2422
2543
|
options.marketplaceRoot = marketplaceFromHome(optionValue(args, index, arg));
|
|
@@ -2453,7 +2574,7 @@ function claudeMarketplaces() {
|
|
|
2453
2574
|
function replaceMarketplaceIfNeeded(client, existing, targetRoot, allowReplacement) {
|
|
2454
2575
|
if (!existing) return false;
|
|
2455
2576
|
const currentPath = marketplacePath(existing);
|
|
2456
|
-
if (currentPath &&
|
|
2577
|
+
if (currentPath && resolve4(currentPath) === targetRoot) return true;
|
|
2457
2578
|
if (!allowReplacement) {
|
|
2458
2579
|
throw new Error(
|
|
2459
2580
|
`${client} already has a ${marketplaceName} marketplace at ${currentPath ?? "an unknown path"}; review it and rerun with --replace-marketplace`
|
|
@@ -2473,8 +2594,8 @@ function installCodex(targetRoot, allowReplacement, autoApproveMcp) {
|
|
|
2473
2594
|
throw new Error(`Codex did not report ${pluginId} as installed and enabled`);
|
|
2474
2595
|
}
|
|
2475
2596
|
if (autoApproveMcp) {
|
|
2476
|
-
const codexRoot = process.env.CODEX_HOME ?
|
|
2477
|
-
const update = configureCodexMcpApproval(
|
|
2597
|
+
const codexRoot = process.env.CODEX_HOME ? resolve4(process.env.CODEX_HOME) : join4(homedir2(), ".codex");
|
|
2598
|
+
const update = configureCodexMcpApproval(join4(codexRoot, "config.toml"));
|
|
2478
2599
|
process.stdout.write(`${update.changed ? "Added" : "Retained"} Codex Cadre MCP approval in ${update.path}
|
|
2479
2600
|
`);
|
|
2480
2601
|
}
|
|
@@ -2495,30 +2616,30 @@ function installClaude(targetRoot, allowReplacement, autoApproveMcp) {
|
|
|
2495
2616
|
throw new Error(`Claude did not report ${pluginId} as installed and enabled`);
|
|
2496
2617
|
}
|
|
2497
2618
|
if (autoApproveMcp) {
|
|
2498
|
-
const claudeRoot = process.env.CLAUDE_HOME ?? process.env.CLAUDE_CONFIG_DIR ??
|
|
2499
|
-
const update = configureClaudeMcpApproval(
|
|
2619
|
+
const claudeRoot = process.env.CLAUDE_HOME ?? process.env.CLAUDE_CONFIG_DIR ?? join4(homedir2(), ".claude");
|
|
2620
|
+
const update = configureClaudeMcpApproval(join4(resolve4(claudeRoot), "settings.json"));
|
|
2500
2621
|
process.stdout.write(`${update.changed ? "Added" : "Retained"} Claude Cadre MCP approval in ${update.path}
|
|
2501
2622
|
`);
|
|
2502
2623
|
}
|
|
2503
2624
|
}
|
|
2504
2625
|
function assertSafeTarget(targetRoot) {
|
|
2505
|
-
if (targetRoot === parse4(targetRoot).root || targetRoot ===
|
|
2626
|
+
if (targetRoot === parse4(targetRoot).root || targetRoot === resolve4(homedir2())) {
|
|
2506
2627
|
throw new Error(`refusing to use broad marketplace root ${targetRoot}`);
|
|
2507
2628
|
}
|
|
2508
2629
|
if (basename2(targetRoot) !== "cadre") throw new Error("marketplace root must end in a directory named cadre");
|
|
2509
2630
|
}
|
|
2510
2631
|
function prepareMarketplace(targetRoot, cachebuster) {
|
|
2511
|
-
const parent =
|
|
2632
|
+
const parent = dirname4(targetRoot);
|
|
2512
2633
|
mkdirSync3(parent, { recursive: true });
|
|
2513
|
-
const stagingRoot = mkdtempSync(
|
|
2634
|
+
const stagingRoot = mkdtempSync(join4(parent, ".cadre-staging-"));
|
|
2514
2635
|
const packaged = packagePluginMarketplace(stagingRoot, cachebuster ?? void 0);
|
|
2515
2636
|
let backupRoot = null;
|
|
2516
|
-
if (
|
|
2637
|
+
if (existsSync4(targetRoot)) {
|
|
2517
2638
|
const catalogs = [
|
|
2518
|
-
|
|
2519
|
-
|
|
2639
|
+
join4(targetRoot, ".agents", "plugins", "marketplace.json"),
|
|
2640
|
+
join4(targetRoot, ".claude-plugin", "marketplace.json")
|
|
2520
2641
|
];
|
|
2521
|
-
const owned = catalogs.every((path) =>
|
|
2642
|
+
const owned = catalogs.every((path) => existsSync4(path) && JSON.parse(readFileSync4(path, "utf8")).name === marketplaceName);
|
|
2522
2643
|
if (!owned) throw new Error(`${targetRoot} exists but is not a Cadre dual-product marketplace`);
|
|
2523
2644
|
backupRoot = `${targetRoot}.backup-${Date.now()}`;
|
|
2524
2645
|
renameSync2(targetRoot, backupRoot);
|
|
@@ -2563,8 +2684,8 @@ function runInstall(args) {
|
|
|
2563
2684
|
}
|
|
2564
2685
|
|
|
2565
2686
|
// scripts/uninstall.ts
|
|
2566
|
-
import { existsSync as
|
|
2567
|
-
import { basename as basename3, dirname as
|
|
2687
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5, readdirSync as readdirSync2, rmSync } from "node:fs";
|
|
2688
|
+
import { basename as basename3, dirname as dirname5, join as join5, resolve as resolve5 } from "node:path";
|
|
2568
2689
|
var marketplaceName2 = "cadre";
|
|
2569
2690
|
var pluginId2 = "cadre@cadre";
|
|
2570
2691
|
function parseUninstallOptions(args) {
|
|
@@ -2579,7 +2700,7 @@ function parseUninstallOptions(args) {
|
|
|
2579
2700
|
options.selection = parseClient(optionValue(args, index, arg));
|
|
2580
2701
|
index += 1;
|
|
2581
2702
|
} else if (arg === "--marketplace-root") {
|
|
2582
|
-
options.marketplaceRoot =
|
|
2703
|
+
options.marketplaceRoot = resolve5(optionValue(args, index, arg));
|
|
2583
2704
|
index += 1;
|
|
2584
2705
|
} else if (arg === "--home") {
|
|
2585
2706
|
options.marketplaceRoot = marketplaceFromHome(optionValue(args, index, arg));
|
|
@@ -2599,15 +2720,15 @@ function selectedClients2(selection) {
|
|
|
2599
2720
|
return [selection];
|
|
2600
2721
|
}
|
|
2601
2722
|
function ownedMarketplace(root) {
|
|
2602
|
-
if (!
|
|
2723
|
+
if (!existsSync5(root)) return false;
|
|
2603
2724
|
const catalogs = [
|
|
2604
|
-
|
|
2605
|
-
|
|
2725
|
+
join5(root, ".agents", "plugins", "marketplace.json"),
|
|
2726
|
+
join5(root, ".claude-plugin", "marketplace.json")
|
|
2606
2727
|
];
|
|
2607
2728
|
return catalogs.every((path) => {
|
|
2608
|
-
if (!
|
|
2729
|
+
if (!existsSync5(path)) return false;
|
|
2609
2730
|
try {
|
|
2610
|
-
return JSON.parse(
|
|
2731
|
+
return JSON.parse(readFileSync5(path, "utf8")).name === marketplaceName2;
|
|
2611
2732
|
} catch {
|
|
2612
2733
|
return false;
|
|
2613
2734
|
}
|
|
@@ -2625,11 +2746,11 @@ function uninstallClient(client) {
|
|
|
2625
2746
|
function removeOwnedMarketplaces(root) {
|
|
2626
2747
|
const removed = [];
|
|
2627
2748
|
const candidates = [root];
|
|
2628
|
-
const parent =
|
|
2749
|
+
const parent = dirname5(root);
|
|
2629
2750
|
const prefix = `${basename3(root)}.backup-`;
|
|
2630
|
-
if (
|
|
2631
|
-
for (const entry of
|
|
2632
|
-
if (entry.startsWith(prefix)) candidates.push(
|
|
2751
|
+
if (existsSync5(parent)) {
|
|
2752
|
+
for (const entry of readdirSync2(parent)) {
|
|
2753
|
+
if (entry.startsWith(prefix)) candidates.push(join5(parent, entry));
|
|
2633
2754
|
}
|
|
2634
2755
|
}
|
|
2635
2756
|
for (const candidate of candidates) {
|
|
@@ -2671,16 +2792,13 @@ function runUninstall(args) {
|
|
|
2671
2792
|
if (removed.length) process.stdout.write(`Removed ${removed.join(", ")}
|
|
2672
2793
|
`);
|
|
2673
2794
|
else process.stdout.write("No owned Cadre marketplace files found to remove.\n");
|
|
2674
|
-
} else if (
|
|
2795
|
+
} else if (existsSync5(options.marketplaceRoot)) {
|
|
2675
2796
|
process.stdout.write(`Retained shared marketplace at ${options.marketplaceRoot} for other clients.
|
|
2676
2797
|
`);
|
|
2677
2798
|
}
|
|
2678
2799
|
return failed ? 1 : 0;
|
|
2679
2800
|
}
|
|
2680
2801
|
|
|
2681
|
-
// src/domain/version.ts
|
|
2682
|
-
var CADRE_RUNTIME_VERSION = "3.0.0";
|
|
2683
|
-
|
|
2684
2802
|
// scripts/cli.ts
|
|
2685
2803
|
function usage() {
|
|
2686
2804
|
return [
|
|
@@ -2695,7 +2813,7 @@ function usage() {
|
|
|
2695
2813
|
].join("\n");
|
|
2696
2814
|
}
|
|
2697
2815
|
function packageRoot() {
|
|
2698
|
-
return
|
|
2816
|
+
return resolve6(dirname6(fileURLToPath3(import.meta.url)), "..");
|
|
2699
2817
|
}
|
|
2700
2818
|
function runDoctor() {
|
|
2701
2819
|
const root = packageRoot();
|
|
@@ -2707,11 +2825,11 @@ function runDoctor() {
|
|
|
2707
2825
|
"skills",
|
|
2708
2826
|
"templates"
|
|
2709
2827
|
];
|
|
2710
|
-
const missing = required.filter((entry) => !
|
|
2711
|
-
const packageJson =
|
|
2828
|
+
const missing = required.filter((entry) => !existsSync6(join6(root, entry)));
|
|
2829
|
+
const packageJson = join6(root, "package.json");
|
|
2712
2830
|
let identity = `cadre-ai@${CADRE_RUNTIME_VERSION}`;
|
|
2713
|
-
if (
|
|
2714
|
-
const metadata = JSON.parse(
|
|
2831
|
+
if (existsSync6(packageJson)) {
|
|
2832
|
+
const metadata = JSON.parse(readFileSync6(packageJson, "utf8"));
|
|
2715
2833
|
identity = `${metadata.name ?? "cadre-ai"}@${metadata.version ?? CADRE_RUNTIME_VERSION}`;
|
|
2716
2834
|
}
|
|
2717
2835
|
process.stdout.write(`${identity}
|
|
@@ -2719,6 +2837,15 @@ package root: ${root}
|
|
|
2719
2837
|
`);
|
|
2720
2838
|
if (missing.length) {
|
|
2721
2839
|
process.stderr.write(`Missing packaged runtime assets: ${missing.join(", ")}
|
|
2840
|
+
`);
|
|
2841
|
+
return 1;
|
|
2842
|
+
}
|
|
2843
|
+
try {
|
|
2844
|
+
const templates = templateCatalog();
|
|
2845
|
+
process.stdout.write(`template catalog: ${templates.length}/${TEMPLATE_IDS.length} required templates
|
|
2846
|
+
`);
|
|
2847
|
+
} catch (error) {
|
|
2848
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
2722
2849
|
`);
|
|
2723
2850
|
return 1;
|
|
2724
2851
|
}
|
package/dist/cadre-mcp.mjs
CHANGED
|
@@ -30994,7 +30994,7 @@ import { existsSync as existsSync4, lstatSync as lstatSync2, readFileSync as rea
|
|
|
30994
30994
|
import { join as join2, resolve as resolve3 } from "node:path";
|
|
30995
30995
|
|
|
30996
30996
|
// src/domain/version.ts
|
|
30997
|
-
var CADRE_RUNTIME_VERSION = "3.0.
|
|
30997
|
+
var CADRE_RUNTIME_VERSION = "3.0.1";
|
|
30998
30998
|
var TEMPLATE_SET_VERSION = "v1";
|
|
30999
30999
|
|
|
31000
31000
|
// src/domain/plan.ts
|
|
@@ -32259,6 +32259,46 @@ import { createHash as createHash4 } from "node:crypto";
|
|
|
32259
32259
|
import { existsSync as existsSync5, readFileSync as readFileSync4, readdirSync as readdirSync3 } from "node:fs";
|
|
32260
32260
|
import { dirname as dirname2, extname, join as join3, relative, resolve as resolve4, sep } from "node:path";
|
|
32261
32261
|
import { fileURLToPath } from "node:url";
|
|
32262
|
+
var TEMPLATE_IDS = [
|
|
32263
|
+
"project/archive-operation",
|
|
32264
|
+
"project/gitignore",
|
|
32265
|
+
"project/guidelines",
|
|
32266
|
+
"project/pattern",
|
|
32267
|
+
"project/patterns/index",
|
|
32268
|
+
"project/product",
|
|
32269
|
+
"project/project",
|
|
32270
|
+
"project/refresh",
|
|
32271
|
+
"project/refresh-operation",
|
|
32272
|
+
"project/styleguides/general",
|
|
32273
|
+
"project/styleguides/language",
|
|
32274
|
+
"project/tech-stack",
|
|
32275
|
+
"project/tracks",
|
|
32276
|
+
"project/workflow",
|
|
32277
|
+
"styleguide/dart",
|
|
32278
|
+
"styleguide/flutter",
|
|
32279
|
+
"styleguide/go",
|
|
32280
|
+
"styleguide/gradle",
|
|
32281
|
+
"styleguide/html-css",
|
|
32282
|
+
"styleguide/index",
|
|
32283
|
+
"styleguide/java",
|
|
32284
|
+
"styleguide/javascript",
|
|
32285
|
+
"styleguide/kotlin",
|
|
32286
|
+
"styleguide/maven",
|
|
32287
|
+
"styleguide/python",
|
|
32288
|
+
"styleguide/react",
|
|
32289
|
+
"styleguide/swift",
|
|
32290
|
+
"styleguide/swiftui",
|
|
32291
|
+
"styleguide/typescript",
|
|
32292
|
+
"track/bug",
|
|
32293
|
+
"track/execution",
|
|
32294
|
+
"track/learning",
|
|
32295
|
+
"track/plan",
|
|
32296
|
+
"track/revert-operation",
|
|
32297
|
+
"track/revise-operation",
|
|
32298
|
+
"track/revision",
|
|
32299
|
+
"track/spec",
|
|
32300
|
+
"track/state"
|
|
32301
|
+
];
|
|
32262
32302
|
var catalogCache = null;
|
|
32263
32303
|
function locateTemplateRoot() {
|
|
32264
32304
|
const moduleDirectory = dirname2(fileURLToPath(import.meta.url));
|
|
@@ -32279,7 +32319,7 @@ function walk(root, directory = root) {
|
|
|
32279
32319
|
}
|
|
32280
32320
|
function templateId(path) {
|
|
32281
32321
|
if (path.endsWith("/.gitkeep")) return null;
|
|
32282
|
-
if (path === "init
|
|
32322
|
+
if (path === "init/gitignore.template") return "project/gitignore";
|
|
32283
32323
|
const withoutExtension = path.slice(0, -extname(path).length);
|
|
32284
32324
|
const styleguidePrefix = "styleguides/";
|
|
32285
32325
|
if (path.startsWith(styleguidePrefix)) return `styleguide/${withoutExtension.slice(styleguidePrefix.length)}`;
|
|
@@ -32287,13 +32327,27 @@ function templateId(path) {
|
|
|
32287
32327
|
return withoutExtension;
|
|
32288
32328
|
}
|
|
32289
32329
|
function mimeType(path) {
|
|
32290
|
-
if (path
|
|
32330
|
+
if (path === "init/gitignore.template") return "text/plain";
|
|
32291
32331
|
return path.endsWith(".json") ? "application/json" : "text/markdown";
|
|
32292
32332
|
}
|
|
32333
|
+
function assertCompleteCatalog(catalog) {
|
|
32334
|
+
const actual = new Set(catalog.map((template) => template.id));
|
|
32335
|
+
if (actual.size !== catalog.length) throw new Error(`Cadre template set ${TEMPLATE_SET_VERSION} has duplicate identifiers`);
|
|
32336
|
+
const expected = new Set(TEMPLATE_IDS);
|
|
32337
|
+
const missing = TEMPLATE_IDS.filter((id) => !actual.has(id));
|
|
32338
|
+
const unexpected = [...actual].filter((id) => !expected.has(id)).sort();
|
|
32339
|
+
if (missing.length || unexpected.length) {
|
|
32340
|
+
const details = [
|
|
32341
|
+
missing.length ? `missing ${missing.join(", ")}` : "",
|
|
32342
|
+
unexpected.length ? `unexpected ${unexpected.join(", ")}` : ""
|
|
32343
|
+
].filter(Boolean).join("; ");
|
|
32344
|
+
throw new Error(`Cadre template set ${TEMPLATE_SET_VERSION} is incomplete: ${details}`);
|
|
32345
|
+
}
|
|
32346
|
+
}
|
|
32293
32347
|
function templateCatalog() {
|
|
32294
32348
|
if (!catalogCache) {
|
|
32295
32349
|
const root = locateTemplateRoot();
|
|
32296
|
-
|
|
32350
|
+
const catalog = walk(root).map((relativePath) => {
|
|
32297
32351
|
const id = templateId(relativePath);
|
|
32298
32352
|
if (!id) return null;
|
|
32299
32353
|
const content = readFileSync4(join3(root, relativePath), "utf8");
|
|
@@ -32306,6 +32360,8 @@ function templateCatalog() {
|
|
|
32306
32360
|
sha256: createHash4("sha256").update(content).digest("hex")
|
|
32307
32361
|
};
|
|
32308
32362
|
}).filter((entry) => entry !== null).sort((left, right) => left.id.localeCompare(right.id));
|
|
32363
|
+
assertCompleteCatalog(catalog);
|
|
32364
|
+
catalogCache = catalog;
|
|
32309
32365
|
}
|
|
32310
32366
|
return catalogCache.map((template) => ({ ...template }));
|
|
32311
32367
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|