Enterprise-Grade AI Orchestration System with Smart Query Routing and Multi-Agent Intelligence
Monk CLI is a revolutionary command-line interface that combines Intelligent Query Routing with the power of multiple AI agents through the TreeQuest engine. This system automatically routes your queries to the optimal AI provider based on query type, complexity, cost, and performance requirements, providing enterprise-grade AI capabilities with unmatched efficiency.
- π§ Intelligent Query Routing: Smart routing to optimal AI providers based on query analysis
- π€ Multi-Agent AI System: Planner, Analyzer, Critic, Synthesizer, and Executor agents
- π§ TreeQuest Engine: Adaptive Branching Monte Carlo Tree Search for LLM orchestration
- π° Cost Optimization: Real-time cost tracking and intelligent model selection
- π Enhanced Analytics: Cross-tool intelligence and correlation
- π High Performance: Async processing with intelligent caching
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Monk CLI β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Planner β β Analyzer β β Critic β β
β β Agent β β Agent β β Agent β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
β β Synthesizer β β Executor β β Simulator β β
β β Agent β β Agent β β Agent β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β TreeQuest Engine β
β (Adaptive Branching MCTS) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Model Registry β
β (Multi-Provider AI Models) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Monk CLI's Intelligent Query Routing system automatically analyzes your queries and routes them to the optimal AI provider, ensuring the best performance, cost efficiency, and results for every interaction.
-
Query Analysis: Analyzes query type, complexity, and requirements
-
Provider Selection: Evaluates available AI providers based on:
- Query Type: Code analysis, planning, critique, synthesis
- Complexity: Simple vs. complex multi-step tasks
- Cost: Token usage and provider pricing
- Performance: Response time and quality requirements
- Specialization: Provider strengths for specific tasks
-
Smart Routing: Routes to the optimal provider using advanced algorithms
-
Fallback Handling: Automatically switches providers if needed
| Query Type | Optimal Provider | Reasoning |
|---|---|---|
| Code Analysis | Claude-3-Sonnet | Superior code understanding |
| Planning Tasks | GPT-4o | Excellent strategic thinking |
| Creative Writing | Claude-3-Opus | Best creative capabilities |
| Quick Answers | GPT-4o-mini | Fast, cost-effective |
| Complex Reasoning | Claude-3-Opus | Deep analytical thinking |
| TreeQuest Tasks | Multi-Agent | Orchestrated AI collaboration |
- Real-time Cost Tracking: Monitor token usage and costs
- Provider Selection: Choose cost-effective providers for simple tasks
- Quality vs. Cost: Balance between performance and expense
- Usage Analytics: Track spending patterns and optimize usage
- Python 3.8+
- Git
- OpenAI API key (or other AI provider keys)
# Clone the repository
git clone https://github.com/Das-rebel/monk-cli.git
cd monk-cli
# Install dependencies
pip install -r requirements.txt
# Set up your API keys
export OPENAI_API_KEY="your-api-key-here"
export ANTHROPIC_API_KEY="your-anthropic-key-here"
export GOOGLE_API_KEY="your-google-key-here"
# Run the enhanced CLI
python3 monk.py --treequest /agents# Show all available AI agents
monk --treequest /agents
# Create execution plan (automatically routed to best planning provider)
monk --treequest /plan objective="Improve project security"
# Run comprehensive analysis (intelligently routed for optimal performance)
monk --treequest /deep-analyze path=src/ depth=comprehensive
# Interactive mode with intelligent routing
monk --treequest --chat# Simple query - automatically routed to cost-effective provider
monk "What is Python?"
# Complex analysis - routed to high-performance provider
monk "Analyze this codebase for security vulnerabilities and suggest improvements"
# Planning task - routed to strategic thinking provider
monk "Create a project roadmap for implementing microservices architecture"
# Code review - routed to code-specialized provider
monk "Review this Python function for best practices and optimization"- Purpose: Strategic planning and roadmap creation
- Capabilities: Long-term planning, resource allocation, timeline management
- Use Cases: Project planning, architecture design, strategic decision making
- Purpose: Data analysis and insight generation
- Capabilities: Code analysis, performance profiling, dependency analysis
- Use Cases: Code review, performance optimization, security auditing
- Purpose: Quality assessment and improvement suggestions
- Capabilities: Code quality evaluation, best practices review, risk assessment
- Use Cases: Code review, quality assurance, compliance checking
- Purpose: Combining and summarizing insights
- Capabilities: Cross-tool correlation, insight synthesis, recommendation generation
- Use Cases: Project overview, decision support, stakeholder communication
- Purpose: Implementation and execution planning
- Capabilities: Action planning, implementation strategies, execution tracking
- Use Cases: Task execution, automation planning, workflow optimization
The system supports multiple AI providers:
# config/treequest.yaml
models:
gpt-4o:
provider: openai
capabilities: [planner, analyzer, critic, synthesizer, executor, simulator]
quality_score: 0.95
cost_per_1k_tokens: 0.005
claude-3-opus:
provider: anthropic
capabilities: [planner, analyzer, critic, synthesizer, executor, simulator]
quality_score: 0.98
cost_per_1k_tokens: 0.015# Required
export OPENAI_API_KEY="your-openai-key"
# Optional
export ANTHROPIC_API_KEY="your-anthropic-key"
export GOOGLE_API_KEY="your-google-key"
export MISTRAL_API_KEY="your-mistral-key"monk --treequest /plan objective="Implement microservices architecture"Output:
π **Execution Plan Generated**
**Objective**: Implement microservices architecture
**Timeline**: 6-8 weeks
**AI Agent Metrics**
β’ Confidence: 0.85
β’ Cost: $0.0750
β’ Execution time: 0.42s
β’ Agent used: planner
monk --treequest /deep-analyze path=src/ depth=comprehensiveOutput:
π¬ **Deep Analysis Results**
**Target**: src/
**Depth**: comprehensive
**Agents Used**: all
**AI Performance**
β’ Total iterations: 32
β’ Max depth explored: 3
β’ Final cost: $0.0703
β’ Execution time: 0.36s
β’ Agent used: synthesizer
monk --treequest /critique path=src/ focus="security and performance"monk-cli/
βββ src/
β βββ ai/
β β βββ treequest_engine.py # TreeQuest AI orchestration
β β βββ model_registry.py # AI model management
β βββ core/
β β βββ intelligent_router.py # π§ Intelligent Query Routing
β β βββ slash_command_processor.py # Enhanced slash commands
β β βββ conversation_manager.py # Conversation management
β β βββ project_context_loader.py # Project context
β βββ analyzers/
β β βββ analyzer_coordinator.py # Analysis orchestration
β β βββ github_analyzer.py # GitHub analysis
β β βββ docker_optimizer.py # Docker optimization
β β βββ npm_manager.py # NPM package analysis
β βββ ui/
β βββ rich_interface.py # Rich terminal interface
βββ config/
β βββ treequest.yaml # TreeQuest configuration
βββ monk.py # Main CLI entry point
βββ treequest_demo.py # Demo script
βββ requirements.txt # Python dependencies
βββ setup_github.sh # GitHub setup automation
βββ docs/ # Documentation
Monk CLI's routing system automatically determines the best AI provider for each query:
- Automatic Provider Selection: Routes queries to optimal AI providers
- Cost-Aware Routing: Balances quality and cost for each task
- Performance Optimization: Selects providers based on speed requirements
- Specialization Matching: Routes to providers best suited for specific tasks
- Fallback Handling: Automatically switches providers if needed
The TreeQuest engine coordinates multiple AI agents:
- Planner Agent: Creates strategic execution plans
- Analyzer Agent: Performs deep code and project analysis
- Critic Agent: Provides quality assurance and feedback
- Synthesizer Agent: Combines insights from multiple sources
- Executor Agent: Implements suggested changes and optimizations
- Real-time cost tracking per query
- Intelligent model selection based on cost/quality trade-offs
- Automatic fallback to cost-effective alternatives
- Execution time tracking
- Agent usage statistics
- Model performance metrics
- Cost analysis and optimization
# Test simple query routing
monk "What is the capital of France?"
# Test complex analysis routing
monk "Analyze this project structure and suggest improvements"
# Test planning task routing
monk "Create a development timeline for this feature"
# Test code review routing
monk "Review this function for best practices"# Test AI agents
monk --treequest /agents
# Test planning
monk --treequest /plan objective="Test planning"
# Test analysis
monk --treequest /deep-analyze path=. depth=deep
# Test interactive mode
monk --treequest --chat- Planning Tasks: 0.35-0.40s execution, $0.0600 cost
- Deep Analysis: 0.35-0.40s execution, $0.0703 cost
- Complex Queries: 1.8-2.2s execution, $0.000059 cost
- Agent Response: <100ms for simple queries
- Supports up to 10+ AI providers simultaneously
- Handles complex multi-agent workflows
- Efficient memory and resource management
- Async processing for concurrent operations
We welcome contributions! Please see our Contributing Guide for details.
# Clone and setup
git clone https://github.com/Das-rebel/monk-cli.git
cd monk-cli
# Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -r requirements-dev.txt
# Run tests
python -m pytest tests/This project is licensed under the MIT License - see the LICENSE file for details.
- TreeQuest Engine: Advanced AI orchestration system
- OpenAI: GPT-4 and GPT-4o models
- Anthropic: Claude models
- Google: Gemini models
- Mistral AI: Mistral models
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Wiki
- Phase 1: Core TreeQuest integration β
- Phase 2: Enhanced agent capabilities β
- Phase 3: Advanced routing and optimization β
- Phase 4: Multi-language support
- Phase 5: Cloud deployment and scaling
- Phase 6: Enterprise features and integrations
Made with β€οΈ by the Smart AI Team
Transform your CLI experience with the power of AI agents!