Skip to content

Add cache support to coderWrapper with shared dispatcher#1843

Merged
steveluc merged 20 commits intomainfrom
add-command-executor-mcp-server
Jan 20, 2026
Merged

Add cache support to coderWrapper with shared dispatcher#1843
steveluc merged 20 commits intomainfrom
add-command-executor-mcp-server

Conversation

@steveluc
Copy link
Copy Markdown
Contributor

Summary

Adds optional caching functionality to the coderWrapper package, allowing it to check TypeAgent's cache before forwarding commands to the wrapped CLI agent. The cache is disabled by default to ensure safe, predictable behavior.

Key Features

Cache Support (Optional)

  • New cacheClient.ts connects to command-executor MCP server to check cache
  • Cache checking happens before forwarding to wrapped agent
  • Results returned immediately on cache hit, bypassing wrapped agent entirely
  • Debug mode shows cache timing: (385ms) indicator
  • Disabled by default - must explicitly enable with --enable-cache flag

Multi-Client Cache Sharing

  • Agent server uses AsyncLocalStorage for request-scoped routing
  • Multiple coderWrapper instances can share the same TypeAgent cache
  • Each client receives isolated results despite shared dispatcher

Input Handling Improvements

  • Fixed Windows \r\n double-execution issue
  • Processing lock prevents concurrent command handling
  • Proper handling of Enter key variations (CR, LF, CRLF)

Debug Logging

  • Optional debug logs written to ~/.tmp/typeagent-coder-wrapper/
  • Enable with --debug flag
  • Logs include stdin events, cache checks, timing information

Changed Packages

coderWrapper

  • Added cacheClient.ts - MCP client for cache checking
  • Added debugLogger.ts - Debug logging utility
  • Updated ptyWrapper.ts - Cache support, input handling fixes
  • Updated CLI - New --enable-cache and --debug flags

commandExecutor

  • Fixed startup race condition (cache miss instead of error)
  • Added CACHE_HIT prefix for client detection
  • Improved error handling for disconnected dispatcher

dispatcher (RPC)

  • Added checkCache method to RPC interface
  • Implemented in client and server

agentServer

  • AsyncLocalStorage-based multi-client routing
  • Context preservation for checkCache calls

Test Plan

  • Basic passthrough works without cache (default behavior)
  • Cache can be enabled with --enable-cache flag
  • Cache hits return immediately with timing indicator
  • Cache misses forward to wrapped agent correctly
  • Multiple clients can share cache via agent server
  • Windows \r\n input handling works correctly
  • Debug logging captures detailed information
  • Startup race condition handled gracefully

Notes

  • Cache is disabled by default for safety
  • Users must explicitly opt-in with enableCache: true or --enable-cache
  • Debug mode adds helpful timing indicators but is also opt-in

🤖 Generated with Claude Code

steveluc and others added 18 commits January 16, 2026 23:19
Introduces a new MCP (Model Context Protocol) server that enables Claude Code to execute TypeAgent commands for music playback, list management, calendar operations, and other natural language tasks.

Key features:
- Connects Claude Code to TypeAgent dispatcher via WebSocket
- Automatic reconnection with 5-second retry interval
- Comprehensive logging to temp files for debugging
- Supports natural language commands (e.g., "play bohemian rhapsody", "add milk to grocery list")
- Clean output formatting with HTML image tags stripped

Includes example configuration for .mcp.json and detailed installation instructions in README.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Add trademark section to README
- Remove dist-test build outputs from git
- Fix package.json field ordering (use exports instead of main)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Use exact trademark text format with proper line breaks
- Sort package.json scripts alphabetically

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit enhances the split editor command in the Coda extension to support more flexible editor selection and improves TypeAgent schema disambiguation.

**Bug Fixes:**
- Fix off-by-one error when selecting "first" or "last" editor by sorting by viewColumn
- Fix multiple split issue by adding conditionals to focus changes
- Remove unnecessary focus restoration logic for voice command scenarios

**Features:**
- Add support for splitting editors by position: "first", "last", "active", or numeric index
- Add support for splitting editors by file name: "split app.tsx to the right"
- Search all open tabs using tabGroups API, not just visible editors
- Automatically open and focus files found in background tabs before splitting

**Schema Improvements:**
- Add clear disambiguation between splitEditor and moveCursorInFile actions
- Add "USE THIS for" and "DO NOT USE for" guidance in schema comments
- Add concrete examples to help LLM choose correct action
- Remove moveCursorInFile reference from main code schema (not useful for voice)

