Refuse to read a large file#2161
Closed
hujianxin wants to merge 1 commit into
Closed
Conversation
Author
|
To be honest, I'm not good at TS. I just modified the program according to my own understanding and tested it in a 2 million line C++ project of mine. After the modification, the performance is much better than before, which allows OpenCode to successfully complete a feature development. If there are any problems with the code I wrote (such as concurrency issues, style issues, etc.), please give me some suggestions, or directly modify the code. |
Author
|
IF you got a better about it, free to close |
Author
|
I modified the pr, simplified the code, and made the logic of reading large files more consistent with Claude code. This helps force OpenCode to make smarter choices when reading large files. @thdxr |
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.
• New file added: packages/opencode/src/file/context.ts - Implements file context tracking for sessions
• Modified: packages/opencode/src/tool/grep.ts - Added file context recording for grep operations
• Modified: packages/opencode/src/tool/read.ts - Added file size checking with context-aware logic and recording reads
These changes implement a file context tracking system that:
This is a feature enhancement that adds smarter file handling with size limitations based on context.
This small change can significantly improve the performance of opencode in large files (large projects), and will force opencode to use the grep tool instead of reading files mindlessly.