Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AtomicWriteFile ¶ added in v1.1.45
AtomicWriteFile writes data to path via a temp file in the same directory, fsync's it, and renames it into place. If path already exists, the existing file's mode is preserved; otherwise defaultMode is used.
This avoids two failure modes of os.WriteFile(path, data, mode):
- A crash between O_TRUNC and the final write leaves the user's source file truncated/empty.
- The hard-coded mode silently downgrades 0755 scripts and 0600 secrets to 0644.
See locks.md S4.
func FormatToolDetail ¶ added in v1.1.91
FormatToolDetail prepares a tool detail string for display. It relativizes absolute paths under baseDir. No truncation — the rendering layer handles width (TUI auto-wraps, IM sends as-is).
func RelativizePaths ¶ added in v1.1.34
RelativizePaths replaces absolute paths under baseDir with relative paths ("./"). It handles two cases:
- baseDir + separator + suffix → "./" + suffix
- baseDir as an exact standalone token → "."
The second case uses boundary checking to avoid false matches (e.g. "/Users/proj" should not match inside "/Users/proj-backup").