**Documentation:**
- Add VSCODE_CAPABILITIES.md documenting all VSCode automation features
- Update split editor examples to show new position and file-based splitting

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This enhancement allows the player agent to create playlists with songs
specified by title and artist, and to add lists of songs to existing
playlists, eliminating the need to search and build a track list first.

Changes:
- Add SongSpecification interface for specifying songs by track name,
  optional artist, and optional album
- Extend CreatePlaylistAction with optional songs parameter to support
  creating playlists with songs in one action
- Add new AddSongsToPlaylistAction for bulk adding songs to existing
  playlists
- Implement searchSongsAndGetUris helper function to search Spotify
  for songs and collect their URIs
- Update createPlaylist handler to search for and add songs when
  creating playlists
- Add addSongsToPlaylist handler for the new action
- Add validation support for the new action in playerHandlers

Benefits:
- Users can create playlists with songs in a single request
- Supports requests like "create a playlist with the top 10 songs"
- Provides feedback on songs that couldn't be found
- Maintains backward compatibility with existing createPlaylist usage

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This package provides a pseudo terminal wrapper for CLI coding assistants
like Claude Code, with support for transparent I/O passthrough and future
caching capabilities.

Features:
- PTY wrapper using node-pty for proper terminal emulation
- Transparent passthrough of all stdin/stdout/stderr
- Support for multiple CLI assistants (Claude Code, Node REPL, Python, etc.)
- Windows compatibility with automatic .exe handling
- Graceful exit handling (Ctrl+C, SIGTERM)
- Terminal features: colors, cursor control, resizing
- Configurable assistant system for extensibility

Architecture:
- assistantConfig.ts: Pluggable configuration for different assistants
- ptyWrapper.ts: Core PTY wrapper with node-pty
- cli.ts: Command-line interface entry point
- index.ts: Public API exports

Usage:
  coder-wrapper                 # Use Claude Code (default)
  coder-wrapper -a node         # Use Node REPL
  coder-wrapper -a python       # Use Python REPL

Future enhancements:
- Cache checking with TypeAgent dispatcher before forwarding requests
- Request/response logging and performance metrics
- Cache hit/miss statistics

Testing requires a real terminal (TTY) - see TESTING.md for manual test
procedures.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit adds optional caching functionality to the coderWrapper package, allowing
it to check TypeAgent's cache before forwarding commands to the wrapped CLI agent.

Key changes:

**coderWrapper package:**
- Add cacheClient.ts: MCP client for checking TypeAgent cache via command-executor
- Add debugLogger.ts: Debug logging to ~/.tmp/typeagent-coder-wrapper/
- Update ptyWrapper.ts:
  - Add cache checking before forwarding commands to wrapped agent
  - Handle \r\n separately to prevent duplicate command execution on Windows
  - Add processing lock to prevent concurrent command handling
  - Add enableCache option (default: false)
  - Add debug option for detailed logging
- Update CLI to support --enable-cache and --debug flags

**commandExecutor MCP server:**
- Add startup connection race handling (return cache miss instead of error)
- Add CACHE_HIT prefix for detection by cacheClient
- Improve error handling for disconnected dispatcher

**dispatcher:**
- Add checkCache RPC method to dispatcher interface
- Implement checkCache in dispatcher client and server
- Support multi-client cache sharing via AsyncLocalStorage routing

**agentServer:**
- Add AsyncLocalStorage-based request routing for multi-client support
- Wrap checkCache calls with client context to route responses correctly
- Each client gets isolated cache results despite shared dispatcher

The cache is disabled by default and must be explicitly enabled with enableCache: true
or --enable-cache flag. When enabled and cache hits occur, results are returned
immediately without invoking the wrapped CLI agent.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…mcp-server

# Conflicts:
#	ts/packages/coderWrapper/README.md
#	ts/packages/coderWrapper/package.json
#	ts/packages/coderWrapper/src/cli.ts
#	ts/packages/coderWrapper/src/index.ts
#	ts/packages/coderWrapper/src/ptyWrapper.ts
#	ts/pnpm-lock.yaml
@steveluc steveluc temporarily deployed to development-fork January 20, 2026 02:05 — with GitHub Actions Inactive
@steveluc steveluc temporarily deployed to development-fork January 20, 2026 02:05 — with GitHub Actions Inactive
@steveluc steveluc added this pull request to the merge queue Jan 20, 2026
Merged via the queue into main with commit df5cc5f Jan 20, 2026
21 checks passed
@steveluc steveluc deleted the add-command-executor-mcp-server branch January 20, 2026 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant