Skip to content

accessvirus/nanoclawbot-evolution-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔮 RefactorBot - Self-Aware Atomic Vertical Slice Architecture

License Python Tests Coverage

Overview

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.

✨ Features

  • 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

📁 Project Structure

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

🎯 Vertical Slices

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 implementation
  • core/services.py - Business logic services
  • core/handlers/ - Tool handlers (slice_tools only)
  • database/schema.sql - SQLite schema
  • ui/pages/ - Streamlit UI pages

🏗️ Architecture

Master Core Responsibilities

  1. Slice Lifecycle Management - Register/unregister, initialize/start/stop slices
  2. Request Routing - Route operations to appropriate slices
  3. Resource Allocation - Manage slice quotas and resource usage
  4. Dashboard Integration - Publish events, track metrics, manage alerts
  5. Chat Orchestration - Coordinate multi-slice chat responses

Self-Aware Slices

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)

🚀 Quick Start

Installation

# 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

Running the Application

# Run Master Dashboard
streamlit run master_dashboard/app.py

# Run a single slice
streamlit run slices/slice_agent/ui/pages/dashboard.py

Programmatic Usage

import 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 Handlers

File Handlers (slice_tools/core/handlers/file_handlers.py)

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

Exec Handler (slice_tools/core/handlers/exec_handler.py)

Tool Description
execute_command Shell execution with security guards
list_files Directory listing
delete_file File/directory deletion

Web Handlers (slice_tools/core/handlers/web_handlers.py)

Tool Description
web_search Web search functionality
web_fetch HTTP GET requests

🔌 Plugin System

Available adapters:

Plugin Location Status
Discord plugins/discord/adapter.py ✅ Implemented
Telegram plugins/telegram/adapter.py ✅ Implemented
Feishu plugins/feishu/adapter.py ✅ Implemented
WhatsApp plugins/whatsapp/adapter.py ✅ Implemented

Base classes in plugins/plugin_base.py:

  • PluginAdapter - Base adapter interface
  • MessageAdapter - Messaging capabilities
  • ChannelAdapter - Channel-specific logic

🤖 LLM Providers

OpenRouter Gateway (providers/openrouter_gateway.py)

Unified access to 100+ models through OpenRouter.

LiteLLM Gateway (providers/litellm_gateway.py)

50+ providers including:

  • OpenAI, Anthropic, Google, Mistral
  • Azure, AWS Bedrock, VertexAI
  • HuggingFace, Cohere, AI21, and more

⏰ Scheduling System (slice_scheduling/)

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

Testing

# 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

Test Results

Category Tests Coverage
Unit Tests 30 53%
Integration Tests 20 99%
Total 50 60%

📊 Coverage by Module

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%

⚙️ Configuration

Environment Variables

# 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
...

Slice Configuration

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
)

🚢 Deployment

Docker

cd deployment/docker
docker-compose up -d

Kubernetes

cd deployment/kubernetes
kubectl apply -f deployment.yaml

📝 Documentation

🏆 Status

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

📄 License

MIT License - See LICENSE file for details.

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Write tests for your changes
  4. Ensure all tests pass
  5. Submit a pull request

Repository: https://github.com/accessvirus/nanoclawbot-evolution-

About

nanoclawbot

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 27