RefactorBot is a Self-Aware Atomic Vertical Slice Architecture where each slice is a meta-agent with its own LLM capabilities, SQLite database, and dedicated UI. A Master Dashboard built with Streamlit orchestrates and monitors all slices.
- 9 Vertical Slices - Each with its own SQLite database, services, and UI
- Master Core Orchestrator - Hierarchical AI orchestration of all slices
- Self-Aware Slices - Each slice has SelfImprovementServices for meta-reasoning
- Meta SDLC CI/CD - Each slice can self-improve and deploy itself
- Dual LLM Gateways - OpenRouter + LiteLLM (50+ providers)
- Plugin System - Discord, Telegram, Feishu, WhatsApp integrations
- Tool Handlers - File system, shell execution, web search/fetch
- Scheduling System - Cron-based scheduling with heartbeat monitoring
- Production Ready - Full test suite, observability, deployment automation
refactorbot/
├── master_core/ # Master Core AI Orchestrator
│ ├── master_core.py # Core orchestrator (79% coverage)
│ ├── dashboard_connector.py # Dashboard integration (62%)
│ ├── global_state.py # Global state (67%)
│ ├── resource_allocator.py # Resource allocation (59%)
│ └── master_chat.py # Chat orchestration
├── master_dashboard/ # Streamlit Master Dashboard
│ ├── app.py # Main dashboard app
│ └── 06_plugins.py # Plugins management page
├── slices/ # 9 Vertical Slices
│ ├── slice_base.py # Base classes & protocols (71%)
│ ├── slice_agent/ # Agent Core Slice (41%)
│ ├── slice_tools/ # Tool System Slice (40%)
│ │ └── core/handlers/ # Tool implementations
│ │ ├── file_handlers.py # File read/write/list
│ │ ├── exec_handler.py # Shell execution
│ │ └── web_handlers.py # Web search/fetch
│ ├── slice_memory/ # Memory System Slice (51%)
│ ├── slice_communication/ # Communication Slice (42%)
│ ├── slice_session/ # Session Slice (42%)
│ ├── slice_providers/ # Providers Slice (38%)
│ │ └── litellm_gateway.py # LiteLLM (50+ providers)
│ ├── slice_skills/ # Skills Slice (38%)
│ ├── slice_eventbus/ # Event Bus Slice (38%)
│ ├── slice_scheduling/ # Scheduling Slice (NEW)
│ │ └── core/services.py # Cron scheduling, heartbeat
│ └── meta_sdlc/ # Meta SDLC module
├── providers/ # LLM Providers
│ ├── openrouter_gateway.py # OpenRouter integration
│ └── litellm_gateway.py # LiteLLM (50+ providers)
├── plugins/ # Plugin System
│ ├── plugin_base.py # Base adapter classes
│ ├── discord/adapter.py
│ ├── telegram/adapter.py
│ ├── feishu/adapter.py
│ └── whatsapp/adapter.py
├── infrastructure/ # Infrastructure
│ ├── observability.py
│ └── security.py
├── deployment/ # Deployment configs
│ ├── docker/
│ └── kubernetes/
├── tests/ # Test suite (60% coverage)
│ ├── test_slices.py
│ ├── test_master_core.py
│ ├── test_integration.py
│ └── conftest.py
├── data/ # SQLite databases
├── pyproject.toml
├── requirements.txt
├── README.md
├── IMPLEMENTATION.md
├── masteraudit.md # Master audit report
├── fullcomplyTODO.md # Implementation roadmap
└── main.py
| Slice | ID | Coverage | Description |
|---|---|---|---|
| Agent Core | slice_agent |
41% | Core agent logic and chat handling |
| Tools | slice_tools |
40% | Tool registry, file/exec/web handlers |
| Memory | slice_memory |
51% | Persistent memory storage |
| Communication | slice_communication |
42% | Channel management |
| Session | slice_session |
42% | Session handling |
| Providers | slice_providers |
38% | LLM provider management + LiteLLM |
| Skills | slice_skills |
38% | Skill registry |
| Event Bus | slice_eventbus |
38% | Event publishing |
| Scheduling | slice_scheduling |
NEW | Cron scheduling, heartbeat monitoring |
Each slice contains:
slice.py- Main slice implementationcore/services.py- Business logic servicescore/handlers/- Tool handlers (slice_tools only)database/schema.sql- SQLite schemaui/pages/- Streamlit UI pages
- Slice Lifecycle Management - Register/unregister, initialize/start/stop slices
- Request Routing - Route operations to appropriate slices
- Resource Allocation - Manage slice quotas and resource usage
- Dashboard Integration - Publish events, track metrics, manage alerts
- Chat Orchestration - Coordinate multi-slice chat responses
Each slice implements the AtomicSlice protocol and includes SelfImprovementServices:
from refactorbot.slices import AtomicSlice, SelfImprovementServices
class MySlice(AtomicSlice):
def __init__(self):
self.self_improve = SelfImprovementServices(self)
async def self_improve(self, feedback: Dict[str, Any]) -> ImprovementPlan:
return await self.self_improve.analyze_and_improve(feedback)# Clone the repository
git clone https://github.com/accessvirus/nanoclawbot-evolution-
cd refactorbot
# Install dependencies
pip install -r requirements.txt
# Run tests
python -m pytest tests/ -v --cov# Run Master Dashboard
streamlit run master_dashboard/app.py
# Run a single slice
streamlit run slices/slice_agent/ui/pages/dashboard.pyimport asyncio
from refactorbot.master_core import MasterCore
from refactorbot.slices.slice_agent import SliceAgent
async def main():
core = MasterCore()
core.register_slice("slice_agent", SliceAgent)
response = await core.execute(
operation="agent_chat",
payload={"message": "Hello!"},
context={}
)
print(f"Success: {response.success}")
asyncio.run(main())| Tool | Description |
|---|---|
read_file |
Read file contents with line ranges |
write_to_file |
Create or overwrite files |
search_and_replace |
Precise text search/replace |
list_files |
List directory contents |
| Tool | Description |
|---|---|
execute_command |
Shell execution with security guards |
list_files |
Directory listing |
delete_file |
File/directory deletion |
| Tool | Description |
|---|---|
web_search |
Web search functionality |
web_fetch |
HTTP GET requests |
Available adapters:
| Plugin | Location | Status |
|---|---|---|
| Discord | plugins/discord/adapter.py |
✅ Implemented |
| Telegram | plugins/telegram/adapter.py |
✅ Implemented |
| Feishu | plugins/feishu/adapter.py |
✅ Implemented |
plugins/whatsapp/adapter.py |
✅ Implemented |
Base classes in plugins/plugin_base.py:
PluginAdapter- Base adapter interfaceMessageAdapter- Messaging capabilitiesChannelAdapter- Channel-specific logic
Unified access to 100+ models through OpenRouter.
50+ providers including:
- OpenAI, Anthropic, Google, Mistral
- Azure, AWS Bedrock, VertexAI
- HuggingFace, Cohere, AI21, and more
| Feature | Description |
|---|---|
| Cron Scheduling | Cron expression-based task scheduling |
| Heartbeat Monitoring | Task health and liveness checks |
| Workflow Support | Multi-step task workflows |
| Execution History | Track task execution results |
| Alerting | Notification on failures |
# Run all tests
python -m pytest tests/ -v
# Run with coverage
python -m pytest tests/ --cov=refactorbot --cov-report=html
# Run specific test file
python -m pytest tests/test_master_core.py -v| Category | Tests | Coverage |
|---|---|---|
| Unit Tests | 30 | 53% |
| Integration Tests | 20 | 99% |
| Total | 50 | 60% |
| Module | Coverage |
|---|---|
| master_core/master_core.py | 79% |
| master_core/dashboard_connector.py | 62% |
| master_core/global_state.py | 67% |
| master_core/resource_allocator.py | 59% |
| master_core/master_chat.py | NEW |
| slices/slice_base.py | 71% |
| slices/slice_agent/ | 41% |
| slices/slice_tools/ | 40% |
| slices/slice_tools/core/handlers/ | NEW |
| slices/slice_memory/ | 51% |
| slices/slice_communication/ | 42% |
| slices/slice_session/ | 42% |
| slices/slice_providers/ | 38% |
| slices/slice_providers/litellm_gateway.py | NEW |
| slices/slice_skills/ | 38% |
| slices/slice_eventbus/ | 38% |
| slices/slice_scheduling/ | NEW |
| plugins/plugin_base.py | NEW |
| Overall | 60% |
# Master Core
OPENROUTER_API_KEY=your_api_key
LITELLM_API_KEY=your_api_key
DATA_DIR=data
# Slice Databases
SLICE_AGENT_DB=data/slice_agent.db
SLICE_TOOLS_DB=data/slice_tools.db
SLICE_MEMORY_DB=data/slice_memory.db
...from refactorbot.slices import SliceConfig
config = SliceConfig(
slice_id="slice_agent",
slice_name="Agent Core",
slice_version="1.0.0",
database_path="data/slice_agent.db",
debug=True
)cd deployment/docker
docker-compose up -dcd deployment/kubernetes
kubectl apply -f deployment.yaml- IMPLEMENTATION.md - Full architecture design
- masteraudit.md - Master audit report
- fullcomplyTODO.md - Implementation roadmap
- Individual
.mdaudit files in each module directory
| Metric | Value |
|---|---|
| Grade | A- |
| Tests | 50/50 passing |
| Coverage | 60% |
| Slices | 9/9 implemented |
| Plugins | 4/4 implemented |
| LLM Gateways | 2/2 implemented |
| Tool Handlers | 3/3 implemented |
MIT License - See LICENSE file for details.
- Fork the repository
- Create a feature branch
- Write tests for your changes
- Ensure all tests pass
- Submit a pull request
Repository: https://github.com/accessvirus/nanoclawbot-evolution-