Implement hybrid agent distribution system

Complete implementation of the agent distribution framework including:

CORE INFRASTRUCTURE:
- AgentRegistry: Agent discovery, categorization, and dependency management
- AgentInstaller: Agent installation, updates, and removal with safety measures
- ProjectInitializer: Template-based project initialization with agent integration
- CLI Tool: Comprehensive kaizen-agentic command-line interface

DISTRIBUTION FEATURES:
- Python package distribution with console script entry point
- Agent categorization (project-management, development-process, code-quality, etc.)
- Project templates (python-basic, python-web, python-cli, python-data, comprehensive)
- Dependency resolution and validation
- Idempotent operations with backup and rollback support

CLI COMMANDS:
- kaizen-agentic init: Initialize new projects with agents
- kaizen-agentic install/update/remove: Manage agents in existing projects
- kaizen-agentic list/status/validate: Discovery and maintenance
- kaizen-agentic templates: Project template management

INTEGRATION & DOCUMENTATION:
- Makefile targets for agent management (list-agents, update-agents, etc.)
- Automatic Claude Code configuration updates (CLAUDE.md)
- Comprehensive documentation (GETTING_STARTED, AGENT_DISTRIBUTION, CLI_CHEAT_SHEET)
- Multi-language build system integration examples
- Complete test coverage for all components

PACKAGE STRUCTURE:
- Console script: kaizen-agentic command available globally
- Package data: All agents included for distribution
- Dependencies: click, pyyaml for CLI and parsing
- Testing: Comprehensive test suite for registry and installer

This enables sharing specialized AI agents across projects with easy installation,
updates, and management through both CLI and integrated Makefile targets.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-19 02:31:15 +02:00
parent cf45bea63b
commit 38965c1d4a
28 changed files with 6402 additions and 3 deletions

415
docs/AGENT_DISTRIBUTION.md Normal file
View File

