Skip to content

fix(core): normalize file paths in read tool output#7015

Open
scarf005 wants to merge 2 commits intoanomalyco:devfrom
scarf005:fix/normalize-read-tool-path
Open

fix(core): normalize file paths in read tool output#7015
scarf005 wants to merge 2 commits intoanomalyco:devfrom
scarf005:fix/normalize-read-tool-path

Conversation

@scarf005
Copy link
Contributor

@scarf005 scarf005 commented Jan 6, 2026

Closes #12394

Summary

  • Show clean relative paths for files inside the worktree
  • Show absolute paths for files outside the worktree instead of ugly ../../../../../../ paths

Changes

Modified the read tool to check if a file is within the worktree before deciding how to display the path:

  • Inside worktree: Show relative path (e.g., src/tool/read.ts)
  • Outside worktree: Show absolute path (e.g., /home/user/other/file.ts)

This improves UX by avoiding confusing paths like read ../../../../../../home/scarf/foo/bar/baz.ts.

Testing

Verified that lsp_diagnostics passes on the modified file.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

The following comment was made by an LLM, it may be inaccurate:

Duplicate PR Search Results

Good news! I found no duplicate PRs addressing the same issue.

The searches returned several related PRs dealing with file paths and permissions, but these are addressing different concerns:

PR #7015 appears to be unique in addressing the specific issue of normalizing file paths in read tool output to show clean relative paths for files inside the worktree and absolute paths for files outside it.

@aspiers
Copy link
Contributor

aspiers commented Jan 6, 2026

Great idea, this is a big improvement! 👍🏼

@scarf005 scarf005 force-pushed the fix/normalize-read-tool-path branch from d716ddc to 650077c Compare January 20, 2026 00:13
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@scarf005 scarf005 force-pushed the fix/normalize-read-tool-path branch from d12eb21 to 88ba7ab Compare February 15, 2026 17:19
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.

fix: normalize file paths in read tool output

2 participants