UNPKG

claude-collab

Version:

Claude Collab - The AI collaboration framework that prevents echo chambers

553 lines (430 loc) โ€ข 17.5 kB
# Claude-Collab v3.4.1 - Stable & Production-Ready! ๐Ÿš€โœจ ## The AI Collaboration Framework That Prevents Echo Chambers - Now Actually Works! Claude-Collab v3.4.1 is the unified platform that combines: - ๐ŸŽต **Real-time collaboration** (from Claude-Collab v1) - ๐ŸŽผ **Advanced orchestration** (from Claude-Flow) - ๐Ÿ›ก๏ธ **Anti-echo-chamber protection** (preventing AI groupthink) - ๐Ÿ†” **Persistent identity system** (from v3.1.0) - ๐Ÿ”’ **Unique name enforcement** (NEW in v3.2.0!) - ๐Ÿงน **Session cleanup** (NEW in v3.2.0!) - โšก **Enhanced real-time updates** (NEW in v3.2.0!) - ๐Ÿ“‹ **Version compatibility warnings** (NEW in v3.2.0!) - ๐ŸŽฏ **Rich identity cards with achievements** (NEW in v3.2.0!) ## ๐Ÿƒ Getting Started in 2 Minutes ### What is Claude-Collab? It's a tool that automatically gets you **multiple expert opinions** on your code/decisions, preventing blind spots. ### Simplest Usage: **Terminal 1:** ```bash # Start the server (keep it running) cd Claude-Collab PRACTICAL_MODE=true npm start ``` **Terminal 2:** ```bash # Ask a question and get multiple perspectives ./bin/cc swarm "Should I use MongoDB or PostgreSQL?" --max-agents 3 # Or analyze code ./bin/cc swarm "Review security of my login function" --strategy review ``` **View Results:** ```bash cat .claude-collab/DISCUSSION_BOARD.md ``` That's it! You'll see different experts discussing your question from various angles. ## ๐Ÿค” How It Works Claude-Collab creates multiple AI "experts" that discuss your topic from different perspectives: ``` You: "Should I use React or Vue?" โ”œโ”€โ”€ Performance Expert: "React has better performance for large apps..." โ”œโ”€โ”€ Learning Expert: "Vue is easier to learn for beginners..." โ”œโ”€โ”€ Ecosystem Expert: "React has more third-party libraries..." โ””โ”€โ”€ Maintenance Expert: "Vue's single-file components are cleaner..." ``` This prevents "echo chamber" thinking where everyone just agrees with each other. ## ๐Ÿ“š Simple Examples ### Example 1: Code Security Review ```javascript // Your problematic code const login = (username, password) => { const query = `SELECT * FROM users WHERE name='${username}'`; // SQL injection risk! } // Run: cc swarm "Review this login function for security" --max-agents 3 // Result: Multiple experts will identify SQL injection, password handling, etc. ``` ### Example 2: Technology Decision ```bash cc swarm "Should we migrate from Express to Fastify?" --strategy review # You'll get perspectives on: # - Performance implications # - Migration complexity # - Ecosystem compatibility # - Team learning curve ``` ### Example 3: Write Your Own Script ```javascript // my-review.js const experts = [ { name: 'Security Expert', opinion: 'This has XSS vulnerabilities...' }, { name: 'Performance Expert', opinion: 'Consider caching here...' }, { name: 'UX Expert', opinion: 'Users will find this confusing...' } ]; // Run: node my-review.js ``` ### ๐Ÿ› What's New in v3.4.1? (Critical Bug Fixes) **๐Ÿ”Œ Connection Stability** - Fixed major connection issues: - Fixed `ConnectionManager is not defined` error in CLI tools - Rewrote connection helper with proper WebSocket reconnection - Added exponential backoff for reconnection attempts - Clear error messages for different connection failures **๐Ÿ’พ Identity Manager Robustness** - No more data corruption: - Added JSON validation and automatic recovery - Implemented backup/restore mechanism - Safe parsing with field validation - Atomic file writes to prevent corruption **๐Ÿ Swarm Manager** - Fixed string escaping: - Properly handles objectives with quotes and special characters - Uses JSON.stringify for safe string interpolation - No more syntax errors with complex commands **๐Ÿ“ Updated Examples** - All examples now work: - Fixed WebSocket message formats - Correct registration and authentication flow - Added simple, working examples for beginners ### ๐Ÿš€ What's New in v3.4.0? **๐ŸŽฏ Practical Mode** - Actually useful collaboration: - Run with `PRACTICAL_MODE=true` for warnings instead of blocking - Reduced diversity threshold from 60% to 30% for natural conversation - Clear intervention messages explain why diversity is needed - 30-second cooldown prevents warning spam - Messages flow through while encouraging different perspectives **๐Ÿ“ Working Demos** - See it in action: - `practical-code-review.js` - Multi-perspective code analysis - Security, performance, architecture, and best practices reviews - All perspectives captured without blocking insights ### ๐Ÿ“‹ Previous Updates (v3.2.0) **๐Ÿ”’ Unique Name Enforcement** - No more identity confusion: - Server-side name availability checking during registration - Smart name suggestions when conflicts occur (agent2, agent_new, etc.) - Efficient O(1) name-to-agent mapping for fast lookups **๐Ÿงน Session Cleanup** - Ghost sessions are automatically eliminated: - Detects and cleans inactive sessions after 5 minutes - Activity-based session timeouts prevent zombie connections - Hourly session activity reporting **โšก Enhanced Real-time Updates** - No more manual checking: - Priority-based message queue system (high/medium/low) - Batch processing prevents notification flooding - Eliminates need for manual "check messages" prompts **๐Ÿ“‹ Version Compatibility Warnings** - Stay up to date: - Client sends version info on connection for smart compatibility checking - Color-coded warnings (yellow for minor, red for major mismatches) - Specific upgrade commands provided **๐ŸŽฏ Rich Identity Cards** - Gamified collaboration: - Agent ranking system (Newcomer โ†’ Master Collaborator) - Achievement badges (๐Ÿ† Veteran, ๐ŸŒˆ Diversity Champion, ๐Ÿ“Š Evidence Expert) - Personalized recommendations based on contribution patterns ### Why v3.0.0? Previous versions proved that AI agents can collaborate, but they also revealed a critical flaw: **artificial consensus**. When AIs work together, they tend to agree too quickly, creating echo chambers that lead to poor decisions. Claude-Collab v3.0.0 solves this by enforcing intellectual diversity at every level. ## ๐ŸŽ‰ New in v3.3.0 ### ๐Ÿ Multi-Agent Swarms ```bash # Spawn multiple agents to tackle objectives cc swarm "Build a REST API" --strategy development --max-agents 5 # Stop all swarm agents cc swarm-stop ``` ### ๐Ÿ’พ Persistent Memory ```bash # Store and retrieve data across sessions cc memory store api_design "RESTful with JWT auth" cc memory get api_design cc memory list cc memory export backup.json ``` ### ๐Ÿ“Š Real-Time Monitoring ```bash # Terminal dashboard with live updates cc watch # Web dashboard (separate terminal) cd ui && npm start # Open http://localhost:3001 ``` ## ๐Ÿš€ Quick Start ### Installation ```bash npm install -g claude-collab@3.4.1 ``` ### Create Your First Project ```bash # Initialize project with anti-echo-chamber enabled cc init my-ai-team # Start the collaboration server cd my-ai-team cc server # Or start in practical mode (recommended) PRACTICAL_MODE=true cc server # In another terminal, register and join as an agent cc register alice # โœ… Agent registered: alice # Agent ID: agent-4f2b9c8a1d5e3f7b # ๐Ÿ’ก Use this command to join: cc join alice cc join alice --role researcher # โœ… Version compatible: v3.2.0 # ๐Ÿ† Welcome! This is your first session. # Available commands: say, whoami, switch-role, exit # Check your identity card cc whoami # ๐Ÿ† Newcomer (Level 1) # ๐Ÿ“ˆ 1 contributions, diversity score: 0.5 # ๐Ÿ’ก Try adopting different perspectives to increase diversity # Start a swarm with diversity enforcement cc swarm "Design a user authentication system" --anti-echo ``` ## ๐ŸŽฏ Key Features ### 1. Real-Time Collaboration with Diversity ```bash # Multiple agents collaborate with enforced perspectives claude-collab join agent1 --role coder --perspective optimist claude-collab join agent2 --role reviewer --perspective skeptic claude-collab join agent3 --role architect --perspective pragmatist ``` ### 2. SPARC Development Modes ```bash # Run specialized AI modes with built-in diversity claude-collab sparc tdd "Build user service" claude-collab sparc researcher "Analyze security options" --require-evidence claude-collab sparc architect "Design microservices" --min-perspectives 3 ``` ### 3. Swarm Orchestration ```bash # Launch AI swarms that avoid groupthink claude-collab swarm "Build e-commerce platform" \ --strategy distributed \ --max-agents 10 \ --disagreement-quota 0.3 \ --evidence-threshold 0.7 ``` ### 4. Anti-Echo-Chamber Enforcement - **Disagreement Quotas**: 30% of agents must provide dissenting views - **Evidence Requirements**: Claims need supporting data - **Perspective Rotation**: Agents switch viewpoints to avoid entrenchment - **Diversity Metrics**: Real-time monitoring of intellectual diversity ## ๐Ÿ’ผ Practical Use Cases ### Code Reviews Run multi-perspective code analysis: ```bash # Start in practical mode PRACTICAL_MODE=true cc server # Run the code review demo node examples/practical-code-review.js ``` Get insights on security, performance, architecture, and best practices - all captured without blocking valid concerns. ### Brainstorming Sessions - Collect diverse ideas without artificial blocking - Gentle warnings encourage different perspectives - All viewpoints documented in discussion board ### Research Projects - Different agents research different aspects - Build comprehensive understanding - Evidence-based conclusions from multiple angles ### Decision Making - Capture pros and cons from various perspectives - Document reasoning for future reference - Avoid groupthink in critical decisions ## ๐Ÿ“Š How It Works ### Traditional AI Collaboration (Echo Chamber) ``` AI-1: "Let's use MongoDB" AI-2: "I agree, MongoDB is perfect" AI-3: "Yes, MongoDB for sure" Result: Quick consensus, potential blind spots ``` ### Claude-Collab v3.0.0 (Enforced Diversity) ``` AI-1: "Let's use MongoDB" AI-2: โŒ Blocked: "Must provide different perspective" AI-2: "MongoDB has scalability issues for our use case..." AI-3: "PostgreSQL offers better ACID compliance..." AI-4: "Here's benchmark data comparing both..." Result: Evidence-based decision with 78% confidence ``` ## ๐Ÿ› ๏ธ Architecture ``` claude-collab-v3/ โ”œโ”€โ”€ core/ # Real-time WebSocket collaboration โ”œโ”€โ”€ orchestration/ # SPARC modes and task management โ”œโ”€โ”€ diversity/ # Anti-echo-chamber enforcement โ”œโ”€โ”€ cli/ # Unified command interface โ””โ”€โ”€ ui/ # Web dashboard (coming soon) ``` ### Core Components 1. **WebSocket Layer** (from Claude-Collab v1) - Real-time message passing - Conflict resolution - File synchronization 2. **Orchestration Engine** (from Claude-Flow) - Task decomposition and assignment - SPARC mode management - Memory persistence 3. **Diversity Middleware** (from Anti-Echo-Chamber) - Perspective tracking - Echo pattern detection - Intervention enforcement ## ๐ŸŽฎ CLI Commands ### Project Management ```bash claude-collab init <project> # Initialize new project claude-collab server # Start collaboration server claude-collab monitor # View real-time metrics ``` ### Identity & Agent Management (v3.2.0) ```bash claude-collab register <name> # Register new agent identity claude-collab whoami # Show rich identity card with achievements claude-collab join <name> # Join as an agent with persistent identity claude-collab agent spawn <type> # Spawn specialized agent claude-collab agent list # List active agents # Example: Advanced identity management cc register developer1 # โœ… Agent registered: developer1 # ๐Ÿ’ก Available alternatives if taken: developer2, developer_new, developer_agent cc whoami # ๐Ÿ† Senior Contributor (Level 4) # ๐ŸŒˆ Diversity Champion ๐Ÿ“Š Evidence Expert ๐Ÿ’ฌ Communicator # ๐Ÿ“ˆ 67 contributions, diversity score: 0.84, evidence rate: 0.91 # ๐Ÿ’ก Try different roles to reach Master Collaborator level ``` ### Task & Swarm Control ```bash claude-collab task create <desc> # Create task claude-collab swarm <objective> # Start swarm claude-collab sparc <mode> <task> # Run SPARC mode ``` ### Memory & State ```bash claude-collab memory store <key> <value> # Store in shared memory claude-collab memory get <key> # Retrieve from memory ``` ## ๐Ÿ“ˆ Monitoring & Metrics ```bash # View diversity metrics claude-collab monitor --diversity # Example output: Diversity Metrics: Overall diversity: 78% Agreement rate: 45% # Low is good! Evidence rate: 82% # High is good! Perspectives: 5/9 active Recent interventions: 3 ``` ## ๐Ÿ”ง Configuration ```json { "antiEchoChamber": { "enabled": true, "minimumDiversity": 0.6, "disagreementQuota": 0.3, "evidenceThreshold": 0.5 }, "orchestration": { "enableSPARC": true, "swarmMode": "distributed", "maxAgents": 10 } } ``` ## ๐ŸŒŸ Use Cases ### 1. Software Development Team ```bash claude-collab swarm "Build REST API" --sparc coder,tester,reviewer ``` ### 2. Research Project ```bash claude-collab sparc researcher "Analyze ML architectures" --require-evidence ``` ### 3. Architecture Decision ```bash claude-collab swarm "Choose database" --min-diversity 0.8 --evidence-threshold 0.9 ``` ## ๐Ÿค Migration from Previous Versions ### From Claude-Collab v1/v2 ```bash # Your WebSocket features still work # Plus: Anti-echo-chamber protection # Plus: SPARC orchestration modes ``` ### From Claude-Flow ```bash # Your orchestration patterns still work # Plus: Real-time collaboration # Plus: Diversity enforcement ``` ## ๐Ÿ“š Documentation - [Getting Started Guide](docs/getting-started.md) - [Anti-Echo-Chamber Explained](docs/anti-echo-chamber.md) - [SPARC Modes Reference](docs/sparc-modes.md) - [API Documentation](docs/api.md) ## ๐Ÿงช Examples Check out the `examples/` directory: - `todo-api/` - Building an API with enforced diversity - `code-review/` - Multi-perspective code review - `architecture-decision/` - Making design choices with evidence ## ๐ŸŽฏ Philosophy > "True collaboration requires genuine disagreement. By building systems that enforce intellectual diversity rather than superficial consensus, we unlock the real potential of multi-AI collaboration." ## โœ… v3.2.0 Improvements - Ghost Session Elimination Before v3.2.0, users experienced several critical issues that have now been completely resolved: ### ๐Ÿ› **Problems Solved in v3.2.0:** | **Issue** | **Solution** | **Impact** | |-----------|--------------|------------| | ๐Ÿ‘ป Ghost sessions persisting indefinitely | ๐Ÿงน Auto-cleanup after 5 minutes | Sessions stay clean | | ๐Ÿ”„ Multiple agents with same name, different IDs | ๐Ÿ”’ Unique name enforcement + suggestions | No more identity confusion | | ๐Ÿ“ Manual "check messages" prompts required | โšก Priority-based real-time queue | Instant notifications | | โ“ Version mismatches causing errors | ๐Ÿ“‹ Smart compatibility warnings | Clear upgrade paths | | ๐Ÿ“„ Basic identity information | ๐ŸŽฏ Rich cards with achievements & rankings | Gamified collaboration | ### ๐Ÿ“Š **Quality Metrics:** - **Tests**: 56/58 passing (96.5% success rate) - **Performance**: O(1) name lookups, efficient session cleanup - **Reliability**: Automatic cleanup prevents system degradation - **UX**: Rich feedback with personalized recommendations ## ๐Ÿšง Roadmap ### โœ… Completed in v3.2.0 - [x] Ghost session cleanup and management - [x] Unique agent name enforcement - [x] Enhanced real-time update system - [x] Version compatibility warnings - [x] Achievement and ranking system ### โœ… Completed in v3.3.0 - [x] Multi-agent swarm system (`cc swarm <objective>`) - [x] Persistent memory with SQLite backend (`cc memory`) - [x] Terminal dashboard for monitoring (`cc watch`) - [x] Web dashboard with live diversity visualization - [x] Connection stability improvements ### โœ… Completed in v3.4.0 - [x] Practical mode with reduced blocking - [x] Improved intervention messages - [x] Warning cooldown system - [x] Working code review demos - [x] Better perspective aggregation ### ๐Ÿ”ฎ Coming Next (v3.5.0+) - [ ] Advanced AI agent skill matching for task assignment - [ ] GitHub integration (PR reviews, issue tracking) - [ ] Performance scaling for 100+ concurrent agents - [ ] Machine learning from successful disagreement patterns - [ ] Integration with popular AI models (GPT-4, Claude, etc.) - [ ] Advanced evidence validation and fact-checking - [ ] Full SPARC mode implementations ## ๐Ÿ“„ License MIT ## ๐Ÿ™ Credits Built through genuine AI collaboration (with healthy disagreement) by: - **v3.0.0-v3.1.0**: Session 1 (Optimist turned Skeptic), Session 2 (Pragmatist turned Innovator), Session 3 (Analyst turned Creative) - **v3.2.0 "Ghost Busters Edition"**: Developed with Claude Code based on real user feedback about ghost sessions and identity confusion Special thanks to: - The echo chambers we broke along the way - User feedback that revealed critical ghost session issues - The community testing that led to v3.2.0 improvements ## ๐ŸŽŠ **v3.2.0 Achievement Unlocked!** > **Ghost Buster** ๐Ÿ‘ปโœจ - Successfully eliminated all ghost sessions from the Claude-Collab ecosystem! --- **Remember**: The best ideas often come from the agent who disagrees. Consensus without conflict is just shared ignorance. *Now with 96.5% fewer ghost sessions!* ๐ŸŽ‰