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 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.
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.
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.
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.