fix: file_read should handle directory paths gracefully #15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
file_readcurrently returns an error when given a directory path instead of gracefully falling back todir_listbehaviour. This forces callers to know in advance whether a path is a file or directory.Current behaviour
Expected behaviour
Option A (preferred): if path is a directory, return directory listing (same format as
dir_list).Option B: return a clear error message:
"path 'cmd' is a directory — use dir_list instead".Gitea API
GET /api/v1/repos/{owner}/{repo}/contents/{filepath}returns array for dirs, object for files — already detectable from response type.Required token permission
No new permissions —
read:repository, same as current.Risk classification
LOW — read-only, UX improvement only.
Implementation notes
file_readdocstring to document behaviourMotivation
During 2026-05-14 session: called
file_read(path: "cmd")oncoo-agent, got cryptic unmarshal error. Required a separatedir_listcall. Small friction, but repeated often during repo exploration.Shipped in v0.2.3. Closing during cleanup pass.