FileSystem Abstraction
Codebuff uses a standardizedCodebuffFileSystem interface compatible with Node.js fs.promises:
- Compatibility: Works with standard Node.js filesystem
- Testability: Easy to mock for testing
- Security: Controlled access patterns
- Portability: Can be swapped for different backends
Working Directory
All file operations are scoped to a working directory (project root):Path Resolution
All paths are resolved relative to the working directory:Reading Files
Agents read files using theread tool, which uses getFiles under the hood.
File Reading Implementation
File Size Limits
Maximum file size: 1MB (1024 * 1024 bytes) Files larger than this are not read, and return a status message:File Filtering
Codebuff automatically filters files based on gitignore rules:Custom File Filters
getFiles:
Writing Files
Agents write files using theedit tool (for modifications) or str_replace (for patches).
Change File Implementation
Path Traversal Protection
Applying Changes
Listing Directories
Thelist_directory tool enumerates files and directories:
Security Considerations
Path Safety
- Relative path normalization: Converts absolute paths to relative
- Boundary checking: Ensures paths stay within project root
- Traversal prevention: Blocks
..sequences that escape root
File Access Controls
- Gitignore enforcement: Respects
.gitignorepatterns - Size limits: Prevents reading very large files
- Error handling: Gracefully handles permission errors
Directory Creation
Directories are created recursively when needed:Testing with Mock FileSystem
Codebuff provides mock filesystem utilities for testing:Next Steps
- Learn about Error Handling
- Explore Tool System
- See Custom Tools for advanced tool creation