@@ -0,0 +1,415 @@
# Agent Distribution Guide
This guide explains how to use the Kaizen Agentic agent distribution system to share specialized agents across projects.
## Overview
The Kaizen Agentic framework provides a comprehensive system for distributing and managing AI agents across multiple projects. This enables:
- **Reusable Agents**: Share specialized agents between projects
- **Consistent Workflows**: Maintain the same development patterns across teams
- **Easy Updates**: Update agents across all projects from a central registry
- **Template-Based Initialization**: Start new projects with predefined agent collections
## Installation
Install the Kaizen Agentic package:
```bash
pip install kaizen-agentic
```
This provides the `kaizen-agentic` CLI tool for managing agents.
## CLI Commands
### List Available Agents
```bash
# List all available agents
kaizen-agentic list
# List agents by category
kaizen-agentic list --category project-management
# List with detailed information
kaizen-agentic list --verbose
```
### Initialize New Projects
```bash
# Initialize with default Python template
kaizen-agentic init my-project
# Use specific template
kaizen-agentic init web-app --template python-web
# Use custom agent selection
kaizen-agentic init data-project --agents todo-keeper,datamodel-optimization,testing-efficiency
# Initialize in specific directory
kaizen-agentic init my-project --parent-dir ~/projects
```
### Install Agents in Existing Projects
```bash
# Install specific agents
kaizen-agentic install todo-keeper changelog-keeper
# Install to specific directory
kaizen-agentic install tdd-workflow --target ~/my-project
# Install without backup
kaizen-agentic install code-refactoring --no-backup
# Install without updating documentation
kaizen-agentic install testing-efficiency --no-docs
```
### Manage Installed Agents
```bash
# List installed agents
kaizen-agentic status
# Update all installed agents
kaizen-agentic update
# Update specific agents
kaizen-agentic update todo-keeper changelog-keeper
# Remove agents
kaizen-agentic remove old-agent-name
# Validate agents
kaizen-agentic validate
```
### Project Templates
```bash
# List available templates
kaizen-agentic templates
# Available templates:
# - python-basic: Basic Python project setup
# - python-web: Web application development
# - python-cli: Command-line tool development
# - python-data: Data science and analysis
# - comprehensive: All available agents
```
## Project Structure
When you install agents, they're organized in your project as follows:
```
my-project/
├── agents/ # Installed agent definitions
│ ├── agent-todo-keeper.md
│ ├── agent-changelog-keeper.md
│ └── agent-tdd-workflow.md
├── src/
├── tests/
├── CLAUDE.md # Updated with agent information
├── Makefile # Enhanced with agent targets
└── pyproject.toml
```
## Agent Categories
Agents are organized into categories for easy discovery:
### Project Management
- `todo-keeper`: Manages TODO.md files following Keep a Todofile format
- `changelog-keeper`: Maintains CHANGELOG.md files following Keep a Changelog format
- `contributing-keeper`: Creates and updates CONTRIBUTING.md files
- `project-assistant`: General project management and coordination
### Development Process
- `tdd-workflow`: Test-driven development workflow guidance
- `requirements-engineering`: Requirements analysis and documentation
- `test-maintenance`: Test suite maintenance and optimization
- `priority-evaluation`: Feature and task prioritization
### Code Quality
- `code-refactoring`: Code improvement and refactoring guidance
- `agent-optimization`: Agent definition optimization and improvement
- `datamodel-optimization`: Data model design and optimization
- `tooling-optimization`: Development tool configuration and optimization
### Infrastructure
- `setup-repository`: Repository initialization and standards compliance
- `claude-documentation`: Claude Code configuration and documentation
- `testing-efficiency`: Testing infrastructure optimization
- `wisdom-encouragement`: Development philosophy and best practices
## Usage Patterns
### New Project Setup
1. **Initialize Project**:
```bash
kaizen-agentic init my-web-app --template python-web
cd my-web-app
```
2. **Set Up Development Environment**:
```bash
make setup-complete
source .venv/bin/activate
```
3. **Start Development**:
```bash
make test # Run tests
make lint # Check code quality
make format # Format code
```
### Adding Agents to Existing Project
1. **Install Needed Agents**:
```bash
kaizen-agentic install todo-keeper changelog-keeper
```
2. **Verify Installation**:
```bash
kaizen-agentic status
kaizen-agentic validate
```
3. **Use Agents**:
- Reference agents in Claude Code conversations
- Use agent-specific Makefile targets
- Follow agent-guided workflows
### Maintaining Agent Updates
1. **Check for Updates**:
```bash
kaizen-agentic status
```
2. **Update All Agents**:
```bash
kaizen-agentic update
```
3. **Validate After Update**:
```bash
kaizen-agentic validate
```
## Integration with Development Tools
### Claude Code Integration
Agents automatically integrate with Claude Code:
- **CLAUDE.md**: Updated with agent descriptions and usage
- **Agent References**: Use agents by name in Claude conversations
- **Workflow Integration**: Agents guide Claude Code interactions
### Makefile Integration
The CLI automatically adds agent management targets:
```bash
make list-agents # List installed agents
make update-agents # Update to latest versions
make validate-agents # Validate agent definitions
```
### Documentation Integration
Agents automatically update project documentation:
- **README.md**: Enhanced with agent information
- **CONTRIBUTING.md**: Updated with agent-assisted workflows
- **CLAUDE.md**: Complete agent catalog and usage instructions
## Advanced Usage
### Custom Agent Templates
Create custom templates by modifying the registry:
```python
from kaizen_agentic import AgentRegistry
registry = AgentRegistry("path/to/agents")
# Add custom template
custom_template = {
"my-template": [
"todo-keeper",
"custom-agent",
"code-refactoring"
]
}
templates = registry.get_agent_templates()
templates.update(custom_template)
```
### Programmatic Agent Management
Use the Python API for custom integrations:
```python
from kaizen_agentic import AgentInstaller, AgentRegistry, InstallationConfig
from pathlib import Path
# Set up registry and installer
registry = AgentRegistry("agents/")
installer = AgentInstaller(registry)
# Configure installation
config = InstallationConfig(
target_dir=Path("my-project"),
claude_config_path=Path("my-project/CLAUDE.md"),
update_docs=True
)
# Install agents
results = installer.install_agents(["todo-keeper", "tdd-workflow"], config)
```
### Agent Development
Create new agents by following the standard format:
```yaml
---
name: my-custom-agent
description: Custom agent for specific needs
model: inherit
---
# My Custom Agent
## Instructions
[Agent instructions and capabilities]
## Authority and Scope
[What the agent can and cannot do]
## Response Guidelines
[How the agent should respond and behave]
```
## Best Practices
### Agent Selection
1. **Start Small**: Begin with basic agents (todo-keeper, changelog-keeper)
2. **Add Gradually**: Introduce more specialized agents as needed
3. **Match Project Type**: Use appropriate templates for your project type
4. **Consider Dependencies**: Let the system resolve agent dependencies
### Maintenance
1. **Regular Updates**: Update agents monthly or before major releases
2. **Validation**: Always validate after updates or changes
3. **Backup**: Keep backups when experimenting with new agents
4. **Documentation**: Keep CLAUDE.md and project docs updated
### Team Coordination
1. **Shared Templates**: Agree on standard templates for your team
2. **Agent Standards**: Establish which agents are required/optional
3. **Update Schedules**: Coordinate agent updates across team projects
4. **Training**: Ensure team members understand agent capabilities
## Troubleshooting
### Common Issues
**Agent Not Found**:
```bash
# Check available agents
kaizen-agentic list
# Validate registry
kaizen-agentic validate
```
**Installation Failures**:
```bash
# Check target directory permissions
# Verify agent file integrity
kaizen-agentic validate --target /path/to/project
```
**Update Problems**:
```bash
# Force reinstall
kaizen-agentic remove problematic-agent
kaizen-agentic install problematic-agent
```
### Getting Help
1. **Validate Configuration**: Use `kaizen-agentic validate`
2. **Check Status**: Use `kaizen-agentic status`
3. **Review Logs**: Check command output for error details
4. **Community Support**: Refer to project documentation and issues
## Migration Guide
### From Manual Agent Management
If you're currently managing agents manually:
1. **Inventory Current Agents**:
```bash
ls agents/agent-*.md
```
2. **Install Package**:
```bash
pip install kaizen-agentic
```
3. **Validate Current Setup**:
```bash
kaizen-agentic validate
```
4. **Update to Standard Agents**:
```bash
kaizen-agentic update
```
### Between Versions
When updating Kaizen Agentic versions:
1. **Backup Current Agents**:
```bash
cp -r agents/ agents_backup/
```
2. **Update Package**:
```bash
pip install --upgrade kaizen-agentic
```
3. **Update Agents**:
```bash
kaizen-agentic update
```
4. **Validate**:
```bash
kaizen-agentic validate
```
This distribution system makes it easy to share and maintain consistent development workflows across all your projects using specialized AI agents.

