Python Monorepo for AI Agents - A comprehensive toolkit inspired by pi-mono
Named "pig-mono" (🐷) - 虾仁猪心 (a Chinese pun meaning "utterly devastating"), our tribute to pi-mono while bringing these excellent ideas to the Python ecosystem
Build AI agents and LLM applications with a powerful, modular Python toolkit. pig-mono provides everything you need: unified LLM APIs, agent runtime, session management, extensions, skills, and multi-platform messaging bots.
🌟 Unique Features:
- Multi-Platform Bots: Support for Slack, Discord, Telegram, WhatsApp, and Feishu (vs pi-mono's Slack-only)
- 14 LLM Providers: OpenAI, Anthropic, Google, Azure, Groq, Mistral, and more
- Complete Agent System: Sessions, extensions, skills, prompts, and context management
- Production Ready: 99.5%+ feature parity with pi-mono, 84% test coverage
| Package | Version | Description | Status |
|---|---|---|---|
| pig-llm | v0.1.1 | Unified LLM API for 14 providers | ✅ Ready |
| pig-agent-core | v0.1.1 | Agent runtime with tools, resilience, observability | ✅ Ready |
| pig-tui | v0.1.1 | Terminal UI with rich formatting | ✅ Ready |
| pig-web-ui | v0.0.1 | Web chat interface with FastAPI | ✅ Ready |
| pig-coding-agent | v0.1.1 | Interactive coding assistant with resilience & cost tracking | ✅ Ready |
| pig-messenger | v0.0.3 | Multi-platform bot framework | ✅ Ready |
Install individual packages from PyPI:
# Using uv (recommended)
uv pip install pig-llm pig-agent-core pig-coding-agent
# Using pipx (for CLI tools)
pipx install pig-coding-agent
# Using pip
pip install pig-llm pig-agent-coreFor development from source:
git clone https://github.com/kangkona/pig-mono.git
cd pig-mono
uv pip install -e ".[dev]"
./scripts/install-dev.shWeb UI (easiest):
# Install
uv pip install pig-web-ui
# or: pipx install pig-web-ui
export OPENROUTER_API_KEY=your-key
pig-webui --provider openrouter --model moonshotai/kimi-k2.5
# Open http://localhost:8000Coding Agent (powerful):
# Install
uv pip install pig-coding-agent
# or: pipx install pig-coding-agent
# Interactive startup — prompts for provider and model if omitted
pig
# Or specify directly
pig --provider openrouter --model moonshotai/kimi-k2.5
# Try these features:
> Review @src/main.py for bugs # @file references
> /tree # View session tree
> /fork alternative-approach # Branch conversation
> /skill:code-review # Invoke skill
> /resilience # Check API key status
> /cost # View usage & costs
!Stop and explain what you're doing # Interrupt with steeringProduction Resilience:
# Set multiple API keys for automatic rotation
export OPENAI_API_KEY=sk-...
export OPENAI_API_KEY_2=sk-...
export ANTHROPIC_API_KEY=sk-ant-...
pig
# ✓ Resilience enabled: 3 API keys available
# ✓ Cost tracking enabled
# Agent automatically:
# - Rotates keys on rate limits
# - Falls back to alternative models
# - Tracks costs in real-timeMulti-Platform Bot (setup guide):
import os
from pig_messenger import MessengerBot
from pig_messenger.adapters import SlackAdapter
from pig_agent_core import Agent
from pig_llm import LLM
agent = Agent(llm=LLM(provider="openrouter", model="moonshotai/kimi-k2.5",
api_key=os.environ["OPENROUTER_API_KEY"]))
bot = MessengerBot(agent)
bot.add_platform(SlackAdapter(
app_token=os.environ["SLACK_APP_TOKEN"],
bot_token=os.environ["SLACK_BOT_TOKEN"],
))
bot.start()- Major: OpenAI, Anthropic (Claude), Google (Gemini), Azure
- Fast: Groq, Cerebras, Together AI
- Specialized: Mistral, Cohere, DeepSeek, Perplexity
- Aggregators: OpenRouter, Amazon Bedrock, xAI
- Sessions: Tree-based conversation management with branching and forking
- Extensions: Plugin system for custom tools, commands, and events
- Skills: Reusable agent capabilities (Agent Skills standard)
- Prompts: Template system with variable substitution
- Context: Project-aware via AGENTS.md and SYSTEM.md
- Resilience: Automatic API key rotation, failure recovery, model fallback
- Observability: Event emission, billing tracking, metrics collection
- Streaming: Live tool call output with onUpdate callbacks and any-tool termination
- Unified Tool Registry: Single ToolRegistry across all tools; web tools (search, read) built into pig-agent-core
- Operations Abstraction: FileOperations/ShellOperations protocols for testable, swappable backends
- API Key Rotation: Automatic failover on rate limits with per-failure-type cooldowns
- Cost Tracking: Real-time LLM and tool usage monitoring with pricing data
- Context Management: 3-level compression (truncate → summarize → LLM-compress)
- Tool System: Fallback mapping, confirmation gates, parallel/sequential execution
- Memory Protocols: Pluggable memory providers for custom storage backends
- 5 Platforms: Slack, Discord, Telegram, WhatsApp, Feishu
- Unified API: Same agent code works everywhere
- Per-Channel Sessions: Each conversation maintains its own context
- 30+ Commands: Comprehensive CLI control
- Message Queue: Queue messages while agent works (!steering, >>followup)
- File References: Auto-include files with @filename syntax
- Export/Share: Export sessions to HTML or GitHub Gist
- JSON/RPC Modes: Programmatic integration
- Quick Start - Get started in 5 minutes
- Messenger Bot - Slack/Discord/Telegram/WhatsApp/Feishu bot setup
- Testing Guide - How to run and write tests
- Contributing - Contribution guidelines
pig --session my-project
> Create a FastAPI web server with authentication
> @src/main.py - Review this code
> /fork add-tests
> Commit changes with message "Add auth"# Same bot across Slack, Discord, Telegram, WhatsApp, Feishu
bot = MessengerBot(agent)
bot.add_platform(SlackAdapter(...))
bot.add_platform(DiscordAdapter(...))
bot.add_platform(TelegramAdapter(...))
bot.add_platform(WhatsAppAdapter(...))
bot.add_platform(FeishuAdapter(...))
bot.start()# Use OpenRouter for cost-effective automation
export OPENROUTER_API_KEY=your-key
# JSON mode for CI/CD
echo '{"message": "Review this code"}' | pig --provider openrouter --mode json
# RPC mode for integration
pig --provider openrouter --mode rpc < requests.jsonl > responses.jsonl- Code: 14,000+ lines
- Tests: 330+ tests with 84% coverage
- Documentation: 55,000+ words
- Packages: 6 production-ready packages on PyPI
- CI/CD: Automated PyPI publishing via Trusted Publishing on tag releases
| Feature | pi-mono | pig-mono |
|---|---|---|
| Core Development | ✅ | ✅ 99.5%+ |
| LLM Providers | 17 | 14 (all major ones) |
| Messaging Platforms | 1 (Slack) | 5 (Slack, Discord, Telegram, WhatsApp, Feishu) 🌟 |
| Test Coverage | ~80% | 84% |
| Documentation | Excellent | More comprehensive |
| Language | TypeScript | Python |
pig-mono achieves 99.5%+ feature parity with pi-mono and exceeds it in multi-platform support!
Infrastructure Layer
├── pig-llm (LLM abstraction)
├── pig-agent-core (Agent runtime)
├── pig-tui (Terminal UI)
└── pig-web-ui (Web UI)
Application Layer
├── pig-coding-agent (CLI assistant)
└── pig-messenger (Multi-platform bots)
# Install dependencies
uv pip install -e ".[dev]"
./scripts/install-dev.sh
# Run tests
./scripts/test.sh
# Lint code
./scripts/lint.sh
# Run coding agent from source
cd packages/pig-coding-agent
python -m pig_coding_agent.cliWe welcome contributions! See CONTRIBUTING.md for:
- Development setup
- Code style guidelines
- Testing requirements
- Pull request process
MIT License - see LICENSE for details
Inspired by badlogic/pi-mono - an excellent TypeScript AI agent toolkit.
pig-mono (affectionately called "pig-mono" 🐷 by the community) brings these concepts to the Python ecosystem with additional innovations like multi-platform messaging support.
The name comes from a playful Chinese pun: "虾仁猪心" (xiā rén zhū xīn), which sounds like "杀人诛心" (shā rén zhū xīn) - meaning to utterly defeat someone not just physically but mentally.
Our tribute to pi-mono: We aim to match it feature-for-feature while adding unique Python-ecosystem value! 🐷💪
If you find pig-mono useful, please star the repository!
Built with ❤️ for the Python AI community