fix(hooks): use path.isAbsolute() for cross-platform path detection on Windows#1549
Open
MoerAI wants to merge 1 commit intocode-yeongyu:devfrom
Open
fix(hooks): use path.isAbsolute() for cross-platform path detection on Windows#1549MoerAI wants to merge 1 commit intocode-yeongyu:devfrom
MoerAI wants to merge 1 commit intocode-yeongyu:devfrom
Conversation
Replace path.startsWith('/') with path.isAbsolute() in directory
injector hooks. The startsWith('/') check only works on Unix-like
systems where absolute paths begin with '/'. On Windows, absolute
paths start with drive letters (e.g., C:\), causing resolveFilePath
to incorrectly treat them as relative and prepend the project
directory.
This follows the same pattern already used in
src/features/claude-tasks/storage.ts (commit 8e349aa).
Affected hooks:
- directory-agents-injector: AGENTS.md injection
- directory-readme-injector: README.md injection
93b4b27 to
c298351
Compare
Author
|
Rebased onto latest Updated changes:
|
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.
Summary
path.startsWith('/')withpath.isAbsolute()in directory injector hooks for proper Windows path supportProblem
resolveFilePath()in bothdirectory-agents-injectoranddirectory-readme-injectorusespath.startsWith('/')to detect absolute paths. This only works on Unix-like systems where absolute paths begin with/.On Windows, absolute paths start with drive letters (e.g.,
C:\Users\...), so the check fails and the function incorrectly treats them as relative paths, prependingctx.directory.Fix
Use Node.js built-in
path.isAbsolute()which correctly handles both Unix (/path) and Windows (C:\path,\server\share) absolute path formats.This follows the same pattern already used in
src/features/claude-tasks/storage.ts(commit 8e349aa).Changes (2 files)
src/hooks/directory-agents-injector/index.tspath.startsWith('/') → isAbsolute(path)src/hooks/directory-readme-injector/index.tspath.startsWith('/') → isAbsolute(path)Summary by cubic
Use Node’s path.isAbsolute() in the directory-agents-injector and directory-readme-injector finders to correctly detect absolute paths on all platforms, fixing Windows path resolution for AGENTS.md and README.md injection.
Written for commit c298351. Summary will update on new commits.