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