hopefully done refining
This commit is contained in:
@@ -1,30 +1,67 @@
|
||||
# Implementation Plan: On-Demand Definition Lookup (on_demand_def_lookup_20260306)
|
||||
|
||||
> **Reference:** [Spec](./spec.md) | [Architecture Guide](../../../docs/guide_architecture.md)
|
||||
|
||||
## Phase 1: Symbol Parsing
|
||||
- [ ] Task: Initialize MMA Environment
|
||||
- [ ] Task: Implement @syntax parsing
|
||||
- WHERE: src/gui_2.py
|
||||
- WHAT: Detect @symbol in input
|
||||
- HOW: Regex or string match
|
||||
- SAFETY: Handle edge cases
|
||||
Focus: Parse @symbol syntax from user input
|
||||
|
||||
- [ ] Task 1.1: Initialize MMA Environment
|
||||
- [ ] Task 1.2: Implement @symbol regex parser
|
||||
- WHERE: `src/gui_2.py` in `_send_callback()`
|
||||
- WHAT: Extract @SymbolName patterns
|
||||
- HOW:
|
||||
```python
|
||||
import re
|
||||
def parse_symbols(text: str) -> list[str]:
|
||||
return re.findall(r'@(\w+(?:\.\w+)*)', text)
|
||||
```
|
||||
|
||||
## Phase 2: Definition Retrieval
|
||||
- [ ] Task: Integrate py_get_definition
|
||||
- WHERE: src/gui_2.py
|
||||
- WHAT: Get definition from outline_tool
|
||||
- HOW: Call existing function
|
||||
- SAFETY: Handle not found
|
||||
Focus: Use existing MCP tool to get definitions
|
||||
|
||||
- [ ] Task 2.1: Integrate py_get_definition
|
||||
- WHERE: `src/gui_2.py`
|
||||
- WHAT: Call MCP tool for each symbol
|
||||
- HOW:
|
||||
```python
|
||||
from src import mcp_client
|
||||
def get_symbol_definition(symbol: str, files: list[str]) -> tuple[str, str] | None:
|
||||
for file_path in files:
|
||||
result = mcp_client.py_get_definition(file_path, symbol)
|
||||
if result and "not found" not in result.lower():
|
||||
return (file_path, result)
|
||||
return None
|
||||
```
|
||||
|
||||
## Phase 3: Inline Display
|
||||
- [ ] Task: Render inline
|
||||
- WHERE: src/gui_2.py
|
||||
- WHAT: Show definition in discussion
|
||||
- HOW: imgui.text with formatting
|
||||
- [ ] Task: Implement navigation
|
||||
- WHERE: src/gui_2.py
|
||||
- WHAT: Click to jump to source
|
||||
- HOW: Store file/line refs
|
||||
Focus: Display definition in discussion
|
||||
|
||||
## Phase 4: Verification
|
||||
- [ ] Task: Test lookup flow
|
||||
- [ ] Task: Conductor - Phase Verification
|
||||
- [ ] Task 3.1: Inject definition as context
|
||||
- WHERE: `src/gui_2.py` `_send_callback()`
|
||||
- WHAT: Append definition to message
|
||||
- HOW:
|
||||
```python
|
||||
symbols = parse_symbols(user_message)
|
||||
for symbol in symbols:
|
||||
result = get_symbol_definition(symbol, self.project_files)
|
||||
if result:
|
||||
file_path, definition = result
|
||||
user_message += f"\n\n[Definition: {symbol} from {file_path}]\n```python\n{definition}\n```"
|
||||
```
|
||||
|
||||
## Phase 4: Click Navigation
|
||||
Focus: Allow clicking definition to open file
|
||||
|
||||
- [ ] Task 4.1: Store file/line metadata with definition
|
||||
- WHERE: Discussion entry structure
|
||||
- WHAT: Track source location
|
||||
- HOW: Add to discussion entry dict
|
||||
|
||||
- [ ] Task 4.2: Add click handler
|
||||
- WHERE: `src/gui_2.py` discussion rendering
|
||||
- WHAT: On click, scroll to definition
|
||||
- HOW: Use selectable text with callback
|
||||
|
||||
## Phase 5: Testing
|
||||
- [ ] Task 5.1: Write unit tests for parsing
|
||||
- [ ] Task 5.2: Conductor - Phase Verification
|
||||
|
||||
Reference in New Issue
Block a user