Files
whetstone_DSL/progress.md
Bill 1131fdf73d Step 247: file operation tools for MCP (read, write, create, diff, list)
Adds 5 workspace-aware file I/O tools to the MCP server so agents can
manage files without a GUI. All paths are resolved against --workspace
root with escape-rejection security. 12/12 tests pass, tool count now 15.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 05:59:02 +00:00

77 lines
3.7 KiB
Markdown

# Sprint 9 Progress — Agent-First Tooling
## Phase 9a: Standalone MCP Server
### Step 245: HeadlessEditorState (no ImGui dependency)
**Status:** PASS (20/20 tests)
Created the headless agent API surface — same method interface as EditorState
but with zero GUI dependencies (no ImGui, no SDL, no WebSocket).
**Files created:**
- `editor/src/ASTUtils.h` — Pure AST utility functions extracted from EditorUtils.h
(cloneModule, isAnnotationNode, countAnnotationNodes, findNodeById, findNodeAtPosition)
- `editor/src/HeadlessEditorState.h` — Lightweight state: HeadlessAgentState,
HeadlessLibraryState, HeadlessBufferState, buffer management, orchestrator sync
- `editor/src/HeadlessAgentRPCHandler.h` — Full RPC dispatch mirroring
AgentRPCHandler.h (20+ methods: getAST, parseSource, runPipeline, applyMutation,
applyBatch, projectLanguage, generateCode, workflow recording, etc.)
- `editor/tests/step245_test.cpp` — 20 test cases covering construction, buffer
management, RPC dispatch, permission enforcement, pipeline execution
**Key design decisions:**
- JSON roundtrip cloning (matching EditorUtils.h) instead of manual deep copy
- Separate HeadlessAgentState (no AgentMarketplace/WebSocket dependency chain)
- All files under 600-line architecture limit
### Step 246: mcp_main.cpp — Standalone MCP Server Entry Point
**Status:** PASS (12/12 tests)
Wires HeadlessEditorState + MCPBridge into a standalone `whetstone_mcp` binary
that any MCP client (Claude Code, Cursor, etc.) can launch over stdio.
**Files created:**
- `editor/src/mcp_main.cpp` — Standalone MCP server entry point with CLI arg
parsing (--workspace, --language, --verbose), signal handling, resource reader
lambda routing whetstone:// URIs, and MCPBridge stdio loop
- `editor/tests/step246_test.cpp` — 12 test cases: initialize, notifications,
tools/list (10+), resources/list (5), prompts/list (4), tools/call pipeline,
tools/call get_ast, resources/read ast, resources/read diagnostics, ping,
resources/read settings, CLI arg parsing
**Key design decisions:**
- No SDL, no ImGui, no OpenGL — headless only binary
- Fixed "mcp-session" session ID (MCP stdio is single-client)
- Default Refactor role for full MCP access
- Empty scratch buffer on startup so getAST works immediately
- All logging to stderr (stdout is the MCP transport)
### Step 247: File Operation Tools for MCP
**Status:** PASS (12/12 tests)
Adds 5 file I/O tools to the MCP server so agents can create, read, write,
diff, and list files without a GUI. All operations respect the `--workspace`
root with path-escape security checks.
**Files created:**
- `editor/src/FileOperations.h` — Standalone file ops: resolve path, read,
write, create (with templates), unified diff, workspace listing via FileTree
- `editor/tests/step247_test.cpp` — 12 test cases: path resolution, path
escape rejection, file create/read/write via RPC, line range, diff, workspace
list, glob filter, language templates, parent dir creation, permission denial
**Files modified:**
- `editor/src/AgentPermissionPolicy.h` — fileRead/workspaceList/fileDiff
read-only; fileWrite/fileCreate require Refactor/Generator
- `editor/src/HeadlessAgentRPCHandler.h` — 5 new RPC handlers
- `editor/src/HeadlessEditorState.h` — include FileOperations.h
- `editor/src/MCPServer.h` — registerFileTools() with 5 MCP tool definitions
- `editor/CMakeLists.txt` — step247_test target
**Key design decisions:**
- Path security: all paths resolved against workspaceRoot, escape rejected
- Simple line-by-line unified diff (no external dependency)
- Language templates for Python, C++, Rust, Go, Java, JS/TS
- FileTree.h reuse for .gitignore-aware workspace listing
- tools/list now returns 15 tools (was 10)