The Deterministic AI Engineering Interface (DAEI) for the Agentic Era. Chroma-Coder is a high-performance terminal CLI for precise AI code generation, featuring auditable execution traces, composable pipes, and strict type safety across multi-model providers.
The Problem: AI coding tools often lack precision, auditability, and enterprise-grade reliability. Engineers need deterministic outputs, not black-box magic.
Our Solution: ChromaCoder provides:
- Deterministic AI Engineering - Type-safe, predictable code generation
- Auditable Execution - Complete traces of every AI interaction
- Production Resilience - Circuit breakers, retries, graceful degradation
- Multi-Provider Support - Works with Anthropic Claude and OpenRouter models
# Generate with full audit trail
chromacoder "Create a TypeScript API for user authentication"
# Output: Complete, type-safe code with execution trace
# Verify what was generated
chromacoder --trace last
# Shows: Prompt, model used, tokens consumed, and generated code hashResult: Enterprise-grade code generation with full provenance and reproducibility.
# Process multiple files with consistency
chromacoder --batch "refactor/*.ts" --template enterprise-pattern
# Applies consistent refactoring across codebase
# Generate verification report
chromacoder --report refactor-results.jsonResult: Scalable code transformations with guaranteed consistency and reporting.
# As part of your pipeline
name: AI Code Review
on: [push]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: ChromaCoder Review
run: |
chromacoder --review ./src --output review.json
chromacoder --verify-review review.jsonResult: Automated code review with deterministic, verifiable AI analysis.
- Type-Safe Generation - All outputs validated with Zod schemas
- Composable Pipes - Chain multiple AI operations predictably
- Hash Verification - Verify code integrity with SHA-256 fingerprints
- Execution Traces - Complete audit trail of all AI interactions
- Circuit Breakers - Prevent cascade failures during outages
- Exponential Backoff - Intelligent retry with 1s→2s→4s→8s progression
- Graceful Degradation - System continues operating during partial failures
- Structured Logging - Component-level logs with JSON/text output
- Anthropic Claude - Native support for Claude models
- OpenRouter - Access to 100+ models including GPT-4, Llama, Mixtral
- Auto-Detection - Intelligent provider selection based on availability
- Model Switching - Change models mid-session without losing context
- 92.83% Test Coverage - Comprehensive test suite with 256 passing tests
- Performance Metrics - Token usage, latency, success rates
- Error Tracking - Structured error reporting with context
- Session Analytics - Track patterns and optimize usage
Prerequisites: Node.js 18+, pnpm 8+
See Installation below for setup instructions.
# Start a conversation
pnpm start
# Or use headless mode for scripting
pnpm start --headless "Create a REST API with TypeScript and Express"
# With specific model and parameters
pnpm start --headless "Build a React component" \
--model claude-3-5-sonnet-20241022 \
--max-tokens 2000 \
--temperature 0.1# Clone and install
git clone https://github.com/Ethical-AI-Syndicate/chroma-coder
cd chroma-coder
pnpm install
# Configure your API keys
cp .env.example .env
# Edit .env with your preferred provider
# Build and run
pnpm build
pnpm start- Node.js 18+
- pnpm 8+
- API key for Anthropic or OpenRouter
# Copy example environment file
cp .env.example .envEdit .env with your API keys:
# Anthropic API Key (https://console.anthropic.com/)
ANTHROPIC_API_KEY=sk-ant-...
# OR OpenRouter API Key (https://openrouter.ai/)
OPENROUTER_API_KEY=sk-or-...
# Optional: Specify model
CHROMA_MODEL=claude-3-5-sonnet-20241022
# Optional: Configure logging
LOG_LEVEL=info # debug | info | warn | error
LOG_FORMAT=text # text | json┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Terminal UI │ │ Core Engine │ │ AI Providers │
│ │ │ │ │ │
│ • Ink React │───▶│ • Sessions │───▶│ • Anthropic │
│ • History │ │ • Validation │ │ • OpenRouter │
│ • Shortcuts │ │ • Retry Logic │ │ • Custom APIs │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ State Mgmt │ │ Persistence │ │ Monitoring │
│ │ │ │ │ │
│ • Redux-like │ │ • File Storage │ │ • Structured │
│ • Immutable │ │ • History │ │ Logging │
│ • Traceable │ │ • Snapshots │ │ • Metrics │
└─────────────────┘ └──────────────────┘ └─────────────────┘
| Variable | Required | Default | Description |
|---|---|---|---|
ANTHROPIC_API_KEY |
No* | - | Anthropic API key for Claude models |
OPENROUTER_API_KEY |
No* | - | OpenRouter API key for various models |
CHROMA_MODEL |
No | Auto-detected | Model to use (e.g., claude-3-5-sonnet-20241022) |
LOG_LEVEL |
No | info |
Logging level: debug, info, warn, error |
LOG_FORMAT |
No | text |
Log output format: text or json |
NO_COLOR |
No | - | Set to 1 to disable colored output |
*At least one API key is required
The application automatically detects which LLM provider to use:
# Prefer Anthropic if available
ANTHROPIC_API_KEY=sk-ant-... pnpm start
# Fall back to OpenRouter
OPENROUTER_API_KEY=sk-or-... pnpm start
# Override with specific model
CHROMA_MODEL=anthropic/claude-3-opus-20240229 pnpm startChain multiple AI operations:
import { chromacoder } from 'chroma-coder';
const pipeline = chromacoder
.pipe('analyze-code', { language: 'typescript' })
.pipe('generate-tests', { coverage: '90%' })
.pipe('optimize-performance', { target: 'sub-100ms' });
await pipeline.execute('./src/component.ts');Verify and audit AI interactions:
# View last execution trace
pnpm chromacoder --trace last
# Export trace for compliance
pnpm chromacoder --export-trace audit-2024-Q1.json
# Verify code integrity
pnpm chromacoder --verify ./src --algorithm sha256Process multiple files with consistency:
# Refactor entire directory
pnpm chromacoder --batch refactor ./src --pattern "*.ts" \
--template enterprise-pattern --output ./refactored
# Generate documentation
pnpm chromacoder --batch docs ./src --format markdown \
--output ./documentationCircuit Breaker Pattern
- Opens after 5 consecutive failures
- Prevents thundering herd during outages
- Automatic recovery after 60-second timeout
- Half-open state for testing recovery
Retry with Exponential Backoff
- Automatic retry on network failures and 5xx errors
- Exponential backoff: 1s → 2s → 4s → 8s (max 10s)
- Configurable max attempts (default: 3)
- Structured logging of all retry attempts
Graceful Degradation
- API failures don't crash the application
- User-friendly error messages with troubleshooting tips
- Conversation state preserved across failures
- Errors added to conversation history for debugging
Runtime Type Validation with Zod
- All API requests validated before sending
- All API responses validated before processing
- Clear validation error messages with context
- Type-safe data flows throughout application
Validated Components
- LLM completion requests (messages, tokens, temperature)
- API responses (content, usage, model)
- Configuration (provider, API keys, model names)
- Generated code (syntax, type checking)
Structured Logging System
- Multiple log levels:
debug,info,warn,error - Component-specific loggers with context
- Nested logger support for complex workflows
- Configurable output formats (colored console, JSON)
- Environment-aware configuration
Performance Metrics
- Token usage tracking per model and session
- Latency measurements with percentiles
- Success/failure rates by operation type
- Resource utilization (memory, CPU)
| Component | Coverage | Tests |
|---|---|---|
| Core Conversation | 100% | 15 tests |
| Session Processor | 98.87% | 23 tests |
| Retry Utility | 96.99% | 32 tests |
| Logger | 100% | 43 tests |
| LLM Clients | 95%+ | 45 tests |
| UI State | 97.98% | 45 tests |
| Overall | 92.83% | 256 tests |
# Run all tests
pnpm test
# Run with coverage report
pnpm test:coverage
# Run specific test file
pnpm test retry.test.ts
# Watch mode for development
pnpm test:watchchroma-coder/
├── src/
│ ├── adapters/ # External adapters
│ │ ├── env/ # Environment configuration
│ │ ├── filesystem/ # File I/O operations
│ │ └── network/ # LLM client implementations
│ ├── cli/ # Command-line interface
│ ├── core/ # Core business logic
│ │ ├── conversation/ # Conversation management
│ │ ├── session/ # Session processing
│ │ ├── utils/ # Utilities (retry, logger)
│ │ └── validation/ # Zod schemas
│ ├── tui/ # Terminal UI components (Ink/React)
│ ├── ui-state/ # State management
│ └── domain/ # Domain types
├── tests/
│ └── unit/ # Unit tests
├── docs/ # Additional documentation
└── dist/ # Compiled output
# Development mode with auto-reload
pnpm dev
# Run tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Run tests in watch mode
pnpm test:watch
# Build for production
pnpm build
# Type checking
pnpm type-check
# Lint code
pnpm lint
# Format code
pnpm formatChromaCoder follows clean architecture principles:
- Domain Layer - Pure business logic and types
- Core Layer - Application logic (conversation, session management)
- Adapters Layer - External integrations (LLM clients, file I/O)
- UI Layer - Terminal interface (Ink components)
Key patterns:
- Dependency Injection - LLM clients injected into session processor
- Adapter Pattern - Unified interface for multiple LLM providers
- Factory Pattern - LLM client factory for provider selection
- State Management - Redux-like reducer pattern for UI state
- ❌ Not a Web IDE - Terminal-first design for developer efficiency
- ❌ Not a Magic Tool - Deterministic, verifiable code generation
- ❌ Not Language Specific - Works with any programming language
- ❌ Not Closed Source - MIT license with full transparency
# Fork and clone
git clone https://github.com/your-username/chroma-coder
cd chroma-coder
# Install dependencies
pnpm install
# Start development
pnpm dev
# Run tests
pnpm test
# Build for production
pnpm build- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Write tests for new functionality
- Ensure tests pass (
pnpm test) - Check code coverage (
pnpm test:coverage) - Format code (
pnpm format) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- TypeScript - Strict mode enabled
- Test Coverage - Maintain >90% coverage
- ESLint - Follow existing linting rules
- Prettier - Use project formatting config
- Conventional Commits - Use semantic commit messages
- Unit tests for all new features
- Minimum 80% coverage for new code
- All existing tests must pass
- Integration tests for API interactions (when applicable)
API Key Not Found
Error: OpenRouter client not configured
Solution: Ensure API key is set in .env file or environment variable
Network Timeouts
- Application automatically retries with exponential backoff
- Check internet connection
- Verify API service status
Model Not Found
Error: Model 'xyz' not found
Solution: Check model name is correct for your provider
- Anthropic:
claude-3-5-sonnet-20241022,claude-3-opus-20240229 - OpenRouter:
anthropic/claude-3-5-sonnet,openai/gpt-4
Import Errors
Error: Cannot find module
Solution: Run pnpm install and pnpm build
Enable debug logging to troubleshoot issues:
LOG_LEVEL=debug pnpm startThis outputs detailed information about:
- API requests and responses
- Retry attempts
- Validation errors
- Internal state changes
- Integration tests for LLM providers
- End-to-end tests for user workflows
- Transactional session storage with rollback
- Multi-turn conversation optimization
- Streaming response support in TUI
- Plugin system for custom commands
- Configuration file support (
.chromacoderrc) - Session export/import functionality
MIT License - see LICENSE file for details
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Full Docs
- Ethical AI Syndicate: aisyndicate.io
Built by Ethical AI Syndicate - Creating deterministic, auditable AI engineering tools.