[PR #6581] feat: add OPENCODE_DISABLE_FILETIME_CHECK flag #11984

Closed
opened 2026-02-16 18:16:55 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6581

State: closed
Merged: Yes


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_CHECK constant in packages/opencode/src/flag/flag.ts
  • Modified FileTime.assert() in packages/opencode/src/file/time.ts to 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

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6581 **State:** closed **Merged:** Yes --- ## 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_CHECK` constant in `packages/opencode/src/flag/flag.ts` - Modified `FileTime.assert()` in `packages/opencode/src/file/time.ts` to 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
yindo added the pull-request label 2026-02-16 18:16:55 -05:00
yindo closed this issue 2026-02-16 18:16:55 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11984