BMAD-METHOD/tools
Michael Pursifull ba890779a2
feat: cross-file reference validator for BMAD source files (#1494)
* feat: add cross-file reference validator for CI

Add tools/validate-file-refs.js that validates cross-file references
in BMAD source files (agents, workflows, tasks, steps). Catches broken
file paths, missing referenced files, wrong extensions, and absolute
path leaks before they reach users.

Addresses broken-file-ref and path-handling bug classes which account
for 25% of all historical bugs (59 closed issues, 129+ comments).

- Scans src/ for YAML, markdown, and XML files
- Validates {project-root}/_bmad/ references against source tree
- Checks relative path references, exec attributes, invoke-task tags
- Detects absolute path leaks (/Users/, /home/, C:\)
- Adds validate:refs npm script and CI step in quality.yaml

* feat: strip JSON example blocks to reduce false-positive broken refs

Add stripJsonExampleBlocks() to the markdown reference extractor so
bare JSON example/template blocks (braces on their own lines) are
removed before pattern matching. This prevents paths inside example
data from being flagged as broken references.

* feat: add line numbers, fix utility/ path mapping, improve verbose output

- Add utility/ to direct path mapping (was incorrectly falling through
  to src/modules/utility/)
- Show line numbers for broken references in markdown files
- Show YAML key path for broken references in YAML files
- Print file headers in verbose mode for all files with refs

* fix: correct verbose [OK]/[BROKEN] overlap and line number drift

Broken refs no longer print [OK] before [BROKEN] in --verbose mode.
Code block stripping now preserves newlines so offsetToLine() reports
accurate line numbers when code blocks precede broken references.

* fix: address review feedback, add CI annotations and step summary

Address alexeyv's review findings on PR #1494:
- Fix exec-attr prefix handling for {_bmad}/ and bare _bmad/ paths
- Fix mapInstalledToSource fallback (remove phantom src/modules/ mapping)
- Switch extractYamlRefs to parseDocument() for YAML line numbers

Add CI integration (stories 2-1, 2-2):
- Emit ::warning annotations for broken refs and abs-path leaks
- Write markdown table to $GITHUB_STEP_SUMMARY
- Guard both behind environment variable checks

Harden CI output:
- escapeAnnotation() encodes %, \r, \n per GitHub Actions spec
- escapeTableCell() escapes pipe chars in step summary table

---------

Co-authored-by: Alex Verkhovsky <alexey.verkhovsky@gmail.com>
Co-authored-by: Brian <bmadcode@gmail.com>
2026-02-03 13:13:38 -06:00
..
cli fix: add disable-model-invocation to all generated slash commands (#1501) 2026-01-31 17:25:31 -06:00
docs docs: radical reduction of documentation scope for v6 beta (#1406) 2026-01-25 14:00:26 -06:00
flattener feat: add documentation website with Docusaurus build pipeline (#1177) 2025-12-23 23:01:36 +08:00
lib feat: add documentation website with Docusaurus build pipeline (#1177) 2025-12-23 23:01:36 +08:00
maintainer feat: add Raven's Verdict PR review tool (#1054) 2025-12-07 14:13:33 -06:00
schema Project Cleanup of Agents Menus, BMB module removal to other repo 2026-01-19 02:04:14 -06:00
bmad-npx-wrapper.js fix: preserve user's cwd when running via npx 2025-10-29 09:31:38 -05:00
build-docs.js docs: named TEA links consistently (#1337) 2026-01-15 18:01:37 -06:00
fix-doc-links.js Add link auditor, reorganize documentation, and README update (#1277) 2026-01-10 02:55:33 +08:00
format-workflow-md.js check alignment 2025-10-22 12:36:39 -05:00
migrate-custom-module-paths.js _cfg -> _config 2025-12-13 19:41:09 +08:00
platform-codes.yaml docs: radical reduction of documentation scope for v6 beta (#1406) 2026-01-25 14:00:26 -06:00
validate-agent-schema.js fix agent scan and help csv files 2026-01-31 21:58:55 -06:00
validate-doc-links.js docs: radical reduction of documentation scope for v6 beta (#1406) 2026-01-25 14:00:26 -06:00
validate-file-refs.js feat: cross-file reference validator for BMAD source files (#1494) 2026-02-03 13:13:38 -06:00
validate-svg-changes.sh Project Cleanup of Agents Menus, BMB module removal to other repo 2026-01-19 02:04:14 -06:00