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

Commit 7f3a214

Browse files
committed
improve docs
1 parent 9c10188 commit 7f3a214

File tree

8 files changed

+663
-11
lines changed

8 files changed

+663
-11
lines changed

md/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- [Daemon message bus](./design/daemon.md) <!-- 💡: Central message router implementation, client management, process lifecycle, and Unix socket server architecture -->
3131
- [MCP Tool interface](./design/mcp-tool-interface.md) <!-- 💡: API specification for AI assistants calling present_review tool with markdown content -->
3232
- [VSCode extension](./design/extension.md) <!-- 💡: Highlights of the VSCode Extension design and implementation: activation, establishing IPC protocol -->
33+
- [Dialect language](./design/dialect-language.md) <!-- 💡: JSON mini-language semantics for IDE operations - function composition, value types, and execution model -->
3334

3435
# References
3536

@@ -43,4 +44,5 @@
4344
- [Implementation Guide](./references/lsp-overview/implementation-guide.md) <!-- 💡: Practical LSP server/client implementation patterns covering process isolation, message ordering, state management, error handling with exponential backoff, transport configuration (--stdio, --pipe, --socket), three-tier testing strategy, and security considerations (input validation, process isolation, path sanitization). Relevant for: robust IPC implementation, testing strategy, security best practices -->
4445
- [Message Reference](./references/lsp-overview/message-reference.md) <!-- 💡: Complete LSP message catalog with request/response pairs, notifications, $/prefixed protocol messages, capabilities exchange during initialization, document synchronization (full/incremental), workspace/window features, and proper lifecycle management (initialize → initialized → shutdown → exit). Relevant for: protocol patterns, capability negotiation, document synchronization, future LSP integration -->
4546
- [Unix IPC Message Bus Implementation Guide](./references/unix-message-bus-architecture.md) <!-- 💡: Comprehensive research on Unix IPC message bus patterns covering Unix domain sockets vs other mechanisms, hub-and-spoke architecture with central broker, epoll-based event handling, process lifecycle management, performance optimization through hybrid approaches, security hardening, and real-world implementations (D-Bus, Redis, nanomsg). Validates Unix sockets as superior foundation for multi-client message buses with concrete implementation patterns. Relevant for: message bus daemon design, IPC architecture decisions, multi-process communication, performance considerations -->
47+
- [VSCode PR Extension Research](./references/vscode-extensions-dev-pattern.md) <!-- 💡: This research report provides comprehensive technical documentation for building a VS Code extension that creates synthetic pull requests for LLM-generated code changes, covering all essential VS Code Extension APIs with detailed implementation examples. It includes the Comment Controller API for creating PR-like commenting experiences with pre-populated LLM explanations, the Tree View API for PR navigation interfaces in VS Code's sidebar, the Webview API for detailed PR panels with approve/request changes functionality, diff viewer integration for showing file changes, and file system watchers for detecting LLM modifications. The report contains practical code examples for comment thread management, tree data providers, webview panel creation, change tracking systems, command registration for review actions, and integration patterns for forwarding user feedback to LLMs and applying their suggested changes back to the codebase. Consult this report when implementing VS Code extensions that need to display code diffs, manage commenting workflows, create custom sidebar views, integrate with LLM APIs for code review scenarios, or replicate GitHub-style pull request interfaces within VS Code. -->
4648
- [Decision documents]()

