Status: Published Last Updated: 2025-08-10 Category: Developer Guide
This guide provides comprehensive documentation for developers contributing to Thea Code or extending its functionality.
- Contributing Guide - How to contribute to Thea Code
- Development Setup - Set up your development environment
- Project Structure - Understanding the codebase
- Architecture Overview - System design and components
- Neutral Client Architecture - Provider abstraction layer
- API Handlers - API integration patterns
- MCP System - Model Context Protocol implementation
- Webview Architecture - UI and state management
- Extension API - Public API for extensions
- Provider API - Creating custom providers
- Tool API - Implementing custom tools
- Types & Interfaces - TypeScript definitions
- Testing Guide - Comprehensive testing documentation
- Unit Tests - Writing and running unit tests
- Integration Tests - Provider and system testing
- Benchmarks - Performance testing
- Migration Guide - Upgrading from older versions
- Dynamic Models Migration - Model system updates
- Node.js 18+ and npm 9+
- VSCode 1.85.0+
- Git
- Docker (for benchmarks)
- Clone the repository
git clone https://github.com/SolaceHarmony/Thea-Code.git
cd Thea-Code- Install dependencies
npm install- Build the extension
npm run build- Run in development mode
npm run watch- Launch VSCode with extension
Press
F5in VSCode or:
code --extensionDevelopmentPath=.- Create a feature branch
git checkout -b feature/your-feature- Make changes and test
npm run test
npm run lint- Build and verify
npm run build
npm run package- Submit pull request
- Follow PR template
- Ensure tests pass
- Update documentation
Thea-Code/
├── src/ # Source code
│ ├── api/ # API providers and handlers
│ ├── core/ # Core functionality
│ ├── services/ # Service layer (MCP, browser, etc.)
│ ├── integrations/ # VSCode integrations
│ ├── shared/ # Shared utilities
│ └── extension.ts # Extension entry point
├── webview-ui/ # React webview application
│ ├── src/
│ │ ├── components/ # UI components
│ │ ├── context/ # React context
│ │ └── App.tsx # Main app component
├── test/ # Test infrastructure
│ ├── generic-provider-mock/
│ ├── mcp-mock-server/
│ └── openai-mock/
├── docs/ # Documentation
├── benchmark/ # Performance benchmarks
└── package.json # Project configuration
- BaseProvider - Abstract provider class
- Provider implementations - Anthropic, OpenAI, Ollama, etc.
- Transform utilities - Message format conversion
- TheaTask - Task management
- Tool system - Tool definitions and execution
- Prompt system - System prompts and instructions
- Configuration - Settings and mode management
- MCP - Model Context Protocol implementation
- Browser - Browser automation
- Terminal - Terminal integration
- Checkpoints - State management
- React components - Chat, settings, history
- State management - Extension state context
- Communication - Message passing with extension
- TypeScript - Use TypeScript for all new code
- ESLint - Follow project ESLint configuration
- Prettier - Auto-format with Prettier
- Naming - Use descriptive, consistent naming
- Type Safety
// ✅ Good - Explicit types
interface ToolResult {
success: boolean;
output?: string;
error?: Error;
}
// ❌ Bad - Any type
function processTool(result: any) { }- Error Handling
// ✅ Good - Proper error handling
try {
const result = await riskyOperation();
return { success: true, data: result };
} catch (error) {
logger.error('Operation failed', error);
return { success: false, error };
}- Async/Await
// ✅ Good - Clean async/await
const data = await fetchData();
const processed = await processData(data);
// ❌ Bad - Callback hell
fetchData((data) => {
processData(data, (processed) => {
// ...
});
});- Unit tests for all utilities and pure functions
- Integration tests for API providers
- E2E tests for critical user flows
- Minimum 80% code coverage
- JSDoc comments for public APIs
- README files for new features
- Update existing docs when changing behavior
- Include examples in documentation
- Create provider class extending
BaseProvider - Implement required methods
- Add tests in
__tests__directory - Update provider factory
- Document in user guide
See Provider Implementation Guide
- Define tool in
src/core/tools/ - Add tool schema
- Implement tool handler
- Register in tool system
- Add tests
- Edit components in
webview-ui/src/components/ - Update styles if needed
- Test in different themes
- Ensure accessibility
- Set breakpoints in VSCode
- Press
F5to launch debug session - Use Debug Console for output
- Check Extension Host logs
- Open Developer Tools:
Ctrl/Cmd + Shift + P→ "Developer: Toggle Developer Tools" - Navigate to Console tab
- Use React DevTools if installed
- Module not found - Run
npm install - Build errors - Check TypeScript errors with
npm run typecheck - Test failures - Run specific test with
npm test -- [test-name] - Port conflicts - Check for running servers
- Version bump
npm version patch|minor|major- Update CHANGELOG.md
- Add version section
- List changes
- Credit contributors
- Create release PR
- Follow PR template
- Ensure CI passes
- Publish
npm run package
vsce publishFor development questions:
- Check this guide and related documentation
- Search existing GitHub Issues
- Ask in the Discord #development channel
Changelog:
- 2025-08-10: Initial comprehensive developer guide