OLLMfiles
Description:
File and project management namespace.
The OLLMfiles namespace provides file and project management functionality without GTK/git dependencies. This allows the core file system
operations to be used in both GUI and non-GUI contexts.
Core Components
Buffer System
The buffer system provides a unified interface for accessing file contents, whether in GUI contexts (using GTK SourceView buffers) or non
-GUI contexts (using in-memory buffers).
- FileBuffer: Interface for file buffer operations
- DummyFileBuffer: In-memory buffer implementation for non-GTK contexts
- BufferProviderBase: Base implementation for non-GTK contexts
File System
- FileBase: Base class for File and Folder objects
- File: Represents a file in the project
- Folder: Represents a folder/directory in the project
- FileAlias: Represents an alias/symlink to a file or folder
Sandbox
- Sandbox: Bubblewrap overlay + seccomp for isolated command execution (OLLMfiles.Sandbox)
Project Management
- ProjectManager: Manages projects, files, and folders
- ProjectList: Manages list of projects
- ProjectFiles: Manages files within a project
- ProjectFile: Represents a file within a project context
Architecture Benefits
- Unified Interface: Same API for GTK and non-GTK contexts
- Type Safety: No set_data/get_data - buffers are properly typed
- Separation of Concerns: GUI code in liboccoder, non-GUI code in libocfiles
- Memory Management: Automatic cleanup of old buffers
- File Tracking: Automatic last_viewed timestamp updates
- Backup System: Automatic backups for database files
Usage Examples
Reading a File
file.manager.buffer_provider.create_buffer(file);
var contents = yield file.buffer.read_async();
// Or use convenience method
var contents2 = file.contents();
Reading Line Range
// User provides 1-based line numbers: lines 10-20
int start = 10 - 1; // Convert to 0-based: 9
int end = 20 - 1; // Convert to 0-based: 19
file.manager.buffer_provider.create_buffer(file);
if (!file.buffer.is_loaded) {
yield file.buffer.read_async();
}
// Get line range
var snippet = file.buffer.get_text(start, end);
Writing a File
file.manager.buffer_provider.create_buffer(file);
yield file.buffer.write(new_contents);
Best Practices
- Create Buffer First: Call create_buffer() before using buffer methods (no null check needed)
2. Load Before Access: Ensure buffer is loaded (is_loaded == true) before using get_text() or get_line()
3. Use read_async() First: Call read_async() before accessing buffer contents to ensure data is current
4. Handle Errors: Always wrap buffer operations in try-catch blocks
5. Convert Line Numbers: Remember to convert between 1-based (user input) and 0-based (buffer API)
6. Sort Edits: When using apply_edits(), sort changes descending by start line
7. Buffer Cleanup: Don't manually set file.buffer = null unless necessary (cleanup is automatic)
Content:
Namespaces:
Interfaces:
- Copyable - GObject types that copy writable
properties from another instance.
- FileBuffer - Interface for file buffer
operations.
Classes:
- BufferProviderBase - Base implementation
for non-GTK contexts.
- DeleteManager - Client entry point for file
deletion — delegates to File.delete RPC.
- DummyFileBuffer - In-memory buffer
implementation for non-GTK contexts (tools, CLI).
- File - Represents a file in the project.
- FileAlias - Represents a symlink/alias to a file or
folder.
- FileBase - Abstract base class providing
common properties and methods for files and folders.
- FileChange - Represents a single edit operation
with range and replacement.
- FileHistory - V2 approve/revert RPC handle (
file_history.id
+ path).
- FileWithHistory - Pending-approval list row (
FileWithHistory
wire). Popover display fields copied from FileBase — not a tree node.
- Folder - Represents a directory/folder in the project.
- FolderFiles - Manages immediate children of one
Folder (flat list for tree UI).
- GitProviderBase - Base class for git
operations with default no-op implementations.
- ProjectFile - Display wrapper for one
File row in ProjectFiles.
- ProjectFiles - V2 client flat file list for one
project (GLib.ListModel).
- ProjectList - V2 client project list —
GLib.ListModel over known project rows.
- ProjectManager - V2 client
ProjectManager — RPC to
ollmfilesd
, local UI state only.
- ReviewFiles - Manages files in a project that
need approval (flat list for approvals UI).
- Tree - Tree-sitter AST path lookup (V2 thin client).
- TreeBase - Base class for tree-sitter AST
parsing (V2 thin client).
Enums: