fix: anchor workflow commands

This commit is contained in:
mq-bot 2025-12-08 17:19:32 +00:00
parent c6a4a592c0
commit 2bebf1cef5
3 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,21 @@
# Pull Request Instructions for Issue #872
Use this checklist to open a PR from your fork.
1. Push branch `fix/872-architecture-command` to your fork (already pushed locally in this workspace).
2. On GitHub, click **Compare & pull request** with:
- **Base repository:** bmad-code-org/BMAD-METHOD
- **Base branch:** main
- **Head repository:** YOUR_FORK/BMAD-METHOD
- **Head branch:** fix/872-architecture-command
3. Suggested PR title: `fix: anchor workflow commands for create-architecture`
4. PR description (project template):
- **What:** Anchor generated workflow commands to `{project-root}` so IDEs dont resolve core/workflow paths relative to module folders; add regression test for the `create-architecture` workflow command.
- **Why:** `*workflow-init`/`*create-architecture` commands could fail with “workflow.xml does not exist” because generated command paths were relative (e.g., `.bmad/bmm/core/tasks/workflow.xml`). Anchoring ensures commands point to `.bmad/core/tasks/workflow.xml` and the correct workflow file.
- **How:**
- Update workflow command generator to prefix core/workflow paths with `{project-root}` and anchor display paths for installed workflows.
- Add installation component test validating anchored paths for the `create-architecture` command.
- **Testing:** `npm test`
5. Submit the PR and link it to Issue #872.
If reviewers ask for proof, include the `npm test` output from your latest run.

View File

@ -157,6 +157,35 @@ async function runTests() {
console.log('');
// ============================================================
// Test 4: Workflow command paths anchor to project root
// ============================================================
console.log(`${colors.yellow}Test Suite 4: Workflow Command Paths${colors.reset}\n`);
try {
const { WorkflowCommandGenerator } = require('../tools/cli/installers/lib/ide/shared/workflow-command-generator');
const generator = new WorkflowCommandGenerator('.bmad');
const workflow = {
name: 'create-architecture',
module: 'bmm',
description: 'Architecture workflow',
path: '.bmad/bmm/workflows/3-solutioning/architecture/workflow.md',
};
const content = await generator.generateCommandContent(workflow, '');
assert(
content.includes('{project-root}/.bmad/bmm/workflows/3-solutioning/architecture/workflow.md'),
'workflow command uses project-root anchored workflow path',
);
assert(!content.includes('@.bmad/bmm'), 'workflow command avoids relative @.bmad paths that IDEs resolve incorrectly');
} catch (error) {
assert(false, 'workflow command generator anchors paths', error.message);
}
console.log('');
// ============================================================
// Test 5: TEA Agent Special Handling
// ============================================================

View File

@ -112,6 +112,11 @@ class WorkflowCommandGenerator {
// To: {project-root}/{bmad_folder}/bmm/workflows/.../workflow.yaml
let workflowPath = workflow.path;
const withProjectRoot = (p) => {
if (!p) return p;
return p.startsWith('{project-root}/') ? p : `{project-root}/${p}`;
};
// Extract the relative path from source
if (workflowPath.includes('/src/modules/')) {
const match = workflowPath.match(/\/src\/modules\/(.+)/);
@ -125,7 +130,11 @@ class WorkflowCommandGenerator {
}
}
const coreWorkflowPath = `${this.bmadFolderName}/core/tasks/workflow.xml`;
// Anchor paths to project root to prevent IDEs from resolving relative to module folders
workflowPath = withProjectRoot(workflowPath);
// Core workflow is always at the BMAD root
const coreWorkflowPath = withProjectRoot(`${this.bmadFolderName}/core/tasks/workflow.xml`);
// Replace template variables
return template
@ -221,6 +230,9 @@ When running any workflow:
if (match) {
transformed = `{project-root}/${this.bmadFolderName}/core/${match[1]}`;
}
} else if (!workflowPath.startsWith('{project-root}/')) {
// Already an installed path (e.g., ".bmad/bmm/...") - anchor to project root
transformed = `{project-root}/${workflowPath}`;
}
return transformed;