-
Notifications
You must be signed in to change notification settings - Fork 34
refactor(code-references): remove reliance on system prompt #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- update the reference parser to be more generic instead of relying on a system prompt - add edit/read files to the references This should fix #194
|
@aweis89 I refactored the references collection to not rely on a system prompt, and prefer parsing common file patterns. Let me know if this works as you expect. |
7c26716 to
d4519b7
Compare
- Update formatter to show relative paths when inside cwd, basename when outside - Normalize file paths in replay test snapshots to be cwd-relative - Update expected test data to use relative paths instead of absolute paths
d4519b7 to
585e05b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors the code reference detection system to work generically without relying on system prompts, making it compatible with all LLM providers including those without system prompt support. It also adds support for detecting file references from tool operations (read/edit).
Changes:
- Refactored reference parser to support multiple patterns (backtick-wrapped, file:// URIs, plain paths) with deduplication logic
- Removed system prompt instructions from core.lua that were previously guiding LLMs to use file:// URIs
- Added file path normalization in formatter to show relative paths within project
- Enhanced test infrastructure with getcwd mocking and file path normalization utilities
- Updated documentation to reflect new reference detection formats
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| lua/opencode/ui/reference_picker.lua | Major refactoring: added multiple parsing strategies, deduplication, and tool-based reference extraction |
| lua/opencode/ui/formatter.lua | Modified file path display logic to show relative paths for files within project |
| lua/opencode/core.lua | Removed system prompt instructions for file:// URI format |
| AGENTS.md | Added comprehensive documentation on supported file reference formats |
| tests/manual/renderer_replay.lua | Added normalize_file_paths helper and simplified load_events to use raw file paths |
| tests/helpers.lua | Added MOCK_CWD constant and mock_getcwd function for consistent test paths |
| tests/data/*.expected.json | Updated test snapshots with normalized timestamps and field ordering |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
False Positive ConcernsThanks for this refactor! Removing the system prompt dependency improves provider compatibility. However, I have concerns about false positives with the more permissive patterns: Potential False Positives1. Plain path pattern is very broad
2. Backtick pattern too greedy
3. Email addresses SuggestionWithout the explicit Consider whether the added complexity and edge cases are worth it vs. keeping the The tool part extraction (filePath from read/edit tools) is a nice addition regardless! |
Thanks for the comments, I understand your issue with false positives. and Will try to work on a better parsing solution. The file_exists is a fail safe on his own for most of the matches so I'm not to worry. The issue I have with only the file:// is staht it's to restrictive and requires a system prompt, and even with the system prompt it misses a lot of paths. I will also ad as part of this MR a config for specifying a system prompt |
f23728e to
db7006b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 22 out of 23 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
af8982c to
ff8f103
Compare
|
I did add more checks around urls, and better patterns to avoid false positives. I also added a system prompt config. I will merge this MR as it is right now and we can always update this later on if we see perf issues. I did some profiling on large outputs and it didn't impact the performance. |
This should fix #194