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.

Files changed (156) hide show
  1. crackerjack/CLAUDE.md +1005 -0
  2. crackerjack/RULES.md +380 -0
  3. crackerjack/__init__.py +42 -13
  4. crackerjack/__main__.py +227 -299
  5. crackerjack/agents/__init__.py +41 -0
  6. crackerjack/agents/architect_agent.py +281 -0
  7. crackerjack/agents/base.py +170 -0
  8. crackerjack/agents/coordinator.py +512 -0
  9. crackerjack/agents/documentation_agent.py +498 -0
  10. crackerjack/agents/dry_agent.py +388 -0
  11. crackerjack/agents/formatting_agent.py +245 -0
  12. crackerjack/agents/import_optimization_agent.py +281 -0
  13. crackerjack/agents/performance_agent.py +669 -0
  14. crackerjack/agents/proactive_agent.py +104 -0
  15. crackerjack/agents/refactoring_agent.py +788 -0
  16. crackerjack/agents/security_agent.py +529 -0
  17. crackerjack/agents/test_creation_agent.py +657 -0
  18. crackerjack/agents/test_specialist_agent.py +486 -0
  19. crackerjack/agents/tracker.py +212 -0
  20. crackerjack/api.py +560 -0
  21. crackerjack/cli/__init__.py +24 -0
  22. crackerjack/cli/facade.py +104 -0
  23. crackerjack/cli/handlers.py +267 -0
  24. crackerjack/cli/interactive.py +471 -0
  25. crackerjack/cli/options.py +409 -0
  26. crackerjack/cli/utils.py +18 -0
  27. crackerjack/code_cleaner.py +618 -928
  28. crackerjack/config/__init__.py +19 -0
  29. crackerjack/config/hooks.py +218 -0
  30. crackerjack/core/__init__.py +0 -0
  31. crackerjack/core/async_workflow_orchestrator.py +406 -0
  32. crackerjack/core/autofix_coordinator.py +200 -0
  33. crackerjack/core/container.py +104 -0
  34. crackerjack/core/enhanced_container.py +542 -0
  35. crackerjack/core/performance.py +243 -0
  36. crackerjack/core/phase_coordinator.py +585 -0
  37. crackerjack/core/proactive_workflow.py +316 -0
  38. crackerjack/core/session_coordinator.py +289 -0
  39. crackerjack/core/workflow_orchestrator.py +826 -0
  40. crackerjack/dynamic_config.py +94 -103
  41. crackerjack/errors.py +263 -41
  42. crackerjack/executors/__init__.py +11 -0
  43. crackerjack/executors/async_hook_executor.py +431 -0
  44. crackerjack/executors/cached_hook_executor.py +242 -0
  45. crackerjack/executors/hook_executor.py +345 -0
  46. crackerjack/executors/individual_hook_executor.py +669 -0
  47. crackerjack/intelligence/__init__.py +44 -0
  48. crackerjack/intelligence/adaptive_learning.py +751 -0
  49. crackerjack/intelligence/agent_orchestrator.py +551 -0
  50. crackerjack/intelligence/agent_registry.py +414 -0
  51. crackerjack/intelligence/agent_selector.py +502 -0
  52. crackerjack/intelligence/integration.py +290 -0
  53. crackerjack/interactive.py +576 -315
  54. crackerjack/managers/__init__.py +11 -0
  55. crackerjack/managers/async_hook_manager.py +135 -0
  56. crackerjack/managers/hook_manager.py +137 -0
  57. crackerjack/managers/publish_manager.py +433 -0
  58. crackerjack/managers/test_command_builder.py +151 -0
  59. crackerjack/managers/test_executor.py +443 -0
  60. crackerjack/managers/test_manager.py +258 -0
  61. crackerjack/managers/test_manager_backup.py +1124 -0
  62. crackerjack/managers/test_progress.py +114 -0
  63. crackerjack/mcp/__init__.py +0 -0
  64. crackerjack/mcp/cache.py +336 -0
  65. crackerjack/mcp/client_runner.py +104 -0
  66. crackerjack/mcp/context.py +621 -0
  67. crackerjack/mcp/dashboard.py +636 -0
  68. crackerjack/mcp/enhanced_progress_monitor.py +479 -0
  69. crackerjack/mcp/file_monitor.py +336 -0
  70. crackerjack/mcp/progress_components.py +569 -0
  71. crackerjack/mcp/progress_monitor.py +949 -0
  72. crackerjack/mcp/rate_limiter.py +332 -0
  73. crackerjack/mcp/server.py +22 -0
  74. crackerjack/mcp/server_core.py +244 -0
  75. crackerjack/mcp/service_watchdog.py +501 -0
  76. crackerjack/mcp/state.py +395 -0
  77. crackerjack/mcp/task_manager.py +257 -0
  78. crackerjack/mcp/tools/__init__.py +17 -0
  79. crackerjack/mcp/tools/core_tools.py +249 -0
  80. crackerjack/mcp/tools/error_analyzer.py +308 -0
  81. crackerjack/mcp/tools/execution_tools.py +372 -0
  82. crackerjack/mcp/tools/execution_tools_backup.py +1097 -0
  83. crackerjack/mcp/tools/intelligence_tool_registry.py +80 -0
  84. crackerjack/mcp/tools/intelligence_tools.py +314 -0
  85. crackerjack/mcp/tools/monitoring_tools.py +502 -0
  86. crackerjack/mcp/tools/proactive_tools.py +384 -0
  87. crackerjack/mcp/tools/progress_tools.py +217 -0
  88. crackerjack/mcp/tools/utility_tools.py +341 -0
  89. crackerjack/mcp/tools/workflow_executor.py +565 -0
  90. crackerjack/mcp/websocket/__init__.py +14 -0
  91. crackerjack/mcp/websocket/app.py +39 -0
  92. crackerjack/mcp/websocket/endpoints.py +559 -0
  93. crackerjack/mcp/websocket/jobs.py +253 -0
  94. crackerjack/mcp/websocket/server.py +116 -0
  95. crackerjack/mcp/websocket/websocket_handler.py +78 -0
  96. crackerjack/mcp/websocket_server.py +10 -0
  97. crackerjack/models/__init__.py +31 -0
  98. crackerjack/models/config.py +93 -0
  99. crackerjack/models/config_adapter.py +230 -0
  100. crackerjack/models/protocols.py +118 -0
  101. crackerjack/models/task.py +154 -0
  102. crackerjack/monitoring/ai_agent_watchdog.py +450 -0
  103. crackerjack/monitoring/regression_prevention.py +638 -0
  104. crackerjack/orchestration/__init__.py +0 -0
  105. crackerjack/orchestration/advanced_orchestrator.py +970 -0
  106. crackerjack/orchestration/coverage_improvement.py +223 -0
  107. crackerjack/orchestration/execution_strategies.py +341 -0
  108. crackerjack/orchestration/test_progress_streamer.py +636 -0
  109. crackerjack/plugins/__init__.py +15 -0
  110. crackerjack/plugins/base.py +200 -0
  111. crackerjack/plugins/hooks.py +246 -0
  112. crackerjack/plugins/loader.py +335 -0
  113. crackerjack/plugins/managers.py +259 -0
  114. crackerjack/py313.py +8 -3
  115. crackerjack/services/__init__.py +22 -0
  116. crackerjack/services/cache.py +314 -0
  117. crackerjack/services/config.py +358 -0
  118. crackerjack/services/config_integrity.py +99 -0
  119. crackerjack/services/contextual_ai_assistant.py +516 -0
  120. crackerjack/services/coverage_ratchet.py +356 -0
  121. crackerjack/services/debug.py +736 -0
  122. crackerjack/services/dependency_monitor.py +617 -0
  123. crackerjack/services/enhanced_filesystem.py +439 -0
  124. crackerjack/services/file_hasher.py +151 -0
  125. crackerjack/services/filesystem.py +421 -0
  126. crackerjack/services/git.py +176 -0
  127. crackerjack/services/health_metrics.py +611 -0
  128. crackerjack/services/initialization.py +873 -0
  129. crackerjack/services/log_manager.py +286 -0
  130. crackerjack/services/logging.py +174 -0
  131. crackerjack/services/metrics.py +578 -0
  132. crackerjack/services/pattern_cache.py +362 -0
  133. crackerjack/services/pattern_detector.py +515 -0
  134. crackerjack/services/performance_benchmarks.py +653 -0
  135. crackerjack/services/security.py +163 -0
  136. crackerjack/services/server_manager.py +234 -0
  137. crackerjack/services/smart_scheduling.py +144 -0
  138. crackerjack/services/tool_version_service.py +61 -0
  139. crackerjack/services/unified_config.py +437 -0
  140. crackerjack/services/version_checker.py +248 -0
  141. crackerjack/slash_commands/__init__.py +14 -0
  142. crackerjack/slash_commands/init.md +122 -0
  143. crackerjack/slash_commands/run.md +163 -0
  144. crackerjack/slash_commands/status.md +127 -0
  145. crackerjack-0.31.7.dist-info/METADATA +742 -0
  146. crackerjack-0.31.7.dist-info/RECORD +149 -0
  147. crackerjack-0.31.7.dist-info/entry_points.txt +2 -0
  148. crackerjack/.gitignore +0 -34
  149. crackerjack/.libcst.codemod.yaml +0 -18
  150. crackerjack/.pdm.toml +0 -1
  151. crackerjack/crackerjack.py +0 -3805
  152. crackerjack/pyproject.toml +0 -286
  153. crackerjack-0.30.3.dist-info/METADATA +0 -1290
  154. crackerjack-0.30.3.dist-info/RECORD +0 -16
  155. {crackerjack-0.30.3.dist-info → crackerjack-0.31.7.dist-info}/WHEEL +0 -0
  156. {crackerjack-0.30.3.dist-info → crackerjack-0.31.7.dist-info}/licenses/LICENSE +0 -0
