Skip to content

fix(compile): normalize absolute input paths in generate_header_comment#645

Merged
jamesadevine merged 2 commits into
mainfrom
copilot/normalize-source-path-absolute-inputs
May 19, 2026
Merged

fix(compile): normalize absolute input paths in generate_header_comment#645
jamesadevine merged 2 commits into
mainfrom
copilot/normalize-source-path-absolute-inputs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

Summary

When invoking ado-aw compile /absolute/path/to/agents/foo.md, the full absolute path was stored verbatim in the # @ado-aw source= header. This broke --source agents/foo.md filter matching and auto-discovery recompile, since neither could strip the absolute prefix to produce a match.

Root cause: generate_header_comment stripped leading ./ prefixes but never handled absolute paths.

Fix:

  • In generate_header_comment (src/compile/common.rs), if input_path is absolute, strip the current_dir() prefix via Path::strip_prefix before storing the source value. Falls back to the original path if it's not under CWD (unusual edge case).
# Before (absolute input):
# @ado-aw source="/home/user/repo/agents/foo.md" version=0.30.2

# After:
# @ado-aw source="agents/foo.md" version=0.30.2

Test plan

Two new unit tests in src/compile/common.rs:

  • test_generate_header_comment_absolute_path_under_cwdcwd/agents/my-agent.mdagents/my-agent.md
  • test_generate_header_comment_absolute_path_subdircwd/.azdo/pipelines/review.md.azdo/pipelines/review.md

All existing header comment tests continue to pass (cargo test test_generate_header_comment).

Copilot AI and others added 2 commits May 19, 2026 10:16
When users invoke `ado-aw compile /absolute/path/to/agents/foo.md`,
strip the current working directory prefix so the stored source in
the @ado-aw header is a relative path (e.g. `agents/foo.md`).

This ensures --source filters and auto-discovery recompile work
correctly regardless of how the compiler was invoked.

Also adds two new unit tests covering absolute paths under CWD.

Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/847594d9-3bf7-4873-b14c-e072979774b6

Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
@jamesadevine jamesadevine marked this pull request as ready for review May 19, 2026 10:21
@jamesadevine jamesadevine merged commit 7a0d268 into main May 19, 2026
@jamesadevine jamesadevine deleted the copilot/normalize-source-path-absolute-inputs branch May 19, 2026 10:25
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.

2 participants