Skip to content

Commit 2004b32

Browse files
committed
feat: implement MCP-compliant blocking openDiff tool with coroutine-based operations
Change-Id: I9f1ad166f5d76e2ad5a2c67e434e6888e07b631c Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 13d12e2 commit 2004b32

17 files changed

+2659
-388
lines changed

CLAUDE.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,16 @@ The plugin follows a modular architecture with these main components:
4242

4343
4. **Diff Integration** (`lua/claudecode/diff.lua`)
4444

45+
- **MCP-compliant blocking diff operations** for Claude Code integration
4546
- Native Neovim diff support with configurable options
47+
- **Scratch buffer system** replacing temporary files for enhanced security
48+
- **Coroutine-based blocking** that waits for user interaction (save/close)
49+
- **Event monitoring system** with autocmds for save/close/reject detection
50+
- **Comprehensive resource cleanup** with automatic state management
51+
- **State management** for concurrent diff operations with unique identifiers
4652
- Current-tab mode (default) to reduce tab clutter
4753
- Helpful keymaps: `<leader>dq` (exit), `<leader>da` (accept all)
48-
- Automatic temporary file cleanup
54+
- Returns MCP-compliant responses: `FILE_SAVED` + content or `DIFF_REJECTED` + tab_name
4955

5056
5. **Selection Tracking** (`lua/claudecode/selection.lua`)
5157

@@ -67,6 +73,23 @@ The plugin follows a modular architecture with these main components:
6773
- Exposes setup and control functions
6874
- Manages plugin lifecycle
6975

76+
## MCP Compliance Enhancements
77+
78+
The plugin now features a **fully MCP-compliant openDiff tool** that implements the Model Context Protocol specification for blocking operations:
79+
80+
### Key MCP Features
81+
82+
- **Blocking Operation**: openDiff now waits indefinitely for user interaction instead of returning immediately
83+
- **MCP Content Array Format**: Returns responses as `{content: [{type: "text", text: "..."}]}`
84+
- **User Action Detection**: Monitors save events, buffer/tab close events, and explicit accept/reject actions
85+
- **Concurrent Operation Support**: Multiple diffs can run simultaneously with unique tab identifiers
86+
- **Resource Management**: Comprehensive cleanup of buffers, autocmds, and state on completion
87+
88+
### Response Formats
89+
90+
- **FILE_SAVED**: When user saves/accepts changes, returns the final file content
91+
- **DIFF_REJECTED**: When user closes/rejects the diff, returns the tab name
92+
7093
## Development Status
7194

7295
The plugin is in beta stage with:
@@ -76,8 +99,9 @@ The plugin is in beta stage with:
7699
- Enhanced selection tracking with multi-mode support
77100
- Lock file management implemented
78101
- Complete MCP tool framework with dynamic registration
79-
- Core MCP tools: openFile, openDiff, getCurrentSelection, getOpenEditors
80-
- Native Neovim diff integration with configurable options
102+
- Core MCP tools: openFile, **openDiff (MCP-compliant)**, getCurrentSelection, getOpenEditors
103+
- **Enhanced diff integration** with blocking operations and MCP compliance
104+
- **Scratch buffer-based diff system** with automatic resource management
81105
- Terminal integration (Snacks.nvim and native support)
82106
- Comprehensive test suite (55+ tests passing)
83107

0 commit comments

Comments
 (0)