fix(rules): Resolve relative @ includes against source file directory#3116
Open
toniher wants to merge 6 commits into
Open
fix(rules): Resolve relative @ includes against source file directory#3116toniher wants to merge 6 commits into
toniher wants to merge 6 commits into
Conversation
Add logic to both claude and cli parsers to resolve relative @include paths against the directory of the source file rather than the current working directory. This allows includes to work correctly when the source file is located outside the cwd. Includes absolute paths (starting with / or ~) and cases where source_dir cannot be determined are left unchanged. Add corresponding test cases for both parsers.
olimorris
requested changes
May 17, 2026
Owner
There was a problem hiding this comment.
against the directory of the source file rather than the current working directory
Looking at the code, is this actually the case? It reads like it tries the source file dir and then tries the cwd? Otherwise, this is potentially a breaking change for users.
Owner
|
But absolutely solid addition to the plugin and one that I should have in from the start. We should also update the configuration page for rules to clarify how the file resolution works. |
The relative @include resolution logic has been moved to the Claude parser and abstracted into a reusable `files.exists()` utility function. The CLI parser no longer needs this functionality, so remove the unused code and its associated test file.
Update the comment to more precisely describe the path resolution logic, clarifying that non-absolute paths (those without leading / or ~) are resolved against the source file's directory.
The rules file now documents that an INSTRUCTIONS.md file in the same directory is automatically included in the chat buffer context, without requiring a './' prefix.
Contributor
Author
|
This should be addressed! More clarity and a bit of documentation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add logic to both claude and cli parsers to resolve relative @ include paths against the directory of the source file rather than the current working directory. This allows includes to work correctly when the source file is located outside the
cwd. Includes absolute paths (starting with / or ~) and cases where source_dir cannot be determined are left unchanged. Add corresponding test cases for both parsers.Coming from discussion here: #2688 (reply in thread)
AI Usage
Claude Code with Sonnet 4.7
Prompt:
...
Checklist
make allto ensure docs are generated, tests pass and StyLua has formatted the code