Quick Summary
list_dir fails on Windows with invalid argument because platform-specific backslashes (\) are passed directly to Go's fs.FS/os.Root, which strictly requires forward slashes (/).
Environment & Tools
- PicoClaw Version: 0.2.6
- Go Version: 1.26
- AI Model & Provider: any
- Operating System: Windows 11
- Channels: WebUI
📸 Steps to Reproduce
- Configure Picoclaw with
restrict_to_workspace: true and a valid workspace directory.
- Call the
list_dir tool with a relative path containing a trailing slash: {"path": "src/Sources/"}.
- Observe the tool's response.
❌ Actual Behavior
Returns an invalid argument error. Directory listing fails completely, even though the path exists, is within the workspace, and works correctly via exec {"action":"run","command":"dir src\\Sources"}.
✅ Expected Behavior
Successfully returns the file/directory listing for src/Sources/ without errors, consistent with standard Windows path handling.
💬 Additional Context
Root Cause: filepath.Clean() and filepath.Rel() produce Windows backslashes (\). These are passed directly to fs.ReadDir(root.FS(), relPath) and root.Open(relPath). Go's fs.FS interface strictly expects forward slashes (/) on all platforms, causing invalid argument on Windows.
Proposed Fix (pkg/tools/filesystem.go):
Convert the relative path using filepath.ToSlash() before any fs.FS call:
// In sandboxFs.ReadDir & sandboxFs.Open
fsPath := filepath.ToSlash(relPath)
// Pass fsPath to fs.ReadDir(root.FS(), fsPath) and root.Open(fsPath)
Note: This forward/backslash separator mismatch likely affects other file operations (read_file, write_file, move_file, etc.) that rely on the same sandboxFs implementation. A broader review of all fs.FS/os.Root interactions across the codebase is recommended to prevent similar cross-platform edge cases.
Quick Summary
list_dirfails on Windows withinvalid argumentbecause platform-specific backslashes (\) are passed directly to Go'sfs.FS/os.Root, which strictly requires forward slashes (/).Environment & Tools
📸 Steps to Reproduce
restrict_to_workspace: trueand a valid workspace directory.list_dirtool with a relative path containing a trailing slash:{"path": "src/Sources/"}.❌ Actual Behavior
Returns an
invalid argumenterror. Directory listing fails completely, even though the path exists, is within the workspace, and works correctly viaexec {"action":"run","command":"dir src\\Sources"}.✅ Expected Behavior
Successfully returns the file/directory listing for
src/Sources/without errors, consistent with standard Windows path handling.💬 Additional Context
Root Cause:
filepath.Clean()andfilepath.Rel()produce Windows backslashes (\). These are passed directly tofs.ReadDir(root.FS(), relPath)androot.Open(relPath). Go'sfs.FSinterface strictly expects forward slashes (/) on all platforms, causinginvalid argumenton Windows.Proposed Fix (
pkg/tools/filesystem.go):Convert the relative path using
filepath.ToSlash()before anyfs.FScall:Note: This forward/backslash separator mismatch likely affects other file operations (read_file, write_file, move_file, etc.) that rely on the same sandboxFs implementation. A broader review of all fs.FS/os.Root interactions across the codebase is recommended to prevent similar cross-platform edge cases.