opencode
opencode copied to clipboard
fix(core): normalize file paths in read tool output
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.