197
docs/CLI_CHEAT_SHEET.md Normal file
View File

@@ -0,0 +1,197 @@
# Kaizen Agentic CLI Cheat Sheet
Quick reference for the `kaizen-agentic` command-line tool.
## Installation
```bash
pip install kaizen-agentic
```
## Core Commands
### Project Initialization
```bash
# New project with default template
kaizen-agentic init my-project
# New project with specific template
kaizen-agentic init web-app --template python-web
# New project with custom agents
kaizen-agentic init cli-tool --agents todo-keeper,tdd-workflow,claude-documentation
# Initialize in specific directory
kaizen-agentic init my-project --parent-dir ~/projects
```
### Agent Management
```bash
# List available agents
kaizen-agentic list
kaizen-agentic list --category project-management
kaizen-agentic list --verbose
# Install agents
kaizen-agentic install todo-keeper changelog-keeper
kaizen-agentic install tdd-workflow --target ~/my-project
kaizen-agentic install code-refactoring --no-backup --no-docs
# Update agents
kaizen-agentic update # Update all installed
kaizen-agentic update todo-keeper # Update specific agents
# Remove agents
kaizen-agentic remove old-agent-name
# Project status
kaizen-agentic status # Show current project status
kaizen-agentic validate # Validate agent installation
```
### Information
```bash
# List templates
kaizen-agentic templates
# Show help
kaizen-agentic --help
kaizen-agentic install --help # Command-specific help
# Version
kaizen-agentic --version
```
## Common Workflows
### Setting Up New Python Web Project
```bash
kaizen-agentic init my-web-app --template python-web
cd my-web-app
make setup-complete
make test
```
### Adding Agents to Existing Project
```bash
cd existing-project
kaizen-agentic install todo-keeper changelog-keeper
kaizen-agentic status
```
### Maintaining Agents
```bash
# Weekly maintenance
kaizen-agentic update
kaizen-agentic validate
# Check what's installed
kaizen-agentic status
```
### Team Onboarding
```bash
git clone team-repo
cd team-repo
pip install kaizen-agentic
kaizen-agentic status # See what agents are used
cat CLAUDE.md # Read agent documentation
```
## Agent Categories
| Category | Example Agents | Use Cases |
|----------|----------------|-----------|
| `project-management` | todo-keeper, changelog-keeper | Task tracking, documentation |
| `development-process` | tdd-workflow, requirements-engineering | Development methodology |
| `code-quality` | code-refactoring, datamodel-optimization | Code improvement |
| `infrastructure` | setup-repository, testing-efficiency | Project setup, tooling |
| `testing` | test-maintenance, tdd-workflow | Test management |
| `documentation` | claude-documentation, contributing-keeper | Documentation management |
## Templates
| Template | Agents Included | Best For |
|----------|----------------|----------|
| `python-basic` | setup-repository, todo-keeper, changelog-keeper | Simple Python projects |
| `python-web` | Basic + tdd-workflow, code-refactoring, contributing-keeper | Web applications |
| `python-cli` | Basic + testing-efficiency, claude-documentation | Command-line tools |
| `python-data` | Basic + datamodel-optimization, requirements-engineering | Data science |
| `comprehensive` | All available agents | Complex projects |
## Integration Commands
### Without Makefile
```bash
# Direct CLI usage when Makefile targets aren't available
kaizen-agentic status # Instead of: make list-agents
kaizen-agentic update # Instead of: make update-agents
kaizen-agentic validate # Instead of: make validate-agents
```
### With Build Tools
**npm/package.json:**
```json
{
"scripts": {
"agents:status": "kaizen-agentic status",
"agents:update": "kaizen-agentic update"
}
}
```
**Make targets (auto-added):**
```bash
make list-agents # List installed agents
make update-agents # Update agents
make validate-agents # Validate agents
make agent-status # Show detailed status
```
## Troubleshooting
### Common Issues
```bash
# Command not found
pip install kaizen-agentic
# No agents directory
kaizen-agentic install todo-keeper
# Validation errors
kaizen-agentic validate
kaizen-agentic remove problematic-agent
kaizen-agentic install problematic-agent
```
### Getting Help
```bash
kaizen-agentic --help # General help
kaizen-agentic COMMAND --help # Command help
kaizen-agentic status # Check current state
kaizen-agentic validate # Validate setup
```
## Quick Examples
**Start a data science project:**
```bash
kaizen-agentic init ml-project --template python-data
cd ml-project && make setup-complete
```
**Add testing workflow to existing project:**
```bash
kaizen-agentic install tdd-workflow testing-efficiency
```
**Update all agents monthly:**
```bash
kaizen-agentic update && kaizen-agentic validate
```
**Check what agents a project uses:**
```bash
kaizen-agentic status
cat CLAUDE.md # Detailed info
```

410
docs/GETTING_STARTED.md Normal file
View File

@@ -0,0 +1,410 @@
# Getting Started with Kaizen Agentic Agents
This guide walks you through using Kaizen Agentic agents in any project, from initial installation to full integration.
## Quick Start
### 1. Install the Package
```bash
pip install kaizen-agentic
```
This gives you the `kaizen-agentic` command globally.
### 2. Verify Installation
```bash
kaizen-agentic --version
kaizen-agentic list
```
You should see the available agents listed.
## For New Projects
### Option A: Initialize with Agents (Recommended)
```bash
# Create a new project with agents included
kaizen-agentic init my-project --template python-web
# Navigate to project
cd my-project
# Set up development environment (agents provide this Makefile)
make setup-complete
# You now have all the Makefile targets available!
make help
```
### Option B: Manual Project Setup
```bash
# Create project directory
mkdir my-project
cd my-project
# Initialize git
git init
# Install agents
kaizen-agentic install setup-repository todo-keeper changelog-keeper
# The setup-repository agent can create the full project structure
# Use it via Claude Code or manually follow its patterns
```
## For Existing Projects
### Step 1: Install Agents
```bash
# Navigate to your existing project
cd /path/to/your/project
# Install relevant agents
kaizen-agentic install todo-keeper changelog-keeper tdd-workflow
# Check what was installed
kaizen-agentic status
```
### Step 2: Integrate with Build System
The agents will create/update files, but you need to integrate with your build system:
#### If you have a Makefile:
```bash
# Add these targets to your existing Makefile:
cat >> Makefile << 'EOF'
# Agent Management (added by kaizen-agentic)
list-agents:
@echo "Installed agents:"
@ls agents/ 2>/dev/null | grep agent- | sed 's/agent-//g' | sed 's/.md//g' | sort
update-agents:
@kaizen-agentic update
validate-agents:
@kaizen-agentic validate
agent-status:
@kaizen-agentic status
EOF
```
#### If you use npm/package.json:
```json
{
"scripts": {
"agents:list": "ls agents/ | grep agent- | sed 's/agent-//g' | sed 's/.md//g'",
"agents:update": "kaizen-agentic update",
"agents:validate": "kaizen-agentic validate",
"agents:status": "kaizen-agentic status"
}
}
```
#### If you use Python/pyproject.toml:
```toml
[project.optional-dependencies]
agents = ["kaizen-agentic>=0.1.0"]
[tool.setuptools]
# Include agents in package data if needed
```
### Step 3: Update Documentation
```bash
# Agents automatically update CLAUDE.md, but you can also manually check:
kaizen-agentic status
# Update your README.md to mention agent usage:
echo "
## AI Agents
This project uses Kaizen Agentic agents for development workflow automation.
- List agents: \`kaizen-agentic list\`
- Check status: \`kaizen-agentic status\`
- Update agents: \`kaizen-agentic update\`
See CLAUDE.md for detailed agent information.
" >> README.md
```
## Working Without Make Targets
If you're in a project without the Kaizen Agentic Makefile targets, you can still use all functionality:
### Direct CLI Usage
```bash
# Instead of 'make list-agents'
kaizen-agentic status
# Instead of 'make update-agents'
kaizen-agentic update
# Instead of 'make validate-agents'
kaizen-agentic validate
# Install new agents
kaizen-agentic install code-refactoring testing-efficiency
# Remove agents you don't need
kaizen-agentic remove old-agent-name
```
### Integration Patterns
#### 1. IDE Integration
Most IDEs can run arbitrary commands. Add these as external tools:
**VS Code tasks.json:**
```json
{
"version": "2.0.0",
"tasks": [
{
"label": "List Agents",
"type": "shell",
"command": "kaizen-agentic",
"args": ["status"],
"group": "build"
},
{
"label": "Update Agents",
"type": "shell",
"command": "kaizen-agentic",
"args": ["update"],
"group": "build"
}
]
}
```
#### 2. Git Hooks Integration
```bash
# Add to .git/hooks/pre-commit
#!/bin/sh
kaizen-agentic validate
```
#### 3. CI/CD Integration
**GitHub Actions (.github/workflows/agents.yml):**
```yaml
name: Validate Agents
on: [push, pull_request]
jobs:
validate-agents:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- run: pip install kaizen-agentic
- run: kaizen-agentic validate
```
#### 4. Shell Aliases
```bash
# Add to your ~/.bashrc or ~/.zshrc
alias ka="kaizen-agentic"
alias ka-status="kaizen-agentic status"
alias ka-update="kaizen-agentic update"
alias ka-list="kaizen-agentic list"
# Now you can use:
# ka status
# ka update
# ka install todo-keeper
```
## Language-Specific Integration
### Python Projects
```bash
# Add to requirements-dev.txt or pyproject.toml
kaizen-agentic>=0.1.0
# Use in scripts
python -c "
import subprocess
subprocess.run(['kaizen-agentic', 'status'])
"
```
### Node.js Projects
```bash
# Add agents commands to package.json scripts
npm run agents:status # -> kaizen-agentic status
npm run agents:update # -> kaizen-agentic update
```
### Ruby Projects
```ruby
# Add to Rakefile
task :agents_status do
system('kaizen-agentic status')
end
task :agents_update do
system('kaizen-agentic update')
end
```
### Java/Gradle Projects
```gradle
// Add to build.gradle
task agentsStatus(type: Exec) {
commandLine 'kaizen-agentic', 'status'
}
task agentsUpdate(type: Exec) {
commandLine 'kaizen-agentic', 'update'
}
```
## Discovery and Learning
### Find Relevant Agents
```bash
# Browse all available agents
kaizen-agentic list --verbose
# Look at specific categories
kaizen-agentic list --category project-management
kaizen-agentic list --category testing
kaizen-agentic list --category code-quality
# See what templates include
kaizen-agentic templates
```
### Understanding Agents
```bash
# Check what's installed in your project
kaizen-agentic status
# Read agent files directly
ls agents/
cat agents/agent-todo-keeper.md
# Validate your setup
kaizen-agentic validate
```
### Getting Help
```bash
# General help
kaizen-agentic --help
# Command-specific help
kaizen-agentic install --help
kaizen-agentic init --help
# Check version
kaizen-agentic --version
```
## Workflow Examples
### Starting a New Feature
```bash
# 1. Check current agents
kaizen-agentic status
# 2. Add agents for the feature (if needed)
kaizen-agentic install requirements-engineering code-refactoring
# 3. Use agents in Claude Code
# Reference them by name in your conversations
# 4. Update project documentation as you work
```
### Maintaining Agents
```bash
# Weekly agent maintenance
kaizen-agentic update
kaizen-agentic validate
# Before major releases
kaizen-agentic status
# Review agent output and update project docs accordingly
```
### Team Onboarding
```bash
# New team member setup
git clone project-repo
cd project-repo
pip install kaizen-agentic # or add to requirements
kaizen-agentic status # See what agents are used
kaizen-agentic validate # Verify everything works
# Read the agent documentation
cat CLAUDE.md
```
## Troubleshooting
### Common Issues
**"Command not found: kaizen-agentic"**
```bash
# Install the package
pip install kaizen-agentic
# Or if using virtual env:
source .venv/bin/activate
pip install kaizen-agentic
```
**"No agents directory found"**
```bash
# Install some agents first
kaizen-agentic install todo-keeper
# Or initialize a new project
kaizen-agentic init . --agents todo-keeper,changelog-keeper
```
**"Agent validation fails"**
```bash
# Check specific errors
kaizen-agentic validate
# Reinstall problematic agents
kaizen-agentic remove problematic-agent
kaizen-agentic install problematic-agent
```
### Getting Support
1. **Check Status**: `kaizen-agentic status`
2. **Validate Setup**: `kaizen-agentic validate`
3. **Review Documentation**: Check CLAUDE.md and agent files
4. **Community Help**: Refer to project issues and documentation
## Next Steps
Once you have agents installed:
1. **Use them in Claude Code**: Reference agents by name in conversations
2. **Follow agent workflows**: Let agents guide your development process
3. **Keep them updated**: Regular `kaizen-agentic update`
4. **Share with team**: Document which agents your project uses
5. **Contribute back**: Report issues and suggest improvements
The key insight is that **you don't need the Makefile targets to use agents effectively** - the `kaizen-agentic` CLI provides all the functionality you need. The Makefile targets are just convenient shortcuts for projects that have them.