# Unified Agent Integration for Claude Code CLI

Complete integration of **Prometheus**, **Every Code**, and **Dexto** - three powerful AI agent platforms - into Claude Code CLI.

## Overview

This integration brings together the strengths of three major AI agent platforms:

| Platform | Strength | Best For |
|----------|----------|----------|
| **Prometheus** | Deep code understanding with knowledge graphs | Bug fixing, semantic search, regression testing |
| **Every Code** | Fast execution with Auto Drive | Rapid development, browser automation, multi-agent tasks |
| **Dexto** | Agent orchestration and session management | Complex workflows, custom agents, tool composition |

## Quick Start

### Automated Setup (Recommended)

```bash
# Run the setup script
bash /tmp/unified-agents-setup.sh

# Or download and run
wget https://raw.githubusercontent.com/your-org/unified-agents/main/setup.sh
bash setup.sh
```

### Manual Setup

See [COMPLETE-INTEGRATION.md](COMPLETE-INTEGRATION.md) for detailed manual setup instructions.

## Available Skills

### Core Skills

| Skill | Description | Primary Backend |
|-------|-------------|-----------------|
| `/agent-plan` | Generate implementation plans | Every Code |
| `/agent-fix-bug` | Fix bugs end-to-end | Prometheus |
| `/agent-solve` | Solve complex problems | Every Code |
| `/agent-review` | Review code quality | Every Code |
| `/agent-context` | Get code context | Prometheus |
| `/agent-orchestrate` | Orchestrate workflows | Dexto |

## Ralph Auto-Integration

The unified agents are **automatically triggered** when using `/ralph`. See [RALPH-AUTO-INTEGRATION.md](RALPH-AUTO-INTEGRATION.md) for details.

### Quick Examples with Ralph

```bash
# Auto-triggers Prometheus for bug fixing
/ralph "fix the authentication bug"

# Auto-triggers Every Code for planning
/ralph "plan and implement user notifications"

# Auto-triggers Dexto for orchestration
/ralph "orchestrate a complete CI/CD pipeline"

# Multi-platform: All agents activate
/ralph "audit, fix, and test all security issues"
```

**Pattern-Based Auto-Trigger:**
- **Prometheus**: "fix bug", "debug", "test failure", "regression"
- **Every Code**: "plan feature", "solve problem", "review code"
- **Dexto**: "orchestrate workflow", "coordinate agents", "multi-step"

## Usage Examples

### Bug Fixing

```
You: /agent-fix-bug "Users can't delete their accounts"

Claude: I'll use Prometheus to fix this bug.

✓ Issue classified as: bug
✓ Bug reproduced in Docker container
✓ Retrieved context from 12 related files
✓ Generated patch for UserService.deleteAccount
✓ Applied patch with git
✓ All 15 tests passing
✓ Regression tests verified

The bug has been fixed. The issue was a missing null check in the deleteAccount method.
```

### Feature Planning

```
You: /agent-plan "Add real-time notifications with WebSocket"

Claude: I'll generate a plan using Every Code with context from Prometheus.

## Implementation Plan

### Phase 1: Backend Setup (2 hours)
- Install WebSocket dependencies
- Create WebSocket server
- Implement connection management

### Phase 2: Frontend Integration (3 hours)
- Create WebSocket client service
- Add notification components
- Implement reconnection logic

### Phase 3: Testing (2 hours)
- Unit tests for WebSocket handlers
- Integration tests
- Load testing

Total estimated time: 7 hours

Would you like me to implement this plan with /agent-implement?
```

### Multi-Agent Orchestration

```
You: /agent-orchestrate "Audit, fix, and test all authentication issues"

Claude: I'll orchestrate a multi-agent workflow using Dexto.

## Workflow: Authentication Audit & Fix

### Agent 1: Prometheus - Code Audit
Found 3 authentication issues:
1. Missing rate limiting on login
2. Weak password requirements
3. No session timeout

### Agent 2: Every Code - Implement Fixes
Applied fixes for all 3 issues
Running tests...

### Agent 3: Every Code - Auto Review
Quality checks passed
No regressions detected

## Results
✓ 3 issues fixed
✓ 47 tests passing
✓ Code review complete
✓ Documentation updated
```

## Backend Selection

The integration automatically selects the best backend for each task:

```
┌─────────────────────┬─────────────┬─────────────┬─────────────┐
│ Task                │ Prometheus  │ Every Code  │ Dexto       │
├─────────────────────┼─────────────┼─────────────┼─────────────┤
│ Bug fixing          │ ✅ Primary   │ ✅ Review   │ ✅ Orchest. │
│ Code planning       │ ✅ Context   │ ✅ Primary  │ ✅ Custom   │
│ Problem solving     │ ✅ Analysis  │ ✅ Primary  │ ✅ Workflow │
│ Code review         │ ✅ AST       │ ✅ Primary  │             │
│ Context retrieval   │ ✅ Primary   │             │ ✅ Memory   │
│ Orchestration       │             │ ✅ Auto Dr. │ ✅ Primary  │
│ Semantic search     │ ✅ Primary   │ ✅ Grep     │             │
│ Browser automation  │             │ ✅ Primary  │ ✅ Tools    │
└─────────────────────┴─────────────┴─────────────┴─────────────┘
```

