Skip to main content

Module file_ops

Module file_ops 

Source

Functions§

compute_edit_file_diff
Return a formatted diff string for an edit_file operation without applying it. Lines prefixed “- “ are removals, “+ “ are additions. Returns Err if the search string cannot be located (caller falls through to normal tool dispatch).
compute_msr_diff
Return a formatted diff string for a multi_search_replace operation without applying it.
compute_patch_hunk_diff
Return a formatted diff string for a patch_hunk operation without applying it.
compute_write_file_diff
Compute a preview diff for write_file — shows the full new content as additions, and any existing file content as removals. New files show only + lines.
create_directory
edit_file
grep_files
hematite_dir
Returns the directory where Hematite’s runtime state (.hematite/) should live.
inspect_lines
is_os_shortcut_directory
Returns true if path is a known OS shortcut directory (Desktop, Downloads, Documents, Pictures, Videos, Music). These directories should not accumulate .hematite/ workspace state — they use the global ~/.hematite/ instead.
is_project_workspace
Returns true if the workspace root looks like a real project. A bare .git alone (e.g. accidental git init in the home folder) doesn’t count — at least one explicit build/package marker must also be present.
list_files
multi_search_replace
open_in_system_editor
patch_hunk
pop_ghost_ledger
read_file
safe_write
Write content to path, refusing to follow a symlink. On platforms that support symlink detection, returns an error if path is already a symlink so malicious workspace symlinks cannot redirect writes to arbitrary files. Falls back to a plain fs::write on platforms or edge cases where symlink detection is unavailable.
tail_file
workspace_root
Resolve the workspace root by looking upward for common markers.
write_file