@codemcp/ade-cli 0.1.1 → 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.
@@ -1,4 +0,0 @@
1
-
2
- > @codemcp/ade-cli@0.1.1 typecheck /home/runner/work/ade/ade/packages/cli
3
- > tsc
4
-
@@ -1 +0,0 @@
1
- export declare function runInstall(projectRoot: string, harnessIds?: string[]): Promise<void>;
@@ -1,39 +0,0 @@
1
- import * as clack from "@clack/prompts";
2
- import { readLockFile } from "@codemcp/ade-core";
3
- import { getHarnessWriter, getHarnessIds, installSkills, writeInlineSkills } from "@codemcp/ade-harnesses";
4
- export async function runInstall(projectRoot, harnessIds) {
5
- clack.intro("ade install");
6
- const lockFile = await readLockFile(projectRoot);
7
- if (!lockFile) {
8
- throw new Error("config.lock.yaml not found. Run `ade setup` first.");
9
- }
10
- // Determine which harnesses to install for:
11
- // 1. --harness flag (comma-separated)
12
- // 2. harnesses saved in the lock file
13
- // 3. default: universal
14
- const ids = harnessIds ?? lockFile.harnesses ?? ["universal"];
15
- const validIds = getHarnessIds();
16
- for (const id of ids) {
17
- if (!validIds.includes(id)) {
18
- throw new Error(`Unknown harness "${id}". Available: ${validIds.join(", ")}`);
19
- }
20
- }
21
- const logicalConfig = lockFile.logical_config;
22
- for (const id of ids) {
23
- const writer = getHarnessWriter(id);
24
- if (writer) {
25
- await writer.install(logicalConfig, projectRoot);
26
- }
27
- }
28
- const modifiedSkills = await writeInlineSkills(logicalConfig, projectRoot);
29
- if (modifiedSkills.length > 0) {
30
- clack.log.warn(`The following skills have been locally modified and will NOT be updated:\n` +
31
- modifiedSkills.map((s) => ` - ${s}`).join("\n") +
32
- `\n\nTo use the latest defaults, remove .ade/skills/ and re-run install.`);
33
- }
34
- await installSkills(logicalConfig.skills, projectRoot);
35
- if (logicalConfig.knowledge_sources.length > 0) {
36
- clack.log.info("Knowledge sources configured. Initialize them separately:\n npx @codemcp/knowledge init");
37
- }
38
- clack.outro("Install complete!");
39
- }
@@ -1,2 +0,0 @@
1
- import { type Catalog } from "@codemcp/ade-core";
2
- export declare function runSetup(projectRoot: string, catalog: Catalog): Promise<void>;
@@ -1,177 +0,0 @@
1
- import * as clack from "@clack/prompts";
2
- import { readUserConfig, writeUserConfig, writeLockFile, resolve, collectDocsets, createDefaultRegistry, getFacet, getOption, sortFacets, getVisibleOptions } from "@codemcp/ade-core";
3
- import { allHarnessWriters, getHarnessWriter, installSkills, writeInlineSkills } from "@codemcp/ade-harnesses";
4
- export async function runSetup(projectRoot, catalog) {
5
- clack.intro("ade setup");
6
- const existingConfig = await readUserConfig(projectRoot);
7
- const existingChoices = existingConfig?.choices ?? {};
8
- // Warn about stale choices that reference options no longer in the catalog
9
- for (const [facetId, value] of Object.entries(existingChoices)) {
10
- const facet = getFacet(catalog, facetId);
11
- if (!facet)
12
- continue;
13
- const ids = Array.isArray(value) ? value : [value];
14
- for (const optionId of ids) {
15
- if (!getOption(facet, optionId)) {
16
- clack.log.warn(`Previously selected option "${optionId}" is no longer available in facet "${facet.label}".`);
17
- }
18
- }
19
- }
20
- const choices = {};
21
- const sortedFacets = sortFacets(catalog);
22
- for (const facet of sortedFacets) {
23
- const visibleOptions = getVisibleOptions(facet, choices, catalog);
24
- if (visibleOptions.length === 0)
25
- continue;
26
- const visibleFacet = { ...facet, options: visibleOptions };
27
- if (facet.multiSelect) {
28
- const selected = await promptMultiSelect(visibleFacet, existingChoices);
29
- if (typeof selected === "symbol") {
30
- clack.cancel("Setup cancelled.");
31
- return;
32
- }
33
- if (selected.length > 0) {
34
- choices[facet.id] = selected;
35
- }
36
- }
37
- else {
38
- const selected = await promptSelect(visibleFacet, existingChoices);
39
- if (typeof selected === "symbol") {
40
- clack.cancel("Setup cancelled.");
41
- return;
42
- }
43
- if (typeof selected === "string" && selected !== "__skip__") {
44
- choices[facet.id] = selected;
45
- }
46
- }
47
- }
48
- // Docset confirmation step: collect implied docsets, let user deselect
49
- const impliedDocsets = collectDocsets(choices, catalog);
50
- let excludedDocsets;
51
- if (impliedDocsets.length > 0) {
52
- const selected = await clack.multiselect({
53
- message: "Documentation — deselect any you don't need",
54
- options: impliedDocsets.map((d) => ({
55
- value: d.id,
56
- label: d.label,
57
- hint: d.description
58
- })),
59
- initialValues: impliedDocsets.map((d) => d.id),
60
- required: false
61
- });
62
- if (typeof selected === "symbol") {
63
- clack.cancel("Setup cancelled.");
64
- return;
65
- }
66
- const selectedSet = new Set(selected);
67
- const excluded = impliedDocsets
68
- .filter((d) => !selectedSet.has(d.id))
69
- .map((d) => d.id);
70
- if (excluded.length > 0) {
71
- excludedDocsets = excluded;
72
- }
73
- }
74
- // Harness selection — multi-select from all available harnesses
75
- const existingHarnesses = existingConfig?.harnesses;
76
- const harnessOptions = allHarnessWriters.map((w) => ({
77
- value: w.id,
78
- label: w.label,
79
- hint: w.description
80
- }));
81
- const validExistingHarnesses = existingHarnesses?.filter((h) => allHarnessWriters.some((w) => w.id === h));
82
- const selectedHarnesses = await clack.multiselect({
83
- message: "Harnesses — which coding agents should receive config?",
84
- options: harnessOptions,
85
- initialValues: validExistingHarnesses && validExistingHarnesses.length > 0
86
- ? validExistingHarnesses
87
- : ["universal"],
88
- required: false
89
- });
90
- if (typeof selectedHarnesses === "symbol") {
91
- clack.cancel("Setup cancelled.");
92
- return;
93
- }
94
- const harnesses = selectedHarnesses;
95
- const userConfig = {
96
- choices,
97
- ...(excludedDocsets && { excluded_docsets: excludedDocsets }),
98
- ...(harnesses.length > 0 && { harnesses })
99
- };
100
- const registry = createDefaultRegistry();
101
- const logicalConfig = await resolve(userConfig, catalog, registry);
102
- await writeUserConfig(projectRoot, userConfig);
103
- const lockFile = {
104
- version: 1,
105
- generated_at: new Date().toISOString(),
106
- choices: userConfig.choices,
107
- ...(harnesses.length > 0 && { harnesses }),
108
- logical_config: logicalConfig
109
- };
110
- await writeLockFile(projectRoot, lockFile);
111
- // Install to all selected harnesses
112
- for (const harnessId of harnesses) {
113
- const writer = getHarnessWriter(harnessId);
114
- if (writer) {
115
- await writer.install(logicalConfig, projectRoot);
116
- }
117
- }
118
- const modifiedSkills = await writeInlineSkills(logicalConfig, projectRoot);
119
- if (modifiedSkills.length > 0) {
120
- clack.log.warn(`The following skills have been locally modified and will NOT be updated:\n` +
121
- modifiedSkills.map((s) => ` - ${s}`).join("\n") +
122
- `\n\nTo use the latest defaults, remove .ade/skills/ and re-run setup.`);
123
- }
124
- await installSkills(logicalConfig.skills, projectRoot);
125
- if (logicalConfig.knowledge_sources.length > 0) {
126
- clack.log.info("Knowledge sources selected. Initialize them separately:\n npx @codemcp/knowledge init");
127
- }
128
- for (const note of logicalConfig.setup_notes) {
129
- clack.log.info(note);
130
- }
131
- clack.outro("Setup complete!");
132
- }
133
- function getValidInitialValue(facet, existingChoices) {
134
- const value = existingChoices[facet.id];
135
- if (typeof value !== "string")
136
- return undefined;
137
- // Only set initialValue if the option still exists in the catalog
138
- return facet.options.some((o) => o.id === value) ? value : undefined;
139
- }
140
- function getValidInitialValues(facet, existingChoices) {
141
- const value = existingChoices[facet.id];
142
- if (!Array.isArray(value))
143
- return undefined;
144
- // Only include options that still exist in the catalog
145
- const valid = value.filter((v) => facet.options.some((o) => o.id === v));
146
- return valid.length > 0 ? valid : undefined;
147
- }
148
- function promptSelect(facet, existingChoices) {
149
- const options = facet.options.map((o) => ({
150
- value: o.id,
151
- label: o.label,
152
- hint: o.description
153
- }));
154
- if (!facet.required) {
155
- options.push({ value: "__skip__", label: "Skip", hint: "" });
156
- }
157
- const initialValue = getValidInitialValue(facet, existingChoices);
158
- return clack.select({
159
- message: facet.label,
160
- options,
161
- ...(initialValue !== undefined && { initialValue })
162
- });
163
- }
164
- function promptMultiSelect(facet, existingChoices) {
165
- const options = facet.options.map((o) => ({
166
- value: o.id,
167
- label: o.label,
168
- hint: o.description
169
- }));
170
- const initialValues = getValidInitialValues(facet, existingChoices);
171
- return clack.multiselect({
172
- message: facet.label,
173
- options,
174
- required: false,
175
- ...(initialValues !== undefined && { initialValues })
176
- });
177
- }
@@ -1,12 +0,0 @@
1
- import type { KnowledgeSource } from "@codemcp/ade-core";
2
- /**
3
- * Install knowledge sources using the @codemcp/knowledge programmatic API.
4
- *
5
- * For each knowledge source:
6
- * 1. Creates a docset config entry via `createDocset`
7
- * 2. Initializes (downloads) the docset via `initDocset`
8
- *
9
- * Errors on individual sources are logged and skipped so that one failure
10
- * doesn't block the rest.
11
- */
12
- export declare function installKnowledge(sources: KnowledgeSource[], projectRoot: string): Promise<void>;
@@ -1,38 +0,0 @@
1
- import { createDocset, initDocset } from "@codemcp/knowledge/packages/cli/dist/exports.js";
2
- /**
3
- * Install knowledge sources using the @codemcp/knowledge programmatic API.
4
- *
5
- * For each knowledge source:
6
- * 1. Creates a docset config entry via `createDocset`
7
- * 2. Initializes (downloads) the docset via `initDocset`
8
- *
9
- * Errors on individual sources are logged and skipped so that one failure
10
- * doesn't block the rest.
11
- */
12
- export async function installKnowledge(sources, projectRoot) {
13
- if (sources.length === 0)
14
- return;
15
- for (const source of sources) {
16
- try {
17
- await createDocset({
18
- id: source.name,
19
- name: source.description,
20
- preset: "git-repo",
21
- url: source.origin
22
- }, { cwd: projectRoot });
23
- }
24
- catch (err) {
25
- console.warn(`Warning: failed to create docset "${source.name}":`, err instanceof Error ? err.message : err);
26
- continue;
27
- }
28
- try {
29
- await initDocset({
30
- docsetId: source.name,
31
- cwd: projectRoot
32
- });
33
- }
34
- catch (err) {
35
- console.warn(`Warning: failed to initialize docset "${source.name}":`, err instanceof Error ? err.message : err);
36
- }
37
- }
38
- }
package/dist/version.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const version = "0.0.0-development";
package/dist/version.js DELETED
@@ -1 +0,0 @@
1
- export const version = "0.0.0-development";
package/eslint.config.mjs DELETED
@@ -1,40 +0,0 @@
1
- import js from "@eslint/js";
2
- import { parser, configs } from "typescript-eslint";
3
- import prettier from "eslint-config-prettier";
4
-
5
- export default [
6
- js.configs.recommended,
7
- ...configs.recommended,
8
- prettier,
9
- {
10
- // Config for TypeScript files
11
- files: ["**/*.{ts,tsx}"],
12
- languageOptions: {
13
- parser,
14
- parserOptions: {
15
- project: ["./tsconfig.json", "./tsconfig.vitest.json"]
16
- }
17
- }
18
- },
19
- {
20
- // Config for JavaScript files - no TypeScript parsing
21
- files: ["**/*.{js,jsx}"],
22
- ...js.configs.recommended
23
- },
24
- {
25
- // Relaxed rules for test files
26
- files: ["**/*.test.ts", "**/*.spec.ts"],
27
- rules: {
28
- "@typescript-eslint/no-explicit-any": "off",
29
- "@typescript-eslint/no-unused-vars": "off"
30
- }
31
- },
32
- {
33
- ignores: [
34
- "**/node_modules/**",
35
- "**/dist/**",
36
- ".pnpm-store/**",
37
- "pnpm-lock.yaml"
38
- ]
39
- }
40
- ];
package/nodemon.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/nodemon.json",
3
- "watch": ["./src/**", "./node_modules/@mme/**/dist/**"],
4
- "ignoreRoot": [],
5
- "ext": "ts,js",
6
- "exec": "pnpm typecheck && pnpm build"
7
- }
@@ -1,267 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
- import { mkdtemp, rm, readFile, access } from "node:fs/promises";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
-
6
- vi.mock("@clack/prompts", () => ({
7
- intro: vi.fn(),
8
- outro: vi.fn(),
9
- select: vi.fn(),
10
- multiselect: vi.fn(),
11
- confirm: vi.fn(),
12
- isCancel: vi.fn().mockReturnValue(false),
13
- cancel: vi.fn(),
14
- spinner: vi.fn().mockReturnValue({ start: vi.fn(), stop: vi.fn() })
15
- }));
16
-
17
- import * as clack from "@clack/prompts";
18
- import { runSetup } from "./setup.js";
19
- import { readUserConfig, readLockFile } from "@codemcp/ade-core";
20
- import { getDefaultCatalog } from "../../../core/src/catalog/index.js";
21
-
22
- describe("architecture and practices facets integration", () => {
23
- let dir: string;
24
-
25
- beforeEach(async () => {
26
- vi.clearAllMocks();
27
- dir = await mkdtemp(join(tmpdir(), "ade-conventions-"));
28
- });
29
-
30
- afterEach(async () => {
31
- await rm(dir, { recursive: true, force: true });
32
- });
33
-
34
- it(
35
- "writes SKILL.md files and installs inline skills for tanstack architecture",
36
- { timeout: 60_000 },
37
- async () => {
38
- const catalog = getDefaultCatalog();
39
-
40
- // Facet order: process (select), architecture (select), practices (multiselect)
41
- vi.mocked(clack.select)
42
- .mockResolvedValueOnce("codemcp-workflows") // process
43
- .mockResolvedValueOnce("tanstack"); // architecture
44
- vi.mocked(clack.multiselect)
45
- .mockResolvedValueOnce([]) // practices: none
46
- .mockResolvedValueOnce([]) // backpressure: none
47
- .mockResolvedValueOnce([]) // docsets: deselect all
48
- .mockResolvedValueOnce(["claude-code"]); // harnesses
49
-
50
- await runSetup(dir, catalog);
51
-
52
- // Inline skills should have SKILL.md in .ade/skills/ (staging area)
53
- for (const skill of [
54
- "tanstack-architecture",
55
- "tanstack-design",
56
- "tanstack-code",
57
- "tanstack-testing"
58
- ]) {
59
- const skillMd = await readFile(
60
- join(dir, ".ade", "skills", skill, "SKILL.md"),
61
- "utf-8"
62
- );
63
- expect(skillMd).toContain(`name: ${skill}`);
64
- expect(skillMd).toContain("---");
65
- }
66
-
67
- // Inline skills should also be installed to .agentskills/skills/ by runAdd
68
- for (const skill of [
69
- "tanstack-architecture",
70
- "tanstack-design",
71
- "tanstack-code",
72
- "tanstack-testing"
73
- ]) {
74
- const installed = await readFile(
75
- join(dir, ".agentskills", "skills", skill, "SKILL.md"),
76
- "utf-8"
77
- );
78
- expect(installed).toContain(`name: ${skill}`);
79
- }
80
-
81
- // skills-lock.json should be created by runAdd
82
- const lockRaw = await readFile(join(dir, "skills-lock.json"), "utf-8");
83
- const skillsLock = JSON.parse(lockRaw);
84
- expect(skillsLock.skills).toBeDefined();
85
-
86
- // skills-server MCP server should be in .mcp.json
87
- const mcpJson = JSON.parse(
88
- await readFile(join(dir, ".mcp.json"), "utf-8")
89
- );
90
- expect(mcpJson.mcpServers["agentskills"]).toMatchObject({
91
- command: "npx",
92
- args: ["-y", "@codemcp/skills-server"]
93
- });
94
- }
95
- );
96
-
97
- it("writes skills for multiple selected practices", async () => {
98
- const catalog = getDefaultCatalog();
99
-
100
- // Facet order: process (select), architecture (select), practices (multiselect)
101
- vi.mocked(clack.select)
102
- .mockResolvedValueOnce("native-agents-md") // process
103
- .mockResolvedValueOnce("__skip__"); // architecture: skip
104
- vi.mocked(clack.multiselect)
105
- .mockResolvedValueOnce(["conventional-commits", "tdd-london"]) // practices
106
- .mockResolvedValueOnce([]) // docsets: deselect all (conventional-commits has docset)
107
- .mockResolvedValueOnce(["claude-code"]); // harnesses
108
-
109
- await runSetup(dir, catalog);
110
-
111
- // Both inline skills should exist in .ade/skills/ (staging)
112
- const commits = await readFile(
113
- join(dir, ".ade", "skills", "conventional-commits", "SKILL.md"),
114
- "utf-8"
115
- );
116
- expect(commits).toContain("name: conventional-commits");
117
- expect(commits).toContain("Conventional Commits");
118
-
119
- const tdd = await readFile(
120
- join(dir, ".ade", "skills", "tdd-london", "SKILL.md"),
121
- "utf-8"
122
- );
123
- expect(tdd).toContain("name: tdd-london");
124
- expect(tdd).toContain("London");
125
-
126
- // Both should be installed to .agentskills/skills/
127
- await expect(
128
- access(join(dir, ".agentskills", "skills", "conventional-commits"))
129
- ).resolves.toBeUndefined();
130
- await expect(
131
- access(join(dir, ".agentskills", "skills", "tdd-london"))
132
- ).resolves.toBeUndefined();
133
-
134
- // config.yaml should have array of choices under practices
135
- const config = await readUserConfig(dir);
136
- expect(config!.choices.practices).toEqual([
137
- "conventional-commits",
138
- "tdd-london"
139
- ]);
140
-
141
- // Lock file should reflect both
142
- const lock = await readLockFile(dir);
143
- expect(lock!.logical_config.skills.length).toBeGreaterThanOrEqual(2);
144
- });
145
-
146
- it("writes ADR skill with template content", async () => {
147
- const catalog = getDefaultCatalog();
148
-
149
- // Facet order: process (select), architecture (select), practices (multiselect)
150
- vi.mocked(clack.select)
151
- .mockResolvedValueOnce("native-agents-md") // process
152
- .mockResolvedValueOnce("__skip__"); // architecture: skip
153
- vi.mocked(clack.multiselect)
154
- .mockResolvedValueOnce(["adr-nygard"])
155
- .mockResolvedValueOnce(["claude-code"]); // harnesses
156
-
157
- await runSetup(dir, catalog);
158
-
159
- const adr = await readFile(
160
- join(dir, ".ade", "skills", "adr-nygard", "SKILL.md"),
161
- "utf-8"
162
- );
163
- expect(adr).toContain("name: adr-nygard");
164
- expect(adr).toContain("## Context");
165
- expect(adr).toContain("## Decision");
166
- expect(adr).toContain("## Consequences");
167
- });
168
-
169
- it("skips both architecture and practices when none selected", async () => {
170
- const catalog = getDefaultCatalog();
171
-
172
- // Facet order: process (select), architecture (select), practices (multiselect)
173
- vi.mocked(clack.select)
174
- .mockResolvedValueOnce("native-agents-md") // process
175
- .mockResolvedValueOnce("__skip__"); // architecture: skip
176
- vi.mocked(clack.multiselect)
177
- .mockResolvedValueOnce([]) // practices: none
178
- .mockResolvedValueOnce(["claude-code"]); // harnesses
179
-
180
- await runSetup(dir, catalog);
181
-
182
- // No .ade directory should exist
183
- await expect(access(join(dir, ".ade"))).rejects.toThrow();
184
-
185
- // config.yaml should not have architecture or practices keys
186
- const config = await readUserConfig(dir);
187
- expect(config!.choices).not.toHaveProperty("architecture");
188
- expect(config!.choices).not.toHaveProperty("practices");
189
- });
190
-
191
- it("exposes practices as skills, not instructions", async () => {
192
- const catalog = getDefaultCatalog();
193
-
194
- // Facet order: process (select), architecture (select), practices (multiselect)
195
- vi.mocked(clack.select)
196
- .mockResolvedValueOnce("native-agents-md") // process
197
- .mockResolvedValueOnce("__skip__"); // architecture: skip
198
- vi.mocked(clack.multiselect)
199
- .mockResolvedValueOnce(["tdd-london"])
200
- .mockResolvedValueOnce(["claude-code"]); // harnesses
201
-
202
- await runSetup(dir, catalog);
203
-
204
- // Practice produces a skill, not an instruction
205
- const skillMd = await readFile(
206
- join(dir, ".ade", "skills", "tdd-london", "SKILL.md"),
207
- "utf-8"
208
- );
209
- expect(skillMd).toContain("name: tdd-london");
210
-
211
- // Lock file should have skill but no practice-specific instructions
212
- const lock = await readLockFile(dir);
213
- expect(lock!.logical_config.skills.length).toBeGreaterThanOrEqual(1);
214
- // Only process-facet instructions should be present (from native-agents-md)
215
- for (const instruction of lock!.logical_config.instructions) {
216
- expect(instruction).not.toContain("tdd-london");
217
- }
218
- });
219
-
220
- it(
221
- "combines architecture and practices selections",
222
- { timeout: 60_000 },
223
- async () => {
224
- const catalog = getDefaultCatalog();
225
-
226
- // Facet order: process (select), architecture (select), practices (multiselect)
227
- vi.mocked(clack.select)
228
- .mockResolvedValueOnce("codemcp-workflows") // process
229
- .mockResolvedValueOnce("tanstack"); // architecture
230
- vi.mocked(clack.multiselect)
231
- .mockResolvedValueOnce(["tdd-london", "conventional-commits"]) // practices
232
- .mockResolvedValueOnce([]) // backpressure: none
233
- .mockResolvedValueOnce([]) // docsets: deselect all
234
- .mockResolvedValueOnce(["claude-code"]); // harnesses
235
-
236
- await runSetup(dir, catalog);
237
-
238
- // Architecture skills should exist
239
- const archSkill = await readFile(
240
- join(dir, ".ade", "skills", "tanstack-architecture", "SKILL.md"),
241
- "utf-8"
242
- );
243
- expect(archSkill).toContain("name: tanstack-architecture");
244
-
245
- // Practice skills should exist
246
- const tddSkill = await readFile(
247
- join(dir, ".ade", "skills", "tdd-london", "SKILL.md"),
248
- "utf-8"
249
- );
250
- expect(tddSkill).toContain("name: tdd-london");
251
-
252
- const commitsSkill = await readFile(
253
- join(dir, ".ade", "skills", "conventional-commits", "SKILL.md"),
254
- "utf-8"
255
- );
256
- expect(commitsSkill).toContain("name: conventional-commits");
257
-
258
- // config.yaml should have both architecture and practices
259
- const config = await readUserConfig(dir);
260
- expect(config!.choices.architecture).toBe("tanstack");
261
- expect(config!.choices.practices).toEqual([
262
- "tdd-london",
263
- "conventional-commits"
264
- ]);
265
- }
266
- );
267
- });