Improve context lookup for code-like source strings#451
Open
Lee-take wants to merge 3 commits into
Open
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.
Summary
deepseek-r1env_var_fornow outrank broader source-text matches, while generic lowercase words such asmessageare not over-boostedWhy
codegraph_contextcould miss important implementation code when the user query named a code-like string that appears only inside function bodies, provider aliases, feature flags, event names, or route keys. In that case the existing node-name FTS path may return generic symbols or nothing useful, even though the indexed source contains an exact match.This keeps the existing tool flow intact: agents still call
codegraph_context, but the context builder can use exact code-like source text as an additional high-signal entry point.Validation
npx vitest run __tests__/context.test.ts— 22 passednpm run build— passeddist/bin/codegraph.js: 7 function-specific context queries all ranked the expected function first:normalize_model_for_provider—crates/config/src/lib.rs:1189sanitize_thinking_mode_messages—crates/tui/src/client/chat.rs:1461active_provider_has_env_api_key—crates/tui/src/config.rs:3464env_for—crates/secrets/src/lib.rs:526provider_env_vars—crates/cli/src/lib.rs:761env_var_for—crates/tui/src/tui/provider_picker.rs:87requires_reasoning_content—crates/tui/src/client/chat.rs:1591npm test; local Windows run was blocked outside this change by MCP process tests failing to remove temp directories withEPERMplus a worker OOM after most tests had already passed.