crackerjack 0.29.0__py3-none-any.whl → 0.31.4__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 (158) hide show
  1. crackerjack/CLAUDE.md +1005 -0
  2. crackerjack/RULES.md +380 -0
  3. crackerjack/__init__.py +42 -13
  4. crackerjack/__main__.py +225 -253
  5. crackerjack/agents/__init__.py +41 -0
  6. crackerjack/agents/architect_agent.py +281 -0
  7. crackerjack/agents/base.py +169 -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 +652 -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 +401 -0
  26. crackerjack/cli/utils.py +18 -0
  27. crackerjack/code_cleaner.py +670 -0
  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 +561 -0
  37. crackerjack/core/proactive_workflow.py +316 -0
  38. crackerjack/core/session_coordinator.py +289 -0
  39. crackerjack/core/workflow_orchestrator.py +640 -0
  40. crackerjack/dynamic_config.py +577 -0
  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 +411 -0
  58. crackerjack/managers/test_command_builder.py +151 -0
  59. crackerjack/managers/test_executor.py +435 -0
  60. crackerjack/managers/test_manager.py +258 -0
  61. crackerjack/managers/test_manager_backup.py +1124 -0
  62. crackerjack/managers/test_progress.py +144 -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 +615 -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 +370 -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 +141 -0
  88. crackerjack/mcp/tools/utility_tools.py +341 -0
  89. crackerjack/mcp/tools/workflow_executor.py +360 -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/execution_strategies.py +341 -0
  107. crackerjack/orchestration/test_progress_streamer.py +636 -0
  108. crackerjack/plugins/__init__.py +15 -0
  109. crackerjack/plugins/base.py +200 -0
  110. crackerjack/plugins/hooks.py +246 -0
  111. crackerjack/plugins/loader.py +335 -0
  112. crackerjack/plugins/managers.py +259 -0
  113. crackerjack/py313.py +8 -3
  114. crackerjack/services/__init__.py +22 -0
  115. crackerjack/services/cache.py +314 -0
  116. crackerjack/services/config.py +347 -0
  117. crackerjack/services/config_integrity.py +99 -0
  118. crackerjack/services/contextual_ai_assistant.py +516 -0
  119. crackerjack/services/coverage_ratchet.py +347 -0
  120. crackerjack/services/debug.py +736 -0
  121. crackerjack/services/dependency_monitor.py +617 -0
  122. crackerjack/services/enhanced_filesystem.py +439 -0
  123. crackerjack/services/file_hasher.py +151 -0
  124. crackerjack/services/filesystem.py +395 -0
  125. crackerjack/services/git.py +165 -0
  126. crackerjack/services/health_metrics.py +611 -0
  127. crackerjack/services/initialization.py +847 -0
  128. crackerjack/services/log_manager.py +286 -0
  129. crackerjack/services/logging.py +174 -0
  130. crackerjack/services/metrics.py +578 -0
  131. crackerjack/services/pattern_cache.py +362 -0
  132. crackerjack/services/pattern_detector.py +515 -0
  133. crackerjack/services/performance_benchmarks.py +653 -0
  134. crackerjack/services/security.py +163 -0
  135. crackerjack/services/server_manager.py +234 -0
  136. crackerjack/services/smart_scheduling.py +144 -0
  137. crackerjack/services/tool_version_service.py +61 -0
  138. crackerjack/services/unified_config.py +437 -0
  139. crackerjack/services/version_checker.py +248 -0
  140. crackerjack/slash_commands/__init__.py +14 -0
  141. crackerjack/slash_commands/init.md +122 -0
  142. crackerjack/slash_commands/run.md +163 -0
  143. crackerjack/slash_commands/status.md +127 -0
  144. crackerjack-0.31.4.dist-info/METADATA +742 -0
  145. crackerjack-0.31.4.dist-info/RECORD +148 -0
  146. crackerjack-0.31.4.dist-info/entry_points.txt +2 -0
  147. crackerjack/.gitignore +0 -34
  148. crackerjack/.libcst.codemod.yaml +0 -18
  149. crackerjack/.pdm.toml +0 -1
  150. crackerjack/.pre-commit-config-ai.yaml +0 -149
  151. crackerjack/.pre-commit-config-fast.yaml +0 -69
  152. crackerjack/.pre-commit-config.yaml +0 -114
  153. crackerjack/crackerjack.py +0 -4140
  154. crackerjack/pyproject.toml +0 -285
  155. crackerjack-0.29.0.dist-info/METADATA +0 -1289
  156. crackerjack-0.29.0.dist-info/RECORD +0 -17
  157. {crackerjack-0.29.0.dist-info → crackerjack-0.31.4.dist-info}/WHEEL +0 -0
  158. {crackerjack-0.29.0.dist-info → crackerjack-0.31.4.dist-info}/licenses/LICENSE +0 -0
