Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Overhaul Ask Socratic Shell with compact reference system #29

@nikomatsakis

Description

@nikomatsakis

Objective

Replace the current verbose XML injection system with a compact reference-based approach that reduces visual clutter and improves LLM interaction quality.

Problem

Current "Ask Socratic Shell" system injects verbose XML that:

  • Takes up significant visual space in terminal
  • Can confuse LLM agents with complex nested structures
  • Makes conversations harder to read and follow
  • Doesn't scale well for multiple references

Current approach:

<ask_socratic_shell>
<file>src/main.rs</file>
<line>42</line>
<selection>let x = foo();</selection>
</ask_socratic_shell>

What does this code do?

Solution

Implement compact reference system with on-demand expansion:

New approach:

<ssref id="22"/>

What does this code do?

Key Components

  1. Compact References: Generate short <ssref id="X"/> tags instead of verbose XML
  2. Expand Reference Tool: MCP tool that LLMs invoke to get full context when needed
  3. Reference Storage: Server-side storage of reference data with unique IDs
  4. Updated Comment UX: Replace comment reply threads with simple "Ask about this" buttons

Implementation Plan

Phase 1: Reference System Infrastructure

  • Design reference storage system (in-memory with expiration)
  • Create expand_reference MCP tool interface
  • Implement reference ID generation and storage
  • Add reference expansion with structured JSON context

Phase 2: Ask Socratic Shell Integration

  • Update text selection → reference generation
  • Replace XML injection with compact ssref tags
  • Update system prompts to guide LLM usage
  • Test with various selection types (code, files, lines)

Phase 3: Comment System Integration

  • Remove comment reply text input UI
  • Add simple "Ask about this" button to walkthrough comments
  • Button generates ssref for comment context
  • Focus terminal after ssref injection

Phase 4: Polish and Documentation

  • Reference expiration and cleanup
  • Error handling for invalid/expired references
  • Update user documentation
  • Performance testing with many references

Benefits

  • Cleaner terminal conversations - minimal visual noise
  • Better LLM performance - less confusion from verbose XML
  • Scalable references - multiple refs in single message
  • On-demand context - LLM controls when to expand details
  • Unified system - works for selections AND comments
  • Natural UX - conversations happen in terminal, not comment threads

Context

Discovered during walkthrough comment reply implementation (#23) that verbose XML injection creates poor UX and can confuse LLM agents. This overhaul addresses fundamental interaction patterns across the entire system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-managedAI is permitted to update this issue OP and add commentsfeatureNew functionalitytracking-issueOngoing work item tracked across multiple sessions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions