Fix linting violations for v1.0.0 release preparation

- Apply black formatting to all Python files
- Fix various flake8 violations in agent system code
- Clean up imports and whitespace issues

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-19 20:44:58 +02:00
parent 30daabf12c
commit d68310793b
9 changed files with 432 additions and 289 deletions

View File

@@ -1,15 +1,15 @@
"""Detection and analysis of existing agent systems in projects."""
import json
import yaml
from pathlib import Path
from typing import Dict, List, Optional, Set, Tuple
from typing import List, Optional, Set, Tuple
from dataclasses import dataclass
from enum import Enum
class AgentSystemType(Enum):
"""Types of existing agent systems that might be found."""
KAIZEN_AGENTIC = "kaizen-agentic"
CLAUDE_CODE = "claude-code"
GITHUB_COPILOT = "github-copilot"
@@ -25,6 +25,7 @@ class AgentSystemType(Enum):
@dataclass
class DetectedAgent:
"""Information about a detected agent."""
name: str
type: AgentSystemType
file_path: Path
@@ -44,6 +45,7 @@ class DetectedAgent:
@dataclass
class AgentSystemDetectionResult:
"""Result of agent system detection in a project."""
project_path: Path
detected_systems: List[AgentSystemType]
agents: List[DetectedAgent]
@@ -197,33 +199,37 @@ class AgentSystemDetector:
agents.append(agent)
except Exception as e:
# Create a detected agent with error info
agents.append(DetectedAgent(
name=agent_file.stem.replace("agent-", ""),
type=AgentSystemType.KAIZEN_AGENTIC,
file_path=agent_file,
can_migrate=False,
migration_notes=f"Parse error: {e}"
))
agents.append(
DetectedAgent(
name=agent_file.stem.replace("agent-", ""),
type=AgentSystemType.KAIZEN_AGENTIC,
file_path=agent_file,
can_migrate=False,
migration_notes=f"Parse error: {e}",
)
)
return agents
def _parse_kaizen_agent_file(self, agent_file: Path) -> Optional[DetectedAgent]:
"""Parse a Kaizen Agentic agent file."""
try:
content = agent_file.read_text(encoding='utf-8')
content = agent_file.read_text(encoding="utf-8")
# Extract YAML frontmatter
if content.startswith('---'):
parts = content.split('---', 2)
if content.startswith("---"):
parts = content.split("---", 2)
if len(parts) >= 3:
frontmatter = yaml.safe_load(parts[1])
return DetectedAgent(
name=frontmatter.get('name', agent_file.stem.replace("agent-", "")),
name=frontmatter.get(
"name", agent_file.stem.replace("agent-", "")
),
type=AgentSystemType.KAIZEN_AGENTIC,
file_path=agent_file,
description=frontmatter.get('description'),
dependencies=set(frontmatter.get('dependencies', []))
description=frontmatter.get("description"),
dependencies=set(frontmatter.get("dependencies", [])),
)
except Exception:
pass
@@ -238,12 +244,14 @@ class AgentSystemDetector:
if claude_file.exists():
# Claude Code typically doesn't have separate agent files
# but might reference agent usage in CLAUDE.md
agents.append(DetectedAgent(
name="claude-integration",
type=AgentSystemType.CLAUDE_CODE,
file_path=claude_file,
description="Claude Code integration configuration"
))
agents.append(
DetectedAgent(
name="claude-integration",
type=AgentSystemType.CLAUDE_CODE,
file_path=claude_file,
description="Claude Code integration configuration",
)
)
return agents
@@ -261,15 +269,20 @@ class AgentSystemDetector:
for pattern in ["*.py", "*.yml", "*.yaml", "*.json", "*.md"]:
for agent_file in agent_dir.glob(pattern):
# Skip kaizen-agentic files
if agent_file.name.startswith("agent-") and agent_file.suffix == ".md":
if (
agent_file.name.startswith("agent-")
and agent_file.suffix == ".md"
):
continue
agents.append(DetectedAgent(
name=agent_file.stem,
type=AgentSystemType.CUSTOM_AGENTS,
file_path=agent_file,
description=f"Custom agent in {dir_name}/"
))
agents.append(
DetectedAgent(
name=agent_file.stem,
type=AgentSystemType.CUSTOM_AGENTS,
file_path=agent_file,
description=f"Custom agent in {dir_name}/",
)
)
return agents
@@ -286,7 +299,9 @@ class AgentSystemDetector:
return config_files
def _analyze_conflicts(self, agents: List[DetectedAgent]) -> List[Tuple[str, str, str]]:
def _analyze_conflicts(
self, agents: List[DetectedAgent]
) -> List[Tuple[str, str, str]]:
"""Analyze potential conflicts between agents."""
conflicts = []
@@ -298,15 +313,16 @@ class AgentSystemDetector:
agents_by_type[agent.type].append(agent)
# Check for naming conflicts
all_names = [agent.name for agent in agents]
for i, agent1 in enumerate(agents):
for j, agent2 in enumerate(agents[i+1:], i+1):
for j, agent2 in enumerate(agents[i + 1 :], i + 1):
if agent1.name == agent2.name and agent1.type != agent2.type:
conflicts.append((
agent1.name,
agent2.name,
f"Name conflict between {agent1.type.value} and {agent2.type.value}"
))
conflicts.append(
(
agent1.name,
agent2.name,
f"Name conflict between {agent1.type.value} and {agent2.type.value}",
)
)
# Check for functional overlaps
functional_conflicts = {
@@ -324,12 +340,14 @@ class AgentSystemDetector:
if len(matching_agents) > 1:
for i, agent1 in enumerate(matching_agents):
for agent2 in matching_agents[i+1:]:
conflicts.append((
agent1.name,
agent2.name,
f"Functional overlap: {conflict_type}"
))
for agent2 in matching_agents[i + 1 :]:
conflicts.append(
(
agent1.name,
agent2.name,
f"Functional overlap: {conflict_type}",
)
)
return conflicts
@@ -343,7 +361,10 @@ class AgentSystemDetector:
if AgentSystemType.KAIZEN_AGENTIC in detected_systems:
return "update_existing"
if len(detected_systems) == 1 and detected_systems[0] == AgentSystemType.CLAUDE_CODE:
if (
len(detected_systems) == 1
and detected_systems[0] == AgentSystemType.CLAUDE_CODE
):
return "claude_compatible"
if len([a for a in agents if a.type == AgentSystemType.CUSTOM_AGENTS]) > 5:
@@ -355,13 +376,15 @@ class AgentSystemDetector:
self,
detected_systems: List[AgentSystemType],
agents: List[DetectedAgent],
conflicts: List[Tuple[str, str, str]]
conflicts: List[Tuple[str, str, str]],
) -> List[str]:
"""Generate migration recommendations."""
recommendations = []
if not detected_systems:
recommendations.append("Clean installation - no existing agent systems detected")
recommendations.append(
"Clean installation - no existing agent systems detected"
)
return recommendations
if AgentSystemType.KAIZEN_AGENTIC in detected_systems:
@@ -369,18 +392,26 @@ class AgentSystemDetector:
recommendations.append("Run 'kaizen-agentic update' to get latest agents")
if conflicts:
recommendations.append(f"Resolve {len(conflicts)} naming/functional conflicts")
recommendations.append(
f"Resolve {len(conflicts)} naming/functional conflicts"
)
for agent1, agent2, reason in conflicts:
recommendations.append(f" - Conflict: {agent1} vs {agent2} ({reason})")
custom_agents = [a for a in agents if a.type == AgentSystemType.CUSTOM_AGENTS]
if custom_agents:
recommendations.append(f"Consider migrating {len(custom_agents)} custom agents")
recommendations.append(" - Review custom agents for Kaizen Agentic equivalents")
recommendations.append(" - Create project-specific extensions for unique functionality")
recommendations.append(
f"Consider migrating {len(custom_agents)} custom agents"
)
recommendations.append(
" - Review custom agents for Kaizen Agentic equivalents"
)
recommendations.append(
" - Create project-specific extensions for unique functionality"
)
if AgentSystemType.CLAUDE_CODE in detected_systems:
recommendations.append("Maintain Claude Code compatibility")
recommendations.append(" - Update CLAUDE.md with new agent references")
return recommendations
return recommendations