@codemcp/ade-cli 0.2.0 → 0.2.2

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/dist/index.d.ts CHANGED
@@ -1,2 +1 @@
1
1
  #!/usr/bin/env node
2
- export {};
package/dist/index.js CHANGED
@@ -1,43 +1,285 @@
1
1
  #!/usr/bin/env node
2
- import { version } from "./version.js";
3
- import { runSetup } from "./commands/setup.js";
4
- import { runInstall } from "./commands/install.js";
5
- import { getDefaultCatalog } from "@codemcp/ade-core";
6
- import { getHarnessIds } from "@codemcp/ade-harnesses";
7
- const args = process.argv.slice(2);
8
- const command = args[0];
9
- if (command === "setup") {
10
- const projectRoot = args[1] ?? process.cwd();
11
- const catalog = getDefaultCatalog();
12
- await runSetup(projectRoot, catalog);
2
+
3
+ // src/version.ts
4
+ var version = "0.0.0-development";
5
+
6
+ // src/commands/setup.ts
7
+ import * as clack from "@clack/prompts";
8
+ import {
9
+ readUserConfig,
10
+ writeUserConfig,
11
+ writeLockFile,
12
+ resolve,
13
+ collectDocsets,
14
+ createDefaultRegistry,
15
+ getFacet,
16
+ getOption,
17
+ sortFacets,
18
+ getVisibleOptions
19
+ } from "@codemcp/ade-core";
20
+ import {
21
+ allHarnessWriters,
22
+ getHarnessWriter,
23
+ installSkills,
24
+ writeInlineSkills
25
+ } from "@codemcp/ade-harnesses";
26
+ async function runSetup(projectRoot, catalog) {
27
+ clack.intro("ade setup");
28
+ const existingConfig = await readUserConfig(projectRoot);
29
+ const existingChoices = existingConfig?.choices ?? {};
30
+ for (const [facetId, value] of Object.entries(existingChoices)) {
31
+ const facet = getFacet(catalog, facetId);
32
+ if (!facet) continue;
33
+ const ids = Array.isArray(value) ? value : [value];
34
+ for (const optionId of ids) {
35
+ if (!getOption(facet, optionId)) {
36
+ clack.log.warn(
37
+ `Previously selected option "${optionId}" is no longer available in facet "${facet.label}".`
38
+ );
39
+ }
40
+ }
41
+ }
42
+ const choices = {};
43
+ const sortedFacets = sortFacets(catalog);
44
+ for (const facet of sortedFacets) {
45
+ const visibleOptions = getVisibleOptions(facet, choices, catalog);
46
+ if (visibleOptions.length === 0) continue;
47
+ const visibleFacet = { ...facet, options: visibleOptions };
48
+ if (facet.multiSelect) {
49
+ const selected = await promptMultiSelect(visibleFacet, existingChoices);
50
+ if (typeof selected === "symbol") {
51
+ clack.cancel("Setup cancelled.");
52
+ return;
53
+ }
54
+ if (selected.length > 0) {
55
+ choices[facet.id] = selected;
56
+ }
57
+ } else {
58
+ const selected = await promptSelect(visibleFacet, existingChoices);
59
+ if (typeof selected === "symbol") {
60
+ clack.cancel("Setup cancelled.");
61
+ return;
62
+ }
63
+ if (typeof selected === "string" && selected !== "__skip__") {
64
+ choices[facet.id] = selected;
65
+ }
66
+ }
67
+ }
68
+ const impliedDocsets = collectDocsets(choices, catalog);
69
+ let excludedDocsets;
70
+ if (impliedDocsets.length > 0) {
71
+ const selected = await clack.multiselect({
72
+ message: "Documentation \u2014 deselect any you don't need",
73
+ options: impliedDocsets.map((d) => ({
74
+ value: d.id,
75
+ label: d.label,
76
+ hint: d.description
77
+ })),
78
+ initialValues: impliedDocsets.map((d) => d.id),
79
+ required: false
80
+ });
81
+ if (typeof selected === "symbol") {
82
+ clack.cancel("Setup cancelled.");
83
+ return;
84
+ }
85
+ const selectedSet = new Set(selected);
86
+ const excluded = impliedDocsets.filter((d) => !selectedSet.has(d.id)).map((d) => d.id);
87
+ if (excluded.length > 0) {
88
+ excludedDocsets = excluded;
89
+ }
90
+ }
91
+ const existingHarnesses = existingConfig?.harnesses;
92
+ const harnessOptions = allHarnessWriters.map((w) => ({
93
+ value: w.id,
94
+ label: w.label,
95
+ hint: w.description
96
+ }));
97
+ const validExistingHarnesses = existingHarnesses?.filter(
98
+ (h) => allHarnessWriters.some((w) => w.id === h)
99
+ );
100
+ const selectedHarnesses = await clack.multiselect({
101
+ message: "Harnesses \u2014 which coding agents should receive config?",
102
+ options: harnessOptions,
103
+ initialValues: validExistingHarnesses && validExistingHarnesses.length > 0 ? validExistingHarnesses : ["universal"],
104
+ required: false
105
+ });
106
+ if (typeof selectedHarnesses === "symbol") {
107
+ clack.cancel("Setup cancelled.");
108
+ return;
109
+ }
110
+ const harnesses = selectedHarnesses;
111
+ const userConfig = {
112
+ choices,
113
+ ...excludedDocsets && { excluded_docsets: excludedDocsets },
114
+ ...harnesses.length > 0 && { harnesses }
115
+ };
116
+ const registry = createDefaultRegistry();
117
+ const logicalConfig = await resolve(userConfig, catalog, registry);
118
+ await writeUserConfig(projectRoot, userConfig);
119
+ const lockFile = {
120
+ version: 1,
121
+ generated_at: (/* @__PURE__ */ new Date()).toISOString(),
122
+ choices: userConfig.choices,
123
+ ...harnesses.length > 0 && { harnesses },
124
+ logical_config: logicalConfig
125
+ };
126
+ await writeLockFile(projectRoot, lockFile);
127
+ for (const harnessId of harnesses) {
128
+ const writer = getHarnessWriter(harnessId);
129
+ if (writer) {
130
+ await writer.install(logicalConfig, projectRoot);
131
+ }
132
+ }
133
+ const modifiedSkills = await writeInlineSkills(logicalConfig, projectRoot);
134
+ if (modifiedSkills.length > 0) {
135
+ clack.log.warn(
136
+ `The following skills have been locally modified and will NOT be updated:
137
+ ` + modifiedSkills.map((s) => ` - ${s}`).join("\n") + `
138
+
139
+ To use the latest defaults, remove .ade/skills/ and re-run setup.`
140
+ );
141
+ }
142
+ await installSkills(logicalConfig.skills, projectRoot);
143
+ if (logicalConfig.knowledge_sources.length > 0) {
144
+ clack.log.info(
145
+ "Knowledge sources selected. Initialize them separately:\n npx @codemcp/knowledge init"
146
+ );
147
+ }
148
+ for (const note of logicalConfig.setup_notes) {
149
+ clack.log.info(note);
150
+ }
151
+ clack.outro("Setup complete!");
152
+ }
153
+ function getValidInitialValue(facet, existingChoices) {
154
+ const value = existingChoices[facet.id];
155
+ if (typeof value !== "string") return void 0;
156
+ return facet.options.some((o) => o.id === value) ? value : void 0;
13
157
  }
14
- else if (command === "install") {
15
- const projectRoot = args[1] ?? process.cwd();
16
- let harnessIds;
17
- // Support --harness flag (comma-separated)
18
- if (args.includes("--harness")) {
19
- const val = args[args.indexOf("--harness") + 1];
20
- if (val) {
21
- harnessIds = val.split(",").map((s) => s.trim());
22
- }
23
- }
24
- await runInstall(projectRoot, harnessIds);
158
+ function getValidInitialValues(facet, existingChoices) {
159
+ const value = existingChoices[facet.id];
160
+ if (!Array.isArray(value)) return void 0;
161
+ const valid = value.filter((v) => facet.options.some((o) => o.id === v));
162
+ return valid.length > 0 ? valid : void 0;
25
163
  }
26
- else if (command === "--version" || command === "-v") {
27
- console.log(version);
164
+ function promptSelect(facet, existingChoices) {
165
+ const options = facet.options.map((o) => ({
166
+ value: o.id,
167
+ label: o.label,
168
+ hint: o.description
169
+ }));
170
+ if (!facet.required) {
171
+ options.push({ value: "__skip__", label: "Skip", hint: "" });
172
+ }
173
+ const initialValue = getValidInitialValue(facet, existingChoices);
174
+ return clack.select({
175
+ message: facet.label,
176
+ options,
177
+ ...initialValue !== void 0 && { initialValue }
178
+ });
28
179
  }
29
- else {
30
- const allIds = getHarnessIds();
31
- console.log(`ade v${version}`);
32
- console.log();
33
- console.log("Usage: ade <command> [options]");
34
- console.log();
35
- console.log("Commands:");
36
- console.log(" setup [dir] Interactive setup wizard (re-run to change selections)");
37
- console.log(" install [dir] Apply lock file to generate agent files (idempotent)");
38
- console.log();
39
- console.log("Options:");
40
- console.log(` --harness <ids> Comma-separated harnesses (${allIds.join(", ")})`);
41
- console.log(" -v, --version Show version");
42
- process.exitCode = command ? 1 : 0;
180
+ function promptMultiSelect(facet, existingChoices) {
181
+ const options = facet.options.map((o) => ({
182
+ value: o.id,
183
+ label: o.label,
184
+ hint: o.description
185
+ }));
186
+ const initialValues = getValidInitialValues(facet, existingChoices);
187
+ return clack.multiselect({
188
+ message: facet.label,
189
+ options,
190
+ required: false,
191
+ ...initialValues !== void 0 && { initialValues }
192
+ });
193
+ }
194
+
195
+ // src/commands/install.ts
196
+ import * as clack2 from "@clack/prompts";
197
+ import { readLockFile } from "@codemcp/ade-core";
198
+ import {
199
+ getHarnessWriter as getHarnessWriter2,
200
+ getHarnessIds,
201
+ installSkills as installSkills2,
202
+ writeInlineSkills as writeInlineSkills2
203
+ } from "@codemcp/ade-harnesses";
204
+ async function runInstall(projectRoot, harnessIds) {
205
+ clack2.intro("ade install");
206
+ const lockFile = await readLockFile(projectRoot);
207
+ if (!lockFile) {
208
+ throw new Error("config.lock.yaml not found. Run `ade setup` first.");
209
+ }
210
+ const ids = harnessIds ?? lockFile.harnesses ?? ["universal"];
211
+ const validIds = getHarnessIds();
212
+ for (const id of ids) {
213
+ if (!validIds.includes(id)) {
214
+ throw new Error(
215
+ `Unknown harness "${id}". Available: ${validIds.join(", ")}`
216
+ );
217
+ }
218
+ }
219
+ const logicalConfig = lockFile.logical_config;
220
+ for (const id of ids) {
221
+ const writer = getHarnessWriter2(id);
222
+ if (writer) {
223
+ await writer.install(logicalConfig, projectRoot);
224
+ }
225
+ }
226
+ const modifiedSkills = await writeInlineSkills2(logicalConfig, projectRoot);
227
+ if (modifiedSkills.length > 0) {
228
+ clack2.log.warn(
229
+ `The following skills have been locally modified and will NOT be updated:
230
+ ` + modifiedSkills.map((s) => ` - ${s}`).join("\n") + `
231
+
232
+ To use the latest defaults, remove .ade/skills/ and re-run install.`
233
+ );
234
+ }
235
+ await installSkills2(logicalConfig.skills, projectRoot);
236
+ if (logicalConfig.knowledge_sources.length > 0) {
237
+ clack2.log.info(
238
+ "Knowledge sources configured. Initialize them separately:\n npx @codemcp/knowledge init"
239
+ );
240
+ }
241
+ clack2.outro("Install complete!");
242
+ }
243
+
244
+ // src/index.ts
245
+ import { getDefaultCatalog } from "@codemcp/ade-core";
246
+ import { getHarnessIds as getHarnessIds2 } from "@codemcp/ade-harnesses";
247
+ var args = process.argv.slice(2);
248
+ var command = args[0];
249
+ if (command === "setup") {
250
+ const projectRoot = args[1] ?? process.cwd();
251
+ const catalog = getDefaultCatalog();
252
+ await runSetup(projectRoot, catalog);
253
+ } else if (command === "install") {
254
+ const projectRoot = args[1] ?? process.cwd();
255
+ let harnessIds;
256
+ if (args.includes("--harness")) {
257
+ const val = args[args.indexOf("--harness") + 1];
258
+ if (val) {
259
+ harnessIds = val.split(",").map((s) => s.trim());
260
+ }
261
+ }
262
+ await runInstall(projectRoot, harnessIds);
263
+ } else if (command === "--version" || command === "-v") {
264
+ console.log(version);
265
+ } else {
266
+ const allIds = getHarnessIds2();
267
+ console.log(`ade v${version}`);
268
+ console.log();
269
+ console.log("Usage: ade <command> [options]");
270
+ console.log();
271
+ console.log("Commands:");
272
+ console.log(
273
+ " setup [dir] Interactive setup wizard (re-run to change selections)"
274
+ );
275
+ console.log(
276
+ " install [dir] Apply lock file to generate agent files (idempotent)"
277
+ );
278
+ console.log();
279
+ console.log("Options:");
280
+ console.log(
281
+ ` --harness <ids> Comma-separated harnesses (${allIds.join(", ")})`
282
+ );
283
+ console.log(" -v, --version Show version");
284
+ process.exitCode = command ? 1 : 0;
43
285
  }
package/package.json CHANGED
@@ -6,35 +6,37 @@
6
6
  "bin": {
7
7
  "ade": "dist/index.js"
8
8
  },
9
+ "files": [
10
+ "dist"
11
+ ],
9
12
  "publishConfig": {
10
13
  "access": "public"
11
14
  },
12
15
  "dependencies": {
13
16
  "@clack/prompts": "^1.1.0",
14
- "@codemcp/ade-core": "0.2.0",
15
- "@codemcp/ade-harnesses": "0.2.0"
17
+ "@codemcp/ade-harnesses": "0.2.2",
18
+ "@codemcp/ade-core": "0.2.2"
16
19
  },
17
20
  "devDependencies": {
18
21
  "@codemcp/knowledge": "2.1.0",
19
- "@typescript-eslint/eslint-plugin": "^8.21.0",
20
- "@typescript-eslint/parser": "^8.21.0",
21
- "eslint": "^9.18.0",
22
- "eslint-config-prettier": "^10.0.1",
22
+ "oxlint": "^1.0.0",
23
23
  "prettier": "^3.4.2",
24
- "rimraf": "^6.0.1",
25
- "typescript": "^5.7.3"
24
+ "rimraf": "^6.1.3",
25
+ "tsup": "^8.3.0",
26
+ "typescript": "^5.9.3",
27
+ "vitest": "^3.2.4"
26
28
  },
27
- "version": "0.2.0",
29
+ "version": "0.2.2",
28
30
  "scripts": {
29
- "build": "tsc -p tsconfig.build.json",
31
+ "build": "tsup",
30
32
  "clean:build": "rimraf ./dist",
31
- "dev": "nodemon",
32
- "lint": "eslint .",
33
- "lint:fix": "eslint --fix .",
33
+ "dev": "tsup --watch",
34
+ "lint": "oxlint .",
35
+ "lint:fix": "oxlint --fix .",
34
36
  "format": "prettier --check .",
35
37
  "format:fix": "prettier --write .",
36
38
  "test": "vitest --run",
37
39
  "test:watch": "vitest",
38
- "typecheck": "tsc"
40
+ "typecheck": "tsc --noEmit"
39
41
  }
40
42
  }
package/.prettierignore DELETED
@@ -1 +0,0 @@
1
- dist
@@ -1,4 +0,0 @@
1
-
2
- > @codemcp/ade-cli@0.2.0 build /home/runner/work/ade/ade/packages/cli
3
- > tsc -p tsconfig.build.json
4
-
@@ -1,6 +0,0 @@
1
-
2
- > @codemcp/ade-cli@0.2.0 format /home/runner/work/ade/ade/packages/cli
3
- > prettier --check .
4
-
5
- Checking formatting...
6
- All matched files use Prettier code style!
@@ -1,4 +0,0 @@
1
-
2
- > @codemcp/ade-cli@0.2.0 lint /home/runner/work/ade/ade/packages/cli
3
- > eslint .
4
-