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); +});