Skip to content

fix(hooks): use path.isAbsolute() for cross-platform path detection on Windows#1549

Open
MoerAI wants to merge 1 commit intocode-yeongyu:devfrom
MoerAI:fix/windows-path-absolute-check
Open

fix(hooks): use path.isAbsolute() for cross-platform path detection on Windows#1549
MoerAI wants to merge 1 commit intocode-yeongyu:devfrom
MoerAI:fix/windows-path-absolute-check

Conversation

@MoerAI
Copy link

@MoerAI MoerAI commented Feb 6, 2026

Summary

  • Replace path.startsWith('/') with path.isAbsolute() in directory injector hooks for proper Windows path support

Problem

resolveFilePath() in both directory-agents-injector and directory-readme-injector uses path.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, prepending ctx.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)

File Change
src/hooks/directory-agents-injector/index.ts path.startsWith('/') → isAbsolute(path)
src/hooks/directory-readme-injector/index.ts path.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.

  • Bug Fixes
    • Windows absolute paths (e.g., C:..., \server\share) are no longer treated as relative or prefixed with the project directory.

Written for commit c298351. Summary will update on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

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
@MoerAI MoerAI force-pushed the fix/windows-path-absolute-check branch from 93b4b27 to c298351 Compare February 11, 2026 10:30
@MoerAI
Copy link
Author

MoerAI commented Feb 11, 2026

Rebased onto latest dev. After rebase, the fix targets finder.ts instead of index.ts since resolveFilePath() was refactored into separate files upstream.

Updated changes:

File Change
src/hooks/directory-agents-injector/finder.ts path.startsWith('/') → isAbsolute(path)
src/hooks/directory-readme-injector/finder.ts path.startsWith('/') → isAbsolute(path)

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.

1 participant