TypeScript interface
Log files can use
.md, .txt, or .log extensions. All paths must be absolute and must not contain path traversal sequences (..).append_to_file
Appends content to the specified file. If the file does not exist it is created. If the parent directory does not exist, it is created recursively. The frontend is responsible for formatting the timestamp and bullet prefix before calling this command.
Parameters
Absolute path to the log file. Must use a
.md, .txt, or .log extension. The file and any missing parent directories are created automatically.The full line to append, including any timestamp or bullet formatting. A newline is added automatically after the content.
Returns
Promise<void>
Error codes
The command rejects with a string error code prefix on failure:| Error code | Meaning |
|---|---|
INVALID_PATH | Path is not absolute or contains traversal sequences |
INVALID_EXTENSION | File extension is not .md, .txt, or .log |
PERMISSION_DENIED | Cannot write to the file |
DISK_FULL | Insufficient disk space |
FILE_LOCKED | File is in use by another process (Windows) |
IO_ERROR | Other I/O failure |
validate_log_path
Validates a file path before using it as a log destination. Use this to give the user immediate feedback when they type a path in the settings UI.
Parameters
The absolute file path to validate. Must use a
.md, .txt, or .log extension.Returns
Promise<PathValidation>
true if the path can be used as a log file destination.true if a file already exists at this path.true if the parent directory exists. If false, append_to_file will attempt to create it.true if the file or parent directory is writable by the current user.A human-readable explanation of why the path is not writable, or
null if it is valid.Validation checks
- Path must be absolute (no relative paths).
- Path must not contain traversal sequences (
..,./,.\\). - File extension must be
.md,.txt, or.log. - The file or parent directory must be writable (if parent does not exist, it is assumed creatable).
get_default_log_directory
Returns the default directory where Trueears stores log files. Use this to pre-fill the path input in the settings UI.
Returns
Promise<string> — An absolute path to the default log directory (<Documents>/Trueears). The directory may not exist yet — it is created when the first log entry is appended.
open_log_file
Opens the specified log file using the default application associated with its extension on the user’s system.
Parameters
Absolute path to the file to open. The file must already exist.
Returns
Promise<void> — Rejects with FILE_NOT_FOUND if the file does not exist, or OPEN_FAILED if the OS fails to open it.
