|
| 1 | +# RFC: Exposing IDE capabilities |
| 2 | + |
| 3 | +*A natural language interface to VSCode and Language Server Protocol features* |
| 4 | + |
| 5 | +**Tracking Issue**: [#8](https://github.com/socratic-shell/dialectic/issues/8) |
| 6 | + |
| 7 | +## Problem Statement |
| 8 | + |
| 9 | +Currently, AI assistants working with code need many specific MCP tools to interact with the IDE: |
| 10 | +- `dialectic___get_selection` for getting selected text |
| 11 | +- `builder_mcp___WorkspaceSearch` for finding code patterns |
| 12 | +- Separate tools would be needed for each LSP feature (find references, go to definition, etc.) |
| 13 | + |
| 14 | +This creates several problems: |
| 15 | +- **Tool selection overwhelm**: Too many specific tools make it hard for AI to choose the right approach |
| 16 | +- **Inconsistent interfaces**: Each tool has different parameter formats and return structures |
| 17 | +- **Limited composability**: Hard to combine operations (e.g., "find references to the currently selected symbol") |
| 18 | +- **Poor discoverability**: AI assistants must memorize many tool names and signatures |
| 19 | + |
| 20 | +## Proposed Solution |
| 21 | + |
| 22 | +Replace multiple specific tools with a single `ideCapability(string)` tool that: |
| 23 | + |
| 24 | +1. **Accepts natural language requests**: "find all references to validateToken" |
| 25 | +2. **Returns either results or refinement suggestions**: Success with data, or "ambiguous, try one of these options" |
| 26 | +3. **Uses a composable JSON mini-language internally** for precise operations |
| 27 | +4. **Provides self-teaching error messages** that guide AI assistants toward successful usage |
| 28 | + |
| 29 | +## Interface Design |
| 30 | + |
| 31 | +### Single Entry Point |
| 32 | +```typescript |
| 33 | +ideCapability(request: string) → string |
| 34 | +``` |
| 35 | + |
| 36 | +### Response Types |
| 37 | + |
| 38 | +**Success:** |
| 39 | +``` |
| 40 | +"Success, results: [{"file": "auth.ts", "line": 42, "context": "validateToken(user)"}]" |
| 41 | +``` |
| 42 | + |
| 43 | +**Ambiguous request:** |
| 44 | +``` |
| 45 | +"Ambiguous request, consider one of the following: |
| 46 | +(1) {"findReferences": {"symbol": {"name": "validateToken", "file": "auth.ts", "line": 42}}} |
| 47 | +(2) {"findReferences": {"symbol": {"name": "validateToken", "file": "utils.ts", "line": 15}}}" |
| 48 | +``` |
| 49 | + |
| 50 | +**Capability not available:** |
| 51 | +``` |
| 52 | +"We don't have the ability to do that :(" |
| 53 | +``` |
| 54 | + |
| 55 | +## Internal Architecture |
| 56 | + |
| 57 | +The system has three main layers: |
| 58 | + |
| 59 | +### 1. Natural Language Interface |
| 60 | +- Converts natural language requests to JSON mini-language programs |
| 61 | +- Handles ambiguity resolution and provides refinement suggestions |
| 62 | +- Acts as the "front door" for AI assistants |
| 63 | + |
| 64 | +### 2. JSON Mini-Language Runtime |
| 65 | +- Executes composable JSON programs |
| 66 | +- Manages value types (Symbol, Selection, Location, etc.) |
| 67 | +- Handles function composition and error propagation |
| 68 | + |
| 69 | +### 3. VSCode Integration Layer |
| 70 | +- Maps JSON functions to actual VSCode/LSP calls |
| 71 | +- Handles async operations and editor state |
| 72 | +- Returns results in JSON mini-language format |
| 73 | + |
| 74 | +## Benefits |
| 75 | + |
| 76 | +**For AI Assistants:** |
| 77 | +- Single tool to learn instead of many specific ones |
| 78 | +- Natural language interface reduces cognitive load |
| 79 | +- Self-teaching through error messages |
| 80 | +- Composable operations enable complex workflows |
| 81 | + |
| 82 | +**For Users:** |
| 83 | +- More capable AI assistance with IDE operations |
| 84 | +- Consistent interface across all IDE features |
| 85 | +- Better error messages and suggestions |
| 86 | +- Extensible system for future capabilities |
| 87 | + |
| 88 | +**For Developers:** |
| 89 | +- Clean separation between language runtime and IDE integration |
| 90 | +- Easy to add new capabilities |
| 91 | +- Testable and maintainable architecture |
| 92 | +- Reusable across different editors (future) |
| 93 | + |
| 94 | +## Open Questions |
| 95 | + |
| 96 | +This RFC establishes the overall approach, but several design questions need resolution: |
| 97 | + |
| 98 | +1. **[Scripting Language Design](./ide-capabilities/scripting-language.md)**: How should the JSON mini-language work? What are the core concepts and composition rules? |
| 99 | + |
| 100 | +2. **[Natural Language Interface](./ide-capabilities/natural-language-interface.md)**: How do we convert natural language requests to JSON programs? What's the right confidence threshold for execution vs clarification? |
| 101 | + |
| 102 | +3. **[Capability Registry](./ide-capabilities/capability-registry.md)**: What IDE capabilities should we expose initially? What are their function signatures and required value types? |
| 103 | + |
| 104 | +## Implementation Strategy |
| 105 | + |
| 106 | +### Phase 1: Proof of Concept |
| 107 | +- Implement basic JSON mini-language runtime |
| 108 | +- Create a few essential capabilities (getSelection, findSymbol, findReferences) |
| 109 | +- Build simple natural language interface (possibly rule-based) |
| 110 | +- Validate the overall approach |
| 111 | + |
| 112 | +### Phase 2: Core Capabilities |
| 113 | +- Expand capability set to cover common IDE operations |
| 114 | +- Improve natural language processing |
| 115 | +- Add comprehensive error handling and suggestions |
| 116 | +- Replace existing specific MCP tools |
| 117 | + |
| 118 | +### Phase 3: Advanced Features |
| 119 | +- Add refactoring operations (rename, extract method, etc.) |
| 120 | +- Integrate with more LSP features |
| 121 | +- Optimize performance and user experience |
| 122 | +- Consider extending to other editors |
| 123 | + |
| 124 | +## Success Criteria |
| 125 | + |
| 126 | +This RFC will be considered successful when: |
| 127 | +- AI assistants can perform common IDE operations through natural language |
| 128 | +- The tool selection problem is significantly reduced |
| 129 | +- Error messages effectively guide AI assistants to successful usage |
| 130 | +- The system is extensible enough to add new capabilities easily |
| 131 | +- User feedback indicates improved AI assistance quality |
| 132 | + |
| 133 | +## Next Steps |
| 134 | + |
| 135 | +1. Review and refine this overall proposal |
| 136 | +2. Work through the detailed design questions in the sub-RFCs |
| 137 | +3. Build a minimal prototype to validate core concepts |
| 138 | +4. Iterate based on real usage with AI assistants |
0 commit comments