opencode icon indicating copy to clipboard operation
opencode copied to clipboard

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

Open scarf005 opened this issue 1 week ago • 2 comments

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.

scarf005 avatar Jan 06 '26 01:01 scarf005