Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /promptdriven_pdd /pdd /commands /utility.py
| """ | |
| Utility commands (install_completion, verify/fix-verification). | |
| """ | |
| from __future__ import annotations | |
| import click | |
| from typing import Optional, Tuple, Dict, Any | |
| from ..fix_verification_main import fix_verification_main | |
| from ..track_cost import track_cost | |
| from ..core.errors import handle_error | |
| from ..operation_log import log_operation | |
| from ..evidence_manifest import write_evidence_manifest | |
| def install_completion_cmd(ctx: click.Context) -> None: | |
| """Install shell completion for the PDD CLI.""" | |
| # Safely retrieve quiet flag, defaulting to False if ctx.obj is None | |
| quiet = (ctx.obj or {}).get("quiet", False) | |
| try: | |
| from .. import cli as cli_module # Import parent module for proper patching | |
| # Call through cli_module so patches to pdd.cli.install_completion work | |
| cli_module.install_completion(quiet=quiet) | |
| except Exception as e: | |
| handle_error(e, "install_completion", quiet) | |
| def verify( | |
| ctx: click.Context, | |
| prompt_file: str, | |
| code_file: str, | |
| verification_program: str, | |
| output_code: Optional[str], | |
| output_program: Optional[str], | |
| output_results: Optional[str], | |
| max_attempts: int, | |
| budget: float, | |
| agentic_fallback: bool, | |
| evidence: bool, | |
| ) -> Optional[Tuple[Dict[str, Any], float, str]]: | |
| """Verify code using a verification program.""" | |
| try: | |
| # verify command implies a loop if max_attempts > 1, but let's enable loop by default | |
| # as it's the more powerful mode and matches the CLI args provided (max_attempts). | |
| # verification_program positional arg acts as both program_file (to run) and verification_program (reference) | |
| success, prog_code, code_content, attempts, total_cost, model_name = fix_verification_main( | |
| ctx=ctx, | |
| prompt_file=prompt_file, | |
| code_file=code_file, | |
| program_file=verification_program, | |
| output_code=output_code, | |
| output_program=output_program, | |
| output_results=output_results, | |
| loop=True, | |
| verification_program=verification_program, | |
| max_attempts=max_attempts, | |
| budget=budget, | |
| agentic_fallback=agentic_fallback, | |
| ) | |
| result = { | |
| "success": success, | |
| "program_code": prog_code, | |
| "code_content": code_content, | |
| "attempts": attempts, | |
| } | |
| if evidence: | |
| write_evidence_manifest( | |
| command="pdd verify", | |
| prompt_file=prompt_file, | |
| output_files=[ | |
| path | |
| for path in (output_code, output_program, output_results) | |
| if path | |
| ], | |
| model=model_name, | |
| cost_usd=total_cost, | |
| temperature=(ctx.obj or {}).get("temperature", 0.0), | |
| validation={"verify": "passed" if success else "failed"}, | |
| logs={"verify_results": output_results}, | |
| ) | |
| return result, total_cost, model_name | |
| except click.Abort: | |
| raise | |
| except Exception as exception: | |
| quiet = (ctx.obj or {}).get("quiet", False) | |
| handle_error(exception, "verify", quiet) | |
| return None | |
Xet Storage Details
- Size:
- 4.79 kB
- Xet hash:
- 1357c6b228fa645fe3185eff7f6bd8d246e326afa4ad1bf38c31a19ea418ebd7
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.