crackerjack 0.30.3__py3-none-any.whl → 0.31.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of crackerjack might be problematic. Click here for more details.
- crackerjack/CLAUDE.md +1005 -0
- crackerjack/RULES.md +380 -0
- crackerjack/__init__.py +42 -13
- crackerjack/__main__.py +227 -299
- crackerjack/agents/__init__.py +41 -0
- crackerjack/agents/architect_agent.py +281 -0
- crackerjack/agents/base.py +170 -0
- crackerjack/agents/coordinator.py +512 -0
- crackerjack/agents/documentation_agent.py +498 -0
- crackerjack/agents/dry_agent.py +388 -0
- crackerjack/agents/formatting_agent.py +245 -0
- crackerjack/agents/import_optimization_agent.py +281 -0
- crackerjack/agents/performance_agent.py +669 -0
- crackerjack/agents/proactive_agent.py +104 -0
- crackerjack/agents/refactoring_agent.py +788 -0
- crackerjack/agents/security_agent.py +529 -0
- crackerjack/agents/test_creation_agent.py +657 -0
- crackerjack/agents/test_specialist_agent.py +486 -0
- crackerjack/agents/tracker.py +212 -0
- crackerjack/api.py +560 -0
- crackerjack/cli/__init__.py +24 -0
- crackerjack/cli/facade.py +104 -0
- crackerjack/cli/handlers.py +267 -0
- crackerjack/cli/interactive.py +471 -0
- crackerjack/cli/options.py +409 -0
- crackerjack/cli/utils.py +18 -0
- crackerjack/code_cleaner.py +618 -928
- crackerjack/config/__init__.py +19 -0
- crackerjack/config/hooks.py +218 -0
- crackerjack/core/__init__.py +0 -0
- crackerjack/core/async_workflow_orchestrator.py +406 -0
- crackerjack/core/autofix_coordinator.py +200 -0
- crackerjack/core/container.py +104 -0
- crackerjack/core/enhanced_container.py +542 -0
- crackerjack/core/performance.py +243 -0
- crackerjack/core/phase_coordinator.py +585 -0
- crackerjack/core/proactive_workflow.py +316 -0
- crackerjack/core/session_coordinator.py +289 -0
- crackerjack/core/workflow_orchestrator.py +826 -0
- crackerjack/dynamic_config.py +94 -103
- crackerjack/errors.py +263 -41
- crackerjack/executors/__init__.py +11 -0
- crackerjack/executors/async_hook_executor.py +431 -0
- crackerjack/executors/cached_hook_executor.py +242 -0
- crackerjack/executors/hook_executor.py +345 -0
- crackerjack/executors/individual_hook_executor.py +669 -0
- crackerjack/intelligence/__init__.py +44 -0
- crackerjack/intelligence/adaptive_learning.py +751 -0
- crackerjack/intelligence/agent_orchestrator.py +551 -0
- crackerjack/intelligence/agent_registry.py +414 -0
- crackerjack/intelligence/agent_selector.py +502 -0
- crackerjack/intelligence/integration.py +290 -0
- crackerjack/interactive.py +576 -315
- crackerjack/managers/__init__.py +11 -0
- crackerjack/managers/async_hook_manager.py +135 -0
- crackerjack/managers/hook_manager.py +137 -0
- crackerjack/managers/publish_manager.py +433 -0
- crackerjack/managers/test_command_builder.py +151 -0
- crackerjack/managers/test_executor.py +443 -0
- crackerjack/managers/test_manager.py +258 -0
- crackerjack/managers/test_manager_backup.py +1124 -0
- crackerjack/managers/test_progress.py +114 -0
- crackerjack/mcp/__init__.py +0 -0
- crackerjack/mcp/cache.py +336 -0
- crackerjack/mcp/client_runner.py +104 -0
- crackerjack/mcp/context.py +621 -0
- crackerjack/mcp/dashboard.py +636 -0
- crackerjack/mcp/enhanced_progress_monitor.py +479 -0
- crackerjack/mcp/file_monitor.py +336 -0
- crackerjack/mcp/progress_components.py +569 -0
- crackerjack/mcp/progress_monitor.py +949 -0
- crackerjack/mcp/rate_limiter.py +332 -0
- crackerjack/mcp/server.py +22 -0
- crackerjack/mcp/server_core.py +244 -0
- crackerjack/mcp/service_watchdog.py +501 -0
- crackerjack/mcp/state.py +395 -0
- crackerjack/mcp/task_manager.py +257 -0
- crackerjack/mcp/tools/__init__.py +17 -0
- crackerjack/mcp/tools/core_tools.py +249 -0
- crackerjack/mcp/tools/error_analyzer.py +308 -0
- crackerjack/mcp/tools/execution_tools.py +372 -0
- crackerjack/mcp/tools/execution_tools_backup.py +1097 -0
- crackerjack/mcp/tools/intelligence_tool_registry.py +80 -0
- crackerjack/mcp/tools/intelligence_tools.py +314 -0
- crackerjack/mcp/tools/monitoring_tools.py +502 -0
- crackerjack/mcp/tools/proactive_tools.py +384 -0
- crackerjack/mcp/tools/progress_tools.py +217 -0
- crackerjack/mcp/tools/utility_tools.py +341 -0
- crackerjack/mcp/tools/workflow_executor.py +565 -0
- crackerjack/mcp/websocket/__init__.py +14 -0
- crackerjack/mcp/websocket/app.py +39 -0
- crackerjack/mcp/websocket/endpoints.py +559 -0
- crackerjack/mcp/websocket/jobs.py +253 -0
- crackerjack/mcp/websocket/server.py +116 -0
- crackerjack/mcp/websocket/websocket_handler.py +78 -0
- crackerjack/mcp/websocket_server.py +10 -0
- crackerjack/models/__init__.py +31 -0
- crackerjack/models/config.py +93 -0
- crackerjack/models/config_adapter.py +230 -0
- crackerjack/models/protocols.py +118 -0
- crackerjack/models/task.py +154 -0
- crackerjack/monitoring/ai_agent_watchdog.py +450 -0
- crackerjack/monitoring/regression_prevention.py +638 -0
- crackerjack/orchestration/__init__.py +0 -0
- crackerjack/orchestration/advanced_orchestrator.py +970 -0
- crackerjack/orchestration/coverage_improvement.py +223 -0
- crackerjack/orchestration/execution_strategies.py +341 -0
- crackerjack/orchestration/test_progress_streamer.py +636 -0
- crackerjack/plugins/__init__.py +15 -0
- crackerjack/plugins/base.py +200 -0
- crackerjack/plugins/hooks.py +246 -0
- crackerjack/plugins/loader.py +335 -0
- crackerjack/plugins/managers.py +259 -0
- crackerjack/py313.py +8 -3
- crackerjack/services/__init__.py +22 -0
- crackerjack/services/cache.py +314 -0
- crackerjack/services/config.py +358 -0
- crackerjack/services/config_integrity.py +99 -0
- crackerjack/services/contextual_ai_assistant.py +516 -0
- crackerjack/services/coverage_ratchet.py +356 -0
- crackerjack/services/debug.py +736 -0
- crackerjack/services/dependency_monitor.py +617 -0
- crackerjack/services/enhanced_filesystem.py +439 -0
- crackerjack/services/file_hasher.py +151 -0
- crackerjack/services/filesystem.py +421 -0
- crackerjack/services/git.py +176 -0
- crackerjack/services/health_metrics.py +611 -0
- crackerjack/services/initialization.py +873 -0
- crackerjack/services/log_manager.py +286 -0
- crackerjack/services/logging.py +174 -0
- crackerjack/services/metrics.py +578 -0
- crackerjack/services/pattern_cache.py +362 -0
- crackerjack/services/pattern_detector.py +515 -0
- crackerjack/services/performance_benchmarks.py +653 -0
- crackerjack/services/security.py +163 -0
- crackerjack/services/server_manager.py +234 -0
- crackerjack/services/smart_scheduling.py +144 -0
- crackerjack/services/tool_version_service.py +61 -0
- crackerjack/services/unified_config.py +437 -0
- crackerjack/services/version_checker.py +248 -0
- crackerjack/slash_commands/__init__.py +14 -0
- crackerjack/slash_commands/init.md +122 -0
- crackerjack/slash_commands/run.md +163 -0
- crackerjack/slash_commands/status.md +127 -0
- crackerjack-0.31.7.dist-info/METADATA +742 -0
- crackerjack-0.31.7.dist-info/RECORD +149 -0
- crackerjack-0.31.7.dist-info/entry_points.txt +2 -0
- crackerjack/.gitignore +0 -34
- crackerjack/.libcst.codemod.yaml +0 -18
- crackerjack/.pdm.toml +0 -1
- crackerjack/crackerjack.py +0 -3805
- crackerjack/pyproject.toml +0 -286
- crackerjack-0.30.3.dist-info/METADATA +0 -1290
- crackerjack-0.30.3.dist-info/RECORD +0 -16
- {crackerjack-0.30.3.dist-info → crackerjack-0.31.7.dist-info}/WHEEL +0 -0
- {crackerjack-0.30.3.dist-info → crackerjack-0.31.7.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"""Integration layer for Intelligent Agent Selection System.
|
|
2
|
+
|
|
3
|
+
Provides high-level API for integrating the intelligent agent system with
|
|
4
|
+
existing crackerjack workflows and MCP tools.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import logging
|
|
8
|
+
import typing as t
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
|
|
11
|
+
from crackerjack.agents.base import AgentContext, FixResult, Issue
|
|
12
|
+
|
|
13
|
+
from .adaptive_learning import get_learning_system
|
|
14
|
+
from .agent_orchestrator import (
|
|
15
|
+
ExecutionRequest,
|
|
16
|
+
ExecutionStrategy,
|
|
17
|
+
get_agent_orchestrator,
|
|
18
|
+
)
|
|
19
|
+
from .agent_registry import get_agent_registry
|
|
20
|
+
from .agent_selector import TaskContext, TaskDescription
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@dataclass
|
|
24
|
+
class SmartAgentResult:
|
|
25
|
+
"""Result from smart agent execution."""
|
|
26
|
+
|
|
27
|
+
success: bool
|
|
28
|
+
result: t.Any
|
|
29
|
+
agents_used: list[str]
|
|
30
|
+
execution_time: float
|
|
31
|
+
confidence: float
|
|
32
|
+
recommendations: list[str]
|
|
33
|
+
learning_applied: bool = False
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class IntelligentAgentSystem:
|
|
37
|
+
"""High-level interface to the intelligent agent system."""
|
|
38
|
+
|
|
39
|
+
def __init__(self) -> None:
|
|
40
|
+
self.logger = logging.getLogger(__name__)
|
|
41
|
+
self._initialized = False
|
|
42
|
+
|
|
43
|
+
async def initialize(self) -> None:
|
|
44
|
+
"""Initialize the intelligent agent system."""
|
|
45
|
+
if self._initialized:
|
|
46
|
+
return
|
|
47
|
+
|
|
48
|
+
self.logger.info("Initializing Intelligent Agent System")
|
|
49
|
+
|
|
50
|
+
# Initialize all components
|
|
51
|
+
self.registry = await get_agent_registry()
|
|
52
|
+
self.orchestrator = await get_agent_orchestrator()
|
|
53
|
+
self.learning_system = await get_learning_system()
|
|
54
|
+
|
|
55
|
+
self._initialized = True
|
|
56
|
+
|
|
57
|
+
# Log system status
|
|
58
|
+
stats = self.registry.get_agent_stats()
|
|
59
|
+
self.logger.info(
|
|
60
|
+
f"System initialized: {stats['total_agents']} agents available "
|
|
61
|
+
f"({stats['by_source']})"
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
async def execute_smart_task(
|
|
65
|
+
self,
|
|
66
|
+
description: str,
|
|
67
|
+
context: TaskContext | None = None,
|
|
68
|
+
strategy: ExecutionStrategy = ExecutionStrategy.SINGLE_BEST,
|
|
69
|
+
context_data: AgentContext | None = None,
|
|
70
|
+
) -> SmartAgentResult:
|
|
71
|
+
"""Execute a task using intelligent agent selection."""
|
|
72
|
+
await self.initialize()
|
|
73
|
+
|
|
74
|
+
# Create task description
|
|
75
|
+
task = TaskDescription(
|
|
76
|
+
description=description,
|
|
77
|
+
context=context,
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# Get learning recommendations
|
|
81
|
+
candidates = await self.orchestrator.selector.select_agents(
|
|
82
|
+
task, max_candidates=5
|
|
83
|
+
)
|
|
84
|
+
candidate_names = [c.agent.metadata.name for c in candidates]
|
|
85
|
+
|
|
86
|
+
learning_recommendations = self.learning_system.get_agent_recommendations(
|
|
87
|
+
task, candidate_names
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# Apply learning to boost scores
|
|
91
|
+
for candidate in candidates:
|
|
92
|
+
agent_name = candidate.agent.metadata.name
|
|
93
|
+
if agent_name in learning_recommendations:
|
|
94
|
+
learning_boost = (
|
|
95
|
+
learning_recommendations[agent_name] * 0.2
|
|
96
|
+
) # 20% boost max
|
|
97
|
+
candidate.final_score = min(1.0, candidate.final_score + learning_boost)
|
|
98
|
+
|
|
99
|
+
# Re-sort by updated scores
|
|
100
|
+
candidates.sort(key=lambda c: c.final_score, reverse=True)
|
|
101
|
+
|
|
102
|
+
# Create execution request
|
|
103
|
+
request = ExecutionRequest(
|
|
104
|
+
task=task,
|
|
105
|
+
strategy=strategy,
|
|
106
|
+
max_agents=min(3, len(candidates)),
|
|
107
|
+
context=context_data,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Execute with orchestrator
|
|
111
|
+
result = await self.orchestrator.execute(request)
|
|
112
|
+
|
|
113
|
+
# Record results for learning
|
|
114
|
+
if candidates:
|
|
115
|
+
best_candidate = candidates[0]
|
|
116
|
+
await self.learning_system.record_execution(
|
|
117
|
+
agent=best_candidate.agent,
|
|
118
|
+
task=task,
|
|
119
|
+
success=result.success,
|
|
120
|
+
execution_time=result.execution_time,
|
|
121
|
+
agent_score=best_candidate,
|
|
122
|
+
error_message=result.error_message,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
# Create smart result
|
|
126
|
+
return SmartAgentResult(
|
|
127
|
+
success=result.success,
|
|
128
|
+
result=result.primary_result,
|
|
129
|
+
agents_used=result.agents_used,
|
|
130
|
+
execution_time=result.execution_time,
|
|
131
|
+
confidence=candidates[0].final_score if candidates else 0.0,
|
|
132
|
+
recommendations=result.recommendations or [],
|
|
133
|
+
learning_applied=bool(learning_recommendations),
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
async def handle_crackerjack_issue(
|
|
137
|
+
self,
|
|
138
|
+
issue: Issue,
|
|
139
|
+
context: AgentContext,
|
|
140
|
+
use_learning: bool = True,
|
|
141
|
+
) -> FixResult:
|
|
142
|
+
"""Handle a crackerjack Issue using intelligent agent selection."""
|
|
143
|
+
await self.initialize()
|
|
144
|
+
|
|
145
|
+
# Convert issue to task description
|
|
146
|
+
task_context = self._map_issue_to_task_context(issue)
|
|
147
|
+
|
|
148
|
+
task = TaskDescription(
|
|
149
|
+
description=f"Fix {issue.type.value} issue: {issue.message}",
|
|
150
|
+
context=task_context,
|
|
151
|
+
error_types=[issue.type.value],
|
|
152
|
+
priority=self._map_severity_to_priority(issue.severity),
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
# Execute smart task
|
|
156
|
+
smart_result = await self.execute_smart_task(
|
|
157
|
+
description=task.description,
|
|
158
|
+
context=task_context,
|
|
159
|
+
context_data=context,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# Convert result back to FixResult
|
|
163
|
+
if smart_result.success and isinstance(smart_result.result, FixResult):
|
|
164
|
+
return smart_result.result
|
|
165
|
+
|
|
166
|
+
# Create fallback FixResult
|
|
167
|
+
return FixResult(
|
|
168
|
+
success=smart_result.success,
|
|
169
|
+
confidence=smart_result.confidence,
|
|
170
|
+
remaining_issues=[issue.message] if not smart_result.success else [],
|
|
171
|
+
recommendations=smart_result.recommendations,
|
|
172
|
+
fixes_applied=[
|
|
173
|
+
f"Applied using intelligent agent: {', '.join(smart_result.agents_used)}"
|
|
174
|
+
]
|
|
175
|
+
if smart_result.success
|
|
176
|
+
else [],
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
async def get_best_agent_for_task(
|
|
180
|
+
self,
|
|
181
|
+
description: str,
|
|
182
|
+
context: TaskContext | None = None,
|
|
183
|
+
) -> tuple[str, float] | None:
|
|
184
|
+
"""Get the best agent for a task without executing it."""
|
|
185
|
+
await self.initialize()
|
|
186
|
+
|
|
187
|
+
task = TaskDescription(description=description, context=context)
|
|
188
|
+
best_candidate = await self.orchestrator.selector.select_best_agent(task)
|
|
189
|
+
|
|
190
|
+
if best_candidate:
|
|
191
|
+
return best_candidate.agent.metadata.name, best_candidate.final_score
|
|
192
|
+
return None
|
|
193
|
+
|
|
194
|
+
async def analyze_task_complexity(self, description: str) -> dict[str, t.Any]:
|
|
195
|
+
"""Analyze a task's complexity and provide recommendations."""
|
|
196
|
+
await self.initialize()
|
|
197
|
+
|
|
198
|
+
task = TaskDescription(description=description)
|
|
199
|
+
return await self.orchestrator.selector.analyze_task_complexity(task)
|
|
200
|
+
|
|
201
|
+
def _map_issue_to_task_context(self, issue: Issue) -> TaskContext | None:
|
|
202
|
+
"""Map crackerjack Issue type to TaskContext."""
|
|
203
|
+
from crackerjack.agents.base import IssueType
|
|
204
|
+
|
|
205
|
+
mapping = {
|
|
206
|
+
IssueType.COMPLEXITY: TaskContext.REFACTORING,
|
|
207
|
+
IssueType.DRY_VIOLATION: TaskContext.REFACTORING,
|
|
208
|
+
IssueType.PERFORMANCE: TaskContext.PERFORMANCE,
|
|
209
|
+
IssueType.SECURITY: TaskContext.SECURITY,
|
|
210
|
+
IssueType.TEST_FAILURE: TaskContext.TESTING,
|
|
211
|
+
IssueType.FORMATTING: TaskContext.CODE_QUALITY,
|
|
212
|
+
IssueType.IMPORT_ERROR: TaskContext.CODE_QUALITY,
|
|
213
|
+
IssueType.TYPE_ERROR: TaskContext.CODE_QUALITY,
|
|
214
|
+
IssueType.DOCUMENTATION: TaskContext.DOCUMENTATION,
|
|
215
|
+
IssueType.DEAD_CODE: TaskContext.REFACTORING,
|
|
216
|
+
IssueType.DEPENDENCY: TaskContext.CODE_QUALITY,
|
|
217
|
+
IssueType.TEST_ORGANIZATION: TaskContext.TESTING,
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return mapping.get(issue.type) or TaskContext.GENERAL
|
|
221
|
+
|
|
222
|
+
def _map_severity_to_priority(self, severity: t.Any) -> int:
|
|
223
|
+
"""Map crackerjack Priority to task priority."""
|
|
224
|
+
from crackerjack.agents.base import Priority
|
|
225
|
+
|
|
226
|
+
mapping = {
|
|
227
|
+
Priority.HIGH: 90,
|
|
228
|
+
Priority.MEDIUM: 60,
|
|
229
|
+
Priority.LOW: 30,
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return mapping.get(severity) or 50
|
|
233
|
+
|
|
234
|
+
async def get_system_status(self) -> dict[str, t.Any]:
|
|
235
|
+
"""Get comprehensive system status."""
|
|
236
|
+
await self.initialize()
|
|
237
|
+
|
|
238
|
+
registry_stats = self.registry.get_agent_stats()
|
|
239
|
+
orchestrator_stats = self.orchestrator.get_execution_stats()
|
|
240
|
+
learning_summary = self.learning_system.get_learning_summary()
|
|
241
|
+
|
|
242
|
+
return {
|
|
243
|
+
"initialized": self._initialized,
|
|
244
|
+
"registry": registry_stats,
|
|
245
|
+
"orchestration": orchestrator_stats,
|
|
246
|
+
"learning": learning_summary,
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
# Global intelligent agent system
|
|
251
|
+
_intelligent_system_instance: IntelligentAgentSystem | None = None
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
async def get_intelligent_agent_system() -> IntelligentAgentSystem:
|
|
255
|
+
"""Get or create the global intelligent agent system."""
|
|
256
|
+
global _intelligent_system_instance
|
|
257
|
+
|
|
258
|
+
if _intelligent_system_instance is None:
|
|
259
|
+
_intelligent_system_instance = IntelligentAgentSystem()
|
|
260
|
+
|
|
261
|
+
return _intelligent_system_instance
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
# Convenience functions for common use cases
|
|
265
|
+
async def smart_fix_issue(
|
|
266
|
+
issue: Issue,
|
|
267
|
+
context: AgentContext,
|
|
268
|
+
) -> FixResult:
|
|
269
|
+
"""Fix an issue using intelligent agent selection."""
|
|
270
|
+
system = await get_intelligent_agent_system()
|
|
271
|
+
return await system.handle_crackerjack_issue(issue, context)
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
async def smart_execute_task(
|
|
275
|
+
description: str,
|
|
276
|
+
context: TaskContext | None = None,
|
|
277
|
+
strategy: ExecutionStrategy = ExecutionStrategy.SINGLE_BEST,
|
|
278
|
+
) -> SmartAgentResult:
|
|
279
|
+
"""Execute a task using intelligent agent selection."""
|
|
280
|
+
system = await get_intelligent_agent_system()
|
|
281
|
+
return await system.execute_smart_task(description, context, strategy)
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
async def get_smart_recommendation(
|
|
285
|
+
description: str,
|
|
286
|
+
context: TaskContext | None = None,
|
|
287
|
+
) -> tuple[str, float] | None:
|
|
288
|
+
"""Get a smart agent recommendation without executing."""
|
|
289
|
+
system = await get_intelligent_agent_system()
|
|
290
|
+
return await system.get_best_agent_for_task(description, context)
|