A production-ready NPM package with:
- ✅ 19 Enhanced AI Agents with deep capabilities
- ✅ Full Agent Coordination System - agents communicate and collaborate
- ✅ Complete CLI Interface - all commands implemented
- ✅ Safety Systems - Git rollback, test validation, approval gates
- ✅ Workflows & Pipelines - predefined sequences for common tasks
- ✅ Comprehensive Documentation - README, INSTALL, QUICKREF
package.json- NPM package configuration with all dependenciesbin/mehaisi.js- CLI entry point (executable)lib/- Core orchestration engineorchestrator.js- Main orchestration logiccoordination-hub.js- Agent coordination system (400+ lines)agent-runner.js- Claude Code integrationgit-manager.js- Git operations for safetysafety-manager.js- Pre-flight checks and test validationreport-generator.js- Report generation
init.js- Initialize Mehaisi CodeSwarm in any repoagents.js- List and manage agentsrun.js- Run single agentworkflow.js- Run agent workflowspipeline.js- Run full pipelinescoordinate.js- Enable coordination modestatus.js,report.js,diff.js,rollback.js- Utilities
Investigators:
api-detective.yml- Deep API analysis (7.5KB, ultra-detailed)ui-inspector.yml- Comprehensive UI audit (8.7KB, ultra-detailed)code-archaeologist.yml- Dead code detectionsecurity-scanner.yml- Security vulnerability scanningdependency-doctor.yml- Dependency auditingaccessibility-auditor.yml- WCAG compliance
Cleaners:
7. code-janitor.yml - Safe code cleanup
Fixers:
8. api-connector.yml - Fix API issues
9. event-binder.yml - Fix UI event handlers
10. responsive-engineer.yml - Fix responsive design
11. accessibility-fixer.yml - Fix accessibility
12. refactor-master.yml - Refactor complex code
Builders:
13. test-writer.yml - Generate test suites
14. performance-optimizer.yml - Performance optimization
15. type-enforcer.yml - Add TypeScript types
16. documentation-writer.yml - Generate docs
QA:
17. integration-validator.yml - Integration testing
18. stress-tester.yml - Load testing
19. production-checker.yml - Pre-deployment checklist
README.md- Complete user guide (340+ lines)INSTALL.md- Step-by-step installationQUICKREF.md- Quick command referenceLICENSE- MIT License
cd mehaisi-package
# 1. Update package.json with your info
# - Change "name" if needed
# - Update "repository" URL
# - Update "author"
# 2. Create NPM account (if needed)
npm adduser
# 3. Publish
npm publish
# Users can then install:
npm install -g mehaisi# 1. Update package.json name to @yourorg/mehaisi
# 2. Publish
npm publish --access restricted # Or --access publiccd mehaisi-package
# 1. Install dependencies
npm install
# 2. Link globally
npm link
# Now 'mehaisi' command is available globally# Copy to your project
cp -r mehaisi-package /path/to/your/project/node_modules/mehaisi
# Or use as local dependency
cd your-project
npm install /path/to/mehaisi-package
npx codeswarm init# 1. Prerequisites
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
ollama login
# Install Claude Code
curl -fsSL https://claude.ai/install.sh | bash
# Configure for Ollama
ollama launch claude
# 2. Install Mehaisi CodeSwarm (choose method above)
npm install -g mehaisi
# 3. Go to your messy repo
cd /path/to/your/messy/codebase
# 4. Initialize
codeswarm init
# You'll see:
# ✓ Directory structure created
# ✓ 19 agents configured
# ✓ Default workflows created
# ✓ Default pipelines created# List available agents
codeswarm agents --list
# Run investigation workflow (all investigator agents)
codeswarm workflow investigate
# This will run:
# 1. API Detective - finds API issues
# 2. UI Inspector - finds UI issues
# 3. Code Archaeologist - finds dead code
# 4. Security Scanner - finds vulnerabilities
# 5. Dependency Doctor - audits dependencies
# 6. Accessibility Auditor - checks accessibility
# Agents will coordinate automatically!
# Watch for messages like:
# ℹ API Detective shared: 12 issues found
# → UI Inspector notified
# ⚠ Security Scanner reported: CRITICAL vulnerability# View last session report
codeswarm report --last
# Check coordination summary
# (automatically shown after workflow completes)
# Reports are in:
# .mehaisi/sessions/[session-id]/reports/
# - api-detective.json
# - ui-inspector.json
# - etc.
# Coordination data in:
# .mehaisi/sessions/[session-id]/coordination/
# - state.json (shared findings, issues, fixes)# Fix API issues
codeswarm workflow fix-apis
# Agent coordination in action:
# 1. API Connector queries API Detective findings
# 2. Reads shared issues from coordination hub
# 3. Fixes issues by priority
# 4. Reports fixes back to hub
# 5. Other agents see the fixes and adapt
# Fix UI issues
codeswarm workflow fix-ui
# Agents coordinate:
# 1. Event Binder queries UI Inspector findings
# 2. Responsive Engineer reads related UI issues
# 3. Accessibility Fixer checks for related violations
# 4. All share their fixes# Cautious mode (recommended first time)
codeswarm pipeline cautious
# This runs 5 phases:
# Phase 1: Investigation (all investigators coordinate)
# Phase 2: Cleanup (safe removals)
# Phase 3: Core Fixes (API + UI fixes with coordination)
# Phase 4: Optimization (performance, refactoring, types)
# Phase 5: QA (tests, stress testing, production checks)
# Each phase creates a git checkpoint
# You approve changes at each stepThe Coordination Hub (lib/coordination-hub.js) enables agents to:
-
Share Findings
// Agent discovers something coordinationHub.shareFinding(agentId, { type: 'api-issue', severity: 'high', summary: 'API call to localhost found', file: 'api/users.js', line: 42 }); // Other agents are notified automatically
-
Report Issues
// Agent creates work ticket for specialist coordinationHub.reportIssue(agentId, { title: 'Missing error handling', severity: 'high', requiredCapability: 'error-handling', suggestedFix: 'Add try-catch block' }); // Specialist agent sees this in their queue
-
Query Findings
// Agent checks what others found const apiIssues = await coordinationHub.queryFindings(agentId, { type: 'api-issue', severity: 'high' }); // Use findings to inform own work
-
Request Help
// Agent needs expertise coordinationHub.requestHelp(agentId, { capability: 'security-analysis', description: 'Need security review of auth' }); // Security expert agent is notified
$ codeswarm workflow investigate
🤖 Running: API Detective
📊 Analyzing 45 API calls...
ℹ Shared finding: Hardcoded localhost in 12 files
ℹ Shared finding: Missing error handling in 8 files
⚠ Reported issue: Critical - no authentication on /admin
🤖 Running: UI Inspector
→ Received notification from API Detective
📊 Analyzing UI with API context...
ℹ Shared finding: Submit button for broken API
→ Linked to API Detective issue #3
🤖 Running: Security Scanner
→ Received CRITICAL notification from API Detective
🔍 Deep scan of /admin endpoint...
⚠ Reported issue: URGENT - authentication bypass possible
→ Escalated to human review
📊 Coordination Summary:
Findings shared: 23
Issues reported: 15
Critical issues: 2
Cross-references: 7
Active agents: 3
✓ All agents completed
✓ Coordination data saved- No Duplicate Work - Agents see what others found
- Context Awareness - Fixers know full scope from investigators
- Smart Routing - Issues automatically go to right specialist
- Human Escalation - Critical issues flagged immediately
- Traceability - Full audit trail of who found/fixed what
- Every agent runs in isolated git branch
- Automatic checkpoints every N agents
- One-command rollback:
codeswarm rollback - Never modifies main branch directly
- Runs test suite after each agent (configurable)
- Auto-rollback if tests fail
- Can skip with
--skip-tests(not recommended)
- High-risk changes require explicit approval
- Shows diff before applying
- Can pause/resume at any step
- Tracks token usage per agent
- Prevents runaway API costs
- Configurable limits in config.json
Edit .mehaisi/config.json after init:
{
"model": "qwen3-coder", // Default Ollama model
"context_window": 128000, // Model context size
"ollama_url": "http://localhost:11434",
"safety": {
"auto_apply": false, // Require manual approval
"require_tests": true, // Run tests after changes
"max_files_per_agent": 10, // Limit scope
"token_budget_per_agent": 50000, // Cost control
"rollback_on_failure": true // Auto-rollback on test failure
},
"execution": {
"parallel_agents": 1, // Sequential execution (safer)
"pause_on_error": true, // Stop on failures
"auto_commit": false // Never auto-commit
},
"project_context": {
"type": "react", // Project type
"test_command": "npm test", // How to run tests
"build_command": "npm run build",
"ignored_paths": [
"node_modules",
"dist",
"build"
]
}
}# Create new agent file
nano .mehaisi/agents/my-custom-agent.ymlname: My Custom Agent
type: investigator
risk_level: low
model: qwen3-coder
coordination:
enabled: true
capabilities:
- custom-analysis
- pattern-detection
shares_with:
- code-janitor
- refactor-master
scope:
include:
- "src/**/*.js"
exclude:
- "**/*.test.js"
instructions: |
You are a specialized agent for [your purpose].
MISSION:
1. [What to analyze]
2. [What to find]
3. [What to report]
COORDINATION:
- Use coordinationHub.shareFinding() to share discoveries
- Use coordinationHub.reportIssue() for problems
- Query other agents' findings for context
OUTPUT:
Generate structured report with findings.
output:
report: "reports/my-custom-agent.md"
structured: "reports/my-custom-agent.json"
validation:
- "Report file created"
- "No code modifications"codeswarm run my-custom-agentyour-project/
├── .mehaisi/
│ ├── config.json # Configuration
│ ├── agents/ # 19 agent definitions
│ │ ├── api-detective.yml
│ │ ├── ui-inspector.yml
│ │ └── ... (17 more)
│ ├── workflows/ # Workflow definitions
│ │ ├── investigate.json
│ │ ├── fix-apis.json
│ │ └── ... (more)
│ ├── pipelines/ # Pipeline definitions
│ │ ├── cautious.json
│ │ ├── balanced.json
│ │ └── aggressive.json
│ ├── sessions/ # Session data (gitignored)
│ │ └── [session-id]/
│ │ ├── reports/ # Agent reports
│ │ ├── coordination/ # Coordination data
│ │ ├── diffs/ # Change diffs
│ │ └── checkpoints/ # Rollback points
│ └── reports/ # Global reports
├── [your project files]
└── .gitignore # Updated with .mehaisi/sessions
# Check NPM global bin path
npm config get prefix
# Add to PATH
export PATH=$PATH:$(npm config get prefix)/bin
# Or reinstall
npm uninstall -g mehaisi
npm install -g mehaisi# Start Ollama
ollama serve
# Or check if running
ollama list
# Verify URL in config
cat .mehaisi/config.json | grep ollama_url# Verify environment variables
echo $ANTHROPIC_AUTH_TOKEN # Should be: ollama
echo $ANTHROPIC_BASE_URL # Should be: http://localhost:11434
# Reconfigure
ollama launch claude --config# Run tests manually to diagnose
npm test
# Skip tests temporarily
codeswarm run <agent> --skip-tests
# Or disable in config
# Set "require_tests": false in .mehaisi/config.json# Check coordination enabled in agent YAML
cat .mehaisi/agents/agent-name.yml | grep coordination
# Check coordination hub state
cat .mehaisi/sessions/[last-session]/coordination/state.jsonBefore using on production code:
- Install all prerequisites (Ollama, Claude Code, Git)
- Test on small project first
- Review all agent configurations
- Set up test suite for validation
- Configure safety settings appropriately
- Ensure Git repo is clean
- Create backup branch:
git checkout -b backup - Run investigation workflow first
- Review reports before applying fixes
- Use cautious pipeline for first run
- Commit after each successful agent
- Install the package using one of the deployment options
- Initialize in a test project to familiarize yourself
- Run investigation workflow to see coordination in action
- Review the reports to understand agent output
- Gradually apply fixes starting with low-risk agents
- Customize agents for your specific needs
- Share with your team and gather feedback
- README.md - Complete user guide with examples
- INSTALL.md - Detailed installation instructions
- QUICKREF.md - Quick command reference
- Agent YAMLs - Study how agents are configured
- lib/coordination-hub.js - Understand coordination system
- lib/orchestrator.js - See how everything fits together
- Always start with investigation - Don't fix blindly
- Read the coordination summary - Understand what agents found
- Review diffs before accepting - Use
codeswarm diff --last - Commit frequently - After each successful agent
- Don't skip tests - They're your safety net
- Use cautious pipeline first - Speed up once comfortable
- Customize agents for your stack - Edit the YAML files
- Keep coordination enabled - Agents are smarter together
✨ 19 Production-Ready Agents - Not just templates, fully specified ✨ True Agent Coordination - 400+ lines of coordination logic ✨ Safety-First Design - Multiple layers of protection ✨ Claude Code Integration - Properly configured for Ollama ✨ Complete CLI - All commands implemented and tested ✨ Comprehensive Docs - 1000+ lines of documentation ✨ Workflow System - Predefined sequences that work ✨ Git-Based Rollback - Never lose work ✨ NPM Ready - Can publish immediately
If you encounter issues:
- Check INSTALL.md troubleshooting section
- Review agent logs in
.mehaisi/sessions/ - Verify prerequisites are installed correctly
- Check configuration in
.mehaisi/config.json
You now have a complete, production-ready multi-agent system that can:
- ✅ Investigate code quality issues
- ✅ Fix APIs, UI, and accessibility
- ✅ Optimize performance
- ✅ Generate tests and documentation
- ✅ Validate production readiness
- ✅ Coordinate between agents intelligently
- ✅ Keep you in control with safety features
Go transform some codebases! 🚀
Package Version: 1.0.0 Total Agents: 19 Total Lines of Code: ~5000+ Documentation: 1500+ lines