Skip to content

Commit 531ddab

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 585ef6c + 5fc0e2e commit 531ddab

3 files changed

Lines changed: 70 additions & 2 deletions

File tree

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
VENV := .venv/bin
22

3+
# ruff: prefer the project venv, fall back to `uvx ruff` when no venv is present
4+
RUFF := $(shell [ -x .venv/bin/ruff ] && echo .venv/bin/ruff || echo "uvx ruff")
5+
36
.PHONY: test lint fmt typecheck check hooks
47

58
test:
69
$(VENV)/pytest tests/ -v
710

811
lint:
9-
$(VENV)/ruff check src/ tests/
12+
$(RUFF) check src/ tests/
1013

1114
fmt:
12-
$(VENV)/ruff format src/ tests/
15+
$(RUFF) format src/ tests/
1316

1417
typecheck:
1518
$(VENV)/pyright src/

src/codeatrium/cli/prime_cmd.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,37 @@
4141
4242
# Retrieve past conversations from work on a specific branch
4343
loci context --branch "feature/foo" --json
44+
```
45+
46+
### IDE selection as a deictic anchor
47+
48+
When the IDE injects an active editor selection (shown as `⧉ Selected N lines from <file>`), treat that selection as the referent of "this / これ / この〜" in the user's prompt. The selection resolves *which* symbol the memory lookup is about — it is NOT by itself a request to recall.
49+
50+
Recall from a selection ONLY when BOTH hold:
51+
52+
1. a selection is active, AND
53+
2. either (a) the user asks about the past — recall / why / history / decisions ("この実装の時の会話を思い出して", "これ前にどう決めた?"), or (b) your own next action on the selected code (edit / refactor / debug) needs prior decisions or constraints.
54+
55+
Do NOT recall when the selection is present only because the user is about to edit it and asks nothing past-oriented.
56+
57+
Map the selection to a query:
58+
59+
- Selection IS a named function/class → look it up directly:
60+
61+
```bash
62+
loci context --symbol "<name>" --json
63+
```
64+
65+
- Selection is a fragment INSIDE one function/class — the `def`/`class` line is usually not in the selection, so resolve the enclosing symbol first (LSP `workspaceSymbol`/`hover`, or read `<file>` around the selection), then:
66+
67+
```bash
68+
loci context --symbol "<enclosing-symbol>" --json
69+
```
70+
71+
- Selection spans multiple symbols or belongs to none (module-level code, config, comments), OR the lookups above return no results → fall back to semantic search over your question:
72+
73+
```bash
74+
loci search "<the user's question>" --json
4475
```\
4576
"""
4677

tests/test_prime_cmd.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,40 @@ def test_prime_text_context_section_explains_bidirectional_recall():
4444
)
4545

4646

47+
# ---- IDE selection trigger contract ----
48+
49+
50+
def test_prime_text_has_ide_selection_section():
51+
"""PRIME_TEXT must explain IDE selection as a deictic anchor for context recall"""
52+
assert "IDE selection as a deictic anchor" in PRIME_TEXT
53+
54+
55+
def test_prime_text_ide_selection_requires_conjunction():
56+
"""A selection alone must NOT trigger recall — requires selection AND a recall need"""
57+
text_lower = PRIME_TEXT.lower()
58+
assert "only when both" in text_lower
59+
# both branches of the recall need must be present
60+
assert "asks about the past" in text_lower
61+
assert "your own next action" in text_lower
62+
63+
64+
def test_prime_text_ide_selection_guards_against_over_fire():
65+
"""PRIME_TEXT must tell the agent NOT to recall on edit-only selections"""
66+
assert "Do NOT recall" in PRIME_TEXT
67+
68+
69+
def test_prime_text_ide_selection_resolves_enclosing_symbol_for_fragments():
70+
"""A fragment selection must resolve its enclosing symbol before context lookup"""
71+
assert "enclosing symbol" in PRIME_TEXT
72+
73+
74+
def test_prime_text_ide_selection_has_search_fallback():
75+
"""When no single symbol applies or context is empty, fall back to loci search"""
76+
text_lower = PRIME_TEXT.lower()
77+
assert "spans multiple symbols" in text_lower
78+
assert "return no results" in text_lower
79+
80+
4781
# ---- inject_claude_md idempotency ----
4882

4983

0 commit comments

Comments
 (0)