From 54955e1bca75072303bbfe567c7a6647f46483b9 Mon Sep 17 00:00:00 2001 From: bmad Date: Sat, 28 Nov 2026 17:02:46 -0600 Subject: [PATCH 1/2] chore: bump skills to 1.9.1, align v7 messaging, and check types on publish --- .github/workflows/publish.yml | 1 + README.md | 19 +++++----- agents.json | 6 ++-- messages.yaml | 29 +++++++-------- package-lock.json | 67 ++++++++++++++++++++--------------- package.json | 8 ++--- src/cli.js | 2 +- tools/generate-agents.js | 39 +++++++++++++++++--- 8 files changed, 106 insertions(+), 65 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5934d2a..8428fe9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -19,5 +19,6 @@ jobs: node-version: 22 registry-url: https://registry.npmjs.org - run: npm ci + - run: npm run check - run: npm test - run: npm publish --provenance --access public --tag next diff --git a/README.md b/README.md index 9bd6ff9..3abaae2 100644 --- a/README.md +++ b/README.md @@ -71,41 +71,40 @@ A code can carry a branch or tag: `-m core-tools#dev,method#dev` installs both f ### Your own modules -`--modules` also takes the folder of a module that is not on the list: anything with a `/` is a source the skills CLI can install from, such as `acme/our-modules/skills/widgets`, `acme/our-modules/skills/widgets#dev`, a git URL or a local path (`./widgets`, made absolute against the folder you run from). It installs whole, like the listed modules, to the agents you pick: `npx bmad-method install -m method,acme/our-modules/skills/widgets`. The folder must hold the module's record and its skills; the `bmad` skill reads the record on its next `bmad setup`. `update` re-adds it from the source and ref the project's `skills-lock.json` recorded for its record, so a module installed with `npx skills add` updates the same way. +`--modules` also takes the folder of a module that is not on the list: anything with a `/` is a source the skills CLI can install from, such as `acme/our-modules/skills/widgets`, `acme/our-modules/skills/widgets#dev`, a git URL or a local path (`./widgets`, made absolute against the folder you run from). It installs whole, like the listed modules, to the agents you pick: `npx bmad-method install -m method,acme/our-modules/skills/widgets`. The folder must hold the module's record and its skills; the BMad Agent reads the record on its next `bmad setup`. `update` re-adds it from the source and ref the project's `skills-lock.json` recorded for its record, so a module installed with `npx skills add` updates the same way. A 6.12 flag this installer dropped prints one line about it, then exits without installing. ## What the summary tells you -The summary names the project, the modules with their version and the coding agents, and asks you to open your coding agent there and tell it to run `bmad setup`. Setup asks the configuration questions, finishes the install, and shows each module's message about where to start. Configuration and customization belong to the `bmad` skill from then on; this installer never asks those questions. Anything that failed is listed above the summary. Below it are the update command, the command that repeats the install without prompts, and links to the blog, GitHub, Discord, YouTube and bmadcode.com. +The summary names the project, the modules with their version and the coding agents, and asks you to open your coding agent there and tell it to run `bmad setup`. Setup asks the configuration questions, finishes the install, and shows each module's message about where to start. Configuration and customization belong to the BMad Agent from then on; this installer never asks those questions. Anything that failed is listed above the summary. Below it are the update command, the command that repeats the install without prompts, and links to the blog, GitHub, Discord, YouTube and bmadcode.com. ## Updating -Three routes: ask the `bmad` skill, run `npx bmad-method update`, or run `npx skills update`. +Three routes: ask the BMad Agent, run `npx bmad-method update`, or run `npx skills update`. `npx bmad-method update` re-adds each installed module whole, one `npx skills add -s '*'` per module, to the agents whose folder in the project already holds BMad. A module installed from a branch or tag stays on it. It then prints the summary and any migrations for the version jump. A module that is not on the list, installed with `--modules ` or `npx skills add`, is re-added from the source and ref the project's `skills-lock.json` recorded for its record. One it cannot place, such as a well-known skill, is named; `npx skills update` covers it, one skill and one clone at a time. A module re-added this way gets back any skill removed from it by hand. -After adding or updating any skill by any route, ask the `bmad` skill to update. Only it reconciles what is installed. +After adding or updating any skill by any route, ask the BMad Agent to update. Only it reconciles what is installed. ## Removing -`npx skills remove` removes skills. This installer has no uninstall command and never removes anything. +Ask the BMad Agent to remove a module (it previews every affected skill folder, lock entry, and `_bmad//`, and preserves `_bmad/custom/`), or run `npx skills remove` for individual skills. This installer has no uninstall command and never removes anything. ## Installing with the skills CLI directly -If you install with the skills CLI directly, ours or your own, install a module from its folder: `npx skills add bmad-code-org/BMAD-METHOD/skills/method --skill '*'` installs BMad Method, record included. Core tools (`skills/core-tools`) hold the `bmad` skill, so install them first. A module is its record skill plus the skills that record lists. The record is a `bmod-` skill, or, for a module of one skill, that skill itself. A record without its skills, or skills without their record, is a partial install: the `bmad` skill cannot see or run it. `npx bmad-method status` lists missing records and unmet requirements. +If you install with the skills CLI directly, ours or your own, install a module from its folder: `npx skills add bmad-code-org/BMAD-METHOD/skills/method --skill '*'` installs BMad Method, record included. Core tools (`skills/core-tools`) hold the `bmad` skill, so install them first. A module is its record skill plus the skills that record lists. The record is a `bmod-` skill, or, for a module of one skill, that skill itself. A record without its skills, or skills without their record, is a partial install: the BMad Agent cannot see or run it. `npx bmad-method status` lists missing records and unmet requirements. ## Troubleshooting -- `status` and `update` take 5 to 10 seconds. The `bmad` skill's setup script reads each module's record from GitHub on every call. -- `npx skills update` currently skips the `bmad` skill because BMAD-METHOD ships a second `bmad` SKILL.md in a test fixture. +- `status` and `update` take a few seconds. The `bmad` skill's setup script reads each module's record from GitHub in parallel on every call. - `npx skills update` re-adds skills without the agent list, so it can add agents whose folders happen to be in the project. `npx bmad-method update` passes the agents already holding BMad. - Symlink errors on Windows: add `--copy`. - `--debug` prints every child command with its output. ## Telemetry -The installer sends nothing. The skills CLI it runs sends two GET requests to `add-skill.vercel.sh`: an audit call to `https://add-skill.vercel.sh/audit` before an install, carrying the `owner/repo` and the skill names, and an install event to `https://add-skill.vercel.sh/t` after it, carrying the source, the skill names, the agent ids and the CLI version. The install event goes out only for a public GitHub repo. The audit call is not gated on repo visibility: it goes out for a private GitHub repo too. A local path sends neither. No file contents leave the machine. The install event carries the metadata this installer attaches: `{"installer":"bmad-method","version":""}`. +The installer sends nothing. The skills CLI it runs sends two GET requests to `www.skills.sh`: an audit call to `https://www.skills.sh/tele/audit` before an install, carrying the `owner/repo` and the skill names, and an install event to `https://www.skills.sh/tele/t` after it, carrying the source, the skill names, the agent ids and the CLI version. For a GitHub repository, both requests go out only when GitHub positively confirms it is public (private GitHub repos send neither; non-GitHub remote sources without a GitHub privacy check may still send the install event). A local path sends neither. No file contents leave the machine. The install event carries the metadata this installer attaches: `{"installer":"bmad-method","version":""}`. `--no-telemetry` sets `DO_NOT_TRACK=1` in every skills CLI process the installer starts. That also removes those installs from the install counts on skills.sh. @@ -113,7 +112,7 @@ The installer sends nothing. The skills CLI it runs sends two GET requests to `a ## Reproducible installs -The skills CLI writes `skills-lock.json` in the project. Commit it. `npx skills experimental_install` restores the skills recorded there. +The skills CLI writes `skills-lock.json` in the project, recording each skill's commit and content hash. Commit it. `npx skills install` (or `npx skills experimental_install`, with `--frozen-lockfile` in CI) restores the exact skills recorded there. ## Testing diff --git a/agents.json b/agents.json index 64f3e22..939fcdc 100644 --- a/agents.json +++ b/agents.json @@ -1,5 +1,5 @@ { - "skillsVersion": "1.7.0", + "skillsVersion": "1.9.1", "agents": [ { "id": "aider-desk", @@ -226,7 +226,7 @@ { "id": "fx", "name": "fx", - "skillsDir": ".fx/skills", + "skillsDir": ".agents/skills", "detect": [ "~/.fx" ] @@ -430,7 +430,7 @@ { "id": "pi", "name": "Pi", - "skillsDir": ".pi/skills", + "skillsDir": ".agents/skills", "detect": [ "~/.pi/agent" ] diff --git a/messages.yaml b/messages.yaml index 101e298..69a6a48 100644 --- a/messages.yaml +++ b/messages.yaml @@ -67,7 +67,8 @@ directoryConfirm: "Install into {directory}?" legacyManifest: |- Found an older BMad install at _bmad/_config/manifest.yaml. - This installer leaves it alone. + This installer leaves it alone. Back up _bmad/ and _bmad-output/ + first; bmad setup handles v6 cleanup and migrations. existingInstallPrompt: "BMad is already installed here. What do you want to do?" @@ -89,7 +90,7 @@ modulesRequired: "Also installing {modules}: a module you picked needs it." modulesKept: |- Still installed: {modules}. This installer never removes anything. - To remove a module, run npx skills remove with its skills. + Ask the BMad Agent to remove a module, or run npx skills remove. agentsPrompt: "Which coding agents should get the skills?" @@ -165,14 +166,14 @@ summaryModuleGroup: "{names} ({version})" summaryAgents: "Agents {agents}" summaryNextSetup: |- - Next: open your coding agent in this project and ask it to run - bmad setup, which finishes the install. Then, if you are unsure - what BMad and your installed modules can do, ask the bmad skill - what to do next. + Next: open your coding agent in this project and ask the BMad Agent + to run bmad setup, which finishes the install. Then, if you are + unsure what BMad and your installed modules can do, ask the BMad + Agent for a tour or what to do next. summaryNextCurrent: |- Next: if you are unsure what BMad and your installed modules can do, - ask the bmad skill in your coding agent what to do next. + ask the BMad Agent in your coding agent for a tour or what to do next. summaryNextOther: "Next: {next}" @@ -197,12 +198,12 @@ cancelled: "Cancelled. Anything already installed is still there." droppedFlags: custom-source: "--custom-source is gone. Install those with npx skills add ." - set: "--set is gone. The bmad setup skill asks these questions." - list-options: "--list-options is gone. The bmad setup skill asks these questions." - user-name: "--user-name is gone. The bmad setup skill asks these questions." - communication-language: "--communication-language is gone. The bmad setup skill asks these questions." - document-output-language: "--document-output-language is gone. The bmad setup skill asks these questions." - output-folder: "--output-folder is gone. The bmad setup skill asks these questions." + set: "--set is gone. The BMad Agent asks these questions during bmad setup." + list-options: "--list-options is gone. The BMad Agent asks these questions during bmad setup." + user-name: "--user-name is gone. The BMad Agent asks these questions during bmad setup." + communication-language: "--communication-language is gone. The BMad Agent asks these questions during bmad setup." + document-output-language: "--document-output-language is gone. The BMad Agent asks these questions during bmad setup." + output-folder: "--output-folder is gone. The BMad Agent asks these questions during bmad setup." channel: "--channel is gone. Modules install from each repo's main branch." all-stable: "--all-stable is gone. Modules install from each repo's main branch." all-next: "--all-next is gone. Modules install from each repo's main branch." @@ -213,4 +214,4 @@ droppedFlags: droppedUninstall: |- This installer does not remove anything. - Remove skills with npx skills remove. + Ask the BMad Agent to remove a module, or run npx skills remove. diff --git a/package-lock.json b/package-lock.json index 4aeb781..d1f9afc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,10 @@ "version": "7.0.0-next.0", "license": "MIT", "dependencies": { - "@clack/prompts": "^1.8.1", - "@vercel/detect-agent": "^1.2.5", - "cross-spawn": "^7.0.6", - "skills": "1.7.0", + "@clack/prompts": "^1.9.0", + "@vercel/detect-agent": "^1.2.7", + "cross-spawn": "^7.1.0", + "skills": "1.9.1", "yaml": "^2.9.1" }, "bin": { @@ -28,28 +28,29 @@ } }, "node_modules/@clack/core": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/@clack/core/-/core-1.5.1.tgz", - "integrity": "sha512-iHTrHA8MtVuLl2TfZySmcKv1qO2PoyC9Z7pfSDozEuV5vtY3/wcOPKJXlqJ5Oq2Cx5DDGQGAMVx6HZfRRoVEbQ==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@clack/core/-/core-1.6.0.tgz", + "integrity": "sha512-4GZynIB2IIe431odxesswvWTCP6orvqd6e2b07b3VFWBQRqUqIHc/EPIZwFoKS692QBp+ooPuXKaJV8g4kXuYA==", "license": "MIT", "dependencies": { + "fast-string-width": "^3.0.2", "fast-wrap-ansi": "^0.2.0", - "sisteransi": "^1.0.5" + "sisteransi": "^2.0.0" }, "engines": { "node": ">= 20.12.0" } }, "node_modules/@clack/prompts": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/@clack/prompts/-/prompts-1.8.1.tgz", - "integrity": "sha512-dlT1m5e/0yUL0kRNcQn7yGLVThkgbB0Ga/1AmfDDC/8ik6AIiSf2QLQO2zPYvefsHP0aFgxO93cVLCCfDp7kzQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@clack/prompts/-/prompts-1.9.0.tgz", + "integrity": "sha512-tEj8X2No2A1c9NDnZECxiiJ8TP3vmFlN9tLlLeSaMqVW4tUmVG2R4qpv/eP4zymWxnymYLkLcIYVV0VcWj3RCQ==", "license": "MIT", "dependencies": { - "@clack/core": "1.5.1", + "@clack/core": "1.6.0", "fast-string-width": "^3.0.2", "fast-wrap-ansi": "^0.2.0", - "sisteransi": "^1.0.5" + "sisteransi": "^2.0.0" }, "engines": { "node": ">= 20.12.0" @@ -88,9 +89,9 @@ } }, "node_modules/@vercel/detect-agent": { - "version": "1.2.5", - "resolved": "https://registry.npmjs.org/@vercel/detect-agent/-/detect-agent-1.2.5.tgz", - "integrity": "sha512-0krENrjuitlW8s6TJu0MlqCevyCU7K7JK63jZAf7xZ6n17tx+vUEwzHT3sTxawtwZxaW21hu+oFUpoOrm49FsQ==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@vercel/detect-agent/-/detect-agent-1.2.7.tgz", + "integrity": "sha512-5tWaC9V+u4SHcSMKBz9FQb3Dhl/1A2lQ6QqHovu8uQeb8dTyjEevpJMANm/uQEn/usYB63fpdjWYjkJ8/bGtjA==", "license": "Apache-2.0", "engines": { "node": ">=14" @@ -106,9 +107,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", - "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.1.0.tgz", + "integrity": "sha512-/PHUIV1x/hZLpJN8KmyV2aYkT8pll4RjQ59TmhwkL/9B4HdOtlBQ2pos6iB2cfVRzpGHk3HXlRa8sdVYrPjIYw==", "license": "MIT", "dependencies": { "path-key": "^3.1.0", @@ -170,6 +171,12 @@ "node": ">= 18" } }, + "node_modules/nostics": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/nostics/-/nostics-1.4.0.tgz", + "integrity": "sha512-WjXHOuNuzY3MPKOoCT2zL1Sa3cS2mOUe4o8F94JvBOH2cGfyNItbQmCb2pNHIxoodd5O+vtmmHq7PoSZVGgCHA==", + "license": "MIT" + }, "node_modules/path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", @@ -201,19 +208,23 @@ } }, "node_modules/sisteransi": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", - "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", - "license": "MIT" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-2.0.0.tgz", + "integrity": "sha512-2WCqLdt12eN6ehLI50S2/ZxoowXU3DD1KVPRyVP0WEsFahrGZZmCdq1K59qjJljMRIDTwx1D9YaRK+hDneBUMg==", + "license": "MIT", + "engines": { + "node": ">=20" + } }, "node_modules/skills": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/skills/-/skills-1.7.0.tgz", - "integrity": "sha512-OfePnDft+Xt9/tCoHdCUe5fkM8i+Q3QOSQO53hm7mKtsXyvc+CKOAAliVWZ484HS3cWx+6r+ob0AArixs3jYXw==", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/skills/-/skills-1.9.1.tgz", + "integrity": "sha512-apCGOld13FyVhv3282T/PmDKdtaH/UI5idOGvzAfhOEsFu5lR5ih+oaYk8QbruH8Zyxh2DgBJORnnmOpz5s1Rw==", "license": "MIT", "dependencies": { - "tar": "^7.5.20", - "yaml": "^2.8.3" + "nostics": "^1.4.0", + "tar": "^7.5.22", + "yaml": "^2.9.1" }, "bin": { "add-skill": "bin/cli.mjs", diff --git a/package.json b/package.json index 05813de..aab6923 100644 --- a/package.json +++ b/package.json @@ -31,11 +31,11 @@ "agents": "node tools/generate-agents.js" }, "dependencies": { - "@clack/prompts": "^1.8.1", - "cross-spawn": "^7.0.6", + "@clack/prompts": "^1.9.0", + "cross-spawn": "^7.1.0", "yaml": "^2.9.1", - "@vercel/detect-agent": "^1.2.5", - "skills": "1.7.0" + "@vercel/detect-agent": "^1.2.7", + "skills": "1.9.1" }, "devDependencies": { "typescript": "^5.9.0", diff --git a/src/cli.js b/src/cli.js index ce01131..803d353 100644 --- a/src/cli.js +++ b/src/cli.js @@ -49,7 +49,7 @@ Commands Flags -d, --directory Project directory, default the current one - -m, --modules Modules to install, e.g. method,cis, method#dev or acme/repo/folder + -m, --modules Modules to install, e.g. method,creative, method#dev or acme/repo/folder -t, --tools Comma-separated coding agent ids to install to --list-tools List the coding agent ids --tools takes -y, --yes Take the defaults and ask nothing diff --git a/tools/generate-agents.js b/tools/generate-agents.js index 7573922..302f6ef 100644 --- a/tools/generate-agents.js +++ b/tools/generate-agents.js @@ -1,6 +1,6 @@ // Writes agents.json from the agent table in the installed skills CLI bundle. Run it after every // `skills` version bump: `node tools/generate-agents.js`. test/agents.test.js fails until you do. -import { readFile, writeFile } from 'node:fs/promises' +import { readdir, readFile, writeFile } from 'node:fs/promises' import { createRequire } from 'node:module' import { dirname, join, posix } from 'node:path' import { fileURLToPath } from 'node:url' @@ -29,6 +29,34 @@ function portable(path) { return path } +/** + * Locates the bundled module holding the agent table (`dist/cli.mjs` in older skills builds, or a + * shared chunk under `dist/_chunks/` in newer split builds). + * @param {string} dir + * @returns {Promise} + */ +async function readAgentsBundle(dir) { + const candidates = [join(dir, 'dist', 'cli.mjs')] + const chunksDir = join(dir, 'dist', '_chunks') + try { + const entries = await readdir(chunksDir, { withFileTypes: true }) + for (const entry of entries) { + if (entry.isFile() && entry.name.endsWith('.mjs')) candidates.push(join(chunksDir, entry.name)) + } + } catch (err) { + if (/** @type {NodeJS.ErrnoException} */ (err)?.code !== 'ENOENT') throw err + } + for (const file of candidates) { + try { + const text = await readFile(file, 'utf8') + if (text.includes(AGENTS_START)) return text + } catch (err) { + if (/** @type {NodeJS.ErrnoException} */ (err)?.code !== 'ENOENT') throw err + } + } + throw new Error('agent table not found in the skills CLI bundle') +} + /** * Runs the bundle's agent table with a fake file system that answers "no" to every path, so each * detection checks every path it knows and the list of asked paths is its detection rule. Environment @@ -37,15 +65,16 @@ function portable(path) { * @returns {Promise} */ export async function agentsFromBundle(bundle) { - const start = bundle.indexOf(TABLE_START) - const tableAt = bundle.indexOf(AGENTS_START, start) - const end = bundle.indexOf('\n};\n', tableAt) + const tableAt = bundle.indexOf(AGENTS_START) + const start = tableAt === -1 ? -1 : bundle.lastIndexOf(TABLE_START, tableAt) + const end = tableAt === -1 ? -1 : bundle.indexOf('\n};\n', tableAt) if (start === -1 || tableAt === -1 || end === -1) throw new Error('agent table not found in the skills CLI bundle') /** @type {string[]} */ let asked = [] const context = vm.createContext({ homedir: () => HOME, + platform: () => 'linux', join: posix.join, existsSync: (/** @type {string} */ path) => (asked.push(path), false), readFileSync: () => { @@ -71,7 +100,7 @@ export async function agentsFromBundle(bundle) { export async function generateAgents() { const dir = skillsPackageDir() const pkg = JSON.parse(await readFile(join(dir, 'package.json'), 'utf8')) - const bundle = await readFile(join(dir, 'dist', 'cli.mjs'), 'utf8') + const bundle = await readAgentsBundle(dir) return { skillsVersion: pkg.version, agents: await agentsFromBundle(bundle) } } From b298f5442c3982dbd86450ca6b388c9bc93e9c81 Mon Sep 17 00:00:00 2001 From: bmad Date: Sat, 28 Nov 2026 17:11:07 -0600 Subject: [PATCH 2/2] fix: ignore missing lockfile entries in skills list and harden review findings --- README.md | 4 +-- src/installed.js | 5 ++-- src/skills-cli.js | 15 +++++++++-- test/agents.test.js | 51 +++++++++++++++++++++++++++++++++-- test/cli.test.js | 5 ++-- test/commands/install.test.js | 33 +++++++++++++++++++++++ test/installed.test.js | 15 +++++++++++ test/messages.test.js | 3 ++- test/skills-cli.test.js | 9 +++++++ tools/generate-agents.js | 34 ++++++++++++++++------- 10 files changed, 153 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 3abaae2..213fff3 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ If you install with the skills CLI directly, ours or your own, install a module ## Telemetry -The installer sends nothing. The skills CLI it runs sends two GET requests to `www.skills.sh`: an audit call to `https://www.skills.sh/tele/audit` before an install, carrying the `owner/repo` and the skill names, and an install event to `https://www.skills.sh/tele/t` after it, carrying the source, the skill names, the agent ids and the CLI version. For a GitHub repository, both requests go out only when GitHub positively confirms it is public (private GitHub repos send neither; non-GitHub remote sources without a GitHub privacy check may still send the install event). A local path sends neither. No file contents leave the machine. The install event carries the metadata this installer attaches: `{"installer":"bmad-method","version":""}`. +The installer sends nothing. The skills CLI it runs sends two GET requests to `www.skills.sh`: an audit call to `https://www.skills.sh/tele/audit` before an install, carrying the `owner/repo` and the skill names, and an install event to `https://www.skills.sh/tele/t` after it, carrying the source, the skill names, their repository-relative `SKILL.md` paths (`skillFiles`), the agent ids and the CLI version. For a GitHub repository, both requests go out only when GitHub positively confirms it is public (private GitHub repos send neither; non-GitHub remote sources without a GitHub privacy check may still send the install event). A local path sends neither. No file contents leave the machine. The install event carries the metadata this installer attaches: `{"installer":"bmad-method","version":""}`. `--no-telemetry` sets `DO_NOT_TRACK=1` in every skills CLI process the installer starts. That also removes those installs from the install counts on skills.sh. @@ -112,7 +112,7 @@ The installer sends nothing. The skills CLI it runs sends two GET requests to `w ## Reproducible installs -The skills CLI writes `skills-lock.json` in the project, recording each skill's commit and content hash. Commit it. `npx skills install` (or `npx skills experimental_install`, with `--frozen-lockfile` in CI) restores the exact skills recorded there. +The skills CLI writes `skills-lock.json` in the project, recording each skill's content hash and (for Git sources) its commit. Commit it. `npx skills install` (or `npx skills experimental_install`) restores the skills recorded there: Git skills restore from the recorded commit, while entries without a commit (local paths, and older locks until `npx skills update` adds one) restore from the current source. Use `--frozen-lockfile` (enabled automatically in CI) when exact content matters: a frozen restore fails on a hash mismatch rather than installing changed content. ## Testing diff --git a/src/installed.js b/src/installed.js index f8e1d47..12ac909 100644 --- a/src/installed.js +++ b/src/installed.js @@ -1,5 +1,6 @@ import { access } from 'node:fs/promises' import { join } from 'node:path' +import { isInstalledListedSkill } from './skills-cli.js' /** @typedef {import('./skills-cli.js').ListedSkill} ListedSkill */ /** @typedef {import('./modules.js').ModuleDefinition} ModuleDefinition */ @@ -15,7 +16,7 @@ const LEGACY_MANIFEST = ['_bmad', '_config', 'manifest.yaml'] * @returns {Promise} */ export async function inspectInstall(dir, skillsCli) { - const skills = await skillsCli.list({ cwd: dir }) + const skills = (await skillsCli.list({ cwd: dir })).filter(isInstalledListedSkill) const bmad = skills.find((skill) => skill.name === BMAD_SKILL) return { skills, @@ -32,7 +33,7 @@ export async function inspectInstall(dir, skillsCli) { * @returns {string[]} */ export function installedModuleCodes(state, modules) { - const installed = new Set(state.skills.map((skill) => skill.name)) + const installed = new Set(state.skills.filter(isInstalledListedSkill).map((skill) => skill.name)) return modules.filter((module) => installed.has(module.record)).map((module) => module.code) } diff --git a/src/skills-cli.js b/src/skills-cli.js index 486d708..ff0ed74 100644 --- a/src/skills-cli.js +++ b/src/skills-cli.js @@ -3,7 +3,7 @@ import { createRequire } from 'node:module' /** @typedef {import('./run.js').RunResult} RunResult */ /** @typedef {import('./run.js').Runner} Runner */ /** @typedef {{ name?: string, status: 'installed' | 'failed' | 'skipped', error?: string, reason?: string, path?: string, agents?: string[], mode?: string }} AddResult */ -/** @typedef {{ name: string, path: string, scope: 'project' | 'global', agents: string[], source: string | null }} ListedSkill */ +/** @typedef {{ name: string, path: string, scope: 'project' | 'global', agents: string[], source: string | null, status?: 'tracked' | 'modified' | 'untracked' | 'missing' }} ListedSkill */ /** @typedef {{ source: string, skills: string[], agents: string[] }} AddRequest */ export class SkillsCliError extends Error { @@ -53,12 +53,23 @@ export function parseAddResults(stdout) { return parseJsonArray(stdout) } +/** + * Drops entries from `skills-lock.json` that are not installed on disk (`path: null`, `status: 'missing'`). + * @param {unknown} entry + * @returns {entry is ListedSkill} + */ +export function isInstalledListedSkill(entry) { + if (!entry || typeof entry !== 'object') return false + const skill = /** @type {Record} */ (entry) + return typeof skill.path === 'string' && skill.path !== '' && skill.status !== 'missing' +} + /** * @param {string} stdout * @returns {ListedSkill[]} */ export function parseListResults(stdout) { - return parseJsonArray(stdout) + return parseJsonArray(stdout).filter(isInstalledListedSkill) } /** diff --git a/test/agents.test.js b/test/agents.test.js index 65601ad..9bd8443 100644 --- a/test/agents.test.js +++ b/test/agents.test.js @@ -1,9 +1,10 @@ import { test } from 'node:test' import assert from 'node:assert/strict' -import { readFile } from 'node:fs/promises' +import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' import { join } from 'node:path' import { AgentsError, agentsHolding, collapseUniversal, detectAgents, loadAgents, parseToolsFlag, sharedFolderHolds } from '../src/agents.js' -import { AGENTS_FILE, generateAgents } from '../tools/generate-agents.js' +import { AGENTS_FILE, agentsFromBundle, generateAgents, readAgentsBundle } from '../tools/generate-agents.js' const agents = await loadAgents() const HOME = '/home/user' @@ -55,3 +56,49 @@ test('parseToolsFlag takes ids and display names, drops repeats and names the un assert.throws(() => parseToolsFlag('claude-code,nope,also-nope', agents), (error) => error instanceof AgentsError && error.message === 'nope, also-nope') assert.throws(() => parseToolsFlag(' , ', agents), AgentsError) }) + +const SYNTHETIC_TABLE = ` +function helper() { + const home = homedir(); + return home; +} +const home = homedir(); +const reasonixHome = platform() === 'win32' ? '/win' : join(home, '.reasonix'); +const agents = { + alpha: { + displayName: 'Alpha', + skillsDir: '.alpha/skills', + detectInstalled: async () => existsSync(reasonixHome), + }, + eve: { + displayName: 'Eve', + skillsDir: '.eve/skills', + detectInstalled: async () => existsSync(join(home, '.eve')), + }, +}; +` + +test('agentsFromBundle extracts the table past earlier home helpers, provides platform(), and skips eve', async () => { + const extracted = await agentsFromBundle(SYNTHETIC_TABLE) + assert.deepEqual(extracted, [{ id: 'alpha', name: 'Alpha', skillsDir: '.alpha/skills', detect: ['~/.reasonix'] }]) + await assert.rejects(() => agentsFromBundle('const agents = { missingHome: true };\n'), /agent table not found/) +}) + +test('readAgentsBundle checks dist/cli.mjs then sorted dist/_chunks/*.mjs and skips incomplete chunks', async (t) => { + const dir = await mkdtemp(join(tmpdir(), 'bmad-bundle-')) + t.after(() => rm(dir, { recursive: true, force: true })) + await mkdir(join(dir, 'dist', '_chunks'), { recursive: true }) + await writeFile(join(dir, 'dist', 'cli.mjs'), 'import "./_chunks/b.mjs";\n') + await writeFile(join(dir, 'dist', '_chunks', 'a-partial.mjs'), 'const agents = { incomplete: true };\n') + await writeFile(join(dir, 'dist', '_chunks', 'b-real.mjs'), SYNTHETIC_TABLE) + + const found = await readAgentsBundle(dir) + assert.ok(found.includes('Alpha')) + + await writeFile(join(dir, 'dist', 'cli.mjs'), SYNTHETIC_TABLE.replace('Alpha', 'CliDirect')) + assert.ok((await readAgentsBundle(dir)).includes('CliDirect')) + + await rm(dir, { recursive: true, force: true }) + await mkdir(join(dir, 'dist'), { recursive: true }) + await assert.rejects(() => readAgentsBundle(dir), /agent table not found/) +}) diff --git a/test/cli.test.js b/test/cli.test.js index 26618a8..11707cf 100644 --- a/test/cli.test.js +++ b/test/cli.test.js @@ -53,7 +53,7 @@ test('every flag is read, long and short', () => { const long = run([ 'install', '--directory', '/tmp/p', - '--modules', 'method,cis', + '--modules', 'method,creative', '--tools', 'claude-code,codex', '--yes', '--no-telemetry', @@ -63,7 +63,7 @@ test('every flag is read, long and short', () => { assert.deepEqual(long, { command: 'install', directory: '/tmp/p', - modules: 'method,cis', + modules: 'method,creative', tools: 'claude-code,codex', yes: true, telemetry: false, @@ -147,6 +147,7 @@ test('helpText lists every command and flag on one line each', () => { '--action', '--no-telemetry', '--copy', '--debug', '--help', '--version']) { assert.ok(text.includes(name), `missing ${name}`) } + assert.ok(text.includes('method,creative')) assert.ok(/--no-telemetry .*skills\.sh install counts/.test(text)) assert.ok(/--copy .*symlinks fail on your system/.test(text)) assert.ok(text.split('\n').every((line) => line.length <= 100)) diff --git a/test/commands/install.test.js b/test/commands/install.test.js index cd77d97..1974bad 100644 --- a/test/commands/install.test.js +++ b/test/commands/install.test.js @@ -2,6 +2,7 @@ import { test } from 'node:test' import assert from 'node:assert/strict' import { join } from 'node:path' import { install } from '../../src/commands/install.js' +import { createSkillsCli } from '../../src/skills-cli.js' import { RECORDS, detectWith, @@ -306,3 +307,35 @@ test('a module complete for one agent is still added for a newly picked agent', ) assert.deepEqual(only(again.requests), [], 'the same agent again adds nothing') }) + +test('a project with only missing locked skills installs as a fresh project', async (t) => { + const dir = await tempDir(t) + const { prompts, asked, said } = fakePrompts({ modules: ['method'] }) + const missingLock = JSON.stringify([ + { name: 'bmad', path: null, scope: 'project', agents: [], source: 'bmad-code-org/BMAD-METHOD', status: 'missing' }, + { name: 'bmod-core-tools', path: null, scope: 'project', agents: [], source: 'bmad-code-org/BMAD-METHOD', status: 'missing' }, + { name: 'bmod-toolsmith', path: null, scope: 'project', agents: [], source: 'bmad-code-org/BMAD-METHOD', status: 'missing' }, + ]) + const afterInstall = JSON.stringify(RECORDS.map((name) => listed(name))) + let listCount = 0 + /** @type {import('../../src/run.js').Runner} */ + const runner = async (request) => { + if (request.argv[0] === 'uv') return { code: 0, stdout: 'uv 0.5.31\n', stderr: '', timedOut: false } + if (request.argv.includes('list')) { + listCount += 1 + return { code: 0, stdout: listCount === 1 ? missingLock : afterInstall, stderr: '', timedOut: false } + } + return { code: 0, stdout: JSON.stringify([{ name: 'bmad', status: 'installed' }]), stderr: '', timedOut: false } + } + const cli = createSkillsCli({ runner, env: { PATH: '/usr/bin' }, telemetry: false, copy: false, metadata: { installer: 'bmad-method', version: '7.0.0-next.0' } }) + const { scripts } = fakeBmadScripts({ statuses: [statusOf()] }) + + const code = await install( + options({ directory: dir, tools: 'claude-code' }), + makeDeps({ prompts, skillsCli: cli, bmadScripts: scripts, cwd: dir, runner }), + ) + + assert.equal(code, 0) + assert.equal(asked.includes('existing'), false) + assert.equal(said.warns.some((warning) => warning.includes('Still installed')), false) +}) diff --git a/test/installed.test.js b/test/installed.test.js index abb63db..707f950 100644 --- a/test/installed.test.js +++ b/test/installed.test.js @@ -92,3 +92,18 @@ test('installedModuleCodes matches installed skills against each module record', assert.deepEqual(installedModuleCodes(stateOf(['bmad-solo']), solo), ['solo']) }) +test('inspectInstall and installedModuleCodes ignore missing lockfile entries', async () => { + const dir = await tempDir() + const missing = /** @type {ListedSkill[]} */ ([ + { name: 'bmad', path: /** @type {any} */ (null), scope: 'project', agents: [], source: 'bmad-code-org/BMAD-METHOD', status: 'missing' }, + { name: 'bmod-method', path: /** @type {any} */ (null), scope: 'project', agents: [], source: 'bmad-code-org/BMAD-METHOD', status: 'missing' }, + ]) + const state = await inspectInstall(dir, fakeSkillsCli(missing)) + + assert.equal(state.bmadSkillDir, null) + assert.deepEqual(state.skills, []) + assert.deepEqual(installedModuleCodes({ skills: missing, bmadSkillDir: null, legacyManifest: false }, await loadModules()), []) + + await rm(dir, { recursive: true, force: true }) +}) + diff --git a/test/messages.test.js b/test/messages.test.js index c107e1f..8c207a0 100644 --- a/test/messages.test.js +++ b/test/messages.test.js @@ -44,6 +44,7 @@ const keysWithValues = { nothingInstalled: {}, updatingSpinner: { what: 'BMad Method' }, modulesRequired: { modules: 'BMad Method' }, + modulesKept: { modules: 'BMad Method' }, updateNotListed: { modules: 'acme' }, updateUnreadInstall: {}, migrationsAvailable: {}, @@ -150,7 +151,7 @@ test('the ending names setup, the update command and every link once', () => { test('the prose blocks fit the clack note box without rewrapping', () => { const blocks = [ 'intro', 'updateAvailable', 'nodeTooOld', 'nodeBelowSkillsFloor', 'uvMissing', 'wslWindowsNode', - 'needsTerminal', 'insideAgent', 'legacyManifest', 'firstInstallNotInProject', 'unknownTools', 'repeatInstall', + 'needsTerminal', 'insideAgent', 'legacyManifest', 'modulesKept', 'firstInstallNotInProject', 'unknownTools', 'repeatInstall', 'nothingInstalled', 'nothingToUpdate', 'cancelled', 'summaryNextSetup', 'summaryNextCurrent', 'thanks', 'droppedUninstall', ] for (const key of blocks) { diff --git a/test/skills-cli.test.js b/test/skills-cli.test.js index 9a671c0..4151e5f 100644 --- a/test/skills-cli.test.js +++ b/test/skills-cli.test.js @@ -119,6 +119,15 @@ test('parseListResults reads listed skills and an empty list', () => { assert.deepEqual(parseListResults('[]'), []) }) +test('parseListResults drops missing lockfile entries emitted by skills list --json', () => { + const stdout = JSON.stringify([ + { name: 'bmad', path: '/p/.claude/skills/bmad', scope: 'project', agents: ['Claude Code'], source: 'owner/repo', status: 'tracked' }, + { name: 'bmod-method', path: null, scope: 'project', agents: [], source: 'owner/repo', status: 'missing' }, + { name: 'bmod-toolsmith', path: '/p/.claude/skills/bmod-toolsmith', scope: 'project', agents: [], source: 'owner/repo', status: 'missing' }, + ]) + assert.deepEqual(parseListResults(stdout).map((skill) => skill.name), ['bmad']) +}) + test('add returns the parsed results', async () => { const stdout = JSON.stringify([{ name: 'bmad', status: 'installed' }]) const { cli, calls } = fakeCli([{ stdout }]) diff --git a/tools/generate-agents.js b/tools/generate-agents.js index 302f6ef..f444f5b 100644 --- a/tools/generate-agents.js +++ b/tools/generate-agents.js @@ -29,27 +29,43 @@ function portable(path) { return path } +/** + * Extracts the `const home = homedir(); ... const agents = { ... };` slice from a bundled file, + * or returns null when the file does not hold the complete table. + * @param {string} bundle + * @returns {string | null} + */ +function findAgentSlice(bundle) { + const tableAt = bundle.indexOf(AGENTS_START) + const start = tableAt === -1 ? -1 : bundle.lastIndexOf(TABLE_START, tableAt) + const end = tableAt === -1 ? -1 : bundle.indexOf('\n};\n', tableAt) + if (start === -1 || tableAt === -1 || end === -1) return null + return bundle.slice(start, end + 3) +} + /** * Locates the bundled module holding the agent table (`dist/cli.mjs` in older skills builds, or a * shared chunk under `dist/_chunks/` in newer split builds). * @param {string} dir * @returns {Promise} */ -async function readAgentsBundle(dir) { +export async function readAgentsBundle(dir) { const candidates = [join(dir, 'dist', 'cli.mjs')] const chunksDir = join(dir, 'dist', '_chunks') try { const entries = await readdir(chunksDir, { withFileTypes: true }) - for (const entry of entries) { - if (entry.isFile() && entry.name.endsWith('.mjs')) candidates.push(join(chunksDir, entry.name)) - } + const chunks = entries + .filter((entry) => entry.isFile() && entry.name.endsWith('.mjs')) + .map((entry) => entry.name) + .sort() + for (const name of chunks) candidates.push(join(chunksDir, name)) } catch (err) { if (/** @type {NodeJS.ErrnoException} */ (err)?.code !== 'ENOENT') throw err } for (const file of candidates) { try { const text = await readFile(file, 'utf8') - if (text.includes(AGENTS_START)) return text + if (findAgentSlice(text) !== null) return text } catch (err) { if (/** @type {NodeJS.ErrnoException} */ (err)?.code !== 'ENOENT') throw err } @@ -65,10 +81,8 @@ async function readAgentsBundle(dir) { * @returns {Promise} */ export async function agentsFromBundle(bundle) { - const tableAt = bundle.indexOf(AGENTS_START) - const start = tableAt === -1 ? -1 : bundle.lastIndexOf(TABLE_START, tableAt) - const end = tableAt === -1 ? -1 : bundle.indexOf('\n};\n', tableAt) - if (start === -1 || tableAt === -1 || end === -1) throw new Error('agent table not found in the skills CLI bundle') + const slice = findAgentSlice(bundle) + if (slice === null) throw new Error('agent table not found in the skills CLI bundle') /** @type {string[]} */ let asked = [] @@ -83,7 +97,7 @@ export async function agentsFromBundle(bundle) { xdgConfig: undefined, process: { env: {}, cwd: () => CWD, platform: 'linux' }, }) - const table = vm.runInContext(`${bundle.slice(start, end + 3)}\nagents`, context) + const table = vm.runInContext(`${slice}\nagents`, context) /** @type {AgentEntry[]} */ const entries = []