crackerjack 0.31.10__py3-none-any.whl → 0.31.12__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 +288 -705
- crackerjack/__main__.py +22 -8
- crackerjack/agents/__init__.py +0 -3
- crackerjack/agents/architect_agent.py +0 -43
- crackerjack/agents/base.py +1 -9
- crackerjack/agents/coordinator.py +2 -148
- crackerjack/agents/documentation_agent.py +109 -81
- crackerjack/agents/dry_agent.py +122 -97
- crackerjack/agents/formatting_agent.py +3 -16
- crackerjack/agents/import_optimization_agent.py +1174 -130
- crackerjack/agents/performance_agent.py +956 -188
- crackerjack/agents/performance_helpers.py +229 -0
- crackerjack/agents/proactive_agent.py +1 -48
- crackerjack/agents/refactoring_agent.py +516 -246
- crackerjack/agents/refactoring_helpers.py +282 -0
- crackerjack/agents/security_agent.py +393 -90
- crackerjack/agents/test_creation_agent.py +1776 -120
- crackerjack/agents/test_specialist_agent.py +59 -15
- crackerjack/agents/tracker.py +0 -102
- crackerjack/api.py +145 -37
- crackerjack/cli/handlers.py +48 -30
- crackerjack/cli/interactive.py +11 -11
- crackerjack/cli/options.py +66 -4
- crackerjack/code_cleaner.py +808 -148
- crackerjack/config/global_lock_config.py +110 -0
- crackerjack/config/hooks.py +43 -64
- crackerjack/core/async_workflow_orchestrator.py +247 -97
- crackerjack/core/autofix_coordinator.py +192 -109
- crackerjack/core/enhanced_container.py +46 -63
- crackerjack/core/file_lifecycle.py +549 -0
- crackerjack/core/performance.py +9 -8
- crackerjack/core/performance_monitor.py +395 -0
- crackerjack/core/phase_coordinator.py +281 -94
- crackerjack/core/proactive_workflow.py +9 -58
- crackerjack/core/resource_manager.py +501 -0
- crackerjack/core/service_watchdog.py +490 -0
- crackerjack/core/session_coordinator.py +4 -8
- crackerjack/core/timeout_manager.py +504 -0
- crackerjack/core/websocket_lifecycle.py +475 -0
- crackerjack/core/workflow_orchestrator.py +343 -209
- crackerjack/dynamic_config.py +47 -6
- crackerjack/errors.py +3 -4
- crackerjack/executors/async_hook_executor.py +63 -13
- crackerjack/executors/cached_hook_executor.py +14 -14
- crackerjack/executors/hook_executor.py +100 -37
- crackerjack/executors/hook_lock_manager.py +856 -0
- crackerjack/executors/individual_hook_executor.py +120 -86
- crackerjack/intelligence/__init__.py +0 -7
- crackerjack/intelligence/adaptive_learning.py +13 -86
- crackerjack/intelligence/agent_orchestrator.py +15 -78
- crackerjack/intelligence/agent_registry.py +12 -59
- crackerjack/intelligence/agent_selector.py +31 -92
- crackerjack/intelligence/integration.py +1 -41
- crackerjack/interactive.py +9 -9
- crackerjack/managers/async_hook_manager.py +25 -8
- crackerjack/managers/hook_manager.py +9 -9
- crackerjack/managers/publish_manager.py +57 -59
- crackerjack/managers/test_command_builder.py +6 -36
- crackerjack/managers/test_executor.py +9 -61
- crackerjack/managers/test_manager.py +17 -63
- crackerjack/managers/test_manager_backup.py +77 -127
- crackerjack/managers/test_progress.py +4 -23
- crackerjack/mcp/cache.py +5 -12
- crackerjack/mcp/client_runner.py +10 -10
- crackerjack/mcp/context.py +64 -6
- crackerjack/mcp/dashboard.py +14 -11
- crackerjack/mcp/enhanced_progress_monitor.py +55 -55
- crackerjack/mcp/file_monitor.py +72 -42
- crackerjack/mcp/progress_components.py +103 -84
- crackerjack/mcp/progress_monitor.py +122 -49
- crackerjack/mcp/rate_limiter.py +12 -12
- crackerjack/mcp/server_core.py +16 -22
- crackerjack/mcp/service_watchdog.py +26 -26
- crackerjack/mcp/state.py +15 -0
- crackerjack/mcp/tools/core_tools.py +95 -39
- crackerjack/mcp/tools/error_analyzer.py +6 -32
- crackerjack/mcp/tools/execution_tools.py +1 -56
- crackerjack/mcp/tools/execution_tools_backup.py +35 -131
- crackerjack/mcp/tools/intelligence_tool_registry.py +0 -36
- crackerjack/mcp/tools/intelligence_tools.py +2 -55
- crackerjack/mcp/tools/monitoring_tools.py +308 -145
- crackerjack/mcp/tools/proactive_tools.py +12 -42
- crackerjack/mcp/tools/progress_tools.py +23 -15
- crackerjack/mcp/tools/utility_tools.py +3 -40
- crackerjack/mcp/tools/workflow_executor.py +40 -60
- crackerjack/mcp/websocket/app.py +0 -3
- crackerjack/mcp/websocket/endpoints.py +206 -268
- crackerjack/mcp/websocket/jobs.py +213 -66
- crackerjack/mcp/websocket/server.py +84 -6
- crackerjack/mcp/websocket/websocket_handler.py +137 -29
- crackerjack/models/config_adapter.py +3 -16
- crackerjack/models/protocols.py +162 -3
- crackerjack/models/resource_protocols.py +454 -0
- crackerjack/models/task.py +3 -3
- crackerjack/monitoring/__init__.py +0 -0
- crackerjack/monitoring/ai_agent_watchdog.py +25 -71
- crackerjack/monitoring/regression_prevention.py +28 -87
- crackerjack/orchestration/advanced_orchestrator.py +44 -78
- crackerjack/orchestration/coverage_improvement.py +10 -60
- crackerjack/orchestration/execution_strategies.py +16 -16
- crackerjack/orchestration/test_progress_streamer.py +61 -53
- crackerjack/plugins/base.py +1 -1
- crackerjack/plugins/managers.py +22 -20
- crackerjack/py313.py +65 -21
- crackerjack/services/backup_service.py +467 -0
- crackerjack/services/bounded_status_operations.py +627 -0
- crackerjack/services/cache.py +7 -9
- crackerjack/services/config.py +35 -52
- crackerjack/services/config_integrity.py +5 -16
- crackerjack/services/config_merge.py +542 -0
- crackerjack/services/contextual_ai_assistant.py +17 -19
- crackerjack/services/coverage_ratchet.py +44 -73
- crackerjack/services/debug.py +25 -39
- crackerjack/services/dependency_monitor.py +52 -50
- crackerjack/services/enhanced_filesystem.py +14 -11
- crackerjack/services/file_hasher.py +1 -1
- crackerjack/services/filesystem.py +1 -12
- crackerjack/services/git.py +71 -47
- crackerjack/services/health_metrics.py +31 -27
- crackerjack/services/initialization.py +276 -428
- crackerjack/services/input_validator.py +760 -0
- crackerjack/services/log_manager.py +16 -16
- crackerjack/services/logging.py +7 -6
- crackerjack/services/metrics.py +43 -43
- crackerjack/services/pattern_cache.py +2 -31
- crackerjack/services/pattern_detector.py +26 -63
- crackerjack/services/performance_benchmarks.py +20 -45
- crackerjack/services/regex_patterns.py +2887 -0
- crackerjack/services/regex_utils.py +537 -0
- crackerjack/services/secure_path_utils.py +683 -0
- crackerjack/services/secure_status_formatter.py +534 -0
- crackerjack/services/secure_subprocess.py +605 -0
- crackerjack/services/security.py +47 -10
- crackerjack/services/security_logger.py +492 -0
- crackerjack/services/server_manager.py +109 -50
- crackerjack/services/smart_scheduling.py +8 -25
- crackerjack/services/status_authentication.py +603 -0
- crackerjack/services/status_security_manager.py +442 -0
- crackerjack/services/thread_safe_status_collector.py +546 -0
- crackerjack/services/tool_version_service.py +1 -23
- crackerjack/services/unified_config.py +36 -58
- crackerjack/services/validation_rate_limiter.py +269 -0
- crackerjack/services/version_checker.py +9 -40
- crackerjack/services/websocket_resource_limiter.py +572 -0
- crackerjack/slash_commands/__init__.py +52 -2
- crackerjack/tools/__init__.py +0 -0
- crackerjack/tools/validate_input_validator_patterns.py +262 -0
- crackerjack/tools/validate_regex_patterns.py +198 -0
- {crackerjack-0.31.10.dist-info → crackerjack-0.31.12.dist-info}/METADATA +197 -12
- crackerjack-0.31.12.dist-info/RECORD +178 -0
- crackerjack/cli/facade.py +0 -104
- crackerjack-0.31.10.dist-info/RECORD +0 -149
- {crackerjack-0.31.10.dist-info → crackerjack-0.31.12.dist-info}/WHEEL +0 -0
- {crackerjack-0.31.10.dist-info → crackerjack-0.31.12.dist-info}/entry_points.txt +0 -0
- {crackerjack-0.31.10.dist-info → crackerjack-0.31.12.dist-info}/licenses/LICENSE +0 -0
crackerjack/CLAUDE.md
CHANGED
|
@@ -6,18 +6,95 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
|
|
6
6
|
|
|
7
7
|
**EVERY LINE OF CODE IS A LIABILITY. The best code is no code.**
|
|
8
8
|
|
|
9
|
-
- **DRY
|
|
10
|
-
- **YAGNI
|
|
11
|
-
- **KISS
|
|
12
|
-
- **Less is More**: Prefer 10 lines
|
|
9
|
+
- **DRY**: If you write it twice, you're doing it wrong
|
|
10
|
+
- **YAGNI**: Build only what's needed NOW
|
|
11
|
+
- **KISS**: Complexity is the enemy of maintainability
|
|
12
|
+
- **Less is More**: Prefer 10 clear lines over 100 clever ones
|
|
13
13
|
- **Code is Read 10x More Than Written**: Optimize for readability
|
|
14
|
-
- **Self-Documenting Code**:
|
|
14
|
+
- **Self-Documenting Code**: Variable names must be clear and descriptive, even in inline functions
|
|
15
|
+
|
|
16
|
+
## Design Philosophy
|
|
17
|
+
|
|
18
|
+
- **Auto-Discovery**: Prefer intelligent auto-discovery of configurations and settings over manual configuration whenever possible, reducing setup friction and configuration errors
|
|
15
19
|
|
|
16
20
|
## Project Overview
|
|
17
21
|
|
|
18
|
-
Crackerjack is an opinionated Python project management tool
|
|
22
|
+
Crackerjack is an opinionated Python project management tool unifying UV, Ruff, pytest, and pre-commit into a single workflow. Enforces consistent code quality with AI agent integration via MCP.
|
|
23
|
+
|
|
24
|
+
**Key Dependencies**: Python 3.13+, UV, pre-commit, pytest
|
|
25
|
+
|
|
26
|
+
## AI-Optimized Documentation
|
|
27
|
+
|
|
28
|
+
**For AI assistants, refer to these structured documentation files:**
|
|
19
29
|
|
|
20
|
-
**
|
|
30
|
+
- **[AI-REFERENCE.md](AI-REFERENCE.md)** - Complete AI command reference with decision trees and lookup tables
|
|
31
|
+
- **[AGENT-CAPABILITIES.json](AGENT-CAPABILITIES.json)** - Structured agent data for automated selection
|
|
32
|
+
- **[ERROR-PATTERNS.yaml](ERROR-PATTERNS.yaml)** - Pattern matching rules for automated issue resolution
|
|
33
|
+
|
|
34
|
+
These files provide parseable formats, decision trees, and structured data optimized for AI understanding and autonomous operation.
|
|
35
|
+
|
|
36
|
+
## Quick Reference
|
|
37
|
+
|
|
38
|
+
### Most Used Commands
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Daily development workflow
|
|
42
|
+
python -m crackerjack # Quality checks only
|
|
43
|
+
python -m crackerjack -t # With tests
|
|
44
|
+
python -m crackerjack --ai-agent -t # AI auto-fixing (recommended)
|
|
45
|
+
|
|
46
|
+
# Debugging and monitoring
|
|
47
|
+
python -m crackerjack --ai-debug -t # AI debug mode with verbose output
|
|
48
|
+
python -m crackerjack --enhanced-monitor # Progress monitor with advanced UI
|
|
49
|
+
python -m crackerjack --watchdog # Auto-restart services monitor
|
|
50
|
+
|
|
51
|
+
# Server management
|
|
52
|
+
python -m crackerjack --start-mcp-server # Start MCP server
|
|
53
|
+
python -m crackerjack --start-websocket-server # Start WebSocket server
|
|
54
|
+
python -m crackerjack --restart-mcp-server # Restart MCP server
|
|
55
|
+
|
|
56
|
+
# Release workflow
|
|
57
|
+
python -m crackerjack --bump patch # Version bump only
|
|
58
|
+
python -m crackerjack -a patch # Full release with publishing
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Common Flags
|
|
62
|
+
|
|
63
|
+
| Flag | Purpose | When to Use |
|
|
64
|
+
|------|---------|-------------|
|
|
65
|
+
| `-t` | Include tests | Always for comprehensive validation |
|
|
66
|
+
| `--ai-agent` | Enable AI auto-fixing | Standard process for quality compliance |
|
|
67
|
+
| `--ai-debug` | Verbose AI debugging | When troubleshooting AI agent issues |
|
|
68
|
+
| `-x` | Code cleaning mode | When ready to resolve all TODOs |
|
|
69
|
+
| `-i` | Interactive mode | For step-by-step workflow control |
|
|
70
|
+
| `--skip-hooks` | Skip pre-commit hooks | During rapid development iterations |
|
|
71
|
+
| `--quick` | Quick mode (3 iterations) | CI/CD pipelines or rapid testing |
|
|
72
|
+
| `--thorough` | Thorough mode (8 iterations) | Complex refactoring or difficult issues |
|
|
73
|
+
| `--verbose` | Extra output | When diagnosing issues |
|
|
74
|
+
|
|
75
|
+
### Agent Selection Guide
|
|
76
|
+
|
|
77
|
+
**When to Use Which Specialist Agent:**
|
|
78
|
+
|
|
79
|
+
| Issue Type | Best Agent | Confidence | Use Case |
|
|
80
|
+
|------------|------------|------------|----------|
|
|
81
|
+
| **Documentation inconsistencies** | DocumentationAgent | 0.8 | Changelog updates, .md file consistency |
|
|
82
|
+
| **Cognitive complexity >15** | RefactoringAgent | 0.9 | Breaking down complex functions |
|
|
83
|
+
| **Unused imports/dead code** | RefactoringAgent | 0.8 | AST-based cleanup |
|
|
84
|
+
| **Performance bottlenecks** | PerformanceAgent | 0.85 | O(n²) loops, string concatenation |
|
|
85
|
+
| **Code duplication** | DRYAgent | 0.8 | Extract common patterns |
|
|
86
|
+
| **Import/formatting issues** | FormattingAgent | 0.8 | Code style violations |
|
|
87
|
+
| **Security vulnerabilities** | SecurityAgent | 0.8 | Hardcoded paths, unsafe operations |
|
|
88
|
+
| **Test failures** | TestCreationAgent | 0.8 | Missing fixtures, assertion issues |
|
|
89
|
+
| **Complex test scenarios** | TestSpecialistAgent | 0.8 | Advanced test frameworks |
|
|
90
|
+
|
|
91
|
+
**Decision Tree:**
|
|
92
|
+
|
|
93
|
+
1. **Type errors?** → Use AI agent auto-fixing (handles all types)
|
|
94
|
+
1. **Single issue type?** → Use specific agent with confidence ≥0.7
|
|
95
|
+
1. **Multiple issue types?** → Use AI agent batch fixing
|
|
96
|
+
1. **Documentation issues?** → Always use DocumentationAgent
|
|
97
|
+
1. **Performance issues?** → Always use PerformanceAgent (real code transformation)
|
|
21
98
|
|
|
22
99
|
## Core Development Commands
|
|
23
100
|
|
|
@@ -31,6 +108,7 @@ python -m crackerjack
|
|
|
31
108
|
python -m crackerjack -t
|
|
32
109
|
|
|
33
110
|
# Code cleaning with TODO detection (blocks if TODOs found)
|
|
111
|
+
# Note: Automatically creates backups in temp directory for safety
|
|
34
112
|
python -m crackerjack -x
|
|
35
113
|
|
|
36
114
|
# Full release workflow with version bump and publishing
|
|
@@ -48,6 +126,12 @@ python -m crackerjack --ai-agent -t
|
|
|
48
126
|
# AI Agent mode with full debugging and verbose output
|
|
49
127
|
python -m crackerjack --ai-debug -t
|
|
50
128
|
|
|
129
|
+
# Quick mode (3 iterations) - ideal for CI/CD
|
|
130
|
+
python -m crackerjack --quick --ai-agent -t
|
|
131
|
+
|
|
132
|
+
# Thorough mode (8 iterations) - for complex refactoring
|
|
133
|
+
python -m crackerjack --thorough --ai-agent -t
|
|
134
|
+
|
|
51
135
|
# Start MCP server for AI agent integration
|
|
52
136
|
python -m crackerjack --start-mcp-server
|
|
53
137
|
|
|
@@ -101,200 +185,50 @@ reset
|
|
|
101
185
|
|
|
102
186
|
### AI Agent Auto-Fixing Process
|
|
103
187
|
|
|
104
|
-
**
|
|
105
|
-
|
|
106
|
-
#### Two Types of Auto-Fixing
|
|
107
|
-
|
|
108
|
-
**1. Hook Auto-Fix Modes (Limited Scope)**
|
|
109
|
-
|
|
110
|
-
- Basic formatting tools like `ruff --fix`, `trailing-whitespace --fix`
|
|
111
|
-
- Only handle simple style issues (whitespace, import order, basic formatting)
|
|
112
|
-
- Cannot fix logic errors, type issues, security problems, or test failures
|
|
188
|
+
**Two Types of Auto-Fixing:**
|
|
113
189
|
|
|
114
|
-
**
|
|
190
|
+
**1. Hook Auto-Fix (Limited)**: Basic formatting (`ruff --fix`, whitespace). Cannot fix logic/security/test issues.
|
|
115
191
|
|
|
116
|
-
|
|
117
|
-
- Reads source code, understands context, and makes intelligent modifications
|
|
118
|
-
- Fixes actual bugs, adds missing type annotations, resolves test failures
|
|
119
|
-
- Handles complex issues that require code understanding and logic changes
|
|
192
|
+
**2. AI Agent (Comprehensive)**: Analyzes ALL error types, reads source code, makes intelligent modifications.
|
|
120
193
|
|
|
121
|
-
#### Standard
|
|
122
|
-
|
|
123
|
-
**This is the recommended standard process for achieving code quality compliance:**
|
|
194
|
+
#### Standard Process
|
|
124
195
|
|
|
125
196
|
```bash
|
|
126
|
-
#
|
|
197
|
+
# Recommended workflow
|
|
127
198
|
python -m crackerjack --ai-agent -t
|
|
128
199
|
|
|
129
|
-
#
|
|
130
|
-
# 1. Fast Hooks
|
|
131
|
-
# 2. Full Test Suite → Collect ALL
|
|
132
|
-
# 3. Comprehensive Hooks → Collect ALL
|
|
133
|
-
# 4. AI
|
|
134
|
-
# 5. Repeat
|
|
135
|
-
|
|
136
|
-
# CRITICAL: The AI agent only moves to the next iteration AFTER applying fixes
|
|
137
|
-
# This ensures that each iteration validates the fixes from the previous iteration
|
|
200
|
+
# AI workflow per iteration:
|
|
201
|
+
# 1. Fast Hooks → Retry once if fail
|
|
202
|
+
# 2. Full Test Suite → Collect ALL failures
|
|
203
|
+
# 3. Comprehensive Hooks → Collect ALL issues
|
|
204
|
+
# 4. AI Batch Fixing → Fix ALL collected issues
|
|
205
|
+
# 5. Repeat until perfect (up to 5 iterations)
|
|
138
206
|
```
|
|
139
207
|
|
|
140
|
-
**
|
|
141
|
-
|
|
142
|
-
- **Type Errors**: Adds missing type annotations, fixes type mismatches
|
|
143
|
-
- **Security Issues**: Removes hardcoded paths, fixes subprocess vulnerabilities
|
|
144
|
-
- **Dead Code**: Removes unused imports, variables, and functions
|
|
145
|
-
- **Test Failures**: Fixes missing fixtures, import errors, assertion issues
|
|
146
|
-
- **Code Quality**: Applies refactoring suggestions, reduces complexity
|
|
147
|
-
- **Dependency Issues**: Removes unused dependencies from pyproject.toml
|
|
148
|
-
- **Hook Failures**: All formatting, linting, and style issues
|
|
208
|
+
**AI Auto-Fixes**: Type errors, security issues, dead code, test failures, complexity, dependencies, hooks
|
|
149
209
|
|
|
150
|
-
**Benefits
|
|
151
|
-
|
|
152
|
-
- **Autonomous Operation**: Requires no manual intervention
|
|
153
|
-
- **Intelligent Analysis**: Understands code context and intent
|
|
154
|
-
- **Comprehensive Coverage**: Fixes all error types, not just formatting
|
|
155
|
-
- **Iterative Improvement**: Continues until perfect code quality achieved
|
|
156
|
-
- **Learning Capability**: Adapts fixing strategies based on codebase patterns
|
|
210
|
+
**Benefits**: Autonomous, intelligent, comprehensive, iterative, adaptive
|
|
157
211
|
|
|
158
212
|
#### Sub-Agent Architecture
|
|
159
213
|
|
|
160
|
-
**
|
|
161
|
-
|
|
162
|
-
**Available Sub-Agents:**
|
|
163
|
-
|
|
164
|
-
- **DocumentationAgent**: Documentation consistency and changelog management
|
|
165
|
-
|
|
166
|
-
- **Primary Expertise**: `IssueType.DOCUMENTATION` (documentation consistency, changelog updates)
|
|
167
|
-
- **Capabilities**:
|
|
168
|
-
- Auto-generates changelog entries from git commits during version bumps
|
|
169
|
-
- Maintains consistency across all .md files (agent counts, references)
|
|
170
|
-
- Updates README examples when APIs change
|
|
171
|
-
- Adds newly discovered error patterns to CLAUDE.md
|
|
172
|
-
- Cross-validates documentation references
|
|
173
|
-
- Integrates with publish workflow for automatic changelog updates
|
|
174
|
-
- **Philosophy Alignment**: Reduces manual documentation maintenance (YAGNI principle)
|
|
175
|
-
- **Confidence**: 0.8 for documentation issues
|
|
176
|
-
|
|
177
|
-
- **RefactoringAgent**: Structural code improvements and complexity reduction
|
|
178
|
-
|
|
179
|
-
- **Primary Expertise**: `IssueType.COMPLEXITY` (cognitive complexity ≤13)
|
|
180
|
-
- **Secondary Expertise**: `IssueType.DEAD_CODE` (unused imports, variables, functions)
|
|
181
|
-
- **Capabilities**:
|
|
182
|
-
- Breaks down complex functions into helper methods
|
|
183
|
-
- Removes unused imports, variables, and functions using AST analysis
|
|
184
|
-
- Extracts common patterns into reusable utilities
|
|
185
|
-
- Applies dependency injection and Protocol patterns
|
|
186
|
-
- **Philosophy Alignment**: Perfect fit with DRY, YAGNI, KISS principles
|
|
187
|
-
|
|
188
|
-
- **PerformanceAgent**: Performance optimization and algorithmic improvements
|
|
189
|
-
|
|
190
|
-
- **Primary Expertise**: `IssueType.PERFORMANCE` (performance anti-patterns and bottlenecks)
|
|
191
|
-
- **Capabilities**:
|
|
192
|
-
- Detects and fixes nested loops with O(n²) complexity
|
|
193
|
-
- Transforms inefficient list concatenation (`list += [item]` → `list.append(item)`)
|
|
194
|
-
- Optimizes string building (concatenation → list.append + join pattern)
|
|
195
|
-
- Identifies repeated expensive operations in loops (file I/O, function calls)
|
|
196
|
-
- Applies AST-based pattern recognition for accurate detection
|
|
197
|
-
- **Real Code Transformation**: Actually modifies code, not just comments
|
|
198
|
-
- **Philosophy Alignment**: KISS principle through algorithmic efficiency
|
|
199
|
-
|
|
200
|
-
- **DRYAgent**: Don't Repeat Yourself violation detection and fixing
|
|
201
|
-
|
|
202
|
-
- **Primary Expertise**: `IssueType.DRY_VIOLATION` (code duplication and repetition)
|
|
203
|
-
- **Capabilities**:
|
|
204
|
-
- Detects duplicate code patterns and repeated functionality
|
|
205
|
-
- Suggests extracting common patterns to utility functions
|
|
206
|
-
- Recommends creating base classes or mixins for repeated functionality
|
|
207
|
-
- Identifies opportunities for code consolidation and refactoring
|
|
208
|
-
- **Philosophy Alignment**: Core DRY principle enforcement
|
|
209
|
-
|
|
210
|
-
- **FormattingAgent**: Code style and formatting issues
|
|
211
|
-
|
|
212
|
-
- **Primary Expertise**: `IssueType.FORMATTING`, `IssueType.IMPORT_ERROR`
|
|
213
|
-
- **Capabilities**:
|
|
214
|
-
- Handles code style and formatting violations
|
|
215
|
-
- Fixes import-related formatting issues
|
|
216
|
-
- Ensures consistent code formatting standards
|
|
217
|
-
|
|
218
|
-
- **SecurityAgent**: Security vulnerabilities and best practices
|
|
219
|
-
|
|
220
|
-
- **Primary Expertise**: `IssueType.SECURITY`
|
|
221
|
-
- **Capabilities**:
|
|
222
|
-
- Detects and fixes security vulnerabilities (hardcoded paths, unsafe operations)
|
|
223
|
-
- Applies security best practices
|
|
224
|
-
- Identifies potential security risks in code patterns
|
|
225
|
-
|
|
226
|
-
- **ImportOptimizationAgent**: Import statement optimization and cleanup
|
|
227
|
-
|
|
228
|
-
- **Primary Expertise**: `IssueType.IMPORT_ERROR`, `IssueType.DEAD_CODE`
|
|
229
|
-
- **Capabilities**:
|
|
230
|
-
- Optimizes import statements and organization
|
|
231
|
-
- Removes unused imports and dead code
|
|
232
|
-
- Consolidates and reorganizes import patterns
|
|
233
|
-
- **Real Code Transformation**: Restructures import statements
|
|
234
|
-
|
|
235
|
-
- **TestCreationAgent**: Test coverage and quality improvements
|
|
236
|
-
|
|
237
|
-
- **Primary Expertise**: `IssueType.TEST_FAILURE`, `IssueType.DEPENDENCY`
|
|
238
|
-
- **Capabilities**:
|
|
239
|
-
- Fixes test failures and missing test dependencies
|
|
240
|
-
- Improves test coverage and quality
|
|
241
|
-
- Handles dependency-related testing issues
|
|
242
|
-
|
|
243
|
-
- **TestSpecialistAgent**: Advanced testing scenarios and fixtures
|
|
244
|
-
|
|
245
|
-
- **Primary Expertise**: `IssueType.IMPORT_ERROR`, `IssueType.TEST_FAILURE`
|
|
246
|
-
- **Capabilities**:
|
|
247
|
-
- Handles complex testing scenarios and fixture management
|
|
248
|
-
- Fixes advanced test failures and import issues in test files
|
|
249
|
-
- Specializes in testing framework integration
|
|
250
|
-
|
|
251
|
-
**Agent Coordination:**
|
|
252
|
-
|
|
253
|
-
- **AgentCoordinator** routes issues to appropriate agents based on confidence scoring
|
|
254
|
-
- **Single-agent mode**: High confidence (≥0.7) issues handled by best-match agent
|
|
255
|
-
- **Collaborative mode**: Lower confidence issues processed by multiple agents
|
|
256
|
-
- **Batch processing**: Issues grouped by type for efficient parallel processing
|
|
257
|
-
|
|
258
|
-
**Agent Integration:**
|
|
214
|
+
**9 specialized agents handle domain-specific issues:**
|
|
259
215
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
# - 0.9 confidence for complexity issues (primary expertise)
|
|
270
|
-
# - 0.8 confidence for dead code issues (secondary expertise)
|
|
271
|
-
# PerformanceAgent:
|
|
272
|
-
# - 0.85 confidence for performance issues (primary expertise)
|
|
273
|
-
# - Real code transformations with AST-based detection
|
|
274
|
-
|
|
275
|
-
# Works with all agents for comprehensive code quality fixes
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
### Temporary File Management
|
|
216
|
+
- **DocumentationAgent** (0.8): Changelog generation, .md consistency, README updates
|
|
217
|
+
- **RefactoringAgent** (0.9): Complexity reduction ≤15, dead code removal, AST analysis
|
|
218
|
+
- **PerformanceAgent** (0.85): O(n²) detection, string optimization, real code transformation
|
|
219
|
+
- **DRYAgent** (0.8): Code duplication detection, pattern extraction, utility creation
|
|
220
|
+
- **FormattingAgent** (0.8): Style violations, import formatting, consistency
|
|
221
|
+
- **SecurityAgent** (0.8): Hardcoded paths, subprocess vulnerabilities, best practices
|
|
222
|
+
- **ImportOptimizationAgent**: Import cleanup, dead code removal, reorganization
|
|
223
|
+
- **TestCreationAgent** (0.8): Test failures, fixture management, dependencies
|
|
224
|
+
- **TestSpecialistAgent** (0.8): Advanced testing, framework integration
|
|
279
225
|
|
|
280
|
-
**
|
|
226
|
+
**Coordination**: AgentCoordinator routes by confidence (≥0.7 single-agent, \<0.7 collaborative), batch processing
|
|
281
227
|
|
|
282
|
-
|
|
283
|
-
# Default behavior (recommended)
|
|
284
|
-
python -m crackerjack # Auto-cleanup: keeps 5 debug logs, 10 coverage files
|
|
285
|
-
|
|
286
|
-
# Customize cleanup behavior
|
|
287
|
-
python -m crackerjack --no-cleanup # Disable automatic cleanup
|
|
288
|
-
python -m crackerjack --keep-debug-logs 10 # Keep more debug files
|
|
289
|
-
python -m crackerjack --keep-coverage-files 20 # Keep more coverage files
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
**Files managed:**
|
|
293
|
-
|
|
294
|
-
- `crackerjack-debug-*.log` - Debug logs from each run (default: keep 5 most recent)
|
|
295
|
-
- `.coverage.*` - Coverage data files from pytest-cov (default: keep 10 most recent)
|
|
228
|
+
### Temporary File Management
|
|
296
229
|
|
|
297
|
-
**
|
|
230
|
+
**Auto-cleanup**: Keeps 5 debug logs, 10 coverage files by default
|
|
231
|
+
**Options**: `--no-cleanup`, `--keep-debug-logs N`, `--keep-coverage-files N`
|
|
298
232
|
|
|
299
233
|
### Testing & Development
|
|
300
234
|
|
|
@@ -345,661 +279,310 @@ python -m crackerjack -p patch
|
|
|
345
279
|
|
|
346
280
|
### UVX Integration
|
|
347
281
|
|
|
348
|
-
**
|
|
349
|
-
|
|
350
|
-
```bash
|
|
351
|
-
# For installed crackerjack (from PyPI)
|
|
352
|
-
uvx crackerjack --help
|
|
353
|
-
uvx crackerjack -t
|
|
354
|
-
uvx crackerjack --start-mcp-server
|
|
355
|
-
|
|
356
|
-
# For local development version
|
|
357
|
-
uvx --from /Users/les/Projects/crackerjack crackerjack --help
|
|
358
|
-
uvx --from /Users/les/Projects/crackerjack crackerjack -t
|
|
359
|
-
uvx --from /Users/les/Projects/crackerjack crackerjack --start-mcp-server
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
**Benefits**: Isolated execution, no dependency conflicts, consistent environment across systems.
|
|
282
|
+
**Isolated execution**: `uvx crackerjack -t` (PyPI) or `uvx --from /path crackerjack -t` (local)
|
|
363
283
|
|
|
364
284
|
## Architecture Overview
|
|
365
285
|
|
|
366
|
-
**
|
|
367
|
-
|
|
368
|
-
### Core Orchestration Layer
|
|
369
|
-
|
|
370
|
-
- **`core/workflow_orchestrator.py`**: Main entry point with `WorkflowOrchestrator` and `WorkflowPipeline` classes
|
|
371
|
-
- **`core/container.py`**: Basic dependency injection container using protocols for loose coupling
|
|
372
|
-
- **`core/enhanced_container.py`**: Advanced DI container with lifecycle management
|
|
373
|
-
- **ServiceLifetime** enum: `SINGLETON`, `TRANSIENT`, `SCOPED` service lifetimes
|
|
374
|
-
- **ServiceDescriptor** dataclass: Comprehensive service registration with factory support
|
|
375
|
-
- **Thread-safe**: Singleton instances with thread-local scoping
|
|
376
|
-
- **Dependency resolution**: Automatic dependency injection with circular dependency detection
|
|
377
|
-
- **`__main__.py`**: Simplified CLI entry point (reduced from 601 to 122 lines via modularization)
|
|
286
|
+
**Modular architecture with dependency injection:**
|
|
378
287
|
|
|
379
|
-
###
|
|
288
|
+
### Core Layers
|
|
380
289
|
|
|
381
|
-
-
|
|
382
|
-
-
|
|
383
|
-
-
|
|
384
|
-
|
|
385
|
-
- **Parallel hook execution**: Concurrent pre-commit hook processing
|
|
386
|
-
- **Progress streaming**: Real-time progress updates via WebSocket
|
|
387
|
-
- **Error aggregation**: Collects all errors before batch processing by AI agents
|
|
290
|
+
- **Orchestration**: `WorkflowOrchestrator`, DI containers with lifecycle management
|
|
291
|
+
- **Coordinators**: Session/phase coordination, async workflows with parallel execution
|
|
292
|
+
- **Managers**: Hook execution (fast→comprehensive), test management, publishing
|
|
293
|
+
- **Services**: Filesystem, git, config, security, health monitoring
|
|
388
294
|
|
|
389
|
-
###
|
|
295
|
+
### Key Patterns
|
|
390
296
|
|
|
391
|
-
|
|
392
|
-
- **`managers/test_manager.py`**: Test execution, coverage analysis, environment validation
|
|
393
|
-
- **`managers/publish_manager.py`**: Version bumping, git tagging, PyPI publishing with authentication
|
|
297
|
+
**Dependency Flow**: `__main__.py` → `WorkflowOrchestrator` → Coordinators → Managers → Services
|
|
394
298
|
|
|
395
|
-
|
|
299
|
+
**Critical**: Always import protocols from `models/protocols.py`, never concrete classes
|
|
396
300
|
|
|
397
|
-
|
|
301
|
+
- ❌ `from ..managers.test_manager import TestManager`
|
|
302
|
+
- ✅ `from ..models.protocols import TestManagerProtocol`
|
|
398
303
|
|
|
399
|
-
|
|
400
|
-
WorkflowOrchestrator → SessionCoordinator → PhaseCoordinator → Managers
|
|
401
|
-
↓
|
|
402
|
-
Container (DI) → Protocols → Concrete Implementations
|
|
403
|
-
```
|
|
304
|
+
### MCP Integration
|
|
404
305
|
|
|
405
|
-
**
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
- Always import protocols, never concrete classes for dependency injection
|
|
409
|
-
- **Common Error**: `from ..managers.test_manager import TestManager` ❌
|
|
410
|
-
- **Correct**: `from ..models.protocols import TestManagerProtocol` ✅
|
|
411
|
-
|
|
412
|
-
**Enhanced Dependency Injection Patterns** (using `EnhancedContainer`):
|
|
413
|
-
|
|
414
|
-
```python
|
|
415
|
-
from crackerjack.core.enhanced_container import EnhancedContainer, ServiceLifetime
|
|
416
|
-
|
|
417
|
-
# Service registration with lifecycle management
|
|
418
|
-
container.register_service(
|
|
419
|
-
interface=HookManagerProtocol,
|
|
420
|
-
implementation=AsyncHookManager,
|
|
421
|
-
lifetime=ServiceLifetime.SINGLETON, # Shared instance
|
|
422
|
-
)
|
|
423
|
-
|
|
424
|
-
# Factory-based registration for complex initialization
|
|
425
|
-
container.register_factory(
|
|
426
|
-
interface=TestManagerProtocol,
|
|
427
|
-
factory=lambda: create_test_manager_with_config(),
|
|
428
|
-
lifetime=ServiceLifetime.SCOPED, # Per-session instance
|
|
429
|
-
)
|
|
430
|
-
|
|
431
|
-
# Automatic dependency resolution
|
|
432
|
-
hook_manager = container.resolve(HookManagerProtocol) # Returns singleton
|
|
433
|
-
test_manager = container.resolve(TestManagerProtocol) # Creates scoped instance
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
### Infrastructure Services
|
|
437
|
-
|
|
438
|
-
- **`services/filesystem.py`**: Basic file operations with caching, batching, and security validation
|
|
439
|
-
- **`services/enhanced_filesystem.py`**: Advanced filesystem operations
|
|
440
|
-
- **Atomic Operations**: Ensures file consistency during concurrent operations
|
|
441
|
-
- **XDG Compliance**: Follows XDG Base Directory Specification for config/cache/data
|
|
442
|
-
- **Backup Management**: Automatic backup creation with rotation policies
|
|
443
|
-
- **Performance Monitoring**: File operation timing and performance metrics
|
|
444
|
-
- **Security Validation**: Path traversal prevention and secure temp file handling
|
|
445
|
-
- **`services/git.py`**: Git operations (commit, push, file tracking) with intelligent commit messages
|
|
446
|
-
- **`services/config.py`**: Configuration management for pyproject.toml and .pre-commit-config.yaml
|
|
447
|
-
- **`services/unified_config.py`**: Centralized configuration management across all components
|
|
448
|
-
- **`services/security.py`**: Token handling, command validation, secure temp file creation
|
|
449
|
-
- **`services/health_metrics.py`**: System health monitoring and performance benchmarking
|
|
450
|
-
- **`services/contextual_ai_assistant.py`**: AI-powered code analysis and suggestions
|
|
451
|
-
|
|
452
|
-
### MCP Integration (AI Agent Support)
|
|
453
|
-
|
|
454
|
-
**Refactored from monolithic 3,116-line server to modular architecture (70% line reduction):**
|
|
455
|
-
|
|
456
|
-
- **`mcp/server.py`**: Backward compatibility wrapper (32 lines, imports from modular implementation)
|
|
457
|
-
- **`mcp/server_core.py`**: Core MCP server configuration and setup (194 lines)
|
|
458
|
-
- **`mcp/tools/`**: Modular tool implementations:
|
|
459
|
-
- `core_tools.py`: Basic execution and stage tools
|
|
460
|
-
- `monitoring_tools.py`: Status monitoring and health checks
|
|
461
|
-
- `progress_tools.py`: Progress tracking and job management
|
|
462
|
-
- `execution_tools.py`: Auto-fixing and workflow execution
|
|
463
|
-
- **`mcp/context.py`**: Context manager for dependency injection and state management
|
|
464
|
-
- **`mcp/state.py`**: Thread-safe session state management with async locks
|
|
465
|
-
- **`mcp/cache.py`**: Thread-safe error pattern caching and fix result tracking
|
|
466
|
-
- **`mcp/rate_limiter.py`**: Rate limiting, resource management, and DoS protection
|
|
467
|
-
- **`mcp/file_monitor.py`**: Event-based file monitoring with watchdog
|
|
468
|
-
- **Entry point**: `python -m crackerjack --start-mcp-server`
|
|
469
|
-
|
|
470
|
-
**WebSocket Server (refactored from 1,479 lines to modular architecture - 35% reduction):**
|
|
471
|
-
|
|
472
|
-
- **`mcp/websocket_server.py`**: Backward compatibility wrapper (imports from modular implementation)
|
|
473
|
-
- **`mcp/websocket/server.py`**: Main WebSocket server class (101 lines)
|
|
474
|
-
- **`mcp/websocket/app.py`**: FastAPI application setup (26 lines)
|
|
475
|
-
- **`mcp/websocket/jobs.py`**: Job lifecycle and progress management (197 lines)
|
|
476
|
-
- **`mcp/websocket/endpoints.py`**: HTTP endpoint definitions (545 lines)
|
|
477
|
-
- **`mcp/websocket/websocket_handler.py`**: WebSocket connection handling (75 lines)
|
|
478
|
-
- **Entry point**: `python -m crackerjack --start-websocket-server`
|
|
479
|
-
|
|
480
|
-
### CLI Interface (Modular Command Handling)
|
|
481
|
-
|
|
482
|
-
- **`cli/options.py`**: CLI option definitions and models (213 lines)
|
|
483
|
-
- **`cli/handlers.py`**: Mode handlers for different execution types (124 lines)
|
|
484
|
-
- **`cli/utils.py`**: CLI utility functions (17 lines)
|
|
485
|
-
|
|
486
|
-
### Advanced Orchestration
|
|
487
|
-
|
|
488
|
-
- **`orchestration/advanced_orchestrator.py`**: Advanced workflow orchestration with parallel execution strategies
|
|
489
|
-
- **`orchestration/execution_strategies.py`**: Pluggable execution strategies for different workflow types
|
|
490
|
-
- **`orchestration/test_progress_streamer.py`**: Real-time test progress streaming with Rich UI
|
|
491
|
-
|
|
492
|
-
### Plugin System
|
|
493
|
-
|
|
494
|
-
- **`plugins/base.py`**: Base plugin interface and lifecycle management
|
|
495
|
-
- **`plugins/loader.py`**: Dynamic plugin loading with dependency resolution
|
|
496
|
-
- **`plugins/hooks.py`**: Pre-commit hook plugins with custom validation rules
|
|
497
|
-
- **`plugins/managers.py`**: Plugin-specific manager implementations
|
|
498
|
-
|
|
499
|
-
### Legacy Components (Stable, Integrated)
|
|
500
|
-
|
|
501
|
-
- **`code_cleaner.py`**: Modernized code cleaning with AST parsing and protocol-based architecture
|
|
502
|
-
- **`dynamic_config.py`**: Configuration generation and management
|
|
503
|
-
- **`interactive.py`**: Rich UI interactive mode with clean architecture
|
|
504
|
-
- **`api.py`**: Public API with TODO detection for code cleaning operations
|
|
306
|
+
**70% reduction**: 3,116 lines → modular architecture with tools, state management, rate limiting, monitoring
|
|
307
|
+
**WebSocket Server**: 35% reduction with FastAPI, job management, progress streaming
|
|
308
|
+
**Entry points**: `--start-mcp-server`, `--start-websocket-server`
|
|
505
309
|
|
|
506
310
|
## Quality Process
|
|
507
311
|
|
|
508
|
-
###
|
|
509
|
-
|
|
510
|
-
**Proper execution order for maximum efficiency (used by `/crackerjack:run`):**
|
|
511
|
-
|
|
512
|
-
1. **Fast Hooks First** (~5 seconds): `trailing-whitespace`, `end-of-file-fixer`, `ruff-format`, `ruff-check`, `gitleaks`
|
|
513
|
-
|
|
514
|
-
- **Package-focused**: `ruff-check` now runs only on `crackerjack/` package code, excludes `tests/`
|
|
515
|
-
- **Repository-wide**: Other fast hooks (formatting) still run on entire repository
|
|
516
|
-
- If any formatting hooks fail → **Retry fast hooks once** (formatting fixes often resolve downstream issues)
|
|
517
|
-
- Only proceed when fast hooks pass or have been retried
|
|
518
|
-
|
|
519
|
-
1. **Full Test Suite** (~variable): Run ALL tests, collect ALL failures
|
|
520
|
-
|
|
521
|
-
- **Don't stop on first failure** - gather complete list of test issues
|
|
522
|
-
- Tests are more critical than lint issues, so run before comprehensive hooks
|
|
523
|
-
|
|
524
|
-
1. **Comprehensive Hooks** (~30 seconds): `pyright`, `bandit`, `vulture`, `refurb`, `creosote`, `complexipy`
|
|
312
|
+
### Workflow Order
|
|
525
313
|
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
314
|
+
1. **Fast Hooks** (~5s): formatting, basic checks → retry once if fail
|
|
315
|
+
1. **Full Test Suite**: collect ALL failures, don't stop on first
|
|
316
|
+
1. **Comprehensive Hooks** (~30s): type checking, security, complexity → collect ALL issues
|
|
317
|
+
1. **AI Batch Fixing**: process all collected failures together
|
|
529
318
|
|
|
530
|
-
|
|
319
|
+
### Testing
|
|
531
320
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
### Testing Configuration
|
|
536
|
-
|
|
537
|
-
- **Framework**: pytest with asyncio auto mode
|
|
538
|
-
- **Coverage**: Incremental ratchet system targeting 100% coverage
|
|
539
|
-
- **Timeout**: 300 seconds per test (configurable with --test-timeout)
|
|
540
|
-
- **Workers**: Auto-detected based on CPU count (override with --test-workers)
|
|
541
|
-
- **Config file**: `pyproject.toml` contains pytest configuration
|
|
321
|
+
**Framework**: pytest with asyncio, 300s timeout, auto-detected workers
|
|
322
|
+
**Coverage**: Ratchet system targeting 100%, never decrease
|
|
542
323
|
|
|
543
324
|
## Code Standards
|
|
544
325
|
|
|
545
|
-
###
|
|
546
|
-
|
|
547
|
-
Following our philosophy that **EVERY LINE OF CODE IS A LIABILITY**:
|
|
548
|
-
|
|
549
|
-
- **DRY**: Extract common patterns into reusable functions/classes
|
|
550
|
-
- **YAGNI**: Implement only current requirements, not future "what-ifs"
|
|
551
|
-
- **KISS**: Choose simple solutions over clever ones
|
|
552
|
-
- **Readability First**: Code should be self-explanatory
|
|
553
|
-
- **Descriptive Names**: `user_count` not `uc`, even in map/filter functions
|
|
326
|
+
### Principles
|
|
554
327
|
|
|
555
|
-
|
|
328
|
+
- **DRY/YAGNI/KISS**: Extract patterns, build only what's needed, choose simple solutions
|
|
329
|
+
- **Python 3.13+**: `|` unions, protocols, pathlib, `import typing as t`, Pydantic
|
|
556
330
|
|
|
557
|
-
|
|
558
|
-
- Protocol-based interfaces in `models/protocols.py`
|
|
559
|
-
- Pathlib over os.path
|
|
560
|
-
- `import typing as t` convention
|
|
561
|
-
- Pydantic BaseModel for configuration with validation
|
|
331
|
+
### Quality Rules
|
|
562
332
|
|
|
563
|
-
|
|
333
|
+
- **Complexity ≤15** per function
|
|
334
|
+
- **No hardcoded paths** (use `tempfile`)
|
|
335
|
+
- **No shell=True** in subprocess
|
|
336
|
+
- **Type annotations required**
|
|
337
|
+
- **Protocol-based DI**
|
|
338
|
+
- **TODO resolution** required for cleaning mode
|
|
564
339
|
|
|
565
|
-
|
|
566
|
-
- **No hardcoded temp paths** (Security: Bandit B108) - use `tempfile` module
|
|
567
|
-
- **UV tool execution**: Always use `uv run` for external tools
|
|
568
|
-
- **No shell=True** in subprocess calls
|
|
569
|
-
- **Type annotations required**: All functions must have return type hints
|
|
570
|
-
- **Protocol compliance**: Use protocols for dependency injection interfaces
|
|
571
|
-
- **TODO detection**: Code cleaning (`-x`) requires resolving all TODO comments first
|
|
572
|
-
|
|
573
|
-
### Refactoring Patterns for Complexity Reduction
|
|
340
|
+
### Refactoring Pattern
|
|
574
341
|
|
|
575
342
|
```python
|
|
576
|
-
#
|
|
343
|
+
# Break complex methods into helper methods
|
|
577
344
|
def complex_method(self, data: dict) -> bool:
|
|
578
345
|
if not self._validate_input(data):
|
|
579
346
|
return self._handle_invalid_input()
|
|
580
|
-
|
|
581
347
|
processed = self._process_data(data)
|
|
582
348
|
return self._save_results(processed)
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
def _validate_input(self, data: dict) -> bool:
|
|
586
|
-
# Single responsibility validation logic
|
|
587
|
-
pass
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
def _handle_invalid_input(self) -> bool:
|
|
591
|
-
# Focused error handling
|
|
592
|
-
pass
|
|
593
349
|
```
|
|
594
350
|
|
|
595
|
-
### Error Prevention
|
|
351
|
+
### Error Prevention Examples
|
|
596
352
|
|
|
597
353
|
```python
|
|
598
|
-
#
|
|
599
|
-
config_path = "/tmp/test-config.yaml" # BAD
|
|
600
|
-
|
|
601
|
-
# USE: Proper temp file handling
|
|
602
|
-
import tempfile
|
|
603
|
-
|
|
354
|
+
# Use tempfile, not hardcoded paths
|
|
604
355
|
with tempfile.NamedTemporaryFile(suffix=".yaml") as f:
|
|
605
356
|
config_path = f.name
|
|
606
357
|
|
|
607
|
-
#
|
|
608
|
-
try:
|
|
609
|
-
risky_operation()
|
|
610
|
-
except Exception:
|
|
611
|
-
pass # BAD
|
|
612
|
-
|
|
613
|
-
# USE: contextlib.suppress
|
|
358
|
+
# Use contextlib.suppress, not try/except pass
|
|
614
359
|
from contextlib import suppress
|
|
615
360
|
|
|
616
361
|
with suppress(Exception):
|
|
617
362
|
risky_operation()
|
|
618
363
|
|
|
619
|
-
#
|
|
620
|
-
if status in
|
|
621
|
-
handle_error()
|
|
622
|
-
|
|
623
|
-
# USE: Tuples for immutable membership tests
|
|
624
|
-
if status in ("error", "failed", "timeout"): # GOOD
|
|
364
|
+
# Use tuples for membership tests
|
|
365
|
+
if status in ("error", "failed", "timeout"):
|
|
625
366
|
handle_error()
|
|
626
367
|
|
|
627
|
-
#
|
|
628
|
-
issues = []
|
|
629
|
-
for item in data:
|
|
630
|
-
if condition(item):
|
|
631
|
-
issues.append(process(item))
|
|
632
|
-
|
|
633
|
-
# USE: List comprehensions
|
|
368
|
+
# Use comprehensions, not manual building
|
|
634
369
|
issues = [process(item) for item in data if condition(item)]
|
|
635
370
|
|
|
636
|
-
#
|
|
637
|
-
emoji = AGENT_EMOJIS.get(agent_type)
|
|
638
|
-
if emoji:
|
|
639
|
-
return emoji
|
|
640
|
-
return "🤖"
|
|
641
|
-
|
|
642
|
-
# USE: Dictionary get with default
|
|
371
|
+
# Use dict.get with default
|
|
643
372
|
return AGENT_EMOJIS.get(agent_type, "🤖")
|
|
644
373
|
|
|
645
|
-
#
|
|
646
|
-
sorted_items = sorted(items, key=lambda x: x["priority"])
|
|
647
|
-
|
|
648
|
-
# USE: operator.itemgetter
|
|
374
|
+
# Use operator functions, not lambdas
|
|
649
375
|
from operator import itemgetter
|
|
650
376
|
|
|
651
377
|
sorted_items = sorted(items, key=itemgetter("priority"))
|
|
652
378
|
```
|
|
653
379
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
### Making Changes
|
|
380
|
+
### Regex Best Practices (CRITICAL)
|
|
657
381
|
|
|
658
|
-
|
|
659
|
-
1. **Run with tests**: `python -m crackerjack -t` (for comprehensive validation)
|
|
660
|
-
1. **Address remaining issues**: Manual fixes for any issues that tools cannot resolve
|
|
661
|
-
1. **Get AI code review**: When gemini-cli MCP server is connected, have Gemini review your completed work with `mcp__gemini-cli__ask-gemini` for a second opinion on code quality
|
|
662
|
-
1. **Commit changes**: Use `python -m crackerjack -c` for auto-commit with intelligent messages
|
|
382
|
+
**⚠️ WARNING: Bad regex caused security vulnerabilities. Always use centralized patterns.**
|
|
663
383
|
|
|
664
|
-
|
|
384
|
+
**NEVER write raw regex. Use centralized registry:**
|
|
665
385
|
|
|
666
|
-
```
|
|
667
|
-
#
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
# Test core orchestration
|
|
671
|
-
python -m pytest tests/test_coordinator_integration.py -v
|
|
386
|
+
```python
|
|
387
|
+
# ❌ DANGEROUS
|
|
388
|
+
text = re.sub(r"(\w+) - (\w+)", r"\g < 1 >-\g < 2 >", text)
|
|
672
389
|
|
|
673
|
-
#
|
|
674
|
-
|
|
390
|
+
# ✅ SAFE
|
|
391
|
+
from crackerjack.services.regex_patterns import SAFE_PATTERNS
|
|
675
392
|
|
|
676
|
-
|
|
677
|
-
python -m pytest tests/test_crackerjack.py::TestClass::test_method -v -s
|
|
393
|
+
text = SAFE_PATTERNS["fix_hyphenated_names"].apply(text)
|
|
678
394
|
```
|
|
679
395
|
|
|
680
|
-
|
|
396
|
+
**Available patterns**: command spacing, token masking, hyphenation, security fixes (18+ validated patterns)
|
|
681
397
|
|
|
682
|
-
|
|
683
|
-
- **Type errors**: Use `t.cast()` for complex type scenarios, ensure proper type annotations
|
|
684
|
-
- **Complexity violations**: Break large methods into focused helper methods
|
|
685
|
-
- **Test failures**: Check mock paths for new architecture
|
|
398
|
+
**FORBIDDEN patterns that cause vulnerabilities:**
|
|
686
399
|
|
|
687
|
-
|
|
400
|
+
- `r"\g < 1 >"` (spaces in replacement - SECURITY ISSUE)
|
|
401
|
+
- `r"\g< 1>"` or `r"\g<1 >"` (spacing bugs)
|
|
402
|
+
- `r".*"` (overly broad)
|
|
403
|
+
- Raw token masking
|
|
688
404
|
|
|
689
|
-
**
|
|
405
|
+
**Security token masking**: Use word boundaries, comprehensive tests, consistent application
|
|
406
|
+
**Emergency fix**: Find with `rg "pattern"`, replace with `SAFE_PATTERNS["pattern_name"].apply(text)`
|
|
690
407
|
|
|
691
|
-
|
|
408
|
+
## Common Issues & Solutions
|
|
692
409
|
|
|
693
|
-
|
|
694
|
-
- **🎨 Real-time Progress**: Live progress updates with Rich formatting
|
|
695
|
-
- **🔄 Auto-Fallback**: Graceful fallback from WebSocket to polling
|
|
696
|
-
- **📊 Job Tracking**: Comprehensive job progress and iteration monitoring
|
|
697
|
-
- **🛑 Signal Handling**: Graceful shutdown with Ctrl+C support
|
|
410
|
+
### Terminal Issues
|
|
698
411
|
|
|
699
|
-
|
|
412
|
+
- **Unresponsive terminal**: `./fix_terminal.sh` or `stty sane; reset; exec $SHELL -l`
|
|
413
|
+
- **No progress updates**: Start WebSocket server, verify at http://localhost:8675/
|
|
700
414
|
|
|
701
|
-
|
|
415
|
+
### Development Issues
|
|
702
416
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
# Step 2: Use /crackerjack:run in Claude - progress will be available at:
|
|
708
|
-
# - WebSocket: ws://localhost:8675/ws/progress/{job_id}
|
|
709
|
-
# - Test page: http://localhost:8675/test
|
|
710
|
-
# - Status: http://localhost:8675/
|
|
711
|
-
```
|
|
417
|
+
- **AI agent ineffective**: Use `--ai-debug -t` for analysis
|
|
418
|
+
- **Import errors**: Always import protocols from `models/protocols.py`
|
|
419
|
+
- **Test hangs**: Avoid complex async tests, use simple synchronous config tests
|
|
712
420
|
|
|
713
|
-
|
|
421
|
+
### Quality Issues
|
|
714
422
|
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
423
|
+
- **Coverage failing**: Never reduce below baseline, add tests incrementally
|
|
424
|
+
- **Complexity >15**: Break into helper methods using RefactoringAgent approach
|
|
425
|
+
- **Security violations**: Use `SAFE_PATTERNS` for token masking
|
|
426
|
+
- **Regex issues**: Never use raw regex, use centralized patterns
|
|
719
427
|
|
|
720
|
-
|
|
428
|
+
### Server Issues
|
|
721
429
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
python -m crackerjack.mcp.progress_monitor abc123-def456
|
|
430
|
+
- **MCP not starting**: `--restart-mcp-server` or `--watchdog`
|
|
431
|
+
- **WebSocket failures**: Restart with `--websocket-port 8675`
|
|
725
432
|
|
|
726
|
-
|
|
727
|
-
python -m crackerjack.mcp.progress_monitor abc123-def456 ws://localhost:8675
|
|
728
|
-
```
|
|
433
|
+
### Performance Issues
|
|
729
434
|
|
|
730
|
-
**
|
|
435
|
+
- **Slow tests**: Customize `--test-workers N` or `--benchmark`
|
|
436
|
+
- **Memory issues**: PerformanceAgent detects O(n²) patterns
|
|
437
|
+
- **Slow hooks**: Use `--skip-hooks` during rapid iteration
|
|
731
438
|
|
|
732
|
-
|
|
733
|
-
from crackerjack.mcp.progress_monitor import (
|
|
734
|
-
run_crackerjack_with_enhanced_progress,
|
|
735
|
-
)
|
|
439
|
+
## Development Workflow
|
|
736
440
|
|
|
737
|
-
|
|
738
|
-
await run_crackerjack_with_enhanced_progress(client, "/crackerjack:run")
|
|
739
|
-
```
|
|
441
|
+
### Standard Process
|
|
740
442
|
|
|
741
|
-
|
|
443
|
+
1. Run quality checks: `python -m crackerjack`
|
|
444
|
+
1. Run with tests: `python -m crackerjack -t`
|
|
445
|
+
1. Address remaining issues manually
|
|
446
|
+
1. Optional AI review: `mcp__gemini-cli__ask-gemini`
|
|
447
|
+
1. Commit: `python -m crackerjack -c`
|
|
742
448
|
|
|
743
|
-
|
|
744
|
-
- **MCP Protocol**: FastMCP-based tools for AI agent integration
|
|
745
|
-
- **Progress Queue**: `asyncio.Queue` for real-time job updates
|
|
746
|
-
- **Rich Components**: Formatted progress panels and status displays
|
|
747
|
-
- **Job Management**: Background task execution with progress tracking
|
|
449
|
+
### Testing Components
|
|
748
450
|
|
|
749
|
-
|
|
451
|
+
- **Specific**: `python -m pytest tests/test_managers.py -v`
|
|
452
|
+
- **Isolated**: `python -m pytest tests/test_file.py::TestClass::test_method -v -s`
|
|
750
453
|
|
|
751
|
-
|
|
752
|
-
- `get_job_progress`: Get current progress for running jobs
|
|
753
|
-
- `get_comprehensive_status`: Get complete system status (servers, jobs, health)
|
|
754
|
-
- `run_crackerjack_stage`: Execute specific workflow stages
|
|
755
|
-
- `analyze_errors`: Intelligent error pattern analysis
|
|
756
|
-
- `session_management`: Track iteration state and checkpoints
|
|
757
|
-
- `get_stage_status`: Get workflow stage completion status
|
|
758
|
-
- `get_server_stats`: Get MCP server resource usage and statistics
|
|
454
|
+
### Common Issues
|
|
759
455
|
|
|
760
|
-
|
|
456
|
+
- **Import errors**: Check `models/protocols.py` for interfaces
|
|
457
|
+
- **Type errors**: Use `t.cast()`, ensure annotations
|
|
458
|
+
- **Complexity**: Break into helper methods
|
|
761
459
|
|
|
762
|
-
|
|
763
|
-
- `uvicorn>=0.32.1`: WebSocket server support
|
|
764
|
-
- `websockets>=15.0.1`: WebSocket client connections
|
|
765
|
-
- `fastapi>=0.116.1`: HTTP/WebSocket endpoint framework
|
|
766
|
-
- `rich>=14`: Terminal formatting and progress displays
|
|
460
|
+
## MCP Server Integration
|
|
767
461
|
|
|
768
|
-
###
|
|
462
|
+
### Features
|
|
769
463
|
|
|
770
|
-
**
|
|
464
|
+
- **Dual Protocol**: MCP tools + WebSocket server on localhost:8675
|
|
465
|
+
- **Real-time Progress**: Live updates with Rich formatting
|
|
466
|
+
- **Job Tracking**: Comprehensive progress monitoring
|
|
771
467
|
|
|
772
|
-
|
|
468
|
+
### Usage
|
|
773
469
|
|
|
774
|
-
|
|
470
|
+
```bash
|
|
471
|
+
# Start WebSocket server
|
|
472
|
+
python -m crackerjack --start-websocket-server
|
|
775
473
|
|
|
776
|
-
|
|
474
|
+
# Use /crackerjack:run in Claude
|
|
475
|
+
# Progress at: http://localhost:8675/
|
|
777
476
|
|
|
778
|
-
|
|
477
|
+
# Monitor job
|
|
478
|
+
python -m crackerjack.mcp.progress_monitor <job_id>
|
|
479
|
+
```
|
|
779
480
|
|
|
780
|
-
|
|
781
|
-
from crackerjack.slash_commands import list_available_commands, get_slash_command_path
|
|
481
|
+
### Available Tools
|
|
782
482
|
|
|
783
|
-
|
|
784
|
-
|
|
483
|
+
- `execute_crackerjack`: Start auto-fixing workflow
|
|
484
|
+
- `get_job_progress`: Get current job progress
|
|
485
|
+
- `get_comprehensive_status`: Complete system status
|
|
486
|
+
- `analyze_errors`: Error pattern analysis
|
|
487
|
+
- `session_management`: Track iterations
|
|
785
488
|
|
|
786
|
-
|
|
787
|
-
command_path = get_slash_command_path("run")
|
|
788
|
-
command_content = command_path.read_text()
|
|
789
|
-
```
|
|
489
|
+
### Slash Commands
|
|
790
490
|
|
|
791
|
-
|
|
491
|
+
- **`/crackerjack:run`**: Full auto-fixing with progress tracking
|
|
492
|
+
- **`/crackerjack:status`**: System status and health
|
|
493
|
+
- **`/crackerjack:init`**: Initialize project configuration
|
|
792
494
|
|
|
793
|
-
|
|
495
|
+
## Configuration
|
|
794
496
|
|
|
795
|
-
- **Coverage
|
|
796
|
-
- **
|
|
797
|
-
- **Python
|
|
798
|
-
- **Test timeout**:
|
|
799
|
-
- **Type checking**: Strict
|
|
800
|
-
- **Security
|
|
497
|
+
- **Coverage**: Ratchet system targeting 100%
|
|
498
|
+
- **Complexity**: ≤15 per function
|
|
499
|
+
- **Python**: 3.13+ required
|
|
500
|
+
- **Test timeout**: 300s
|
|
501
|
+
- **Type checking**: Strict Pyright
|
|
502
|
+
- **Security**: Bandit scanning
|
|
801
503
|
|
|
802
504
|
## Service Watchdog
|
|
803
505
|
|
|
804
|
-
**
|
|
805
|
-
|
|
806
|
-
### Overview
|
|
807
|
-
|
|
808
|
-
The Service Watchdog provides enterprise-grade monitoring and automatic recovery for Crackerjack's server components. It ensures continuous availability by detecting failures and restarting services automatically.
|
|
506
|
+
**Auto-restart system for servers**
|
|
809
507
|
|
|
810
508
|
### Usage
|
|
811
509
|
|
|
812
510
|
```bash
|
|
813
|
-
# Start watchdog to monitor both MCP and WebSocket servers
|
|
814
511
|
python -m crackerjack --watchdog
|
|
815
512
|
```
|
|
816
513
|
|
|
817
|
-
### Monitored Services
|
|
818
|
-
|
|
819
|
-
1. **MCP Server** (`--start-mcp-server`)
|
|
820
|
-
|
|
821
|
-
- Process monitoring (detects crashes)
|
|
822
|
-
- No HTTP health checks (stdio-based protocol)
|
|
823
|
-
- Auto-restart on process termination
|
|
824
|
-
|
|
825
|
-
1. **WebSocket Server** (`--start-websocket-server`)
|
|
826
|
-
|
|
827
|
-
- Process monitoring (detects crashes)
|
|
828
|
-
- HTTP health checks (`http://localhost:8675/`)
|
|
829
|
-
- Auto-restart on process or health check failures
|
|
830
|
-
|
|
831
514
|
### Features
|
|
832
515
|
|
|
833
|
-
- **Real-time
|
|
834
|
-
- **
|
|
835
|
-
- **
|
|
836
|
-
- **
|
|
837
|
-
- **
|
|
838
|
-
- **Error Tracking**: Logs and displays last error for each service
|
|
839
|
-
- **Graceful Shutdown**: Proper cleanup on Ctrl+C
|
|
840
|
-
|
|
841
|
-
### Dashboard Display
|
|
842
|
-
|
|
843
|
-
The watchdog shows a real-time table with:
|
|
844
|
-
|
|
845
|
-
- **Service**: Service name (MCP Server, WebSocket Server)
|
|
846
|
-
- **Status**: ✅ Running / ❌ Stopped
|
|
847
|
-
- **Health**: 🟢 Healthy / 🔴 Unhealthy / N/A
|
|
848
|
-
- **Restarts**: Total restart count for the session
|
|
849
|
-
- **Last Error**: Most recent error message (truncated)
|
|
850
|
-
|
|
851
|
-
### Configuration
|
|
852
|
-
|
|
853
|
-
Default configuration monitors:
|
|
854
|
-
|
|
855
|
-
- **Health Check Interval**: 30 seconds
|
|
856
|
-
- **Restart Delay**: 5 seconds between restart attempts
|
|
857
|
-
- **Max Restarts**: 10 per 5-minute window
|
|
858
|
-
- **Health Timeout**: 10 seconds for HTTP checks
|
|
859
|
-
|
|
860
|
-
### Use Cases
|
|
861
|
-
|
|
862
|
-
- **Development**: Automatic recovery during active development sessions
|
|
863
|
-
- **CI/CD**: Ensure services stay running during automated testing
|
|
864
|
-
- **Production**: High-availability deployment with automatic failover
|
|
865
|
-
- **Debugging**: Monitor service stability and identify recurring issues
|
|
866
|
-
|
|
867
|
-
### Dependencies
|
|
868
|
-
|
|
869
|
-
- `aiohttp`: HTTP health check client
|
|
870
|
-
- `rich`: Dashboard display and formatting
|
|
871
|
-
- `asyncio`: Concurrent monitoring and restart management
|
|
872
|
-
|
|
873
|
-
## Architecture Migration Notes
|
|
874
|
-
|
|
875
|
-
**Key changes from monolithic to modular:**
|
|
876
|
-
|
|
877
|
-
- `Crackerjack` class methods → `WorkflowOrchestrator` + coordinator delegation
|
|
878
|
-
- Direct tool execution → Manager pattern with dependency injection
|
|
879
|
-
- Hardcoded workflows → Configurable phase execution with retry logic
|
|
880
|
-
- Manual error handling → Automatic fixing with intelligent retry
|
|
516
|
+
- **Real-time monitoring**: Process/health checks
|
|
517
|
+
- **Auto-restart**: Rate-limited with backoff (max 10/5min)
|
|
518
|
+
- **Dashboard**: Live status display
|
|
519
|
+
- **Health checks**: HTTP monitoring for WebSocket server
|
|
520
|
+
- **Graceful shutdown**: Ctrl+C cleanup
|
|
881
521
|
|
|
882
|
-
**
|
|
522
|
+
**Monitors**: MCP server (process), WebSocket server (process + HTTP health)
|
|
883
523
|
|
|
884
|
-
|
|
885
|
-
- **Modular CLI**: Options and handlers moved to dedicated modules (`cli/options.py`, `cli/handlers.py`)
|
|
886
|
-
- **Protocol-based Design**: Dependency injection through protocols for better testability
|
|
524
|
+
## Recent Achievements (January 2025)
|
|
887
525
|
|
|
888
|
-
**Refactoring
|
|
526
|
+
**Refactoring Results:**
|
|
889
527
|
|
|
890
|
-
- **70% line reduction
|
|
891
|
-
- **35% line reduction
|
|
892
|
-
- **80% line reduction
|
|
893
|
-
- **Code Quality Improvements**:
|
|
894
|
-
- Fixed all 31+ refurb violations in agents directory (FURB107, FURB109, FURB118, FURB135, FURB138, FURB184)
|
|
895
|
-
- Reduced complex functions from 32 to 29 total, with major reductions:
|
|
896
|
-
- `_execute_crackerjack_sync`: complexity 34 → 3 (91% reduction)
|
|
897
|
-
- `TestManagementImpl::run_tests`: complexity 33 → 2 (94% reduction)
|
|
898
|
-
- All 5 fast hooks now passing consistently
|
|
899
|
-
- **Improved maintainability** through single responsibility principle
|
|
900
|
-
- **Better testability** with focused, isolated modules
|
|
901
|
-
- **Enhanced security** with modular validation and error handling
|
|
902
|
-
- **Protocol-based interfaces** for better dependency injection and testing
|
|
903
|
-
- **Performance Improvements**: Enhanced async/await patterns, parallel execution, and caching strategies
|
|
904
|
-
- **Plugin Architecture**: Extensible plugin system for custom hooks and workflow extensions
|
|
905
|
-
- **Health Monitoring**: Comprehensive system health metrics and performance benchmarking
|
|
528
|
+
- **70% line reduction**: MCP server (3,116 → 921 lines)
|
|
529
|
+
- **35% line reduction**: WebSocket server (1,479 → 944 lines)
|
|
530
|
+
- **80% line reduction**: CLI entry point (601 → 122 lines)
|
|
906
531
|
|
|
907
|
-
|
|
532
|
+
**Quality Improvements:**
|
|
908
533
|
|
|
909
|
-
|
|
534
|
+
- Fixed all 31+ refurb violations
|
|
535
|
+
- Major complexity reductions: 34→3 (91%), 33→2 (94%)
|
|
536
|
+
- All 5 fast hooks passing consistently
|
|
537
|
+
- Protocol-based interfaces throughout
|
|
910
538
|
|
|
911
|
-
|
|
912
|
-
- **Add tests to increase coverage** incrementally toward 100%
|
|
913
|
-
- **Current Status**: Test coverage at 10.11% baseline, targeting 100%
|
|
914
|
-
- Existing test files cover various modules including core components, managers, and async workflows
|
|
915
|
-
- Focus testing on modules with 0% coverage: plugins, MCP server, enhanced filesystem, unified config
|
|
539
|
+
## Test Coverage Status
|
|
916
540
|
|
|
917
|
-
|
|
541
|
+
**Current**: 10.11% baseline targeting 100%
|
|
542
|
+
**Strategy**: Import-only tests, protocol compliance, async validation, integration testing
|
|
543
|
+
**Priority**: Fix existing failures first, then add tests incrementally
|
|
918
544
|
|
|
919
|
-
|
|
545
|
+
**Ratchet System**: 2% tolerance, never reduce coverage
|
|
920
546
|
|
|
921
|
-
|
|
922
|
-
- Fast hooks: All 5 passing consistently
|
|
923
|
-
- Major complexity reductions (34→3, 33→2)
|
|
924
|
-
- Import errors and protocol compliance fixed
|
|
547
|
+
## Critical Reminders
|
|
925
548
|
|
|
926
|
-
|
|
549
|
+
### Core Instructions
|
|
927
550
|
|
|
928
|
-
-
|
|
929
|
-
-
|
|
551
|
+
- Do only what's asked, nothing more
|
|
552
|
+
- NEVER create files unless absolutely necessary
|
|
553
|
+
- ALWAYS prefer editing existing files
|
|
554
|
+
- NEVER proactively create documentation
|
|
555
|
+
- MAINTAIN coverage ratchet
|
|
930
556
|
|
|
931
|
-
|
|
557
|
+
### Quality Standards
|
|
932
558
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
559
|
+
- **Test Quality**: Avoid async tests that hang, use synchronous config tests
|
|
560
|
+
- **Honest Reporting**: Report actual percentages (10.17%, not "approaching 15%")
|
|
561
|
+
- **Import Compliance**: Use protocols from `models/protocols.py`
|
|
562
|
+
- **Fix failures FIRST** before creating new tests
|
|
563
|
+
- Use IDE diagnostics after implementation
|
|
564
|
+
- Be critical/comprehensive in reviews
|
|
565
|
+
- Use crackerjack-architect agent for compliant code
|
|
937
566
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
### Current Test Strategy (Post-Architectural Refactoring)
|
|
941
|
-
|
|
942
|
-
**Strategic Testing Approach**:
|
|
943
|
-
|
|
944
|
-
- **Import-only tests**: Fast, reliable coverage for basic module loading and interface compliance
|
|
945
|
-
- **Protocol compliance tests**: Ensure all implementations properly follow interface contracts
|
|
946
|
-
- **Async pattern testing**: Comprehensive validation of async/await workflows without hanging tests
|
|
947
|
-
- **Integration testing**: End-to-end validation of dependency injection and workflow orchestration
|
|
948
|
-
- **Performance regression testing**: Automated detection of performance degradation in async workflows
|
|
949
|
-
|
|
950
|
-
## Important Instruction Reminders
|
|
951
|
-
|
|
952
|
-
- Do what has been asked; nothing more, nothing less
|
|
953
|
-
- NEVER create files unless absolutely necessary for achieving your goal
|
|
954
|
-
- ALWAYS prefer editing an existing file to creating a new one
|
|
955
|
-
- NEVER proactively create documentation files (\*.md) or README files unless explicitly requested
|
|
956
|
-
- MAINTAIN coverage ratchet - never decrease coverage, always improve toward 100%
|
|
957
|
-
|
|
958
|
-
## Coding Standards Memories
|
|
959
|
-
|
|
960
|
-
- Do not reduce coverage below current baseline. Instead add tests to increase coverage toward 100% target.
|
|
961
|
-
- **Debugging Approach Memory**: Focus on test errors first then move on to failures when debugging tests
|
|
962
|
-
|
|
963
|
-
## Critical Quality Standards
|
|
964
|
-
|
|
965
|
-
- **Test Quality**: Never create async tests that hang indefinitely. When testing async components like `BatchedStateSaver`, prefer simple synchronous tests that verify configuration and basic state rather than complex async workflows that can cause test suite timeouts.
|
|
966
|
-
- **Honest Progress Reporting**: Always report actual coverage percentages and test results accurately. If coverage is 10.17%, report it as 10.17%, not "approaching 15%" or other optimistic estimates.
|
|
967
|
-
- **Import Error Prevention**: Common import error pattern: `TestManager` vs `TestManagerProtocol` in `async_workflow_orchestrator.py`. Always use protocol interfaces from `models/protocols.py`.
|
|
968
|
-
|
|
969
|
-
## Development Standards
|
|
970
|
-
|
|
971
|
-
- be honest when describing the things you have accomplished. if tasks have not been completed to their full extent we need to know so sugarcoating your accomplishments for your, and especially our, benefit helps nobody.
|
|
972
|
-
|
|
973
|
-
- be very critical and comprehensive when performing code or documentation reviews/audits. pride ourselves on our attention to detail and take the time to do things right the first time. always still assume failure on the first try, when making edits, so our work is double checked and bulletproof.
|
|
974
|
-
|
|
975
|
-
## Common Failure Patterns to Avoid
|
|
976
|
-
|
|
977
|
-
### Async Test Hangs
|
|
567
|
+
### Failure Patterns to Avoid
|
|
978
568
|
|
|
979
569
|
```python
|
|
980
|
-
#
|
|
570
|
+
# ❌ Async tests that hang
|
|
981
571
|
@pytest.mark.asyncio
|
|
982
572
|
async def test_batch_processing(self, batched_saver):
|
|
983
|
-
await batched_saver.start()
|
|
984
|
-
# Complex async workflow that might hang
|
|
573
|
+
await batched_saver.start() # Can hang
|
|
985
574
|
|
|
986
575
|
|
|
987
|
-
#
|
|
576
|
+
# ✅ Simple synchronous tests
|
|
988
577
|
def test_batch_configuration(self, batched_saver):
|
|
989
578
|
assert batched_saver.max_batch_size == expected_size
|
|
990
|
-
assert not batched_saver._running
|
|
991
|
-
```
|
|
992
579
|
|
|
993
|
-
### Import Error Prevention
|
|
994
580
|
|
|
995
|
-
|
|
996
|
-
# WRONG: Importing concrete classes instead of protocols
|
|
581
|
+
# ❌ Import concrete classes
|
|
997
582
|
from ..managers.test_manager import TestManager
|
|
998
583
|
|
|
999
|
-
#
|
|
584
|
+
# ✅ Import protocols
|
|
1000
585
|
from ..models.protocols import TestManagerProtocol
|
|
1001
586
|
```
|
|
1002
587
|
|
|
1003
|
-
-
|
|
1004
|
-
- always be honest with your answers. do not embelish on progress.
|
|
1005
|
-
- always clean up after yourself
|
|
588
|
+
- make as few edits as possible by batching related changes together in a single operation.
|