Files
manual_slop/conductor/tracks/manual_skeleton_injection_20260306/spec.md
2026-03-06 16:14:31 -05:00

3.5 KiB

Track Specification: Manual Skeleton Context Injection (manual_skeleton_injection_20260306)

Overview

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)

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

# 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

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

  • "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