feat: fix missing monorepo context logic and add validation tests

This commit is contained in:
sno 2026-02-17 19:46:14 +01:00
parent 0f37258d5c
commit 1237eeb375
9 changed files with 187 additions and 5 deletions

View File

@ -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",

View File

@ -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}`

View File

@ -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}`

View File

@ -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}`
<action>Maintain running notes of findings and impacts discovered</action>
<action>Present checklist progress after each major section</action>

View File

@ -79,6 +79,15 @@
</step>
## 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 n="3" goal="Check for existing documentation and determine workflow mode" if="resume_mode == false">
<action>Check if {project_knowledge}/index.md exists</action>

View File

@ -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

View File

@ -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

View File

@ -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:

View File

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