Developer Guide
Development Setup
Prerequisites
- Node.js 18+ - Required for TypeScript development
- macOS 10.15+ - Currently macOS only (Windows/Linux coming soon)
- REAPER 6.0+ - The DAW we're controlling
- Git - For version control
Getting Started
# Clone the repository
git clone https://github.com/shiehn/reaper-chat.git
cd reaper-chat
# Install dependencies
npm install
# Run in development mode
npm run start # Standard development mode
npm run dev:safe # Safe mode with crash protection
npm run dev:smart # Auto-restarts on crashes
Architecture Overview
Project Structure
signals-and-sorcery/
├── src/
│ ├── main/ # Electron main process
│ │ ├── index.ts # App entry point
│ │ ├── mcp-typescript.ts # MCP server manager
│ │ └── bridge-installer.ts # Auto-installer
│ ├── renderer/ # React UI
│ │ ├── App.tsx # Main component
│ │ ├── pages/ # UI pages
│ │ └── components/ # React components
│ ├── mcp-server/ # TypeScript MCP
│ │ ├── index.ts # Server entry
│ │ ├── dsl/ # 93 DSL tools
│ │ └── resources/ # Lua bridges
│ └── layers/ # Experimental architecture
│ ├── intent/ # Intent analysis
│ ├── validation/ # Parameter validation
│ ├── planning/ # Multi-step planning
│ ├── execution/ # Tool execution
│ ├── retry/ # Retry mechanisms
│ └── response/ # Response formatting
├── scripts/ # Build & test scripts
├── docs/ # Documentation
└── conversation-tracking/ # Analysis data
Key Technologies
- Electron - Desktop application framework
- React 19 - UI framework
- TypeScript - Type-safe JavaScript
- MCP - Model Context Protocol for LLM tools
- Tailwind CSS - Utility-first CSS
- Zod - Runtime type validation
Adding New DSL Tools
⚠️ IMPORTANT: Read First!
Before adding tools, you MUST read TOOL_ARCHITECTURE.md. The smart router requires careful tool placement to function correctly.
Tool Structure
// src/mcp-server/dsl/tracks.ts
export const createTrackTool = {
name: "dsl_create_track",
description: "Create a new track in REAPER",
parameters: z.object({
name: z.string().optional().describe("Track name"),
type: z.enum(['audio', 'midi']).default('audio'),
index: z.number().optional().describe("Insert position")
}),
execute: async (params) => {
// Implementation
return await reaperAPI.createTrack(params);
}
};
Tool Categories
Tools must be placed in the correct category file:
tracks.ts
- Track operations (create, delete, rename)effects.ts
- FX and processingtransport.ts
- Playback controlautomation.ts
- Envelope and automationnavigation.ts
- Cursor and selectionmixing.ts
- Volume, pan, routingmidi.ts
- MIDI operationsgeneration.ts
- Content generation
Adding a Tool Checklist
- ✅ Determine the correct category
- ✅ Add tool to category file
- ✅ Define tool relationships in router
- ✅ Update category keywords
- ✅ Add corresponding Lua function if needed
- ✅ Write unit tests
- ✅ Update documentation
Testing
Unit Tests
# Run all tests
npm test
# Test specific module
npm test -- dsl/tracks
# Test with coverage
npm test -- --coverage
Integration Tests
# Test with real REAPER instance
npm run test:integration
# Test specific command flow
node scripts/tests/test-full-stack.js 10
E2E Tests
# Run Playwright tests
npm run test:e2e
# Test layered architecture
npm run test:e2e:layered
# Test backward compatibility
npm run test:e2e:compat
Debugging
Enable Debug Logging
# In .env file
VITE_LOG_LEVEL=debug
DEBUG_TOOL_SELECTION=true
ENABLE_CONVERSATION_TRACKING=true
# Or via environment
DEBUG=* npm run start
Chrome DevTools
- Open the app
- Press
Cmd+Option+I
(Mac) orCtrl+Shift+I
(Windows) - Use Console, Network, and Sources tabs
REAPER Bridge Debugging
- Open REAPER's ReaScript console
- Look for MCP bridge output
- Check
Scripts/mcp_bridge_data/
for logs
Building & Distribution
Build Commands
# Build TypeScript
npm run build
# Build for current platform
npm run dist
# Build for specific platforms
npm run dist:mac
npm run dist:win
npm run dist:linux
Release Process
- Update version in
package.json
- Run tests:
npm test
- Build:
npm run dist
- Test the built app
- Create GitHub release
- Upload artifacts
Contributing
Code Style
- Use TypeScript for type safety
- Follow ESLint rules
- Use Prettier for formatting
- Write tests for new features
Commit Messages
Follow conventional commits:
feat: add new DSL tool for track routing
fix: resolve MCP connection timeout
docs: update developer guide
test: add unit tests for effects tools
Pull Request Process
- Fork the repository
- Create feature branch
- Make changes with tests
- Update documentation
- Submit PR with description
Advanced Topics
Layered Architecture
Enable experimental features:
// src/main/config.ts
export const config = {
useLayeredArchitecture: true,
layers: {
intent: true,
validation: true,
planning: true,
retry: true,
response: true
}
};
Custom Tool Providers
// src/mcp-server/providers/custom.ts
export class CustomToolProvider {
async getTools() {
return [
// Your custom tools
];
}
}
Performance Optimization
- Use batch operations for multiple tracks
- Cache frequently used data
- Optimize Lua bridge calls
- Monitor with conversation tracking
Resources
Documentation
Support
- GitHub Issues
- Discord Community
- Email: support@reaper-chat.com