A Python project depending on minion
Project description
MinionCodeAgent
An enhanced AI code assistant built on the Minion framework, pre-configured with rich development tools, optimized for code development tasks.
Features
- 🤖 Intelligent Code Assistant: Pre-configured AI agent designed for programming tasks
- 🔧 Rich Toolset: Automatically includes 12+ tools for file operations, command execution, web search, etc.
- ⚡ Ready to Use: One-line creation, no complex configuration needed
- 📝 Conversation History: Built-in conversation history tracking and management
- 🎯 Optimized Prompts: System prompts optimized for code development tasks
- 🛡️ Security by Design: Built-in security checks to prevent dangerous operations
- 🔌 ACP Protocol Support: Seamless integration with ACP clients like Zed editor
Installation
Option 1: Install from source (recommended for development)
# Clone the dependency repository
git clone https://github.com/femto/minion
# Clone this repository
git clone https://github.com/femto/minion-code
# Enter the directory
cd minion-code
# Install minion dependency
pip install -e ../minion
# Install minion-code
pip install -e .
In this case, MINION_ROOT is located at ../minion
Option 2: Direct installation (recommended for general use)
# Clone this repository
git clone https://github.com/femto/minion-code
cd minion-code
# Install dependencies
pip install minionx
# Install minion-code
pip install -e .
In this case, MINION_ROOT is located at the current startup location
On startup, the actual path of MINION_ROOT will be displayed:
2025-11-13 12:21:48.042 | INFO | minion.const:get_minion_root:44 - MINION_ROOT set to: <some_path>
LLM Configuration
Please refer to https://github.com/femto/minion?tab=readme-ov-file#get-started
Make sure the config file is in MINION_ROOT/config/config.yaml or ~/.minion/config.yaml
Quick Start
CLI Usage
# Basic usage
mcode
# Specify working directory
mcode --dir /path/to/project
# Specify LLM model
mcode --model gpt-4o
mcode --model claude-3-5-sonnet
# Enable verbose output
mcode --verbose
# Load additional tools using MCP config file
mcode --config mcp.json
# Combined usage
mcode --dir /path/to/project --model gpt-4o --config mcp.json --verbose
Model Configuration
Configure the default LLM model used by minion-code:
# View current default model
mcode model
# Set default model (saved to ~/.minion/minion-code.json)
mcode model gpt-4o
mcode model claude-3-5-sonnet
# Clear default model (use built-in default)
mcode model --clear
Model Priority:
- CLI
--modelargument (highest priority) - Config file
~/.minion/minion-code.json - Built-in default (lowest priority)
ACP Protocol Support
MinionCodeAgent supports the ACP (Agent Communication Protocol) protocol, enabling integration with ACP-compatible clients like Zed editor.
# Start ACP server (stdio mode)
mcode acp
# Specify working directory
mcode acp --dir /path/to/project
# Specify LLM model
mcode acp --model gpt-4o
# Enable verbose logging
mcode acp --verbose
# Skip tool permission prompts (auto-allow all tools)
mcode acp --dangerously-skip-permissions
# Combined usage
mcode acp --dir /path/to/project --model claude-3-5-sonnet --verbose
Using with Zed Editor
Add the following to Zed's settings.json:
{
"agent_servers": {
"minion-code": {
"type": "custom",
"command": "/path/to/mcode",
"args": [
"acp"
],
"env": {}
}
}
}
Permission Management
In ACP mode, tool calls will request user permission:
- Allow once: Allow this time only
- Always allow: Permanently allow this tool (saved to
~/.minion/sessions/) - Reject: Deny execution
Programming Interface
import asyncio
from minion_code import MinionCodeAgent
async def main():
# Create AI code assistant with all tools auto-configured
agent = await MinionCodeAgent.create(
name="My Code Assistant",
llm="gpt-4.1"
)
# Chat with the AI assistant
response = await agent.run_async("List files in current directory")
print(response.answer)
response = await agent.run_async("Read the README.md file")
print(response.answer)
asyncio.run(main())
Custom Configuration
# Custom system prompt and working directory
agent = await MinionCodeAgent.create(
name="Python Expert",
llm="gpt-4.1",
system_prompt="You are a specialized Python developer assistant.",
workdir="/path/to/project",
additional_tools=[MyCustomTool()]
)
View Available Tools
# Print tools summary
agent.print_tools_summary()
# Get tools info
tools_info = agent.get_tools_info()
for tool in tools_info:
print(f"{tool['name']}: {tool['description']}")
Built-in Tools
MinionCodeAgent automatically includes the following tool categories:
📁 File and Directory Tools
- FileReadTool: Read file contents
- FileWriteTool: Write files
- GrepTool: Search text in files
- GlobTool: File pattern matching
- LsTool: List directory contents
💻 System and Execution Tools
- BashTool: Execute shell commands
- PythonInterpreterTool: Execute Python code
🌐 Network and Search Tools
- WebSearchTool: Web search
- WikipediaSearchTool: Wikipedia search
- VisitWebpageTool: Visit webpages
🔧 Other Tools
- UserInputTool: User input
- TodoWriteTool: Task management write
- TodoReadTool: Task management read
MCP Tool Integration
MinionCodeAgent supports loading additional tools via MCP (Model Context Protocol) configuration files.
MCP Configuration File Format
Create a JSON configuration file (e.g., mcp.json):
{
"mcpServers": {
"chrome-devtools": {
"command": "npx",
"args": ["-y", "chrome-devtools-mcp@latest"],
"env": {
"FASTMCP_LOG_LEVEL": "ERROR"
},
"disabled": false,
"autoApprove": []
},
"filesystem": {
"command": "uvx",
"args": ["mcp-server-filesystem", "/tmp"],
"disabled": true,
"autoApprove": ["read_file", "list_directory"]
},
"git": {
"command": "uvx",
"args": ["mcp-server-git"],
"disabled": false,
"autoApprove": ["git_status", "git_log"]
}
}
}
Configuration Options
command: Command to start the MCP serverargs: List of command argumentsenv: Environment variables (optional)disabled: Whether to disable this server (default: false)autoApprove: List of tool names to auto-approve (optional)
Using MCP Configuration
# Use MCP config file
minion-code --config examples/mcp_config.json
# View loaded tools (including MCP tools)
# In CLI, type: tools
Using MCP Tools in Programming Interface
from minion_code.utils.mcp_loader import load_mcp_tools
from pathlib import Path
async def main():
# Load MCP tools
mcp_tools = await load_mcp_tools(Path("mcp.json"))
# Create agent with MCP tools
agent = await MinionCodeAgent.create(
name="Enhanced Assistant",
llm="gpt-4o-mini",
additional_tools=mcp_tools
)
Conversation History Management
# Get conversation history
history = agent.get_conversation_history()
for entry in history:
print(f"User: {entry['user_message']}")
print(f"Agent: {entry['agent_response']}")
# Clear history
agent.clear_conversation_history()
Comparison with Original Implementation
Before (Complex manual configuration)
# Need to manually import and configure all tools
from minion_code.tools import (
FileReadTool, FileWriteTool, BashTool,
GrepTool, GlobTool, LsTool,
PythonInterpreterTool, WebSearchTool,
# ... more tools
)
# Manually create tool instances
custom_tools = [
FileReadTool(),
FileWriteTool(),
BashTool(),
# ... more tool configuration
]
# Manually set system prompt
SYSTEM_PROMPT = "You are a coding agent..."
# Create agent (~50 lines of code)
agent = await CodeAgent.create(
name="Minion Code Assistant",
llm="gpt-4o-mini",
system_prompt=SYSTEM_PROMPT,
tools=custom_tools,
)
Now (Using MinionCodeAgent)
# One line of code completes all setup
agent = await MinionCodeAgent.create(
name="Minion Code Assistant",
llm="gpt-4o-mini"
)
API Reference
MinionCodeAgent.create()
async def create(
name: str = "Minion Code Assistant",
llm: str = "gpt-4o-mini",
system_prompt: Optional[str] = None,
workdir: Optional[Union[str, Path]] = None,
additional_tools: Optional[List[Any]] = None,
**kwargs
) -> MinionCodeAgent
Parameters:
name: Agent namellm: LLM model to usesystem_prompt: Custom system prompt (optional)workdir: Working directory (optional, defaults to current directory)additional_tools: List of additional tools (optional)**kwargs: Other parameters passed to CodeAgent.create()
Instance Methods
run_async(message: str): Run agent asynchronouslyrun(message: str): Run agent synchronouslyget_conversation_history(): Get conversation historyclear_conversation_history(): Clear conversation historyget_tools_info(): Get tools infoprint_tools_summary(): Print tools summary
Properties
agent: Access underlying CodeAgent instancetools: Get available tools listname: Get agent name
Security Features
- Command Execution Safety: BashTool prohibits dangerous commands (e.g.,
rm -rf,sudo, etc.) - Python Execution Restrictions: PythonInterpreterTool runs in a restricted environment, allowing only safe built-in functions and specified modules
- File Access Control: All file operations have path validation and error handling
Examples
See complete examples in the examples/ directory:
simple_code_agent.py: Basic MinionCodeAgent usage examplesimple_tui.py: Simplified TUI implementationadvanced_textual_tui.py: Advanced TUI interface (using Textual library)minion_agent_tui.py: Original complex implementation (for comparison)mcp_config.json: MCP configuration file exampletest_mcp_config.py: MCP configuration loading testdemo_mcp_cli.py: MCP CLI feature demo
Run examples:
# Basic usage example
python examples/simple_code_agent.py
# Simple TUI
python examples/simple_tui.py
# Advanced TUI (requires textual: pip install textual rich)
python examples/advanced_textual_tui.py
# Test MCP config loading
python examples/test_mcp_config.py
# MCP CLI feature demo
python examples/demo_mcp_cli.py
Documentation
- LLM Configuration Guide - How to configure Large Language Models (LLM)
- MCP Tool Integration Guide - Detailed MCP configuration and usage guide
Contributing
Issues and Pull Requests are welcome to improve this project!
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file minion_code-0.1.23.tar.gz.
File metadata
- Download URL: minion_code-0.1.23.tar.gz
- Upload date:
- Size: 184.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d940615d8a8227b33589c9b388edf54b919556d0e67a03c6a3529cc39d3a7cf
|
|
| MD5 |
04e46a98d1a70c4d4d9c74c8bf00fd7a
|
|
| BLAKE2b-256 |
5a334bd7a03f9f88697f80dac280d6e88f4365d3f24347587d5c6c166ae7538c
|
File details
Details for the file minion_code-0.1.23-py3-none-any.whl.
File metadata
- Download URL: minion_code-0.1.23-py3-none-any.whl
- Upload date:
- Size: 229.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7101d5f60730545c1140e22b1428262aca3f1eb747557ac81d0dd51dcd0fc4bb
|
|
| MD5 |
9a118ce93bb2684af1bcf7bd9f991fe8
|
|
| BLAKE2b-256 |
2646f64269ad96456dd2954add49c0bda427c1464d13900d58b24786a179f12f
|