fix(core): match rule globs against file paths containing spaces - #13170
Open
santhiprakash wants to merge 1 commit into
Open
fix(core): match rule globs against file paths containing spaces#13170santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
Rule globs like `docs/**/*.md` or the exact glob `docs/foo bar.md` silently failed to match files whose names contain spaces, so any rule whose target files lived under `docs/foo bar.md` was excluded from the system prompt. The root cause is in extractPathsFromCodeBlocks: its filename regex excluded whitespace, so a code block header like ```typescript docs/foo bar.md` was truncated to just `bar.md`. Replace the regex with a small parser that strips the optional language tag and trailing line range but preserves any spaces inside the path. Fixes continuedev#13135
Open
3 tasks
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
Rule globs like
docs/**/*.mdor the exact globdocs/foo bar.mdsilently failed to match files whose names contain spaces, so any rule whose target files lived under e.g.docs/foo bar.mdwas excluded from the system prompt.Root cause
core/llm/utils/extractPathsFromCodeBlocks.tsused the regex/([^\s()]+.[a-zA-Z0-9]+)/to pull a filename out of a code-block header. The character class[^\s()]excluded whitespace, so a header liketypescript docs/foo bar.mdwas truncated to justbar.md. The downstream rule matcher never saw the directory portion, so neither the broad glob (docs/**/*.md) nor the exact glob (docs/foo bar.md) could match.Fix
Replace the regex with a small parser that strips the optional
<lang>tag and the optional trailing(<start>-<end>)line range but preserves any spaces inside the path itself. The heuristic for identifying a language tag is that it must be a single token containing no/or\(paths almost always contain a separator; language tags liketypescript,md,pynever do).Tests
core/llm/utils/extractPathsFromCodeBlocks.vitest.tscovers paths with spaces (with and without language tag, with and without line range, in nested directories).core/llm/rules/getSystemMessageWithRules.vitest.tsverifies thatdocs/**/*.mdand the exact globdocs/foo bar.mdboth apply to a file referenced in a code block.core/llm/utils/extractPathsFromCodeBlocks.test.tswith the same regression cases.Fixes #13135
Checklist
Screen recording or screenshot
N/A — backend correctness fix, no UI surface change.
Tests
core/llm/utils/extractPathsFromCodeBlocks.vitest.ts(new, 9 tests)core/llm/rules/getSystemMessageWithRules.vitest.ts(2 new tests added)core/llm/utils/extractPathsFromCodeBlocks.test.ts(regression case added)All pass locally via
node_modules/.bin/vitest runincore/. Verified by reverting the fix and re-running: the new regression tests fail on the original code and pass with the fix in place.