From 0f37258d5c3d50cb7e0ddfd9d8faec3c5d99ecb2 Mon Sep 17 00:00:00 2001 From: sno Date: Tue, 17 Feb 2026 19:37:06 +0100 Subject: [PATCH 01/16] feat: add monorepo support with dynamic project context --- .github/copilot-instructions.md | 60 +++++++++++++++++++ src/bmm/module-help.csv | 1 + .../0-context/set-project/workflow.md | 36 +++++++++++ .../create-product-brief/workflow.md | 7 ++- .../research/workflow-domain-research.md | 10 +++- .../research/workflow-market-research.md | 10 +++- .../research/workflow-technical-research.md | 9 +++ .../create-prd/workflow-create-prd.md | 7 ++- .../create-prd/workflow-edit-prd.md | 6 +- .../create-prd/workflow-validate-prd.md | 7 ++- .../create-ux-design/workflow.md | 9 ++- .../create-architecture/workflow.md | 9 ++- .../code-review/instructions.xml | 6 ++ .../create-story/instructions.xml | 5 ++ .../dev-story/instructions.xml | 7 ++- .../retrospective/instructions.md | 12 +++- .../sprint-planning/instructions.md | 12 +++- .../sprint-status/instructions.md | 9 +++ .../bmad-quick-flow/quick-dev/workflow.md | 9 ++- .../bmad-quick-flow/quick-spec/workflow.md | 8 ++- .../generate-project-context/workflow.md | 9 ++- .../advanced-elicitation/workflow.xml | 5 ++ src/core/workflows/brainstorming/workflow.md | 9 ++- src/core/workflows/party-mode/workflow.md | 9 ++- 24 files changed, 252 insertions(+), 19 deletions(-) create mode 100644 .github/copilot-instructions.md create mode 100644 src/bmm/workflows/0-context/set-project/workflow.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 000000000..7a70892e8 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,60 @@ + + +# BMAD Method — Project Instructions + +## Project Configuration + +- **Project**: snowmain1 +- **User**: Sergey +- **Communication Language**: English +- **Document Output Language**: English +- **User Skill Level**: expert +- **Output Folder**: {project-root}/\_bmad-output/{context} (Dynamic) +- **Planning Artifacts**: {project-root}/\_bmad-output/{context}/planning-artifacts +- **Implementation Artifacts**: {project-root}/\_bmad-output/{context}/implementation-artifacts +- **Project Knowledge**: {project-root}/docs + +## BMAD Runtime Structure + +- **Agent definitions**: `_bmad/bmm/agents/` (BMM module) and `_bmad/core/agents/` (core) +- **Workflow definitions**: `_bmad/bmm/workflows/` (organized by phase) +- **Core tasks**: `_bmad/core/tasks/` (help, editorial review, indexing, sharding, adversarial review) +- **Core workflows**: `_bmad/core/workflows/` (brainstorming, party-mode, advanced-elicitation) +- **Workflow engine**: `_bmad/core/tasks/workflow.xml` (executes YAML-based workflows) +- **Module configuration**: `_bmad/bmm/config.yaml` +- **Core configuration**: `_bmad/core/config.yaml` +- **Agent manifest**: `_bmad/_config/agent-manifest.csv` +- **Workflow manifest**: `_bmad/_config/workflow-manifest.csv` +- **Help manifest**: `_bmad/_config/bmad-help.csv` +- **Agent memory**: `_bmad/_memory/` + +## Key Conventions + +- Always load `_bmad/bmm/config.yaml` before any agent activation or workflow execution +- Store all config fields as session variables: `{user_name}`, `{communication_language}`, `{output_folder}`, `{planning_artifacts}`, `{implementation_artifacts}`, `{project_knowledge}` +- MD-based workflows execute directly — load and follow the `.md` file +- YAML-based workflows require the workflow engine — load `workflow.xml` first, then pass the `.yaml` config +- Follow step-based workflow execution: load steps JIT, never multiple at once +- Save outputs after EACH step when using the workflow engine +- The `{project-root}` variable resolves to the workspace root at runtime + +## Available Agents + +| Agent | Persona | Title | Capabilities | +| ------------------- | ----------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| bmad-master | BMad Master | BMad Master Executor, Knowledge Custodian, and Workflow Orchestrator | runtime resource management, workflow orchestration, task execution, knowledge custodian | +| analyst | Mary | Business Analyst | market research, competitive analysis, requirements elicitation, domain expertise | +| architect | Winston | Architect | distributed systems, cloud infrastructure, API design, scalable patterns | +| dev | Amelia | Developer Agent | story execution, test-driven development, code implementation | +| pm | John | Product Manager | PRD creation, requirements discovery, stakeholder alignment, user interviews | +| qa | Quinn | QA Engineer | test automation, API testing, E2E testing, coverage analysis | +| quick-flow-solo-dev | Barry | Quick Flow Solo Dev | rapid spec creation, lean implementation, minimum ceremony | +| sm | Bob | Scrum Master | sprint planning, story preparation, agile ceremonies, backlog management | +| tech-writer | Paige | Technical Writer | documentation, Mermaid diagrams, standards compliance, concept explanation | +| ux-designer | Sally | UX Designer | user research, interaction design, UI patterns, experience strategy | + +## Slash Commands + +Type `/bmad-` in Copilot Chat to see all available BMAD workflows and agent activators. Agents are also available in the agents dropdown. + + diff --git a/src/bmm/module-help.csv b/src/bmm/module-help.csv index 635bb8a81..a77860a06 100644 --- a/src/bmm/module-help.csv +++ b/src/bmm/module-help.csv @@ -28,4 +28,5 @@ bmm,4-implementation,Create Story,CS,30,_bmad/bmm/workflows/4-implementation/cre bmm,4-implementation,Dev Story,DS,40,_bmad/bmm/workflows/4-implementation/dev-story/workflow.yaml,bmad-bmm-dev-story,true,dev,Create Mode,"Story cycle: Execute story implementation tasks and tests then CR then back to DS if fixes needed",,, bmm,4-implementation,Code Review,CR,50,_bmad/bmm/workflows/4-implementation/code-review/workflow.yaml,bmad-bmm-code-review,false,dev,Create Mode,"Story cycle: If issues back to DS if approved then next CS or ER if epic complete",,, bmm,4-implementation,QA Automation Test,QA,45,_bmad/bmm/workflows/qa/automate/workflow.yaml,bmad-bmm-qa-automate,false,qa,Create Mode,"Generate automated API and E2E tests for implemented code using the project's existing test framework (detects existing well known in use test frameworks). Use after implementation to add test coverage. NOT for code review or story validation - use CR for that.",implementation_artifacts,"test suite", +bmm,anytime,Set Project,SPJ,05,_bmad/bmm/workflows/0-context/set-project/workflow.md,bmad-set-project,false,bmad-master,Anytime,"Set or clear the current project context for monorepo support.",_bmad,.current_project, bmm,4-implementation,Retrospective,ER,60,_bmad/bmm/workflows/4-implementation/retrospective/workflow.yaml,bmad-bmm-retrospective,false,sm,Create Mode,"Optional at epic end: Review completed work lessons learned and next epic or if major issues consider CC",implementation_artifacts,retrospective, diff --git a/src/bmm/workflows/0-context/set-project/workflow.md b/src/bmm/workflows/0-context/set-project/workflow.md new file mode 100644 index 000000000..8424c18b0 --- /dev/null +++ b/src/bmm/workflows/0-context/set-project/workflow.md @@ -0,0 +1,36 @@ +--- +name: set-project +description: Set the current project context for monorepo support +main_config: '{project-root}/_bmad/bmm/config.yaml' +--- + +# Set Project Context + +**Goal:** Configure the active project path for BMAD artifacts. + +**Your Role:** Configuration Assistant. + +## WORKFLOW ARCHITECTURE + +This is a single-step workflow that updates a local state file. + +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +### 2. Context Management + +1. **Ask User:** "Please enter the **project name** or path relative to `_bmad-output/` (e.g. `project-name` or `libs/auth-lib`). Enter `CLEAR` to reset to root." +2. **Wait for Input.** +3. **Process Input:** + - **Case: CLEAR**: + - Delete file: `_bmad/.current_project` + - Output: "✅ Project context cleared. Artifacts will go to root `_bmad-output/`." + - **Case: Path Provided**: + - **Sanitize:** Remove leading `/` or `_bmad-output/` if present in the input. + - Write file: `_bmad/.current_project` with content `` + - Output: "✅ Project context set to: ``. Artifacts will go to `_bmad-output//`." + +### 3. Verification + +- Display the full resolved output path for confirmation. diff --git a/src/bmm/workflows/1-analysis/create-product-brief/workflow.md b/src/bmm/workflows/1-analysis/create-product-brief/workflow.md index 9d5e83f19..6715a1462 100644 --- a/src/bmm/workflows/1-analysis/create-product-brief/workflow.md +++ b/src/bmm/workflows/1-analysis/create-product-brief/workflow.md @@ -48,7 +48,12 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {project-root}/_bmad/bmm/config.yaml and resolve: +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project` exists. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name`, `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/1-analysis/research/workflow-domain-research.md b/src/bmm/workflows/1-analysis/research/workflow-domain-research.md index 91fcbaa9a..923e2a0b7 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-domain-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-domain-research.md @@ -15,7 +15,15 @@ description: Conduct domain research covering industry analysis, regulations, te ## CONFIGURATION -Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project` exists. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` + - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` - `date` as a system-generated value diff --git a/src/bmm/workflows/1-analysis/research/workflow-market-research.md b/src/bmm/workflows/1-analysis/research/workflow-market-research.md index 5669e6f24..c4f30d36c 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-market-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-market-research.md @@ -15,7 +15,15 @@ description: Conduct market research covering market size, growth, competition, ## CONFIGURATION -Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` + - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` - `date` as a system-generated value diff --git a/src/bmm/workflows/1-analysis/research/workflow-technical-research.md b/src/bmm/workflows/1-analysis/research/workflow-technical-research.md index 2ac5420ce..dbc58b0e9 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-technical-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-technical-research.md @@ -15,6 +15,15 @@ description: Conduct technical research covering technology evaluation, architec ## CONFIGURATION +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project` exists. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` + Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md index 7d10ec3ed..6c846d7ea 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md @@ -48,7 +48,12 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve: +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project` exists. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md index 5cb05af53..3ba6b3c2f 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md @@ -48,8 +48,12 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve: +Load and read full config from {main_config} and resolve basic variables. +**Monorepo Context Check:** +1. Check if `_bmad/.current_project` exists. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` - `date` as system-generated current datetime diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md index e21745139..03045b967 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md @@ -48,7 +48,12 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve: +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project` exists. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md b/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md index 4af87c39a..9f1e8f4fa 100644 --- a/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md +++ b/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md @@ -22,9 +22,14 @@ This uses **micro-file architecture** for disciplined execution: ## INITIALIZATION -### Configuration Loading +### 1. Configuration Loading -Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/3-solutioning/create-architecture/workflow.md b/src/bmm/workflows/3-solutioning/create-architecture/workflow.md index b75b4a46c..201c04cac 100644 --- a/src/bmm/workflows/3-solutioning/create-architecture/workflow.md +++ b/src/bmm/workflows/3-solutioning/create-architecture/workflow.md @@ -25,7 +25,14 @@ This uses **micro-file architecture** for disciplined execution: ## INITIALIZATION -### Configuration Loading +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project` exists. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: diff --git a/src/bmm/workflows/4-implementation/code-review/instructions.xml b/src/bmm/workflows/4-implementation/code-review/instructions.xml index e5649559d..4be776b58 100644 --- a/src/bmm/workflows/4-implementation/code-review/instructions.xml +++ b/src/bmm/workflows/4-implementation/code-review/instructions.xml @@ -16,6 +16,11 @@ + + Read content as project_suffix + Override output_folder to {project-root}/_bmad-output/{project_suffix} + + Use provided {{story_path}} or ask user which story file to review Read COMPLETE story file Set {{story_key}} = extracted key from filename (e.g., "1-2-user-authentication.md" → "1-2-user-authentication") or story @@ -41,6 +46,7 @@ Load {project_context} for coding standards (if exists) + diff --git a/src/bmm/workflows/4-implementation/create-story/instructions.xml b/src/bmm/workflows/4-implementation/create-story/instructions.xml index f9433371f..b06b4c29e 100644 --- a/src/bmm/workflows/4-implementation/create-story/instructions.xml +++ b/src/bmm/workflows/4-implementation/create-story/instructions.xml @@ -18,6 +18,11 @@ 🎯 ZERO USER INTERVENTION: Process should be fully automated except for initial epic/story selection or missing documents + + Read content as project_suffix + Override output_folder to {project-root}/_bmad-output/{project_suffix} + + Parse user-provided story path: extract epic_num, story_num, story_title from format like "1-2-user-auth" Set {{epic_num}}, {{story_num}}, {{story_key}} from user input diff --git a/src/bmm/workflows/4-implementation/dev-story/instructions.xml b/src/bmm/workflows/4-implementation/dev-story/instructions.xml index 3c4989f39..e0e4e7857 100644 --- a/src/bmm/workflows/4-implementation/dev-story/instructions.xml +++ b/src/bmm/workflows/4-implementation/dev-story/instructions.xml @@ -13,6 +13,11 @@ User skill level ({user_skill_level}) affects conversation style ONLY, not code updates. + + Read content as project_suffix + Override output_folder to {project-root}/_bmad-output/{project_suffix} + + Use {{story_path}} directly Read COMPLETE story file @@ -376,8 +381,6 @@ Communicate to {user_name} that story implementation is complete and ready for review Summarize key accomplishments: story ID, story key, title, key changes made, tests added, files modified - Provide the story file path and current status (now "review") - Based on {user_skill_level}, ask if user needs any explanations about: - What was implemented and how it works - Why certain technical decisions were made diff --git a/src/bmm/workflows/4-implementation/retrospective/instructions.md b/src/bmm/workflows/4-implementation/retrospective/instructions.md index 018ef6ee3..b824096ca 100644 --- a/src/bmm/workflows/4-implementation/retrospective/instructions.md +++ b/src/bmm/workflows/4-implementation/retrospective/instructions.md @@ -1,7 +1,17 @@ # Retrospective - Epic Completion Review Instructions The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -You MUST have already loaded and processed: {project-root}/_bmad/bmm/workflows/4-implementation/retrospective/workflow.yaml +You MUST have already loaded and processed: {installed_path}/workflow.yaml + +## 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` + Communicate all responses in {communication_language} and language MUST be tailored to {user_skill_level} Generate all documents in {document_output_language} ⚠️ ABSOLUTELY NO TIME ESTIMATES - NEVER mention hours, days, weeks, months, or ANY time-based predictions. AI has fundamentally changed development speed - what once took teams weeks/months can now be done by one person in hours. DO NOT give ANY time estimates whatsoever. diff --git a/src/bmm/workflows/4-implementation/sprint-planning/instructions.md b/src/bmm/workflows/4-implementation/sprint-planning/instructions.md index 316d2fec3..666125a42 100644 --- a/src/bmm/workflows/4-implementation/sprint-planning/instructions.md +++ b/src/bmm/workflows/4-implementation/sprint-planning/instructions.md @@ -3,7 +3,17 @@ The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml You MUST have already loaded and processed: {project-root}/_bmad/bmm/workflows/4-implementation/sprint-planning/workflow.yaml -## 📚 Document Discovery - Full Epic Loading +## 📚 Document Discovery +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` + +- Full Epic Loading **Strategy**: Sprint planning needs ALL epics and stories to build complete status tracking. diff --git a/src/bmm/workflows/4-implementation/sprint-status/instructions.md b/src/bmm/workflows/4-implementation/sprint-status/instructions.md index 4182e1f25..1ba831de4 100644 --- a/src/bmm/workflows/4-implementation/sprint-status/instructions.md +++ b/src/bmm/workflows/4-implementation/sprint-status/instructions.md @@ -1,6 +1,15 @@ # Sprint Status - Multi-Mode Service The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml + +## 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` You MUST have already loaded and processed: {project-root}/_bmad/bmm/workflows/4-implementation/sprint-status/workflow.yaml Modes: interactive (default), validate, data ⚠️ ABSOLUTELY NO TIME ESTIMATES. Do NOT mention hours, days, weeks, or timelines. diff --git a/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md b/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md index 8c6a1902b..73f1feee2 100644 --- a/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md +++ b/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md @@ -23,7 +23,14 @@ This uses **step-file architecture** for focused execution: ## INITIALIZATION -### Configuration Loading +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: diff --git a/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md b/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md index cc4fdf221..08146d91c 100644 --- a/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md +++ b/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md @@ -66,8 +66,14 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from `{main_config}` and resolve: +Load and read full config from {main_config} and resolve basic variables. +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` + +Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: - `project_name`, `planning_artifacts`, `implementation_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` - `date` as system-generated current datetime diff --git a/src/bmm/workflows/generate-project-context/workflow.md b/src/bmm/workflows/generate-project-context/workflow.md index 3f626d65f..05644360b 100644 --- a/src/bmm/workflows/generate-project-context/workflow.md +++ b/src/bmm/workflows/generate-project-context/workflow.md @@ -25,7 +25,14 @@ This uses **micro-file architecture** for disciplined execution: ## INITIALIZATION -### Configuration Loading +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: diff --git a/src/core/workflows/advanced-elicitation/workflow.xml b/src/core/workflows/advanced-elicitation/workflow.xml index ea7395e41..985ac0bc3 100644 --- a/src/core/workflows/advanced-elicitation/workflow.xml +++ b/src/core/workflows/advanced-elicitation/workflow.xml @@ -20,6 +20,11 @@ + + Read content as project_suffix + Override output_folder to {project-root}/_bmad-output/{project_suffix} + + Load and read {{methods}} and {{agent-party}} diff --git a/src/core/workflows/brainstorming/workflow.md b/src/core/workflows/brainstorming/workflow.md index 3190c983c..e6aab4c14 100644 --- a/src/core/workflows/brainstorming/workflow.md +++ b/src/core/workflows/brainstorming/workflow.md @@ -32,7 +32,14 @@ This uses **micro-file architecture** for disciplined execution: ## INITIALIZATION -### Configuration Loading +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project` exists. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` Load config from `{project-root}/_bmad/core/config.yaml` and resolve: diff --git a/src/core/workflows/party-mode/workflow.md b/src/core/workflows/party-mode/workflow.md index eaec3c931..f30e0d7df 100644 --- a/src/core/workflows/party-mode/workflow.md +++ b/src/core/workflows/party-mode/workflow.md @@ -25,9 +25,14 @@ This uses **micro-file architecture** with **sequential conversation orchestrati ## INITIALIZATION -### Configuration Loading +### 1. Configuration Loading -Load config from `{project-root}/_bmad/core/config.yaml` and resolve: +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project` exists. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` From 1237eeb375a8eb815c106a5e629919cfd53dd40f Mon Sep 17 00:00:00 2001 From: sno Date: Tue, 17 Feb 2026 19:46:14 +0100 Subject: [PATCH 02/16] feat: fix missing monorepo context logic and add validation tests --- package.json | 1 + .../workflow.md | 9 +- .../create-epics-and-stories/workflow.md | 7 +- .../correct-course/instructions.md | 8 ++ .../document-project/instructions.md | 9 ++ .../workflows/deep-dive-instructions.md | 10 +- .../workflows/full-scan-instructions.md | 10 ++ src/bmm/workflows/qa/automate/instructions.md | 9 ++ test/test-monorepo-validation.js | 129 ++++++++++++++++++ 9 files changed, 187 insertions(+), 5 deletions(-) create mode 100644 test/test-monorepo-validation.js diff --git a/package.json b/package.json index cd02e3746..8166acb2d 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "test": "npm run test:schemas && npm run test:refs && npm run test:install && npm run validate:schemas && npm run lint && npm run lint:md && npm run format:check", "test:coverage": "c8 --reporter=text --reporter=html npm run test:schemas", "test:install": "node test/test-installation-components.js", + "test:monorepo": "node test/test-monorepo-validation.js", "test:refs": "node test/test-file-refs-csv.js", "test:schemas": "node test/test-agent-schema.js", "validate:refs": "node tools/validate-file-refs.js", diff --git a/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md b/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md index 49d2afab9..c00edab53 100644 --- a/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md +++ b/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md @@ -42,9 +42,14 @@ description: 'Critical validation workflow that assesses PRD, Architecture, and ## INITIALIZATION SEQUENCE -### 1. Module Configuration Loading +### 1. Configuration Loading -Load and read full config from {project-root}/_bmad/bmm/config.yaml and resolve: +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name`, `communication_language`, `document_output_language` - ✅ YOU MUST ALWAYS SPEAK OUTPUT In your Agent communication style with the config `{communication_language}` diff --git a/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md b/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md index a0e232ab8..389eb6b7e 100644 --- a/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md +++ b/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md @@ -48,7 +48,12 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {project-root}/_bmad/bmm/config.yaml and resolve: +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project` exists. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name`, `communication_language`, `document_output_language` - ✅ YOU MUST ALWAYS SPEAK OUTPUT In your Agent communication style with the config `{communication_language}` diff --git a/src/bmm/workflows/4-implementation/correct-course/instructions.md b/src/bmm/workflows/4-implementation/correct-course/instructions.md index bbe2c21e0..9556de401 100644 --- a/src/bmm/workflows/4-implementation/correct-course/instructions.md +++ b/src/bmm/workflows/4-implementation/correct-course/instructions.md @@ -40,6 +40,14 @@ - [x] Done - Item completed successfully - [N/A] Skip - Item not applicable to this change - [!] Action-needed - Item requires attention or follow-up +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` Maintain running notes of findings and impacts discovered Present checklist progress after each major section diff --git a/src/bmm/workflows/document-project/instructions.md b/src/bmm/workflows/document-project/instructions.md index 0354be610..a81289012 100644 --- a/src/bmm/workflows/document-project/instructions.md +++ b/src/bmm/workflows/document-project/instructions.md @@ -79,6 +79,15 @@ +## 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` + Check if {project_knowledge}/index.md exists diff --git a/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md b/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md index 637621c4c..85b9e2887 100644 --- a/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md +++ b/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md @@ -250,8 +250,14 @@ Detailed exhaustive analysis of specific areas: - Complete file inventory with all exports - Dependency graph and data flow -- Integration points and API contracts -- Testing analysis and coverage +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - Related code and reuse opportunities - Implementation guidance diff --git a/src/bmm/workflows/document-project/workflows/full-scan-instructions.md b/src/bmm/workflows/document-project/workflows/full-scan-instructions.md index 8a3621d21..b55ac3b77 100644 --- a/src/bmm/workflows/document-project/workflows/full-scan-instructions.md +++ b/src/bmm/workflows/document-project/workflows/full-scan-instructions.md @@ -95,6 +95,16 @@ Your choice [1/2/3]: - Best for: Quick project overview, initial understanding - File reading: Minimal (configs, README, package.json, etc.) +## 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` +json, etc.) + **2. Deep Scan** (10-30 minutes) - Reads files in critical directories based on project type diff --git a/src/bmm/workflows/qa/automate/instructions.md b/src/bmm/workflows/qa/automate/instructions.md index 03653337f..dd0c91877 100644 --- a/src/bmm/workflows/qa/automate/instructions.md +++ b/src/bmm/workflows/qa/automate/instructions.md @@ -18,6 +18,15 @@ Check project for existing test framework: - Search online for current recommended test framework for that stack - Suggest the meta framework and use it (or ask user to confirm) +### 1. Configuration Loading + +Load and read full config from {main_config} and resolve basic variables. + +**Monorepo Context Check:** +1. Check if `_bmad/.current_project exists`. +2. If it exists, read its content as `{project_suffix}` and override output folder: + - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` + ### Step 1: Identify Features Ask user what to test: diff --git a/test/test-monorepo-validation.js b/test/test-monorepo-validation.js new file mode 100644 index 000000000..bab840708 --- /dev/null +++ b/test/test-monorepo-validation.js @@ -0,0 +1,129 @@ +/** + * Monorepo Support Validation Tests + * + * Verifies that: + * 1. The set-project workflow is correctly registered. + * 2. All core and BMM workflows contain the monorepo context logic. + */ + +const fs = require('fs-extra'); +const path = require('node:path'); +const glob = require('glob'); + +// ANSI colors +const colors = { + reset: '\u001B[0m', + green: '\u001B[32m', + red: '\u001B[31m', + yellow: '\u001B[33m', + cyan: '\u001B[36m', + dim: '\u001B[2m', +}; + +let passed = 0; +let failed = 0; + +function assert(condition, testName, errorMessage = '') { + if (condition) { + console.log(`${colors.green}✓${colors.reset} ${testName}`); + passed++; + } else { + console.log(`${colors.red}✗${colors.reset} ${testName}`); + if (errorMessage) { + console.log(` ${colors.dim}${errorMessage}${colors.reset}`); + } + failed++; + } +} + +async function runTests() { + console.log(`${colors.cyan}========================================`); + console.log('Monorepo Support Validation Tests'); + console.log(`========================================${colors.reset}\n`); + + const projectRoot = path.join(__dirname, '..'); + + // 1. Verify set-project registration + console.log(`${colors.yellow}Test Suite 1: Workflow Registration${colors.reset}\n`); + try { + const csvPath = path.join(projectRoot, 'src/bmm/module-help.csv'); + const content = await fs.readFile(csvPath, 'utf8'); + assert(content.includes('set-project'), 'set-project workflow is registered in module-help.csv'); + } catch (error) { + assert(false, 'Registration check failed', error.message); + } + + console.log(''); + + // 2. Verify context logic in workflows + console.log(`${colors.yellow}Test Suite 2: Workflow Context Logic${colors.reset}\n`); + + const workflowFiles = glob.sync('src/{core,bmm}/workflows/**/*.{md,xml}', { cwd: projectRoot }); + + // Workflows that MUST have the check + const requiredWorkflows = [ + 'brainstorming', + 'party-mode', + 'create-product-brief', + 'create-prd', + 'create-architecture', + 'code-review', + 'create-story', + 'dev-story', + 'set-project', // Should not have the check itself, but let's exclude it + ]; + + for (const file of workflowFiles) { + const basename = path.basename(path.dirname(file)); + if (basename === 'set-project' || basename === '0-context') continue; + + const content = await fs.readFile(path.join(projectRoot, file), 'utf8'); + const isXml = file.endsWith('.xml'); + + if (isXml) { + assert(content.includes('_bmad/.current_project'), `XML workflow contains context check: ${file}`); + } else { + // Only check Markdown files that look like main workflow/instruction files + const filename = path.basename(file); + if (filename.includes('workflow') || filename.includes('instructions')) { + assert(content.includes('_bmad/.current_project'), `Markdown workflow contains context check: ${file}`); + } + } + } + + console.log(''); + + // 3. Verify set-project implementation + console.log(`${colors.yellow}Test Suite 3: set-project Implementation${colors.reset}\n`); + try { + const setProjectPath = path.join(projectRoot, 'src/bmm/workflows/0-context/set-project/workflow.md'); + const exists = await fs.pathExists(setProjectPath); + assert(exists, 'set-project workflow file exists'); + if (exists) { + const content = await fs.readFile(setProjectPath, 'utf8'); + assert(content.includes('_bmad/.current_project'), 'set-project implementation manages .current_project'); + } + } catch (error) { + assert(false, 'set-project check failed', error.message); + } + + console.log('\n'); + console.log(`${colors.cyan}========================================`); + console.log('Test Results:'); + console.log(` Passed: ${colors.green}${passed}${colors.reset}`); + console.log(` Failed: ${colors.red}${failed}${colors.reset}`); + console.log(`========================================${colors.reset}\n`); + + if (failed === 0) { + console.log(`${colors.green}✨ All monorepo validation tests passed!${colors.reset}\n`); + process.exit(0); + } else { + console.log(`${colors.red}❌ Some monorepo validation tests failed${colors.reset}\n`); + process.exit(1); + } +} + +runTests().catch((error) => { + console.error(error); + process.exit(1); +}); From 855a4b36957cff35aa60959bb38f5602d6a450f8 Mon Sep 17 00:00:00 2001 From: sno Date: Tue, 17 Feb 2026 21:58:59 +0100 Subject: [PATCH 03/16] feat: enhance installer copilot instructions for monorepo support --- .github/copilot-instructions.md | 60 ------------------- .../cli/installers/lib/ide/github-copilot.js | 6 +- 2 files changed, 3 insertions(+), 63 deletions(-) delete mode 100644 .github/copilot-instructions.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md deleted file mode 100644 index 7a70892e8..000000000 --- a/.github/copilot-instructions.md +++ /dev/null @@ -1,60 +0,0 @@ - - -# BMAD Method — Project Instructions - -## Project Configuration - -- **Project**: snowmain1 -- **User**: Sergey -- **Communication Language**: English -- **Document Output Language**: English -- **User Skill Level**: expert -- **Output Folder**: {project-root}/\_bmad-output/{context} (Dynamic) -- **Planning Artifacts**: {project-root}/\_bmad-output/{context}/planning-artifacts -- **Implementation Artifacts**: {project-root}/\_bmad-output/{context}/implementation-artifacts -- **Project Knowledge**: {project-root}/docs - -## BMAD Runtime Structure - -- **Agent definitions**: `_bmad/bmm/agents/` (BMM module) and `_bmad/core/agents/` (core) -- **Workflow definitions**: `_bmad/bmm/workflows/` (organized by phase) -- **Core tasks**: `_bmad/core/tasks/` (help, editorial review, indexing, sharding, adversarial review) -- **Core workflows**: `_bmad/core/workflows/` (brainstorming, party-mode, advanced-elicitation) -- **Workflow engine**: `_bmad/core/tasks/workflow.xml` (executes YAML-based workflows) -- **Module configuration**: `_bmad/bmm/config.yaml` -- **Core configuration**: `_bmad/core/config.yaml` -- **Agent manifest**: `_bmad/_config/agent-manifest.csv` -- **Workflow manifest**: `_bmad/_config/workflow-manifest.csv` -- **Help manifest**: `_bmad/_config/bmad-help.csv` -- **Agent memory**: `_bmad/_memory/` - -## Key Conventions - -- Always load `_bmad/bmm/config.yaml` before any agent activation or workflow execution -- Store all config fields as session variables: `{user_name}`, `{communication_language}`, `{output_folder}`, `{planning_artifacts}`, `{implementation_artifacts}`, `{project_knowledge}` -- MD-based workflows execute directly — load and follow the `.md` file -- YAML-based workflows require the workflow engine — load `workflow.xml` first, then pass the `.yaml` config -- Follow step-based workflow execution: load steps JIT, never multiple at once -- Save outputs after EACH step when using the workflow engine -- The `{project-root}` variable resolves to the workspace root at runtime - -## Available Agents - -| Agent | Persona | Title | Capabilities | -| ------------------- | ----------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -| bmad-master | BMad Master | BMad Master Executor, Knowledge Custodian, and Workflow Orchestrator | runtime resource management, workflow orchestration, task execution, knowledge custodian | -| analyst | Mary | Business Analyst | market research, competitive analysis, requirements elicitation, domain expertise | -| architect | Winston | Architect | distributed systems, cloud infrastructure, API design, scalable patterns | -| dev | Amelia | Developer Agent | story execution, test-driven development, code implementation | -| pm | John | Product Manager | PRD creation, requirements discovery, stakeholder alignment, user interviews | -| qa | Quinn | QA Engineer | test automation, API testing, E2E testing, coverage analysis | -| quick-flow-solo-dev | Barry | Quick Flow Solo Dev | rapid spec creation, lean implementation, minimum ceremony | -| sm | Bob | Scrum Master | sprint planning, story preparation, agile ceremonies, backlog management | -| tech-writer | Paige | Technical Writer | documentation, Mermaid diagrams, standards compliance, concept explanation | -| ux-designer | Sally | UX Designer | user research, interaction design, UI patterns, experience strategy | - -## Slash Commands - -Type `/bmad-` in Copilot Chat to see all available BMAD workflows and agent activators. Agents are also available in the agents dropdown. - - diff --git a/tools/cli/installers/lib/ide/github-copilot.js b/tools/cli/installers/lib/ide/github-copilot.js index 033e8d627..082cd1543 100644 --- a/tools/cli/installers/lib/ide/github-copilot.js +++ b/tools/cli/installers/lib/ide/github-copilot.js @@ -437,9 +437,9 @@ tools: ${toolsStr} - **Communication Language**: ${configVars.communication_language || '{{communication_language}}'} - **Document Output Language**: ${configVars.document_output_language || '{{document_output_language}}'} - **User Skill Level**: ${configVars.user_skill_level || '{{user_skill_level}}'} -- **Output Folder**: ${configVars.output_folder || '{{output_folder}}'} -- **Planning Artifacts**: ${configVars.planning_artifacts || '{{planning_artifacts}}'} -- **Implementation Artifacts**: ${configVars.implementation_artifacts || '{{implementation_artifacts}}'} +- **Output Folder**: ${configVars.output_folder || '{{output_folder}}'}/{context} (Dynamic) +- **Planning Artifacts**: ${configVars.planning_artifacts || '{{planning_artifacts}}'}/{context} (Dynamic) +- **Implementation Artifacts**: ${configVars.implementation_artifacts || '{{implementation_artifacts}}'}/{context} (Dynamic) - **Project Knowledge**: ${configVars.project_knowledge || '{{project_knowledge}}'} ## BMAD Runtime Structure From a023178c0c392b31bf676642542677d77879646f Mon Sep 17 00:00:00 2001 From: sno Date: Tue, 17 Feb 2026 22:02:39 +0100 Subject: [PATCH 04/16] fix: add missing main_config frontmatter to analysis workflows --- src/bmm/workflows/1-analysis/create-product-brief/workflow.md | 1 + .../workflows/1-analysis/research/workflow-domain-research.md | 1 + .../workflows/1-analysis/research/workflow-market-research.md | 1 + .../1-analysis/research/workflow-technical-research.md | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bmm/workflows/1-analysis/create-product-brief/workflow.md b/src/bmm/workflows/1-analysis/create-product-brief/workflow.md index 6715a1462..58bff4d44 100644 --- a/src/bmm/workflows/1-analysis/create-product-brief/workflow.md +++ b/src/bmm/workflows/1-analysis/create-product-brief/workflow.md @@ -1,6 +1,7 @@ --- name: create-product-brief description: Create comprehensive product briefs through collaborative step-by-step discovery as creative Business Analyst working with the user as peers. +main_config: '{project-root}/_bmad/bmm/config.yaml' --- # Product Brief Workflow diff --git a/src/bmm/workflows/1-analysis/research/workflow-domain-research.md b/src/bmm/workflows/1-analysis/research/workflow-domain-research.md index 923e2a0b7..453afa496 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-domain-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-domain-research.md @@ -1,6 +1,7 @@ --- name: domain-research description: Conduct domain research covering industry analysis, regulations, technology trends, and ecosystem dynamics using current web data and verified sources. +main_config: '{project-root}/_bmad/bmm/config.yaml' --- # Domain Research Workflow diff --git a/src/bmm/workflows/1-analysis/research/workflow-market-research.md b/src/bmm/workflows/1-analysis/research/workflow-market-research.md index c4f30d36c..9c48ac12b 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-market-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-market-research.md @@ -1,6 +1,7 @@ --- name: market-research description: Conduct market research covering market size, growth, competition, and customer insights using current web data and verified sources. +main_config: '{project-root}/_bmad/bmm/config.yaml' --- # Market Research Workflow diff --git a/src/bmm/workflows/1-analysis/research/workflow-technical-research.md b/src/bmm/workflows/1-analysis/research/workflow-technical-research.md index dbc58b0e9..9b03fbe54 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-technical-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-technical-research.md @@ -1,6 +1,7 @@ --- name: technical-research description: Conduct technical research covering technology evaluation, architecture decisions, and implementation approaches using current web data and verified sources. +main_config: '{project-root}/_bmad/bmm/config.yaml' --- # Technical Research Workflow @@ -24,7 +25,6 @@ Load and read full config from {main_config} and resolve basic variables. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` -Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` - `date` as a system-generated value From 5ae2cad5a339f6fd4e41730101087040a2134194 Mon Sep 17 00:00:00 2001 From: sno Date: Wed, 18 Feb 2026 09:28:17 +0100 Subject: [PATCH 05/16] fix: ensure absolute path resolution for monorepo context checks --- src/bmm/workflows/0-context/set-project/workflow.md | 4 ++-- src/bmm/workflows/1-analysis/create-product-brief/workflow.md | 2 +- .../workflows/1-analysis/research/workflow-domain-research.md | 2 +- .../1-analysis/research/workflow-technical-research.md | 2 +- .../2-plan-workflows/create-prd/workflow-create-prd.md | 2 +- .../2-plan-workflows/create-prd/workflow-edit-prd.md | 2 +- .../2-plan-workflows/create-prd/workflow-validate-prd.md | 2 +- .../workflows/3-solutioning/create-architecture/workflow.md | 2 +- .../3-solutioning/create-epics-and-stories/workflow.md | 2 +- .../workflows/4-implementation/code-review/instructions.xml | 2 +- .../workflows/4-implementation/retrospective/instructions.md | 2 +- .../4-implementation/sprint-planning/instructions.md | 2 +- .../workflows/4-implementation/sprint-status/instructions.md | 2 +- src/bmm/workflows/document-project/instructions.md | 2 +- .../document-project/workflows/deep-dive-instructions.md | 2 +- .../document-project/workflows/full-scan-instructions.md | 2 +- src/bmm/workflows/generate-project-context/workflow.md | 2 +- src/bmm/workflows/qa/automate/instructions.md | 2 +- src/core/workflows/brainstorming/workflow.md | 2 +- src/core/workflows/party-mode/workflow.md | 2 +- 20 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/bmm/workflows/0-context/set-project/workflow.md b/src/bmm/workflows/0-context/set-project/workflow.md index 8424c18b0..738d8c0ca 100644 --- a/src/bmm/workflows/0-context/set-project/workflow.md +++ b/src/bmm/workflows/0-context/set-project/workflow.md @@ -24,11 +24,11 @@ Load and read full config from {main_config} and resolve basic variables. 2. **Wait for Input.** 3. **Process Input:** - **Case: CLEAR**: - - Delete file: `_bmad/.current_project` + - Delete file: `{project-root}/_bmad/.current_project` - Output: "✅ Project context cleared. Artifacts will go to root `_bmad-output/`." - **Case: Path Provided**: - **Sanitize:** Remove leading `/` or `_bmad-output/` if present in the input. - - Write file: `_bmad/.current_project` with content `` + - Write file: `{project-root}/_bmad/.current_project` with content `` - Output: "✅ Project context set to: ``. Artifacts will go to `_bmad-output//`." ### 3. Verification diff --git a/src/bmm/workflows/1-analysis/create-product-brief/workflow.md b/src/bmm/workflows/1-analysis/create-product-brief/workflow.md index 58bff4d44..c5764d4ff 100644 --- a/src/bmm/workflows/1-analysis/create-product-brief/workflow.md +++ b/src/bmm/workflows/1-analysis/create-product-brief/workflow.md @@ -52,7 +52,7 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project` exists. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/1-analysis/research/workflow-domain-research.md b/src/bmm/workflows/1-analysis/research/workflow-domain-research.md index 453afa496..58cf01f4e 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-domain-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-domain-research.md @@ -21,7 +21,7 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project` exists. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/1-analysis/research/workflow-technical-research.md b/src/bmm/workflows/1-analysis/research/workflow-technical-research.md index 9b03fbe54..6e03f7af1 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-technical-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-technical-research.md @@ -21,7 +21,7 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project` exists. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md index 6c846d7ea..8b50a309d 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md @@ -51,7 +51,7 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project` exists. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md index 3ba6b3c2f..ada593f90 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md @@ -51,7 +51,7 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project` exists. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md index 03045b967..8e09bb612 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md @@ -51,7 +51,7 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project` exists. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/3-solutioning/create-architecture/workflow.md b/src/bmm/workflows/3-solutioning/create-architecture/workflow.md index 201c04cac..ceff8cb7e 100644 --- a/src/bmm/workflows/3-solutioning/create-architecture/workflow.md +++ b/src/bmm/workflows/3-solutioning/create-architecture/workflow.md @@ -30,7 +30,7 @@ This uses **micro-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project` exists. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md b/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md index 389eb6b7e..3d42212ec 100644 --- a/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md +++ b/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md @@ -51,7 +51,7 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project` exists. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/4-implementation/code-review/instructions.xml b/src/bmm/workflows/4-implementation/code-review/instructions.xml index 4be776b58..19902a093 100644 --- a/src/bmm/workflows/4-implementation/code-review/instructions.xml +++ b/src/bmm/workflows/4-implementation/code-review/instructions.xml @@ -16,7 +16,7 @@ - + Read content as project_suffix Override output_folder to {project-root}/_bmad-output/{project_suffix} diff --git a/src/bmm/workflows/4-implementation/retrospective/instructions.md b/src/bmm/workflows/4-implementation/retrospective/instructions.md index b824096ca..6fa97edca 100644 --- a/src/bmm/workflows/4-implementation/retrospective/instructions.md +++ b/src/bmm/workflows/4-implementation/retrospective/instructions.md @@ -8,7 +8,7 @@ Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/4-implementation/sprint-planning/instructions.md b/src/bmm/workflows/4-implementation/sprint-planning/instructions.md index 666125a42..2fbd0c1da 100644 --- a/src/bmm/workflows/4-implementation/sprint-planning/instructions.md +++ b/src/bmm/workflows/4-implementation/sprint-planning/instructions.md @@ -9,7 +9,7 @@ Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/4-implementation/sprint-status/instructions.md b/src/bmm/workflows/4-implementation/sprint-status/instructions.md index 1ba831de4..fc589a22a 100644 --- a/src/bmm/workflows/4-implementation/sprint-status/instructions.md +++ b/src/bmm/workflows/4-implementation/sprint-status/instructions.md @@ -7,7 +7,7 @@ Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` You MUST have already loaded and processed: {project-root}/_bmad/bmm/workflows/4-implementation/sprint-status/workflow.yaml diff --git a/src/bmm/workflows/document-project/instructions.md b/src/bmm/workflows/document-project/instructions.md index a81289012..35fcc290d 100644 --- a/src/bmm/workflows/document-project/instructions.md +++ b/src/bmm/workflows/document-project/instructions.md @@ -84,7 +84,7 @@ Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md b/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md index 85b9e2887..d0d1dd6d4 100644 --- a/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md +++ b/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md @@ -255,7 +255,7 @@ Detailed exhaustive analysis of specific areas: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - Related code and reuse opportunities diff --git a/src/bmm/workflows/document-project/workflows/full-scan-instructions.md b/src/bmm/workflows/document-project/workflows/full-scan-instructions.md index b55ac3b77..e43435bd2 100644 --- a/src/bmm/workflows/document-project/workflows/full-scan-instructions.md +++ b/src/bmm/workflows/document-project/workflows/full-scan-instructions.md @@ -100,7 +100,7 @@ Your choice [1/2/3]: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` json, etc.) diff --git a/src/bmm/workflows/generate-project-context/workflow.md b/src/bmm/workflows/generate-project-context/workflow.md index 05644360b..88b8e8270 100644 --- a/src/bmm/workflows/generate-project-context/workflow.md +++ b/src/bmm/workflows/generate-project-context/workflow.md @@ -30,7 +30,7 @@ This uses **micro-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/qa/automate/instructions.md b/src/bmm/workflows/qa/automate/instructions.md index dd0c91877..91ee2f771 100644 --- a/src/bmm/workflows/qa/automate/instructions.md +++ b/src/bmm/workflows/qa/automate/instructions.md @@ -23,7 +23,7 @@ Check project for existing test framework: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/core/workflows/brainstorming/workflow.md b/src/core/workflows/brainstorming/workflow.md index e6aab4c14..f93ceb6d2 100644 --- a/src/core/workflows/brainstorming/workflow.md +++ b/src/core/workflows/brainstorming/workflow.md @@ -37,7 +37,7 @@ This uses **micro-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project` exists. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/core/workflows/party-mode/workflow.md b/src/core/workflows/party-mode/workflow.md index f30e0d7df..da61fb165 100644 --- a/src/core/workflows/party-mode/workflow.md +++ b/src/core/workflows/party-mode/workflow.md @@ -30,7 +30,7 @@ This uses **micro-file architecture** with **sequential conversation orchestrati Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project` exists. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` From 21685f23f311e9973b8bab62da2817829b4e19c2 Mon Sep 17 00:00:00 2001 From: sno Date: Wed, 18 Feb 2026 09:39:39 +0100 Subject: [PATCH 06/16] fix: enhance monorepo support with robust path resolution, input sanitization, and documentation fixes --- .../research/workflow-market-research.md | 2 +- .../create-ux-design/workflow.md | 2 +- .../workflow.md | 2 +- .../code-review/instructions.xml | 10 +++++++++ .../correct-course/instructions.md | 2 +- .../create-story/instructions.xml | 14 +++++++++++- .../dev-story/instructions.xml | 12 +++++++++- .../bmad-quick-flow/quick-dev/workflow.md | 2 +- .../bmad-quick-flow/quick-spec/workflow.md | 2 +- .../workflows/deep-dive-instructions.md | 22 +++++++++++++++---- .../advanced-elicitation/workflow.xml | 12 +++++++++- 11 files changed, 69 insertions(+), 13 deletions(-) diff --git a/src/bmm/workflows/1-analysis/research/workflow-market-research.md b/src/bmm/workflows/1-analysis/research/workflow-market-research.md index 9c48ac12b..937a98c4d 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-market-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-market-research.md @@ -21,7 +21,7 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md b/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md index 9f1e8f4fa..5b5be72c4 100644 --- a/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md +++ b/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md @@ -27,7 +27,7 @@ This uses **micro-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md b/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md index c00edab53..dad036735 100644 --- a/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md +++ b/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md @@ -47,7 +47,7 @@ description: 'Critical validation workflow that assesses PRD, Architecture, and Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/4-implementation/code-review/instructions.xml b/src/bmm/workflows/4-implementation/code-review/instructions.xml index 19902a093..becdbc943 100644 --- a/src/bmm/workflows/4-implementation/code-review/instructions.xml +++ b/src/bmm/workflows/4-implementation/code-review/instructions.xml @@ -18,6 +18,16 @@ Read content as project_suffix + + Trim whitespace and newlines from project_suffix + + 🚫 Security Error: Invalid project context path detected. + HALT + + + 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. + HALT + Override output_folder to {project-root}/_bmad-output/{project_suffix} diff --git a/src/bmm/workflows/4-implementation/correct-course/instructions.md b/src/bmm/workflows/4-implementation/correct-course/instructions.md index 9556de401..58d00c658 100644 --- a/src/bmm/workflows/4-implementation/correct-course/instructions.md +++ b/src/bmm/workflows/4-implementation/correct-course/instructions.md @@ -45,7 +45,7 @@ Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` Maintain running notes of findings and impacts discovered diff --git a/src/bmm/workflows/4-implementation/create-story/instructions.xml b/src/bmm/workflows/4-implementation/create-story/instructions.xml index b06b4c29e..fe543108f 100644 --- a/src/bmm/workflows/4-implementation/create-story/instructions.xml +++ b/src/bmm/workflows/4-implementation/create-story/instructions.xml @@ -18,9 +18,21 @@ 🎯 ZERO USER INTERVENTION: Process should be fully automated except for initial epic/story selection or missing documents - + Read content as project_suffix + + Trim whitespace and newlines from project_suffix + + 🚫 Security Error: Invalid project context path detected. + HALT + + + 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. + HALT + Override output_folder to {project-root}/_bmad-output/{project_suffix} + Set {default_output_file} = {output_folder}/{story_key}.md + Output "Monorepo context detected. Output redirected to: {default_output_file}" diff --git a/src/bmm/workflows/4-implementation/dev-story/instructions.xml b/src/bmm/workflows/4-implementation/dev-story/instructions.xml index e0e4e7857..b36935782 100644 --- a/src/bmm/workflows/4-implementation/dev-story/instructions.xml +++ b/src/bmm/workflows/4-implementation/dev-story/instructions.xml @@ -13,8 +13,18 @@ User skill level ({user_skill_level}) affects conversation style ONLY, not code updates. - + Read content as project_suffix + + Trim whitespace and newlines from project_suffix + + 🚫 Security Error: Invalid project context path detected. + HALT + + + 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. + HALT + Override output_folder to {project-root}/_bmad-output/{project_suffix} diff --git a/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md b/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md index 73f1feee2..f156f4b4e 100644 --- a/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md +++ b/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md @@ -28,7 +28,7 @@ This uses **step-file architecture** for focused execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md b/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md index 08146d91c..08afd36b1 100644 --- a/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md +++ b/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md @@ -69,7 +69,7 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. **Monorepo Context Check:** -1. Check if `_bmad/.current_project exists`. +1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` diff --git a/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md b/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md index d0d1dd6d4..17b7768d9 100644 --- a/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md +++ b/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md @@ -11,6 +11,23 @@ Load existing project structure from index.md and project-parts.json (if exists) Load source tree analysis to understand available areas + + Read content as project_suffix + + Trim whitespace and newlines from project_suffix + + 🚫 Security Error: Invalid project context path detected. + HALT + + + 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. + HALT + + Override output_folder to {project-root}/_bmad-output/{project_suffix} + Override project_knowledge to {project-root}/_bmad-output/{project_suffix} + Output "Monorepo context detected. Writing deep-dive artifacts to: {project_knowledge}" + + Analyze existing documentation to suggest deep-dive options @@ -254,10 +271,7 @@ Detailed exhaustive analysis of specific areas: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` + - Related code and reuse opportunities - Implementation guidance diff --git a/src/core/workflows/advanced-elicitation/workflow.xml b/src/core/workflows/advanced-elicitation/workflow.xml index 985ac0bc3..0f8ed3be7 100644 --- a/src/core/workflows/advanced-elicitation/workflow.xml +++ b/src/core/workflows/advanced-elicitation/workflow.xml @@ -20,8 +20,18 @@ - + Read content as project_suffix + + Trim whitespace and newlines from project_suffix + + 🚫 Security Error: Invalid project context path detected. + HALT + + + 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. + HALT + Override output_folder to {project-root}/_bmad-output/{project_suffix} From 6df9369cd064a4f94ec6b7bae99a620f3f64638f Mon Sep 17 00:00:00 2001 From: sno Date: Wed, 18 Feb 2026 10:02:39 +0100 Subject: [PATCH 07/16] fix(workflows): improve monorepo context handling and sanitization - Re-derive dependent paths in retrospective workflow after monorepo override - Add max length validation for project_suffix in dev-story - Fix premature output path computation in create-story workflow --- .../create-story/instructions.xml | 35 ++++++++++--------- .../dev-story/instructions.xml | 4 +++ .../retrospective/instructions.md | 3 ++ 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/src/bmm/workflows/4-implementation/create-story/instructions.xml b/src/bmm/workflows/4-implementation/create-story/instructions.xml index fe543108f..279585a7a 100644 --- a/src/bmm/workflows/4-implementation/create-story/instructions.xml +++ b/src/bmm/workflows/4-implementation/create-story/instructions.xml @@ -31,8 +31,7 @@ HALT Override output_folder to {project-root}/_bmad-output/{project_suffix} - Set {default_output_file} = {output_folder}/{story_key}.md - Output "Monorepo context detected. Output redirected to: {default_output_file}" + Output "Monorepo context detected. Output folder redirected to: {output_folder}" @@ -277,48 +276,52 @@ 📝 CREATE ULTIMATE STORY FILE - The developer's master implementation guide! + + Set {target_story_file} = {output_folder}/{story_key}.md + Output "Generating story file at: {target_story_file}" + Initialize from template.md: - {default_output_file} - story_header + {target_story_file} + story_header story_requirements + file="{target_story_file}">story_requirements - - developer_context_section **DEV AGENT GUARDRAILS:** + + developer_context_section **DEV AGENT GUARDRAILS:** technical_requirements - architecture_compliance + architecture_compliance library_framework_requirements - + file="{target_story_file}">library_framework_requirements + file_structure_requirements - testing_requirements + testing_requirements - previous_story_intelligence + previous_story_intelligence - git_intelligence_summary + git_intelligence_summary - latest_tech_information + latest_tech_information project_context_reference + file="{target_story_file}">project_context_reference - + story_completion_status diff --git a/src/bmm/workflows/4-implementation/dev-story/instructions.xml b/src/bmm/workflows/4-implementation/dev-story/instructions.xml index b36935782..4767e9624 100644 --- a/src/bmm/workflows/4-implementation/dev-story/instructions.xml +++ b/src/bmm/workflows/4-implementation/dev-story/instructions.xml @@ -25,6 +25,10 @@ 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. HALT + + 🚫 Error: Project context name is too long (max 100 characters). + HALT + Override output_folder to {project-root}/_bmad-output/{project_suffix} diff --git a/src/bmm/workflows/4-implementation/retrospective/instructions.md b/src/bmm/workflows/4-implementation/retrospective/instructions.md index 6fa97edca..fd1f7d52e 100644 --- a/src/bmm/workflows/4-implementation/retrospective/instructions.md +++ b/src/bmm/workflows/4-implementation/retrospective/instructions.md @@ -11,6 +11,9 @@ Load and read full config from {main_config} and resolve basic variables. 1. Check if `{project-root}/_bmad/.current_project` exists. 2. If it exists, read its content as `{project_suffix}` and override output folder: - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` +3. Re-derive dependent path variables to reflect the new `output_folder`: + - `implementation_artifacts`: `{output_folder}/implementation` + - `planning_artifacts`: `{output_folder}/planning` Communicate all responses in {communication_language} and language MUST be tailored to {user_skill_level} Generate all documents in {document_output_language} From a5bda6a80e80252141c40e7f2e109dcb52cef008 Mon Sep 17 00:00:00 2001 From: sno Date: Thu, 19 Feb 2026 13:30:48 +0100 Subject: [PATCH 08/16] feat: Introduce monorepo context logic for inline project overrides and dynamic path adjustments in workflows. --- .../0-context/set-project/workflow.md | 13 +++++ src/core/tasks/workflow.xml | 10 ++-- tools/cli/installers/lib/core/installer.js | 5 ++ .../cli/installers/lib/ide/_config-driven.js | 5 +- .../lib/ide/shared/context-logic.js | 48 +++++++++++++++++++ .../ide/shared/workflow-command-generator.js | 3 ++ .../lib/ide/templates/combined/antigravity.md | 2 + .../combined/default-workflow-yaml.md | 2 + .../templates/combined/default-workflow.md | 2 + .../ide/templates/combined/kiro-workflow.md | 4 +- .../templates/combined/opencode-workflow.md | 1 + .../templates/combined/windsurf-workflow.md | 2 + .../templates/workflow-command-template.md | 2 + .../lib/ide/templates/workflow-commander.md | 2 + 14 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 tools/cli/installers/lib/ide/shared/context-logic.js diff --git a/src/bmm/workflows/0-context/set-project/workflow.md b/src/bmm/workflows/0-context/set-project/workflow.md index 738d8c0ca..51fa848c2 100644 --- a/src/bmm/workflows/0-context/set-project/workflow.md +++ b/src/bmm/workflows/0-context/set-project/workflow.md @@ -34,3 +34,16 @@ Load and read full config from {main_config} and resolve basic variables. ### 3. Verification - Display the full resolved output path for confirmation. + +## Inline Project Overrides + +You can also temporarily run a command against a different project without changing the global context file. Use the `#project:NAME` or `#p:NAME` syntax in your command invocation. + +**Examples:** +- `/create-prd #project:my-app` +- `/sprint-planning #p:admin-portal` + +**Precedence:** +1. **Inline Override** (`#p:NAME`) +2. **Global Context File** (`_bmad/.current_project`) +3. **Default Config** (if neither is present) diff --git a/src/core/tasks/workflow.xml b/src/core/tasks/workflow.xml index 536c9d8e7..2b5503135 100644 --- a/src/core/tasks/workflow.xml +++ b/src/core/tasks/workflow.xml @@ -18,7 +18,11 @@ - + + {{monorepo_context_logic}} + + + Read workflow.yaml from provided path Load config_source (REQUIRED for all modules) Load external config from config_source path @@ -27,7 +31,7 @@ Ask user for input of any variables that are still unknown - + Instructions: Read COMPLETE file from path OR embedded list (REQUIRED) If template path → Read COMPLETE template file If validation path → Note path for later loading when needed @@ -35,7 +39,7 @@ Data files (csv, json) → Store paths only, load on-demand when instructions reference them - + Resolve default_output_file path with all variables and {{date}} Create output directory if doesn't exist If template-workflow → Write template to output file with placeholders diff --git a/tools/cli/installers/lib/core/installer.js b/tools/cli/installers/lib/core/installer.js index fe8b88d7c..e9c9518fe 100644 --- a/tools/cli/installers/lib/core/installer.js +++ b/tools/cli/installers/lib/core/installer.js @@ -16,6 +16,7 @@ const { IdeConfigManager } = require('./ide-config-manager'); const { CustomHandler } = require('../custom/handler'); const prompts = require('../../../lib/prompts'); const { BMAD_FOLDER_NAME } = require('../ide/shared/path-utils'); +const { MONOREPO_CONTEXT_LOGIC } = require('../ide/shared/context-logic'); class Installer { constructor() { @@ -89,6 +90,10 @@ class Installer { // Read the file content let content = await fs.readFile(sourcePath, 'utf8'); + // Apply replacements + content = content.replaceAll('{{monorepo_context_logic}}', MONOREPO_CONTEXT_LOGIC); + content = content.replaceAll('_bmad', this.bmadFolderName); + // Write to target with replaced content await fs.ensureDir(path.dirname(targetPath)); await fs.writeFile(targetPath, content, 'utf8'); diff --git a/tools/cli/installers/lib/ide/_config-driven.js b/tools/cli/installers/lib/ide/_config-driven.js index 9541c75ed..68c3a18c9 100644 --- a/tools/cli/installers/lib/ide/_config-driven.js +++ b/tools/cli/installers/lib/ide/_config-driven.js @@ -391,12 +391,15 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}} // No default } + const { MONOREPO_CONTEXT_LOGIC } = require('./shared/context-logic'); + let rendered = template .replaceAll('{{name}}', artifact.name || '') .replaceAll('{{module}}', artifact.module || 'core') .replaceAll('{{path}}', pathToUse) .replaceAll('{{description}}', artifact.description || `${artifact.name} ${artifact.type || ''}`) - .replaceAll('{{workflow_path}}', pathToUse); + .replaceAll('{{workflow_path}}', pathToUse) + .replaceAll('{{monorepo_context_logic}}', MONOREPO_CONTEXT_LOGIC); // Replace _bmad placeholder with actual folder name rendered = rendered.replaceAll('_bmad', this.bmadFolderName); diff --git a/tools/cli/installers/lib/ide/shared/context-logic.js b/tools/cli/installers/lib/ide/shared/context-logic.js new file mode 100644 index 000000000..f5fb7359e --- /dev/null +++ b/tools/cli/installers/lib/ide/shared/context-logic.js @@ -0,0 +1,48 @@ +/** + * Monorepo Context Logic XML Block + * + * robust, secure, and centralized logic for handling: + * 1. Inline project overrides (#p:NAME) + * 2. .current_project file fallback + * 3. Path variable overrides + */ +const MONOREPO_CONTEXT_LOGIC = ` + + + + Scan user's invocation message for pattern #project:NAME or #p:NAME (case-insensitive) + + Set project_suffix = extracted NAME + 🎯 Inline project override: {project_suffix} + + + + + Read {project-root}/_bmad/.current_project as project_suffix + + + + + Trim whitespace and newlines from project_suffix + + + 🚫 Security Error: Invalid project context — path traversal detected. + HALT + + + 🚫 Error: project_suffix must only contain alphanumeric characters, dots, dashes, or underscores. + HALT + + + + Override output_folder = {project-root}/_bmad-output/{project_suffix} + Override planning_artifacts = {output_folder}/planning-artifacts + Override implementation_artifacts = {output_folder}/implementation-artifacts + Override project_knowledge = {output_folder}/knowledge + Override sprint_status_file = {output_folder}/sprint-status.yaml + 🗂️ Monorepo context: {project_suffix} → outputs to {output_folder} + + +`; + +module.exports = { MONOREPO_CONTEXT_LOGIC }; diff --git a/tools/cli/installers/lib/ide/shared/workflow-command-generator.js b/tools/cli/installers/lib/ide/shared/workflow-command-generator.js index d94e77db1..985e3437b 100644 --- a/tools/cli/installers/lib/ide/shared/workflow-command-generator.js +++ b/tools/cli/installers/lib/ide/shared/workflow-command-generator.js @@ -151,12 +151,15 @@ class WorkflowCommandGenerator { } } + const { MONOREPO_CONTEXT_LOGIC } = require('./context-logic'); + // Replace template variables return template .replaceAll('{{name}}', workflow.name) .replaceAll('{{module}}', workflow.module) .replaceAll('{{description}}', workflow.description) .replaceAll('{{workflow_path}}', workflowPath) + .replaceAll('{{monorepo_context_logic}}', MONOREPO_CONTEXT_LOGIC) .replaceAll('_bmad', this.bmadFolderName); } diff --git a/tools/cli/installers/lib/ide/templates/combined/antigravity.md b/tools/cli/installers/lib/ide/templates/combined/antigravity.md index 88e806e9d..b897563f9 100644 --- a/tools/cli/installers/lib/ide/templates/combined/antigravity.md +++ b/tools/cli/installers/lib/ide/templates/combined/antigravity.md @@ -3,6 +3,8 @@ name: '{{name}}' description: '{{description}}' --- +{{monorepo_context_logic}} + Read the entire workflow file at: {project-root}/_bmad/{{workflow_path}} Follow all instructions in the workflow file exactly as written. diff --git a/tools/cli/installers/lib/ide/templates/combined/default-workflow-yaml.md b/tools/cli/installers/lib/ide/templates/combined/default-workflow-yaml.md index 2a5e49b83..605e6c57b 100644 --- a/tools/cli/installers/lib/ide/templates/combined/default-workflow-yaml.md +++ b/tools/cli/installers/lib/ide/templates/combined/default-workflow-yaml.md @@ -7,6 +7,8 @@ disable-model-invocation: true IT IS CRITICAL THAT YOU FOLLOW THESE STEPS - while staying in character as the current agent persona you may have loaded: +0. {{monorepo_context_logic}} + 1. Always LOAD the FULL @{project-root}/{{bmadFolderName}}/core/tasks/workflow.xml 2. READ its entire contents - this is the CORE OS for EXECUTING the specific workflow-config @{project-root}/{{bmadFolderName}}/{{path}} 3. Pass the yaml path @{project-root}/{{bmadFolderName}}/{{path}} as 'workflow-config' parameter to the workflow.xml instructions diff --git a/tools/cli/installers/lib/ide/templates/combined/default-workflow.md b/tools/cli/installers/lib/ide/templates/combined/default-workflow.md index 8c4fa818f..8b7d9eea6 100644 --- a/tools/cli/installers/lib/ide/templates/combined/default-workflow.md +++ b/tools/cli/installers/lib/ide/templates/combined/default-workflow.md @@ -4,4 +4,6 @@ description: '{{description}}' disable-model-invocation: true --- +{{monorepo_context_logic}} + IT IS CRITICAL THAT YOU FOLLOW THIS COMMAND: LOAD the FULL @{project-root}/{{bmadFolderName}}/{{path}}, READ its entire contents and follow its directions exactly! diff --git a/tools/cli/installers/lib/ide/templates/combined/kiro-workflow.md b/tools/cli/installers/lib/ide/templates/combined/kiro-workflow.md index e1847f414..2041edfdd 100644 --- a/tools/cli/installers/lib/ide/templates/combined/kiro-workflow.md +++ b/tools/cli/installers/lib/ide/templates/combined/kiro-workflow.md @@ -4,4 +4,6 @@ inclusion: manual # {{name}} -IT IS CRITICAL THAT YOU FOLLOW THIS COMMAND: LOAD the FULL #[[file:{{bmadFolderName}}/{{path}}]], READ its entire contents and follow its directions exactly! +{{monorepo_context_logic}} + +IT IS CRITICAL THAT YOU FOLLOW THIS COMMAND: LOAD the FULL @{project-root}/{{bmadFolderName}}/{{path}}, READ its entire contents and follow its directions exactly! diff --git a/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md b/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md index a6f5cb96f..e7596ea1d 100644 --- a/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md +++ b/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md @@ -8,6 +8,7 @@ Execute the BMAD '{{name}}' workflow. CRITICAL: You must load and follow the workflow definition exactly. WORKFLOW INSTRUCTIONS: +{{monorepo_context_logic}} 1. LOAD the workflow file from {project-root}/{{bmadFolderName}}/{{path}} 2. READ its entire contents diff --git a/tools/cli/installers/lib/ide/templates/combined/windsurf-workflow.md b/tools/cli/installers/lib/ide/templates/combined/windsurf-workflow.md index 6366425c7..cb2b8bb2d 100644 --- a/tools/cli/installers/lib/ide/templates/combined/windsurf-workflow.md +++ b/tools/cli/installers/lib/ide/templates/combined/windsurf-workflow.md @@ -5,6 +5,8 @@ auto_execution_mode: "iterate" # {{name}} +{{monorepo_context_logic}} + Read the entire workflow file at {project-root}/_bmad/{{workflow_path}} Follow all instructions in the workflow file exactly as written. diff --git a/tools/cli/installers/lib/ide/templates/workflow-command-template.md b/tools/cli/installers/lib/ide/templates/workflow-command-template.md index 472c1553a..7a26a6684 100644 --- a/tools/cli/installers/lib/ide/templates/workflow-command-template.md +++ b/tools/cli/installers/lib/ide/templates/workflow-command-template.md @@ -3,6 +3,8 @@ description: '{{description}}' disable-model-invocation: true --- +{{monorepo_context_logic}} + IT IS CRITICAL THAT YOU FOLLOW THESE STEPS - while staying in character as the current agent persona you may have loaded: diff --git a/tools/cli/installers/lib/ide/templates/workflow-commander.md b/tools/cli/installers/lib/ide/templates/workflow-commander.md index d49c8319d..6f9ed8759 100644 --- a/tools/cli/installers/lib/ide/templates/workflow-commander.md +++ b/tools/cli/installers/lib/ide/templates/workflow-commander.md @@ -3,4 +3,6 @@ description: '{{description}}' disable-model-invocation: true --- +{{monorepo_context_logic}} + IT IS CRITICAL THAT YOU FOLLOW THIS COMMAND: LOAD the FULL @{{workflow_path}}, READ its entire contents and follow its directions exactly! From d05b9f87d50a2203e2774cf21f149d7d6e7afc29 Mon Sep 17 00:00:00 2001 From: sno Date: Thu, 19 Feb 2026 13:47:02 +0100 Subject: [PATCH 09/16] refactor: centralize monorepo context detection logic by removing duplicated checks from numerous workflow files and updating related tests. --- .../create-product-brief/workflow.md | 5 - .../research/workflow-domain-research.md | 4 - .../research/workflow-market-research.md | 4 - .../research/workflow-technical-research.md | 4 - .../create-prd/workflow-create-prd.md | 9 - .../create-prd/workflow-edit-prd.md | 4 - .../create-prd/workflow-validate-prd.md | 4 - .../create-ux-design/workflow.md | 4 - .../workflow.md | 5 - .../create-architecture/workflow.md | 5 - .../create-epics-and-stories/workflow.md | 4 - .../correct-course/instructions.md | 10 +- .../create-story/instructions.xml | 17 +- .../dev-story/instructions.xml | 20 +- .../retrospective/instructions.md | 11 - .../sprint-planning/instructions.md | 8 - .../sprint-status/instructions.md | 8 - .../bmad-quick-flow/quick-dev/workflow.md | 5 - .../bmad-quick-flow/quick-spec/workflow.md | 5 - .../document-project/instructions.md | 4 - .../workflows/full-scan-instructions.md | 8 - .../generate-project-context/workflow.md | 6 - src/bmm/workflows/qa/automate/instructions.md | 8 - src/core/workflows/brainstorming/workflow.md | 6 - src/core/workflows/party-mode/workflow.md | 5 - test/test-context-logic-integration.js | 206 ++++++++++++++++++ test/test-monorepo-validation.js | 66 +++--- 27 files changed, 244 insertions(+), 201 deletions(-) create mode 100644 test/test-context-logic-integration.js diff --git a/src/bmm/workflows/1-analysis/create-product-brief/workflow.md b/src/bmm/workflows/1-analysis/create-product-brief/workflow.md index c5764d4ff..14a9084a5 100644 --- a/src/bmm/workflows/1-analysis/create-product-brief/workflow.md +++ b/src/bmm/workflows/1-analysis/create-product-brief/workflow.md @@ -51,11 +51,6 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - - `project_name`, `output_folder`, `planning_artifacts`, `user_name`, `communication_language`, `document_output_language`, `user_skill_level` ### 2. First Step EXECUTION diff --git a/src/bmm/workflows/1-analysis/research/workflow-domain-research.md b/src/bmm/workflows/1-analysis/research/workflow-domain-research.md index 58cf01f4e..f17a7d907 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-domain-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-domain-research.md @@ -20,10 +20,6 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/1-analysis/research/workflow-market-research.md b/src/bmm/workflows/1-analysis/research/workflow-market-research.md index 937a98c4d..06501fdb1 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-market-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-market-research.md @@ -20,10 +20,6 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/1-analysis/research/workflow-technical-research.md b/src/bmm/workflows/1-analysis/research/workflow-technical-research.md index 6e03f7af1..778def8c7 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-technical-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-technical-research.md @@ -20,10 +20,6 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md index 8b50a309d..7007ab8fb 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-create-prd.md @@ -46,15 +46,6 @@ This uses **step-file architecture** for disciplined execution: ## INITIALIZATION SEQUENCE -### 1. Configuration Loading - -Load and read full config from {main_config} and resolve basic variables. - -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` - `date` as system-generated current datetime diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md index ada593f90..37731b4c5 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md @@ -50,10 +50,6 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` - `date` as system-generated current datetime diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md index 8e09bb612..7b17c8026 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md @@ -50,10 +50,6 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md b/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md index 5b5be72c4..f00c76256 100644 --- a/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md +++ b/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md @@ -26,10 +26,6 @@ This uses **micro-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md b/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md index dad036735..58b12630d 100644 --- a/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md +++ b/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md @@ -46,11 +46,6 @@ description: 'Critical validation workflow that assesses PRD, Architecture, and Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - - `project_name`, `output_folder`, `planning_artifacts`, `user_name`, `communication_language`, `document_output_language` - ✅ YOU MUST ALWAYS SPEAK OUTPUT In your Agent communication style with the config `{communication_language}` diff --git a/src/bmm/workflows/3-solutioning/create-architecture/workflow.md b/src/bmm/workflows/3-solutioning/create-architecture/workflow.md index ceff8cb7e..100432e4e 100644 --- a/src/bmm/workflows/3-solutioning/create-architecture/workflow.md +++ b/src/bmm/workflows/3-solutioning/create-architecture/workflow.md @@ -29,11 +29,6 @@ This uses **micro-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: - `project_name`, `output_folder`, `planning_artifacts`, `user_name` diff --git a/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md b/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md index 3d42212ec..6d449749e 100644 --- a/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md +++ b/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md @@ -50,10 +50,6 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - `project_name`, `output_folder`, `planning_artifacts`, `user_name`, `communication_language`, `document_output_language` - ✅ YOU MUST ALWAYS SPEAK OUTPUT In your Agent communication style with the config `{communication_language}` diff --git a/src/bmm/workflows/4-implementation/correct-course/instructions.md b/src/bmm/workflows/4-implementation/correct-course/instructions.md index 58d00c658..023c8c4fd 100644 --- a/src/bmm/workflows/4-implementation/correct-course/instructions.md +++ b/src/bmm/workflows/4-implementation/correct-course/instructions.md @@ -40,15 +40,7 @@ - [x] Done - Item completed successfully - [N/A] Skip - Item not applicable to this change - [!] Action-needed - Item requires attention or follow-up -### 1. Configuration Loading - -Load and read full config from {main_config} and resolve basic variables. - -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - Maintain running notes of findings and impacts discovered + Present checklist progress after each major section Identify blocking issues and work with user to resolve before continuing diff --git a/src/bmm/workflows/4-implementation/create-story/instructions.xml b/src/bmm/workflows/4-implementation/create-story/instructions.xml index 279585a7a..d7b7158aa 100644 --- a/src/bmm/workflows/4-implementation/create-story/instructions.xml +++ b/src/bmm/workflows/4-implementation/create-story/instructions.xml @@ -18,22 +18,7 @@ 🎯 ZERO USER INTERVENTION: Process should be fully automated except for initial epic/story selection or missing documents - - Read content as project_suffix - - Trim whitespace and newlines from project_suffix - - 🚫 Security Error: Invalid project context path detected. - HALT - - - 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. - HALT - - Override output_folder to {project-root}/_bmad-output/{project_suffix} - Output "Monorepo context detected. Output folder redirected to: {output_folder}" - - + Parse user-provided story path: extract epic_num, story_num, story_title from format like "1-2-user-auth" Set {{epic_num}}, {{story_num}}, {{story_key}} from user input diff --git a/src/bmm/workflows/4-implementation/dev-story/instructions.xml b/src/bmm/workflows/4-implementation/dev-story/instructions.xml index 4767e9624..aa8308404 100644 --- a/src/bmm/workflows/4-implementation/dev-story/instructions.xml +++ b/src/bmm/workflows/4-implementation/dev-story/instructions.xml @@ -13,25 +13,7 @@ User skill level ({user_skill_level}) affects conversation style ONLY, not code updates. - - Read content as project_suffix - - Trim whitespace and newlines from project_suffix - - 🚫 Security Error: Invalid project context path detected. - HALT - - - 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. - HALT - - - 🚫 Error: Project context name is too long (max 100 characters). - HALT - - Override output_folder to {project-root}/_bmad-output/{project_suffix} - - + Use {{story_path}} directly Read COMPLETE story file diff --git a/src/bmm/workflows/4-implementation/retrospective/instructions.md b/src/bmm/workflows/4-implementation/retrospective/instructions.md index fd1f7d52e..762f5a6ef 100644 --- a/src/bmm/workflows/4-implementation/retrospective/instructions.md +++ b/src/bmm/workflows/4-implementation/retrospective/instructions.md @@ -3,17 +3,6 @@ The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml You MUST have already loaded and processed: {installed_path}/workflow.yaml -## 1. Configuration Loading - -Load and read full config from {main_config} and resolve basic variables. - -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` -3. Re-derive dependent path variables to reflect the new `output_folder`: - - `implementation_artifacts`: `{output_folder}/implementation` - - `planning_artifacts`: `{output_folder}/planning` Communicate all responses in {communication_language} and language MUST be tailored to {user_skill_level} Generate all documents in {document_output_language} diff --git a/src/bmm/workflows/4-implementation/sprint-planning/instructions.md b/src/bmm/workflows/4-implementation/sprint-planning/instructions.md index 2fbd0c1da..e87110c27 100644 --- a/src/bmm/workflows/4-implementation/sprint-planning/instructions.md +++ b/src/bmm/workflows/4-implementation/sprint-planning/instructions.md @@ -4,14 +4,6 @@ You MUST have already loaded and processed: {project-root}/_bmad/bmm/workflows/4-implementation/sprint-planning/workflow.yaml ## 📚 Document Discovery -### 1. Configuration Loading - -Load and read full config from {main_config} and resolve basic variables. - -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - Full Epic Loading diff --git a/src/bmm/workflows/4-implementation/sprint-status/instructions.md b/src/bmm/workflows/4-implementation/sprint-status/instructions.md index fc589a22a..43b5e1316 100644 --- a/src/bmm/workflows/4-implementation/sprint-status/instructions.md +++ b/src/bmm/workflows/4-implementation/sprint-status/instructions.md @@ -2,14 +2,6 @@ The workflow execution engine is governed by: {project-root}/_bmad/core/tasks/workflow.xml -## 1. Configuration Loading - -Load and read full config from {main_config} and resolve basic variables. - -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` You MUST have already loaded and processed: {project-root}/_bmad/bmm/workflows/4-implementation/sprint-status/workflow.yaml Modes: interactive (default), validate, data ⚠️ ABSOLUTELY NO TIME ESTIMATES. Do NOT mention hours, days, weeks, or timelines. diff --git a/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md b/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md index f156f4b4e..56fa658e1 100644 --- a/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md +++ b/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md @@ -27,11 +27,6 @@ This uses **step-file architecture** for focused execution: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: - `user_name`, `communication_language`, `user_skill_level` diff --git a/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md b/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md index 08afd36b1..ad027deb7 100644 --- a/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md +++ b/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md @@ -68,11 +68,6 @@ This uses **step-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: - `project_name`, `planning_artifacts`, `implementation_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/document-project/instructions.md b/src/bmm/workflows/document-project/instructions.md index 35fcc290d..d6a685c3d 100644 --- a/src/bmm/workflows/document-project/instructions.md +++ b/src/bmm/workflows/document-project/instructions.md @@ -83,10 +83,6 @@ Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` Check if {project_knowledge}/index.md exists diff --git a/src/bmm/workflows/document-project/workflows/full-scan-instructions.md b/src/bmm/workflows/document-project/workflows/full-scan-instructions.md index e43435bd2..6e3a3fed3 100644 --- a/src/bmm/workflows/document-project/workflows/full-scan-instructions.md +++ b/src/bmm/workflows/document-project/workflows/full-scan-instructions.md @@ -95,15 +95,7 @@ Your choice [1/2/3]: - Best for: Quick project overview, initial understanding - File reading: Minimal (configs, README, package.json, etc.) -## 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. - -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` -json, etc.) **2. Deep Scan** (10-30 minutes) diff --git a/src/bmm/workflows/generate-project-context/workflow.md b/src/bmm/workflows/generate-project-context/workflow.md index 88b8e8270..749016fec 100644 --- a/src/bmm/workflows/generate-project-context/workflow.md +++ b/src/bmm/workflows/generate-project-context/workflow.md @@ -29,12 +29,6 @@ This uses **micro-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - -Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: - `project_name`, `output_folder`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/qa/automate/instructions.md b/src/bmm/workflows/qa/automate/instructions.md index 91ee2f771..561a80581 100644 --- a/src/bmm/workflows/qa/automate/instructions.md +++ b/src/bmm/workflows/qa/automate/instructions.md @@ -18,14 +18,6 @@ Check project for existing test framework: - Search online for current recommended test framework for that stack - Suggest the meta framework and use it (or ask user to confirm) -### 1. Configuration Loading - -Load and read full config from {main_config} and resolve basic variables. - -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` ### Step 1: Identify Features diff --git a/src/core/workflows/brainstorming/workflow.md b/src/core/workflows/brainstorming/workflow.md index f93ceb6d2..fb983a730 100644 --- a/src/core/workflows/brainstorming/workflow.md +++ b/src/core/workflows/brainstorming/workflow.md @@ -36,12 +36,6 @@ This uses **micro-file architecture** for disciplined execution: Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - -Load config from `{project-root}/_bmad/core/config.yaml` and resolve: - `project_name`, `output_folder`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/core/workflows/party-mode/workflow.md b/src/core/workflows/party-mode/workflow.md index da61fb165..183968f7d 100644 --- a/src/core/workflows/party-mode/workflow.md +++ b/src/core/workflows/party-mode/workflow.md @@ -29,11 +29,6 @@ This uses **micro-file architecture** with **sequential conversation orchestrati Load and read full config from {main_config} and resolve basic variables. -**Monorepo Context Check:** -1. Check if `{project-root}/_bmad/.current_project` exists. -2. If it exists, read its content as `{project_suffix}` and override output folder: - - `output_folder`: `{project-root}/_bmad-output/{project_suffix}` - - `project_name`, `output_folder`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` - `date` as a system-generated value diff --git a/test/test-context-logic-integration.js b/test/test-context-logic-integration.js new file mode 100644 index 000000000..75a40d8d4 --- /dev/null +++ b/test/test-context-logic-integration.js @@ -0,0 +1,206 @@ +/** + * Context Logic Integration Tests + * + * Validates the centralized monorepo context logic deduplication: + * 1. context-logic.js exports a valid XML block + * 2. All workflow templates that need it use the {{monorepo_context_logic}} placeholder + * 3. No stale hardcoded blocks exist in templates + * 4. src/core/tasks/workflow.xml uses the placeholder (not a hardcoded block) + * 5. All JS consumers correctly import context-logic.js + * 6. MONOREPO_CONTEXT_LOGIC string integrity (key fields are present) + */ + +const fs = require('fs-extra'); +const path = require('node:path'); + +// ANSI colors +const c = { + reset: '\u001B[0m', + green: '\u001B[32m', + red: '\u001B[31m', + yellow: '\u001B[33m', + cyan: '\u001B[36m', + dim: '\u001B[2m', +}; + +let passed = 0; +let failed = 0; + +function ok(condition, testName, detail = '') { + if (condition) { + console.log(`${c.green}✓${c.reset} ${testName}`); + passed++; + } else { + console.log(`${c.red}✗${c.reset} ${testName}`); + if (detail) console.log(` ${c.dim}${detail}${c.reset}`); + failed++; + } +} + +async function readFile(p) { + return fs.readFile(p, 'utf8'); +} + +async function exists(p) { + return fs.pathExists(p); +} + +async function runTests() { + console.log(`${c.cyan}============================================================`); + console.log(' Context Logic Integration Tests'); + console.log(`============================================================${c.reset}\n`); + + const root = path.join(__dirname, '..'); + const sharedDir = path.join(root, 'tools/cli/installers/lib/ide/shared'); + const templatesDir = path.join(root, 'tools/cli/installers/lib/ide/templates'); + const combinedDir = path.join(templatesDir, 'combined'); + + // ──────────────────────────────────────────────────────────── + // Suite 1: context-logic.js module integrity + // ──────────────────────────────────────────────────────────── + console.log(`${c.yellow}Suite 1: context-logic.js module integrity${c.reset}\n`); + + const contextLogicPath = path.join(sharedDir, 'context-logic.js'); + ok(await exists(contextLogicPath), 'context-logic.js file exists'); + + let MONOREPO_CONTEXT_LOGIC; + try { + const mod = require(contextLogicPath); + ok(typeof mod.MONOREPO_CONTEXT_LOGIC === 'string', 'exports MONOREPO_CONTEXT_LOGIC as a string'); + ok(mod.MONOREPO_CONTEXT_LOGIC.length > 0, 'MONOREPO_CONTEXT_LOGIC is non-empty'); + MONOREPO_CONTEXT_LOGIC = mod.MONOREPO_CONTEXT_LOGIC; + } catch (error) { + ok(false, 'context-logic.js is require()-able', error.message); + MONOREPO_CONTEXT_LOGIC = ''; + } + + // Key content checks + ok(MONOREPO_CONTEXT_LOGIC.includes(' tag'); + ok(MONOREPO_CONTEXT_LOGIC.includes(''), 'has closing tag'); + ok(MONOREPO_CONTEXT_LOGIC.includes('#project:NAME'), 'documents #project:NAME syntax'); + ok(MONOREPO_CONTEXT_LOGIC.includes('#p:NAME'), 'documents #p:NAME short alias'); + ok(MONOREPO_CONTEXT_LOGIC.includes('.current_project'), 'includes .current_project fallback logic'); + ok(MONOREPO_CONTEXT_LOGIC.includes('path traversal'), 'includes path traversal security check'); + ok(MONOREPO_CONTEXT_LOGIC.includes('output_folder'), 'overrides output_folder path variable'); + ok(MONOREPO_CONTEXT_LOGIC.includes('planning_artifacts'), 'overrides planning_artifacts path variable'); + ok(MONOREPO_CONTEXT_LOGIC.includes('HALT'), 'halts on security violation'); + console.log(''); + + // ──────────────────────────────────────────────────────────── + // Suite 2: JS consumers import context-logic.js correctly + // ──────────────────────────────────────────────────────────── + console.log(`${c.yellow}Suite 2: JS consumers import context-logic.js${c.reset}\n`); + + const consumers = [ + { + file: 'tools/cli/installers/lib/core/installer.js', + expectedImport: "require('../ide/shared/context-logic')", + }, + { + file: 'tools/cli/installers/lib/ide/_config-driven.js', + expectedImport: "require('./shared/context-logic')", + }, + { + file: 'tools/cli/installers/lib/ide/shared/workflow-command-generator.js', + expectedImport: "require('./context-logic')", + }, + ]; + + for (const { file, expectedImport } of consumers) { + const fullPath = path.join(root, file); + const content = await readFile(fullPath); + ok(content.includes(expectedImport), `${path.basename(file)} imports context-logic correctly`); + ok(content.includes("replaceAll('{{monorepo_context_logic}}'"), `${path.basename(file)} uses replaceAll for placeholder`); + } + console.log(''); + + // ──────────────────────────────────────────────────────────── + // Suite 3: Templates use placeholder, not hardcoded blocks + // ──────────────────────────────────────────────────────────── + console.log(`${c.yellow}Suite 3: Templates use {{monorepo_context_logic}} placeholder${c.reset}\n`); + + // These templates MUST have the placeholder (they are rendered directly as IDE workflow commands) + const mustHavePlaceholder = [ + path.join(templatesDir, 'workflow-command-template.md'), + path.join(templatesDir, 'workflow-commander.md'), + path.join(combinedDir, 'antigravity.md'), + path.join(combinedDir, 'claude-workflow.md'), + path.join(combinedDir, 'claude-workflow-yaml.md'), + path.join(combinedDir, 'default-workflow.md'), + path.join(combinedDir, 'default-workflow-yaml.md'), + path.join(combinedDir, 'kiro-workflow.md'), + path.join(combinedDir, 'opencode-workflow.md'), + path.join(combinedDir, 'windsurf-workflow.md'), + ]; + + for (const filePath of mustHavePlaceholder) { + const rel = path.relative(root, filePath); + const content = await readFile(filePath); + ok(content.includes('{{monorepo_context_logic}}'), `${path.basename(filePath)} has {{monorepo_context_logic}} placeholder`); + // Must NOT have raw hardcoded block (only the shared module should have it) + ok(!content.includes(' block`); + } + console.log(''); + + // ──────────────────────────────────────────────────────────── + // Suite 4: No rogue hardcoded blocks anywhere in templates dir + // ──────────────────────────────────────────────────────────── + console.log(`${c.yellow}Suite 4: No hardcoded blocks in templates directory${c.reset}\n`); + + const walkDir = async (dir) => { + const entries = await fs.readdir(dir, { withFileTypes: true }); + const files = []; + for (const e of entries) { + const full = path.join(dir, e.name); + if (e.isDirectory()) files.push(...(await walkDir(full))); + else if (e.isFile()) files.push(full); + } + return files; + }; + + const allTemplateFiles = await walkDir(templatesDir); + const rogueFiles = []; + for (const f of allTemplateFiles) { + const content = await readFile(f); + if (content.includes(' blocks in templates (found ${rogueFiles.length})`, + rogueFiles.length > 0 ? `Rogue files: ${rogueFiles.join(', ')}` : '', + ); + console.log(''); + + // ──────────────────────────────────────────────────────────── + // Suite 5: src/core/tasks/workflow.xml uses placeholder + // ──────────────────────────────────────────────────────────── + console.log(`${c.yellow}Suite 5: src/core/tasks/workflow.xml uses placeholder${c.reset}\n`); + + const srcWorkflowXml = path.join(root, 'src/core/tasks/workflow.xml'); + ok(await exists(srcWorkflowXml), 'src/core/tasks/workflow.xml exists'); + const srcXmlContent = await readFile(srcWorkflowXml); + ok(srcXmlContent.includes('{{monorepo_context_logic}}'), 'workflow.xml (src) uses {{monorepo_context_logic}} placeholder'); + ok(!srcXmlContent.includes(' block'); + + // ──────────────────────────────────────────────────────────── + // Results + // ──────────────────────────────────────────────────────────── + console.log(`\n${c.cyan}============================================================`); + console.log(` Results: ${c.green}${passed} passed${c.reset}${c.cyan}, ${c.red}${failed} failed${c.reset}${c.cyan}`); + console.log(`============================================================${c.reset}\n`); + + if (failed === 0) { + console.log(`${c.green}✨ All context-logic integration tests passed!${c.reset}\n`); + process.exit(0); + } else { + console.log(`${c.red}❌ ${failed} test(s) failed${c.reset}\n`); + process.exit(1); + } +} + +runTests().catch((error) => { + console.error(error); + process.exit(1); +}); diff --git a/test/test-monorepo-validation.js b/test/test-monorepo-validation.js index bab840708..0b696390e 100644 --- a/test/test-monorepo-validation.js +++ b/test/test-monorepo-validation.js @@ -1,9 +1,19 @@ /** * Monorepo Support Validation Tests * - * Verifies that: + * Architecture after deduplication: + * - Monorepo context logic lives ONLY in context-logic.js + * - workflow.xml (src) uses {{monorepo_context_logic}} placeholder → injected at install time + * - Individual source workflow files do NOT have inline checks (that's the deduplication!) + * - Only code-review/instructions.xml, dev-story/instructions.xml, create-story/instructions.xml + * and advanced-elicitation/workflow.xml are XML workflows checked; XML workflows that go through + * workflow.xml no longer need inline checks. + * + * Verifies: * 1. The set-project workflow is correctly registered. - * 2. All core and BMM workflows contain the monorepo context logic. + * 2. No source workflow file has a stale inline "Monorepo Context Check" block. + * 3. Only the canonical SINGLE source (context-logic.js) defines the check. + * 4. set-project implementation still manages .current_project. */ const fs = require('fs-extra'); @@ -55,46 +65,39 @@ async function runTests() { console.log(''); - // 2. Verify context logic in workflows - console.log(`${colors.yellow}Test Suite 2: Workflow Context Logic${colors.reset}\n`); + // 2. Verify NO stale inline "Monorepo Context Check" blocks in source workflow files + // These are redundant since workflow.xml now handles context injection via context-logic.js + console.log(`${colors.yellow}Test Suite 2: No Stale Inline Monorepo Context Checks${colors.reset}\n`); + console.log(` ${colors.dim}(Inline checks were moved to workflow.xml via context-logic.js)${colors.reset}\n`); const workflowFiles = glob.sync('src/{core,bmm}/workflows/**/*.{md,xml}', { cwd: projectRoot }); - // Workflows that MUST have the check - const requiredWorkflows = [ - 'brainstorming', - 'party-mode', - 'create-product-brief', - 'create-prd', - 'create-architecture', - 'code-review', - 'create-story', - 'dev-story', - 'set-project', // Should not have the check itself, but let's exclude it - ]; - for (const file of workflowFiles) { - const basename = path.basename(path.dirname(file)); - if (basename === 'set-project' || basename === '0-context') continue; + // skip the context-logic source itself (it's the canonical source) + if (file.includes('context-logic')) continue; const content = await fs.readFile(path.join(projectRoot, file), 'utf8'); - const isXml = file.endsWith('.xml'); - if (isXml) { - assert(content.includes('_bmad/.current_project'), `XML workflow contains context check: ${file}`); - } else { - // Only check Markdown files that look like main workflow/instruction files - const filename = path.basename(file); - if (filename.includes('workflow') || filename.includes('instructions')) { - assert(content.includes('_bmad/.current_project'), `Markdown workflow contains context check: ${file}`); - } - } + assert(!content.includes('**Monorepo Context Check:**'), `No stale inline check block in: ${file}`); } console.log(''); - // 3. Verify set-project implementation - console.log(`${colors.yellow}Test Suite 3: set-project Implementation${colors.reset}\n`); + // 3. Verify canonical source is context-logic.js (single source of truth) + console.log(`${colors.yellow}Test Suite 3: Single Source of Truth${colors.reset}\n`); + + const contextLogicPath = path.join(projectRoot, 'tools/cli/installers/lib/ide/shared/context-logic.js'); + assert(await fs.pathExists(contextLogicPath), 'context-logic.js exists as canonical source'); + + const srcWorkflowXml = path.join(projectRoot, 'src/core/tasks/workflow.xml'); + const xmlContent = await fs.readFile(srcWorkflowXml, 'utf8'); + assert(xmlContent.includes('{{monorepo_context_logic}}'), 'workflow.xml uses {{monorepo_context_logic}} placeholder'); + assert(!xmlContent.includes('**Monorepo Context Check:**'), 'workflow.xml has no stale inline check'); + + console.log(''); + + // 4. Verify set-project implementation + console.log(`${colors.yellow}Test Suite 4: set-project Implementation${colors.reset}\n`); try { const setProjectPath = path.join(projectRoot, 'src/bmm/workflows/0-context/set-project/workflow.md'); const exists = await fs.pathExists(setProjectPath); @@ -102,6 +105,7 @@ async function runTests() { if (exists) { const content = await fs.readFile(setProjectPath, 'utf8'); assert(content.includes('_bmad/.current_project'), 'set-project implementation manages .current_project'); + assert(content.includes('my-app'), 'set-project examples use generic public-friendly names'); } } catch (error) { assert(false, 'set-project check failed', error.message); From 006642552a82deec284049930c1f07d066562e5e Mon Sep 17 00:00:00 2001 From: sno Date: Thu, 19 Feb 2026 14:00:37 +0100 Subject: [PATCH 10/16] docs: Add monorepo setup guide and link it in the index. --- docs/how-to/monorepo-setup.md | 79 +++++++++++++++++++++++++++++++++++ docs/index.md | 6 +++ 2 files changed, 85 insertions(+) create mode 100644 docs/how-to/monorepo-setup.md diff --git a/docs/how-to/monorepo-setup.md b/docs/how-to/monorepo-setup.md new file mode 100644 index 000000000..4aea2fb48 --- /dev/null +++ b/docs/how-to/monorepo-setup.md @@ -0,0 +1,79 @@ +--- +title: "Set Up Monorepo Support" +description: Manage multiple projects in a single repository with isolated artifacts +sidebar: + order: 8 +--- + +BMad Method supports working in monorepo environments where multiple projects share a single repository. This allows you to centralize methodology files while keeping project artifacts isolated and organized. + +:::note[Prerequisites] +- BMad Method v6.0.1+ +- A repository containing multiple projects +::: + +## Why Use Monorepo Support? + +In a standard setup, BMad expects one project per repository. In a monorepo, you might have `apps/frontend`, `apps/backend`, and `packages/shared`. Without monorepo support, BMad's artifacts (plans, architecture, stories) would be mixed or require installing BMad in every sub-directory. + +Monorepo support allows you to: +- **Centralize Methodology**: Install BMad once at the root based on your team's process. +- **Isolate Artifacts**: Automatically route outputs to project-specific folders (e.g., `_bmad-output/frontend/`). +- **Context Switch Easily**: Switch between projects without reinstalling or reconfiguring. + +## Project Structure + +When monorepo support is active, the structure changes slightly to accommodate multiple projects: + +``` +monorepo-root/ +├── _bmad/ # Methodology (installed core & modules) +│ └── .current_project # Context marker (e.g., "app-alpha") +├── _bmad-output/ # Unified output directory +│ ├── app-alpha/ # Sub-project artifacts +│ │ ├── planning-artifacts/ +│ │ └── implementation-artifacts/ +│ └── app-beta/ # Sub-project artifacts +│ └── planning-artifacts/ +├── apps/ # Actual source code +│ ├── app-alpha/ +│ └── app-beta/ +└── package.json +``` + +## How It Works + +### Context Injection + +Core and BMM workflows automatically check for the existence of `_bmad/.current_project`. +- **If found**: It reads the content (e.g., "app-alpha") and overrides the `output_folder` to `_bmad-output/app-alpha`. +- **If not found**: It behaves like a standard single-project installation, outputting to `_bmad-output` root. + +### The /set-project Command + +You can easily manage the active project context using the `/set-project` workflow. + +**To set a context:** +1. Run `/set-project` in your chat. +2. Select "Set Project Context". +3. Enter the name of your project (e.g., `frontend`, `backend`, `mobile-app`). + +**To clear context (return to single-project mode):** +1. Run `/set-project`. +2. Select "Clear Project Context". + +### Inline Override + +You can temporarily override the project context for a specific command without changing the global `.current_project` state. This is useful for one-off tasks in a different project. + +Use the `#project:` syntax (or `#p:` for short) anywhere in your prompt: + +```bash +# Full syntax +/create-prd #project:myproject_name + +# Short alias +/create-story #p:frontend +``` + +**Note:** The inline override takes precedence over the `.current_project` file. If no project is specified via `#` or `.current_project`, BMad defaults to the root `_bmad-output` folder. diff --git a/docs/index.md b/docs/index.md index 5ae60e922..dba1fccf9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -18,6 +18,12 @@ The fastest way to understand BMad is to try it. Install BMad and run `/bmad-help` — it will guide you through everything based on your project and installed modules. ::: +## Advanced Setup + +- **[Monorepo Support](./how-to/monorepo-setup.md)** — Manage multiple projects in a single repository. +- **[Non-Interactive Installation](./how-to/non-interactive-installation.md)** — Automate BMad installation for CI/CD. + + ## How to Use These Docs These docs are organized into four sections based on what you're trying to do: From 54139314437a18c124d202e2e9c00d7db34b75b0 Mon Sep 17 00:00:00 2001 From: sno Date: Thu, 19 Feb 2026 14:04:58 +0100 Subject: [PATCH 11/16] docs: Explain inline check retention in advanced elicitation workflow XML. --- src/core/workflows/advanced-elicitation/workflow.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/workflows/advanced-elicitation/workflow.xml b/src/core/workflows/advanced-elicitation/workflow.xml index 0f8ed3be7..edce339f8 100644 --- a/src/core/workflows/advanced-elicitation/workflow.xml +++ b/src/core/workflows/advanced-elicitation/workflow.xml @@ -20,6 +20,7 @@ + Read content as project_suffix From 89e310a6ce402795e6bc7b362fe20a697e532564 Mon Sep 17 00:00:00 2001 From: sno Date: Fri, 20 Feb 2026 10:47:48 +0100 Subject: [PATCH 12/16] chore(cli): refine folder protection, sync regex, correct replacement order, and template paths --- docs/how-to/monorepo-setup.md | 2 +- .../0-context/set-project/workflow.md | 21 ++++++++---- .../create-product-brief/workflow.md | 2 +- .../research/workflow-domain-research.md | 2 +- .../research/workflow-market-research.md | 2 +- .../research/workflow-technical-research.md | 2 +- .../create-prd/workflow-edit-prd.md | 2 +- .../create-prd/workflow-validate-prd.md | 2 +- .../create-ux-design/workflow.md | 2 +- .../workflow.md | 2 +- .../create-architecture/workflow.md | 2 +- .../create-epics-and-stories/workflow.md | 2 +- .../code-review/instructions.xml | 15 +++++---- .../create-story/instructions.xml | 2 +- .../sprint-status/instructions.md | 19 +++++++++-- .../bmad-quick-flow/quick-dev/workflow.md | 2 +- .../bmad-quick-flow/quick-spec/workflow.md | 2 +- .../document-project/instructions.md | 2 +- .../workflows/deep-dive-instructions.md | 33 +++++++++++++------ .../generate-project-context/workflow.md | 2 +- .../advanced-elicitation/workflow.xml | 33 +++++++++++++++---- src/core/workflows/brainstorming/workflow.md | 2 +- src/core/workflows/party-mode/workflow.md | 2 +- test/test-context-logic-integration.js | 22 +++++++++---- test/test-monorepo-validation.js | 24 ++++++++++---- tools/cli/installers/lib/core/installer.js | 11 +++++-- .../cli/installers/lib/ide/_config-driven.js | 7 ++-- .../lib/ide/shared/context-logic.js | 16 +++++---- .../ide/shared/workflow-command-generator.js | 20 +++++++---- .../combined/default-workflow-yaml.md | 4 +-- .../ide/templates/combined/kiro-workflow.md | 2 +- .../templates/combined/opencode-workflow.md | 3 +- 32 files changed, 180 insertions(+), 86 deletions(-) diff --git a/docs/how-to/monorepo-setup.md b/docs/how-to/monorepo-setup.md index 4aea2fb48..44105e18e 100644 --- a/docs/how-to/monorepo-setup.md +++ b/docs/how-to/monorepo-setup.md @@ -45,7 +45,7 @@ monorepo-root/ ### Context Injection -Core and BMM workflows automatically check for the existence of `_bmad/.current_project`. +Core and BMM workflows automatically check for the existence of `{project-root}/_bmad/.current_project`. - **If found**: It reads the content (e.g., "app-alpha") and overrides the `output_folder` to `_bmad-output/app-alpha`. - **If not found**: It behaves like a standard single-project installation, outputting to `_bmad-output` root. diff --git a/src/bmm/workflows/0-context/set-project/workflow.md b/src/bmm/workflows/0-context/set-project/workflow.md index 51fa848c2..cd373b885 100644 --- a/src/bmm/workflows/0-context/set-project/workflow.md +++ b/src/bmm/workflows/0-context/set-project/workflow.md @@ -16,20 +16,29 @@ This is a single-step workflow that updates a local state file. ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. ### 2. Context Management -1. **Ask User:** "Please enter the **project name** or path relative to `_bmad-output/` (e.g. `project-name` or `libs/auth-lib`). Enter `CLEAR` to reset to root." +1. **Ask User:** "Please enter the **project name** or path relative to `_bmad-output/` (e.g. `project-name` or `auth-lib`). Enter `CLEAR` to reset to root." 2. **Wait for Input.** 3. **Process Input:** - **Case: CLEAR**: - Delete file: `{project-root}/_bmad/.current_project` - Output: "✅ Project context cleared. Artifacts will go to root `_bmad-output/`." - **Case: Path Provided**: - - **Sanitize:** Remove leading `/` or `_bmad-output/` if present in the input. - - Write file: `{project-root}/_bmad/.current_project` with content `` - - Output: "✅ Project context set to: ``. Artifacts will go to `_bmad-output//`." + - **1. Cleanup**: Remove leading/trailing slashes and any occurrences of `_bmad-output/`. + - **2. Validate - No Traversal**: Reject if path contains `..`. + - **3. Validate - No Absolute**: Reject if path starts with `/` or drive letter (e.g., `C:`). + - **4. Validate - Empty/Whitespace**: Reject if empty or only whitespace. + - **5. Validate - Whitelist**: Match against regex `^[a-zA-Z0-9._-/]+$`. + - **Check Results**: + - **If Invalid**: + - Output: "❌ Error: Invalid project context — must be a relative path and contain only alphanumeric characters, dots, dashes, underscores, or slashes. Traversal (..) is strictly forbidden." + - **HALT** + - **If Valid**: + - Write file: `{project-root}/_bmad/.current_project` with content `` + - Output: "✅ Project context set to: ``. Artifacts will go to `_bmad-output//`." ### 3. Verification @@ -45,5 +54,5 @@ You can also temporarily run a command against a different project without chang **Precedence:** 1. **Inline Override** (`#p:NAME`) -2. **Global Context File** (`_bmad/.current_project`) +2. **Global Context File** (`{project-root}/_bmad/.current_project`) 3. **Default Config** (if neither is present) diff --git a/src/bmm/workflows/1-analysis/create-product-brief/workflow.md b/src/bmm/workflows/1-analysis/create-product-brief/workflow.md index 14a9084a5..708904df6 100644 --- a/src/bmm/workflows/1-analysis/create-product-brief/workflow.md +++ b/src/bmm/workflows/1-analysis/create-product-brief/workflow.md @@ -49,7 +49,7 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `planning_artifacts`, `user_name`, `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/1-analysis/research/workflow-domain-research.md b/src/bmm/workflows/1-analysis/research/workflow-domain-research.md index f17a7d907..b026a448b 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-domain-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-domain-research.md @@ -18,7 +18,7 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `planning_artifacts`, `user_name` diff --git a/src/bmm/workflows/1-analysis/research/workflow-market-research.md b/src/bmm/workflows/1-analysis/research/workflow-market-research.md index 06501fdb1..5cd0f26c9 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-market-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-market-research.md @@ -18,7 +18,7 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `planning_artifacts`, `user_name` diff --git a/src/bmm/workflows/1-analysis/research/workflow-technical-research.md b/src/bmm/workflows/1-analysis/research/workflow-technical-research.md index 778def8c7..2fd1d5bf8 100644 --- a/src/bmm/workflows/1-analysis/research/workflow-technical-research.md +++ b/src/bmm/workflows/1-analysis/research/workflow-technical-research.md @@ -18,7 +18,7 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `planning_artifacts`, `user_name` diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md index 37731b4c5..2d428529f 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-edit-prd.md @@ -48,7 +48,7 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `planning_artifacts`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md index 7b17c8026..18746cee2 100644 --- a/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md +++ b/src/bmm/workflows/2-plan-workflows/create-prd/workflow-validate-prd.md @@ -48,7 +48,7 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `planning_artifacts`, `user_name` diff --git a/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md b/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md index f00c76256..ccf92bf56 100644 --- a/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md +++ b/src/bmm/workflows/2-plan-workflows/create-ux-design/workflow.md @@ -24,7 +24,7 @@ This uses **micro-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `planning_artifacts`, `user_name` diff --git a/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md b/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md index 58b12630d..0e7d91a28 100644 --- a/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md +++ b/src/bmm/workflows/3-solutioning/check-implementation-readiness/workflow.md @@ -44,7 +44,7 @@ description: 'Critical validation workflow that assesses PRD, Architecture, and ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `planning_artifacts`, `user_name`, `communication_language`, `document_output_language` - ✅ YOU MUST ALWAYS SPEAK OUTPUT In your Agent communication style with the config `{communication_language}` diff --git a/src/bmm/workflows/3-solutioning/create-architecture/workflow.md b/src/bmm/workflows/3-solutioning/create-architecture/workflow.md index 100432e4e..d205c79b7 100644 --- a/src/bmm/workflows/3-solutioning/create-architecture/workflow.md +++ b/src/bmm/workflows/3-solutioning/create-architecture/workflow.md @@ -27,7 +27,7 @@ This uses **micro-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: diff --git a/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md b/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md index 6d449749e..b87cb05d0 100644 --- a/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md +++ b/src/bmm/workflows/3-solutioning/create-epics-and-stories/workflow.md @@ -48,7 +48,7 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `planning_artifacts`, `user_name`, `communication_language`, `document_output_language` diff --git a/src/bmm/workflows/4-implementation/code-review/instructions.xml b/src/bmm/workflows/4-implementation/code-review/instructions.xml index becdbc943..0ce1584f4 100644 --- a/src/bmm/workflows/4-implementation/code-review/instructions.xml +++ b/src/bmm/workflows/4-implementation/code-review/instructions.xml @@ -18,14 +18,15 @@ Read content as project_suffix - - Trim whitespace and newlines from project_suffix - - 🚫 Security Error: Invalid project context path detected. - HALT + + + 🚫 Security Error: Invalid project context path detected — path traversal or absolute path detected. + HALT - - 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. + + + + 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, underscores, or slashes. HALT Override output_folder to {project-root}/_bmad-output/{project_suffix} diff --git a/src/bmm/workflows/4-implementation/create-story/instructions.xml b/src/bmm/workflows/4-implementation/create-story/instructions.xml index d7b7158aa..dd8f2fe07 100644 --- a/src/bmm/workflows/4-implementation/create-story/instructions.xml +++ b/src/bmm/workflows/4-implementation/create-story/instructions.xml @@ -262,7 +262,7 @@ 📝 CREATE ULTIMATE STORY FILE - The developer's master implementation guide! - Set {target_story_file} = {output_folder}/{story_key}.md + Set {target_story_file} = {output_folder}/{{story_key}}.md Output "Generating story file at: {target_story_file}" Initialize from template.md: diff --git a/src/bmm/workflows/4-implementation/sprint-status/instructions.md b/src/bmm/workflows/4-implementation/sprint-status/instructions.md index 43b5e1316..50a4ff349 100644 --- a/src/bmm/workflows/4-implementation/sprint-status/instructions.md +++ b/src/bmm/workflows/4-implementation/sprint-status/instructions.md @@ -25,17 +25,26 @@ + + + 🚫 Error: Workflow configuration not loaded properly ({sprint_status_file} is undefined). + HALT + + Load {project_context} for project-wide patterns and conventions (if exists) Try {sprint_status_file} - ❌ sprint-status.yaml not found. + ❌ sprint-status.yaml not found at: {sprint_status_file} Run `/bmad:bmm:workflows:sprint-planning` to generate it, then rerun sprint-status. - Exit workflow + HALT Continue to Step 2 + + HALT - Safety Error: sprint_status_file variable lost or undefined. + Read the FULL file: {sprint_status_file} Parse fields: generated, project, project_key, tracking_system, story_location Parse development_status map. Classify keys: @@ -165,6 +174,9 @@ If the command targets a story, set `story_key={{next_story_id}}` when prompted. + + HALT - Safety Error: sprint_status_file variable lost or undefined. + Load and parse {sprint_status_file} same as Step 2 Compute recommendation same as Step 3 next_workflow_id = {{next_workflow_id}} @@ -186,6 +198,9 @@ If the command targets a story, set `story_key={{next_story_id}}` when prompted. + + HALT - Safety Error: sprint_status_file variable lost or undefined. + Check that {sprint_status_file} exists is_valid = false diff --git a/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md b/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md index 56fa658e1..abb14ea58 100644 --- a/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md +++ b/src/bmm/workflows/bmad-quick-flow/quick-dev/workflow.md @@ -25,7 +25,7 @@ This uses **step-file architecture** for focused execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: diff --git a/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md b/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md index ad027deb7..7d70e8edb 100644 --- a/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md +++ b/src/bmm/workflows/bmad-quick-flow/quick-spec/workflow.md @@ -66,7 +66,7 @@ This uses **step-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. Load config from `{project-root}/_bmad/bmm/config.yaml` and resolve: - `project_name`, `planning_artifacts`, `implementation_artifacts`, `user_name` diff --git a/src/bmm/workflows/document-project/instructions.md b/src/bmm/workflows/document-project/instructions.md index d6a685c3d..a0e21780f 100644 --- a/src/bmm/workflows/document-project/instructions.md +++ b/src/bmm/workflows/document-project/instructions.md @@ -81,7 +81,7 @@ ## 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. diff --git a/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md b/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md index 17b7768d9..a3428e83f 100644 --- a/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md +++ b/src/bmm/workflows/document-project/workflows/deep-dive-instructions.md @@ -11,18 +11,31 @@ Load existing project structure from index.md and project-parts.json (if exists) Load source tree analysis to understand available areas - + +Scan request for pattern #project:NAME or #p:NAME (case-insensitive) + + Set project_suffix = extracted NAME + + + + Read content as project_suffix - - Trim whitespace and newlines from project_suffix - - 🚫 Security Error: Invalid project context path detected. - HALT + + + + + + + 🚫 Security Error: Invalid project context path detected — path traversal or absolute path detected. + HALT - - 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. - HALT + + + + 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, underscores, or slashes. + HALT + Override output_folder to {project-root}/_bmad-output/{project_suffix} Override project_knowledge to {project-root}/_bmad-output/{project_suffix} Output "Monorepo context detected. Writing deep-dive artifacts to: {project_knowledge}" @@ -269,7 +282,7 @@ Detailed exhaustive analysis of specific areas: - Dependency graph and data flow ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - Related code and reuse opportunities diff --git a/src/bmm/workflows/generate-project-context/workflow.md b/src/bmm/workflows/generate-project-context/workflow.md index 749016fec..16f84f65f 100644 --- a/src/bmm/workflows/generate-project-context/workflow.md +++ b/src/bmm/workflows/generate-project-context/workflow.md @@ -27,7 +27,7 @@ This uses **micro-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `user_name` diff --git a/src/core/workflows/advanced-elicitation/workflow.xml b/src/core/workflows/advanced-elicitation/workflow.xml index edce339f8..bca783a09 100644 --- a/src/core/workflows/advanced-elicitation/workflow.xml +++ b/src/core/workflows/advanced-elicitation/workflow.xml @@ -21,19 +21,38 @@ - + + + Scan request for pattern #project:NAME or #p:NAME (case-insensitive) + + Set project_suffix = extracted NAME + + + + Read content as project_suffix - - Trim whitespace and newlines from project_suffix - - 🚫 Security Error: Invalid project context path detected. + + + + + + + 🚫 Security Error: Invalid project context path detected — path traversal or absolute path detected. HALT - - 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, or underscores. + + + + 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, underscores, or slashes. HALT + Override output_folder to {project-root}/_bmad-output/{project_suffix} + Override planning_artifacts to {project-root}/_bmad-output/{project_suffix} + Override implementation_artifacts to {project-root}/_bmad-output/{project_suffix} + Override project_knowledge to {project-root}/_bmad-output/{project_suffix} + Override sprint_status_file to {project-root}/_bmad-output/{project_suffix}/sprint-status.yaml + Output "Monorepo context detected. Paths adjusted to: {project_suffix}" Load and read {{methods}} and {{agent-party}} diff --git a/src/core/workflows/brainstorming/workflow.md b/src/core/workflows/brainstorming/workflow.md index fb983a730..2db66a1e2 100644 --- a/src/core/workflows/brainstorming/workflow.md +++ b/src/core/workflows/brainstorming/workflow.md @@ -34,7 +34,7 @@ This uses **micro-file architecture** for disciplined execution: ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `user_name` diff --git a/src/core/workflows/party-mode/workflow.md b/src/core/workflows/party-mode/workflow.md index 183968f7d..1d38557ef 100644 --- a/src/core/workflows/party-mode/workflow.md +++ b/src/core/workflows/party-mode/workflow.md @@ -27,7 +27,7 @@ This uses **micro-file architecture** with **sequential conversation orchestrati ### 1. Configuration Loading -Load and read full config from {main_config} and resolve basic variables. +Load and read full config from {main_config} and resolve variables and artifact paths. - `project_name`, `output_folder`, `user_name` - `communication_language`, `document_output_language`, `user_skill_level` diff --git a/test/test-context-logic-integration.js b/test/test-context-logic-integration.js index 75a40d8d4..c100acf41 100644 --- a/test/test-context-logic-integration.js +++ b/test/test-context-logic-integration.js @@ -108,9 +108,13 @@ async function runTests() { for (const { file, expectedImport } of consumers) { const fullPath = path.join(root, file); - const content = await readFile(fullPath); - ok(content.includes(expectedImport), `${path.basename(file)} imports context-logic correctly`); - ok(content.includes("replaceAll('{{monorepo_context_logic}}'"), `${path.basename(file)} uses replaceAll for placeholder`); + try { + const content = await readFile(fullPath); + ok(content.includes(expectedImport), `${path.basename(file)} imports context-logic correctly`); + ok(content.includes("replaceAll('{{monorepo_context_logic}}'"), `${path.basename(file)} uses replaceAll for placeholder`); + } catch (error) { + ok(false, `File not found or unreadable: ${fullPath} - ${error.message}`); + } } console.log(''); @@ -135,10 +139,14 @@ async function runTests() { for (const filePath of mustHavePlaceholder) { const rel = path.relative(root, filePath); - const content = await readFile(filePath); - ok(content.includes('{{monorepo_context_logic}}'), `${path.basename(filePath)} has {{monorepo_context_logic}} placeholder`); - // Must NOT have raw hardcoded block (only the shared module should have it) - ok(!content.includes(' block`); + try { + const content = await readFile(filePath); + ok(content.includes('{{monorepo_context_logic}}'), `${path.basename(filePath)} has {{monorepo_context_logic}} placeholder`); + // Must NOT have raw hardcoded block (only the shared module should have it) + ok(!content.includes(' block`); + } catch (error) { + ok(false, `File not found or unreadable: ${filePath} - ${error.message}`); + } } console.log(''); diff --git a/test/test-monorepo-validation.js b/test/test-monorepo-validation.js index 0b696390e..fb4d90d28 100644 --- a/test/test-monorepo-validation.js +++ b/test/test-monorepo-validation.js @@ -18,7 +18,7 @@ const fs = require('fs-extra'); const path = require('node:path'); -const glob = require('glob'); +const { globSync } = require('glob'); // ANSI colors const colors = { @@ -70,15 +70,26 @@ async function runTests() { console.log(`${colors.yellow}Test Suite 2: No Stale Inline Monorepo Context Checks${colors.reset}\n`); console.log(` ${colors.dim}(Inline checks were moved to workflow.xml via context-logic.js)${colors.reset}\n`); - const workflowFiles = glob.sync('src/{core,bmm}/workflows/**/*.{md,xml}', { cwd: projectRoot }); + const workflowFiles = globSync('src/{core,bmm}/workflows/**/*.{md,xml}', { cwd: projectRoot }); + + const exceptions = [ + 'context-logic.js', + 'code-review/instructions.xml', + 'create-story/instructions.xml', + 'dev-story/instructions.xml', + 'advanced-elicitation/workflow.xml', + 'deep-dive-instructions.md', + ]; for (const file of workflowFiles) { - // skip the context-logic source itself (it's the canonical source) - if (file.includes('context-logic')) continue; + if (exceptions.some((e) => file.endsWith(e))) continue; const content = await fs.readFile(path.join(projectRoot, file), 'utf8'); - assert(!content.includes('**Monorepo Context Check:**'), `No stale inline check block in: ${file}`); + const hasMarkdownCheck = content.includes('**Monorepo Context Check:**'); + const hasXmlCheck = / - - Read {project-root}/_bmad/.current_project as project_suffix + + Read {project-root}/{{bmadFolderName}}/.current_project as project_suffix Trim whitespace and newlines from project_suffix - - - 🚫 Security Error: Invalid project context — path traversal detected. + + + 🚫 Security Error: Invalid project context — path traversal or absolute path detected. HALT - - 🚫 Error: project_suffix must only contain alphanumeric characters, dots, dashes, or underscores. + + + + 🚫 Error: project_suffix must only contain alphanumeric characters, dots, dashes, underscores, or slashes. HALT diff --git a/tools/cli/installers/lib/ide/shared/workflow-command-generator.js b/tools/cli/installers/lib/ide/shared/workflow-command-generator.js index 985e3437b..e97b9a67b 100644 --- a/tools/cli/installers/lib/ide/shared/workflow-command-generator.js +++ b/tools/cli/installers/lib/ide/shared/workflow-command-generator.js @@ -154,13 +154,19 @@ class WorkflowCommandGenerator { const { MONOREPO_CONTEXT_LOGIC } = require('./context-logic'); // Replace template variables - return template - .replaceAll('{{name}}', workflow.name) - .replaceAll('{{module}}', workflow.module) - .replaceAll('{{description}}', workflow.description) - .replaceAll('{{workflow_path}}', workflowPath) - .replaceAll('{{monorepo_context_logic}}', MONOREPO_CONTEXT_LOGIC) - .replaceAll('_bmad', this.bmadFolderName); + return ( + template + .replaceAll('{{name}}', workflow.name) + .replaceAll('{{module}}', workflow.module) + .replaceAll('{{description}}', workflow.description) + .replaceAll('{{workflow_path}}', workflowPath) + .replaceAll('{{monorepo_context_logic}}', MONOREPO_CONTEXT_LOGIC) + // Replace _bmad placeholder with actual folder name using precise regex + // This protects literals like '_bmad-output' from corruption. + .replaceAll(/_bmad(?!-output)/g, this.bmadFolderName) + // Replace {{bmadFolderName}} placeholder (used in centralized context logic) + .replaceAll('{{bmadFolderName}}', this.bmadFolderName) + ); } /** diff --git a/tools/cli/installers/lib/ide/templates/combined/default-workflow-yaml.md b/tools/cli/installers/lib/ide/templates/combined/default-workflow-yaml.md index 605e6c57b..ac7a5bb9d 100644 --- a/tools/cli/installers/lib/ide/templates/combined/default-workflow-yaml.md +++ b/tools/cli/installers/lib/ide/templates/combined/default-workflow-yaml.md @@ -6,9 +6,9 @@ disable-model-invocation: true IT IS CRITICAL THAT YOU FOLLOW THESE STEPS - while staying in character as the current agent persona you may have loaded: - -0. {{monorepo_context_logic}} +{{monorepo_context_logic}} + 1. Always LOAD the FULL @{project-root}/{{bmadFolderName}}/core/tasks/workflow.xml 2. READ its entire contents - this is the CORE OS for EXECUTING the specific workflow-config @{project-root}/{{bmadFolderName}}/{{path}} 3. Pass the yaml path @{project-root}/{{bmadFolderName}}/{{path}} as 'workflow-config' parameter to the workflow.xml instructions diff --git a/tools/cli/installers/lib/ide/templates/combined/kiro-workflow.md b/tools/cli/installers/lib/ide/templates/combined/kiro-workflow.md index 2041edfdd..54aef9d57 100644 --- a/tools/cli/installers/lib/ide/templates/combined/kiro-workflow.md +++ b/tools/cli/installers/lib/ide/templates/combined/kiro-workflow.md @@ -6,4 +6,4 @@ inclusion: manual {{monorepo_context_logic}} -IT IS CRITICAL THAT YOU FOLLOW THIS COMMAND: LOAD the FULL @{project-root}/{{bmadFolderName}}/{{path}}, READ its entire contents and follow its directions exactly! +IT IS CRITICAL THAT YOU FOLLOW THIS COMMAND: LOAD the FULL #[[file:{{bmadFolderName}}/{{path}}]], READ its entire contents and follow its directions exactly! diff --git a/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md b/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md index e7596ea1d..1b5046e09 100644 --- a/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md +++ b/tools/cli/installers/lib/ide/templates/combined/opencode-workflow.md @@ -3,12 +3,13 @@ name: '{{name}}' description: '{{description}}' --- +{{monorepo_context_logic}} + Execute the BMAD '{{name}}' workflow. CRITICAL: You must load and follow the workflow definition exactly. WORKFLOW INSTRUCTIONS: -{{monorepo_context_logic}} 1. LOAD the workflow file from {project-root}/{{bmadFolderName}}/{{path}} 2. READ its entire contents From eb6568c8c1068b5ba954a8dd066f0bd07ee0a838 Mon Sep 17 00:00:00 2001 From: sno Date: Fri, 20 Feb 2026 12:20:59 +0100 Subject: [PATCH 13/16] feat(cli): add /list-envs and enhance /set-project interactivity --- docs/how-to/monorepo-setup.md | 13 +++++---- .../workflows/0-context/list-envs/workflow.md | 26 +++++++++++++++++ .../0-context/set-project/workflow.md | 29 +++++++++++++------ test/test-monorepo-validation.js | 2 +- 4 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 src/bmm/workflows/0-context/list-envs/workflow.md diff --git a/docs/how-to/monorepo-setup.md b/docs/how-to/monorepo-setup.md index 44105e18e..a21750132 100644 --- a/docs/how-to/monorepo-setup.md +++ b/docs/how-to/monorepo-setup.md @@ -49,18 +49,21 @@ Core and BMM workflows automatically check for the existence of `{project-root}/ - **If found**: It reads the content (e.g., "app-alpha") and overrides the `output_folder` to `_bmad-output/app-alpha`. - **If not found**: It behaves like a standard single-project installation, outputting to `_bmad-output` root. +### The /list-envs Command + +You can view all available environments created in your monorepo by running the `/list-envs` command. This will scan your `_bmad-output/` directory and display all existing project environments, as well as indicate which one is currently active. + ### The /set-project Command You can easily manage the active project context using the `/set-project` workflow. **To set a context:** -1. Run `/set-project` in your chat. -2. Select "Set Project Context". -3. Enter the name of your project (e.g., `frontend`, `backend`, `mobile-app`). +1. Run `/set-project ` in your chat. +2. If the environment does not exist, you will be prompted to create it interactively. +3. If you run `/set-project` without an argument, it will automatically list available environments and prompt you to select one or create a new one. **To clear context (return to single-project mode):** -1. Run `/set-project`. -2. Select "Clear Project Context". +1. Run `/set-project CLEAR`. ### Inline Override diff --git a/src/bmm/workflows/0-context/list-envs/workflow.md b/src/bmm/workflows/0-context/list-envs/workflow.md new file mode 100644 index 000000000..fe8fad04c --- /dev/null +++ b/src/bmm/workflows/0-context/list-envs/workflow.md @@ -0,0 +1,26 @@ +--- +name: list-envs +description: List available project environments for monorepo support +main_config: '{project-root}/_bmad/bmm/config.yaml' +--- + +# List Project Environments + +**Goal:** List the available project context environments for BMAD artifacts. + +**Your Role:** Configuration Assistant. + +## WORKFLOW ARCHITECTURE + +### 1. Identify Environments + +- Use your file listing/system capabilities to examine the `{project-root}/_bmad-output/` directory. +- Identify all subdirectories within this path. Each subdirectory represents an available environment (ignore hidden directories starting with `.`). +- The root `_bmad-output/` directory itself represents the `default (root)` unset environment. + +### 2. Output Results + +1. Display a formatted bulleted list of the existing environments you found. +2. Clearly indicate the `default (root)` environment. +3. Check if there is an active environment currently set. Read `{project-root}/{{bmadFolderName}}/.current_project`. If it exists, indicate which environment from the list is currently active (e.g. by adding `(ACTIVE)` next to the bullet point). +4. Inform the user that they can switch to another environment or create a new one using the `/set-project ` command. diff --git a/src/bmm/workflows/0-context/set-project/workflow.md b/src/bmm/workflows/0-context/set-project/workflow.md index cd373b885..df1c7ac1a 100644 --- a/src/bmm/workflows/0-context/set-project/workflow.md +++ b/src/bmm/workflows/0-context/set-project/workflow.md @@ -20,24 +20,35 @@ Load and read full config from {main_config} and resolve variables and artifact ### 2. Context Management -1. **Ask User:** "Please enter the **project name** or path relative to `_bmad-output/` (e.g. `project-name` or `auth-lib`). Enter `CLEAR` to reset to root." -2. **Wait for Input.** -3. **Process Input:** +1. **Analyze Request**: Determine the requested project name from the user's initial invocation (e.g., `/set-project my-app`). +2. **Wait for Input (If Missing)**: If the user did NOT provide a project name: + - Use your file listing capabilities to examine the `{project-root}/_bmad-output/` directory. + - Output: A formatted list of the existing environments (subdirectories) you found, explicitly noting the `default (root)` environment. + - Ask the user: "Please select an existing environment from the list above, or type a new name to create one. Enter `CLEAR` to reset to root." + - **Wait for Input.** +3. **Process Input**: Once a project name is established: - **Case: CLEAR**: - - Delete file: `{project-root}/_bmad/.current_project` + - Delete file: `{project-root}/{{bmadFolderName}}/.current_project` - Output: "✅ Project context cleared. Artifacts will go to root `_bmad-output/`." + - **HALT** - **Case: Path Provided**: - **1. Cleanup**: Remove leading/trailing slashes and any occurrences of `_bmad-output/`. - - **2. Validate - No Traversal**: Reject if path contains `..`. - - **3. Validate - No Absolute**: Reject if path starts with `/` or drive letter (e.g., `C:`). - - **4. Validate - Empty/Whitespace**: Reject if empty or only whitespace. - - **5. Validate - Whitelist**: Match against regex `^[a-zA-Z0-9._-/]+$`. + - **2. Validate Existence**: Check if `{project-root}/_bmad-output/` exists on the file system. + - **If it DOES NOT exist**: + - Ask: "The environment `` is not present. Do you want to create a new one? (Yes/No)" + - **Wait for Input.** + - **If No**: Inform the user to run `/list-envs` to see available environments or `/set-project` to try again. **HALT**. + - **If Yes**: Proceed to validation. + - **3. Validate - No Traversal**: Reject if path contains `..`. + - **4. Validate - No Absolute**: Reject if path starts with `/` or drive letter (e.g., `C:`). + - **5. Validate - Empty/Whitespace**: Reject if empty or only whitespace. + - **6. Validate - Whitelist**: Match against regex `^[a-zA-Z0-9._-/]+$`. - **Check Results**: - **If Invalid**: - Output: "❌ Error: Invalid project context — must be a relative path and contain only alphanumeric characters, dots, dashes, underscores, or slashes. Traversal (..) is strictly forbidden." - **HALT** - **If Valid**: - - Write file: `{project-root}/_bmad/.current_project` with content `` + - Write file: `{project-root}/{{bmadFolderName}}/.current_project` with content `` - Output: "✅ Project context set to: ``. Artifacts will go to `_bmad-output//`." ### 3. Verification diff --git a/test/test-monorepo-validation.js b/test/test-monorepo-validation.js index fb4d90d28..cd7f41727 100644 --- a/test/test-monorepo-validation.js +++ b/test/test-monorepo-validation.js @@ -115,7 +115,7 @@ async function runTests() { assert(exists, 'set-project workflow file exists'); if (exists) { const content = await fs.readFile(setProjectPath, 'utf8'); - assert(content.includes('_bmad/.current_project'), 'set-project implementation manages .current_project'); + assert(content.includes('{{bmadFolderName}}/.current_project'), 'set-project implementation manages .current_project'); const examplePattern = /(?:example|my[-_ ]?app|[a-z0-9]+-[a-z0-9]+)/i; assert(examplePattern.test(content), 'set-project examples use generic public-friendly names'); } From 2a30b47c9184ba74e8721ad8f1bb7a801bae3bbd Mon Sep 17 00:00:00 2001 From: sno Date: Fri, 20 Feb 2026 12:35:09 +0100 Subject: [PATCH 14/16] feat(cli): refine /set-project with numbered selection and exclusions --- .../workflows/0-context/list-envs/workflow.md | 4 +++- .../0-context/set-project/workflow.md | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/bmm/workflows/0-context/list-envs/workflow.md b/src/bmm/workflows/0-context/list-envs/workflow.md index fe8fad04c..953182555 100644 --- a/src/bmm/workflows/0-context/list-envs/workflow.md +++ b/src/bmm/workflows/0-context/list-envs/workflow.md @@ -15,7 +15,9 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' ### 1. Identify Environments - Use your file listing/system capabilities to examine the `{project-root}/_bmad-output/` directory. -- Identify all subdirectories within this path. Each subdirectory represents an available environment (ignore hidden directories starting with `.`). +- Identify all subdirectories within this path. Each subdirectory represents an available environment, EXCEPT: + - Ignore hidden directories starting with `.` + - Ignore standard BMAD artifact directories: `planning-artifacts`, `implementation-artifacts`, `test-artifacts`, `knowledge`, `docs`, `assets` - The root `_bmad-output/` directory itself represents the `default (root)` unset environment. ### 2. Output Results diff --git a/src/bmm/workflows/0-context/set-project/workflow.md b/src/bmm/workflows/0-context/set-project/workflow.md index df1c7ac1a..557e5ce31 100644 --- a/src/bmm/workflows/0-context/set-project/workflow.md +++ b/src/bmm/workflows/0-context/set-project/workflow.md @@ -24,14 +24,29 @@ Load and read full config from {main_config} and resolve variables and artifact 2. **Wait for Input (If Missing)**: If the user did NOT provide a project name: - Use your file listing capabilities to examine the `{project-root}/_bmad-output/` directory. - Output: A formatted list of the existing environments (subdirectories) you found, explicitly noting the `default (root)` environment. - - Ask the user: "Please select an existing environment from the list above, or type a new name to create one. Enter `CLEAR` to reset to root." + *(Exclude hidden directories and standard BMAD artifact folders like `planning-artifacts`, `implementation-artifacts`, `test-artifacts`, `knowledge`, `docs`, `assets`)* + - Present options in a numbered list format and ask the user to select by number or type a new project name: + ``` + Select a project environment: + [0] default (root) - Current location for standard artifacts + [1] project-name-1 + [2] project-name-2 + ... + + Enter a number to select, type a new project name, or enter 'CLEAR' to reset to root: + ``` - **Wait for Input.** 3. **Process Input**: Once a project name is established: - **Case: CLEAR**: - Delete file: `{project-root}/{{bmadFolderName}}/.current_project` - Output: "✅ Project context cleared. Artifacts will go to root `_bmad-output/`." - **HALT** - - **Case: Path Provided**: + - **Case: Numeric Selection**: If input is a number (0, 1, 2, etc.): + - Map the number to the corresponding environment from your earlier listing + - If number 0, treat as "CLEAR" case above + - If valid number but out of range, show error and ask again + - If valid selection, use that environment name as the path + - **Case: Path Provided** (text input): - **1. Cleanup**: Remove leading/trailing slashes and any occurrences of `_bmad-output/`. - **2. Validate Existence**: Check if `{project-root}/_bmad-output/` exists on the file system. - **If it DOES NOT exist**: From 9d00f69680d52055980950d84cae570e80c95db0 Mon Sep 17 00:00:00 2001 From: sno Date: Fri, 20 Feb 2026 12:35:25 +0100 Subject: [PATCH 15/16] feat(cli): refine /set-project and /list-envs with numbered selection and exclusions --- src/bmm/workflows/0-context/list-envs/workflow.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bmm/workflows/0-context/list-envs/workflow.md b/src/bmm/workflows/0-context/list-envs/workflow.md index 953182555..3c5cd3b35 100644 --- a/src/bmm/workflows/0-context/list-envs/workflow.md +++ b/src/bmm/workflows/0-context/list-envs/workflow.md @@ -22,7 +22,7 @@ main_config: '{project-root}/_bmad/bmm/config.yaml' ### 2. Output Results -1. Display a formatted bulleted list of the existing environments you found. -2. Clearly indicate the `default (root)` environment. +1. Display a formatted numbered list of the existing environments you found. +2. Clearly indicate the `default (root)` environment (usually [0]). 3. Check if there is an active environment currently set. Read `{project-root}/{{bmadFolderName}}/.current_project`. If it exists, indicate which environment from the list is currently active (e.g. by adding `(ACTIVE)` next to the bullet point). 4. Inform the user that they can switch to another environment or create a new one using the `/set-project ` command. From efc2152ad89c109d3112df6b736ccca6486abca7 Mon Sep 17 00:00:00 2001 From: sno Date: Sun, 22 Feb 2026 15:09:57 +0100 Subject: [PATCH 16/16] feat(monorepo): fix project_name resolution and variable leakage --- .../4-implementation/code-review/instructions.xml | 1 + src/core/tasks/workflow.xml | 15 +++++++++------ .../workflows/advanced-elicitation/workflow.xml | 1 + .../installers/lib/ide/shared/context-logic.js | 3 ++- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/bmm/workflows/4-implementation/code-review/instructions.xml b/src/bmm/workflows/4-implementation/code-review/instructions.xml index 0ce1584f4..0d0707599 100644 --- a/src/bmm/workflows/4-implementation/code-review/instructions.xml +++ b/src/bmm/workflows/4-implementation/code-review/instructions.xml @@ -29,6 +29,7 @@ 🚫 Error: Project context must only contain alphanumeric characters, dots, dashes, underscores, or slashes. HALT + Override project_name to {project_suffix} Override output_folder to {project-root}/_bmad-output/{project_suffix} diff --git a/src/core/tasks/workflow.xml b/src/core/tasks/workflow.xml index 2b5503135..59cac7d3e 100644 --- a/src/core/tasks/workflow.xml +++ b/src/core/tasks/workflow.xml @@ -18,8 +18,8 @@ - - {{monorepo_context_logic}} + + Resolve system variables (date:system-generated) and paths ({project-root}, {installed_path}) @@ -27,11 +27,14 @@ Load config_source (REQUIRED for all modules) Load external config from config_source path Resolve all {config_source}: references with values from config - Resolve system variables (date:system-generated) and paths ({project-root}, {installed_path}) - Ask user for input of any variables that are still unknown + Ask user for input of any variables that are still unknown - + + {{monorepo_context_logic}} + + + Instructions: Read COMPLETE file from path OR embedded list (REQUIRED) If template path → Read COMPLETE template file If validation path → Note path for later loading when needed @@ -39,7 +42,7 @@ Data files (csv, json) → Store paths only, load on-demand when instructions reference them - + Resolve default_output_file path with all variables and {{date}} Create output directory if doesn't exist If template-workflow → Write template to output file with placeholders diff --git a/src/core/workflows/advanced-elicitation/workflow.xml b/src/core/workflows/advanced-elicitation/workflow.xml index bca783a09..7764cfd11 100644 --- a/src/core/workflows/advanced-elicitation/workflow.xml +++ b/src/core/workflows/advanced-elicitation/workflow.xml @@ -47,6 +47,7 @@ HALT + Override project_name to {project_suffix} Override output_folder to {project-root}/_bmad-output/{project_suffix} Override planning_artifacts to {project-root}/_bmad-output/{project_suffix} Override implementation_artifacts to {project-root}/_bmad-output/{project_suffix} diff --git a/tools/cli/installers/lib/ide/shared/context-logic.js b/tools/cli/installers/lib/ide/shared/context-logic.js index c25751920..cf26a8ff6 100644 --- a/tools/cli/installers/lib/ide/shared/context-logic.js +++ b/tools/cli/installers/lib/ide/shared/context-logic.js @@ -36,7 +36,8 @@ const MONOREPO_CONTEXT_LOGIC = ` HALT - + + Override project_name = {project_suffix} Override output_folder = {project-root}/_bmad-output/{project_suffix} Override planning_artifacts = {output_folder}/planning-artifacts Override implementation_artifacts = {output_folder}/implementation-artifacts