## MCP Tools

### Prometheus Tools

- `prometheus_find_file` - Find files by basename
- `prometheus_search_code` - Search code using AST
- `prometheus_search_ast` - Search by node type
- `prometheus_classify_issue` - Classify GitHub issues
- `prometheus_fix_bug` - End-to-end bug fixing
- `prometheus_run_tests` - Run tests in Docker

### Every Code Tools

- `everycode_auto_drive` - Orchestrate multi-agent tasks
- `everycode_plan` - Generate implementation plans
- `everycode_solve` - Coordinate multiple agents
- `everycode_auto_review` - Background code review
- `everycode_browser_*` - Browser automation

### Dexto Tools

- `dexto_create_agent` - Create custom agents
- `dexto_run_agent` - Run configured agents
- `dexto_orchestrate` - Orchestrate workflows
- `dexto_mcp_*` - MCP client operations
- `dexto_memory_*` - Memory management

## Architecture

```
┌─────────────────────────────────────────────────────────────┐
│                    Claude Code CLI                          │
│  ┌──────────────────────────────────────────────────────┐  │
│  │              Unified Agent Skills                    │  │
│  │  /agent-plan | /agent-fix-bug | /agent-solve       │  │
│  └────────────────────────┬─────────────────────────────┘  │
│                           │ MCP Client                      │
└───────────────────────────┼─────────────────────────────────┘
                            │
┌───────────────────────────┼─────────────────────────────────┐
│              Unified Agent MCP Server                       │
│  ┌────────────────────────────────────────────────────────┐ │
│  │              Intelligent Router                         │ │
│  │        Routes to best backend per task                │ │
│  └────┬──────────────┬──────────────┬────────────────────┘ │
│       │              │              │                         │
│  ┌────▼────┐   ┌────▼────┐   ┌────▼────┐                    │
│  │Prometheus│   │Every Code│   │ Dexto   │                    │
│  │ Knowledge│   │ Auto Drive│  │ Harness │                    │
│  │   Graph  │   │  Browser  │  │   MCP   │                    │
│  │   AST    │   │  Multi    │  │ Session │                    │
│  │ LangGraph│   │  Agent    │  │  Tools  │                    │
│  └─────────┘   └───────────┘   └─────────┘                    │
└─────────────────────────────────────────────────────────────┘
```

## Documentation

- [COMPLETE-INTEGRATION.md](COMPLETE-INTEGRATION.md) - Full integration guide
- [UNIFIED-INTEGRATION.md](UNIFIED-INTEGRATION.md) - Prometheus + Every Code integration
- [INTEGRATION-DESIGN.md](prometheus/INTEGRATION-DESIGN.md) - Prometheus design

## Requirements

- Python 3.11+
- Node.js 20+
- Rust + Cargo
- Docker + Docker Compose (for Prometheus)
- Neo4j (for Prometheus knowledge graph)
- API keys (OpenAI, Anthropic, or Gemini)

## Installation Paths

| Component | Location |
|-----------|----------|
| Install directory | `~/UnifiedAgents/` |
| Prometheus | `~/UnifiedAgents/Prometheus/` |
| Every Code | `~/UnifiedAgents/EveryCode/` |
| Dexto | `~/UnifiedAgents/Dexto/` |
| Claude Code skills | `~/.config/claude-code/skills/agents/` |

## Troubleshooting

### Prometheus: "Neo4j connection failed"
```bash
cd ~/UnifiedAgents/Prometheus
docker-compose up -d neo4j
```

### Every Code: "Not authenticated"
```bash
code
# Follow authentication prompts
```

### Dexto: "Config file not found"
```bash
cp ~/UnifiedAgents/Dexto/config.example.yaml ~/UnifiedAgents/Dexto/config.yaml
# Edit config.yaml with your settings
```

### MCP servers not found
```bash
# Verify Claude Code config
cat ~/.config/claude-code/config.json

# Restart Claude Code
```

## Contributing

Contributions welcome! Please see [DEVELOPMENT.md](DEVELOPMENT.md) for guidelines.

## License

Apache-2.0

## Acknowledgments

- [Prometheus](https://github.com/EuniAI/Prometheus) - Knowledge graph code reasoning
- [Every Code](https://github.com/just-every/code) - Fast coding agent
- [Dexto](https://github.com/truffle-ai/dexto) - Agent harness
- [Claude Code](https://claude.com/claude-code) - AI CLI
