opencode
opencode copied to clipboard
feat: add user diff tracking to show external file changes between generations
Summary
This PR implements a "user diff" feature that tracks and displays external file changes made by users between AI generations. When a user modifies files outside of OpenCode and submits a new prompt, the system now shows what changed.
- Captures a snapshot at the end of each successful AI generation
- Computes diff against the snapshot when a new prompt is submitted
- Shows changes in the TUI with file status indicators (A/M/D)
- Injects diff context into the conversation for the AI to understand
- Includes protections against context overload (max 50 files, 10k chars)
- Ignores common non-essential files (node_modules, dist, lock files, etc.)
Changes
- Added
lastGenerationSnapshotfield to Session schema - Created new
UserDiffPartmessage part type - New
user-diff.tsmodule for diff computation and formatting - Modified
SessionProcessorto capture snapshots at end of generation - Modified
SessionPromptto compute and inject user diffs - Added TUI rendering for user diff display
- Regenerated SDK types
Design Doc
See specs/user-diff.md for the full design specification.
this is a POC do not merge