From 2bebf1cef527d763bee451b0a6650f9ce8ef95bb Mon Sep 17 00:00:00 2001 From: mq-bot Date: Mon, 8 Dec 2025 17:19:32 +0000 Subject: [PATCH] fix: anchor workflow commands --- docs/pr-instructions-issue-872.md | 21 ++++++++++++++ test/test-installation-components.js | 29 +++++++++++++++++++ .../ide/shared/workflow-command-generator.js | 14 ++++++++- 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 docs/pr-instructions-issue-872.md diff --git a/docs/pr-instructions-issue-872.md b/docs/pr-instructions-issue-872.md new file mode 100644 index 00000000..1ffc5645 --- /dev/null +++ b/docs/pr-instructions-issue-872.md @@ -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 don’t 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. diff --git a/test/test-installation-components.js b/test/test-installation-components.js index 464ca613..127dfdf4 100644 --- a/test/test-installation-components.js +++ b/test/test-installation-components.js @@ -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 // ============================================================ 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 fd7dde2e..3a643720 100644 --- a/tools/cli/installers/lib/ide/shared/workflow-command-generator.js +++ b/tools/cli/installers/lib/ide/shared/workflow-command-generator.js @@ -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;