Skip to content

feat: add cross-file reference validator to CI pipeline#1490

Closed
arcaven wants to merge 1 commit intobmad-code-org:mainfrom
arcaven:feat/validate-file-refs
Closed

feat: add cross-file reference validator to CI pipeline#1490
arcaven wants to merge 1 commit intobmad-code-org:mainfrom
arcaven:feat/validate-file-refs

Conversation

@arcaven
Copy link
Copy Markdown
Contributor

@arcaven arcaven commented Jan 31, 2026

What

Add tools/validate-file-refs.js — a CI validator that checks cross-file references in BMAD source files (agents, workflows, tasks, steps) and detects absolute path leaks.

Why

Analysis of all 422 closed issues shows broken file references and path handling account for 59 bugs (25% of all bugs) and 129+ maintainer/user comments. These two categories have zero existing automated prevention — no validator, no CI check, no pre-commit hook catches them today. When files are renamed, moved, or have extensions changed (e.g., .yaml.md migration), stale references are left behind and only discovered by users post-release.

On first run against the current main branch, the validator immediately finds 6 genuine broken references including wrong extensions (.yaml vs .md), missing files, and incorrect relative paths — confirming the ongoing need.

How

  • Scans src/ for YAML, markdown, and XML files (~212 files, ~480 references)
  • Validates {project-root}/_bmad/ references by mapping to source tree paths
  • Checks relative paths (./, ../), exec attributes, <invoke-task> tags, step metadata, and Load directives
  • Detects absolute path leaks (/Users/, /home/, C:\)
  • Adds validate:refs npm script and step in quality.yaml validate job
  • Self-contained: uses only node:fs, node:path, and yaml (existing dep)
  • Follows validate-doc-links.js scan→extract→resolve→report pattern

Testing

  • Runs cleanly via npm run validate:refs (currently finds 6 pre-existing broken refs on main)
  • All existing tests pass (test:schemas, test:install, validate:schemas, lint, format)
  • Verified broken ref detection by confirming each finding against the filesystem

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant