You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Normalize relative working directories in glob searches - #1725
A glob search with cwd: "." reports zero files even when the project contains matches. Likewise, ./src and src/../src fail because the SDK compares the raw cwd with project-relative file paths.
Normalize cwd before filtering, treat the project-root dot path as the full project, and convert native path separators to the file tree's forward slashes. Returned paths and pattern matching retain their project-relative semantics.
One regression scans a real temporary project and checks the file sets for equivalent relative directories, including the host's native separator. On unmodified main (1279f1463) it fails with 0 files instead of 4; with the patch it passes.
Validation on Windows, Bun 1.3.14:
New regression and existing runtime glob handlers: 12 passed.
The 5 existing SDK glob fixture tests fail identically on unmodified main and the patched tree in this Windows environment.
SDK TypeScript, frozen-lockfile install, SDK build, Windows binary build, version and official smoke passed.
Prettier and diff checks passed; ESLint has 0 errors and 4 resolver-configuration warnings.
No authenticated model/TUI session or Linux/macOS build was run.
Good catch and a clean fix. The root bug is real: the old prefix-matching logic in glob.ts never special-cased cwd === '.' (so it filtered against './' and dropped every file), and it never normalized the cwd string, so ./src and src/../src didn't match the project-relative /-separated paths produced by flattenTree. Using path.normalize + converting path.sep to / + special-casing '.' as "no filter" is the right, small fix for this.
The new test in glob-cwd.test.ts is appropriately scoped — it builds a real temp project, writes nested files, and checks several equivalent relative cwd spellings including the native separator case (path.join('src','nested','..')). That's exactly the kind of regression coverage this fix needs, and the PR description is honest about pre-existing unrelated SDK fixture failures on your Windows environment (good diligence, not hiding anything).
Two things worth double-checking before this lands:
Behavior for an absolute cwd (outside the project root) isn't addressed — probably fine since that's out of scope for this bug, but worth a one-line comment confirming it's an explicit non-goal.
path.normalize uses the OS-native separator semantics; on Windows this correctly produces backslash-normalized paths before you convert to /, but it'd be good to confirm this behaves identically if cwd is ever constructed with mixed separators from a config file rather than a CLI arg.
Overall this is a focused, well-tested fix in the right file. Worth porting as-is, pending a maintainer glance at the absolute-path edge case.
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
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.
A glob search with
cwd: "."reports zero files even when the project contains matches. Likewise,./srcandsrc/../srcfail because the SDK compares the raw cwd with project-relative file paths.Normalize cwd before filtering, treat the project-root dot path as the full project, and convert native path separators to the file tree's forward slashes. Returned paths and pattern matching retain their project-relative semantics.
One regression scans a real temporary project and checks the file sets for equivalent relative directories, including the host's native separator. On unmodified main (
1279f1463) it fails with 0 files instead of 4; with the patch it passes.Validation on Windows, Bun 1.3.14:
No authenticated model/TUI session or Linux/macOS build was run.