This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
SimaCode is a modern AI orchestration workflow framework built with Python, featuring intelligent ReAct (Reasoning and Acting) mechanisms and comprehensive workflow orchestration capabilities. It operates in dual modes: as an independent terminal AI Agent application for direct workflow execution, and as a backend API service providing RESTful API and WebSocket services for enterprise workflow integration and automation.
SimaCode follows a clean dual-mode architecture with distinct layers supporting both terminal and API operations:
- Terminal Workflow Agent Mode: CLI interface with Click framework and Rich terminal UI for direct workflow execution
- Backend Workflow Service Mode: FastAPI-based RESTful and WebSocket services for enterprise workflow integration
- Unified Workflow Engine: Both modes share the same core workflow orchestration logic through
SimaCodeService
- Workflow Orchestration Engine (
src/simacode/react/): Intelligent workflow planning, execution, and coordination with MCP tool integration - MCP Integration (
src/simacode/mcp/): Complete Model Context Protocol support with auto-discovery and dynamic updates for workflow tools - Tool Ecosystem (
src/simacode/tools/): Extensible framework with built-in workflow tools (bash, file operations, data processing) - AI Integration (
src/simacode/ai/): Multi-provider AI support for intelligent workflow decision-making (OpenAI with planned Anthropic support) - Security Framework (
src/simacode/permissions/): Comprehensive permission-based access control for workflow execution
# Install dependencies
poetry install
# Install with API support (optional)
poetry install --extras api
# Install development dependencies
poetry install --with dev
# Setup pre-commit hooks
poetry run pre-commit install# Basic workflow execution
simacode chat "Your workflow request here"
# Interactive workflow mode
simacode chat --interactive
# ReAct workflow orchestration
simacode chat --react "Create a complete Python project with tests and documentation"
# Interactive ReAct workflow mode
simacode chat --react --interactive
# Resume a workflow session
simacode chat --react --session-id <session_id># Start workflow orchestration server
simacode serve --host 0.0.0.0 --port 8000
# Development mode with auto-reload
simacode serve --dev --reload
# With custom workflow configuration
simacode serve --config workflow_config.yaml --workers 4# Initialize MCP workflow tools
simacode mcp init
# List all available workflow tools
simacode mcp list
# Search for specific workflow tools
simacode mcp search "file"
# Execute workflow tools directly
simacode mcp run file_tools:read_file --param file_path=/path/to/file.txt
# Interactive workflow parameter input
simacode mcp run web_tools:fetch_url --interactive
# Show workflow system status
simacode mcp status# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov=simacode --cov-report=html
# Run specific test file
poetry run pytest tests/test_cli.py
# Use comprehensive test runner
./tests/run_all_tests.sh
# Run with options
./tests/run_all_tests.sh -v --html
./tests/run_all_tests.sh -t test_ai.py# Format code
poetry run black .
poetry run isort .
# Type checking
poetry run mypy src/simacode
# Linting
poetry run flake8 src/simacodeSimaCode uses a hierarchical configuration system with YAML files and environment variables:
- Runtime configuration (CLI arguments)
- Project configuration (
.simacode/config.yaml) - User configuration (
~/.simacode/config.yaml) - Default configuration (
config/default.yaml)
config/default.yaml: Default application settingsconfig/mcp_servers.yaml: MCP server configurations.simacode/config.yaml: Project-specific settings
SIMACODE_API_KEYorOPENAI_API_KEY: AI provider API keySIMACODE_TEST_CONFIG: Config file for testing
cli.py: Command-line interface entry pointcore/service.py: Unified service layer for dual-mode architecturereact/: ReAct engine implementation (planning, execution, evaluation)mcp/: Model Context Protocol integrationtools/: Built-in tool implementationsai/: AI client implementations and conversation managementapi/: FastAPI-based API service (routes, models, dependencies)services/: Application services layerpermissions/: Security and permission managementsession/: Session handling and persistence
- Contains default YAML configuration files
- MCP server definitions
- Security and AI provider settings
- Architecture documentation
- Development plans and progress reports
- API usage examples and feature documentation
- Comprehensive test suite with integration and unit tests
run_all_tests.sh: Comprehensive test runner with options- MCP integration tests
- AI functionality tests
Once the workflow orchestration server is running:
GET /health: Health checkPOST /api/v1/chat/: Single workflow completionPOST /api/v1/chat/stream/: Streaming workflow executionWS /api/v1/chat/ws/: WebSocket real-time workflow interactionPOST /api/v1/react/execute/: ReAct workflow orchestrationWS /api/v1/react/ws/: WebSocket ReAct workflow executionGET /api/v1/sessions/: List workflow sessionsGET /api/v1/sessions/{id}: Workflow session details
SimaCode provides comprehensive MCP (Model Context Protocol) support for workflow orchestration:
- Two Usage Modes: AI-assisted workflow orchestration (ReAct mode) and direct workflow tool execution
- Auto-Discovery: Automatically discover and register MCP workflow tools
- Dynamic Updates: Hot-reload workflow tool changes without restart
- Namespace Management: Avoid workflow tool conflicts with namespacing
- Network Proxy Support: Handle proxy configurations that may interfere with workflow WebSocket connections
- Dual-Mode Workflow Development: Implement workflow features in core service layer first, then expose through both CLI and API interfaces
- Workflow Testing: Use
./tests/run_all_tests.shfor comprehensive workflow testing with coverage reports - MCP Workflow Tools: Use
simacode mcp initto set up workflow tool integration - Workflow Configuration: Leverage hierarchical config system for different workflow environments
- Workflow Sessions: Both modes support workflow session persistence and management
- Runtime: Python 3.10+
- Package Management: Poetry
- CLI Framework: Click
- API Framework: FastAPI (optional dependency)
- Configuration: Pydantic + YAML
- Testing: pytest + pytest-asyncio
- Code Quality: Black, isort, flake8, mypy
If MCP tools fail to initialize due to proxy issues:
# Temporarily disable proxy
unset http_proxy https_proxy HTTP_PROXY HTTPS_PROXY
simacode mcp init
# Or add localhost to proxy bypass
export no_proxy="localhost,127.0.0.1,*.local"# Check configuration
simacode config --check
# View MCP status
simacode mcp status
# Health check API
curl http://localhost:8000/health
# Check Poetry environment
poetry env info