feat(prime): wire IDE selection into loci context recall trigger#12
Merged
Conversation
Teach the agent to treat an active IDE editor selection as a deictic
anchor ("this / これ") for memory recall. The selection resolves *which*
symbol to look up; it does not by itself request a recall.
Recall fires only on the conjunction: a selection is active AND either
the user asks about the past or the agent's next action on the selected
code needs prior decisions. Guards against over-firing on edit-only
selections.
Selection -> query mapping: named symbol -> `loci context --symbol`;
mid-function fragment -> resolve enclosing symbol (LSP/read) first;
multi-symbol / non-symbol / empty result -> fall back to `loci search`.
Adds PRIME_TEXT contract tests for the new section.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The pre-commit hook (make check -> lint) hard-coded .venv/bin/ruff and failed in worktrees without a provisioned venv. Resolve ruff to the venv binary when present, otherwise `uvx ruff`, so lint/fmt work everywhere. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
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
Add a trigger to
loci prime's instruction text (PRIME_TEXT) so the agent treats an active IDE editor selection as a deictic anchor — the referent of "this / これ / この〜" — for past-conversation recall.Mechanism facts (researched):
UserPromptSubmitetc.) and is not queryable via MCP.⧉ Selected N lines from <file>).Trigger design (conjunction)
A selection only resolves which symbol is meant; it is not itself a recall request. Recall fires on the AND of:
It must NOT fire when the selection is present only because the user is about to edit it (over-fire guard).
Selection → query mapping
loci context --symbol "<name>"loci context --symbolloci search "<question>"Scope is staged: phase 1 ships the prime instruction only. A
loci context --filefilter to disambiguate common symbol names is deferred until noise is actually observed.Changes
src/codeatrium/cli/prime_cmd.py— add the "IDE selection as a deictic anchor" section to PRIME_TEXT.tests/test_prime_cmd.py— add 5 contract tests (TDD: Red → Green).Makefile— resolve ruff to the venv binary when present, otherwiseuvx ruff, forlint/fmt(fixes the pre-commit hook failing in worktrees without a provisioned venv).Verification
🤖 Generated with Claude Code