Add semantic project search quickfix command#12
Conversation
WalkthroughThis PR implements semantic project search for pi.nvim. It adds a dedicated search prompt format that instructs the model to return only quickfix-style file locations ( 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lua/pi/context.lua`:
- Line 116: The gsub call on cleaned_message uses the pattern "@?" which treats
? as a pattern quantifier; update the pattern to escape the question mark so it
matches the literal sequence by changing the call on cleaned_message (the gsub
invocation) to use "@%?" (e.g., cleaned_message = cleaned_message:gsub("@%?",
"") ) so both characters are matched literally.
- Line 114: The pattern check using cleaned_message:find("@?") treats '?' as a
pattern quantifier, so update the call to perform literal matching of the
sequence "@?" (either by using plain-text matching with the third-argument true
on the find call or by escaping the question mark in the pattern), replacing the
existing cleaned_message:find("@?") usage in the code around the cleaned_message
handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6fc55590-e4ed-4396-98c6-594de99a9c40
📒 Files selected for processing (6)
README.mdlua/pi/context.lualua/pi/init.lualua/pi/runner.luaplugin/pi.nvim.luatests/test_pi_commands.lua
| local cleaned_message = message | ||
|
|
||
| -- Check for @? directive | ||
| if cleaned_message:find("@?") then |
There was a problem hiding this comment.
Fix the pattern matching for the @? directive.
Line 114 uses find("@?") which treats ? as a Lua pattern quantifier (0 or 1 of previous char), not a literal character. This means it would match just @ alone, which is incorrect.
🔧 Proposed fix to use literal string matching
- if cleaned_message:find("@?") then
+ if cleaned_message:find("@?", 1, true) thenThe third parameter true enables plain text matching, treating ? as a literal character.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if cleaned_message:find("@?") then | |
| if cleaned_message:find("@?", 1, true) then |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@lua/pi/context.lua` at line 114, The pattern check using
cleaned_message:find("@?") treats '?' as a pattern quantifier, so update the
call to perform literal matching of the sequence "@?" (either by using
plain-text matching with the third-argument true on the find call or by escaping
the question mark in the pattern), replacing the existing
cleaned_message:find("@?") usage in the code around the cleaned_message
handling.
9abadcf to
e648a27
Compare
e648a27 to
b3bb88c
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
lua/pi/init.lua (1)
106-128: ⚖️ Poor tradeoffConsider a more robust parsing approach for the search result format.
The pattern
^(.-):(%d+):(.+)$uses non-greedy matching from the start, which is fragile for filenames that might contain colons. While the documented format is/absolute/path/to/file:lnum:col,line_count,notesand the AI is instructed to output this specific format, a more robust approach would match from the right to find the last:digits:occurrence. This would be safer for edge cases and makes the intent clearer.For example, instead of
^(.-):(%d+):(.+)$, consider matching backwards or using a pattern that explicitly handles the expected format more defensively (e.g.,(.+):(%d+):(%d+,.*)$).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/pi/init.lua` around lines 106 - 128, The current parse_search_line uses a non-greedy filename pattern which breaks when filenames contain colons; update parse_search_line to locate the lnum/col section from the right by changing the filename/line split to a greedy filename match (e.g., use "^(.*):(%d+):(.+)$" instead of "^(.-):(%d+):(.+)$") so the last ":<digits>:" is used as the separator, keep the subsequent parsing of rest (col,line_count,notes) as-is (the local function parse_search_line and its call to normalize_search_line are the loci to change) to ensure filenames with colons are handled robustly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@lua/pi/init.lua`:
- Around line 106-128: The current parse_search_line uses a non-greedy filename
pattern which breaks when filenames contain colons; update parse_search_line to
locate the lnum/col section from the right by changing the filename/line split
to a greedy filename match (e.g., use "^(.*):(%d+):(.+)$" instead of
"^(.-):(%d+):(.+)$") so the last ":<digits>:" is used as the separator, keep the
subsequent parsing of rest (col,line_count,notes) as-is (the local function
parse_search_line and its call to normalize_search_line are the loci to change)
to ensure filenames with colons are handled robustly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2edabedd-d52e-429d-b6c0-5e9c66f6c75a
📒 Files selected for processing (5)
README.mdlua/pi/context.lualua/pi/init.luaplugin/pi.nvim.luatests/test_pi_commands.lua
✅ Files skipped from review due to trivial changes (2)
- plugin/pi.nvim.lua
- README.md
🚧 Files skipped from review as they are similar to previous changes (1)
- tests/test_pi_commands.lua
|
Closing in favor of a smaller core abstraction PR that lets downstream configs/plugins implement workflows like semantic search without adding them to pi.nvim core. |
Summary
Adds a semantic project search workflow to pi.nvim:
:PiSearchcommand andrequire("pi").search()Lua API:copenCloses #11
Testing
make testSummary by CodeRabbit
New Features
:PiSearchcommand or<leader>askeymap.Documentation