API Reference
This reference documentation provides detailed information about ThinkCode's APIs for developers who want to extend, customize, or integrate with the platform. ThinkCode exposes several core APIs that enable powerful interactions with the editor, AI systems, and extension framework.
ExMCP API
The ExMCP (Extended Machine Comprehension Protocol) API is the foundation of ThinkCode's AI integration capabilities. It provides a standardized way to communicate context, actions, and responses between the editor and AI systems.
Core Concepts
Concept | Description |
---|---|
Context Object | Container for all contextual information shared with AI systems |
Provider | Source of contextual information (e.g., file system, git history) |
Extension Point | Location where custom logic can be injected |
Message | Structured communication unit between components |
Key Interfaces
Context API
The Context API allows extensions to access and modify the context shared with AI systems:
Message API
The Message API enables communication between ThinkCode components:
Extension Points
ExMCP provides several extension points:
Extension Point | Description |
---|---|
context.provider | Register a new context provider |
context.transformer | Transform context before AI processing |
message.interceptor | Intercept and modify messages |
response.handler | Custom handling of AI responses |
VSCode Integration API
ThinkCode builds upon the VSCode API, extending it with additional capabilities while maintaining compatibility. This allows extensions to leverage both VSCode and ThinkCode-specific features.
Editor Integration
Document Management
ThinkCode-Specific Extensions
ThinkCode extends the VSCode API with additional capabilities:
Think Engine API
The Think Engine API provides access to ThinkCode's AI capabilities, allowing extensions to leverage machine learning models for various tasks.
Model Access
AI Tools
Custom AI Workflows
AI Context Management
Event System
ThinkCode provides a comprehensive event system to react to editor and AI actions:
Storage API
Extensions can persist data using ThinkCode's storage API:
Authentication and Security
API Versioning and Compatibility
ThinkCode APIs follow semantic versioning (SemVer) principles:
- Major version changes (X.0.0): Include breaking changes that require code updates
- Minor version changes (0.X.0): Add new features in a backward-compatible manner
- Patch version changes (0.0.X): Include bug fixes and non-breaking improvements
You can check the current API version and register for compatibility modes:
Common API Patterns
Promise-Based APIs
Most ThinkCode APIs that perform I/O operations return Promises:
Disposables
Resources that need to be cleaned up implement the Disposable pattern:
API Limitations and Best Practices
- Respect Rate Limits: AI operations may have rate limits to prevent abuse
- Batch Operations: Group multiple operations when possible
- Context Size: Be mindful of the context size when providing data to AI models
- Error Handling: Always handle errors gracefully, especially for network operations
- User Consent: Request only necessary permissions and respect user privacy
- Performance: Cache results when appropriate to reduce API calls