hopefully done refining

This commit is contained in:
2026-03-06 16:14:31 -05:00
parent 88e27ae414
commit 1294104f7f
20 changed files with 1736 additions and 734 deletions

View File

@@ -1,36 +1,113 @@
# Track Specification: Manual Skeleton Context Injection (manual_skeleton_injection_20260306)
## Overview
Add UI controls to manually flag files for skeleton injection in discussions. Allow agent to request full file reads or specific def/class definitions on-demand.
Add UI controls to manually inject file skeletons into discussions. Allow user to preview skeleton content before sending to AI, with option to toggle between skeleton and full file.
## Current State Audit
### Already Implemented (DO NOT re-implement)
- **`file_cache.ASTParser.get_skeleton()`**: Returns Python skeleton
- **`mcp_client.py_get_skeleton()`**: MCP tool for skeleton generation
- **`aggregate.py`**: Builds file items context
### Gaps to Fill
- No UI to flag files for skeleton vs full
- No preview of skeleton before injection
- No on-demand definition lookup
#### ASTParser (src/file_cache.py)
- **`ASTParser` class**: Uses tree-sitter for Python parsing
- **`get_skeleton(code: str) -> str`**: Returns file skeleton (signatures/docstrings preserved, function bodies replaced with `...`)
- **`get_curated_view(code: str) -> str`**: Returns curated view preserving `@core_logic` and `# [HOT]` decorated function bodies
#### MCP Tools (src/mcp_client.py)
- **`py_get_skeleton(path, language)`**: Tool #15 - generates skeleton
- **`py_get_definition(path, name)`**: Tool #18 - gets specific definition
- **Both available to AI during discussion**
#### Context Building (src/aggregate.py)
- **`build_file_items()`**: Creates file items from project config
- **`build_tier*_context()`**: Tier-specific context builders already use skeleton logic
### Gaps to Fill (This Track's Scope)
- No UI for manual skeleton preview/injection
- No toggle between skeleton and full file
- No inject-to-discussion button
## Architectural Constraints
### Non-Blocking Preview
- Skeleton generation MUST NOT block UI
- Use existing `ASTParser.get_skeleton()` - already fast (<100ms)
### Preview Size Limit
- Truncate preview at 500 lines
- Show "... (truncated)" notice if exceeded
## Architecture Reference
### Key Integration Points
| File | Lines | Purpose |
|------|-------|---------|
| `src/gui_2.py` | ~1300-1400 | Discussion panel - add injection UI |
| `src/file_cache.py` | 30-80 | `ASTParser.get_skeleton()` |
| `src/aggregate.py` | 119-145 | `build_file_items()` |
### UI Integration Pattern
```python
# In discussion panel:
if imgui.button("Inject File"):
# Open file picker
self._inject_file_path = selected_path
self._inject_mode = "skeleton" # or "full"
# Preview in child window
preview = ASTParser("python").get_skeleton(content) if skeleton_mode else content
# Inject button appends to input text
```
## Functional Requirements
- File picker UI in discussion panel
- Skeleton preview before injection
- Toggle: skeleton vs full file
- Uses existing `py_get_skeleton()` tool
## Key Integration Points
| File | Purpose |
|-----|---------|
| `src/gui_2.py` | File picker, injection UI |
| `src/mcp_client.py` | `py_get_skeleton()` |
| `src/file_cache.py` | `ASTParser` |
### FR1: File Selection
- Button "Inject File" in discussion panel
- Opens file browser limited to project files
- Path validation against project's `files.base_dir`
### FR2: Mode Toggle
- Radio buttons: "Skeleton" / "Full File"
- Default: Skeleton
- Switching regenerates preview
### FR3: Preview Display
- Child window showing preview content
- Monospace font
- Scrollable, max 500 lines displayed
- Line numbers optional
### FR4: Inject Action
- Button "Inject to Discussion"
- Appends content to input text area
- Format: `## File: {path}\n\`\`\`python\n{content}\n\`\`\``
## Non-Functional Requirements
| Requirement | Constraint |
|-------------|------------|
| Preview Time | <100ms for typical file |
| Memory | Preview limited to 50KB |
## Testing Requirements
### Unit Tests
- Test skeleton generation for sample files
- Test truncation at 500 lines
### Integration Tests
- Inject file, verify appears in discussion
- Toggle modes, verify preview updates
## Out of Scope
- Definition lookup (separate track: on_demand_def_lookup)
- Multi-file injection
- Custom skeleton configuration
## Acceptance Criteria
- [ ] File picker UI functional
- [ ] Skeleton preview displays
- [ ] Manual refresh button works
- [ ] Full read option available
- [ ] 1-space indentation
- [ ] "Inject File" button in discussion panel
- [ ] File browser limits to project files
- [ ] Skeleton/Full toggle works
- [ ] Preview displays correctly
- [ ] Inject appends to input
- [ ] Large file truncation works
- [ ] 1-space indentation maintained