md/design/ask-socratic-shell.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,59 @@
11
# Ask Socratic Shell
2+
3+
How users can select code and route it to AI assistants running in terminals.
4+
5+
## User Flow
6+
7+
1. User selects code in VSCode editor
8+
2. Right-click → "Ask Socratic Shell" or use command palette
9+
3. Extension queries terminal registry for active AI assistants
10+
4. Routes to single terminal automatically, or shows picker for multiple
11+
5. Injects formatted context into chosen terminal
12+
13+
## Message Flow
14+
15+
```mermaid
16+
sequenceDiagram
17+
participant User as User
18+
participant Ext as VSCode Extension
19+
participant Term as Terminal
20+
participant AI as AI Assistant
21+
22+
User->>Ext: Select code + "Ask Socratic Shell"
23+
Ext->>Ext: Query terminal registry
24+
alt Single active terminal
25+
Ext->>Term: Inject context message
26+
else Multiple terminals
27+
Ext->>User: Show terminal picker
28+
User->>Ext: Select terminal
29+
Ext->>Term: Inject context message
30+
end
31+
Term->>AI: Context available for next query
32+
```
33+
34+
## Terminal Registry
35+
36+
The extension tracks which terminals have active AI assistants by monitoring:
37+
- Shell PIDs from MCP server connections
38+
- VSCode terminal process IDs
39+
- Matching PIDs to route messages correctly
40+
41+
**Multi-window support**: Each VSCode window maintains its own terminal registry.
42+
43+
## Implementation Details
44+
45+
**Context Formatting**:
46+
```
47+
<context>looking at this code from src/auth.ts:42:1-50</context>
48+
```
49+
50+
**Terminal Detection** (`extension/src/extension.ts`):
51+
- Maintains `Set<number>` of active shell PIDs
52+
- Updates registry based on daemon messages
53+
- Matches VSCode terminals to shell processes
54+
55+
## Key Files
56+
57+
- `extension/src/extension.ts` - Terminal registry and routing logic
58+
- `extension/src/reviewWebview.ts` - Selection handling (if applicable)
59+
- Server components handle PID discovery and reporting

md/design/dialect-language.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Dialect language
2+
3+
The "Dialect" language is a variation of the Lambda calculus that is used to express and compose IDE operations. It is written in JSON:
4+
## Quick Start
5+
6+
Dialect programs are JSON expressions that compose IDE operations. Here are the most common patterns:
7+
8+
**Find where a symbol is defined:**
9+
```json
10+
{"findDefinitions": "MyFunction"}
11+
```
12+
13+
**Find all references to a symbol:**
14+
```json
15+
{"findReferences": "MyClass"}
16+
```
17+
18+
**Get information about a symbol:**
19+
```json
20+
{"getSymbolInfo": "methodName"}
21+
```
22+
23+
**Basic composition - find references to all definitions:**
24+
```json
25+
{"findReferences": {"findDefinitions": "MyFunction"}}
26+
```
27+
28+
These expressions are passed to the `ide_operation` tool, which executes them and returns structured results with file locations and symbol information.
29+
30+
## Grammar
31+
32+
```
33+
Expr = ExprAtomic
34+
| `{` Name `:` `{` Name `:` Expr ... `}` `}`
35+
| `{` Name `:` ExprAtomic `}`
36+
37+
ExprAtomic = number
38+
| boolean
39+
| `null`
40+
| `undefined`
41+
| string
42+
| `[` Expr... `]`
43+
44+
Name = string
45+
46+
// Here: capitalized things are nonterminals.
47+
//
48+
// number, boolean, string are JSON terminals.
49+
//
50+
// `foo` indicates the text `foo`.
51+
//
52+
// And ... indicates a comma-separated list.
53+
```
54+
55+
## Dynamic semantics
56+
57+
A Dialect expression `E` evaluates to a JSON value:
58+
59+
* If `E = [ Expr... ]` a list, then
60+
* evaluate `Expr...` to values `V...`
61+
* and `E` evaluates to `[ V... ]`
62+
* If `E = { Name_f: { Name_a: Expr ... }}`, then
63+
* evaluate `Expr...` to values `V...`
64+
* create an object `{ Name_a: V ... }` where each argument name is paired with the value of its expression
65+
* lookup the function `Name_f` and call it with the given arguments
66+
* If `E = { Name_f: ExprAtomic }`, then
67+
* lookup the function `Name_f` and check whether it defaults a default argument `Name_a`
68+
* if so, evaluate `{ Name_f: { Name_a: ExprAtomic }}` instead
69+
* If `E = number | string | null | undefined`, evaluate to itself
70+
71+
The interpreter is defined in `dialect.rs`.
72+
73+
## Defining functions
74+
75+
Functions are defined in Rust by implementing the `DialectFunction` trait:
76+
77+
```rust
78+
{{#include ../../server/src/dialect.rs:dialect_function_trait}}
79+
```
80+
81+
The `Output` will be serialized into JSON and passed along.
82+
83+
Some functions evaluate to instances of themselves, these represent "values"
84+
(as in the lambda calculus). They can implement `DialectValue` instead:
85+
86+
```rust
87+
{{#include ../../server/src/dialect.rs:dialect_value_trait}}
88+
```
89+

