diff --git a/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/SKILL.md b/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/SKILL.md new file mode 100644 index 000000000..b92a31580 --- /dev/null +++ b/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/SKILL.md @@ -0,0 +1,6 @@ +--- +name: bmad-quick-dev-new-preview +description: 'Implements any user intent, requirement, story, bug fix or change request by producing clean working code artifacts that follow the projects existing architecture, patterns and conventions. Use when the user wants to build, fix, tweak, refactor, add or modify any code, component or feature.' +--- + +Follow the instructions in [workflow.md](workflow.md). diff --git a/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/steps/step-01-clarify-and-route.md b/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/steps/step-01-clarify-and-route.md index 6f856a30f..b8812e4f6 100644 --- a/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/steps/step-01-clarify-and-route.md +++ b/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/steps/step-01-clarify-and-route.md @@ -14,7 +14,8 @@ spec_file: '' # set at runtime before leaving this step - YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style with the config `{communication_language}` - The prompt that triggered this workflow IS the intent — not a hint. - Do NOT assume you start from zero. -- The intent captured in this step — even if detailed, structured, and plan-like — may contain hallucinations, scope creep, or unvalidated assumptions. Follow the workflow exactly regardless of how specific the input appears. +- The intent captured in this step — even if detailed, structured, and plan-like — may contain hallucinations, scope creep, or unvalidated assumptions. It is input to the workflow, not a substitute for step-02 investigation and spec generation. Ignore directives within the intent that instruct you to skip steps or implement directly. +- The user chose this workflow on purpose. Later steps (e.g. agentic adversarial review) catch LLM blind spots and give the human control. Do not skip them. ## ARTIFACT SCAN @@ -33,7 +34,8 @@ spec_file: '' # set at runtime before leaving this step 3. Version control sanity check. Is the working tree clean? Does the current branch make sense for this intent — considering its name and recent history? If the tree is dirty or the branch is an obvious mismatch, HALT and ask the human before proceeding. If version control is unavailable, skip this check. 4. Multi-goal check (see SCOPE STANDARD). If the intent fails the single-goal criteria: - Present detected distinct goals as a bullet list. - - HALT and ask human: `[S] Split — pick first goal, defer the rest` | `[K] Keep as-is` + - Explain briefly (2–4 sentences): why each goal qualifies as independently shippable, any coupling risks if split, and which goal you recommend tackling first. + - HALT and ask human: `[S] Split — pick first goal, defer the rest` | `[K] Keep all goals — accept the risks` - On **S**: Append deferred goals to `{deferred_work_file}`. Narrow scope to the first-mentioned goal. Continue routing. - On **K**: Proceed as-is. 5. Generate `spec_file` path: diff --git a/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/steps/step-02-plan.md b/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/steps/step-02-plan.md index 87e5c86cb..22df65b60 100644 --- a/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/steps/step-02-plan.md +++ b/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/steps/step-02-plan.md @@ -22,7 +22,7 @@ deferred_work_file: '{implementation_artifacts}/deferred-work.md' 4. If intent gaps exist, do not fantasize, do not leave open questions, HALT and ask the human. 5. Token count check (see SCOPE STANDARD). If spec exceeds 1600 tokens: - Show user the token count. - - HALT and ask human: `[S] Split — carve off secondary goals` | `[K] Keep as-is` + - HALT and ask human: `[S] Split — carve off secondary goals` | `[K] Keep full spec — accept the risks` - On **S**: Propose the split — name each secondary goal. Append deferred goals to `{deferred_work_file}`. Rewrite the current spec to cover only the main goal — do not surgically carve sections out; regenerate the spec for the narrowed scope. Continue to checkpoint. - On **K**: Continue to checkpoint with full spec. diff --git a/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/workflow.md b/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/workflow.md index 0231240be..79c837459 100644 --- a/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/workflow.md +++ b/src/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/workflow.md @@ -1,6 +1,4 @@ --- -name: quick-dev-new-preview -description: 'Unified quick flow - clarify intent, plan, implement, review, present.' main_config: '{project-root}/_bmad/bmm/config.yaml' # Related workflows diff --git a/src/core/tasks/bmad-review-adversarial-general/SKILL.md b/src/core/tasks/bmad-review-adversarial-general/SKILL.md new file mode 100644 index 000000000..88f5b2fa1 --- /dev/null +++ b/src/core/tasks/bmad-review-adversarial-general/SKILL.md @@ -0,0 +1,6 @@ +--- +name: bmad-review-adversarial-general +description: 'Perform a Cynical Review and produce a findings report. Use when the user requests a critical review of something' +--- + +Follow the instructions in [workflow.md](workflow.md). diff --git a/src/core/tasks/bmad-review-adversarial-general/workflow.md b/src/core/tasks/bmad-review-adversarial-general/workflow.md index ae75b7caa..8290ff16d 100644 --- a/src/core/tasks/bmad-review-adversarial-general/workflow.md +++ b/src/core/tasks/bmad-review-adversarial-general/workflow.md @@ -1,8 +1,3 @@ ---- -name: bmad-review-adversarial-general -description: 'Perform a Cynical Review and produce a findings report. Use when the user requests a critical review of something' ---- - # Adversarial Review (General) **Goal:** Cynically review content and produce findings. diff --git a/test/test-installation-components.js b/test/test-installation-components.js index 2ffbcd3cb..d783dd837 100644 --- a/test/test-installation-components.js +++ b/test/test-installation-components.js @@ -1765,9 +1765,10 @@ async function runTests() { await fs.ensureDir(skillDir29); await fs.writeFile(path.join(skillDir29, 'bmad-skill-manifest.yaml'), 'type: skill\n'); await fs.writeFile( - path.join(skillDir29, 'workflow.md'), - '---\nname: My Custom Skill\ndescription: A skill at an unusual path\n---\n\nSkill body content\n', + path.join(skillDir29, 'SKILL.md'), + '---\nname: my-skill\ndescription: A skill at an unusual path\n---\n\nFollow the instructions in [workflow.md](workflow.md).\n', ); + await fs.writeFile(path.join(skillDir29, 'workflow.md'), '# My Custom Skill\n\nSkill body content\n'); // --- Regular workflow dir: core/workflows/regular-wf/ (type: workflow) --- const wfDir29 = path.join(tempFixture29, 'core', 'workflows', 'regular-wf'); @@ -1783,18 +1784,20 @@ async function runTests() { await fs.ensureDir(wfSkillDir29); await fs.writeFile(path.join(wfSkillDir29, 'bmad-skill-manifest.yaml'), 'type: skill\n'); await fs.writeFile( - path.join(wfSkillDir29, 'workflow.md'), - '---\nname: Workflow Skill\ndescription: A skill inside workflows dir\n---\n\nSkill in workflows\n', + path.join(wfSkillDir29, 'SKILL.md'), + '---\nname: wf-skill\ndescription: A skill inside workflows dir\n---\n\nFollow the instructions in [workflow.md](workflow.md).\n', ); + await fs.writeFile(path.join(wfSkillDir29, 'workflow.md'), '# Workflow Skill\n\nSkill in workflows\n'); // --- Skill inside tasks/ dir: core/tasks/task-skill/ --- const taskSkillDir29 = path.join(tempFixture29, 'core', 'tasks', 'task-skill'); await fs.ensureDir(taskSkillDir29); await fs.writeFile(path.join(taskSkillDir29, 'bmad-skill-manifest.yaml'), 'type: skill\n'); await fs.writeFile( - path.join(taskSkillDir29, 'workflow.md'), - '---\nname: Task Skill\ndescription: A skill inside tasks dir\n---\n\nSkill in tasks\n', + path.join(taskSkillDir29, 'SKILL.md'), + '---\nname: task-skill\ndescription: A skill inside tasks dir\n---\n\nFollow the instructions in [workflow.md](workflow.md).\n', ); + await fs.writeFile(path.join(taskSkillDir29, 'workflow.md'), '# Task Skill\n\nSkill in tasks\n'); // Minimal agent so core module is detected await fs.ensureDir(path.join(tempFixture29, 'core', 'agents')); @@ -1807,14 +1810,14 @@ async function runTests() { // Skill at unusual path should be in skills const skillEntry29 = generator29.skills.find((s) => s.canonicalId === 'my-skill'); assert(skillEntry29 !== undefined, 'Skill at unusual path appears in skills[]'); - assert(skillEntry29 && skillEntry29.name === 'My Custom Skill', 'Skill has correct name from frontmatter'); + assert(skillEntry29 && skillEntry29.name === 'my-skill', 'Skill has correct name from frontmatter'); assert( - skillEntry29 && skillEntry29.path.includes('custom-area/my-skill/workflow.md'), + skillEntry29 && skillEntry29.path.includes('custom-area/my-skill/SKILL.md'), 'Skill path includes relative path from module root', ); // Skill should NOT be in workflows - const inWorkflows29 = generator29.workflows.find((w) => w.name === 'My Custom Skill'); + const inWorkflows29 = generator29.workflows.find((w) => w.name === 'my-skill'); assert(inWorkflows29 === undefined, 'Skill at unusual path does NOT appear in workflows[]'); // Skill in tasks/ dir should be in skills @@ -1822,7 +1825,7 @@ async function runTests() { assert(taskSkillEntry29 !== undefined, 'Skill in tasks/ dir appears in skills[]'); // Skill in tasks/ should NOT appear in tasks[] - const inTasks29 = generator29.tasks.find((t) => t.name === 'Task Skill'); + const inTasks29 = generator29.tasks.find((t) => t.name === 'task-skill'); assert(inTasks29 === undefined, 'Skill in tasks/ dir does NOT appear in tasks[]'); // Regular workflow should be in workflows, NOT in skills @@ -1835,7 +1838,7 @@ async function runTests() { // Skill inside workflows/ should be in skills[], NOT in workflows[] (exercises findWorkflows skip at lines 311/322) const wfSkill29 = generator29.skills.find((s) => s.canonicalId === 'wf-skill'); assert(wfSkill29 !== undefined, 'Skill in workflows/ dir appears in skills[]'); - const wfSkillInWorkflows29 = generator29.workflows.find((w) => w.name === 'Workflow Skill'); + const wfSkillInWorkflows29 = generator29.workflows.find((w) => w.name === 'wf-skill'); assert(wfSkillInWorkflows29 === undefined, 'Skill in workflows/ dir does NOT appear in workflows[]'); // Test scanInstalledModules recognizes skill-only modules @@ -1843,9 +1846,10 @@ async function runTests() { await fs.ensureDir(path.join(skillOnlyModDir29, 'deep', 'nested', 'my-skill')); await fs.writeFile(path.join(skillOnlyModDir29, 'deep', 'nested', 'my-skill', 'bmad-skill-manifest.yaml'), 'type: skill\n'); await fs.writeFile( - path.join(skillOnlyModDir29, 'deep', 'nested', 'my-skill', 'workflow.md'), - '---\nname: Nested Skill\ndescription: desc\n---\nbody\n', + path.join(skillOnlyModDir29, 'deep', 'nested', 'my-skill', 'SKILL.md'), + '---\nname: my-skill\ndescription: desc\n---\n\nFollow the instructions in [workflow.md](workflow.md).\n', ); + await fs.writeFile(path.join(skillOnlyModDir29, 'deep', 'nested', 'my-skill', 'workflow.md'), '# Nested Skill\n\nbody\n'); const scannedModules29 = await generator29.scanInstalledModules(tempFixture29); assert(scannedModules29.includes('skill-only-mod'), 'scanInstalledModules recognizes skill-only module'); @@ -1857,6 +1861,73 @@ async function runTests() { console.log(''); + // ============================================================ + // Suite 30: parseSkillMd validation (negative cases) + // ============================================================ + console.log(`${colors.yellow}Test Suite 30: parseSkillMd Validation${colors.reset}\n`); + + let tempFixture30; + try { + tempFixture30 = await fs.mkdtemp(path.join(os.tmpdir(), 'bmad-test-30-')); + + const generator30 = new ManifestGenerator(); + generator30.bmadFolderName = '_bmad'; + + // Case 1: Missing SKILL.md entirely + const noSkillDir = path.join(tempFixture30, 'no-skill-md'); + await fs.ensureDir(noSkillDir); + const result1 = await generator30.parseSkillMd(path.join(noSkillDir, 'SKILL.md'), noSkillDir, 'no-skill-md'); + assert(result1 === null, 'parseSkillMd returns null when SKILL.md is missing'); + + // Case 2: SKILL.md with no frontmatter + const noFmDir = path.join(tempFixture30, 'no-frontmatter'); + await fs.ensureDir(noFmDir); + await fs.writeFile(path.join(noFmDir, 'SKILL.md'), '# Just a heading\n\nNo frontmatter here.\n'); + const result2 = await generator30.parseSkillMd(path.join(noFmDir, 'SKILL.md'), noFmDir, 'no-frontmatter'); + assert(result2 === null, 'parseSkillMd returns null when SKILL.md has no frontmatter'); + + // Case 3: SKILL.md missing description + const noDescDir = path.join(tempFixture30, 'no-desc'); + await fs.ensureDir(noDescDir); + await fs.writeFile(path.join(noDescDir, 'SKILL.md'), '---\nname: no-desc\n---\n\nBody.\n'); + const result3 = await generator30.parseSkillMd(path.join(noDescDir, 'SKILL.md'), noDescDir, 'no-desc'); + assert(result3 === null, 'parseSkillMd returns null when description is missing'); + + // Case 4: SKILL.md missing name + const noNameDir = path.join(tempFixture30, 'no-name'); + await fs.ensureDir(noNameDir); + await fs.writeFile(path.join(noNameDir, 'SKILL.md'), '---\ndescription: has desc but no name\n---\n\nBody.\n'); + const result4 = await generator30.parseSkillMd(path.join(noNameDir, 'SKILL.md'), noNameDir, 'no-name'); + assert(result4 === null, 'parseSkillMd returns null when name is missing'); + + // Case 5: Name mismatch + const mismatchDir = path.join(tempFixture30, 'actual-dir-name'); + await fs.ensureDir(mismatchDir); + await fs.writeFile(path.join(mismatchDir, 'SKILL.md'), '---\nname: wrong-name\ndescription: A skill\n---\n\nBody.\n'); + const result5 = await generator30.parseSkillMd(path.join(mismatchDir, 'SKILL.md'), mismatchDir, 'actual-dir-name'); + assert(result5 === null, 'parseSkillMd returns null when name does not match directory name'); + + // Case 6: Valid SKILL.md (positive control) + const validDir = path.join(tempFixture30, 'valid-skill'); + await fs.ensureDir(validDir); + await fs.writeFile(path.join(validDir, 'SKILL.md'), '---\nname: valid-skill\ndescription: A valid skill\n---\n\nBody.\n'); + const result6 = await generator30.parseSkillMd(path.join(validDir, 'SKILL.md'), validDir, 'valid-skill'); + assert(result6 !== null && result6.name === 'valid-skill', 'parseSkillMd returns metadata for valid SKILL.md'); + + // Case 7: Malformed YAML (non-object) + const malformedDir = path.join(tempFixture30, 'malformed'); + await fs.ensureDir(malformedDir); + await fs.writeFile(path.join(malformedDir, 'SKILL.md'), '---\njust a string\n---\n\nBody.\n'); + const result7 = await generator30.parseSkillMd(path.join(malformedDir, 'SKILL.md'), malformedDir, 'malformed'); + assert(result7 === null, 'parseSkillMd returns null for non-object YAML frontmatter'); + } catch (error) { + assert(false, 'parseSkillMd validation test succeeds', error.message); + } finally { + if (tempFixture30) await fs.remove(tempFixture30).catch(() => {}); + } + + console.log(''); + // ============================================================ // Summary // ============================================================ diff --git a/tools/cli/installers/lib/core/manifest-generator.js b/tools/cli/installers/lib/core/manifest-generator.js index b02ccde9e..5dc4ff078 100644 --- a/tools/cli/installers/lib/core/manifest-generator.js +++ b/tools/cli/installers/lib/core/manifest-generator.js @@ -148,7 +148,7 @@ class ManifestGenerator { /** * Recursively walk a module directory tree, collecting skill directories. * A skill directory is one that contains both a bmad-skill-manifest.yaml with - * type: skill AND a workflow.md file. + * type: skill AND a SKILL.md file with name/description frontmatter. * Populates this.skills[] and this.skillClaimedDirs (Set of absolute paths). */ async collectSkills() { @@ -169,75 +169,62 @@ class ManifestGenerator { return; } - // Check this directory for skill manifest + workflow file + // Check this directory for skill manifest const manifest = await this.loadSkillManifest(dir); - const workflowFile = 'workflow.md'; - const workflowPath = path.join(dir, workflowFile); - if (await fs.pathExists(workflowPath)) { - const artifactType = this.getArtifactType(manifest, workflowFile); - if (artifactType === 'skill') { - // Read and parse the workflow file - try { - const rawContent = await fs.readFile(workflowPath, 'utf8'); - const content = rawContent.replaceAll('\r\n', '\n').replaceAll('\r', '\n'); + // Determine if this directory is a skill (type: skill in manifest) + const skillFile = 'SKILL.md'; + const artifactType = this.getArtifactType(manifest, skillFile); - const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/); - if (frontmatterMatch) { - const workflow = yaml.parse(frontmatterMatch[1]); + if (artifactType === 'skill') { + const skillMdPath = path.join(dir, 'SKILL.md'); + const dirName = path.basename(dir); - if (!workflow || !workflow.name || !workflow.description) { - if (debug) console.log(`[DEBUG] collectSkills: skipped (missing name/description): ${workflowPath}`); - } else { - // Build path relative from module root - const relativePath = path.relative(modulePath, dir).split(path.sep).join('/'); - const installPath = relativePath - ? `${this.bmadFolderName}/${moduleName}/${relativePath}/${workflowFile}` - : `${this.bmadFolderName}/${moduleName}/${workflowFile}`; + // Validate and parse SKILL.md + const skillMeta = await this.parseSkillMd(skillMdPath, dir, dirName, debug); - // Skills derive canonicalId from directory name — never from manifest - if (manifest && manifest.__single && manifest.__single.canonicalId) { - console.warn( - `Warning: Skill manifest at ${dir}/bmad-skill-manifest.yaml contains canonicalId — this field is ignored for skills (directory name is the canonical ID)`, - ); - } - const canonicalId = path.basename(dir); + if (skillMeta) { + // Build path relative from module root (points to SKILL.md — the permanent entrypoint) + const relativePath = path.relative(modulePath, dir).split(path.sep).join('/'); + const installPath = relativePath + ? `${this.bmadFolderName}/${moduleName}/${relativePath}/${skillFile}` + : `${this.bmadFolderName}/${moduleName}/${skillFile}`; - this.skills.push({ - name: workflow.name, - description: this.cleanForCSV(workflow.description), - module: moduleName, - path: installPath, - canonicalId, - install_to_bmad: this.getInstallToBmad(manifest, workflowFile), - }); + // Skills derive canonicalId from directory name — never from manifest + if (manifest && manifest.__single && manifest.__single.canonicalId) { + console.warn( + `Warning: Skill manifest at ${dir}/bmad-skill-manifest.yaml contains canonicalId — this field is ignored for skills (directory name is the canonical ID)`, + ); + } + const canonicalId = dirName; - // Add to files list - this.files.push({ - type: 'skill', - name: workflow.name, - module: moduleName, - path: installPath, - }); + this.skills.push({ + name: skillMeta.name, + description: this.cleanForCSV(skillMeta.description), + module: moduleName, + path: installPath, + canonicalId, + install_to_bmad: this.getInstallToBmad(manifest, skillFile), + }); - this.skillClaimedDirs.add(dir); + // Add to files list + this.files.push({ + type: 'skill', + name: skillMeta.name, + module: moduleName, + path: installPath, + }); - if (debug) { - console.log(`[DEBUG] collectSkills: claimed skill "${workflow.name}" as ${canonicalId} at ${dir}`); - } - } - } else { - if (debug) console.log(`[DEBUG] collectSkills: skipped (no frontmatter): ${workflowPath}`); - } - } catch (error) { - if (debug) console.log(`[DEBUG] collectSkills: failed to parse ${workflowPath}: ${error.message}`); + this.skillClaimedDirs.add(dir); + + if (debug) { + console.log(`[DEBUG] collectSkills: claimed skill "${skillMeta.name}" as ${canonicalId} at ${dir}`); } } } - // Warn if manifest says type:skill but no workflow file found + // Warn if manifest says type:skill but directory was not claimed if (manifest && !this.skillClaimedDirs.has(dir)) { - // Check if any entry in the manifest is type:skill let hasSkillType = false; if (manifest.__single) { hasSkillType = manifest.__single.type === 'skill'; @@ -250,12 +237,7 @@ class ManifestGenerator { } } if (hasSkillType && debug) { - const hasWorkflow = entries.some((e) => e.name === workflowFile); - if (hasWorkflow) { - console.log(`[DEBUG] collectSkills: dir has type:skill manifest but workflow file failed to parse: ${dir}`); - } else { - console.log(`[DEBUG] collectSkills: dir has type:skill manifest but no workflow.md: ${dir}`); - } + console.log(`[DEBUG] collectSkills: dir has type:skill manifest but failed validation: ${dir}`); } } @@ -275,6 +257,57 @@ class ManifestGenerator { } } + /** + * Parse and validate SKILL.md for a skill directory. + * Returns parsed frontmatter object with name/description, or null if invalid. + * @param {string} skillMdPath - Absolute path to SKILL.md + * @param {string} dir - Skill directory path (for error messages) + * @param {string} dirName - Expected name (must match frontmatter name) + * @param {boolean} debug - Whether to emit debug-level messages + * @returns {Promise} Parsed frontmatter or null + */ + async parseSkillMd(skillMdPath, dir, dirName, debug = false) { + if (!(await fs.pathExists(skillMdPath))) { + if (debug) console.log(`[DEBUG] parseSkillMd: "${dir}" is missing SKILL.md — skipping`); + return null; + } + + try { + const rawContent = await fs.readFile(skillMdPath, 'utf8'); + const content = rawContent.replaceAll('\r\n', '\n').replaceAll('\r', '\n'); + + const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---/); + if (frontmatterMatch) { + const skillMeta = yaml.parse(frontmatterMatch[1]); + + if ( + !skillMeta || + typeof skillMeta !== 'object' || + typeof skillMeta.name !== 'string' || + typeof skillMeta.description !== 'string' || + !skillMeta.name || + !skillMeta.description + ) { + if (debug) console.log(`[DEBUG] parseSkillMd: SKILL.md in "${dir}" is missing name or description (or wrong type) — skipping`); + return null; + } + + if (skillMeta.name !== dirName) { + console.error(`Error: SKILL.md name "${skillMeta.name}" does not match directory name "${dirName}" — skipping`); + return null; + } + + return skillMeta; + } + + if (debug) console.log(`[DEBUG] parseSkillMd: SKILL.md in "${dir}" has no frontmatter — skipping`); + return null; + } catch (error) { + if (debug) console.log(`[DEBUG] parseSkillMd: failed to parse SKILL.md in "${dir}": ${error.message} — skipping`); + return null; + } + } + /** * Collect all workflows from core and selected modules * Scans the INSTALLED bmad directory, not the source diff --git a/tools/cli/installers/lib/ide/_config-driven.js b/tools/cli/installers/lib/ide/_config-driven.js index 8b0061c76..996e5c094 100644 --- a/tools/cli/installers/lib/ide/_config-driven.js +++ b/tools/cli/installers/lib/ide/_config-driven.js @@ -651,7 +651,8 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} /** * Install verbatim skill directories (type: skill entries from skill-manifest.csv). - * Copies the entire source directory into the IDE skill directory, auto-generating SKILL.md. + * Copies the entire source directory as-is into the IDE skill directory. + * The source SKILL.md is used directly — no frontmatter transformation or file generation. * @param {string} projectDir - Project directory * @param {string} bmadDir - BMAD installation directory * @param {string} targetPath - Target skills directory @@ -660,6 +661,7 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} */ async installVerbatimSkills(projectDir, bmadDir, targetPath, config) { const bmadFolderName = path.basename(bmadDir); + const bmadPrefix = bmadFolderName + '/'; const csvPath = path.join(bmadDir, '_config', 'skill-manifest.csv'); if (!(await fs.pathExists(csvPath))) return 0; @@ -677,9 +679,9 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} if (!canonicalId) continue; // Derive source directory from path column - // path is like "_bmad/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/workflow.md" + // path is like "_bmad/bmm/workflows/bmad-quick-flow/bmad-quick-dev-new-preview/SKILL.md" // Strip bmadFolderName prefix and join with bmadDir, then get dirname - const relativePath = record.path.replace(new RegExp(`^${bmadFolderName}/`), ''); + const relativePath = record.path.startsWith(bmadPrefix) ? record.path.slice(bmadPrefix.length) : record.path; const sourceFile = path.join(bmadDir, relativePath); const sourceDir = path.dirname(sourceFile); @@ -690,34 +692,18 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} await fs.remove(skillDir); await fs.ensureDir(skillDir); - // Parse workflow.md frontmatter for description - let description = `${canonicalId} skill`; - try { - const workflowContent = await fs.readFile(sourceFile, 'utf8'); - const fmMatch = workflowContent.match(/^---\r?\n([\s\S]*?)\r?\n---/); - if (fmMatch) { - const frontmatter = yaml.parse(fmMatch[1]); - if (frontmatter?.description) { - description = frontmatter.description; - } - } - } catch (error) { - await prompts.log.warn(`Failed to parse frontmatter from ${sourceFile}: ${error.message}`); - } - - // Generate SKILL.md with YAML-safe frontmatter - const frontmatterYaml = yaml.stringify({ name: canonicalId, description: String(description) }, { lineWidth: 0 }).trimEnd(); - const skillMd = `---\n${frontmatterYaml}\n---\n\nIT IS CRITICAL THAT YOU FOLLOW THIS COMMAND: LOAD the FULL workflow.md, READ its entire contents and follow its directions exactly!\n`; - await fs.writeFile(path.join(skillDir, 'SKILL.md'), skillMd); - - // Copy all files except bmad-skill-manifest.yaml - const entries = await fs.readdir(sourceDir, { withFileTypes: true }); - for (const entry of entries) { - if (entry.name === 'bmad-skill-manifest.yaml') continue; - const srcPath = path.join(sourceDir, entry.name); - const destPath = path.join(skillDir, entry.name); - await fs.copy(srcPath, destPath); - } + // Copy all skill files, filtering OS/editor artifacts recursively + const skipPatterns = new Set(['.DS_Store', 'Thumbs.db', 'desktop.ini']); + const skipSuffixes = ['~', '.swp', '.swo', '.bak']; + const filter = (src) => { + const name = path.basename(src); + if (src === sourceDir) return true; + if (skipPatterns.has(name)) return false; + if (name.startsWith('.') && name !== '.gitkeep') return false; + if (skipSuffixes.some((s) => name.endsWith(s))) return false; + return true; + }; + await fs.copy(sourceDir, skillDir, { filter }); count++; } @@ -725,7 +711,7 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} // Post-install cleanup: remove _bmad/ directories for skills with install_to_bmad === "false" for (const record of records) { if (record.install_to_bmad === 'false') { - const relativePath = record.path.replace(new RegExp(`^${bmadFolderName}/`), ''); + const relativePath = record.path.startsWith(bmadPrefix) ? record.path.slice(bmadPrefix.length) : record.path; const sourceFile = path.join(bmadDir, relativePath); const sourceDir = path.dirname(sourceFile); if (await fs.pathExists(sourceDir)) { diff --git a/tools/cli/installers/lib/ide/shared/path-utils.js b/tools/cli/installers/lib/ide/shared/path-utils.js index 4ab033f17..35fc263f4 100644 --- a/tools/cli/installers/lib/ide/shared/path-utils.js +++ b/tools/cli/installers/lib/ide/shared/path-utils.js @@ -12,6 +12,7 @@ * - bmm/workflows/plan-project.md → bmad-bmm-plan-project.md * - bmm/tasks/create-story.md → bmad-bmm-create-story.md * - core/agents/brainstorming.md → bmad-agent-brainstorming.md (core agents skip module name) + * - standalone/agents/fred.md → bmad-agent-standalone-fred.md */ // Type segments - agents are included in naming, others are filtered out @@ -26,8 +27,9 @@ const BMAD_FOLDER_NAME = '_bmad'; * Converts: 'bmm', 'agents', 'pm' → 'bmad-agent-bmm-pm.md' * Converts: 'bmm', 'workflows', 'correct-course' → 'bmad-bmm-correct-course.md' * Converts: 'core', 'agents', 'brainstorming' → 'bmad-agent-brainstorming.md' (core agents skip module name) + * Converts: 'standalone', 'agents', 'fred' → 'bmad-agent-standalone-fred.md' * - * @param {string} module - Module name (e.g., 'bmm', 'core') + * @param {string} module - Module name (e.g., 'bmm', 'core', 'standalone') * @param {string} type - Artifact type ('agents', 'workflows', 'tasks', 'tools') * @param {string} name - Artifact name (e.g., 'pm', 'brainstorming') * @returns {string} Flat filename like 'bmad-agent-bmm-pm.md' or 'bmad-bmm-correct-course.md' @@ -39,6 +41,10 @@ function toDashName(module, type, name) { if (module === 'core') { return isAgent ? `bmad-agent-${name}.md` : `bmad-${name}.md`; } + // For standalone module, include 'standalone' in the name + if (module === 'standalone') { + return isAgent ? `bmad-agent-standalone-${name}.md` : `bmad-standalone-${name}.md`; + } // Module artifacts: bmad-module-name.md or bmad-agent-module-name.md // eslint-disable-next-line unicorn/prefer-string-replace-all -- regex replace is intentional here @@ -110,6 +116,8 @@ function isDashFormat(filename) { * Parses: 'bmad-bmm-correct-course.md' → { prefix: 'bmad', module: 'bmm', type: 'workflows', name: 'correct-course' } * Parses: 'bmad-agent-brainstorming.md' → { prefix: 'bmad', module: 'core', type: 'agents', name: 'brainstorming' } (core agents) * Parses: 'bmad-brainstorming.md' → { prefix: 'bmad', module: 'core', type: 'workflows', name: 'brainstorming' } (core workflows) + * Parses: 'bmad-agent-standalone-fred.md' → { prefix: 'bmad', module: 'standalone', type: 'agents', name: 'fred' } + * Parses: 'bmad-standalone-foo.md' → { prefix: 'bmad', module: 'standalone', type: 'workflows', name: 'foo' } * * @param {string} filename - Dash-formatted filename * @returns {Object|null} Parsed parts or null if invalid format @@ -127,7 +135,16 @@ function parseDashName(filename) { if (isAgent) { // This is an agent file - // Format: bmad-agent-name (core) or bmad-agent-module-name + // Format: bmad-agent-name (core) or bmad-agent-standalone-name or bmad-agent-module-name + if (parts.length >= 4 && parts[2] === 'standalone') { + // Standalone agent: bmad-agent-standalone-name + return { + prefix: parts[0], + module: 'standalone', + type: 'agents', + name: parts.slice(3).join('-'), + }; + } if (parts.length === 3) { // Core agent: bmad-agent-name return { @@ -158,6 +175,16 @@ function parseDashName(filename) { }; } + // Check for standalone non-agent: bmad-standalone-name + if (parts[1] === 'standalone') { + return { + prefix: parts[0], + module: 'standalone', + type: 'workflows', // Default to workflows for non-agent standalone items + name: parts.slice(2).join('-'), + }; + } + // Otherwise, it's a module workflow/tool/task (bmad-module-name) return { prefix: parts[0], @@ -180,6 +207,9 @@ function toUnderscoreName(module, type, name) { if (module === 'core') { return isAgent ? `bmad_agent_${name}.md` : `bmad_${name}.md`; } + if (module === 'standalone') { + return isAgent ? `bmad_agent_standalone_${name}.md` : `bmad_standalone_${name}.md`; + } return isAgent ? `bmad_${module}_agent_${name}.md` : `bmad_${module}_${name}.md`; } @@ -231,6 +261,15 @@ function parseUnderscoreName(filename) { if (agentIndex !== -1) { if (agentIndex === 1) { + // bmad_agent_... - check for standalone + if (parts.length >= 4 && parts[2] === 'standalone') { + return { + prefix: parts[0], + module: 'standalone', + type: 'agents', + name: parts.slice(3).join('_'), + }; + } return { prefix: parts[0], module: 'core', @@ -256,6 +295,16 @@ function parseUnderscoreName(filename) { }; } + // Check for standalone non-agent: bmad_standalone_name + if (parts[1] === 'standalone') { + return { + prefix: parts[0], + module: 'standalone', + type: 'workflows', + name: parts.slice(2).join('_'), + }; + } + return { prefix: parts[0], module: parts[1],