crackerjack/CLAUDE.md ADDED
@@ -0,0 +1,1005 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Clean Code Philosophy (READ FIRST)
6
+
7
+ **EVERY LINE OF CODE IS A LIABILITY. The best code is no code.**
8
+
9
+ - **DRY (Don't Repeat Yourself)**: If you write it twice, you're doing it wrong
10
+ - **YAGNI (You Ain't Gonna Need It)**: Build only what's needed NOW
11
+ - **KISS (Keep It Simple, Stupid)**: Complexity is the enemy of maintainability
12
+ - **Less is More**: Prefer 10 lines that are clear over 100 that are clever
13
+ - **Code is Read 10x More Than Written**: Optimize for readability
14
+ - **Self-Documenting Code**: Code should explain itself; comments only for "why", not "what". Variable names should **ALWAYS** be clear and descriptive, even in inline map/filter functions.
15
+
16
+ ## Project Overview
17
+
18
+ Crackerjack is an opinionated Python project management tool that unifies UV, Ruff, pytest, and pre-commit into a single workflow. It enforces consistent code quality from setup to deployment and includes AI agent integration via MCP (Model Context Protocol).
19
+
20
+ **Key Dependencies**: Python 3.13+, UV package manager, pre-commit hooks, pytest
21
+
22
+ ## Core Development Commands
23
+
24
+ ### Primary Workflows
25
+
26
+ ```bash
27
+ # Quality checks only (most common during development)
28
+ python -m crackerjack
29
+
30
+ # With testing
31
+ python -m crackerjack -t
32
+
33
+ # Code cleaning with TODO detection (blocks if TODOs found)
34
+ python -m crackerjack -x
35
+
36
+ # Full release workflow with version bump and publishing
37
+ python -m crackerjack -a patch
38
+
39
+ # Interactive mode with rich UI
40
+ python -m crackerjack -i
41
+
42
+ # Skip hooks during development iterations
43
+ python -m crackerjack --skip-hooks
44
+
45
+ # AI Agent mode with autonomous auto-fixing (STANDARD PROCESS)
46
+ python -m crackerjack --ai-agent -t
47
+
48
+ # AI Agent mode with full debugging and verbose output
49
+ python -m crackerjack --ai-debug -t
50
+
51
+ # Start MCP server for AI agent integration
52
+ python -m crackerjack --start-mcp-server
53
+
54
+ # Stop all running MCP servers
55
+ python -m crackerjack --stop-mcp-server
56
+
57
+ # Restart MCP server (stop and start again)
58
+ python -m crackerjack --restart-mcp-server
59
+
60
+ # Start dedicated WebSocket progress server (runs on localhost:8675)
61
+ python -m crackerjack --start-websocket-server
62
+
63
+ # Start multi-project progress monitor with Textual TUI
64
+ python -m crackerjack --monitor
65
+
66
+ # Start enhanced progress monitor with advanced MetricCard widgets (recommended)
67
+ python -m crackerjack --enhanced-monitor
68
+
69
+ # Start MCP server with custom WebSocket port
70
+ python -m crackerjack --start-mcp-server --websocket-port 8675
71
+
72
+ # Restart MCP server with custom WebSocket port
73
+ python -m crackerjack --restart-mcp-server --websocket-port 8675
74
+
75
+ # Start service watchdog to monitor and auto-restart MCP and WebSocket servers
76
+ python -m crackerjack --watchdog
77
+ ```
78
+
79
+ ### Terminal Recovery
80
+
81
+ **If your terminal gets stuck after quitting the monitor (no history, character input issues):**
82
+
83
+ ```bash
84
+ # Option 1: Use the recovery script
85
+ ./fix_terminal.sh
86
+
87
+ # Option 2: Manual recovery commands
88
+ stty sane; reset; exec $SHELL -l
89
+
90
+ # Option 3: Simple reset
91
+ reset
92
+ ```
93
+
94
+ **The enhanced terminal restoration automatically handles:**
95
+
96
+ - Mouse tracking disabling
97
+ - Alternate screen buffer exit
98
+ - Focus events restoration
99
+ - Bracketed paste mode cleanup
100
+ - Full terminal input/output restoration
101
+
102
+ ### AI Agent Auto-Fixing Process
103
+
104
+ **The AI agent provides intelligent, autonomous code fixing that goes far beyond basic tool auto-fixes:**
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
113
+
114
+ **2. AI Agent Auto-Fixing (Comprehensive Intelligence)**
115
+
116
+ - Analyzes ALL error types: hooks, tests, type checking, security, complexity
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
120
+
121
+ #### Standard AI Agent Iterative Process
122
+
123
+ **This is the recommended standard process for achieving code quality compliance:**
124
+
125
+ ```bash
126
+ # AI Agent mode with automatic fixing between iterations
127
+ python -m crackerjack --ai-agent -t
128
+
129
+ # The AI agent follows this optimal workflow order in each iteration:
130
+ # 1. Fast Hooks (formatting) → Retry once if any fail (fixes often cascade)
131
+ # 2. Full Test Suite → Collect ALL test failures (don't stop on first)
132
+ # 3. Comprehensive Hooks → Collect ALL quality issues (don't stop on first)
133
+ # 4. AI Analysis & Batch Fixing → Fix ALL collected issues in one pass
134
+ # 5. Repeat entire cycle until all checks pass (up to 10 iterations)
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
138
+ ```
139
+
140
+ **What the AI Agent Auto-Fixes:**
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
149
+
150
+ **Benefits of AI Agent Auto-Fixing:**
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
157
+
158
+ #### Sub-Agent Architecture
159
+
160
+ **Crackerjack uses specialized sub-agents for domain-specific code quality issues:**
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:**
259
+
260
+ ```python
261
+ # Automatic integration - all agents are registered and coordinated
262
+ # 9 total agents: DocumentationAgent, RefactoringAgent, PerformanceAgent, FormattingAgent,
263
+ # SecurityAgent, TestCreationAgent, TestSpecialistAgent, ImportOptimizationAgent, DRYAgent
264
+
265
+ # Agent confidence scoring examples:
266
+ # DocumentationAgent:
267
+ # - 0.8 confidence for documentation issues (primary expertise)
268
+ # RefactoringAgent:
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
279
+
280
+ **Crackerjack automatically manages temporary files created during execution:**
281
+
282
+ ```bash
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)
296
+
297
+ **Configuration**: Cleanup behavior can be controlled via CLI options or disabled entirely for debugging purposes.
298
+
299
+ ### Testing & Development
300
+
301
+ ```bash
302
+ # Run specific test
303
+ python -m pytest tests/test_specific.py::TestClass::test_method -v
304
+
305
+ # Run with coverage
306
+ python -m pytest --cov=crackerjack --cov-report=html
307
+
308
+ # Run tests with specific worker count
309
+ python -m crackerjack -t --test-workers 4
310
+
311
+ # Benchmark mode
312
+ python -m crackerjack --benchmark
313
+
314
+ # Progress monitoring for WebSocket MCP jobs
315
+ python -m crackerjack.mcp.progress_monitor <job_id> ws://localhost:8675
316
+
317
+ # Run with experimental hooks (pyrefly, ty)
318
+ python -m crackerjack --experimental-hooks
319
+
320
+ # Debug AI agent workflows with detailed logging
321
+ python -m crackerjack --ai-debug -t
322
+
323
+ # Enable verbose output for troubleshooting
324
+ python -m crackerjack --verbose -t
325
+
326
+ ```
327
+
328
+ ### Version Management
329
+
330
+ ```bash
331
+ # Bump version without publishing
332
+ python -m crackerjack --bump patch # 0.30.3 -> 0.30.4
333
+ python -m crackerjack --bump minor # 0.30.3 -> 0.31.0
334
+ python -m crackerjack --bump major # 0.30.3 -> 1.0.0
335
+
336
+ # Bump version without git tags
337
+ python -m crackerjack --bump patch --no-git-tags
338
+
339
+ # Skip version consistency verification
340
+ python -m crackerjack --bump patch --skip-version-check
341
+
342
+ # Publish to PyPI (requires UV_PUBLISH_TOKEN or keyring)
343
+ python -m crackerjack -p patch
344
+ ```
345
+
346
+ ### UVX Integration
347
+
348
+ **Crackerjack can be executed via uvx for isolated environments:**
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.
363
+
364
+ ## Architecture Overview
365
+
366
+ **Recently refactored from monolithic `crackerjack.py` to modular architecture:**
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)
378
+
379
+ ### Coordinator Layer (Workflow Management)
380
+
381
+ - **`core/session_coordinator.py`**: Session tracking, cleanup handlers, progress management
382
+ - **`core/phase_coordinator.py`**: Individual workflow phases (cleaning, config, hooks, testing, publishing, commit)
383
+ - **`core/async_workflow_orchestrator.py`**: Async workflow coordination with parallel execution
384
+ - **Async/await patterns**: Non-blocking workflow execution
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
388
+
389
+ ### Domain Managers (Business Logic)
390
+
391
+ - **`managers/hook_manager.py`**: Pre-commit hook execution with fast→comprehensive two-stage system
392
+ - **`managers/test_manager.py`**: Test execution, coverage analysis, environment validation
393
+ - **`managers/publish_manager.py`**: Version bumping, git tagging, PyPI publishing with authentication
394
+
395
+ ### Component Interaction Patterns
396
+
397
+ **Dependency Flow:**
398
+
399
+ ```
400
+ WorkflowOrchestrator → SessionCoordinator → PhaseCoordinator → Managers
401
+
402
+ Container (DI) → Protocols → Concrete Implementations
403
+ ```
404
+
405
+ **Critical Interfaces in `models/protocols.py`:**
406
+
407
+ - `HookManagerProtocol`, `TestManagerProtocol`, `PublishManagerProtocol`
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
505
+
506
+ ## Quality Process
507
+
508
+ ### Optimal AI Agent Workflow Order
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`
525
+
526
+ - **Package-focused by default**: Only run on `crackerjack/` package code, excludes `tests/`, `examples/`
527
+ - **Don't stop on first failure** - gather complete list of quality issues
528
+ - Use `--with-tests` flag (future) to include tests in comprehensive quality checks
529
+
530
+ 1. **AI Analysis & Batch Fixing**: Process ALL collected failures together
531
+
532
+ - More efficient than fixing one issue at a time
533
+ - AI can consider dependencies between fixes
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
542
+
543
+ ## Code Standards
544
+
545
+ ### Clean Code Principles (Applied)
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
554
+
555
+ ### Python 3.13+ Requirements
556
+
557
+ - Modern type hints with `|` unions instead of `Union`
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
562
+
563
+ ### Quality Rules (Enforced by Tools)
564
+
565
+ - **Cognitive complexity ≤15** per function (Complexipy) - KISS principle in action
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
574
+
575
+ ```python
576
+ # GOOD: Break complex methods into smaller helper methods
577
+ def complex_method(self, data: dict) -> bool:
578
+ if not self._validate_input(data):
579
+ return self._handle_invalid_input()
580
+
581
+ processed = self._process_data(data)
582
+ 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
+ ```
594
+
595
+ ### Error Prevention Patterns
596
+
597
+ ```python
598
+ # AVOID: Hardcoded temp paths (Security issue)
599
+ config_path = "/tmp/test-config.yaml" # BAD
600
+
601
+ # USE: Proper temp file handling
602
+ import tempfile
603
+
604
+ with tempfile.NamedTemporaryFile(suffix=".yaml") as f:
605
+ config_path = f.name
606
+
607
+ # AVOID: try/except pass (Refurb FURB107)
608
+ try:
609
+ risky_operation()
610
+ except Exception:
611
+ pass # BAD
612
+
613
+ # USE: contextlib.suppress
614
+ from contextlib import suppress
615
+
616
+ with suppress(Exception):
617
+ risky_operation()
618
+
619
+ # AVOID: Lists in membership tests (Refurb FURB109)
620
+ if status in ["error", "failed", "timeout"]: # BAD
621
+ handle_error()
622
+
623
+ # USE: Tuples for immutable membership tests
624
+ if status in ("error", "failed", "timeout"): # GOOD
625
+ handle_error()
626
+
627
+ # AVOID: Manual list building (FURB138)
628
+ issues = []
629
+ for item in data:
630
+ if condition(item):
631
+ issues.append(process(item))
632
+
633
+ # USE: List comprehensions
634
+ issues = [process(item) for item in data if condition(item)]
635
+
636
+ # AVOID: Dictionary get with if/else (FURB184)
637
+ emoji = AGENT_EMOJIS.get(agent_type)
638
+ if emoji:
639
+ return emoji
640
+ return "🤖"
641
+
642
+ # USE: Dictionary get with default
643
+ return AGENT_EMOJIS.get(agent_type, "🤖")
644
+
645
+ # AVOID: Lambda for simple attribute access (FURB118)
646
+ sorted_items = sorted(items, key=lambda x: x["priority"])
647
+
648
+ # USE: operator.itemgetter
649
+ from operator import itemgetter
650
+
651
+ sorted_items = sorted(items, key=itemgetter("priority"))
652
+ ```
653
+
654
+ ## Development Workflow
655
+
656
+ ### Making Changes
657
+
658
+ 1. **Run quality checks**: `python -m crackerjack`
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
663
+
664
+ ### Testing Individual Components
665
+
666
+ ```bash
667
+ # Test specific manager
668
+ python -m pytest tests/test_managers.py -v
669
+
670
+ # Test core orchestration
671
+ python -m pytest tests/test_coordinator_integration.py -v
672
+
673
+ # Test MCP integration
674
+ python -m pytest tests/test_mcp_server.py -v
675
+
676
+ # Run failing test in isolation
677
+ python -m pytest tests/test_crackerjack.py::TestClass::test_method -v -s
678
+ ```
679
+
680
+ ### Common Development Issues
681
+
682
+ - **Import errors**: Check `models/protocols.py` for interface definitions
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
686
+
687
+ ## MCP Server Integration
688
+
689
+ **WebSocket-based MCP server with real-time progress streaming:**
690
+
691
+ ### Server Features
692
+
693
+ - **🌐 Dual Protocol Support**: MCP protocol tools + WebSocket server on localhost:8675
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
698
+
699
+ ### MCP Server Usage
700
+
701
+ **For live progress monitoring with `/crackerjack:run`:**
702
+
703
+ ```bash
704
+ # Step 1: Start the dedicated WebSocket server (in a separate terminal)
705
+ python -m crackerjack --start-websocket-server
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
+ ```
712
+
713
+ **Alternative - Start MCP server with WebSocket support:**
714
+
715
+ ```bash
716
+ # Starts server on localhost:8675 with WebSocket + MCP protocol support
717
+ python -m crackerjack --start-mcp-server --websocket-port 8675
718
+ ```
719
+
720
+ **Progress monitoring:**
721
+
722
+ ```bash
723
+ # Monitor specific job by ID via WebSocket
724
+ python -m crackerjack.mcp.progress_monitor abc123-def456
725
+
726
+ # Monitor with custom WebSocket URL
727
+ python -m crackerjack.mcp.progress_monitor abc123-def456 ws://localhost:8675
728
+ ```
729
+
730
+ **Enhanced API integration:**
731
+
732
+ ```python
733
+ from crackerjack.mcp.progress_monitor import (
734
+ run_crackerjack_with_enhanced_progress,
735
+ )
736
+
737
+ # Uses WebSocket monitoring with Rich display
738
+ await run_crackerjack_with_enhanced_progress(client, "/crackerjack:run")
739
+ ```
740
+
741
+ ### Server Architecture
742
+
743
+ - **WebSocket Server**: Runs on localhost:8675 for progress streaming
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
748
+
749
+ ### Available MCP Tools
750
+
751
+ - `execute_crackerjack`: Start iterative auto-fixing workflow
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
759
+
760
+ ### Dependencies
761
+
762
+ - `fastmcp>=2.10.6`: MCP server framework
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
767
+
768
+ ### Slash Commands
769
+
770
+ **Location**: Available in `crackerjack.slash_commands` module for other packages to use
771
+
772
+ **`/crackerjack:run`**: Run full iterative auto-fixing with AI agent, tests, progress tracking, and verbose output
773
+
774
+ **`/crackerjack:status`**: Get comprehensive system status including MCP server health, WebSocket server status, active jobs, progress tracking, and resource usage
775
+
776
+ **`/crackerjack:init`**: Initialize or update project configuration with intelligent smart merge (preserves existing configurations, never overwrites project identity)
777
+
778
+ **Programmatic Access**:
779
+
780
+ ```python
781
+ from crackerjack.slash_commands import list_available_commands, get_slash_command_path
782
+
783
+ # List all available commands
784
+ commands = list_available_commands() # ['run', 'init']
785
+
786
+ # Get path to specific command
787
+ command_path = get_slash_command_path("run")
788
+ command_content = command_path.read_text()
789
+ ```
790
+
791
+ ## Configuration Details
792
+
793
+ **Tool Configuration** (from `pyproject.toml`):
794
+
795
+ - **Coverage requirement**: Ratchet system - never decrease, always improve toward 100%
796
+ - **Cognitive complexity**: ≤13 per function (complexipy)
797
+ - **Python version**: 3.13+ required
798
+ - **Test timeout**: 300 seconds per test
799
+ - **Type checking**: Strict mode with Pyright
800
+ - **Security scanning**: Bandit with custom exclusions
801
+
802
+ ## Service Watchdog
803
+
804
+ **Automatic monitoring and restart system for MCP and WebSocket servers.**
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.
809
+
810
+ ### Usage
811
+
812
+ ```bash
813
+ # Start watchdog to monitor both MCP and WebSocket servers
814
+ python -m crackerjack --watchdog
815
+ ```
816
+
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
+ ### Features
832
+
833
+ - **Real-time Monitoring**: Continuous process and health monitoring
834
+ - **Intelligent Restart**: Rate-limited restarts with exponential backoff
835
+ - **Rich Dashboard**: Live status display with service health, restart counts, and errors
836
+ - **Rate Limiting**: Maximum 10 restarts per 5-minute window to prevent restart loops
837
+ - **Health Checks**: HTTP endpoint monitoring for WebSocket server
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
881
+
882
+ **Modular Architecture Notes:**
883
+
884
+ - **Clean Architecture**: Direct use of modern class names (`InteractiveCLI`, `WorkflowManager`, `CodeCleaner`)
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
887
+
888
+ **Refactoring Achievements (January 2025):**
889
+
890
+ - **70% line reduction** in MCP server (3,116 lines → 921 lines across 6 focused modules)
891
+ - **35% line reduction** in WebSocket server (1,479 lines → 944 lines across 5 modules)
892
+ - **80% line reduction** in CLI entry point (601 lines → 122 lines via delegation)
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
906
+
907
+ ## Test Coverage Requirements
908
+
909
+ **CRITICAL**: The coverage ratchet system prevents regression and targets 100% coverage.
910
+
911
+ - **Never reduce coverage below current baseline** - coverage can only improve
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
916
+
917
+ ## Current Quality Status (January 2025)
918
+
919
+ **✅ COMPLETED:**
920
+
921
+ - All 31+ refurb violations fixed in agents directory
922
+ - Fast hooks: All 5 passing consistently
923
+ - Major complexity reductions (34→3, 33→2)
924
+ - Import errors and protocol compliance fixed
925
+
926
+ **🔄 IN PROGRESS:**
927
+
928
+ - Complexipy violations: Some functions still > 15 complexity
929
+ - Test coverage: Working toward 100% via incremental improvements
930
+
931
+ **⚠️ CRITICAL PRIORITIES:**
932
+
933
+ 1. **Fix existing test failures first** (before adding new tests)
934
+ 1. Add tests strategically to reach next milestone toward 100% coverage
935
+ 1. Complete remaining complexity reductions
936
+ 1. Final integration and release preparation
937
+
938
+ **Key User Directive**: Always prioritize fixing failures of existing tests over creating new tests, especially when coverage issues are being addressed.
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
978
+
979
+ ```python
980
+ # AVOID: Complex async tests that can hang
981
+ @pytest.mark.asyncio
982
+ async def test_batch_processing(self, batched_saver):
983
+ await batched_saver.start()
984
+ # Complex async workflow that might hang
985
+
986
+
987
+ # PREFER: Simple synchronous config tests
988
+ def test_batch_configuration(self, batched_saver):
989
+ assert batched_saver.max_batch_size == expected_size
990
+ assert not batched_saver._running
991
+ ```
992
+
993
+ ### Import Error Prevention
994
+
995
+ ```python
996
+ # WRONG: Importing concrete classes instead of protocols
997
+ from ..managers.test_manager import TestManager
998
+
999
+ # CORRECT: Use protocol interfaces for dependency injection
1000
+ from ..models.protocols import TestManagerProtocol
1001
+ ```
1002
+
1003
+ - DO NOT CREATE ANY NEW TESTS UNTIL CURRENTLY FAILING OR ERRORING TESTS HAVE EITHER BEEN FIXED OR REMOVED!
1004
+ - always be honest with your answers. do not embelish on progress.
1005
+ - always clean up after yourself