md/design/ide-capabilities.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,55 @@
11
# IDE Capabilities
2+
3+
How AI assistants access VSCode's Language Server Protocol (LSP) features through the `ide_operation` tool.
4+
5+
## Dialect Mini-Language
6+
7+
The `ide_operation` tool uses a composable [JSON mini-language called Dialect](./dialect-language.md) for IDE operations:
8+
9+
```json
10+
{"findDefinitions": "MyFunction"}
11+
{"findReferences": "MyClass"}
12+
{"getSymbolInfo": "methodName"}
13+
```
14+
15+
## Message Flow
16+
17+
```mermaid
18+
sequenceDiagram
19+
participant AI as AI Assistant
20+
participant MCP as MCP Server
21+
participant Ext as VSCode Extension
22+
participant LSP as Language Server
23+
24+
AI->>MCP: ide_operation tool call
25+
MCP->>Ext: Execute Dialect program
26+
Ext->>LSP: LSP request (definitions/references/etc)
27+
LSP->>Ext: Symbol locations/info
28+
Ext->>MCP: Formatted results
29+
MCP->>AI: Tool response with locations
30+
```
31+
32+
## Implementation Details
33+
34+
**MCP Server** (`server/src/server.rs`):
35+
- Receives Dialect program in `IdeOperationParams`
36+
- Forwards to extension via IPC for execution
37+
- Returns structured results to AI assistant
38+
39+
**VSCode Extension**:
40+
- Interprets Dialect operations
41+
- Translates to appropriate VSCode/LSP API calls
42+
- Handles disambiguation when multiple matches found
43+
- Returns formatted location/symbol information
44+
45+
**Supported Operations**:
46+
- `findDefinitions` - Where symbols are defined
47+
- `findReferences` - Where symbols are used
48+
- `getSymbolInfo` - Type signatures and documentation
49+
- Future: completion, hover info, workspace symbols
50+
51+
## Key Files
52+
53+
- `server/src/server.rs` - Tool handler and parameter validation
54+
- Extension components handle Dialect interpretation and LSP communication
55+
- `server/src/dialect/` - Dialect interpreter (if implemented)

md/design/present-review.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,43 @@
11
# Present Review
2+
3+
How AI assistants display code reviews in VSCode through the MCP server and extension.
4+
5+
## Message Flow
6+
7+
```mermaid
8+
sequenceDiagram
9+
participant AI as AI Assistant
10+
participant MCP as MCP Server
11+
participant Ext as VSCode Extension
12+
participant UI as Webview Panel
13+
14+
AI->>MCP: present_review tool call
15+
MCP->>Ext: PresentReview message (Unix socket)
16+
Ext->>UI: Update webview content
17+
UI->>Ext: Link click (postMessage)
18+
Ext->>UI: Navigate to file/line
19+
```
20+
21+
## Implementation Details
22+
23+
**MCP Server** (`server/src/server.rs`):
24+
- Receives `present_review` tool call with markdown content
25+
- Validates parameters using `PresentReviewParams` struct
26+
- Forwards to VSCode extension via Unix socket IPC
27+
28+
**VSCode Extension** (`extension/src/reviewWebview.ts`):
29+
- Receives message from MCP server
30+
- Processes markdown with custom link renderer
31+
- Updates webview panel with processed HTML
32+
33+
**Link Processing**:
34+
- Converts `file.ts?searchTerm``dialectic:file.ts?regex=searchTerm`
35+
- Converts `file.ts#L42``dialectic:file.ts?line=42`
36+
- Handles disambiguation when search finds multiple matches
37+
38+
## Key Files
39+
40+
- `server/src/server.rs` - Tool handler and IPC forwarding
41+
- `server/src/types.rs` - Parameter definitions
42+
- `extension/src/reviewWebview.ts` - Webview management and link handling
43+
- `extension/src/extension.ts` - Message routing from daemon client

0 commit comments

Comments
 (0)