file_read currently returns an error when given a directory path instead of gracefully falling back to dir_list behaviour. This forces callers to know in advance whether a path is a file or directory.
Current behaviour
file_read(path: "cmd") → error: "json: cannot unmarshal array into Go value of type gitea.FileContents"
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
Unmarshal response: try object first, fall back to array
If array: either return dir listing or return typed error (decide in PR)
Update file_read docstring to document behaviour
Add test case: call file_read on a directory path
Motivation
During 2026-05-14 session: called file_read(path: "cmd") on coo-agent, got cryptic unmarshal error. Required a separate dir_list call. Small friction, but repeated often during repo exploration.
## Summary
`file_read` currently returns an error when given a directory path instead of gracefully falling back to `dir_list` behaviour. This forces callers to know in advance whether a path is a file or directory.
## Current behaviour
```
file_read(path: "cmd") → error: "json: cannot unmarshal array into Go value of type gitea.FileContents"
```
## 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
- Unmarshal response: try object first, fall back to array
- If array: either return dir listing or return typed error (decide in PR)
- Update `file_read` docstring to document behaviour
- Add test case: call file_read on a directory path
## Motivation
During 2026-05-14 session: called `file_read(path: "cmd")` on `coo-agent`, got cryptic unmarshal error. Required a separate `dir_list` call. Small friction, but repeated often during repo exploration.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
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.