HelixCode is a sophisticated, enterprise-grade distributed AI development platform written in Go with support for multiple LLM providers, advanced reasoning capabilities, distributed worker management, MCP protocol support, and comprehensive task management. It implements cutting-edge AI features including prompt caching, extended thinking, vision capabilities, and streaming.
helix_code/
├── cmd/ # Application entry points
│ ├── server/main.go # REST API server (82 lines)
│ └── cli/main.go # CLI client (333 lines)
├── internal/ # Core packages
│ ├── llm/ # LLM providers (22 files)
│ ├── mcp/ # Model Context Protocol (3 files)
│ ├── task/ # Task management (7 files)
│ ├── workflow/ # Workflow engine (3 files)
│ ├── worker/ # Distributed workers (6 files)
│ ├── auth/ # Authentication (3 files)
│ ├── notification/ # Multi-channel notifications
│ ├── server/ # HTTP server & routes
│ ├── database/ # PostgreSQL layer
│ ├── redis/ # Caching layer
│ ├── config/ # Configuration management
│ ├── hardware/ # Hardware detection
│ └── event/ # Event system
├── config/ # YAML configuration
├── test/ # Test suites
│ ├── integration/
│ ├── automation/
│ └── e2e/
└── docs/ # Documentation
Module: dev.helix.code
Go Version: 1.24.0
- File:
/internal/llm/provider.go(lines 112-128) - Unified
Providerinterface for all LLM implementations - Supports multiple concurrent providers with fallback
- Key methods:
Generate(),GenerateStream(),IsAvailable(),GetHealth()
- File:
/internal/llm/model_manager.go - Intelligent model selection based on:
- Required capabilities (planning, code_generation, debugging, testing, refactoring, vision)
- Context window requirements
- Hardware compatibility
- Task-specific suitability
- Quality preferences (fast/balanced/quality)
- File:
/internal/task/manager.go - Priority-based task queue
- Dependency resolution (DAG execution)
- Checkpoint system for work preservation
- Status tracking (pending → assigned → running → completed/failed)
- Automatic retry with exponential backoff
- File:
/internal/worker/ssh_pool.go(lines 17-37) - SSH-based remote worker management
- Automatic Helix CLI installation on new workers
- Health monitoring with configurable intervals
- Resource tracking (CPU, memory, GPU)
- Capability-based task assignment
| Provider | File | Status | Models | Key Features |
|---|---|---|---|---|
| Anthropic Claude | anthropic_provider.go |
✓ Full | 11 models | Extended thinking, prompt caching, vision |
| Google Gemini | gemini_provider.go |
✓ Full | 11 models | 2M token context, multimodal, function calling |
| OpenAI | openai_provider.go |
✓ Full | 8+ models | Vision, function calling, reasoning (O1/O3) |
| Qwen | qwen_provider.go |
✓ Full | 4+ models | OAuth2 auth, Chinese models, free tier |
| xAI (Grok) | xai_provider.go |
✓ Full | 3 models | Fast inference, free models available |
| OpenRouter | openrouter_provider.go |
✓ Full | 40+ models | Multi-provider aggregation |
| GitHub Copilot | copilot_provider.go |
✓ Full | 4 models | GitHub token exchange, free with subscription |
| Local (Llama.cpp) | local_provider.go |
✓ Full | Dynamic | 100% offline, privacy-first |
| Ollama | ollama_provider.go |
✓ Full | Dynamic | Docker-based local models |
| Llama.cpp | llamacpp_provider.go |
✓ Full | Dynamic | Direct C++ integration |
File: /internal/llm/provider.go (lines 335-360)
type ProviderFactory struct{}
func (pf *ProviderFactory) CreateProvider(config ProviderConfigEntry) (Provider, error) {
switch config.Type {
case ProviderTypeAnthropic:
return NewAnthropicProvider(config)
// ... other providers
}
}File: /internal/llm/anthropic_provider.go (lines 86-90)
- Auto-detected from prompt keywords: "think", "reason", "analyze", "step by step"
- Allocates 80% of max_tokens to reasoning budget
- Temperature auto-adjusted to 1.0 for thinking mode
- Budget configurable via
anthropicThinkingConfig.Budget
File: /internal/llm/anthropic_provider.go (lines 48-70)
- System Message Caching: Ephemeral cache for system instructions
- Content Block Caching: Last user message cached with
cache_control: ephemeral - Tool Caching: Last tool definition automatically cached
- Cache metadata in response:
cache_creation_input_tokens: New cache creationcache_read_input_tokens: Cache hits
File: /internal/llm/anthropic_provider.go (lines 72-77)
type anthropicImageSource struct {
Type string // "base64", "url"
MediaType string // "image/jpeg", "image/png", etc.
Data string // base64 encoded
URL string
}File: /internal/llm/anthropic_provider.go
- SSE-based token-by-token streaming
- Tool call streaming support
- Usage tracking in final event
File: /internal/llm/gemini_provider.go
- Gemini 2.5 Pro: 2,097,152 tokens (2M tokens)
- Gemini 2.5 Flash: 1,048,576 tokens (1M tokens)
- Gemini 1.5 Pro: 2,097,152 tokens (2M tokens)
- Can process entire codebases in single request
File: /internal/llm/gemini_provider.go (lines 42-74)
type geminiTextPart struct {
Text string `json:"text"`
}
type geminiInlineDataPart struct {
InlineData *geminiBlob `json:"inlineData"`
}
type geminiBlob struct {
MimeType string // MIME type
Data string // base64 encoded
}File: /internal/llm/gemini_provider.go (lines 75-91)
type geminiTool struct {
FunctionDeclarations []geminiFunctionDeclaration `json:"functionDeclarations,omitempty"`
}
type geminiFunctionDeclaration struct {
Name string
Description string
Parameters map[string]interface{}
}File: /internal/llm/gemini_provider.go (lines 93-96)
- Configurable safety thresholds per category
- Content filtering controls
Free Providers (No API Key):
- XAI (Grok):
grok-3-fast-beta,grok-3-mini-fast-beta,grok-3-beta - OpenRouter:
deepseek-r1-free,meta-llama/llama-3.2-3b-instruct:free - GitHub Copilot:
gpt-4o,claude-3.5-sonnet,o1,gemini-2.0-flash(with GitHub subscription) - Qwen: OAuth2 authentication, 2,000 requests/day free tier
Premium Providers:
- Anthropic Claude: All models with 200K context + extended thinking
- Google Gemini: Up to 2M token context
- OpenAI: GPT-4.1, GPT-4.5 Preview, O1/O3 reasoning
- Qwen, xAI, OpenRouter: Various paid tiers
File: /internal/llm/tool_provider.go (lines 14-53)
type ToolGenerationRequest struct {
ID uuid.UUID
Prompt string
Tools []Tool
MaxTokens int
Temperature float64
Stream bool
Context map[string]interface{}
}
type EnhancedLLMProvider interface {
Provider
GenerateWithTools(ctx context.Context, req ToolGenerationRequest) (*ToolGenerationResponse, error)
StreamWithTools(ctx context.Context, req ToolGenerationRequest) (<-chan ToolStreamChunk, error)
ListAvailableTools() []Tool
RegisterTool(tool Tool) error
}Implementation:
- Tool detection from response content
- Tool execution with handler callbacks
- Multi-turn tool conversations
- Streaming tool chunks
- Tool registration system
File: /internal/llm/reasoning.go (lines 13-87)
Reasoning Types Supported:
chain_of_thought: Step-by-step reasoning with intermediate thoughtstree_of_thoughts: Multi-path explorationself_reflection: Reflexive thinkingprogressive: Progressive refinement
ReasoningEngine Features:
- Tool integration during reasoning steps
- Confidence scoring per step
- Multi-step execution with max steps control
- Tool result incorporation
- Final answer extraction
Example Usage:
type ReasoningRequest struct {
ID uuid.UUID
Prompt string
Tools []ReasoningTool
ReasoningType ReasoningType
MaxSteps int
Temperature float64
Context map[string]interface{}
}
type ReasoningResponse struct {
ID uuid.UUID
FinalAnswer string
ReasoningSteps []ReasoningStep
ToolsUsed []string
Duration time.Duration
Confidence float64
}File: /internal/mcp/server.go
Protocol Implementation:
- Version: 2024-11-05
- Transport: WebSocket with JSON-RPC
- Sessions: Per-connection session management with context
- Tool System: Centralized tool registry with permissions
Key Methods:
initialize: Protocol handshaketools/list: List all available toolstools/call: Execute tool with parametersnotifications/capabilities: Capability exchangeping: Keep-alive mechanism
Session Management (lines 26-33):
type MCPSession struct {
ID uuid.UUID
Conn *websocket.Conn
CreatedAt time.Time
LastActivity time.Time
UserID uuid.UUID
Context map[string]interface{}
}Tool Execution (lines 35-42):
type Tool struct {
ID string
Name string
Description string
Parameters map[string]interface{}
Handler ToolHandler
Permissions []string
}Broadcasting Capabilities:
BroadcastNotification(): Send to all active sessions- Support for experimental features
File: /internal/task/manager.go
Task Types:
TaskTypePlanning: Requirements analysis and breakdownTaskTypeBuilding: Code generation and integrationTaskTypeTesting: Unit, integration, E2E testsTaskTypeRefactoring: Code optimizationTaskTypeDebugging: Error diagnosis and fixesTaskTypeDesign: Architecture and designTaskTypeDiagram: Visual representationsTaskTypeDeployment: Release managementTaskTypePorting: Platform migration
Task Features:
- Priority Levels: Low (1), Normal (5), High (10), Critical (20)
- Status Tracking: pending → assigned → running → completed/failed
- Dependency Resolution: Task DAG execution
- Checkpointing: Work preservation at 300s intervals
- Retry Mechanism: Max 3 retries with exponential backoff
- Resource Management: Worker capability matching
Checkpoint System (lines in checkpoint.go):
- Automatic checkpoint creation
- Work recovery on failure
- Configurable checkpoint interval
File: /internal/workflow/workflow.go
Workflow Structure:
type Workflow struct {
ID string
Name string
Mode string
Steps []Step
Status WorkflowStatus
}
type Step struct {
ID string
Type StepType // analysis, generation, execution, validation
Action StepAction // analyze_code, generate_code, run_tests, etc.
Dependencies []string // For DAG execution
Status StepStatus // pending, running, completed, failed, skipped
}Workflow Types:
- Planning Mode: Analyze requirements, create specs, break into tasks
- Building Mode: Code generation, dependency management, integration
- Testing Mode: Unit, integration, E2E test execution
- Refactoring Mode: Code analysis, optimization, restructuring
- Debugging Mode: Error analysis, RCA, fix generation
- Deployment Mode: Build, package, deploy to targets
File: /internal/worker/ssh_pool.go
Worker Pool Capabilities:
- SSH-Based Remote Execution: Using
golang.org/x/crypto/ssh - Auto-Installation: Automatic Helix CLI deployment on new workers
- Health Monitoring: 30-second health check intervals
- Resource Detection: CPU, memory, GPU capabilities
- Task Assignment: Capability-based worker selection
- Connection Pooling: Persistent SSH connections
Worker Configuration (lines 12-29):
type WorkerConfig struct {
Enabled bool
Pool map[string]WorkerConfigEntry
AutoInstall bool
HealthCheckInterval int
MaxConcurrentTasks int
TaskTimeout int
}
type SSHWorker struct {
ID uuid.UUID
Hostname string
Capabilities []string
Resources Resources
Status WorkerStatus
HealthStatus WorkerHealth
}File: /internal/llm/model_manager.go
Model Capabilities:
CapabilityTextGeneration: General text outputCapabilityCodeGeneration: Code synthesisCapabilityCodeAnalysis: Code review and understandingCapabilityPlanning: Requirement analysisCapabilityDebugging: Error diagnosisCapabilityRefactoring: Code optimizationCapabilityTesting: Test generation and validationCapabilityVision: Image understanding
Intelligent Model Selection (lines 74-101):
type ModelSelectionCriteria struct {
TaskType string
RequiredCapabilities []ModelCapability
MaxTokens int
Budget float64
LatencyRequirement time.Duration
QualityPreference string // "fast", "balanced", "quality"
}
func (m *ModelManager) SelectOptimalModel(criteria ModelSelectionCriteria) (*ModelInfo, error)Scoring Factors:
- Capability matching (0-1.0)
- Context adequacy (up to 2.0x requirement)
- Task-specific suitability (1.1-1.3x for specialized models)
- Hardware compatibility (0.0-1.0)
- Quality preference (variable)
- Provider availability
File: /config/config.yaml
server:
address: "0.0.0.0"
port: 8080
read_timeout: 30
write_timeout: 30
idle_timeout: 60database:
host: "localhost"
port: 5432
user: "helixcode"
password: "" # Via HELIX_DATABASE_PASSWORD env var
dbname: "helixcode"
sslmode: "disable"llm:
default_provider: "local"
providers:
local: "http://localhost:11434"
openai: "" # Via env var
max_tokens: 4096
temperature: 0.7Channels Supported:
- Slack (webhook-based)
- Telegram (bot-based)
- Email (SMTP)
- Discord (webhook-based)
Example Rule:
rules:
- name: "Critical Task Failures"
condition: "type==error"
channels: ["slack", "email", "telegram"]
priority: urgent
enabled: trueDatabase:
HELIX_DATABASE_PASSWORD: PostgreSQL password
Authentication:
HELIX_AUTH_JWT_SECRET: JWT signing secret
Cache:
HELIX_REDIS_PASSWORD: Redis password (optional)
Providers:
ANTHROPIC_API_KEY: Anthropic ClaudeOPENAI_API_KEY: OpenAIGEMINI_API_KEYorGOOGLE_API_KEY: Google GeminiXAI_API_KEY: XAI (Grok)OPENROUTER_API_KEY: OpenRouterQWEN_API_KEY: Qwen (fallback to OAuth2)GITHUB_TOKEN: GitHub Copilot
Notifications:
HELIX_SLACK_WEBHOOK_URL: Slack integrationHELIX_TELEGRAM_BOT_TOKEN: Telegram botHELIX_TELEGRAM_CHAT_ID: Telegram chatHELIX_EMAIL_SMTP_SERVER: Email SMTPHELIX_DISCORD_WEBHOOK_URL: Discord
Anthropic Claude (provider.go implementation):
- Context: 200K tokens (all models)
- Max Output: 4K-50K depending on model
- Implementation: Automatic prompt caching reduces effective token usage by 70-90%
Google Gemini:
- Gemini 2.5 Pro: 2,097,152 tokens (2M)
- Gemini 2.5 Flash: 1,048,576 tokens (1M)
- Gemini 1.5 Pro: 2,097,152 tokens (2M)
- Max Output: 8K tokens
OpenAI:
- GPT-4.1: Up to 1,024K tokens
- GPT-4.5 Preview: Variable context
- O1/O3 Models: Up to 128K context
Local Models (via Llama.cpp/Ollama):
- Depends on model size and quantization
- Typically 4K-32K context window
- No token cost
File: /internal/llm/provider.go (lines 105-110)
type Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
}Enhanced Tracking (anthropic_provider.go):
type anthropicUsage struct {
InputTokens int
OutputTokens int
CacheCreationTokens int // New cache entries
CacheReadTokens int // Cache hits
}- Prompt Caching (Anthropic): Reuse context across requests
- Streaming: Token-by-token delivery reduces perceived latency
- Model Selection: Choose smallest sufficient model for task
- Checkpointing: Preserve state to avoid re-computation
File: /internal/llm/provider.go (lines 175-194)
func (pm *ProviderManager) RegisterProvider(provider Provider) error {
providerType := provider.GetType()
if _, exists := pm.providers[providerType]; exists {
return fmt.Errorf("provider %s already registered", providerType)
}
pm.providers[providerType] = provider
log.Printf("✅ LLM Provider registered: %s (%s)", provider.GetName(), providerType)
return nil
}All providers implement the Provider Interface (lines 112-128):
type Provider interface {
// Basic provider information
GetType() ProviderType
GetName() string
GetModels() []ModelInfo
GetCapabilities() []ModelCapability
// Core functionality
Generate(ctx context.Context, request *LLMRequest) (*LLMResponse, error)
GenerateStream(ctx context.Context, request *LLMRequest, ch chan<- LLMResponse) error
// Provider management
IsAvailable(ctx context.Context) bool
GetHealth(ctx context.Context) (*ProviderHealth, error)
Close() error
}Each provider implements request transformation:
Anthropic Example:
func (ap *AnthropicProvider) convertToAnthropicRequest(request *LLMRequest) (*anthropicRequest, error) {
// Transform generic LLMRequest to Anthropic-specific format
// Handle tool definitions, vision content, thinking config, etc.
}File: /internal/llm/provider.go (lines 215-244)
func (pm *ProviderManager) Generate(ctx context.Context, request *LLMRequest) (*LLMResponse, error) {
var provider Provider
var err error
// Use specified provider or default
if request.ProviderType != "" {
provider, err = pm.GetProvider(request.ProviderType)
} else {
provider, err = pm.GetDefaultProvider()
}
if err != nil {
return nil, fmt.Errorf("failed to get provider: %v", err)
}
return provider.Generate(ctx, request)
}File: /internal/llm/provider.go (lines 259-276)
func (pm *ProviderManager) GetProviderHealth(ctx context.Context) map[ProviderType]*ProviderHealth {
health := make(map[ProviderType]*ProviderHealth)
for providerType, provider := range pm.providers {
if healthStatus, err := provider.GetHealth(ctx); err == nil {
health[providerType] = healthStatus
}
}
return health
}ProviderHealth Structure (lines 142-149):
type ProviderHealth struct {
Status string // "healthy" or "unhealthy"
Latency time.Duration
LastCheck time.Time
ErrorCount int
ModelCount int
}File: /internal/llm/provider.go (lines 278-290)
func (pm *ProviderManager) FindProviderForCapabilities(capabilities []ModelCapability) []Provider {
var matching []Provider
for _, provider := range pm.GetAvailableProviders() {
providerCaps := provider.GetCapabilities()
if hasAllCapabilities(providerCaps, capabilities) {
matching = append(matching, provider)
}
}
return matching
}Unique Aspect: Multi-stage development workflow with AI assistance
- Analyzes code structure and requirements
- Generates implementation plans
- Executes changes with verification
- Provides explanations and documentation
Unique Aspect: SSH-based worker pool with auto-installation
- Deploy workers without pre-configuration
- Automatic capability detection
- Health-aware task distribution
- Resource-aware scheduling
Unique Aspect: Mix cloud and local models dynamically
- Free models for development
- Premium models for critical tasks
- Fallback chain with automatic provider switching
- Cost-optimized routing
Unique Aspect: Integrated caching for 70-90% cost reduction
- Automatic system message caching
- Last message caching
- Tool definition caching
- Provider-aware cache management
Unique Aspect: Pluggable reasoning for complex tasks
- Chain-of-thought reasoning
- Tool integration during reasoning
- Multi-step problem solving
- Confidence scoring
Unique Aspect: Rule-based multi-channel notifications
- 4 channel types (Slack, Telegram, Email, Discord)
- Condition-based routing
- Priority levels
- Event-driven architecture
Unique Aspect: Image understanding across multiple providers
- Anthropic Claude: All models support vision
- Google Gemini: Full multimodal support
- OpenAI: Vision-enabled models
- Base64 encoding, URL references, file upload paths
Unique Aspect: Automatic reasoning mode activation
- Detect complex queries
- Allocate 80% of tokens to thinking
- Temperature optimization
- Cost tracking for thinking budget
Unique Aspect: Full Model Context Protocol support
- WebSocket-based real-time communication
- Per-session tool execution
- Tool permission system
- Broadcast notifications
Unique Aspect: Interactive OAuth flow for free tier
- 2,000 requests/day free
- User authentication without API keys
- Token refresh mechanism
// HTTP Framework
"github.com/gin-gonic/gin"
// Database
"github.com/jackc/pgx/v5"
// Authentication
"github.com/golang-jwt/jwt/v4"
// Configuration
"github.com/spf13/viper"
// WebSocket
"github.com/gorilla/websocket"
// SSH Client
"golang.org/x/crypto/ssh"
// UUID Generation
"github.com/google/uuid"
// Testing
"github.com/stretchr/testify"- Standard: Linux, macOS, Windows
- Mobile: iOS (gomobile), Android
- Embedded: Aurora OS, Symphony OS (Russian platforms)
- Containers: Docker with Compose
Based on the analysis, these features provide the most value for a new AI coding platform:
- Multi-Provider LLM System: Supports 10+ providers with unified interface
- Tool Calling Framework: Extensible tool system with caching
- Reasoning Engine: Chain-of-thought with tool integration
- Task Management: Priority queue, dependencies, checkpoints
- Worker Pool: SSH-based distributed execution
- Prompt Caching: 70-90% cost reduction on repeated contexts
- Extended Thinking: Automatic reasoning mode for complex tasks
- Vision Support: Multi-provider image understanding
- MCP Protocol: Real-time tool execution protocol
- Workflow Engine: Multi-stage development workflows
- Hardware Detection: Optimize model selection for device capabilities
- Notification System: Multi-channel event notifications
- OAuth2 Integration: Interactive authentication flows
- Streaming: Token-by-token response delivery
| Feature | File | Lines | Key Functions |
|---|---|---|---|
| Provider Interface | provider.go |
361 | Provider, ProviderManager, ProviderFactory |
| Anthropic Claude | anthropic_provider.go |
400+ | Extended thinking, prompt caching, vision |
| Google Gemini | gemini_provider.go |
400+ | 2M token context, multimodal, function calling |
| Tool Calling | tool_provider.go |
404 | GenerateWithTools, StreamWithTools |
| Reasoning | reasoning.go |
332 | ReasoningEngine, multiple reasoning types |
| MCP Server | mcp/server.go |
383 | WebSocket handling, tool execution |
| Task Manager | task/manager.go |
200+ | Task queue, dependencies, retry logic |
| Worker Pool | worker/ssh_pool.go |
300+ | SSH management, auto-install, health checks |
| Model Manager | model_manager.go |
420 | Intelligent model selection, scoring |
| Configuration | config/config.yaml |
109 | Server, database, LLM, notification config |
make build # Build main server binary
make test # Run all tests
make prod # Cross-platform production builds
make mobile-ios # Build iOS framework
make mobile-android # Build Android AARdocker-compose up -d
# Includes: Server, PostgreSQL, Redis, Nginx, Prometheus, Grafana- Auth:
/api/auth/register,/api/auth/login,/api/auth/me - Tasks:
/api/tasks,/api/tasks/{id} - Workers:
/api/workers,/api/workers/{id} - Health:
/health - MCP:
/ws/mcp(WebSocket)
HelixCode is a production-ready, feature-rich AI development platform with:
✓ 10+ LLM provider support with advanced features
✓ Intelligent model selection based on capabilities
✓ Distributed worker management with auto-installation
✓ Prompt caching for 70-90% cost reduction
✓ Advanced reasoning with tool integration
✓ MCP protocol implementation
✓ Comprehensive task management with dependencies
✓ Multi-channel notifications
✓ Vision support across providers
✓ 100% offline local model support
The architecture emphasizes flexibility (plugin-based providers), scalability (distributed workers), cost-efficiency (caching, model selection), and reliability (health monitoring, task checkpoints).