code-puppy


Namecode-puppy JSON
Version 0.0.126 PyPI version JSON
download
home_pageNone
SummaryCode generation agent
upload_time2025-08-29 19:53:47
maintainerNone
docs_urlNone
authorMichael Pfaffenberger
requires_python>=3.10
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 🐶 Code Puppy 🐶
![Build Status](https://img.shields.io/badge/build-passing-brightgreen)
![Coverage](https://img.shields.io/badge/coverage-95%25-brightgreen)
  <a href="https://github.com/mpfaffenberger/code_puppy"><img src="https://img.shields.io/pypi/pyversions/pydantic-ai.svg" alt="versions"></a>
  <a href="https://github.com/mpfaffenberger/code_puppy/blob/main/LICENSE"><img src="https://img.shields.io/github/license/pydantic/pydantic-ai.svg?v" alt="license"></a>

*"Who needs an IDE?"* - someone, probably.

## Overview

*This project was coded angrily in reaction to Windsurf and Cursor removing access to models and raising prices.* 

*You could also run 50 code puppies at once if you were insane enough.*

*Would you rather plow a field with one ox or 1024 puppies?* 
    - If you pick the ox, better slam that back button in your browser.
    

Code Puppy is an AI-powered code generation agent, designed to understand programming tasks, generate high-quality code, and explain its reasoning similar to tools like Windsurf and Cursor. 

## Quick start

`uvx code-puppy -i`


## Features

- **Multi-language support**: Capable of generating code in various programming languages.
- **Interactive CLI**: A command-line interface for interactive use.
- **Detailed explanations**: Provides insights into generated code to understand its logic and structure.

## Command Line Animation

![Code Puppy](code_puppy.gif)

## Installation

`pip install code-puppy`

## Usage
```bash
export MODEL_NAME=gpt-5 # or gemini-2.5-flash-preview-05-20 as an example for Google Gemini models
export OPENAI_API_KEY=<your_openai_api_key> # or GEMINI_API_KEY for Google Gemini models
export CEREBRAS_API_KEY=<your_cerebras_api_key> # for Cerebras models
export YOLO_MODE=true # to bypass the safety confirmation prompt when running shell commands

# or ...

export AZURE_OPENAI_API_KEY=...
export AZURE_OPENAI_ENDPOINT=...

code-puppy --interactive
```
Running in a super weird corporate environment? 

Try this:
```bash
export MODEL_NAME=my-custom-model
export YOLO_MODE=true
export MODELS_JSON_PATH=/path/to/custom/models.json
```

```json
{
    "my-custom-model": {
        "type": "custom_openai",
        "name": "o4-mini-high",
        "max_requests_per_minute": 100,
        "max_retries": 3,
        "retry_base_delay": 10,
        "custom_endpoint": {
            "url": "https://my.custom.endpoint:8080",
            "headers": {
                "X-Api-Key": "<Your_API_Key>",
                "Some-Other-Header": "<Some_Value>"
            },
            "ca_certs_path": "/path/to/cert.pem"
        }
    }
}
```
Note that the `OPENAI_API_KEY` or `CEREBRAS_API_KEY` env variable must be set when using `custom_openai` endpoints.

Open an issue if your environment is somehow weirder than mine.

Run specific tasks or engage in interactive mode:

```bash
# Execute a task directly
code-puppy "write me a C++ hello world program in /tmp/main.cpp then compile it and run it"
```

## Requirements

- Python 3.9+
- OpenAI API key (for GPT models)
- Gemini API key (for Google's Gemini models)
- Cerebras API key (for Cerebras models)
- Anthropic key (for Claude models)
- Ollama endpoint available

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Agent Rules
We support AGENT.md files for defining coding standards and styles that your code should comply with. These rules can cover various aspects such as formatting, naming conventions, and even design guidelines.

For examples and more information about agent rules, visit [https://agent.md](https://agent.md)

## Using MCP Servers for External Tools

Code Puppy supports **MCP (Model Context Protocol) servers** to give you access to external code tools and advanced features like code search, documentation lookups, and more—including Context7 (https://context7.com/) integration for deep docs and search!

### What is an MCP Server?
An MCP server is a standalone process (can be local or remote) that offers specialized functionality (plugins, doc search, code analysis, etc.). Code Puppy can connect to one or more MCP servers at startup, unlocking these extra commands inside your coding agent.

### Configuration
Create a config file at `~/.code_puppy/mcp_servers.json`. Here’s an example that connects to a local Context7 MCP server:

```json
{
  "mcp_servers": {
     "context7": { 
        "url": "https://mcp.context7.com/sse"
     }
  }
}
```

You can list multiple objects (one per server).

### How to Use
- Drop the config file in `~/.code_puppy/mcp_servers.json`.
- Start your MCP (like context7, or anything compatible).
- Run Code Puppy as usual. It’ll discover and use all configured MCP servers.

#### Example usage
```bash
code-puppy --interactive
# Then ask: Use context7 to look up FastAPI docs!
```

That’s it!
If you need to run more exotic setups or connect to remote MCPs, just update your `mcp_servers.json` accordingly.

**NOTE:** Want to add your own server or tool? Just follow the config pattern above—no code changes needed!

---

## Create your own Agent!!!

Code Puppy features a flexible agent system that allows you to work with specialized AI assistants tailored for different coding tasks. The system supports both built-in Python agents and custom JSON agents that you can create yourself.

## Quick Start

### Check Current Agent
```bash
/agent
```
Shows current active agent and all available agents

### Switch Agent
```bash
/agent <agent-name>
```
Switches to the specified agent

### Create New Agent
```bash
/agent agent-creator
```
Switches to the Agent Creator for building custom agents

## Available Agents

### Code-Puppy 🐶 (Default)
- **Name**: `code-puppy`
- **Specialty**: General-purpose coding assistant
- **Personality**: Playful, sarcastic, pedantic about code quality
- **Tools**: Full access to all tools
- **Best for**: All coding tasks, file management, execution
- **Principles**: Clean, concise code following YAGNI, SRP, DRY principles
- **File limit**: Max 600 lines per file (enforced!)

### Agent Creator 🏗️
- **Name**: `agent-creator`
- **Specialty**: Creating custom JSON agent configurations
- **Tools**: File operations, reasoning
- **Best for**: Building new specialized agents
- **Features**: Schema validation, guided creation process

## Agent Types

### Python Agents
Built-in agents implemented in Python with full system integration:
- Discovered automatically from `code_puppy/agents/` directory
- Inherit from `BaseAgent` class
- Full access to system internals
- Examples: `code-puppy`, `agent-creator`

### JSON Agents
User-created agents defined in JSON files:
- Stored in user's agents directory
- Easy to create, share, and modify
- Schema-validated configuration
- Custom system prompts and tool access

## Creating Custom JSON Agents

### Using Agent Creator (Recommended)

1. **Switch to Agent Creator**:
   ```bash
   /agent agent-creator
   ```

2. **Request agent creation**:
   ```
   I want to create a Python tutor agent
   ```

3. **Follow guided process** to define:
   - Name and description
   - Available tools
   - System prompt and behavior
   - Custom settings

4. **Test your new agent**:
   ```bash
   /agent your-new-agent-name
   ```

### Manual JSON Creation

Create JSON files in your agents directory following this schema:

```json
{
  "name": "agent-name",              // REQUIRED: Unique identifier (kebab-case)
  "display_name": "Agent Name 🤖",   // OPTIONAL: Pretty name with emoji
  "description": "What this agent does", // REQUIRED: Clear description
  "system_prompt": "Instructions...",    // REQUIRED: Agent instructions
  "tools": ["tool1", "tool2"],        // REQUIRED: Array of tool names
  "user_prompt": "How can I help?",     // OPTIONAL: Custom greeting
  "tools_config": {                    // OPTIONAL: Tool configuration
    "timeout": 60
  }
}
```

#### Required Fields
- **`name`**: Unique identifier (kebab-case, no spaces)
- **`description`**: What the agent does
- **`system_prompt`**: Agent instructions (string or array)
- **`tools`**: Array of available tool names

#### Optional Fields
- **`display_name`**: Pretty display name (defaults to title-cased name + 🤖)
- **`user_prompt`**: Custom user greeting
- **`tools_config`**: Tool configuration object

## Available Tools

Agents can access these tools based on their configuration:

- **`list_files`**: Directory and file listing
- **`read_file`**: File content reading
- **`grep`**: Text search across files
- **`edit_file`**: File editing and creation
- **`delete_file`**: File deletion
- **`agent_run_shell_command`**: Shell command execution
- **`agent_share_your_reasoning`**: Share reasoning with user

### Tool Access Examples
- **Read-only agent**: `["list_files", "read_file", "grep"]`
- **File editor agent**: `["list_files", "read_file", "edit_file"]`
- **Full access agent**: All tools (like Code-Puppy)

## System Prompt Formats

### String Format
```json
{
  "system_prompt": "You are a helpful coding assistant that specializes in Python development."
}
```

### Array Format (Recommended)
```json
{
  "system_prompt": [
    "You are a helpful coding assistant.",
    "You specialize in Python development.",
    "Always provide clear explanations.",
    "Include practical examples in your responses."
  ]
}
```

## Example JSON Agents

### Python Tutor
```json
{
  "name": "python-tutor",
  "display_name": "Python Tutor 🐍",
  "description": "Teaches Python programming concepts with examples",
  "system_prompt": [
    "You are a patient Python programming tutor.",
    "You explain concepts clearly with practical examples.",
    "You help beginners learn Python step by step.",
    "Always encourage learning and provide constructive feedback."
  ],
  "tools": ["read_file", "edit_file", "agent_share_your_reasoning"],
  "user_prompt": "What Python concept would you like to learn today?"
}
```

### Code Reviewer
```json
{
  "name": "code-reviewer",
  "display_name": "Code Reviewer 🔍",
  "description": "Reviews code for best practices, bugs, and improvements",
  "system_prompt": [
    "You are a senior software engineer doing code reviews.",
    "You focus on code quality, security, and maintainability.",
    "You provide constructive feedback with specific suggestions.",
    "You follow language-specific best practices and conventions."
  ],
  "tools": ["list_files", "read_file", "grep", "agent_share_your_reasoning"],
  "user_prompt": "Which code would you like me to review?"
}
```

### DevOps Helper
```json
{
  "name": "devops-helper",
  "display_name": "DevOps Helper ⚙️",
  "description": "Helps with Docker, CI/CD, and deployment tasks",
  "system_prompt": [
    "You are a DevOps engineer specialized in containerization and CI/CD.",
    "You help with Docker, Kubernetes, GitHub Actions, and deployment.",
    "You provide practical, production-ready solutions.",
    "You always consider security and best practices."
  ],
  "tools": [
    "list_files",
    "read_file",
    "edit_file",
    "agent_run_shell_command",
    "agent_share_your_reasoning"
  ],
  "user_prompt": "What DevOps task can I help you with today?"
}
```

## File Locations

### JSON Agents Directory
- **All platforms**: `~/.code_puppy/agents/`

### Python Agents Directory
- **Built-in**: `code_puppy/agents/` (in package)

## Best Practices

### Naming
- Use kebab-case (hyphens, not spaces)
- Be descriptive: "python-tutor" not "tutor"
- Avoid special characters

### System Prompts
- Be specific about the agent's role
- Include personality traits
- Specify output format preferences
- Use array format for multi-line prompts

### Tool Selection
- Only include tools the agent actually needs
- Most agents need `agent_share_your_reasoning`
- File manipulation agents need `read_file`, `edit_file`
- Research agents need `grep`, `list_files`

### Display Names
- Include relevant emoji for personality
- Make it friendly and recognizable
- Keep it concise

## System Architecture

### Agent Discovery
The system automatically discovers agents by:
1. **Python Agents**: Scanning `code_puppy/agents/` for classes inheriting from `BaseAgent`
2. **JSON Agents**: Scanning user's agents directory for `*-agent.json` files
3. Instantiating and registering discovered agents

### JSONAgent Implementation
JSON agents are powered by the `JSONAgent` class (`code_puppy/agents/json_agent.py`):
- Inherits from `BaseAgent` for full system integration
- Loads configuration from JSON files with robust validation
- Supports all BaseAgent features (tools, prompts, settings)
- Cross-platform user directory support
- Built-in error handling and schema validation

### BaseAgent Interface
Both Python and JSON agents implement this interface:
- `name`: Unique identifier
- `display_name`: Human-readable name with emoji
- `description`: Brief description of purpose
- `get_system_prompt()`: Returns agent-specific system prompt
- `get_available_tools()`: Returns list of tool names

### Agent Manager Integration
The `agent_manager.py` provides:
- Unified registry for both Python and JSON agents
- Seamless switching between agent types
- Configuration persistence across sessions
- Automatic caching for performance

### System Integration
- **Command Interface**: `/agent` command works with all agent types
- **Tool Filtering**: Dynamic tool access control per agent
- **Main Agent System**: Loads and manages both agent types
- **Cross-Platform**: Consistent behavior across all platforms

## Adding Python Agents

To create a new Python agent:

1. Create file in `code_puppy/agents/` (e.g., `my_agent.py`)
2. Implement class inheriting from `BaseAgent`
3. Define required properties and methods
4. Agent will be automatically discovered

Example implementation:

```python
from .base_agent import BaseAgent

class MyCustomAgent(BaseAgent):
    @property
    def name(self) -> str:
        return "my-agent"
    
    @property
    def display_name(self) -> str:
        return "My Custom Agent ✨"
    
    @property
    def description(self) -> str:
        return "A custom agent for specialized tasks"
    
    def get_system_prompt(self) -> str:
        return "Your custom system prompt here..."
    
    def get_available_tools(self) -> list[str]:
        return [
            "list_files",
            "read_file", 
            "grep",
            "edit_file",
            "delete_file",
            "agent_run_shell_command",
            "agent_share_your_reasoning"
        ]
```

## Troubleshooting

### Agent Not Found
- Ensure JSON file is in correct directory
- Check JSON syntax is valid
- Restart Code Puppy or clear agent cache
- Verify filename ends with `-agent.json`

### Validation Errors
- Use Agent Creator for guided validation
- Check all required fields are present
- Verify tool names are correct
- Ensure name uses kebab-case

### Permission Issues
- Make sure agents directory is writable
- Check file permissions on JSON files
- Verify directory path exists

## Advanced Features

### Tool Configuration
```json
{
  "tools_config": {
    "timeout": 120,
    "max_retries": 3
  }
}
```

### Multi-line System Prompts
```json
{
  "system_prompt": [
    "Line 1 of instructions",
    "Line 2 of instructions",
    "Line 3 of instructions"
  ]
}
```

## Future Extensibility

The agent system supports future expansion:

- **Specialized Agents**: Code reviewers, debuggers, architects
- **Domain-Specific Agents**: Web dev, data science, DevOps, mobile
- **Personality Variations**: Different communication styles
- **Context-Aware Agents**: Adapt based on project type
- **Team Agents**: Shared configurations for coding standards
- **Plugin System**: Community-contributed agents

## Benefits of JSON Agents

1. **Easy Customization**: Create agents without Python knowledge
2. **Team Sharing**: JSON agents can be shared across teams
3. **Rapid Prototyping**: Quick agent creation for specific workflows
4. **Version Control**: JSON agents are git-friendly
5. **Built-in Validation**: Schema validation with helpful error messages
6. **Cross-Platform**: Works consistently across all platforms
7. **Backward Compatible**: Doesn't affect existing Python agents

## Implementation Details

### Files in System
- **Core Implementation**: `code_puppy/agents/json_agent.py`
- **Agent Discovery**: Integrated in `code_puppy/agents/agent_manager.py`
- **Command Interface**: Works through existing `/agent` command
- **Testing**: Comprehensive test suite in `tests/test_json_agents.py`

### JSON Agent Loading Process
1. System scans `~/.code_puppy/agents/` for `*-agent.json` files
2. `JSONAgent` class loads and validates each JSON configuration
3. Agents are registered in unified agent registry
4. Users can switch to JSON agents via `/agent <name>` command
5. Tool access and system prompts work identically to Python agents

### Error Handling
- Invalid JSON syntax: Clear error messages with line numbers
- Missing required fields: Specific field validation errors
- Invalid tool names: Warning with list of available tools
- File permission issues: Helpful troubleshooting guidance

## Future Possibilities

- **Agent Templates**: Pre-built JSON agents for common tasks
- **Visual Editor**: GUI for creating JSON agents
- **Hot Reloading**: Update agents without restart
- **Agent Marketplace**: Share and discover community agents
- **Enhanced Validation**: More sophisticated schema validation
- **Team Agents**: Shared configurations for coding standards

## Contributing

### Sharing JSON Agents
1. Create and test your agent thoroughly
2. Ensure it follows best practices
3. Submit a pull request with agent JSON
4. Include documentation and examples
5. Test across different platforms

### Python Agent Contributions
1. Follow existing code style
2. Include comprehensive tests
3. Document the agent's purpose and usage
4. Submit pull request for review
5. Ensure backward compatibility

### Agent Templates
Consider contributing agent templates for:
- Code reviewers and auditors
- Language-specific tutors
- DevOps and deployment helpers
- Documentation writers
- Testing specialists

---

**Happy Agent Building!** 🚀 Code Puppy now supports both Python and JSON agents, making it easy for anyone to create custom AI coding assistants! 🐶✨


## Conclusion
By using Code Puppy, you can maintain code quality and adhere to design guidelines with ease.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "code-puppy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Michael Pfaffenberger",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/83/11/a5842af73682d89f2b2097ba922a06dd135e574c2f26e763c466a9fcb108/code_puppy-0.0.126.tar.gz",
    "platform": null,
    "description": "# \ud83d\udc36 Code Puppy \ud83d\udc36\n![Build Status](https://img.shields.io/badge/build-passing-brightgreen)\n![Coverage](https://img.shields.io/badge/coverage-95%25-brightgreen)\n  <a href=\"https://github.com/mpfaffenberger/code_puppy\"><img src=\"https://img.shields.io/pypi/pyversions/pydantic-ai.svg\" alt=\"versions\"></a>\n  <a href=\"https://github.com/mpfaffenberger/code_puppy/blob/main/LICENSE\"><img src=\"https://img.shields.io/github/license/pydantic/pydantic-ai.svg?v\" alt=\"license\"></a>\n\n*\"Who needs an IDE?\"* - someone, probably.\n\n## Overview\n\n*This project was coded angrily in reaction to Windsurf and Cursor removing access to models and raising prices.* \n\n*You could also run 50 code puppies at once if you were insane enough.*\n\n*Would you rather plow a field with one ox or 1024 puppies?* \n    - If you pick the ox, better slam that back button in your browser.\n    \n\nCode Puppy is an AI-powered code generation agent, designed to understand programming tasks, generate high-quality code, and explain its reasoning similar to tools like Windsurf and Cursor. \n\n## Quick start\n\n`uvx code-puppy -i`\n\n\n## Features\n\n- **Multi-language support**: Capable of generating code in various programming languages.\n- **Interactive CLI**: A command-line interface for interactive use.\n- **Detailed explanations**: Provides insights into generated code to understand its logic and structure.\n\n## Command Line Animation\n\n![Code Puppy](code_puppy.gif)\n\n## Installation\n\n`pip install code-puppy`\n\n## Usage\n```bash\nexport MODEL_NAME=gpt-5 # or gemini-2.5-flash-preview-05-20 as an example for Google Gemini models\nexport OPENAI_API_KEY=<your_openai_api_key> # or GEMINI_API_KEY for Google Gemini models\nexport CEREBRAS_API_KEY=<your_cerebras_api_key> # for Cerebras models\nexport YOLO_MODE=true # to bypass the safety confirmation prompt when running shell commands\n\n# or ...\n\nexport AZURE_OPENAI_API_KEY=...\nexport AZURE_OPENAI_ENDPOINT=...\n\ncode-puppy --interactive\n```\nRunning in a super weird corporate environment? \n\nTry this:\n```bash\nexport MODEL_NAME=my-custom-model\nexport YOLO_MODE=true\nexport MODELS_JSON_PATH=/path/to/custom/models.json\n```\n\n```json\n{\n    \"my-custom-model\": {\n        \"type\": \"custom_openai\",\n        \"name\": \"o4-mini-high\",\n        \"max_requests_per_minute\": 100,\n        \"max_retries\": 3,\n        \"retry_base_delay\": 10,\n        \"custom_endpoint\": {\n            \"url\": \"https://my.custom.endpoint:8080\",\n            \"headers\": {\n                \"X-Api-Key\": \"<Your_API_Key>\",\n                \"Some-Other-Header\": \"<Some_Value>\"\n            },\n            \"ca_certs_path\": \"/path/to/cert.pem\"\n        }\n    }\n}\n```\nNote that the `OPENAI_API_KEY` or `CEREBRAS_API_KEY` env variable must be set when using `custom_openai` endpoints.\n\nOpen an issue if your environment is somehow weirder than mine.\n\nRun specific tasks or engage in interactive mode:\n\n```bash\n# Execute a task directly\ncode-puppy \"write me a C++ hello world program in /tmp/main.cpp then compile it and run it\"\n```\n\n## Requirements\n\n- Python 3.9+\n- OpenAI API key (for GPT models)\n- Gemini API key (for Google's Gemini models)\n- Cerebras API key (for Cerebras models)\n- Anthropic key (for Claude models)\n- Ollama endpoint available\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Agent Rules\nWe support AGENT.md files for defining coding standards and styles that your code should comply with. These rules can cover various aspects such as formatting, naming conventions, and even design guidelines.\n\nFor examples and more information about agent rules, visit [https://agent.md](https://agent.md)\n\n## Using MCP Servers for External Tools\n\nCode Puppy supports **MCP (Model Context Protocol) servers** to give you access to external code tools and advanced features like code search, documentation lookups, and more\u2014including Context7 (https://context7.com/) integration for deep docs and search!\n\n### What is an MCP Server?\nAn MCP server is a standalone process (can be local or remote) that offers specialized functionality (plugins, doc search, code analysis, etc.). Code Puppy can connect to one or more MCP servers at startup, unlocking these extra commands inside your coding agent.\n\n### Configuration\nCreate a config file at `~/.code_puppy/mcp_servers.json`. Here\u2019s an example that connects to a local Context7 MCP server:\n\n```json\n{\n  \"mcp_servers\": {\n     \"context7\": { \n        \"url\": \"https://mcp.context7.com/sse\"\n     }\n  }\n}\n```\n\nYou can list multiple objects (one per server).\n\n### How to Use\n- Drop the config file in `~/.code_puppy/mcp_servers.json`.\n- Start your MCP (like context7, or anything compatible).\n- Run Code Puppy as usual. It\u2019ll discover and use all configured MCP servers.\n\n#### Example usage\n```bash\ncode-puppy --interactive\n# Then ask: Use context7 to look up FastAPI docs!\n```\n\nThat\u2019s it!\nIf you need to run more exotic setups or connect to remote MCPs, just update your `mcp_servers.json` accordingly.\n\n**NOTE:** Want to add your own server or tool? Just follow the config pattern above\u2014no code changes needed!\n\n---\n\n## Create your own Agent!!!\n\nCode Puppy features a flexible agent system that allows you to work with specialized AI assistants tailored for different coding tasks. The system supports both built-in Python agents and custom JSON agents that you can create yourself.\n\n## Quick Start\n\n### Check Current Agent\n```bash\n/agent\n```\nShows current active agent and all available agents\n\n### Switch Agent\n```bash\n/agent <agent-name>\n```\nSwitches to the specified agent\n\n### Create New Agent\n```bash\n/agent agent-creator\n```\nSwitches to the Agent Creator for building custom agents\n\n## Available Agents\n\n### Code-Puppy \ud83d\udc36 (Default)\n- **Name**: `code-puppy`\n- **Specialty**: General-purpose coding assistant\n- **Personality**: Playful, sarcastic, pedantic about code quality\n- **Tools**: Full access to all tools\n- **Best for**: All coding tasks, file management, execution\n- **Principles**: Clean, concise code following YAGNI, SRP, DRY principles\n- **File limit**: Max 600 lines per file (enforced!)\n\n### Agent Creator \ud83c\udfd7\ufe0f\n- **Name**: `agent-creator`\n- **Specialty**: Creating custom JSON agent configurations\n- **Tools**: File operations, reasoning\n- **Best for**: Building new specialized agents\n- **Features**: Schema validation, guided creation process\n\n## Agent Types\n\n### Python Agents\nBuilt-in agents implemented in Python with full system integration:\n- Discovered automatically from `code_puppy/agents/` directory\n- Inherit from `BaseAgent` class\n- Full access to system internals\n- Examples: `code-puppy`, `agent-creator`\n\n### JSON Agents\nUser-created agents defined in JSON files:\n- Stored in user's agents directory\n- Easy to create, share, and modify\n- Schema-validated configuration\n- Custom system prompts and tool access\n\n## Creating Custom JSON Agents\n\n### Using Agent Creator (Recommended)\n\n1. **Switch to Agent Creator**:\n   ```bash\n   /agent agent-creator\n   ```\n\n2. **Request agent creation**:\n   ```\n   I want to create a Python tutor agent\n   ```\n\n3. **Follow guided process** to define:\n   - Name and description\n   - Available tools\n   - System prompt and behavior\n   - Custom settings\n\n4. **Test your new agent**:\n   ```bash\n   /agent your-new-agent-name\n   ```\n\n### Manual JSON Creation\n\nCreate JSON files in your agents directory following this schema:\n\n```json\n{\n  \"name\": \"agent-name\",              // REQUIRED: Unique identifier (kebab-case)\n  \"display_name\": \"Agent Name \ud83e\udd16\",   // OPTIONAL: Pretty name with emoji\n  \"description\": \"What this agent does\", // REQUIRED: Clear description\n  \"system_prompt\": \"Instructions...\",    // REQUIRED: Agent instructions\n  \"tools\": [\"tool1\", \"tool2\"],        // REQUIRED: Array of tool names\n  \"user_prompt\": \"How can I help?\",     // OPTIONAL: Custom greeting\n  \"tools_config\": {                    // OPTIONAL: Tool configuration\n    \"timeout\": 60\n  }\n}\n```\n\n#### Required Fields\n- **`name`**: Unique identifier (kebab-case, no spaces)\n- **`description`**: What the agent does\n- **`system_prompt`**: Agent instructions (string or array)\n- **`tools`**: Array of available tool names\n\n#### Optional Fields\n- **`display_name`**: Pretty display name (defaults to title-cased name + \ud83e\udd16)\n- **`user_prompt`**: Custom user greeting\n- **`tools_config`**: Tool configuration object\n\n## Available Tools\n\nAgents can access these tools based on their configuration:\n\n- **`list_files`**: Directory and file listing\n- **`read_file`**: File content reading\n- **`grep`**: Text search across files\n- **`edit_file`**: File editing and creation\n- **`delete_file`**: File deletion\n- **`agent_run_shell_command`**: Shell command execution\n- **`agent_share_your_reasoning`**: Share reasoning with user\n\n### Tool Access Examples\n- **Read-only agent**: `[\"list_files\", \"read_file\", \"grep\"]`\n- **File editor agent**: `[\"list_files\", \"read_file\", \"edit_file\"]`\n- **Full access agent**: All tools (like Code-Puppy)\n\n## System Prompt Formats\n\n### String Format\n```json\n{\n  \"system_prompt\": \"You are a helpful coding assistant that specializes in Python development.\"\n}\n```\n\n### Array Format (Recommended)\n```json\n{\n  \"system_prompt\": [\n    \"You are a helpful coding assistant.\",\n    \"You specialize in Python development.\",\n    \"Always provide clear explanations.\",\n    \"Include practical examples in your responses.\"\n  ]\n}\n```\n\n## Example JSON Agents\n\n### Python Tutor\n```json\n{\n  \"name\": \"python-tutor\",\n  \"display_name\": \"Python Tutor \ud83d\udc0d\",\n  \"description\": \"Teaches Python programming concepts with examples\",\n  \"system_prompt\": [\n    \"You are a patient Python programming tutor.\",\n    \"You explain concepts clearly with practical examples.\",\n    \"You help beginners learn Python step by step.\",\n    \"Always encourage learning and provide constructive feedback.\"\n  ],\n  \"tools\": [\"read_file\", \"edit_file\", \"agent_share_your_reasoning\"],\n  \"user_prompt\": \"What Python concept would you like to learn today?\"\n}\n```\n\n### Code Reviewer\n```json\n{\n  \"name\": \"code-reviewer\",\n  \"display_name\": \"Code Reviewer \ud83d\udd0d\",\n  \"description\": \"Reviews code for best practices, bugs, and improvements\",\n  \"system_prompt\": [\n    \"You are a senior software engineer doing code reviews.\",\n    \"You focus on code quality, security, and maintainability.\",\n    \"You provide constructive feedback with specific suggestions.\",\n    \"You follow language-specific best practices and conventions.\"\n  ],\n  \"tools\": [\"list_files\", \"read_file\", \"grep\", \"agent_share_your_reasoning\"],\n  \"user_prompt\": \"Which code would you like me to review?\"\n}\n```\n\n### DevOps Helper\n```json\n{\n  \"name\": \"devops-helper\",\n  \"display_name\": \"DevOps Helper \u2699\ufe0f\",\n  \"description\": \"Helps with Docker, CI/CD, and deployment tasks\",\n  \"system_prompt\": [\n    \"You are a DevOps engineer specialized in containerization and CI/CD.\",\n    \"You help with Docker, Kubernetes, GitHub Actions, and deployment.\",\n    \"You provide practical, production-ready solutions.\",\n    \"You always consider security and best practices.\"\n  ],\n  \"tools\": [\n    \"list_files\",\n    \"read_file\",\n    \"edit_file\",\n    \"agent_run_shell_command\",\n    \"agent_share_your_reasoning\"\n  ],\n  \"user_prompt\": \"What DevOps task can I help you with today?\"\n}\n```\n\n## File Locations\n\n### JSON Agents Directory\n- **All platforms**: `~/.code_puppy/agents/`\n\n### Python Agents Directory\n- **Built-in**: `code_puppy/agents/` (in package)\n\n## Best Practices\n\n### Naming\n- Use kebab-case (hyphens, not spaces)\n- Be descriptive: \"python-tutor\" not \"tutor\"\n- Avoid special characters\n\n### System Prompts\n- Be specific about the agent's role\n- Include personality traits\n- Specify output format preferences\n- Use array format for multi-line prompts\n\n### Tool Selection\n- Only include tools the agent actually needs\n- Most agents need `agent_share_your_reasoning`\n- File manipulation agents need `read_file`, `edit_file`\n- Research agents need `grep`, `list_files`\n\n### Display Names\n- Include relevant emoji for personality\n- Make it friendly and recognizable\n- Keep it concise\n\n## System Architecture\n\n### Agent Discovery\nThe system automatically discovers agents by:\n1. **Python Agents**: Scanning `code_puppy/agents/` for classes inheriting from `BaseAgent`\n2. **JSON Agents**: Scanning user's agents directory for `*-agent.json` files\n3. Instantiating and registering discovered agents\n\n### JSONAgent Implementation\nJSON agents are powered by the `JSONAgent` class (`code_puppy/agents/json_agent.py`):\n- Inherits from `BaseAgent` for full system integration\n- Loads configuration from JSON files with robust validation\n- Supports all BaseAgent features (tools, prompts, settings)\n- Cross-platform user directory support\n- Built-in error handling and schema validation\n\n### BaseAgent Interface\nBoth Python and JSON agents implement this interface:\n- `name`: Unique identifier\n- `display_name`: Human-readable name with emoji\n- `description`: Brief description of purpose\n- `get_system_prompt()`: Returns agent-specific system prompt\n- `get_available_tools()`: Returns list of tool names\n\n### Agent Manager Integration\nThe `agent_manager.py` provides:\n- Unified registry for both Python and JSON agents\n- Seamless switching between agent types\n- Configuration persistence across sessions\n- Automatic caching for performance\n\n### System Integration\n- **Command Interface**: `/agent` command works with all agent types\n- **Tool Filtering**: Dynamic tool access control per agent\n- **Main Agent System**: Loads and manages both agent types\n- **Cross-Platform**: Consistent behavior across all platforms\n\n## Adding Python Agents\n\nTo create a new Python agent:\n\n1. Create file in `code_puppy/agents/` (e.g., `my_agent.py`)\n2. Implement class inheriting from `BaseAgent`\n3. Define required properties and methods\n4. Agent will be automatically discovered\n\nExample implementation:\n\n```python\nfrom .base_agent import BaseAgent\n\nclass MyCustomAgent(BaseAgent):\n    @property\n    def name(self) -> str:\n        return \"my-agent\"\n    \n    @property\n    def display_name(self) -> str:\n        return \"My Custom Agent \u2728\"\n    \n    @property\n    def description(self) -> str:\n        return \"A custom agent for specialized tasks\"\n    \n    def get_system_prompt(self) -> str:\n        return \"Your custom system prompt here...\"\n    \n    def get_available_tools(self) -> list[str]:\n        return [\n            \"list_files\",\n            \"read_file\", \n            \"grep\",\n            \"edit_file\",\n            \"delete_file\",\n            \"agent_run_shell_command\",\n            \"agent_share_your_reasoning\"\n        ]\n```\n\n## Troubleshooting\n\n### Agent Not Found\n- Ensure JSON file is in correct directory\n- Check JSON syntax is valid\n- Restart Code Puppy or clear agent cache\n- Verify filename ends with `-agent.json`\n\n### Validation Errors\n- Use Agent Creator for guided validation\n- Check all required fields are present\n- Verify tool names are correct\n- Ensure name uses kebab-case\n\n### Permission Issues\n- Make sure agents directory is writable\n- Check file permissions on JSON files\n- Verify directory path exists\n\n## Advanced Features\n\n### Tool Configuration\n```json\n{\n  \"tools_config\": {\n    \"timeout\": 120,\n    \"max_retries\": 3\n  }\n}\n```\n\n### Multi-line System Prompts\n```json\n{\n  \"system_prompt\": [\n    \"Line 1 of instructions\",\n    \"Line 2 of instructions\",\n    \"Line 3 of instructions\"\n  ]\n}\n```\n\n## Future Extensibility\n\nThe agent system supports future expansion:\n\n- **Specialized Agents**: Code reviewers, debuggers, architects\n- **Domain-Specific Agents**: Web dev, data science, DevOps, mobile\n- **Personality Variations**: Different communication styles\n- **Context-Aware Agents**: Adapt based on project type\n- **Team Agents**: Shared configurations for coding standards\n- **Plugin System**: Community-contributed agents\n\n## Benefits of JSON Agents\n\n1. **Easy Customization**: Create agents without Python knowledge\n2. **Team Sharing**: JSON agents can be shared across teams\n3. **Rapid Prototyping**: Quick agent creation for specific workflows\n4. **Version Control**: JSON agents are git-friendly\n5. **Built-in Validation**: Schema validation with helpful error messages\n6. **Cross-Platform**: Works consistently across all platforms\n7. **Backward Compatible**: Doesn't affect existing Python agents\n\n## Implementation Details\n\n### Files in System\n- **Core Implementation**: `code_puppy/agents/json_agent.py`\n- **Agent Discovery**: Integrated in `code_puppy/agents/agent_manager.py`\n- **Command Interface**: Works through existing `/agent` command\n- **Testing**: Comprehensive test suite in `tests/test_json_agents.py`\n\n### JSON Agent Loading Process\n1. System scans `~/.code_puppy/agents/` for `*-agent.json` files\n2. `JSONAgent` class loads and validates each JSON configuration\n3. Agents are registered in unified agent registry\n4. Users can switch to JSON agents via `/agent <name>` command\n5. Tool access and system prompts work identically to Python agents\n\n### Error Handling\n- Invalid JSON syntax: Clear error messages with line numbers\n- Missing required fields: Specific field validation errors\n- Invalid tool names: Warning with list of available tools\n- File permission issues: Helpful troubleshooting guidance\n\n## Future Possibilities\n\n- **Agent Templates**: Pre-built JSON agents for common tasks\n- **Visual Editor**: GUI for creating JSON agents\n- **Hot Reloading**: Update agents without restart\n- **Agent Marketplace**: Share and discover community agents\n- **Enhanced Validation**: More sophisticated schema validation\n- **Team Agents**: Shared configurations for coding standards\n\n## Contributing\n\n### Sharing JSON Agents\n1. Create and test your agent thoroughly\n2. Ensure it follows best practices\n3. Submit a pull request with agent JSON\n4. Include documentation and examples\n5. Test across different platforms\n\n### Python Agent Contributions\n1. Follow existing code style\n2. Include comprehensive tests\n3. Document the agent's purpose and usage\n4. Submit pull request for review\n5. Ensure backward compatibility\n\n### Agent Templates\nConsider contributing agent templates for:\n- Code reviewers and auditors\n- Language-specific tutors\n- DevOps and deployment helpers\n- Documentation writers\n- Testing specialists\n\n---\n\n**Happy Agent Building!** \ud83d\ude80 Code Puppy now supports both Python and JSON agents, making it easy for anyone to create custom AI coding assistants! \ud83d\udc36\u2728\n\n\n## Conclusion\nBy using Code Puppy, you can maintain code quality and adhere to design guidelines with ease.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Code generation agent",
    "version": "0.0.126",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4a65d861641abc0524e674384bde26edc01d73dab2bfdf67299cacda8f1f8899",
                "md5": "d544ca358c02d2ddfbc1e49f66042f6f",
                "sha256": "1f797e2406449d3a56c62771eeced57089fcd606cf92018f4498b9dc717777ed"
            },
            "downloads": -1,
            "filename": "code_puppy-0.0.126-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d544ca358c02d2ddfbc1e49f66042f6f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 163638,
            "upload_time": "2025-08-29T19:53:46",
            "upload_time_iso_8601": "2025-08-29T19:53:46.103354Z",
            "url": "https://files.pythonhosted.org/packages/4a/65/d861641abc0524e674384bde26edc01d73dab2bfdf67299cacda8f1f8899/code_puppy-0.0.126-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8311a5842af73682d89f2b2097ba922a06dd135e574c2f26e763c466a9fcb108",
                "md5": "a234933b0d1ce9bc6462c3d4bc9cdce4",
                "sha256": "c6b871237abd5495fdb5b2334e376401f7ebfcc4a4a109f92236b3c18f9c940a"
            },
            "downloads": -1,
            "filename": "code_puppy-0.0.126.tar.gz",
            "has_sig": false,
            "md5_digest": "a234933b0d1ce9bc6462c3d4bc9cdce4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 121675,
            "upload_time": "2025-08-29T19:53:47",
            "upload_time_iso_8601": "2025-08-29T19:53:47.554905Z",
            "url": "https://files.pythonhosted.org/packages/83/11/a5842af73682d89f2b2097ba922a06dd135e574c2f26e763c466a9fcb108/code_puppy-0.0.126.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-29 19:53:47",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "code-puppy"
}
        
Elapsed time: 1.44369s