From 4655bb1482d3bab531b078dd8dee5b4f5195f367 Mon Sep 17 00:00:00 2001 From: sdev Date: Thu, 12 Mar 2026 19:39:25 +0530 Subject: [PATCH 1/6] fix(prd): require explicit user confirmation before de-scoping requirements or inventing phases --- .../steps-c/step-08-scoping.md | 64 +++++++++++++++++-- .../bmad-create-prd/steps-c/step-11-polish.md | 2 +- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-08-scoping.md b/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-08-scoping.md index b060dda8d..3d913f6ee 100644 --- a/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-08-scoping.md +++ b/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-08-scoping.md @@ -12,6 +12,8 @@ - πŸ“‹ YOU ARE A FACILITATOR, not a content generator - πŸ’¬ FOCUS on strategic scope decisions that keep projects viable - 🎯 EMPHASIZE lean MVP thinking while preserving long-term vision +- ⚠️ NEVER de-scope, defer, or phase out requirements that the user explicitly included in their input documents without asking first +- ⚠️ NEVER invent phasing (MVP/Growth/Vision) unless the user requests phased delivery β€” if input documents define all components as core requirements, they are ALL in scope - βœ… YOU MUST ALWAYS SPEAK OUTPUT In your Agent communication style with the config `{communication_language}` - βœ… YOU MUST ALWAYS WRITE all artifact and document content in `{document_output_language}` @@ -75,10 +77,23 @@ Use structured decision-making for scope: - Advanced functionality that builds on MVP - Ask what features could be added in versions 2, 3, etc. +**⚠️ SCOPE CHANGE CONFIRMATION GATE:** +- If you believe any user-specified requirement should be deferred or de-scoped, you MUST present this to the user and get explicit confirmation BEFORE removing it from scope +- Frame it as a recommendation, not a decision: "I'd recommend deferring X because [reason]. Do you agree, or should it stay in scope?" +- NEVER silently move user requirements to a later phase or exclude them from MVP + ### 4. Progressive Feature Roadmap -Create phased development approach: -- Guide mapping of features across development phases +**CRITICAL: Phasing is NOT automatic. Check the user's input first.** + +Before proposing any phased approach, review the user's input documents: + +- **If the input documents define all components as core requirements with no mention of phases:** Present all requirements as a single release scope. Do NOT invent phases or move requirements to fabricated future phases. +- **If the input documents explicitly request phased delivery:** Guide mapping of features across the phases the user defined. +- **If scope is unclear:** ASK the user whether they want phased delivery or a single release before proceeding. + +**When the user wants phased delivery**, guide mapping of features across development phases: + - Structure as Phase 1 (MVP), Phase 2 (Growth), Phase 3 (Vision) - Ensure clear progression and dependencies @@ -98,6 +113,12 @@ Create phased development approach: - Platform features - New markets or use cases +**When the user wants a single release**, define the complete scope: + +- All user-specified requirements are in scope +- Focus must-have vs nice-to-have analysis on what ships in this release +- Do NOT create phases β€” use must-have/nice-to-have priority within the single release + **Where does your current vision fit in this development sequence?**" ### 5. Risk-Based Scoping @@ -129,6 +150,8 @@ Prepare comprehensive scoping section: #### Content Structure: +**If user chose phased delivery:** + ```markdown ## Project Scoping & Phased Development @@ -160,6 +183,34 @@ Prepare comprehensive scoping section: **Resource Risks:** {{contingency_approach}} ``` +**If user chose single release (no phasing):** + +```markdown +## Project Scoping + +### Strategy & Philosophy + +**Approach:** {{chosen_approach}} +**Resource Requirements:** {{team_size_and_skills}} + +### Complete Feature Set + +**Core User Journeys Supported:** +{{all_journeys}} + +**Must-Have Capabilities:** +{{list_of_must_have_features}} + +**Nice-to-Have Capabilities:** +{{list_of_nice_to_have_features}} + +### Risk Mitigation Strategy + +**Technical Risks:** {{mitigation_approach}} +**Market Risks:** {{validation_approach}} +**Resource Risks:** {{contingency_approach}} +``` + ### 7. Present MENU OPTIONS Present the scoping decisions for review, then display menu: @@ -189,8 +240,9 @@ When user selects 'C', append the content directly to the document using the str βœ… Complete PRD document analyzed for scope implications βœ… Strategic MVP approach defined and justified -βœ… Clear MVP feature boundaries established -βœ… Phased development roadmap created +βœ… Clear feature boundaries established (phased or single-release, per user preference) +βœ… All user-specified requirements accounted for β€” none silently removed or deferred +βœ… Any scope reduction recommendations presented to user with rationale and explicit confirmation obtained βœ… Key risks identified and mitigation strategies defined βœ… User explicitly agrees to scope decisions βœ… A/P/C menu presented and handled correctly @@ -202,8 +254,10 @@ When user selects 'C', append the content directly to the document using the str ❌ Making scope decisions without strategic rationale ❌ Not getting explicit user agreement on MVP boundaries ❌ Missing critical risk analysis -❌ Not creating clear phased development approach ❌ Not presenting A/P/C menu after content generation +❌ **CRITICAL**: Silently de-scoping or deferring requirements that the user explicitly included in their input documents +❌ **CRITICAL**: Inventing phasing (MVP/Growth/Vision) when the user did not request phased delivery +❌ **CRITICAL**: Making consequential scoping decisions (what is in/out of scope) without explicit user confirmation ❌ **CRITICAL**: Reading only partial step file - leads to incomplete understanding and poor decisions ❌ **CRITICAL**: Proceeding with 'C' without fully reading and understanding the next step file diff --git a/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-11-polish.md b/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-11-polish.md index c63ae5b29..decf8865b 100644 --- a/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-11-polish.md +++ b/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-11-polish.md @@ -138,7 +138,7 @@ Make targeted improvements: - All user success criteria - All functional requirements (capability contract) - All user journey narratives -- All scope decisions (MVP, Growth, Vision) +- All scope decisions (whether phased or single-release) - All non-functional requirements - Product differentiator and vision - Domain-specific requirements From 36f9df69bf0e11741b8fef95575c072ea51bdcea Mon Sep 17 00:00:00 2001 From: sdev Date: Wed, 18 Mar 2026 22:08:51 +0530 Subject: [PATCH 2/6] fix: address CodeRabbit review feedback for PRD scoping step step-08-scoping.md: - Neutral title replacing hard-coded "MVP & Future Features" - Task statement no longer mandates phase-based prioritization - Confirmation gate now covers artifact creation, not just de-scoping - Phased delivery uses user-defined phase labels/count instead of fixed 3 - "wants phased" phrasing replaced with "requests/chooses" - Development sequence question branches by release mode - Menu text conditional on delivery mode (no "phased roadmap" for single-release) - Handoff to step-09 now persists releaseMode in frontmatter - New failure mode for unapproved phase artifact creation step-11-polish.md: - Preservation rule now includes consent-critical evidence from step 8 --- .../steps-c/step-08-scoping.md | 39 ++++++++----------- .../bmad-create-prd/steps-c/step-11-polish.md | 2 +- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-08-scoping.md b/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-08-scoping.md index 3d913f6ee..c35289145 100644 --- a/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-08-scoping.md +++ b/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-08-scoping.md @@ -1,4 +1,4 @@ -# Step 8: Scoping Exercise - MVP & Future Features +# Step 8: Scoping Exercise - Scope Definition (Phased or Single-Release) **Progress: Step 8 of 11** - Next: Functional Requirements @@ -36,7 +36,7 @@ ## YOUR TASK: -Conduct comprehensive scoping exercise to define MVP boundaries and prioritize features across development phases. +Conduct comprehensive scoping exercise to define release boundaries and prioritize features based on the user's chosen delivery mode (phased or single-release). ## SCOPING SEQUENCE: @@ -81,6 +81,7 @@ Use structured decision-making for scope: - If you believe any user-specified requirement should be deferred or de-scoped, you MUST present this to the user and get explicit confirmation BEFORE removing it from scope - Frame it as a recommendation, not a decision: "I'd recommend deferring X because [reason]. Do you agree, or should it stay in scope?" - NEVER silently move user requirements to a later phase or exclude them from MVP +- Before creating any consequential phase-based artifacts (e.g., phase tags, labels, or follow-on prompts), present artifact creation as a recommendation and proceed only after explicit user approval ### 4. Progressive Feature Roadmap @@ -92,34 +93,25 @@ Before proposing any phased approach, review the user's input documents: - **If the input documents explicitly request phased delivery:** Guide mapping of features across the phases the user defined. - **If scope is unclear:** ASK the user whether they want phased delivery or a single release before proceeding. -**When the user wants phased delivery**, guide mapping of features across development phases: +**When the user requests phased delivery**, guide mapping of features across the phases the user defines: -- Structure as Phase 1 (MVP), Phase 2 (Growth), Phase 3 (Vision) -- Ensure clear progression and dependencies +- Use user-provided phase labels and count; if none are provided, propose a default (e.g., MVP/Growth/Vision) and ask for confirmation +- Ensure clear progression and dependencies between phases -- Core user value delivery -- Essential user journeys -- Basic functionality that works reliably +**Each phase should address:** -**Phase 2: Growth** +- Core user value delivery and essential journeys for that phase +- Clear boundaries on what ships in each phase +- Dependencies on prior phases -- Additional user types -- Enhanced features -- Scale improvements - -**Phase 3: Expansion** - -- Advanced capabilities -- Platform features -- New markets or use cases - -**When the user wants a single release**, define the complete scope: +**When the user chooses a single release**, define the complete scope: - All user-specified requirements are in scope - Focus must-have vs nice-to-have analysis on what ships in this release - Do NOT create phases β€” use must-have/nice-to-have priority within the single release -**Where does your current vision fit in this development sequence?**" +**If phased delivery:** "Where does your current vision fit in this development sequence?" +**If single release:** "How does your current vision map to this upcoming release?" ### 5. Risk-Based Scoping @@ -215,7 +207,7 @@ Prepare comprehensive scoping section: Present the scoping decisions for review, then display menu: - Show strategic scoping plan (using structure from step 6) -- Highlight MVP boundaries and phased roadmap +- Highlight release boundaries and prioritization (phased roadmap only if phased delivery was selected) - Ask if they'd like to refine further, get other perspectives, or proceed - Present menu options naturally as part of conversation @@ -224,7 +216,7 @@ Display: "**Select:** [A] Advanced Elicitation [P] Party Mode [C] Continue to Fu #### Menu Handling Logic: - IF A: Invoke the `bmad-advanced-elicitation` skill with the current scoping analysis, process the enhanced insights that come back, ask user if they accept the improvements, if yes update content then redisplay menu, if no keep original content then redisplay menu - IF P: Invoke the `bmad-party-mode` skill with the scoping context, process the collaborative insights on MVP and roadmap decisions, ask user if they accept the changes, if yes update content then redisplay menu, if no keep original content then redisplay menu -- IF C: Append the final content to {outputFile}, update frontmatter by adding this step name to the end of the stepsCompleted array, then read fully and follow: ./step-09-functional.md +- IF C: Append the final content to {outputFile}, update frontmatter by adding this step name to the end of the stepsCompleted array (also add `releaseMode: phased` or `releaseMode: single-release` to frontmatter based on user's choice), then read fully and follow: ./step-09-functional.md - IF Any other: help user respond, then redisplay menu #### EXECUTION RULES: @@ -258,6 +250,7 @@ When user selects 'C', append the content directly to the document using the str ❌ **CRITICAL**: Silently de-scoping or deferring requirements that the user explicitly included in their input documents ❌ **CRITICAL**: Inventing phasing (MVP/Growth/Vision) when the user did not request phased delivery ❌ **CRITICAL**: Making consequential scoping decisions (what is in/out of scope) without explicit user confirmation +❌ **CRITICAL**: Creating phase-based artifacts (tags, labels, follow-on prompts) without explicit user approval ❌ **CRITICAL**: Reading only partial step file - leads to incomplete understanding and poor decisions ❌ **CRITICAL**: Proceeding with 'C' without fully reading and understanding the next step file diff --git a/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-11-polish.md b/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-11-polish.md index decf8865b..6d33abd5c 100644 --- a/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-11-polish.md +++ b/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-11-polish.md @@ -138,7 +138,7 @@ Make targeted improvements: - All user success criteria - All functional requirements (capability contract) - All user journey narratives -- All scope decisions (whether phased or single-release) +- All scope decisions (whether phased or single-release), including consent-critical evidence (explicit user confirmations and rationales for any scope changes from step 8) - All non-functional requirements - Product differentiator and vision - Domain-specific requirements From 83f374c254dabbaae5b66174bc955bf222f0c49e Mon Sep 17 00:00:00 2001 From: Brian Madison Date: Sun, 12 Apr 2026 22:41:40 -0500 Subject: [PATCH 3/6] fix(installer): source built-in modules locally instead of from registry Core and BMM modules live in this repo (src/core-skills, src/bmm-skills) but the installer UI sourced them from the remote registry. When the registry was unreachable (VPN, proxy, firewall), the fallback YAML only had the 4 external modules, so core and bmm disappeared from the install list entirely. Now _selectOfficialModules and getDefaultModules always read built-in modules from the local source via OfficialModules.listAvailable(), then append external modules from the registry. Network failures only affect external modules. Closes #2239 --- src/core-skills/module.yaml | 1 + tools/installer/ui.js | 55 +++++++++++++++++++++++++++++-------- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/core-skills/module.yaml b/src/core-skills/module.yaml index 48e7a58f7..5ac3cd887 100644 --- a/src/core-skills/module.yaml +++ b/src/core-skills/module.yaml @@ -1,5 +1,6 @@ code: core name: "BMad Core Module" +description: "Core configuration and shared resources" header: "BMad Core Configuration" subheader: "Configure the core settings for your BMad installation.\nThese settings will be used across all installed bmad skills, workflows, and agents." diff --git a/tools/installer/ui.js b/tools/installer/ui.js index 527708494..9e48c647a 100644 --- a/tools/installer/ui.js +++ b/tools/installer/ui.js @@ -598,7 +598,7 @@ class UI { const officialCodes = new Set(officialSelected); const externalManager = new ExternalModuleManager(); const registryModules = await externalManager.listAvailable(); - const officialRegistryCodes = new Set(registryModules.map((m) => m.code)); + const officialRegistryCodes = new Set(['core', 'bmm', ...registryModules.map((m) => m.code)]); const installedNonOfficial = [...installedModuleIds].filter((id) => !officialRegistryCodes.has(id)); // Phase 2: Community modules (category drill-down) @@ -630,6 +630,11 @@ class UI { * @returns {Array} Selected official module codes */ async _selectOfficialModules(installedModuleIds = new Set()) { + // Built-in modules (core, bmm) come from local source, not the registry + const { OfficialModules } = require('./modules/official-modules'); + const builtInModules = (await new OfficialModules().listAvailable()).modules || []; + + // External modules come from the registry (with fallback) const externalManager = new ExternalModuleManager(); const registryModules = await externalManager.listAvailable(); @@ -637,20 +642,34 @@ class UI { const initialValues = []; const lockedValues = ['core']; - const buildModuleEntry = async (mod) => { - const isInstalled = installedModuleIds.has(mod.code); - const version = await getMarketplaceVersion(mod.code); - const label = version ? `${mod.name} (v${version})` : mod.name; + const buildModuleEntry = async (code, name, description, isDefault) => { + const isInstalled = installedModuleIds.has(code); + const version = await getMarketplaceVersion(code); + const label = version ? `${name} (v${version})` : name; return { label, - value: mod.code, - hint: mod.description, - selected: isInstalled, + value: code, + hint: description, + selected: isInstalled || isDefault, }; }; + // Add built-in modules first (always available regardless of network) + const builtInCodes = new Set(); + for (const mod of builtInModules) { + const code = mod.id; + builtInCodes.add(code); + const entry = await buildModuleEntry(code, mod.name, mod.description, mod.defaultSelected); + allOptions.push({ label: entry.label, value: entry.value, hint: entry.hint }); + if (entry.selected) { + initialValues.push(code); + } + } + + // Add external registry modules (skip built-in duplicates) for (const mod of registryModules) { - const entry = await buildModuleEntry(mod); + if (mod.builtIn || builtInCodes.has(mod.code)) continue; + const entry = await buildModuleEntry(mod.code, mod.name, mod.description, mod.defaultSelected); allOptions.push({ label: entry.label, value: entry.value, hint: entry.hint }); if (entry.selected) { initialValues.push(mod.code); @@ -1122,12 +1141,26 @@ class UI { * @returns {Array} Default module codes */ async getDefaultModules(installedModuleIds = new Set()) { + // Built-in modules with default_selected come from local source + const { OfficialModules } = require('./modules/official-modules'); + const builtInModules = (await new OfficialModules().listAvailable()).modules || []; + + const defaultModules = []; + const seen = new Set(); + + for (const mod of builtInModules) { + if (mod.defaultSelected || installedModuleIds.has(mod.id)) { + defaultModules.push(mod.id); + seen.add(mod.id); + } + } + + // Add external registry defaults const externalManager = new ExternalModuleManager(); const registryModules = await externalManager.listAvailable(); - const defaultModules = []; - for (const mod of registryModules) { + if (mod.builtIn || seen.has(mod.code)) continue; if (mod.defaultSelected || installedModuleIds.has(mod.code)) { defaultModules.push(mod.code); } From 246270bef297a25fad6cabb88f8d9108c4d7fb57 Mon Sep 17 00:00:00 2001 From: Brian Madison Date: Sun, 12 Apr 2026 23:12:32 -0500 Subject: [PATCH 4/6] docs: remove Bob from workflow map diagrams Bob (Scrum Master) was consolidated into Amelia (Developer) in v6.3.0 (#2186) but still appeared in the workflow map diagrams for sprint-planning, create-story, and retrospective. Updated both English and French versions to show Amelia and removed the unused Bob CSS class. Closes #2249 --- website/public/workflow-map-diagram-fr.html | 7 +++---- website/public/workflow-map-diagram.html | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/website/public/workflow-map-diagram-fr.html b/website/public/workflow-map-diagram-fr.html index bc59f23a9..1fde3c038 100644 --- a/website/public/workflow-map-diagram-fr.html +++ b/website/public/workflow-map-diagram-fr.html @@ -93,7 +93,6 @@ .agent-icon.john { background: linear-gradient(135deg, #60a5fa, #3b82f6); } .agent-icon.sally { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #000; } .agent-icon.winston { background: linear-gradient(135deg, #a78bfa, #8b5cf6); } - .agent-icon.bob { background: linear-gradient(135deg, #34d399, #10b981); color: #000; } .agent-icon.amelia { background: linear-gradient(135deg, #fb7185, #ef4444); } .agent-name { font-size: 0.65rem; } @@ -261,7 +260,7 @@ sprint-planning
-
B
Bob
+
A
Amelia
sprint-status.yaml β†’
@@ -270,7 +269,7 @@ create-story
-
B
Bob
+
A
Amelia
story-[slug].md β†’
@@ -308,7 +307,7 @@ par Epic
-
B
Bob
+
A
Amelia
leΓ§ons
diff --git a/website/public/workflow-map-diagram.html b/website/public/workflow-map-diagram.html index 897492700..0a17cc2eb 100644 --- a/website/public/workflow-map-diagram.html +++ b/website/public/workflow-map-diagram.html @@ -93,7 +93,6 @@ .agent-icon.john { background: linear-gradient(135deg, #60a5fa, #3b82f6); } .agent-icon.sally { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #000; } .agent-icon.winston { background: linear-gradient(135deg, #a78bfa, #8b5cf6); } - .agent-icon.bob { background: linear-gradient(135deg, #34d399, #10b981); color: #000; } .agent-icon.amelia { background: linear-gradient(135deg, #fb7185, #ef4444); } .agent-name { font-size: 0.65rem; } @@ -272,7 +271,7 @@ sprint-planning
-
B
Bob
+
A
Amelia
sprint-status.yaml β†’
@@ -281,7 +280,7 @@ create-story
-
B
Bob
+
A
Amelia
story-[slug].md β†’
@@ -319,7 +318,7 @@ per epic
-
B
Bob
+
A
Amelia
lessons
From a6d075bd0bddcaad495de700d2471c7c3689b7dd Mon Sep 17 00:00:00 2001 From: Brian Madison Date: Mon, 13 Apr 2026 00:44:28 -0500 Subject: [PATCH 5/6] fix(installer): replace fs-extra with native node:fs to prevent file loss fs-extra routes all operations through graceful-fs, which globally monkey-patches node:fs with a deferred retry queue. During multi-module installs (~500+ file ops), retried unlink operations from one module's remove phase can fire after the next module's copy phase has written files, silently deleting them non-deterministically. Replace fs-extra with a thin fs-native.js wrapper over node:fs/promises and node:fs. All 21 consumers now use native APIs with no global monkey-patching, eliminating the retry-queue race condition entirely. Closes #1779 --- package.json | 1 - test/test-installation-components.js | 2 +- tools/installer/commands/status.js | 2 +- tools/installer/commands/uninstall.js | 2 +- tools/installer/core/existing-install.js | 2 +- tools/installer/core/install-paths.js | 2 +- tools/installer/core/installer.js | 2 +- tools/installer/core/manifest-generator.js | 2 +- tools/installer/core/manifest.js | 2 +- tools/installer/file-ops.js | 2 +- tools/installer/fs-native.js | 87 +++++++++++++++++++ tools/installer/ide/_config-driven.js | 2 +- tools/installer/ide/platform-codes.js | 2 +- tools/installer/ide/shared/skill-manifest.js | 2 +- tools/installer/message-loader.js | 2 +- tools/installer/modules/community-manager.js | 2 +- .../modules/custom-module-manager.js | 2 +- tools/installer/modules/external-manager.js | 2 +- tools/installer/modules/official-modules.js | 2 +- tools/installer/modules/plugin-resolver.js | 2 +- tools/installer/project-root.js | 2 +- tools/installer/ui.js | 2 +- tools/migrate-custom-module-paths.js | 2 +- 23 files changed, 108 insertions(+), 22 deletions(-) create mode 100644 tools/installer/fs-native.js diff --git a/package.json b/package.json index 875d788f5..a26398fdf 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,6 @@ "chalk": "^4.1.2", "commander": "^14.0.0", "csv-parse": "^6.1.0", - "fs-extra": "^11.3.0", "glob": "^11.0.3", "ignore": "^7.0.5", "js-yaml": "^4.1.0", diff --git a/test/test-installation-components.js b/test/test-installation-components.js index 10639bab8..f1c1be486 100644 --- a/test/test-installation-components.js +++ b/test/test-installation-components.js @@ -13,7 +13,7 @@ const path = require('node:path'); const os = require('node:os'); -const fs = require('fs-extra'); +const fs = require('../tools/installer/fs-native'); const { Installer } = require('../tools/installer/core/installer'); const { ManifestGenerator } = require('../tools/installer/core/manifest-generator'); const { OfficialModules } = require('../tools/installer/modules/official-modules'); diff --git a/tools/installer/commands/status.js b/tools/installer/commands/status.js index 49c0afd73..c7f4a816c 100644 --- a/tools/installer/commands/status.js +++ b/tools/installer/commands/status.js @@ -19,7 +19,7 @@ module.exports = { const { bmadDir } = await installer.findBmadDir(projectDir); // Check if bmad directory exists - const fs = require('fs-extra'); + const fs = require('../fs-native'); if (!(await fs.pathExists(bmadDir))) { await prompts.log.warn('No BMAD installation found in the current directory.'); await prompts.log.message(`Expected location: ${bmadDir}`); diff --git a/tools/installer/commands/uninstall.js b/tools/installer/commands/uninstall.js index d0e168a15..727b7b0ef 100644 --- a/tools/installer/commands/uninstall.js +++ b/tools/installer/commands/uninstall.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('../fs-native'); const prompts = require('../prompts'); const { Installer } = require('../core/installer'); diff --git a/tools/installer/core/existing-install.js b/tools/installer/core/existing-install.js index 643f1d946..6bbf191d1 100644 --- a/tools/installer/core/existing-install.js +++ b/tools/installer/core/existing-install.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('../fs-native'); const yaml = require('yaml'); const { Manifest } = require('./manifest'); diff --git a/tools/installer/core/install-paths.js b/tools/installer/core/install-paths.js index f1c50ee43..e7fb98b6d 100644 --- a/tools/installer/core/install-paths.js +++ b/tools/installer/core/install-paths.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('../fs-native'); const { getProjectRoot } = require('../project-root'); const { BMAD_FOLDER_NAME } = require('../ide/shared/path-utils'); diff --git a/tools/installer/core/installer.js b/tools/installer/core/installer.js index 95e16adfe..2a9ff3272 100644 --- a/tools/installer/core/installer.js +++ b/tools/installer/core/installer.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('../fs-native'); const { Manifest } = require('./manifest'); const { OfficialModules } = require('../modules/official-modules'); const { IdeManager } = require('../ide/manager'); diff --git a/tools/installer/core/manifest-generator.js b/tools/installer/core/manifest-generator.js index 13e33af56..477142888 100644 --- a/tools/installer/core/manifest-generator.js +++ b/tools/installer/core/manifest-generator.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('../fs-native'); const yaml = require('yaml'); const crypto = require('node:crypto'); const csv = require('csv-parse/sync'); diff --git a/tools/installer/core/manifest.js b/tools/installer/core/manifest.js index aaa86649a..2dc94ae9f 100644 --- a/tools/installer/core/manifest.js +++ b/tools/installer/core/manifest.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('../fs-native'); const crypto = require('node:crypto'); const { getProjectRoot } = require('../project-root'); const prompts = require('../prompts'); diff --git a/tools/installer/file-ops.js b/tools/installer/file-ops.js index 5cd7970d8..2a2869930 100644 --- a/tools/installer/file-ops.js +++ b/tools/installer/file-ops.js @@ -1,4 +1,4 @@ -const fs = require('fs-extra'); +const fs = require('./fs-native'); const path = require('node:path'); const crypto = require('node:crypto'); diff --git a/tools/installer/fs-native.js b/tools/installer/fs-native.js new file mode 100644 index 000000000..6adeb1032 --- /dev/null +++ b/tools/installer/fs-native.js @@ -0,0 +1,87 @@ +// Drop-in replacement for fs-extra using native node:fs APIs. +// Eliminates graceful-fs monkey-patching that causes non-deterministic +// file loss during multi-module installs on macOS (issue #1779). +const fsp = require('node:fs/promises'); +const fs = require('node:fs'); +const path = require('node:path'); + +async function pathExists(p) { + try { + await fsp.access(p); + return true; + } catch { + return false; + } +} + +async function ensureDir(dir) { + await fsp.mkdir(dir, { recursive: true }); +} + +async function remove(p) { + await fsp.rm(p, { recursive: true, force: true }); +} + +async function copy(src, dest, options = {}) { + const filterFn = options.filter; + const srcStat = await fsp.stat(src); + + if (srcStat.isFile()) { + if (filterFn && !(await filterFn(src, dest))) return; + await fsp.mkdir(path.dirname(dest), { recursive: true }); + await fsp.copyFile(src, dest); + return; + } + + if (srcStat.isDirectory()) { + if (filterFn && !(await filterFn(src, dest))) return; + await fsp.mkdir(dest, { recursive: true }); + const entries = await fsp.readdir(src, { withFileTypes: true }); + for (const entry of entries) { + await copy(path.join(src, entry.name), path.join(dest, entry.name), options); + } + } +} + +function readJsonSync(p) { + return JSON.parse(fs.readFileSync(p, 'utf8')); +} + +async function writeJson(p, data, options = {}) { + const spaces = options.spaces ?? 2; + await fsp.writeFile(p, JSON.stringify(data, null, spaces) + '\n', 'utf8'); +} + +module.exports = { + // Native async (node:fs/promises) + readFile: fsp.readFile, + writeFile: fsp.writeFile, + stat: fsp.stat, + readdir: fsp.readdir, + access: fsp.access, + rename: fsp.rename, + unlink: fsp.unlink, + chmod: fsp.chmod, + mkdir: fsp.mkdir, + mkdtemp: fsp.mkdtemp, + copyFile: fsp.copyFile, + rm: fsp.rm, + + // fs-extra compatible helpers (native implementations) + pathExists, + ensureDir, + remove, + copy, + readJsonSync, + writeJson, + + // Sync methods from core node:fs + existsSync: fs.existsSync.bind(fs), + readFileSync: fs.readFileSync.bind(fs), + writeFileSync: fs.writeFileSync.bind(fs), + createReadStream: fs.createReadStream.bind(fs), + pathExistsSync: fs.existsSync.bind(fs), + + // Constants + constants: fs.constants, +}; diff --git a/tools/installer/ide/_config-driven.js b/tools/installer/ide/_config-driven.js index 9c7df4bc5..563818f67 100644 --- a/tools/installer/ide/_config-driven.js +++ b/tools/installer/ide/_config-driven.js @@ -1,6 +1,6 @@ const os = require('node:os'); const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('../fs-native'); const yaml = require('yaml'); const prompts = require('../prompts'); const csv = require('csv-parse/sync'); diff --git a/tools/installer/ide/platform-codes.js b/tools/installer/ide/platform-codes.js index 32d82e9cc..f29be8fcb 100644 --- a/tools/installer/ide/platform-codes.js +++ b/tools/installer/ide/platform-codes.js @@ -1,4 +1,4 @@ -const fs = require('fs-extra'); +const fs = require('../fs-native'); const path = require('node:path'); const yaml = require('yaml'); diff --git a/tools/installer/ide/shared/skill-manifest.js b/tools/installer/ide/shared/skill-manifest.js index 746d5d16f..1dfc7eb35 100644 --- a/tools/installer/ide/shared/skill-manifest.js +++ b/tools/installer/ide/shared/skill-manifest.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('../../fs-native'); const yaml = require('yaml'); /** diff --git a/tools/installer/message-loader.js b/tools/installer/message-loader.js index 03ba7eca1..97f02d6e4 100644 --- a/tools/installer/message-loader.js +++ b/tools/installer/message-loader.js @@ -1,4 +1,4 @@ -const fs = require('fs-extra'); +const fs = require('./fs-native'); const path = require('node:path'); const yaml = require('yaml'); const prompts = require('./prompts'); diff --git a/tools/installer/modules/community-manager.js b/tools/installer/modules/community-manager.js index 0f88cffff..3e0217688 100644 --- a/tools/installer/modules/community-manager.js +++ b/tools/installer/modules/community-manager.js @@ -1,4 +1,4 @@ -const fs = require('fs-extra'); +const fs = require('../fs-native'); const os = require('node:os'); const path = require('node:path'); const { execSync } = require('node:child_process'); diff --git a/tools/installer/modules/custom-module-manager.js b/tools/installer/modules/custom-module-manager.js index e0f8b7085..482c4dc43 100644 --- a/tools/installer/modules/custom-module-manager.js +++ b/tools/installer/modules/custom-module-manager.js @@ -1,4 +1,4 @@ -const fs = require('fs-extra'); +const fs = require('../fs-native'); const os = require('node:os'); const path = require('node:path'); const { execSync } = require('node:child_process'); diff --git a/tools/installer/modules/external-manager.js b/tools/installer/modules/external-manager.js index 0b8f5074c..5169ffb50 100644 --- a/tools/installer/modules/external-manager.js +++ b/tools/installer/modules/external-manager.js @@ -1,4 +1,4 @@ -const fs = require('fs-extra'); +const fs = require('../fs-native'); const os = require('node:os'); const path = require('node:path'); const { execSync } = require('node:child_process'); diff --git a/tools/installer/modules/official-modules.js b/tools/installer/modules/official-modules.js index 6158a7863..19dc0f4dc 100644 --- a/tools/installer/modules/official-modules.js +++ b/tools/installer/modules/official-modules.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('../fs-native'); const yaml = require('yaml'); const prompts = require('../prompts'); const { getProjectRoot, getSourcePath, getModulePath } = require('../project-root'); diff --git a/tools/installer/modules/plugin-resolver.js b/tools/installer/modules/plugin-resolver.js index 9fbf325a2..58e20ab88 100644 --- a/tools/installer/modules/plugin-resolver.js +++ b/tools/installer/modules/plugin-resolver.js @@ -1,4 +1,4 @@ -const fs = require('fs-extra'); +const fs = require('../fs-native'); const path = require('node:path'); const yaml = require('yaml'); diff --git a/tools/installer/project-root.js b/tools/installer/project-root.js index 26063f81f..037f1a430 100644 --- a/tools/installer/project-root.js +++ b/tools/installer/project-root.js @@ -1,5 +1,5 @@ const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('./fs-native'); /** * Find the BMAD project root directory by looking for package.json diff --git a/tools/installer/ui.js b/tools/installer/ui.js index 9e48c647a..d1c5189e9 100644 --- a/tools/installer/ui.js +++ b/tools/installer/ui.js @@ -1,6 +1,6 @@ const path = require('node:path'); const os = require('node:os'); -const fs = require('fs-extra'); +const fs = require('./fs-native'); const { CLIUtils } = require('./cli-utils'); const { ExternalModuleManager } = require('./modules/external-manager'); const { getProjectRoot } = require('./project-root'); diff --git a/tools/migrate-custom-module-paths.js b/tools/migrate-custom-module-paths.js index 13aa3e710..b199e8bfe 100755 --- a/tools/migrate-custom-module-paths.js +++ b/tools/migrate-custom-module-paths.js @@ -3,7 +3,7 @@ * This should be run once to update existing installations */ -const fs = require('fs-extra'); +const fs = require('./installer/fs-native'); const path = require('node:path'); const yaml = require('yaml'); const chalk = require('chalk'); From c6c8301ea180bbdc3d16d2745c37ee9288f45238 Mon Sep 17 00:00:00 2001 From: Brian Madison Date: Mon, 13 Apr 2026 00:52:41 -0500 Subject: [PATCH 6/6] fix(installer): add move() and overwrite support to fs-native MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing move() with cross-device fallback (rename β†’ copy+rm on EXDEV), needed by OfficialModules.createModuleDirectories for directory migrations during upgrades. Honor overwrite/errorOnExist options in copy() to match fs-extra behavior for callers that pass these flags. --- tools/installer/fs-native.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/installer/fs-native.js b/tools/installer/fs-native.js index 6adeb1032..b6a4abfa5 100644 --- a/tools/installer/fs-native.js +++ b/tools/installer/fs-native.js @@ -24,11 +24,21 @@ async function remove(p) { async function copy(src, dest, options = {}) { const filterFn = options.filter; + const overwrite = options.overwrite !== false; const srcStat = await fsp.stat(src); if (srcStat.isFile()) { if (filterFn && !(await filterFn(src, dest))) return; await fsp.mkdir(path.dirname(dest), { recursive: true }); + if (!overwrite) { + try { + await fsp.access(dest); + if (options.errorOnExist) throw new Error(`${dest} already exists`); + return; + } catch (error) { + if (error.message.includes('already exists')) throw error; + } + } await fsp.copyFile(src, dest); return; } @@ -43,6 +53,19 @@ async function copy(src, dest, options = {}) { } } +async function move(src, dest) { + try { + await fsp.rename(src, dest); + } catch (error) { + if (error.code === 'EXDEV') { + await copy(src, dest); + await fsp.rm(src, { recursive: true, force: true }); + } else { + throw error; + } + } +} + function readJsonSync(p) { return JSON.parse(fs.readFileSync(p, 'utf8')); } @@ -72,6 +95,7 @@ module.exports = { ensureDir, remove, copy, + move, readJsonSync, writeJson,