opencode
opencode copied to clipboard
feat: add OPENCODE_DISABLE_FILETIME_CHECK flag
Summary
Adds a new environment variable OPENCODE_DISABLE_FILETIME_CHECK that allows users to skip the FileTime verification check before editing files.
Problem
Currently, OpenCode enforces that files must be read before editing, tracked by timestamps. This causes issues:
- Time precision errors cause false positives when file wasn't actually modified
- AI must re-read files that are already in context, wasting tokens
- Users report 0.2s between read and edit still triggers error
Solution
Added OPENCODE_DISABLE_FILETIME_CHECK flag that:
- When set to
true: Skips all FileTime checks, allowing edits without re-reading - When not set or set to
false: Maintains existing default behavior for safety
Changes
- Added
OPENCODE_DISABLE_FILETIME_CHECKconstant inpackages/opencode/src/flag/flag.ts - Modified
FileTime.assert()inpackages/opencode/src/file/time.tsto check flag - Added comprehensive tests in
packages/opencode/test/file/time-flag.test.ts
Testing
All tests pass:
- ✅ Flag enabled: FileTime check is skipped
- ✅ Flag disabled: FileTime check is enforced
- ✅ Default behavior: Read then assert works correctly
Usage
```bash
Temporary (single command)
OPENCODE_DISABLE_FILETIME_CHECK=true bun dev
Permanent (add to ~/.bashrc or ~/.zshrc)
export OPENCODE_DISABLE_FILETIME_CHECK=true ```
Trade-offs
This is a convenience vs safety trade-off:
- Benefit: Eliminates token waste and unnecessary re-reads when context is available
- Risk: Files modified externally won't trigger a warning, potentially missing external changes
Users who are confident in their workflow can enable this flag for better experience.
Closes #4406