Skip to main content

Codebase Summary

Technical overview of the miu-mono monorepo structure and implementation.

Project Structure

miu-mono/
├── packages/
│   ├── miu_core/           # Core framework (0.1.0)
│   ├── miu_code/           # CLI agent (0.2.0)
│   ├── miu_studio/         # Web server (0.1.0)
│   ├── miu_examples/       # Examples (0.1.0)
│   └── miu_mono/           # Meta-package (0.1.0)
├── .github/                # GitHub Actions workflows
├── docs/                   # Documentation
├── pyproject.toml          # Root workspace config
└── README.md               # Quick start

miu-core Modules

miu_core.agents - Agent framework base classes
from miu_core.agents import ReActAgent
from miu_core.providers import AnthropicProvider

provider = AnthropicProvider()
agent = ReActAgent(provider=provider)
response = await agent.run("Hello!")

miu-code Tools

ToolPurposeParameters
readRead file contentspath: str
writeWrite new filepath: str, content: str
editModify existing filepath: str, old: str, new: str
bashExecute shell commandcommand: str
globFind files by patternpattern: str
grepSearch file contentspattern: str, path: str

TUI Components

Location: miu_code/tui/
Footer showing mode, path, and token usage with real-time updates during streaming.
Keyboard cycling through NORMAL → PLAN → ASK modes via shift+tab.
  • ctrl+n - New session
  • ctrl+l - Clear chat
  • ctrl+c - Quit

Usage Tracking

from miu_core import UsageTracker

tracker = UsageTracker(context_limit=200_000)
tracker.add_usage(input_tokens=150, output_tokens=50)

print(tracker.total_tokens)    # 200
print(tracker.usage_percent)   # 0.1%
print(tracker.format_usage())  # "0% of 200k tokens"

Mode Management

from miu_core import AgentMode, ModeManager

manager = ModeManager()
manager.on_change(lambda mode: print(f"Mode: {mode}"))

manager.cycle()  # NORMAL → PLAN
manager.cycle()  # PLAN → ASK
manager.set_mode(AgentMode.NORMAL)

Dependencies

Core Framework

PackagePurpose
pydantic≥2.0Data validation
httpx≥0.27Async HTTP
aiofiles≥23.0Async file ops
packaging≥24.0Version management

Optional Providers

PackageProvider
anthropic≥0.40Claude
openai≥1.50GPT
google-genai≥0.8Gemini
mcp≥1.0MCP support

CLI/TUI

PackagePurpose
textual≥1.0.0TUI framework
richTerminal formatting
asyncclickCLI framework

Development Setup

# Clone and install
git clone https://github.com/vanducng/miu-mono.git
cd miu-mono
uv sync

# Run tests
uv run pytest --cov

# Type check
uv run mypy packages/

# Lint
uv run ruff check .

Build System

  • Package Manager: UV with workspace management
  • Build Backend: hatchling
  • Type Checking: MyPy (strict mode)
  • Linting: Ruff
  • Testing: Pytest with asyncio