pdd-cli 0.0.26__py3-none-any.whl → 0.0.27__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 pdd-cli might be problematic. Click here for more details.

@@ -122,7 +122,7 @@ def fix_verification_errors(
122
122
  model_name = verification_response.get('model_name', model_name)
123
123
 
124
124
  if verbose:
125
- rprint(f"[cyan]Verification LLM call complete.[/cyan]")
125
+ rprint("[cyan]Verification LLM call complete.[/cyan]")
126
126
  rprint(f" [dim]Model Used:[/dim] {verification_response.get('model_name', 'N/A')}")
127
127
  rprint(f" [dim]Cost:[/dim] ${verification_response.get('cost', 0.0):.6f}")
128
128
 
@@ -209,7 +209,7 @@ def fix_verification_errors(
209
209
  "verification_issues_count": 0,
210
210
  }
211
211
  else: # Not VerificationOutput and not a successfully parsed string
212
- rprint(f"[bold red]Error:[/bold red] Verification LLM call did not return the expected structured output (e.g., parsing failed).")
212
+ rprint("[bold red]Error:[/bold red] Verification LLM call did not return the expected structured output (e.g., parsing failed).")
213
213
  rprint(f" [dim]Expected type:[/dim] {VerificationOutput} or str")
214
214
  rprint(f" [dim]Received type:[/dim] {type(verification_result_obj)}")
215
215
  content_str = str(verification_result_obj)
@@ -86,6 +86,8 @@ def fix_verification_errors_loop(
86
86
  max_attempts: int,
87
87
  budget: float,
88
88
  verification_log_file: str = "verification.log",
89
+ output_code_path: Optional[str] = None,
90
+ output_program_path: Optional[str] = None,
89
91
  verbose: bool = False,
90
92
  program_args: Optional[list[str]] = None,
91
93
  ) -> Dict[str, Any]:
@@ -103,6 +105,8 @@ def fix_verification_errors_loop(
103
105
  max_attempts: Maximum number of fix attempts.
104
106
  budget: Maximum allowed cost in USD.
105
107
  verification_log_file: Path for detailed XML logging (default: "verification.log").
108
+ output_code_path: Optional path to save fixed code (default: None).
109
+ output_program_path: Optional path to save fixed program (default: None).
106
110
  verbose: Enable verbose logging (default: False).
107
111
  program_args: Optional list of command-line arguments for the program_file.
108
112
 
@@ -423,7 +427,7 @@ def fix_verification_errors_loop(
423
427
  output=program_output,
424
428
  strength=strength,
425
429
  temperature=temperature,
426
- verbose=verbose # Pass verbose flag down
430
+ verbose=verbose
427
431
  )
428
432
 
429
433
  # 4f: Add cost
@@ -88,6 +88,7 @@ def fix_verification_main(
88
88
  program_file: str,
89
89
  output_results: Optional[str],
90
90
  output_code: Optional[str],
91
+ output_program: Optional[str],
91
92
  loop: bool,
92
93
  verification_program: Optional[str], # Only used if loop=True
93
94
  max_attempts: int = DEFAULT_MAX_ATTEMPTS,
@@ -105,6 +106,7 @@ def fix_verification_main(
105
106
  program_file (str): Path to the program to run for verification.
106
107
  output_results (Optional[str]): Path to save verification results log.
107
108
  output_code (Optional[str]): Path to save the verified code file.
109
+ output_program (Optional[str]): Path to save the verified program file.
108
110
  loop (bool): If True, perform iterative verification and fixing.
109
111
  verification_program (Optional[str]): Path to a verification program (required if loop=True).
110
112
  max_attempts (int): Max attempts for the loop.
@@ -161,12 +163,14 @@ def fix_verification_main(
161
163
  command_options: Dict[str, Optional[str]] = {
162
164
  "output_results": output_results,
163
165
  "output_code": output_code,
166
+ "output_program": output_program,
164
167
  }
165
168
 
166
169
  # Initial default values (in case we need the manual fallback)
167
170
  input_strings: Dict[str, str] = {}
168
171
  output_code_path: Optional[str] = output_code
169
172
  output_results_path: Optional[str] = output_results
173
+ output_program_path: Optional[str] = output_program
170
174
  language: str = ""
171
175
 
172
176
  try:
@@ -180,6 +184,7 @@ def fix_verification_main(
180
184
  )
181
185
  output_code_path = output_file_paths.get("output_code")
182
186
  output_results_path = output_file_paths.get("output_results")
187
+ output_program_path = output_file_paths.get("output_program")
183
188
 
184
189
  if verbose:
185
190
  rich_print("[dim]Resolved output paths via construct_paths.[/dim]")
@@ -211,6 +216,9 @@ def fix_verification_main(
211
216
  if output_results_path is None:
212
217
  base, _ = os.path.splitext(program_file)
213
218
  output_results_path = f"{base}_verify_results.log"
219
+ if output_program_path is None:
220
+ base_prog, ext_prog = os.path.splitext(program_file)
221
+ output_program_path = f"{base_prog}_verified{ext_prog}"
214
222
 
215
223
  # Best‑effort language guess
216
224
  if program_file.endswith(".py"):
@@ -331,7 +339,7 @@ def fix_verification_main(
331
339
  model_name = fix_results['model_name']
332
340
 
333
341
  # Build results log content for single pass
334
- results_log_content = f"PDD Verify Results (Single Pass)\n"
342
+ results_log_content = "PDD Verify Results (Single Pass)\n"
335
343
  results_log_content += f"Timestamp: {os.path.getmtime(prompt_file)}\n" # Use prompt timestamp as reference
336
344
  results_log_content += f"Prompt File: {prompt_file}\n"
337
345
  results_log_content += f"Code File: {code_file}\n"
@@ -361,6 +369,7 @@ def fix_verification_main(
361
369
  # --- Output File Writing ---
362
370
  saved_code_path: Optional[str] = None
363
371
  saved_results_path: Optional[str] = None
372
+ saved_program_path: Optional[str] = None
364
373
 
365
374
  if success and output_code_path:
366
375
  try:
@@ -372,6 +381,16 @@ def fix_verification_main(
372
381
  except IOError as e:
373
382
  rich_print(f"[bold red]Error:[/bold red] Failed to write verified code file '{output_code_path}': {e}")
374
383
 
384
+ if success and output_program_path:
385
+ try:
386
+ with open(output_program_path, "w") as f:
387
+ f.write(final_program)
388
+ saved_program_path = output_program_path
389
+ if not quiet:
390
+ rich_print(f"Successfully verified program saved to: [green]{output_program_path}[/green]")
391
+ except IOError as e:
392
+ rich_print(f"[bold red]Error:[/bold red] Failed to write verified program file '{output_program_path}': {e}")
393
+
375
394
  # Write results log (only for single pass, loop writes its own)
376
395
  if not loop and output_results_path:
377
396
  try:
@@ -398,6 +417,7 @@ def fix_verification_main(
398
417
  f"Total Cost: ${total_cost:.6f}\n"
399
418
  f"Model Used: {model_name}\n"
400
419
  f"Verified Code Saved: {saved_code_path or 'N/A'}\n"
420
+ f"Verified Program Saved: {saved_program_path or 'N/A'}\n"
401
421
  f"Results Log Saved: {saved_results_path or 'N/A'}",
402
422
  title=title,
403
423
  border_style="green" if success else "red"
@@ -25,7 +25,7 @@ COMMAND_OUTPUT_KEYS: Dict[str, List[str]] = {
25
25
  'trace': ['output'],
26
26
  'bug': ['output'],
27
27
  'auto-deps': ['output'],
28
- 'verify': ['output_results', 'output_code'],
28
+ 'verify': ['output_results', 'output_code', 'output_program'],
29
29
  }
30
30
 
31
31
  # Define default filename patterns for each output key
@@ -61,6 +61,7 @@ DEFAULT_FILENAMES: Dict[str, Dict[str, str]] = {
61
61
  'verify': {
62
62
  'output_results': '{basename}_verify_results.log',
63
63
  'output_code': '{basename}_verified{ext}',
64
+ 'output_program': '{basename}_program_verified{ext}',
64
65
  },
65
66
  }
66
67
 
@@ -93,6 +94,7 @@ ENV_VAR_MAP: Dict[str, Dict[str, str]] = {
93
94
  'verify': {
94
95
  'output_results': 'PDD_VERIFY_RESULTS_OUTPUT_PATH',
95
96
  'output_code': 'PDD_VERIFY_CODE_OUTPUT_PATH',
97
+ 'output_program': 'PDD_VERIFY_PROGRAM_OUTPUT_PATH',
96
98
  },
97
99
  }
98
100
 
@@ -435,4 +437,43 @@ if __name__ == '__main__':
435
437
  # Expected: {
436
438
  # 'output_results': '/path/to/cwd/module_to_verify_verify_results.log',
437
439
  # 'output_code': '/path/to/cwd/module_to_verify_verified.py'
438
- # }
440
+ # 'output_program': '/path/to/cwd/module_to_verify_program_verified.py'
441
+ # }
442
+
443
+ # --- Test Case 12: Verify command with user-specified output_program directory ---
444
+ print("\n--- Test Case 12: Verify (User Dir for output_program) ---")
445
+ test_dir_verify_prog = "temp_verify_prog_output"
446
+ os.makedirs(test_dir_verify_prog, exist_ok=True)
447
+ paths12 = generate_output_paths(
448
+ command='verify',
449
+ output_locations={'output_program': test_dir_verify_prog + os.path.sep},
450
+ basename="module_to_verify",
451
+ language="python",
452
+ file_extension=".py"
453
+ )
454
+ print(f"Result: {paths12}")
455
+ # Expected: {
456
+ # 'output_results': '/path/to/cwd/module_to_verify_verify_results.log',
457
+ # 'output_code': '/path/to/cwd/module_to_verify_verified.py',
458
+ # 'output_program': f'/path/to/cwd/{test_dir_verify_prog}/module_to_verify_program_verified.py'
459
+ # }
460
+ os.rmdir(test_dir_verify_prog) # Clean up
461
+
462
+ # --- Test Case 13: Verify command with environment variable for output_program ---
463
+ print("\n--- Test Case 13: Verify (Env Var for output_program) ---")
464
+ env_verify_prog_path = "env_verify_program_custom.py"
465
+ os.environ['PDD_VERIFY_PROGRAM_OUTPUT_PATH'] = env_verify_prog_path
466
+ paths13 = generate_output_paths(
467
+ command='verify',
468
+ output_locations={},
469
+ basename="another_module_verify",
470
+ language="python",
471
+ file_extension=".py"
472
+ )
473
+ print(f"Result: {paths13}")
474
+ # Expected: {
475
+ # 'output_results': '/path/to/cwd/another_module_verify_verify_results.log',
476
+ # 'output_code': '/path/to/cwd/another_module_verify_verified.py',
477
+ # 'output_program': f'/path/to/cwd/{env_verify_prog_path}'
478
+ # }
479
+ del os.environ['PDD_VERIFY_PROGRAM_OUTPUT_PATH'] # Clean up