fix(core): render granular instruction updates - #42383
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Instruction changes now append only the affected file deltas instead of repeating every loaded
AGENTS.mdfile in full.For each modified file, OpenCode renders both a three-context unified diff and the complete new instructions, then uses whichever final message is shorter. Added and removed files use explicit messages.
Before / After
Before: Editing one line in one instruction file appended a complete replacement containing every global and project instruction file. The session learned the correct new state, but paid the token cost of unrelated unchanged files.
After: Unchanged files are omitted. A localized edit usually appends a small diff, while a rewrite or tiny file appends the complete new instructions when that is shorter. Additions and removals remain explicit.
How
packages/core/src/instruction-discovery.tscompares the previous and current file arrays by path.diffdependency to produce unified patches with three lines of context.packages/core/test/instruction-discovery.test.tscovers diff selection, replacement selection, and the real watcher-driven update/delete flow.Scope
This does not attempt to attribute file changes to the session that made them or suppress self-authored updates. Durable instruction state, chronological updates, and compaction behavior are unchanged.
Testing
bun run testinpackages/core: 1,709 passed, 16 skippedbun run test test/instruction-discovery.test.tsinpackages/core: 10 passedbun typecheckinpackages/corebunx prettier --check packages/core/src/instruction-discovery.ts packages/core/test/instruction-discovery.test.tsgit diff --checkFlow
flowchart LR A[Read instruction files] --> B[Compare with admitted values] B --> C{Change type} C -->|Modified| D[Render diff and replacement] D --> E[Append shorter message] C -->|Added| F[Append new instructions] C -->|Removed| G[Append removal notice] E --> H[Durable chronological update] F --> H G --> H