How It Works
The tracker records the state of each file after reading and verifies it before writing:Read (RecordRead)
After each successful
read operation, the tracker records:- mtime: file modification timestamp
- SHA-256: cryptographic hash of the complete content
- Size: size in bytes
- ReadAt: timestamp of when the read occurred
Verification (CheckStaleness)
Before each
write or patch operation, the tracker checks whether the file has changed.2-Step Verification
The verification uses an optimized strategy of fast path followed by full hash:- Step 1: mtime + size (fast)
- Step 2: SHA-256 (full)
First, the tracker compares the current
mtime and size with the recorded values. If both are identical, the file is not stale (immediate return, no additional I/O).Warning Message
When a stale file is detected, the system generates a formatted warning:- Re-read the file before making changes
- Understand that proceeding will overwrite the external changes
Covered Scenarios
| Scenario | Result | Description |
|---|---|---|
| File not modified | Not stale | mtime and size identical |
touch without editing | Not stale | mtime changes but SHA-256 identical |
| Real edit by user/IDE | Stale | mtime and hash different |
| File deleted | Stale | File no longer exists |
| File never read | Not stale | No record to compare against |
| Error during check | Not stale | Assumes not stale to avoid blocking |
Quote Normalization
ChatCLI also normalizes Unicode quotes in code files to prevent compilation errors caused by typographic quotes generated by LLMs:| Character | Description | Replacement |
|---|---|---|
' ' | Curly single quotes | ' |
" " | Curly double quotes | " |
' | Prime | ' |
" | Double prime | " |
<< >> | Angle quotes | << >> |
.go, .py, .js, .ts, .java, .rs, .sh, .sql, .json, .yaml, etc.) and to special file names (Makefile, Dockerfile, .gitignore, etc.).
Documentation files (
.md, .txt, .rst) are not normalized to preserve intentional typography.Tracking Lifecycle
Next Steps
Plugin @coder
Complete reference for read/write/patch operations.
Permissions
Permissions system that protects write operations.
JSON Recovery
How tool arguments are fixed before execution.
Coder Security
Path validation and security protections.