Coverage for /Users/les/Projects/crackerjack/crackerjack/cli/options.py: 0%
78 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-03 15:39 -0700
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-03 15:39 -0700
1import typing as t
2from enum import Enum
4import typer
5from pydantic import BaseModel, field_validator
8class BumpOption(str, Enum):
9 patch = "patch"
10 minor = "minor"
11 major = "major"
12 interactive = "interactive"
14 def __str__(self) -> str:
15 return self.value
18class Options(BaseModel):
19 commit: bool = False
20 interactive: bool = False
21 no_config_updates: bool = False
22 update_precommit: bool = False
23 publish: BumpOption | None = None
24 bump: BumpOption | None = None
25 verbose: bool = False
26 clean: bool = False
27 test: bool = False
28 benchmark: bool = False
29 test_workers: int = 0
30 test_timeout: int = 0
31 all: BumpOption | None = None
32 ai_agent: bool = False
33 start_mcp_server: bool = False
34 stop_mcp_server: bool = False
35 restart_mcp_server: bool = False
36 create_pr: bool = False
37 skip_hooks: bool = False
38 fast: bool = False
39 comp: bool = False
40 async_mode: bool = False
41 experimental_hooks: bool = False
42 enable_pyrefly: bool = False
43 enable_ty: bool = False
44 cleanup: t.Any | None = None
45 no_git_tags: bool = False
46 skip_version_check: bool = False
47 cleanup_pypi: bool = False
48 keep_releases: int = 10
49 track_progress: bool = False
50 orchestrated: bool = False
51 boost_coverage: bool = True
52 coverage: bool = False
53 orchestration_strategy: str = "adaptive"
54 orchestration_progress: str = "granular"
55 orchestration_ai_mode: str = "single-agent"
56 monitor: bool = False
57 enhanced_monitor: bool = False
58 watchdog: bool = False
59 start_websocket_server: bool = False
60 stop_websocket_server: bool = False
61 restart_websocket_server: bool = False
62 websocket_port: int | None = None
63 dev: bool = False
64 dashboard: bool = False
65 max_iterations: int = 10
66 enterprise_batch: str | None = None
67 monitor_dashboard: str | None = None
68 coverage_status: bool = False
69 coverage_goal: float | None = None
70 no_coverage_ratchet: bool = False
72 @classmethod
73 @field_validator("publish", "bump", mode="before")
74 def validate_bump_options(cls, value: t.Any) -> BumpOption | None:
75 if value is None:
76 return None
77 if value == "":
78 return BumpOption.interactive
79 try:
80 return BumpOption(value.lower())
81 except ValueError:
82 valid_options = ", ".join([o.value for o in BumpOption])
83 msg = f"Invalid bump option: {value}. Must be one of: {valid_options}"
84 raise ValueError(
85 msg,
86 )
89CLI_OPTIONS = {
90 "commit": typer.Option(
91 False,
92 "-c",
93 "--commit",
94 help="Commit and push changes to Git.",
95 ),
96 "interactive": typer.Option(
97 False,
98 "-i",
99 "--interactive",
100 help="Use the interactive Rich UI for a better experience.",
101 ),
102 "no_config_updates": typer.Option(
103 False,
104 "-n",
105 "--no-config-updates",
106 help="Do not update configuration files.",
107 ),
108 "update_precommit": typer.Option(
109 False,
110 "-u",
111 "--update-precommit",
112 help="Update pre-commit hooks configuration.",
113 ),
114 "verbose": typer.Option(False, "-v", "--verbose", help="Enable verbose output."),
115 "publish": typer.Option(
116 None,
117 "-p",
118 "--publish",
119 help="Bump version and publish to PyPI (patch, minor, major). Use 'interactive' to be prompted for version selection.",
120 case_sensitive=False,
121 ),
122 "bump": typer.Option(
123 None,
124 "-b",
125 "--bump",
126 help="Bump version (patch, minor, major).",
127 case_sensitive=False,
128 ),
129 "clean": typer.Option(
130 False,
131 "-x",
132 "--clean",
133 help="Remove docstrings, line comments, and unnecessary whitespace from source code with automatic backup protection (doesn't affect test files).",
134 ),
135 "test": typer.Option(False, "-t", "--test", help="Run tests."),
136 "benchmark": typer.Option(
137 False,
138 "--benchmark",
139 help="Run tests in benchmark mode (disables parallel execution).",
140 ),
141 "test_workers": typer.Option(
142 0,
143 "--test-workers",
144 help="Number of parallel workers for running tests (0 = auto-detect, 1 = disable parallelization).",
145 ),
146 "test_timeout": typer.Option(
147 0,
148 "--test-timeout",
149 help="Timeout in seconds for individual tests (0 = use default based on project size).",
150 ),
151 "skip_hooks": typer.Option(
152 False,
153 "-s",
154 "--skip-hooks",
155 help="Skip running pre-commit hooks (useful with -t).",
156 ),
157 "fast": typer.Option(
158 False,
159 "--fast",
160 help="Run only fast hooks (formatting and basic checks).",
161 ),
162 "comp": typer.Option(
163 False,
164 "--comp",
165 help="Run only comprehensive hooks (type checking, security, complexity analysis).",
166 ),
167 "all": typer.Option(
168 None,
169 "-a",
170 "--all",
171 help="Run with `-x -t -p <patch|minor|major> -c` development options).",
172 case_sensitive=False,
173 ),
174 "create_pr": typer.Option(
175 False,
176 "-r",
177 "--pr",
178 "--new-pull-request",
179 help="Create a new pull request to the upstream repository.",
180 ),
181 "ai_agent": typer.Option(
182 False,
183 "--ai-agent",
184 help="Enable AI agent mode with autonomous auto-fixing.",
185 ),
186 "start_mcp_server": typer.Option(
187 False,
188 "--start-mcp-server",
189 help="Start MCP server for AI agent integration.",
190 ),
191 "stop_mcp_server": typer.Option(
192 False,
193 "--stop-mcp-server",
194 help="Stop all running MCP servers.",
195 ),
196 "restart_mcp_server": typer.Option(
197 False,
198 "--restart-mcp-server",
199 help="Restart MCP server (stop and start again).",
200 ),
201 "async_mode": typer.Option(
202 False,
203 "--async",
204 help="Enable async mode for faster file operations (experimental).",
205 hidden=True,
206 ),
207 "experimental_hooks": typer.Option(
208 False,
209 "--experimental-hooks",
210 help="Enable experimental pre-commit hooks (includes pyrefly and ty).",
211 ),
212 "enable_pyrefly": typer.Option(
213 False,
214 "--enable-pyrefly",
215 help="Enable pyrefly experimental type checking (requires experimental hooks mode).",
216 ),
217 "enable_ty": typer.Option(
218 False,
219 "--enable-ty",
220 help="Enable ty experimental type verification (requires experimental hooks mode).",
221 ),
222 "no_git_tags": typer.Option(
223 False,
224 "--no-git-tags",
225 help="Skip creating git tags during version bumping (tags are created by default).",
226 ),
227 "skip_version_check": typer.Option(
228 False,
229 "--skip-version-check",
230 help="Skip version consistency verification between pyproject.toml and git tags.",
231 ),
232 "start_websocket_server": typer.Option(
233 False,
234 "--start-websocket-server",
235 help="Start WebSocket progress server on port 8675.",
236 ),
237 "stop_websocket_server": typer.Option(
238 False,
239 "--stop-websocket-server",
240 help="Stop all running WebSocket servers.",
241 ),
242 "restart_websocket_server": typer.Option(
243 False,
244 "--restart-websocket-server",
245 help="Restart WebSocket server (stop and start again).",
246 ),
247 "websocket_port": typer.Option(
248 None,
249 "--websocket-port",
250 help="Port for WebSocket server when using --start-mcp-server (e.g., 8675).",
251 ),
252 "watchdog": typer.Option(
253 False,
254 "--watchdog",
255 help="Start service watchdog to monitor and auto-restart MCP and WebSocket servers.",
256 ),
257 "monitor": typer.Option(
258 False,
259 "--monitor",
260 help="Start multi-project progress monitor with WebSocket polling, watchdog services, and autodiscovery.",
261 ),
262 "enhanced_monitor": typer.Option(
263 False,
264 "--enhanced-monitor",
265 help="Start enhanced progress monitor with advanced MetricCard widgets and modern web UI patterns.",
266 ),
267 "dev": typer.Option(
268 False,
269 "--dev",
270 help="Enable development mode for progress monitors (enables textual --dev mode).",
271 ),
272 "dashboard": typer.Option(
273 False,
274 "--dashboard",
275 help="Start the comprehensive dashboard with system metrics, job tracking, and performance monitoring.",
276 ),
277 "max_iterations": typer.Option(
278 10,
279 "--max-iterations",
280 help="Maximum number of iterations for AI agent auto-fixing workflows (default: 10).",
281 ),
282 "ai_debug": typer.Option(
283 False,
284 "--ai-debug",
285 help="Enable verbose debugging for AI agent mode (implies --ai-agent).",
286 ),
287 "job_id": typer.Option(
288 None,
289 "--job-id",
290 help="Job ID for WebSocket progress tracking (internal use).",
291 hidden=True,
292 ),
293 "orchestrated": typer.Option(
294 False,
295 "--orchestrated",
296 help="Enable advanced orchestrated workflow mode with intelligent execution strategies, granular progress tracking, and multi-agent AI coordination.",
297 ),
298 "orchestration_strategy": typer.Option(
299 "adaptive",
300 "--orchestration-strategy",
301 help="Execution strategy for orchestrated mode: batch, individual, adaptive, selective (default: adaptive).",
302 ),
303 "orchestration_progress": typer.Option(
304 "granular",
305 "--orchestration-progress",
306 help="Progress tracking level: basic, detailed, granular, streaming (default: granular).",
307 ),
308 "orchestration_ai_mode": typer.Option(
309 "single-agent",
310 "--orchestration-ai-mode",
311 help="AI coordination mode: single-agent, multi-agent, coordinator (default: single-agent).",
312 ),
313 "coverage_status": typer.Option(
314 False,
315 "--coverage-status",
316 help="Show current coverage ratchet status and progress toward 100%.",
317 ),
318 "coverage_goal": typer.Option(
319 None,
320 "--coverage-goal",
321 help="Set explicit coverage target for this session (e.g., 15.0).",
322 ),
323 "no_coverage_ratchet": typer.Option(
324 False,
325 "--no-coverage-ratchet",
326 help="Disable coverage ratchet system temporarily (for experiments).",
327 ),
328 "boost_coverage": typer.Option(
329 True,
330 "--boost-coverage/--no-boost-coverage",
331 help="Automatically improve test coverage after successful workflow execution (default: True).",
332 ),
333}
336def create_options(
337 commit: bool,
338 interactive: bool,
339 no_config_updates: bool,
340 update_precommit: bool,
341 verbose: bool,
342 publish: BumpOption | None,
343 all: BumpOption | None,
344 bump: BumpOption | None,
345 clean: bool,
346 test: bool,
347 benchmark: bool,
348 test_workers: int,
349 test_timeout: int,
350 skip_hooks: bool,
351 fast: bool,
352 comp: bool,
353 create_pr: bool,
354 ai_agent: bool,
355 async_mode: bool,
356 experimental_hooks: bool,
357 enable_pyrefly: bool,
358 enable_ty: bool,
359 no_git_tags: bool,
360 skip_version_check: bool,
361 orchestrated: bool,
362 orchestration_strategy: str,
363 orchestration_progress: str,
364 orchestration_ai_mode: str,
365 dev: bool,
366 dashboard: bool,
367 max_iterations: int,
368 coverage_status: bool,
369 coverage_goal: float | None,
370 no_coverage_ratchet: bool,
371 boost_coverage: bool,
372) -> Options:
373 return Options(
374 commit=commit,
375 interactive=interactive,
376 no_config_updates=no_config_updates,
377 update_precommit=update_precommit,
378 verbose=verbose,
379 publish=publish,
380 bump=bump,
381 clean=clean,
382 test=test,
383 benchmark=benchmark,
384 test_workers=test_workers,
385 test_timeout=test_timeout,
386 skip_hooks=skip_hooks,
387 fast=fast,
388 comp=comp,
389 all=all,
390 ai_agent=ai_agent,
391 create_pr=create_pr,
392 async_mode=async_mode,
393 experimental_hooks=experimental_hooks,
394 enable_pyrefly=enable_pyrefly,
395 enable_ty=enable_ty,
396 no_git_tags=no_git_tags,
397 skip_version_check=skip_version_check,
398 orchestrated=orchestrated,
399 orchestration_strategy=orchestration_strategy,
400 orchestration_progress=orchestration_progress,
401 orchestration_ai_mode=orchestration_ai_mode,
402 dev=dev,
403 dashboard=dashboard,
404 max_iterations=max_iterations,
405 coverage_status=coverage_status,
406 coverage_goal=coverage_goal,
407 no_coverage_ratchet=no_coverage_ratchet,
408 boost_coverage=boost_coverage,
409 )