pdd-cli 0.0.45__py3-none-any.whl → 0.0.118__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.
- pdd/__init__.py +40 -8
- pdd/agentic_bug.py +323 -0
- pdd/agentic_bug_orchestrator.py +497 -0
- pdd/agentic_change.py +231 -0
- pdd/agentic_change_orchestrator.py +526 -0
- pdd/agentic_common.py +598 -0
- pdd/agentic_crash.py +534 -0
- pdd/agentic_e2e_fix.py +319 -0
- pdd/agentic_e2e_fix_orchestrator.py +426 -0
- pdd/agentic_fix.py +1294 -0
- pdd/agentic_langtest.py +162 -0
- pdd/agentic_update.py +387 -0
- pdd/agentic_verify.py +183 -0
- pdd/architecture_sync.py +565 -0
- pdd/auth_service.py +210 -0
- pdd/auto_deps_main.py +71 -51
- pdd/auto_include.py +245 -5
- pdd/auto_update.py +125 -47
- pdd/bug_main.py +196 -23
- pdd/bug_to_unit_test.py +2 -0
- pdd/change_main.py +11 -4
- pdd/cli.py +22 -1181
- pdd/cmd_test_main.py +350 -150
- pdd/code_generator.py +60 -18
- pdd/code_generator_main.py +790 -57
- pdd/commands/__init__.py +48 -0
- pdd/commands/analysis.py +306 -0
- pdd/commands/auth.py +309 -0
- pdd/commands/connect.py +290 -0
- pdd/commands/fix.py +163 -0
- pdd/commands/generate.py +257 -0
- pdd/commands/maintenance.py +175 -0
- pdd/commands/misc.py +87 -0
- pdd/commands/modify.py +256 -0
- pdd/commands/report.py +144 -0
- pdd/commands/sessions.py +284 -0
- pdd/commands/templates.py +215 -0
- pdd/commands/utility.py +110 -0
- pdd/config_resolution.py +58 -0
- pdd/conflicts_main.py +8 -3
- pdd/construct_paths.py +589 -111
- pdd/context_generator.py +10 -2
- pdd/context_generator_main.py +175 -76
- pdd/continue_generation.py +53 -10
- pdd/core/__init__.py +33 -0
- pdd/core/cli.py +527 -0
- pdd/core/cloud.py +237 -0
- pdd/core/dump.py +554 -0
- pdd/core/errors.py +67 -0
- pdd/core/remote_session.py +61 -0
- pdd/core/utils.py +90 -0
- pdd/crash_main.py +262 -33
- pdd/data/language_format.csv +71 -63
- pdd/data/llm_model.csv +20 -18
- pdd/detect_change_main.py +5 -4
- pdd/docs/prompting_guide.md +864 -0
- pdd/docs/whitepaper_with_benchmarks/data_and_functions/benchmark_analysis.py +495 -0
- pdd/docs/whitepaper_with_benchmarks/data_and_functions/creation_compare.py +528 -0
- pdd/fix_code_loop.py +523 -95
- pdd/fix_code_module_errors.py +6 -2
- pdd/fix_error_loop.py +491 -92
- pdd/fix_errors_from_unit_tests.py +4 -3
- pdd/fix_main.py +278 -21
- pdd/fix_verification_errors.py +12 -100
- pdd/fix_verification_errors_loop.py +529 -286
- pdd/fix_verification_main.py +294 -89
- pdd/frontend/dist/assets/index-B5DZHykP.css +1 -0
- pdd/frontend/dist/assets/index-DQ3wkeQ2.js +449 -0
- pdd/frontend/dist/index.html +376 -0
- pdd/frontend/dist/logo.svg +33 -0
- pdd/generate_output_paths.py +139 -15
- pdd/generate_test.py +218 -146
- pdd/get_comment.py +19 -44
- pdd/get_extension.py +8 -9
- pdd/get_jwt_token.py +318 -22
- pdd/get_language.py +8 -7
- pdd/get_run_command.py +75 -0
- pdd/get_test_command.py +68 -0
- pdd/git_update.py +70 -19
- pdd/incremental_code_generator.py +2 -2
- pdd/insert_includes.py +13 -4
- pdd/llm_invoke.py +1711 -181
- pdd/load_prompt_template.py +19 -12
- pdd/path_resolution.py +140 -0
- pdd/pdd_completion.fish +25 -2
- pdd/pdd_completion.sh +30 -4
- pdd/pdd_completion.zsh +79 -4
- pdd/postprocess.py +14 -4
- pdd/preprocess.py +293 -24
- pdd/preprocess_main.py +41 -6
- pdd/prompts/agentic_bug_step10_pr_LLM.prompt +182 -0
- pdd/prompts/agentic_bug_step1_duplicate_LLM.prompt +73 -0
- pdd/prompts/agentic_bug_step2_docs_LLM.prompt +129 -0
- pdd/prompts/agentic_bug_step3_triage_LLM.prompt +95 -0
- pdd/prompts/agentic_bug_step4_reproduce_LLM.prompt +97 -0
- pdd/prompts/agentic_bug_step5_root_cause_LLM.prompt +123 -0
- pdd/prompts/agentic_bug_step6_test_plan_LLM.prompt +107 -0
- pdd/prompts/agentic_bug_step7_generate_LLM.prompt +172 -0
- pdd/prompts/agentic_bug_step8_verify_LLM.prompt +119 -0
- pdd/prompts/agentic_bug_step9_e2e_test_LLM.prompt +289 -0
- pdd/prompts/agentic_change_step10_identify_issues_LLM.prompt +1006 -0
- pdd/prompts/agentic_change_step11_fix_issues_LLM.prompt +984 -0
- pdd/prompts/agentic_change_step12_create_pr_LLM.prompt +131 -0
- pdd/prompts/agentic_change_step1_duplicate_LLM.prompt +73 -0
- pdd/prompts/agentic_change_step2_docs_LLM.prompt +101 -0
- pdd/prompts/agentic_change_step3_research_LLM.prompt +126 -0
- pdd/prompts/agentic_change_step4_clarify_LLM.prompt +164 -0
- pdd/prompts/agentic_change_step5_docs_change_LLM.prompt +981 -0
- pdd/prompts/agentic_change_step6_devunits_LLM.prompt +1005 -0
- pdd/prompts/agentic_change_step7_architecture_LLM.prompt +1044 -0
- pdd/prompts/agentic_change_step8_analyze_LLM.prompt +1027 -0
- pdd/prompts/agentic_change_step9_implement_LLM.prompt +1077 -0
- pdd/prompts/agentic_crash_explore_LLM.prompt +49 -0
- pdd/prompts/agentic_e2e_fix_step1_unit_tests_LLM.prompt +90 -0
- pdd/prompts/agentic_e2e_fix_step2_e2e_tests_LLM.prompt +91 -0
- pdd/prompts/agentic_e2e_fix_step3_root_cause_LLM.prompt +89 -0
- pdd/prompts/agentic_e2e_fix_step4_fix_e2e_tests_LLM.prompt +96 -0
- pdd/prompts/agentic_e2e_fix_step5_identify_devunits_LLM.prompt +91 -0
- pdd/prompts/agentic_e2e_fix_step6_create_unit_tests_LLM.prompt +106 -0
- pdd/prompts/agentic_e2e_fix_step7_verify_tests_LLM.prompt +116 -0
- pdd/prompts/agentic_e2e_fix_step8_run_pdd_fix_LLM.prompt +120 -0
- pdd/prompts/agentic_e2e_fix_step9_verify_all_LLM.prompt +146 -0
- pdd/prompts/agentic_fix_explore_LLM.prompt +45 -0
- pdd/prompts/agentic_fix_harvest_only_LLM.prompt +48 -0
- pdd/prompts/agentic_fix_primary_LLM.prompt +85 -0
- pdd/prompts/agentic_update_LLM.prompt +925 -0
- pdd/prompts/agentic_verify_explore_LLM.prompt +45 -0
- pdd/prompts/auto_include_LLM.prompt +122 -905
- pdd/prompts/change_LLM.prompt +3093 -1
- pdd/prompts/detect_change_LLM.prompt +686 -27
- pdd/prompts/example_generator_LLM.prompt +22 -1
- pdd/prompts/extract_code_LLM.prompt +5 -1
- pdd/prompts/extract_program_code_fix_LLM.prompt +7 -1
- pdd/prompts/extract_prompt_update_LLM.prompt +7 -8
- pdd/prompts/extract_promptline_LLM.prompt +17 -11
- pdd/prompts/find_verification_errors_LLM.prompt +6 -0
- pdd/prompts/fix_code_module_errors_LLM.prompt +12 -2
- pdd/prompts/fix_errors_from_unit_tests_LLM.prompt +9 -0
- pdd/prompts/fix_verification_errors_LLM.prompt +22 -0
- pdd/prompts/generate_test_LLM.prompt +41 -7
- pdd/prompts/generate_test_from_example_LLM.prompt +115 -0
- pdd/prompts/increase_tests_LLM.prompt +1 -5
- pdd/prompts/insert_includes_LLM.prompt +316 -186
- pdd/prompts/prompt_code_diff_LLM.prompt +119 -0
- pdd/prompts/prompt_diff_LLM.prompt +82 -0
- pdd/prompts/trace_LLM.prompt +25 -22
- pdd/prompts/unfinished_prompt_LLM.prompt +85 -1
- pdd/prompts/update_prompt_LLM.prompt +22 -1
- pdd/pytest_output.py +127 -12
- pdd/remote_session.py +876 -0
- pdd/render_mermaid.py +236 -0
- pdd/server/__init__.py +52 -0
- pdd/server/app.py +335 -0
- pdd/server/click_executor.py +587 -0
- pdd/server/executor.py +338 -0
- pdd/server/jobs.py +661 -0
- pdd/server/models.py +241 -0
- pdd/server/routes/__init__.py +31 -0
- pdd/server/routes/architecture.py +451 -0
- pdd/server/routes/auth.py +364 -0
- pdd/server/routes/commands.py +929 -0
- pdd/server/routes/config.py +42 -0
- pdd/server/routes/files.py +603 -0
- pdd/server/routes/prompts.py +1322 -0
- pdd/server/routes/websocket.py +473 -0
- pdd/server/security.py +243 -0
- pdd/server/terminal_spawner.py +209 -0
- pdd/server/token_counter.py +222 -0
- pdd/setup_tool.py +648 -0
- pdd/simple_math.py +2 -0
- pdd/split_main.py +3 -2
- pdd/summarize_directory.py +237 -195
- pdd/sync_animation.py +8 -4
- pdd/sync_determine_operation.py +839 -112
- pdd/sync_main.py +351 -57
- pdd/sync_orchestration.py +1400 -756
- pdd/sync_tui.py +848 -0
- pdd/template_expander.py +161 -0
- pdd/template_registry.py +264 -0
- pdd/templates/architecture/architecture_json.prompt +237 -0
- pdd/templates/generic/generate_prompt.prompt +174 -0
- pdd/trace.py +168 -12
- pdd/trace_main.py +4 -3
- pdd/track_cost.py +140 -63
- pdd/unfinished_prompt.py +51 -4
- pdd/update_main.py +567 -67
- pdd/update_model_costs.py +2 -2
- pdd/update_prompt.py +19 -4
- {pdd_cli-0.0.45.dist-info → pdd_cli-0.0.118.dist-info}/METADATA +29 -11
- pdd_cli-0.0.118.dist-info/RECORD +227 -0
- {pdd_cli-0.0.45.dist-info → pdd_cli-0.0.118.dist-info}/licenses/LICENSE +1 -1
- pdd_cli-0.0.45.dist-info/RECORD +0 -116
- {pdd_cli-0.0.45.dist-info → pdd_cli-0.0.118.dist-info}/WHEEL +0 -0
- {pdd_cli-0.0.45.dist-info → pdd_cli-0.0.118.dist-info}/entry_points.txt +0 -0
- {pdd_cli-0.0.45.dist-info → pdd_cli-0.0.118.dist-info}/top_level.txt +0 -0
pdd/agentic_verify.py
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import re
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from rich.console import Console
|
|
10
|
+
|
|
11
|
+
from .agentic_common import run_agentic_task
|
|
12
|
+
from .load_prompt_template import load_prompt_template
|
|
13
|
+
|
|
14
|
+
console = Console()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _get_file_mtimes(root: Path) -> dict[Path, float]:
|
|
18
|
+
"""
|
|
19
|
+
Recursively scan the directory to record file modification times.
|
|
20
|
+
Excludes common ignored directories like .git, __pycache__, .venv, etc.
|
|
21
|
+
"""
|
|
22
|
+
mtimes = {}
|
|
23
|
+
ignore_dirs = {".git", "__pycache__", ".venv", "venv", "node_modules", ".idea", ".vscode"}
|
|
24
|
+
|
|
25
|
+
for path in root.rglob("*"):
|
|
26
|
+
# Skip ignored directories
|
|
27
|
+
if any(part in ignore_dirs for part in path.parts):
|
|
28
|
+
continue
|
|
29
|
+
|
|
30
|
+
if path.is_file():
|
|
31
|
+
try:
|
|
32
|
+
mtimes[path] = path.stat().st_mtime
|
|
33
|
+
except OSError:
|
|
34
|
+
# Handle cases where file might disappear or be inaccessible during scan
|
|
35
|
+
continue
|
|
36
|
+
return mtimes
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _extract_json_from_text(text: str) -> dict[str, Any] | None:
|
|
40
|
+
"""
|
|
41
|
+
Attempts to extract a JSON object from a string.
|
|
42
|
+
Handles Markdown code blocks and raw JSON.
|
|
43
|
+
"""
|
|
44
|
+
# Try to find JSON within markdown code blocks first
|
|
45
|
+
json_block_pattern = r"```(?:json)?\s*(\{.*?\})\s*```"
|
|
46
|
+
match = re.search(json_block_pattern, text, re.DOTALL)
|
|
47
|
+
|
|
48
|
+
if match:
|
|
49
|
+
json_str = match.group(1)
|
|
50
|
+
else:
|
|
51
|
+
# Try to find the first opening brace and last closing brace
|
|
52
|
+
start = text.find("{")
|
|
53
|
+
end = text.rfind("}")
|
|
54
|
+
if start != -1 and end != -1 and end > start:
|
|
55
|
+
json_str = text[start : end + 1]
|
|
56
|
+
else:
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
try:
|
|
60
|
+
return json.loads(json_str)
|
|
61
|
+
except json.JSONDecodeError:
|
|
62
|
+
return None
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def run_agentic_verify(
|
|
66
|
+
prompt_file: Path,
|
|
67
|
+
code_file: Path,
|
|
68
|
+
program_file: Path,
|
|
69
|
+
verification_log_file: Path,
|
|
70
|
+
*,
|
|
71
|
+
verbose: bool = False,
|
|
72
|
+
quiet: bool = False,
|
|
73
|
+
) -> tuple[bool, str, float, str, list[str]]:
|
|
74
|
+
"""
|
|
75
|
+
Runs an agentic verification fallback.
|
|
76
|
+
|
|
77
|
+
This function delegates the verification fix to a CLI agent (explore mode).
|
|
78
|
+
It records file changes, parses the agent's JSON output, and returns the results.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
prompt_file: Path to the prompt specification file.
|
|
82
|
+
code_file: Path to the generated code file.
|
|
83
|
+
program_file: Path to the program/driver file.
|
|
84
|
+
verification_log_file: Path to the log containing previous failures.
|
|
85
|
+
verbose: Enable verbose logging.
|
|
86
|
+
quiet: Suppress standard output.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
Tuple containing:
|
|
90
|
+
- success (bool): Whether the agent claims success.
|
|
91
|
+
- message (str): The explanation or output message.
|
|
92
|
+
- cost (float): Estimated cost of the operation.
|
|
93
|
+
- model (str): The model/provider used.
|
|
94
|
+
- changed_files (list[str]): List of files modified during execution.
|
|
95
|
+
"""
|
|
96
|
+
project_root = Path.cwd()
|
|
97
|
+
|
|
98
|
+
if not quiet:
|
|
99
|
+
console.print(f"[bold blue]Starting Agentic Verify (Explore Mode)[/bold blue]")
|
|
100
|
+
console.print(f"Context: {project_root}")
|
|
101
|
+
|
|
102
|
+
# 1. Load Prompt Template
|
|
103
|
+
template_name = "agentic_verify_explore_LLM"
|
|
104
|
+
template = load_prompt_template(template_name)
|
|
105
|
+
|
|
106
|
+
if not template:
|
|
107
|
+
error_msg = f"Failed to load prompt template: {template_name}"
|
|
108
|
+
console.print(f"[bold red]{error_msg}[/bold red]")
|
|
109
|
+
return False, error_msg, 0.0, "unknown", []
|
|
110
|
+
|
|
111
|
+
# 2. Prepare Context
|
|
112
|
+
if verification_log_file.exists():
|
|
113
|
+
previous_attempts = verification_log_file.read_text(encoding="utf-8")
|
|
114
|
+
else:
|
|
115
|
+
previous_attempts = "No previous verification logs found."
|
|
116
|
+
|
|
117
|
+
# 3. Format Instruction
|
|
118
|
+
instruction = template.format(
|
|
119
|
+
prompt_path=prompt_file.resolve(),
|
|
120
|
+
code_path=code_file.resolve(),
|
|
121
|
+
program_path=program_file.resolve(),
|
|
122
|
+
project_root=project_root.resolve(),
|
|
123
|
+
previous_attempts=previous_attempts
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
# 4. Record State Before Execution
|
|
127
|
+
mtimes_before = _get_file_mtimes(project_root)
|
|
128
|
+
|
|
129
|
+
# 5. Run Agentic Task
|
|
130
|
+
# We use the project root as the CWD so the agent can explore freely
|
|
131
|
+
agent_success, agent_output, cost, provider = run_agentic_task(
|
|
132
|
+
instruction=instruction,
|
|
133
|
+
cwd=project_root,
|
|
134
|
+
verbose=verbose,
|
|
135
|
+
quiet=quiet,
|
|
136
|
+
label="verify-explore"
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# 6. Record State After Execution & Detect Changes
|
|
140
|
+
mtimes_after = _get_file_mtimes(project_root)
|
|
141
|
+
changed_files = []
|
|
142
|
+
|
|
143
|
+
for path, mtime in mtimes_after.items():
|
|
144
|
+
# Check if file is new or modified
|
|
145
|
+
if path not in mtimes_before or mtimes_before[path] != mtime:
|
|
146
|
+
# Store relative path for cleaner output
|
|
147
|
+
try:
|
|
148
|
+
rel_path = path.relative_to(project_root)
|
|
149
|
+
changed_files.append(str(rel_path))
|
|
150
|
+
except ValueError:
|
|
151
|
+
changed_files.append(str(path))
|
|
152
|
+
|
|
153
|
+
# 7. Parse Agent Output
|
|
154
|
+
# The agent is instructed to return JSON.
|
|
155
|
+
parsed_data = _extract_json_from_text(agent_output)
|
|
156
|
+
|
|
157
|
+
final_success = False
|
|
158
|
+
final_message = agent_output
|
|
159
|
+
|
|
160
|
+
if parsed_data:
|
|
161
|
+
# Trust the agent's self-reported success if JSON is valid
|
|
162
|
+
final_success = parsed_data.get("success", False)
|
|
163
|
+
final_message = parsed_data.get("message", agent_output)
|
|
164
|
+
|
|
165
|
+
# We prefer our calculated changed_files, but if we found none and the agent
|
|
166
|
+
# claims to have changed some (and they exist), we could log that discrepancy.
|
|
167
|
+
# For now, we stick to the physical reality of mtimes.
|
|
168
|
+
else:
|
|
169
|
+
# Fallback if agent didn't output valid JSON but the CLI tool reported success
|
|
170
|
+
if verbose:
|
|
171
|
+
console.print("[yellow]Warning: Could not parse JSON from agent output. Using raw output.[/yellow]")
|
|
172
|
+
|
|
173
|
+
# If the CLI tool failed (agent_success is False), we definitely failed.
|
|
174
|
+
# If the CLI tool succeeded, we still default to False because we couldn't verify the JSON contract.
|
|
175
|
+
final_success = False
|
|
176
|
+
|
|
177
|
+
if not quiet:
|
|
178
|
+
status_color = "green" if final_success else "red"
|
|
179
|
+
console.print(f"[{status_color}]Agentic Verify Finished. Success: {final_success}[/{status_color}]")
|
|
180
|
+
if changed_files:
|
|
181
|
+
console.print(f"Changed files: {', '.join(changed_files)}")
|
|
182
|
+
|
|
183
|
+
return final_success, final_message, cost, provider, changed_files
|