Skip to content

fix(mcp): normalize root-ish path filters in codegraph_files (#426)#466

Merged
colbymchenry merged 1 commit into
mainfrom
fix/issue-426-codegraph-files-path-normalization
May 26, 2026
Merged

fix(mcp): normalize root-ish path filters in codegraph_files (#426)#466
colbymchenry merged 1 commit into
mainfrom
fix/issue-426-codegraph-files-path-normalization

Conversation

@colbymchenry
Copy link
Copy Markdown
Owner

Summary

  • codegraph_files returned "No files found" whenever the agent passed path="/", ".", "./", "", "\\", or any leading-slash/.//Windows-backslash subpath — pushing it back to Read/Glob (exact opencode + Gemini Flash regression in have to explicitly ask it to check codegraph, otherwise no results #426).
  • Normalized the path filter (strip leading /, ./, \, bare .; convert \ to /; trim trailing /) and switched matching from raw startsWith to exact-equal or <filter>/ boundary — which also kills a sibling-prefix bleed (src used to match src-utils/...).
  • 13 new tests pinning every root-ish/leading-slash/Windows-backslash branch + the sibling-prefix regression.

Closes #426.

Test plan

  • npx vitest run __tests__/mcp-files-path-normalization.test.ts — 13/13 (macOS)
  • Full suite: npm test — 1000 passed / 2 skipped (macOS)
  • Linux (Docker, node:22-bookworm w/ --init): 28/28 across path-normalization + mcp-input-limits + concurrent-locking
  • Windows (Parallels VM): 28/28 across the same three test files, including treats path="/" as project root and normalizes Windows backslashes
  • End-to-end through opencode TUI (Big Pickle / OpenCode Zen) in tmux: codegraph_codegraph_files [path=/] now returns the project tree; agent answers from it without falling back to Read

🤖 Generated with Claude Code

The agent (opencode/Gemini Flash on Windows) called codegraph_files with
path="/" and got "No files found matching the criteria.", which pushed it
straight back to Read/Glob. Indexed file paths are stored as
project-relative POSIX (e.g. "src/foo.py"), and the old startsWith filter
matched nothing for any of the root-ish or platform-flavored shapes an
agent might guess: "/", ".", "./", "", "\\", leading-slash and
leading-./ subpaths, or Windows backslash subpaths.

Normalize the filter (strip leading "/", "./", "\", bare "."; convert
"\" to "/"; trim trailing "/"), then match by exact equal or "<filter>/"
boundary — which also kills a sibling-prefix bleed where filter "src"
used to match "src-utils/...".

Validated on macOS + Linux (Docker) + Windows (Parallels) with 13 new
unit tests plus the existing mcp-input-limits/concurrent-locking
suites, and end-to-end through opencode in tmux (Big Pickle/OpenCode
Zen): codegraph_files [path=/] now returns the project tree and the
agent answers directly instead of falling back to Read.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@colbymchenry colbymchenry merged commit e1eb13c into main May 26, 2026
@colbymchenry colbymchenry deleted the fix/issue-426-codegraph-files-path-normalization branch May 26, 2026 20:39
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.

have to explicitly ask it to check codegraph, otherwise no results

1 participant