@@ -1,1289 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: crackerjack
3
- Version: 0.29.0
4
- Summary: Crackerjack: code quality toolkit
5
- Project-URL: documentation, https://github.com/lesleslie/crackerjack
6
- Project-URL: homepage, https://github.com/lesleslie/crackerjack
7
- Project-URL: repository, https://github.com/lesleslie/crackerjack
8
- Author-email: lesleslie <les@wedgwoodwebworks.com>
9
- Maintainer-email: lesleslie <les@wedgwoodwebworks.com>
10
- License: BSD-3-CLAUSE
11
- License-File: LICENSE
12
- Keywords: bandit,black,creosote,mypy,pyright,pytest,refurb,ruff
13
- Classifier: Development Status :: 4 - Beta
14
- Classifier: Environment :: Console
15
- Classifier: License :: OSI Approved :: BSD License
16
- Classifier: Operating System :: POSIX
17
- Classifier: Programming Language :: Python
18
- Classifier: Programming Language :: Python :: 3 :: Only
19
- Classifier: Programming Language :: Python :: 3.13
20
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
- Classifier: Topic :: Software Development :: Quality Assurance
22
- Classifier: Topic :: Software Development :: Testing
23
- Classifier: Topic :: Utilities
24
- Classifier: Typing :: Typed
25
- Requires-Python: >=3.13
26
- Requires-Dist: aiofiles>=24.1
27
- Requires-Dist: autotyping>=24.9
28
- Requires-Dist: hatchling>=1.25
29
- Requires-Dist: keyring>=25.6
30
- Requires-Dist: pre-commit>=4.2
31
- Requires-Dist: pydantic>=2.11.7
32
- Requires-Dist: pyleak>=0.1.14
33
- Requires-Dist: pytest-asyncio>=1
34
- Requires-Dist: pytest-benchmark>=5.1
35
- Requires-Dist: pytest-cov>=6.2.1
36
- Requires-Dist: pytest-mock>=3.14.1
37
- Requires-Dist: pytest-timeout>=2.4
38
- Requires-Dist: pytest-xdist>=3.8
39
- Requires-Dist: pytest>=8.4.1
40
- Requires-Dist: pyyaml>=6.0.2
41
- Requires-Dist: rich>=14
42
- Requires-Dist: tomli-w>=1.2
43
- Requires-Dist: typer>=0.16
44
- Requires-Dist: uv>=0.7.20
45
- Description-Content-Type: text/markdown
46
-
47
- # Crackerjack: Elevate Your Python Development
48
-
49
- [![Code style: crackerjack](https://img.shields.io/badge/code%20style-crackerjack-000042)](https://github.com/lesleslie/crackerjack)
50
- [![Python: 3.13+](https://img.shields.io/badge/python-3.13%2B-green)](https://www.python.org/downloads/)
51
- [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
52
- [![uv](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json)](https://github.com/astral-sh/uv)
53
- [![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
54
- [![security: bandit](https://img.shields.io/badge/security-bandit-yellow.svg)](https://github.com/PyCQA/bandit)
55
- [![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)
56
-
57
- **Crackerjack** (`ˈkra-kər-ˌjak`): *a person or thing of marked excellence.*
58
-
59
- ## What is Crackerjack?
60
-
61
- Crackerjack is an opinionated Python project management tool that streamlines the entire development lifecycle. It combines best-in-class tools into a unified workflow, allowing you to focus on writing code rather than configuring tools.
62
-
63
- ### Why Choose Crackerjack?
64
-
65
- Crackerjack solves three critical challenges in Python development:
66
-
67
- 1. **Project Setup & Configuration**
68
-
69
- - **Challenge**: Setting up Python projects with best practices requires knowledge of numerous tools and configurations
70
- - **Solution**: Crackerjack automates project initialization with pre-configured templates and industry best practices
71
-
72
- 1. **Code Quality & Consistency**
73
-
74
- - **Challenge**: Maintaining consistent code quality across a project and team requires constant vigilance
75
- - **Solution**: Crackerjack enforces a unified style through integrated linting, formatting, and pre-commit hooks
76
-
77
- 1. **Streamlined Publishing**
78
-
79
- - **Challenge**: Publishing Python packages involves many manual, error-prone steps
80
- - **Solution**: Crackerjack automates the entire release process from testing to version bumping to publishing
81
-
82
- Crackerjack integrates powerful tools like Ruff, UV, pre-commit, pytest, and more into a cohesive system that ensures code quality, consistency, and reliability. It's designed for developers who value both productivity and excellence.
83
-
84
- ______________________________________________________________________
85
-
86
- ## Getting Started
87
-
88
- ### Quick Start
89
-
90
- If you're new to Crackerjack, follow these steps:
91
-
92
- 1. **Install Python 3.13:** Ensure you have Python 3.13 or higher installed.
93
-
94
- 1. **Install UV:**
95
-
96
- ```
97
- pipx install uv
98
- ```
99
-
100
- 1. **Install Crackerjack:**
101
-
102
- ```
103
- pip install crackerjack
104
- ```
105
-
106
- 1. **Initialize a New Project:**
107
- Navigate to your project's root directory and run:
108
-
109
- ```
110
- python -m crackerjack
111
- ```
112
-
113
- Or use the interactive Rich UI:
114
-
115
- ```
116
- python -m crackerjack -i
117
- ```
118
-
119
- ______________________________________________________________________
120
-
121
- ## The Crackerjack Philosophy
122
-
123
- Crackerjack is built on the following core principles:
124
-
125
- - **Code Clarity:** Code should be easy to read, understand, and maintain.
126
- - **Automation:** Tedious tasks should be automated, allowing developers to focus on solving problems.
127
- - **Consistency:** Code style, formatting, and project structure should be consistent across projects.
128
- - **Reliability:** Tests are essential, and code should be checked rigorously.
129
- - **Tool Integration:** Leverage powerful existing tools instead of reinventing the wheel.
130
- - **Static Typing:** Static typing is essential for all development.
131
-
132
- ## Key Features
133
-
134
- ### Project Management
135
-
136
- - **Effortless Project Setup:** Initializes new Python projects with a standard directory structure, `pyproject.toml`, and essential configuration files
137
- - **UV Integration:** Manages dependencies and virtual environments using [UV](https://github.com/astral-sh/uv) for lightning-fast package operations
138
- - **Dependency Management:** Automatically detects and manages project dependencies
139
-
140
- ### Code Quality
141
-
142
- - **Automated Code Cleaning:** Removes unnecessary docstrings, line comments, and trailing whitespace
143
- - **Consistent Code Formatting:** Enforces a unified style using [Ruff](https://github.com/astral-sh/ruff), the lightning-fast Python linter and formatter
144
- - **Comprehensive Pre-commit Hooks:** Installs and manages a robust suite of pre-commit hooks (see the "Pre-commit Hooks" section below)
145
- - **Interactive Checks:** Supports interactive pre-commit hooks (like `refurb`, `bandit`, and `pyright`) to fix issues in real-time
146
- - **Static Type Checking:** Enforces type safety with Pyright integration
147
-
148
- ### Testing & Deployment
149
-
150
- - **Built-in Testing:** Automatically runs tests using `pytest`
151
- - **Easy Version Bumping:** Provides commands to bump the project version (patch, minor, or major)
152
- - **Simplified Publishing:** Automates publishing to PyPI via UV
153
-
154
- ### Git Integration
155
-
156
- - **Intelligent Commit Messages:** Analyzes git changes and suggests descriptive commit messages based on file types and modifications
157
- - **Commit and Push:** Commits and pushes your changes with standardized commit messages
158
- - **Pull Request Creation:** Creates pull requests to upstream repositories on GitHub or GitLab
159
- - **Pre-commit Integration:** Ensures code quality before commits
160
-
161
- ### Developer Experience
162
-
163
- - **Command-Line Interface:** Simple, intuitive CLI with comprehensive options
164
- - **Interactive Rich UI:** Visual workflow with real-time task tracking, progress visualization, and interactive prompts
165
- - **Structured Error Handling:** Clear error messages with error codes, detailed explanations, and recovery suggestions
166
- - **Programmatic API:** Can be integrated into your own Python scripts and workflows
167
- - **AI Agent Integration:** Structured output format for integration with AI assistants, with complete style rules available in [RULES.md](RULES.md) for AI tool customization
168
- - **Celebratory Success Messages:** Trophy emoji (🏆) celebrates achieving crackerjack quality when all checks pass
169
- - **Verbose Mode:** Detailed output for debugging and understanding what's happening
170
- - **Python 3.13+ Features:** Leverages the latest Python language features including PEP 695 type parameter syntax, Self type annotations, and structural pattern matching
171
-
172
- ## Pre-commit Hooks & Performance Optimization
173
-
174
- Crackerjack provides dual-mode pre-commit hook configuration optimized for different development scenarios:
175
-
176
- ### ⚡ Fast Development Mode (Default)
177
-
178
- **Target Execution Time: \<5 seconds**
179
-
180
- Uses `.pre-commit-config-fast.yaml` for regular development work:
181
-
182
- - **Structure Validation**: Basic file structure checks
183
- - **UV Lock Updates**: Keeps dependency lock files current
184
- - **Security Checks**: Essential security scanning with detect-secrets
185
- - **Quick Formatting**: Fast formatting with codespell and ruff
186
- - **Markdown Formatting**: mdformat with ruff integration
187
-
188
- ```bash
189
- # Default fast mode (automatically selected)
190
- python -m crackerjack
191
-
192
- # Explicitly use fast mode
193
- python -m crackerjack --fast # Uses fast pre-commit configuration
194
- ```
195
-
196
- ### 🔍 Comprehensive Analysis Mode
197
-
198
- **Target Execution Time: \<30 seconds**
199
-
200
- Uses `.pre-commit-config.yaml` for thorough analysis before releases or important commits:
201
-
202
- - **All Fast Mode Checks**: Includes everything from fast mode
203
- - **Type Checking**: Complete static analysis with Pyright
204
- - **Code Modernization**: Advanced suggestions with Refurb
205
- - **Security Scanning**: Comprehensive vulnerability detection with Bandit
206
- - **Dead Code Detection**: Unused code identification with Vulture
207
- - **Dependency Analysis**: Unused dependency detection with Creosote
208
- - **Complexity Analysis**: Code complexity checking with Complexipy
209
- - **Auto Type Hints**: Automatic type annotation with Autotyping
210
-
211
- ```bash
212
- # Run comprehensive analysis
213
- python -m crackerjack --comprehensive
214
-
215
- # Use comprehensive mode for releases
216
- python -m crackerjack --comprehensive -a patch
217
- ```
218
-
219
- ### 📦 Pre-push Hooks (CI/CD Integration)
220
-
221
- For expensive operations that should run before pushing to remote repositories:
222
-
223
- ```bash
224
- # Install pre-push hooks for comprehensive checks
225
- pre-commit install --hook-type pre-push
226
-
227
- # Manual pre-push validation
228
- python -m crackerjack --comprehensive --test
229
- ```
230
-
231
- ### Performance Comparison
232
-
233
- | Mode | Execution Time | Use Case | Hooks Count |
234
- |------|---------------|----------|-------------|
235
- | **Fast** | \<5s | Regular development | 8 essential hooks |
236
- | **Comprehensive** | \<30s | Pre-release, important commits | 15+ thorough hooks |
237
- | **Pre-push** | Variable | CI/CD, remote push | All hooks + extended analysis |
238
-
239
- ### Hook Categories
240
-
241
- **Fast Mode Hooks:**
242
-
243
- 1. **uv-lock:** Ensures the `uv.lock` file is up to date
244
- 1. **Core pre-commit-hooks:** Essential hooks (trailing-whitespace, end-of-file-fixer)
245
- 1. **Ruff:** Fast linting and formatting
246
- 1. **Detect-secrets:** Security credential detection
247
- 1. **Codespell:** Spelling mistake correction
248
- 1. **mdformat:** Markdown formatting
249
-
250
- **Additional Comprehensive Mode Hooks:**
251
- 7\. **Vulture:** Dead code detection
252
- 8\. **Creosote:** Unused dependency detection
253
- 9\. **Complexipy:** Code complexity analysis
254
- 10\. **Autotyping:** Automatic type hint generation
255
- 11\. **Refurb:** Code modernization suggestions
256
- 12\. **Bandit:** Security vulnerability scanning
257
- 13\. **Pyright:** Static type checking
258
- 14\. **Extended Ruff:** Additional formatting passes
259
-
260
- ### Smart Hook Selection
261
-
262
- Crackerjack automatically selects the appropriate hook configuration based on:
263
-
264
- - **Operation Type**: Fast for regular development, comprehensive for releases
265
- - **User Preference**: Explicit `--fast` or `--comprehensive` flags
266
- - **CI/CD Context**: Pre-push hooks for remote operations
267
- - **Project Size**: Larger projects may benefit from fast mode during development
268
-
269
- ## The Crackerjack Style Guide
270
-
271
- Crackerjack projects adhere to these guidelines:
272
-
273
- - **Static Typing:** Use type hints consistently throughout your code.
274
- - **Modern Type Hints:** Use the pipe operator (`|`) for union types (e.g., `Path | None` instead of `Optional[Path]`).
275
- - **Explicit Naming:** Choose clear, descriptive names for classes, functions, variables, and other identifiers.
276
- - **Markdown for Documentation:** Use Markdown (`.md`) for all documentation, READMEs, etc.
277
- - **Pathlib:** Use `pathlib.Path` for handling file and directory paths instead of `os.path`.
278
- - **Consistent Imports:** Use `import typing as t` for type hinting and prefix all typing references with `t.`.
279
- - **Protocol-Based Design:** Use `t.Protocol` for interface definitions instead of abstract base classes.
280
- - **Constants and Config:** Do not use all-caps for constants or configuration settings.
281
- - **Path Parameters:** Functions that handle file operations should accept `pathlib.Path` objects as parameters.
282
- - **Dependency Management:** Use UV for dependency management, package building, and publishing.
283
- - **Testing:** Use pytest as your testing framework.
284
- - **Python Version:** Crackerjack projects target Python 3.13+ and use the latest language features.
285
- - **Clear Code:** Avoid overly complex code.
286
- - **Modular:** Functions should do one thing well.
287
-
288
- ## Testing Features
289
-
290
- Crackerjack provides advanced testing capabilities powered by pytest:
291
-
292
- ### Standard Testing
293
-
294
- - **Parallel Test Execution:** Tests run in parallel by default using pytest-xdist for faster execution
295
- - **Smart Parallelization:** Automatically adjusts the number of worker processes based on project size
296
- - **Timeout Protection:** Tests have dynamic timeouts based on project size to prevent hanging tests
297
- - **Coverage Reports:** Automatically generates test coverage reports with configurable thresholds
298
-
299
- ### Advanced Test Configuration
300
-
301
- Crackerjack offers fine-grained control over test execution:
302
-
303
- - **Worker Control:** Set the number of parallel workers with `--test-workers` (0 = auto-detect, 1 = disable parallelization)
304
- - **Timeout Control:** Customize test timeouts with `--test-timeout` (in seconds)
305
- - **Project Size Detection:** Automatically detects project size and adjusts timeout and parallelization settings
306
- - **Deadlock Prevention:** Uses advanced threading techniques to prevent deadlocks in test output processing
307
- - **Progress Tracking:** Shows periodic heartbeat messages for long-running tests
308
-
309
- Example test execution options:
310
-
311
- ```bash
312
- # Run tests with a single worker (no parallelization)
313
- python -m crackerjack -t --test-workers=1
314
-
315
- # Run tests with a specific number of workers (e.g., 4)
316
- python -m crackerjack -t --test-workers=4
317
-
318
- # Run tests with a custom timeout (5 minutes per test)
319
- python -m crackerjack -t --test-timeout=300
320
-
321
- # Combine options for maximum control
322
- python -m crackerjack -t --test-workers=2 --test-timeout=600
323
- ```
324
-
325
- ### Benchmark Testing & Performance Monitoring
326
-
327
- Crackerjack includes comprehensive benchmark testing capabilities designed for continuous performance monitoring and regression detection:
328
-
329
- #### 📊 Core Benchmark Features
330
-
331
- - **Performance Measurement:** Accurately measure execution time, memory usage, and function calls
332
- - **Regression Detection:** Automatic detection of performance degradation between code changes
333
- - **Statistical Analysis:** Statistical validation of performance differences with confidence intervals
334
- - **Historical Tracking:** Track performance trends across commits and releases
335
- - **CI/CD Integration:** Seamless integration with continuous integration pipelines
336
- - **AI Agent Output:** JSON format benchmark results for automated analysis
337
-
338
- #### 🚀 Benchmark Execution Modes
339
-
340
- **Basic Benchmarking:**
341
-
342
- ```bash
343
- # Run tests with performance measurement
344
- python -m crackerjack -t --benchmark
345
-
346
- # Combine with AI agent mode for structured output
347
- python -m crackerjack -t --benchmark --ai-agent
348
- ```
349
-
350
- **Regression Testing:**
351
-
352
- ```bash
353
- # Run benchmarks with regression detection (5% threshold)
354
- python -m crackerjack -t --benchmark-regression
355
-
356
- # Custom regression threshold (fail if >10% slower)
357
- python -m crackerjack -t --benchmark-regression --benchmark-regression-threshold=10.0
358
-
359
- # Strict regression testing for critical performance paths (2% threshold)
360
- python -m crackerjack -t --benchmark-regression --benchmark-regression-threshold=2.0
361
- ```
362
-
363
- #### 📈 Strategic Benchmark Scheduling
364
-
365
- **🚀 Critical Scenarios (Always Run Benchmarks):**
366
-
367
- - Before major releases
368
- - After significant algorithmic changes
369
- - When performance-critical code is modified
370
-
371
- **📊 Regular Monitoring (Weekly):**
372
-
373
- - Automated CI/CD pipeline execution
374
- - Performance drift detection
375
- - Long-term trend analysis
376
-
377
- **🎲 Random Sampling (10% of commits):**
378
-
379
- - Stochastic performance monitoring
380
- - Gradual performance regression detection
381
- - Statistical baseline maintenance
382
-
383
- #### ⚙️ Technical Implementation
384
-
385
- When benchmarks are executed, Crackerjack:
386
-
387
- 1. **Disables Parallel Execution**: Ensures accurate timing measurements (pytest-benchmark incompatible with pytest-xdist)
388
- 1. **Optimizes Configuration**: Configures pytest-benchmark with performance-optimized settings
389
- 1. **Baseline Comparison**: Compares results against previous runs for regression detection
390
- 1. **Statistical Validation**: Uses statistical methods to determine significant performance changes
391
- 1. **JSON Export**: Generates machine-readable results for automated analysis (with `--ai-agent`)
392
-
393
- #### 🎯 Benchmark Best Practices
394
-
395
- **Threshold Guidelines:**
396
-
397
- - **2-5% threshold**: For release candidates and critical performance paths
398
- - **5-10% threshold**: For regular development and monitoring
399
- - **10%+ threshold**: For experimental features and early development
400
-
401
- **Execution Strategy:**
402
-
403
- ```bash
404
- # Development workflow with benchmarks
405
- python -m crackerjack -t --benchmark --test-workers=1
406
-
407
- # Release validation with strict thresholds
408
- python -m crackerjack -t --benchmark-regression --benchmark-regression-threshold=2.0
409
-
410
- # CI/CD integration with structured output
411
- python -m crackerjack --ai-agent -t --benchmark-regression --benchmark-regression-threshold=5.0
412
- ```
413
-
414
- #### 📁 Benchmark Output Files
415
-
416
- When using `--ai-agent` mode, benchmark results are exported to:
417
-
418
- - **`benchmark.json`**: Detailed performance metrics and statistical analysis
419
- - **`test-results.xml`**: JUnit XML format with benchmark integration
420
- - **`ai-agent-summary.json`**: Summary including benchmark status and regression analysis
421
-
422
- This comprehensive approach ensures that performance regressions are caught early while maintaining development velocity.
423
-
424
- ## Installation
425
-
426
- 1. **Python:** Ensure you have Python 3.13 or higher installed.
427
-
428
- 1. **UV:** Install [UV](https://github.com/astral-sh/uv) using `pipx`:
429
-
430
- ```
431
- pipx install uv
432
- ```
433
-
434
- 1. **Crackerjack:** Install Crackerjack and initialize in your project root using:
435
-
436
- ```
437
- pip install crackerjack
438
- cd your_project_root
439
- python -m crackerjack
440
- ```
441
-
442
- Or with the interactive Rich UI:
443
-
444
- ```
445
- python -m crackerjack -i
446
- ```
447
-
448
- ## Usage
449
-
450
- ### Command Line
451
-
452
- Run Crackerjack from the root of your Python project using:
453
-
454
- ```
455
- python -m crackerjack
456
- ```
457
-
458
- ### Programmatic API
459
-
460
- You can also use Crackerjack programmatically in your Python code:
461
-
462
- ```python
463
- import typing as t
464
- from pathlib import Path
465
- from rich.console import Console
466
- from crackerjack import create_crackerjack_runner
467
-
468
-
469
- # Create a custom options object
470
- class MyOptions:
471
- def __init__(self):
472
- # Core options
473
- self.commit = False # Commit changes to Git
474
- self.interactive = True # Run pre-commit hooks interactively
475
- self.verbose = True # Enable verbose output
476
-
477
- # Configuration options
478
- self.no_config_updates = False # Skip updating config files
479
- self.update_precommit = False # Update pre-commit hooks
480
-
481
- # Process options
482
- self.clean = True # Clean code (remove docstrings, comments, etc.)
483
- self.test = True # Run tests using pytest
484
- self.skip_hooks = False # Skip running pre-commit hooks
485
-
486
- # Test execution options
487
- self.test_workers = 2 # Number of parallel workers (0 = auto-detect, 1 = disable parallelization)
488
- self.test_timeout = 120 # Timeout in seconds for individual tests (0 = use default based on project size)
489
-
490
- # Benchmark options
491
- self.benchmark = False # Run tests in benchmark mode
492
- self.benchmark_regression = (
493
- False # Fail tests if benchmarks regress beyond threshold
494
- )
495
- self.benchmark_regression_threshold = (
496
- 5.0 # Threshold percentage for benchmark regression
497
- )
498
-
499
- # Version and publishing options
500
- self.publish = None # Publish to PyPI (patch, minor, major)
501
- self.bump = "patch" # Bump version (patch, minor, major)
502
- self.all = None # Run with -x -t -p <version> -c
503
-
504
- # Git options
505
- self.create_pr = False # Create a pull request
506
-
507
- # Integration options
508
- self.ai_agent = False # Enable AI agent structured output
509
-
510
-
511
- # Create a Crackerjack runner with custom settings
512
- runner = create_crackerjack_runner(
513
- console=Console(force_terminal=True), # Rich console for pretty output
514
- pkg_path=Path.cwd(), # Path to your project
515
- python_version="3.13", # Target Python version
516
- dry_run=False, # Set to True to simulate without changes
517
- )
518
-
519
- # Run Crackerjack with your options
520
- runner.process(MyOptions())
521
- ```
522
-
523
- ## Intelligent Commit Messages
524
-
525
- Crackerjack includes a smart commit message generation system that analyzes your git changes and suggests descriptive commit messages based on the files modified and the type of changes made.
526
-
527
- ### How It Works
528
-
529
- When you use the `-c` (commit) flag, Crackerjack automatically:
530
-
531
- 1. **Analyzes Changes**: Scans `git diff` to understand what files were added, modified, deleted, or renamed
532
- 1. **Categorizes Files**: Groups changes by type (documentation, tests, core functionality, configuration, dependencies)
533
- 1. **Suggests Message**: Generates a descriptive commit message with appropriate action verbs and categorization
534
- 1. **Interactive Choice**: Offers options to use the suggestion, edit it, or write a custom message
535
-
536
- ### Message Format
537
-
538
- Generated commit messages follow this structure:
539
-
540
- ```
541
- [Action] [primary changes] and [secondary changes]
542
-
543
- - Added N file(s)
544
- * path/to/new/file.py
545
- * path/to/another/file.py
546
- - Modified N file(s)
547
- * path/to/changed/file.py
548
- - Deleted N file(s)
549
- - Renamed N file(s)
550
- ```
551
-
552
- ### Examples
553
-
554
- **Documentation Updates:**
555
-
556
- ```
557
- Update documentation
558
-
559
- - Modified 3 file(s)
560
- * README.md
561
- * CLAUDE.md
562
- * docs/guide.md
563
- ```
564
-
565
- **New Feature Addition:**
566
-
567
- ```
568
- Add core functionality and tests
569
-
570
- - Added 2 file(s)
571
- * src/new_feature.py
572
- * tests/test_feature.py
573
- - Modified 1 file(s)
574
- * README.md
575
- ```
576
-
577
- **Configuration Changes:**
578
-
579
- ```
580
- Update configuration
581
-
582
- - Modified 2 file(s)
583
- * pyproject.toml
584
- * .pre-commit-config.yaml
585
- ```
586
-
587
- ### Usage Options
588
-
589
- When committing, you'll see:
590
-
591
- ```bash
592
- 🔍 Analyzing changes...
593
-
594
- README.md | 10 ++++
595
- tests/test_new.py | 50 ++++
596
- 2 files changed, 60 insertions(+)
597
-
598
- 📋 Suggested commit message:
599
- Update documentation and tests
600
-
601
- - Modified 1 file(s)
602
- * README.md
603
- - Added 1 file(s)
604
- * tests/test_new.py
605
-
606
- Use suggested message? [Y/n/e to edit]:
607
- ```
608
-
609
- **Options:**
610
-
611
- - **Y** or **Enter**: Use the suggested message as-is
612
- - **n**: Enter a completely custom commit message
613
- - **e**: Edit the suggested message in your default editor (`$EDITOR`)
614
-
615
- ### Smart Categorization
616
-
617
- The system intelligently categorizes files:
618
-
619
- - **Documentation**: `README.md`, `CLAUDE.md`, `docs/`, `.md` files
620
- - **Tests**: `test_`, `tests/`, `conftest.py`
621
- - **Configuration**: `pyproject.toml`, `.yaml`, `.yml`, `.json`, `.gitignore`
622
- - **CI/CD**: `.github/`, `ci/`, `.pre-commit`
623
- - **Dependencies**: `requirements`, `pyproject.toml`, `uv.lock`
624
- - **Core**: All other Python files and application code
625
-
626
- This intelligent commit message system helps maintain consistent, descriptive commit history while saving time during development workflows.
627
-
628
- ### Command-Line Options
629
-
630
- #### Core Workflow Options
631
-
632
- - `-c`, `--commit`: Commit changes to Git
633
- - `-i`, `--interactive`: Launch the interactive Rich UI with visual progress tracking
634
- - `-v`, `--verbose`: Enable detailed verbose output for debugging
635
- - `-a`, `--all <patch|minor|major>`: Run complete workflow: clean, test, publish, commit
636
-
637
- #### Configuration & Setup
638
-
639
- - `-n`, `--no-config-updates`: Skip updating configuration files (e.g., `pyproject.toml`)
640
- - `-u`, `--update-precommit`: Update pre-commit hooks to the latest versions
641
- - `--update-docs`: Create CLAUDE.md and RULES.md templates (only if they don't exist)
642
- - `--force-update-docs`: Force update CLAUDE.md and RULES.md even if they exist
643
-
644
- #### Code Quality & Testing
645
-
646
- - `-x`, `--clean`: Clean code by removing docstrings, line comments, and extra whitespace
647
- - `-t`, `--test`: Run tests using pytest with intelligent parallelization
648
- - `-s`, `--skip-hooks`: Skip running pre-commit hooks (useful with `-t`)
649
- - `--comprehensive`: Use comprehensive pre-commit analysis mode (\<30s, thorough)
650
-
651
- #### Test Execution Control
652
-
653
- - `--test-workers <N>`: Set parallel workers (0=auto-detect, 1=disable, N=specific count)
654
- - `--test-timeout <seconds>`: Set timeout per test (0=auto-detect based on project size)
655
-
656
- #### Performance & Benchmarking
657
-
658
- - `--benchmark`: Run tests in benchmark mode (disables parallel execution)
659
- - `--benchmark-regression`: Fail tests if benchmarks regress beyond threshold
660
- - `--benchmark-regression-threshold <percentage>`: Set regression threshold (default: 5.0%)
661
-
662
- #### Version Management & Publishing
663
-
664
- - `-p`, `--publish <patch|minor|major>`: Bump version and publish to PyPI with enhanced authentication
665
- - `-b`, `--bump <patch|minor|major>`: Bump version without publishing
666
-
667
- #### Git Integration
668
-
669
- - `-r`, `--pr`: Create a pull request to the upstream repository
670
-
671
- #### Session Management
672
-
673
- - `--track-progress`: Enable session progress tracking with automatic recovery
674
- - `--progress-file <path>`: Custom path for progress file (default: SESSION-PROGRESS-{timestamp}.md)
675
- - `--resume-from <file>`: Resume session from existing progress file
676
-
677
- #### AI & Integration
678
-
679
- - `--ai-agent`: Enable AI agent mode with structured JSON output
680
- - `--help`: Display comprehensive help information
681
-
682
- #### Example Flag Combinations
683
-
684
- ```bash
685
- # Complete development workflow with session tracking
686
- python -m crackerjack --track-progress -a patch
687
-
688
- # Fast development cycle
689
- python -m crackerjack -x -t -c
690
-
691
- # Comprehensive pre-release validation
692
- python -m crackerjack --comprehensive --benchmark-regression -p minor
693
-
694
- # AI-optimized workflow with progress tracking
695
- python -m crackerjack --ai-agent --track-progress -t --benchmark
696
-
697
- # Interactive mode with comprehensive analysis
698
- python -m crackerjack -i --comprehensive
699
- ```
700
-
701
- ### Example Workflows
702
-
703
- #### Development Workflows
704
-
705
- - **Quick Check** - Run basic checks on your code:
706
-
707
- ```bash
708
- python -m crackerjack
709
- ```
710
-
711
- - **Full Development Cycle** - Clean, test, bump version, publish, and commit:
712
-
713
- ```bash
714
- python -m crackerjack -a minor # All-in-one command
715
-
716
- # Equivalent to:
717
- python -m crackerjack -x -t -p minor -c
718
- ```
719
-
720
- - **Development with Tests** - Clean code, run checks, run tests, then commit:
721
-
722
- ```bash
723
- python -m crackerjack -c -x -t
724
- ```
725
-
726
- - **Fast Testing** - Run tests without running pre-commit hooks:
727
-
728
- ```bash
729
- python -m crackerjack -t -s
730
- ```
731
-
732
- #### Test Execution Options
733
-
734
- - **Single-Process Testing** - Run tests sequentially (no parallelization):
735
-
736
- ```bash
737
- python -m crackerjack -t --test-workers=1
738
- ```
739
-
740
- - **Customized Parallel Testing** - Run tests with a specific number of workers:
741
-
742
- ```bash
743
- python -m crackerjack -t --test-workers=4
744
- ```
745
-
746
- - **Long-Running Tests** - Increase test timeout for complex tests:
747
-
748
- ```bash
749
- python -m crackerjack -t --test-timeout=600
750
- ```
751
-
752
- - **Optimized for Large Projects** - Reduce workers and increase timeout for large codebases:
753
-
754
- ```bash
755
- python -m crackerjack -t --test-workers=2 --test-timeout=300
756
- ```
757
-
758
- #### Version Management & PyPI Publishing
759
-
760
- Crackerjack provides comprehensive PyPI publishing with enhanced authentication and validation.
761
-
762
- **🔐 PyPI Authentication Setup**
763
-
764
- Crackerjack automatically validates your authentication setup before publishing and provides helpful error messages. Choose one of these authentication methods:
765
-
766
- **Method 1: Environment Variable (Recommended)**
767
-
768
- ```bash
769
- # Set PyPI token as environment variable
770
- export UV_PUBLISH_TOKEN=pypi-your-token-here
771
-
772
- # Publish with automatic token authentication
773
- python -m crackerjack -p patch
774
- ```
775
-
776
- **Method 2: Keyring Integration**
777
-
778
- ```bash
779
- # Install keyring globally or in current environment
780
- uv tool install keyring
781
-
782
- # Store PyPI token in keyring (you'll be prompted for the token)
783
- keyring set https://upload.pypi.org/legacy/ __token__
784
-
785
- # Ensure keyring provider is configured in pyproject.toml
786
- [tool.uv]
787
- keyring-provider = "subprocess"
788
-
789
- # Publish with keyring authentication
790
- python -m crackerjack -p patch
791
- ```
792
-
793
- **Method 3: Environment Variable for Keyring Provider**
794
-
795
- ```bash
796
- # Set keyring provider via environment
797
- export UV_KEYRING_PROVIDER=subprocess
798
-
799
- # Publish (will use keyring for authentication)
800
- python -m crackerjack -p patch
801
- ```
802
-
803
- **Authentication Validation**
804
-
805
- Crackerjack automatically validates your authentication setup before publishing:
806
-
807
- - ✅ **Token Found**: When `UV_PUBLISH_TOKEN` is set
808
- - ✅ **Keyring Ready**: When keyring is configured and token is stored
809
- - ⚠️ **Setup Needed**: When authentication needs configuration
810
-
811
- If publishing fails due to authentication issues, crackerjack displays helpful setup instructions.
812
-
813
- **PyPI Token Best Practices**
814
-
815
- 1. **Generate Project-Specific Tokens**: Create separate PyPI tokens for each project
816
- 1. **Use Scoped Tokens**: Limit token scope to the specific package you're publishing
817
- 1. **Secure Storage**: Use environment variables or keyring - never hardcode tokens
818
- 1. **Token Format**: PyPI tokens start with `pypi-` (e.g., `pypi-AgEIcHlwaS5vcmcCJGZm...`)
819
-
820
- **Troubleshooting Authentication**
821
-
822
- If you encounter authentication issues:
823
-
824
- 1. **Check Token Format**: Ensure your token starts with `pypi-`
825
- 1. **Verify Environment Variable**: `echo $UV_PUBLISH_TOKEN` should show your token
826
- 1. **Test Keyring**: `keyring get https://upload.pypi.org/legacy/ __token__` should return your token
827
- 1. **Check Configuration**: Ensure `keyring-provider = "subprocess"` in pyproject.toml
828
- 1. **Install Keyring**: `uv tool install keyring` if using keyring authentication
829
-
830
- **Version Management Commands**
831
-
832
- - **Bump and Publish** - Bump version and publish to PyPI:
833
-
834
- ```bash
835
- python -m crackerjack -p patch # For patch version
836
- python -m crackerjack -p minor # For minor version
837
- python -m crackerjack -p major # For major version
838
- ```
839
-
840
- - **Version Bump Only** - Bump version without publishing:
841
-
842
- ```bash
843
- python -m crackerjack -b major
844
- ```
845
-
846
- #### Documentation Template Management
847
-
848
- Crackerjack can automatically propagate its quality standards to other Python projects by creating or updating their CLAUDE.md and RULES.md files. This ensures consistent AI code generation across all projects.
849
-
850
- **📄 Template Propagation Commands**
851
-
852
- ```bash
853
- # Update CLAUDE.md and RULES.md with latest quality standards (only if they don't exist)
854
- python -m crackerjack --update-docs
855
-
856
- # Force update CLAUDE.md and RULES.md even if they already exist
857
- python -m crackerjack --force-update-docs
858
- ```
859
-
860
- **When to Use Documentation Templates**
861
-
862
- - **New Projects**: Use `--update-docs` to create initial documentation templates
863
- - **Quality Standard Updates**: Use `--force-update-docs` weekly to keep standards current
864
- - **AI Integration**: Ensures Claude Code generates compliant code on first pass across all projects
865
- - **Team Synchronization**: Keeps all team projects using the same quality standards
866
-
867
- **How Template Management Works**
868
-
869
- - **Quality Standards**: Copies the latest Refurb, Pyright, Complexipy, and Bandit standards from Crackerjack
870
- - **Project Customization**: Customizes project-specific sections (project name, overview)
871
- - **Standard Preservation**: Preserves the core quality standards and AI generation guidelines
872
- - **Git Integration**: Automatically adds files to git for easy committing
873
-
874
- This feature is particularly valuable for teams maintaining multiple Python projects, ensuring that AI assistants generate consistent, high-quality code across all repositories.
875
-
876
- #### Configuration Management
877
-
878
- - **Skip Config Updates** - Run checks without updating configuration files:
879
-
880
- ```bash
881
- python -m crackerjack -n
882
- ```
883
-
884
- - **Update Hooks** - Update pre-commit hooks to latest versions:
885
-
886
- ```bash
887
- python -m crackerjack -u
888
- ```
889
-
890
- #### Git Operations
891
-
892
- - **Commit Changes** - Run checks and commit changes:
893
-
894
- ```bash
895
- python -m crackerjack -c
896
- ```
897
-
898
- - **Create PR** - Create a pull request to the upstream repository:
899
-
900
- ```bash
901
- python -m crackerjack -r
902
- ```
903
-
904
- #### Other Operations
905
-
906
- - **Interactive Mode** - Run pre-commit hooks interactively:
907
-
908
- ```bash
909
- python -m crackerjack -i
910
- ```
911
-
912
- - **Rich Interactive Mode** - Run with the interactive Rich UI:
913
-
914
- ```bash
915
- python -m crackerjack -i
916
- ```
917
-
918
- - **AI Integration** - Run with structured output for AI tools:
919
-
920
- ```bash
921
- python -m crackerjack --ai-agent --test
922
- ```
923
-
924
- - **Help** - Display command help:
925
-
926
- ```bash
927
- python -m crackerjack --help
928
- ```
929
-
930
- ## AI Agent Integration
931
-
932
- Crackerjack includes special features for integration with AI agents like Claude, ChatGPT, and other LLM-based assistants:
933
-
934
- - **Structured JSON Output:** When run with `--ai-agent`, Crackerjack outputs results in JSON format that's easy for AI agents to parse
935
- - **Clear Status Indicators:** Provides clear status indicators (running, success, failed, complete) to track progress
936
- - **Action Tracking:** Includes a list of actions performed to help AI agents understand what happened
937
-
938
- ### Example AI Agent Usage
939
-
940
- ```bash
941
- python -m crackerjack --ai-agent --test
942
- ```
943
-
944
- For detailed information about using Crackerjack with AI agents, including the structured output format and programmatic usage, see [README-AI-AGENT.md](README-AI-AGENT.md).
945
-
946
- ## Session Progress Tracking
947
-
948
- Crackerjack includes robust session progress tracking to maintain continuity during long-running development sessions and enable seamless collaboration with AI assistants.
949
-
950
- ### Key Features
951
-
952
- - **Automatic Progress Logging:** Tracks each step of the crackerjack workflow with detailed timestamps and status information
953
- - **Markdown Output:** Generates human-readable progress files with comprehensive task status and file change tracking
954
- - **Session Recovery:** Automatically detects and resumes interrupted sessions from where they left off
955
- - **Task Status Tracking:** Monitors pending, in-progress, completed, failed, and skipped tasks with detailed context
956
- - **File Change Tracking:** Records which files were modified during each task for easy debugging and rollback
957
- - **Error Recovery:** Provides detailed error information with recovery suggestions and continuation instructions
958
- - **AI Assistant Integration:** Optimized for AI workflows with structured progress information and session continuity
959
-
960
- ### Usage Examples
961
-
962
- **Enable automatic session tracking:**
963
-
964
- ```bash
965
- # Basic session tracking with automatic detection
966
- python -m crackerjack --track-progress -x -t -c
967
-
968
- # Session tracking with custom progress file
969
- python -m crackerjack --track-progress --progress-file my-session.md -a patch
970
-
971
- # Resume from interrupted session (automatic detection)
972
- python -m crackerjack --track-progress -a patch
973
- # 📋 Found incomplete session: SESSION-PROGRESS-20240716-143052.md
974
- # ❓ Resume this session? [y/N]: y
975
-
976
- # Manual session resumption
977
- python -m crackerjack --resume-from SESSION-PROGRESS-20240716-143052.md
978
-
979
- # Combine with AI agent mode for maximum visibility
980
- python -m crackerjack --track-progress --ai-agent -x -t -c
981
- ```
982
-
983
- ### Automatic Session Detection
984
-
985
- **🚀 Smart Recovery:** Crackerjack automatically detects interrupted sessions and offers to resume them! When you use `--track-progress`, crackerjack will:
986
-
987
- 1. **Scan for incomplete sessions** in the current directory (last 24 hours)
988
- 1. **Analyze session status** to determine if resumption is possible
989
- 1. **Prompt for user confirmation** with detailed session information
990
- 1. **Automatically resume** from the most recent incomplete task
991
-
992
- ### Progress File Structure
993
-
994
- Progress files are generated in markdown format with comprehensive information:
995
-
996
- ````markdown
997
- # Crackerjack Session Progress: abc123def
998
-
999
- **Session ID**: abc123def
1000
- **Started**: 2024-07-16 14:30:52
1001
- **Status**: In Progress
1002
- **Progress**: 3/8 tasks completed
1003
-
1004
- ## Task Progress Overview
1005
- | Task | Status | Duration | Details |
1006
- |------|--------|----------|---------|
1007
- | Setup | ✅ completed | 0.15s | Project structure initialized |
1008
- | Clean | ⏳ in_progress | - | Removing docstrings and comments |
1009
- | Tests | ⏸️ pending | - | - |
1010
-
1011
- ## Detailed Task Log
1012
- ### ✅ Setup - COMPLETED
1013
- - **Started**: 2024-07-16 14:30:52
1014
- - **Completed**: 2024-07-16 14:30:52
1015
- - **Duration**: 0.15s
1016
- - **Files Changed**: None
1017
- - **Details**: Project structure initialized
1018
-
1019
- ## Files Modified This Session
1020
- - src/main.py
1021
- - tests/test_main.py
1022
-
1023
- ## Session Recovery Information
1024
- If this session was interrupted, you can resume from where you left off:
1025
- ```bash
1026
- python -m crackerjack --resume-from SESSION-PROGRESS-20240716-143052.md
1027
- ````
1028
-
1029
- ### Benefits for Development Workflows
1030
-
1031
- - **Long-running Sessions:** Perfect for complex development workflows that may be interrupted
1032
- - **Team Collaboration:** Share session files with team members to show exactly what was done
1033
- - **Debugging Support:** Detailed logs help diagnose issues and understand workflow execution
1034
- - **AI Assistant Continuity:** AI assistants can read progress files to understand current project state
1035
- - **Audit Trail:** Complete record of all changes and operations performed during development
1036
-
1037
- ### Integration with Other Features
1038
-
1039
- Session progress tracking works seamlessly with:
1040
-
1041
- - **AI Agent Mode:** Structured output files reference progress tracking for enhanced AI workflows
1042
- - **Interactive Mode:** Progress is displayed in the Rich UI with real-time updates
1043
- - **Benchmark Mode:** Performance metrics are included in progress files for analysis
1044
- - **Version Bumping:** Version changes are tracked in session history for rollback support
1045
-
1046
- ## Interactive Rich UI
1047
-
1048
- Crackerjack now offers an enhanced interactive experience through its Rich UI:
1049
-
1050
- - **Visual Workflow:** See a visual representation of the entire task workflow with dependencies
1051
- - **Real-time Progress:** Track task progress with interactive progress bars and status indicators
1052
- - **Task Management:** Confirm tasks before execution and view detailed status information
1053
- - **Error Visualization:** Errors are presented in a structured, easy-to-understand format with recovery suggestions
1054
- - **File Selection:** Interactive file browser for operations that require selecting files
1055
-
1056
- To use the Rich UI, run Crackerjack with the `-i` flag:
1057
-
1058
- ```bash
1059
- python -m crackerjack -i
1060
- ```
1061
-
1062
- This launches an interactive terminal interface where you can:
1063
-
1064
- 1. View all available tasks and their dependencies
1065
- 1. Confirm each task before execution
1066
- 1. Get detailed status information for running tasks
1067
- 1. See a summary of completed, failed, and skipped tasks
1068
- 1. Visualize error details with recovery suggestions
1069
-
1070
- ## Structured Error Handling
1071
-
1072
- Crackerjack implements a comprehensive error handling system that provides:
1073
-
1074
- - **Error Categories:** Errors are categorized by type (configuration, execution, testing, etc.)
1075
- - **Error Codes:** Each error has a unique numeric code for easy reference
1076
- - **Detailed Messages:** Clear, descriptive messages explain what went wrong
1077
- - **Recovery Suggestions:** Where possible, errors include recovery suggestions to help resolve issues
1078
- - **Rich Formatting:** Errors are presented with clear visual formatting (when using Rich UI or verbose mode)
1079
-
1080
- Error types include:
1081
-
1082
- - Configuration errors (1000-1999)
1083
- - Execution errors (2000-2999)
1084
- - Test errors (3000-3999)
1085
- - Publishing errors (4000-4999)
1086
- - Git errors (5000-5999)
1087
- - File operation errors (6000-6999)
1088
- - Code cleaning errors (7000-7999)
1089
- - Generic errors (9000-9999)
1090
-
1091
- Use the `-v` or `--verbose` flag to see more detailed error information:
1092
-
1093
- ```bash
1094
- python -m crackerjack -v
1095
- ```
1096
-
1097
- For the most comprehensive error details with visual formatting, combine verbose mode with the Rich UI:
1098
-
1099
- ```bash
1100
- python -m crackerjack -i -v
1101
- ```
1102
-
1103
- ## Performance Optimization
1104
-
1105
- Crackerjack is optimized for performance across different project sizes and development scenarios:
1106
-
1107
- ### ⚡ Development Speed Optimization
1108
-
1109
- **Fast Mode Execution:**
1110
-
1111
- - **Target Time**: \<5 seconds for most operations
1112
- - **Smart Hook Selection**: Essential hooks only during development
1113
- - **Parallel Processing**: Intelligent worker allocation based on system resources
1114
- - **Incremental Updates**: Only processes changed files when possible
1115
-
1116
- **Adaptive Configuration:**
1117
-
1118
- ```bash
1119
- # Automatic optimization based on project size
1120
- python -m crackerjack # Auto-detects and optimizes
1121
-
1122
- # Force fast mode for development
1123
- python -m crackerjack --fast
1124
-
1125
- # Override for large projects
1126
- python -m crackerjack --test-workers=2 --test-timeout=300
1127
- ```
1128
-
1129
- ### 🔍 Quality vs Speed Balance
1130
-
1131
- | Operation | Fast Mode (\<5s) | Comprehensive Mode (\<30s) | Use Case |
1132
- |-----------|----------------|---------------------------|----------|
1133
- | **Pre-commit** | Essential hooks | All hooks + analysis | Development vs Release |
1134
- | **Testing** | Parallel execution | Full suite + benchmarks | Quick check vs Validation |
1135
- | **Code Cleaning** | Basic formatting | Deep analysis + refactoring | Daily work vs Refactoring |
1136
-
1137
- ### 📊 Project Size Adaptation
1138
-
1139
- **Small Projects (\<1000 lines):**
1140
-
1141
- - Default: Maximum parallelization
1142
- - Fast hooks with minimal overhead
1143
- - Quick test execution
1144
-
1145
- **Medium Projects (1000-10000 lines):**
1146
-
1147
- - Balanced worker allocation
1148
- - Selective comprehensive checks
1149
- - Optimized timeout settings
1150
-
1151
- **Large Projects (>10000 lines):**
1152
-
1153
- - Conservative parallelization
1154
- - Extended timeouts
1155
- - Strategic hook selection
1156
- - Session progress tracking recommended
1157
-
1158
- ### 🚀 CI/CD Optimization
1159
-
1160
- **Pre-push Hooks:**
1161
-
1162
- ```bash
1163
- # Install optimized pre-push hooks
1164
- pre-commit install --hook-type pre-push
1165
-
1166
- # Comprehensive validation before push
1167
- python -m crackerjack --comprehensive --ai-agent -t
1168
- ```
1169
-
1170
- **Performance Monitoring:**
1171
-
1172
- - Benchmark regression detection
1173
- - Statistical performance analysis
1174
- - Automated performance alerts
1175
- - Long-term trend tracking
1176
-
1177
- This multi-layered optimization approach ensures that Crackerjack remains fast during development while providing thorough analysis when needed.
1178
-
1179
- ## Python 3.13+ Features
1180
-
1181
- Crackerjack is designed to leverage the latest Python 3.13+ language features:
1182
-
1183
- - **Type Parameter Syntax (PEP 695):** Uses the new, more concise syntax for generic type parameters
1184
- - **Self Type:** Leverages the `Self` type for better method chaining and builder patterns
1185
- - **Structural Pattern Matching:** Uses pattern matching for cleaner code, especially in configuration and command processing
1186
- - **Enhanced Type Hints:** More precise type hints with union types using the pipe operator
1187
- - **Modern Dictionary Patterns:** Leverages structural pattern matching with dictionaries for cleaner data handling
1188
-
1189
- These modern Python features contribute to:
1190
-
1191
- - More readable and maintainable code
1192
- - Better static type checking with tools like pyright
1193
- - Cleaner, more concise implementations
1194
- - Enhanced error handling and pattern recognition
1195
-
1196
- Crackerjack provides examples of these features in action, serving as a reference for modern Python development practices.
1197
-
1198
- ## Contributing
1199
-
1200
- Crackerjack is an evolving project. Contributions are welcome! Please open a pull request or issue.
1201
-
1202
- To contribute:
1203
-
1204
- 1. Add Crackerjack as a development dependency to your project:
1205
-
1206
- ```
1207
- uv add --dev crackerjack
1208
- ```
1209
-
1210
- 2. Run checks and tests before submitting:
1211
-
1212
- ```
1213
- python -m crackerjack -x -t
1214
- ```
1215
-
1216
- This ensures your code meets all quality standards before submission.
1217
-
1218
- ## License
1219
-
1220
- This project is licensed under the terms of the BSD 3-Clause license.
1221
-
1222
- ## Architecture
1223
-
1224
- Crackerjack is designed with modern Python principles in mind:
1225
-
1226
- - **Factory Pattern:** Uses a factory function (`create_crackerjack_runner`) to create instances with proper dependency injection
1227
- - **Protocol-Based Design:** Defines clear interfaces using `t.Protocol` for better flexibility and testability
1228
- - **Dependency Injection:** Components can be easily replaced with custom implementations
1229
- - **Separation of Concerns:** CLI interface is separate from core logic
1230
- - **Type Safety:** Comprehensive type hints throughout the codebase
1231
- - **Testability:** Designed to be easily testable with mock objects
1232
-
1233
- ## Acknowledgments
1234
-
1235
- Crackerjack stands on the shoulders of giants. We're grateful to the maintainers and contributors of these outstanding tools that make modern Python development possible:
1236
-
1237
- ### Core Development Tools
1238
-
1239
- - **[UV](https://docs.astral.sh/uv/)** - Next-generation Python package and project management
1240
- - **[Ruff](https://docs.astral.sh/ruff/)** - Lightning-fast Python linter and formatter written in Rust
1241
- - **[pyright](https://microsoft.github.io/pyright/)** - Fast, feature-rich static type checker for Python
1242
- - **[pytest](https://pytest.org/)** - Flexible and powerful testing framework
1243
-
1244
- ### Code Quality & Security
1245
-
1246
- - **[pre-commit](https://pre-commit.com/)** - Multi-language pre-commit hooks framework
1247
- - **[bandit](https://bandit.readthedocs.io/)** - Security vulnerability scanner for Python
1248
- - **[vulture](https://github.com/jendrikseipp/vulture)** - Dead code detection tool
1249
- - **[refurb](https://github.com/dosisod/refurb)** - Code modernization and improvement suggestions
1250
- - **[codespell](https://github.com/codespell-project/codespell)** - Spelling mistake detection and correction
1251
- - **[detect-secrets](https://github.com/Yelp/detect-secrets)** - Prevention of secrets in repositories
1252
-
1253
- ### Dependencies & Project Management
1254
-
1255
- - **[creosote](https://github.com/fredrikaverpil/creosote)** - Unused dependency detection
1256
- - **[autotyping](https://github.com/JelleZijlstra/autotyping)** - Automatic type hint generation
1257
- - **[complexipy](https://github.com/rohaquinlop/complexipy)** - Code complexity analysis
1258
-
1259
- ### CLI & User Interface
1260
-
1261
- - **[Typer](https://typer.tiangolo.com/)** - Modern CLI framework for building command-line interfaces
1262
- - **[Rich](https://rich.readthedocs.io/)** - Rich text and beautiful formatting in the terminal
1263
- - **[click](https://click.palletsprojects.com/)** - Python package for creating command line interfaces
1264
-
1265
- ### Performance & Development Tools
1266
-
1267
- - **[icecream](https://github.com/gruns/icecream)** - Sweet and creamy print debugging
1268
- - **[bevy](https://github.com/ZeroIntensity/bevy)** - Lightweight dependency injection framework
1269
- - **[msgspec](https://github.com/jcrist/msgspec)** - High-performance message serialization
1270
- - **[attrs](https://github.com/python-attrs/attrs)** - Classes without boilerplate
1271
-
1272
- ### Development Environment
1273
-
1274
- - **[PyCharm](https://www.jetbrains.com/pycharm/)** - The premier Python IDE that powered the development of Crackerjack
1275
- - **[Claude Code](https://claude.ai/code)** - AI-powered development assistant that accelerated development and ensured code quality
1276
-
1277
- ### Legacy Inspiration
1278
-
1279
- - **[PDM](https://pdm.fming.dev/)** - Original inspiration for modern Python dependency management patterns
1280
-
1281
- ### Special Recognition
1282
-
1283
- We extend special thanks to the **Astral team** for their groundbreaking work on UV and Ruff, which have revolutionized Python tooling. Their commitment to performance, reliability, and developer experience has set new standards for the Python ecosystem.
1284
-
1285
- The integration of these tools into Crackerjack's unified workflow demonstrates the power of the modern Python toolchain when thoughtfully combined. Each tool excels in its domain, and together they create a development experience that is both powerful and delightful.
1286
-
1287
- We're honored to build upon this foundation and contribute to the Python community's continued evolution toward better development practices and tools.
1288
-
1289
- ______________________________________________________________________