pdd-cli 0.0.2__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.

Files changed (95) hide show
  1. pdd/__init__.py +0 -0
  2. pdd/auto_deps_main.py +98 -0
  3. pdd/auto_include.py +175 -0
  4. pdd/auto_update.py +73 -0
  5. pdd/bug_main.py +99 -0
  6. pdd/bug_to_unit_test.py +159 -0
  7. pdd/change.py +141 -0
  8. pdd/change_main.py +240 -0
  9. pdd/cli.py +607 -0
  10. pdd/cmd_test_main.py +155 -0
  11. pdd/code_generator.py +117 -0
  12. pdd/code_generator_main.py +66 -0
  13. pdd/comment_line.py +35 -0
  14. pdd/conflicts_in_prompts.py +143 -0
  15. pdd/conflicts_main.py +90 -0
  16. pdd/construct_paths.py +251 -0
  17. pdd/context_generator.py +133 -0
  18. pdd/context_generator_main.py +73 -0
  19. pdd/continue_generation.py +140 -0
  20. pdd/crash_main.py +127 -0
  21. pdd/data/language_format.csv +61 -0
  22. pdd/data/llm_model.csv +15 -0
  23. pdd/detect_change.py +142 -0
  24. pdd/detect_change_main.py +100 -0
  25. pdd/find_section.py +28 -0
  26. pdd/fix_code_loop.py +212 -0
  27. pdd/fix_code_module_errors.py +143 -0
  28. pdd/fix_error_loop.py +216 -0
  29. pdd/fix_errors_from_unit_tests.py +240 -0
  30. pdd/fix_main.py +138 -0
  31. pdd/generate_output_paths.py +194 -0
  32. pdd/generate_test.py +140 -0
  33. pdd/get_comment.py +55 -0
  34. pdd/get_extension.py +52 -0
  35. pdd/get_language.py +41 -0
  36. pdd/git_update.py +84 -0
  37. pdd/increase_tests.py +93 -0
  38. pdd/insert_includes.py +150 -0
  39. pdd/llm_invoke.py +304 -0
  40. pdd/load_prompt_template.py +59 -0
  41. pdd/pdd_completion.fish +72 -0
  42. pdd/pdd_completion.sh +141 -0
  43. pdd/pdd_completion.zsh +418 -0
  44. pdd/postprocess.py +121 -0
  45. pdd/postprocess_0.py +52 -0
  46. pdd/preprocess.py +199 -0
  47. pdd/preprocess_main.py +72 -0
  48. pdd/process_csv_change.py +182 -0
  49. pdd/prompts/auto_include_LLM.prompt +230 -0
  50. pdd/prompts/bug_to_unit_test_LLM.prompt +17 -0
  51. pdd/prompts/change_LLM.prompt +34 -0
  52. pdd/prompts/conflict_LLM.prompt +23 -0
  53. pdd/prompts/continue_generation_LLM.prompt +3 -0
  54. pdd/prompts/detect_change_LLM.prompt +65 -0
  55. pdd/prompts/example_generator_LLM.prompt +10 -0
  56. pdd/prompts/extract_auto_include_LLM.prompt +6 -0
  57. pdd/prompts/extract_code_LLM.prompt +22 -0
  58. pdd/prompts/extract_conflict_LLM.prompt +19 -0
  59. pdd/prompts/extract_detect_change_LLM.prompt +19 -0
  60. pdd/prompts/extract_program_code_fix_LLM.prompt +16 -0
  61. pdd/prompts/extract_prompt_change_LLM.prompt +7 -0
  62. pdd/prompts/extract_prompt_split_LLM.prompt +9 -0
  63. pdd/prompts/extract_prompt_update_LLM.prompt +8 -0
  64. pdd/prompts/extract_promptline_LLM.prompt +11 -0
  65. pdd/prompts/extract_unit_code_fix_LLM.prompt +332 -0
  66. pdd/prompts/extract_xml_LLM.prompt +7 -0
  67. pdd/prompts/fix_code_module_errors_LLM.prompt +17 -0
  68. pdd/prompts/fix_errors_from_unit_tests_LLM.prompt +62 -0
  69. pdd/prompts/generate_test_LLM.prompt +12 -0
  70. pdd/prompts/increase_tests_LLM.prompt +16 -0
  71. pdd/prompts/insert_includes_LLM.prompt +30 -0
  72. pdd/prompts/split_LLM.prompt +94 -0
  73. pdd/prompts/summarize_file_LLM.prompt +11 -0
  74. pdd/prompts/trace_LLM.prompt +30 -0
  75. pdd/prompts/trim_results_LLM.prompt +83 -0
  76. pdd/prompts/trim_results_start_LLM.prompt +45 -0
  77. pdd/prompts/unfinished_prompt_LLM.prompt +18 -0
  78. pdd/prompts/update_prompt_LLM.prompt +19 -0
  79. pdd/prompts/xml_convertor_LLM.prompt +54 -0
  80. pdd/split.py +119 -0
  81. pdd/split_main.py +103 -0
  82. pdd/summarize_directory.py +212 -0
  83. pdd/trace.py +135 -0
  84. pdd/trace_main.py +108 -0
  85. pdd/track_cost.py +102 -0
  86. pdd/unfinished_prompt.py +114 -0
  87. pdd/update_main.py +96 -0
  88. pdd/update_prompt.py +115 -0
  89. pdd/xml_tagger.py +122 -0
  90. pdd_cli-0.0.2.dist-info/LICENSE +7 -0
  91. pdd_cli-0.0.2.dist-info/METADATA +225 -0
  92. pdd_cli-0.0.2.dist-info/RECORD +95 -0
  93. pdd_cli-0.0.2.dist-info/WHEEL +5 -0
  94. pdd_cli-0.0.2.dist-info/entry_points.txt +2 -0
  95. pdd_cli-0.0.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,72 @@
1
+ # pdd_completion.fish - Fish shell completion for PDD CLI
2
+
3
+ # Global options
4
+ complete -c pdd -n "__fish_use_subcommand" -l force -d "Overwrite existing files without confirmation"
5
+ complete -c pdd -n "__fish_use_subcommand" -l strength -x -d "Set AI model strength (0.0 to 1.0)"
6
+ complete -c pdd -n "__fish_use_subcommand" -l temperature -x -d "Set AI model temperature"
7
+ complete -c pdd -n "__fish_use_subcommand" -l verbose -d "Increase output verbosity"
8
+ complete -c pdd -n "__fish_use_subcommand" -l quiet -d "Decrease output verbosity"
9
+ complete -c pdd -n "__fish_use_subcommand" -l output-cost -r -d "Enable cost tracking and output CSV file"
10
+ complete -c pdd -n "__fish_use_subcommand" -l review-examples -d "Review few-shot examples before execution"
11
+ complete -c pdd -n "__fish_use_subcommand" -l help -d "Show help message"
12
+ complete -c pdd -n "__fish_use_subcommand" -l version -d "Show version information"
13
+
14
+ # Commands
15
+ complete -c pdd -n "__fish_use_subcommand" -a generate -d "Generate code from prompt file"
16
+ complete -c pdd -n "__fish_use_subcommand" -a example -d "Create example from prompt and code"
17
+ complete -c pdd -n "__fish_use_subcommand" -a test -d "Generate or enhance unit tests"
18
+ complete -c pdd -n "__fish_use_subcommand" -a preprocess -d "Preprocess prompt files"
19
+ complete -c pdd -n "__fish_use_subcommand" -a fix -d "Fix errors in code and tests"
20
+ complete -c pdd -n "__fish_use_subcommand" -a split -d "Split large prompt files"
21
+ complete -c pdd -n "__fish_use_subcommand" -a change -d "Modify prompt based on change prompt"
22
+ complete -c pdd -n "__fish_use_subcommand" -a update -d "Update prompt based on modified code"
23
+ complete -c pdd -n "__fish_use_subcommand" -a detect -d "Detect prompts needing changes"
24
+ complete -c pdd -n "__fish_use_subcommand" -a conflicts -d "Analyze conflicts between prompts"
25
+ complete -c pdd -n "__fish_use_subcommand" -a crash -d "Fix code causing program crash"
26
+ complete -c pdd -n "__fish_use_subcommand" -a trace -d "Trace code line to prompt"
27
+ complete -c pdd -n "__fish_use_subcommand" -a bug -d "Generate unit test from bug report"
28
+ complete -c pdd -n "__fish_use_subcommand" -a auto-deps -d "Analyze and insert dependencies"
29
+
30
+ # Command-specific completions
31
+ complete -c pdd -n "__fish_seen_subcommand_from generate" -l output -r -d "Output location for generated code"
32
+ complete -c pdd -n "__fish_seen_subcommand_from generate" -a "(__fish_complete_suffix .prompt)"
33
+
34
+ complete -c pdd -n "__fish_seen_subcommand_from example" -l output -r -d "Output location for example code"
35
+ complete -c pdd -n "__fish_seen_subcommand_from example" -a "(__fish_complete_suffix .prompt)"
36
+ complete -c pdd -n "__fish_seen_subcommand_from example" -a "(__fish_complete_suffix .py .js .java .cpp .rb .go)"
37
+
38
+ complete -c pdd -n "__fish_seen_subcommand_from test" -l output -r -d "Output location for test file"
39
+ complete -c pdd -n "__fish_seen_subcommand_from test" -l language -x -d "Specify programming language"
40
+ complete -c pdd -n "__fish_seen_subcommand_from test" -l coverage-report -r -d "Path to coverage report"
41
+ complete -c pdd -n "__fish_seen_subcommand_from test" -l existing-tests -r -d "Path to existing test file"
42
+ complete -c pdd -n "__fish_seen_subcommand_from test" -l target-coverage -x -d "Target coverage percentage"
43
+ complete -c pdd -n "__fish_seen_subcommand_from test" -l merge -d "Merge new tests with existing"
44
+ complete -c pdd -n "__fish_seen_subcommand_from test" -a "(__fish_complete_suffix .prompt)"
45
+ complete -c pdd -n "__fish_seen_subcommand_from test" -a "(__fish_complete_suffix .py .js .java .cpp .rb .go)"
46
+
47
+ complete -c pdd -n "__fish_seen_subcommand_from preprocess" -l output -r -d "Output location for preprocessed file"
48
+ complete -c pdd -n "__fish_seen_subcommand_from preprocess" -l xml -d "Insert XML delimiters"
49
+ complete -c pdd -n "__fish_seen_subcommand_from preprocess" -l recursive -d "Recursively preprocess"
50
+ complete -c pdd -n "__fish_seen_subcommand_from preprocess" -l double -d "Double curly brackets"
51
+ complete -c pdd -n "__fish_seen_subcommand_from preprocess" -l exclude -x -d "Keys to exclude from doubling"
52
+ complete -c pdd -n "__fish_seen_subcommand_from preprocess" -a "(__fish_complete_suffix .prompt)"
53
+
54
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -l output-test -r -d "Output location for fixed test"
55
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -l output-code -r -d "Output location for fixed code"
56
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -l output-results -r -d "Output location for fix results"
57
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -l loop -d "Enable iterative fixing"
58
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -l verification-program -r -d "Verification program path"
59
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -l max-attempts -x -d "Maximum fix attempts"
60
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -l budget -x -d "Maximum budget for fixing"
61
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -l auto-submit -d "Auto-submit if tests pass"
62
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -a "(__fish_complete_suffix .prompt)"
63
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -a "(__fish_complete_suffix .py .js .java .cpp .rb .go)"
64
+ complete -c pdd -n "__fish_seen_subcommand_from fix" -a "(__fish_complete_suffix .log)"
65
+
66
+ # File completion for all commands
67
+ complete -c pdd -n "__fish_seen_subcommand_from generate example test preprocess fix split change update detect conflicts crash trace bug auto-deps" -a "(__fish_complete_suffix .prompt)"
68
+ complete -c pdd -n "__fish_seen_subcommand_from generate example test preprocess fix split change update detect conflicts crash trace bug auto-deps" -a "(__fish_complete_suffix .py .js .java .cpp .rb .go)"
69
+ complete -c pdd -n "__fish_seen_subcommand_from generate example test preprocess fix split change update detect conflicts crash trace bug auto-deps" -a "(__fish_complete_suffix .log .txt .csv)"
70
+
71
+ # Help completion
72
+ complete -c pdd -n "__fish_seen_subcommand_from help" -a "generate example test preprocess fix split change update detect conflicts crash trace bug auto-deps" -d "Show help for specific command"
pdd/pdd_completion.sh ADDED
@@ -0,0 +1,141 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # PDD CLI Bash Completion Script
4
+ # Version: 0.0.2
5
+ # Supports all PDD commands and options with filename completion
6
+
7
+ _pdd() {
8
+ local cur prev words cword
9
+
10
+ # Replace _init_completion with manual initialization
11
+ COMPREPLY=()
12
+ cur="${COMP_WORDS[COMP_CWORD]}"
13
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
14
+ words=("${COMP_WORDS[@]}")
15
+ cword=$COMP_CWORD
16
+
17
+ # Global options
18
+ local global_opts="--force --strength --temperature --verbose --quiet --output-cost --review-examples --help --version"
19
+
20
+ # Commands
21
+ local commands="generate example test preprocess fix split change update detect conflicts crash trace bug auto-deps"
22
+
23
+ # Command-specific options
24
+ local generate_opts="--output"
25
+ local example_opts="--output"
26
+ local test_opts="--output --language --coverage-report --existing-tests --target-coverage --merge"
27
+ local preprocess_opts="--output --xml --recursive --double --exclude"
28
+ local fix_opts="--output-test --output-code --output-results --loop --verification-program --max-attempts --budget --auto-submit"
29
+ local split_opts="--output-sub --output-modified"
30
+ local change_opts="--output --csv"
31
+ local update_opts="--output --git"
32
+ local detect_opts="--output"
33
+ local conflicts_opts="--output"
34
+ local crash_opts="--output --output-program --loop --max-attempts --budget"
35
+ local trace_opts="--output"
36
+ local bug_opts="--output --language"
37
+ local auto_deps_opts="--output --csv --force-scan"
38
+
39
+ # Complete global options before command
40
+ if [[ $cword -eq 1 ]]; then
41
+ COMPREPLY=($(compgen -W "$global_opts $commands" -- "$cur"))
42
+ return
43
+ fi
44
+
45
+ # Complete command-specific options
46
+ case ${words[1]} in
47
+ generate)
48
+ _complete_files ".prompt"
49
+ COMPREPLY+=($(compgen -W "$generate_opts" -- "$cur"))
50
+ ;;
51
+ example)
52
+ _complete_files ".prompt"
53
+ _complete_files
54
+ COMPREPLY+=($(compgen -W "$example_opts" -- "$cur"))
55
+ ;;
56
+ test)
57
+ _complete_files ".prompt"
58
+ _complete_files
59
+ COMPREPLY+=($(compgen -W "$test_opts" -- "$cur"))
60
+ ;;
61
+ preprocess)
62
+ _complete_files ".prompt"
63
+ COMPREPLY+=($(compgen -W "$preprocess_opts" -- "$cur"))
64
+ ;;
65
+ fix)
66
+ _complete_files ".prompt"
67
+ _complete_files
68
+ _complete_files
69
+ _complete_files
70
+ COMPREPLY+=($(compgen -W "$fix_opts" -- "$cur"))
71
+ ;;
72
+ split)
73
+ _complete_files ".prompt"
74
+ _complete_files
75
+ _complete_files
76
+ COMPREPLY+=($(compgen -W "$split_opts" -- "$cur"))
77
+ ;;
78
+ change)
79
+ _complete_files ".prompt"
80
+ _complete_files
81
+ _complete_files
82
+ COMPREPLY+=($(compgen -W "$change_opts" -- "$cur"))
83
+ ;;
84
+ update)
85
+ _complete_files ".prompt"
86
+ _complete_files
87
+ _complete_files
88
+ COMPREPLY+=($(compgen -W "$update_opts" -- "$cur"))
89
+ ;;
90
+ detect)
91
+ _complete_files ".prompt"
92
+ _complete_files
93
+ COMPREPLY+=($(compgen -W "$detect_opts" -- "$cur"))
94
+ ;;
95
+ conflicts)
96
+ _complete_files ".prompt"
97
+ _complete_files
98
+ COMPREPLY+=($(compgen -W "$conflicts_opts" -- "$cur"))
99
+ ;;
100
+ crash)
101
+ _complete_files ".prompt"
102
+ _complete_files
103
+ _complete_files
104
+ _complete_files
105
+ COMPREPLY+=($(compgen -W "$crash_opts" -- "$cur"))
106
+ ;;
107
+ trace)
108
+ _complete_files ".prompt"
109
+ _complete_files
110
+ COMPREPLY+=($(compgen -W "$trace_opts" -- "$cur"))
111
+ ;;
112
+ bug)
113
+ _complete_files ".prompt"
114
+ _complete_files
115
+ _complete_files
116
+ _complete_files
117
+ _complete_files
118
+ COMPREPLY+=($(compgen -W "$bug_opts" -- "$cur"))
119
+ ;;
120
+ auto-deps)
121
+ _complete_files ".prompt"
122
+ COMPREPLY+=($(compgen -W "$auto_deps_opts" -- "$cur"))
123
+ ;;
124
+ *)
125
+ COMPREPLY=($(compgen -W "$global_opts" -- "$cur"))
126
+ ;;
127
+ esac
128
+ }
129
+
130
+ _complete_files() {
131
+ local ext=$1
132
+ local files
133
+ if [[ -n $ext ]]; then
134
+ files=$(compgen -f -X "!*$ext" -- "$cur")
135
+ else
136
+ files=$(compgen -f -- "$cur")
137
+ fi
138
+ COMPREPLY+=($(compgen -W "$files" -- "$cur"))
139
+ }
140
+
141
+ complete -F _pdd pdd
pdd/pdd_completion.zsh ADDED
@@ -0,0 +1,418 @@
1
+ #compdef pdd
2
+
3
+ ##
4
+ # ZSH Completion for PDD CLI (Prompt-Driven Development)
5
+ #
6
+ # Save this file as "pdd_completion.zsh" and source it from your ~/.zshrc:
7
+ # autoload -U compinit && compinit
8
+ # fpath=(/path/to/this/file $fpath)
9
+ # source /path/to/pdd_completion.zsh
10
+ #
11
+ # Or place it in a standard completion directory recognized by ZSH.
12
+ #
13
+ # After installation, typing:
14
+ # pdd <Tab>
15
+ # will offer completions for subcommands and options as described in the PDD CLI README.
16
+ ##
17
+
18
+ # 1) Define global options for all commands.
19
+ local -a _pdd_global_opts
20
+ _pdd_global_opts=(
21
+ '--force[Overwrite existing files without asking for confirmation.]'
22
+ '--strength[Set the strength of the AI model (0.0 to 1.0, default: 0.5)]:strength:(0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0)'
23
+ '--temperature[Set the temperature of the AI model (default: 0.0)]:temperature:(0.0 0.25 0.5 0.75 1.0)'
24
+ '--verbose[Increase output verbosity for more detailed information.]'
25
+ '--quiet[Decrease output verbosity (minimal information).]'
26
+ '--output-cost[Enable cost tracking and output a CSV file with usage details.]:filename:_files'
27
+ '--review-examples[Review and optionally exclude few-shot examples before command execution.]'
28
+ '--help[Show help message and exit.]'
29
+ '--version[Show version and exit.]'
30
+ )
31
+
32
+ ##
33
+ # Per-subcommand completion functions
34
+ ##
35
+
36
+ # generate
37
+ # Usage: pdd [GLOBAL OPTIONS] generate [OPTIONS] PROMPT_FILE
38
+ # Options:
39
+ # --output [LOCATION]
40
+ # Args:
41
+ # 1: PROMPT_FILE
42
+ _pdd_generate() {
43
+ _arguments -s \
44
+ $_pdd_global_opts \
45
+ '--output=[Specify where to save the generated code.]:filename:_files' \
46
+ '1:prompt-file:_files' \
47
+ '*:filename:_files'
48
+ }
49
+
50
+ # example
51
+ # Usage: pdd [GLOBAL OPTIONS] example [OPTIONS] PROMPT_FILE CODE_FILE
52
+ # Options:
53
+ # --output [LOCATION]
54
+ # Args:
55
+ # 1: PROMPT_FILE
56
+ # 2: CODE_FILE
57
+ _pdd_example() {
58
+ _arguments -s \
59
+ $_pdd_global_opts \
60
+ '--output=[Specify where to save the generated example code.]:filename:_files' \
61
+ '1:prompt-file:_files' \
62
+ '2:code-file:_files' \
63
+ '*:filename:_files'
64
+ }
65
+
66
+ # test
67
+ # Usage: pdd [GLOBAL OPTIONS] test [OPTIONS] PROMPT_FILE CODE_FILE
68
+ # Options:
69
+ # --output [LOCATION]
70
+ # --language [LANGUAGE]
71
+ # --coverage-report [PATH]
72
+ # --existing-tests [PATH]
73
+ # --target-coverage [FLOAT]
74
+ # --merge
75
+ # Args:
76
+ # 1: PROMPT_FILE
77
+ # 2: CODE_FILE
78
+ _pdd_test() {
79
+ _arguments -s \
80
+ $_pdd_global_opts \
81
+ '--output=[Specify where to save the generated test file.]:filename:_files' \
82
+ '--language=[Specify the programming language.]:string:_guard' \
83
+ '--coverage-report=[Path to a coverage report file.]:filename:_files' \
84
+ '--existing-tests=[Path to existing test file.]:filename:_files' \
85
+ '--target-coverage=[Desired code coverage percentage (default 90.0)]:float' \
86
+ '--merge[Merge new tests with existing test file when using --existing-tests.]' \
87
+ '1:prompt-file:_files' \
88
+ '2:code-file:_files' \
89
+ '*:filename:_files'
90
+ }
91
+
92
+ # preprocess
93
+ # Usage: pdd [GLOBAL OPTIONS] preprocess [OPTIONS] PROMPT_FILE
94
+ # Options:
95
+ # --output [LOCATION]
96
+ # --xml
97
+ # --recursive
98
+ # --double
99
+ # --exclude
100
+ # Arg:
101
+ # 1: PROMPT_FILE
102
+ _pdd_preprocess() {
103
+ _arguments -s \
104
+ $_pdd_global_opts \
105
+ '--output=[Where to save the preprocessed prompt file.]:filename:_files' \
106
+ '--xml[Insert XML delimiters instead of normal preprocessing.]' \
107
+ '--recursive[Recursively preprocess all prompt files in the prompt file.]' \
108
+ '--double[Double curly braces in prompt file(s).]' \
109
+ '--exclude=[List of keys to exclude from curly bracket doubling.]:string:_guard' \
110
+ '1:prompt-file:_files' \
111
+ '*:filename:_files'
112
+ }
113
+
114
+ # fix
115
+ # Usage: pdd [GLOBAL OPTIONS] fix [OPTIONS] PROMPT_FILE CODE_FILE UNIT_TEST_FILE ERROR_FILE
116
+ # Options:
117
+ # --output-test [LOCATION]
118
+ # --output-code [LOCATION]
119
+ # --output-results [LOCATION]
120
+ # --loop
121
+ # --verification-program [PATH]
122
+ # --max-attempts [INT]
123
+ # --budget [FLOAT]
124
+ # --auto-submit
125
+ # Args:
126
+ # 1: PROMPT_FILE
127
+ # 2: CODE_FILE
128
+ # 3: UNIT_TEST_FILE
129
+ # 4: ERROR_FILE
130
+ _pdd_fix() {
131
+ _arguments -s \
132
+ $_pdd_global_opts \
133
+ '--output-test=[Where to save the fixed unit test file.]:filename:_files' \
134
+ '--output-code=[Where to save the fixed code file.]:filename:_files' \
135
+ '--output-results=[Where to save the fix results.]:filename:_files' \
136
+ '--loop[Enable iterative fixing process.]' \
137
+ '--verification-program=[Path to a Python program that verifies code.]:filename:_files' \
138
+ '--max-attempts=[Maximum fix attempts (default 3)]:int' \
139
+ '--budget=[Maximum cost allowed for fixes (default 5.0)]:float' \
140
+ '--auto-submit[Automatically submit example if all tests pass in fix loop.]' \
141
+ '1:prompt-file:_files' \
142
+ '2:code-file:_files' \
143
+ '3:unit-test-file:_files' \
144
+ '4:error-file:_files' \
145
+ '*:filename:_files'
146
+ }
147
+
148
+ # split
149
+ # Usage: pdd [GLOBAL OPTIONS] split [OPTIONS] INPUT_PROMPT INPUT_CODE EXAMPLE_CODE
150
+ # Options:
151
+ # --output-sub [LOCATION]
152
+ # --output-modified [LOCATION]
153
+ # Args:
154
+ # 1: INPUT_PROMPT
155
+ # 2: INPUT_CODE
156
+ # 3: EXAMPLE_CODE
157
+ _pdd_split() {
158
+ _arguments -s \
159
+ $_pdd_global_opts \
160
+ '--output-sub=[Where to save the generated sub-prompt file.]:filename:_files' \
161
+ '--output-modified=[Where to save the modified prompt file.]:filename:_files' \
162
+ '1:prompt-file:_files' \
163
+ '2:code-file:_files' \
164
+ '3:example-code-file:_files' \
165
+ '*:filename:_files'
166
+ }
167
+
168
+ # change
169
+ # Usage: pdd [GLOBAL OPTIONS] change [OPTIONS] CHANGE_PROMPT_FILE INPUT_CODE [INPUT_PROMPT_FILE]
170
+ # Options:
171
+ # --output [LOCATION]
172
+ # --csv
173
+ # Args:
174
+ # 1: CHANGE_PROMPT_FILE
175
+ # 2: INPUT_CODE (filename or directory)
176
+ # 3: INPUT_PROMPT_FILE (optional)
177
+ _pdd_change() {
178
+ _arguments -s \
179
+ $_pdd_global_opts \
180
+ '--output=[Where to save the modified prompt file.]:filename:_files' \
181
+ '--csv[Use a CSV file for batch changes (columns: prompt_name, change_instructions).]' \
182
+ '1:change-prompt-file:_files' \
183
+ '2:input-code:_files' \
184
+ '3:optional-prompt-file:_files' \
185
+ '*:filename:_files'
186
+ }
187
+
188
+ # update
189
+ # Usage: pdd [GLOBAL OPTIONS] update [OPTIONS] INPUT_PROMPT_FILE MODIFIED_CODE_FILE [INPUT_CODE_FILE]
190
+ # Options:
191
+ # --output [LOCATION]
192
+ # --git
193
+ # Args:
194
+ # 1: INPUT_PROMPT_FILE
195
+ # 2: MODIFIED_CODE_FILE
196
+ # 3: INPUT_CODE_FILE (optional)
197
+ _pdd_update() {
198
+ _arguments -s \
199
+ $_pdd_global_opts \
200
+ '--output=[Where to save the updated prompt file.]:filename:_files' \
201
+ '--git[Use git history to find the original code file.]' \
202
+ '1:prompt-file:_files' \
203
+ '2:modified-code-file:_files' \
204
+ '3:original-code-file:_files' \
205
+ '*:filename:_files'
206
+ }
207
+
208
+ # detect
209
+ # Usage: pdd [GLOBAL OPTIONS] detect [OPTIONS] PROMPT_FILES... CHANGE_FILE
210
+ # Options:
211
+ # --output [LOCATION]
212
+ # Args:
213
+ # (multiple) PROMPT_FILES
214
+ # (final) CHANGE_FILE
215
+ _pdd_detect() {
216
+ _arguments -s \
217
+ $_pdd_global_opts \
218
+ '--output=[Where to save the CSV file with analysis results.]:filename:_files' \
219
+ '*:prompt-files:_files' \
220
+ ':change-file:_files'
221
+ }
222
+
223
+ # conflicts
224
+ # Usage: pdd [GLOBAL OPTIONS] conflicts [OPTIONS] PROMPT1 PROMPT2
225
+ # Options:
226
+ # --output [LOCATION]
227
+ # Args:
228
+ # 1: PROMPT1
229
+ # 2: PROMPT2
230
+ _pdd_conflicts() {
231
+ _arguments -s \
232
+ $_pdd_global_opts \
233
+ '--output=[Where to save the conflict analysis CSV file.]:filename:_files' \
234
+ '1:prompt-file1:_files' \
235
+ '2:prompt-file2:_files' \
236
+ '*:filename:_files'
237
+ }
238
+
239
+ # crash
240
+ # Usage: pdd [GLOBAL OPTIONS] crash [OPTIONS] PROMPT_FILE CODE_FILE PROGRAM_FILE ERROR_FILE
241
+ # Options:
242
+ # --output [LOCATION]
243
+ # --output-program [LOCATION]
244
+ # --loop
245
+ # --max-attempts [INT]
246
+ # --budget [FLOAT]
247
+ # Args:
248
+ # 1: PROMPT_FILE
249
+ # 2: CODE_FILE
250
+ # 3: PROGRAM_FILE
251
+ # 4: ERROR_FILE
252
+ _pdd_crash() {
253
+ _arguments -s \
254
+ $_pdd_global_opts \
255
+ '--output=[Where to save the fixed code file.]:filename:_files' \
256
+ '--output-program=[Where to save the fixed program file.]:filename:_files' \
257
+ '--loop[Enable iterative fixing process.]' \
258
+ '--max-attempts=[Maximum fix attempts.]:int' \
259
+ '--budget=[Maximum cost allowed for fixes (default 5.0)]:float' \
260
+ '1:prompt-file:_files' \
261
+ '2:code-file:_files' \
262
+ '3:program-file:_files' \
263
+ '4:error-file:_files' \
264
+ '*:filename:_files'
265
+ }
266
+
267
+ # trace
268
+ # Usage: pdd [GLOBAL OPTIONS] trace [OPTIONS] PROMPT_FILE CODE_FILE CODE_LINE
269
+ # Options:
270
+ # --output [LOCATION]
271
+ # Args:
272
+ # 1: PROMPT_FILE
273
+ # 2: CODE_FILE
274
+ # 3: CODE_LINE
275
+ _pdd_trace() {
276
+ _arguments -s \
277
+ $_pdd_global_opts \
278
+ '--output=[Where to save the trace analysis results.]:filename:_files' \
279
+ '1:prompt-file:_files' \
280
+ '2:code-file:_files' \
281
+ '3:code-line: ' \
282
+ '*:filename:_files'
283
+ }
284
+
285
+ # bug
286
+ # Usage: pdd [GLOBAL OPTIONS] bug [OPTIONS] PROMPT_FILE CODE_FILE PROGRAM_FILE CURRENT_OUTPUT_FILE DESIRED_OUTPUT_FILE
287
+ # Options:
288
+ # --output [LOCATION]
289
+ # --language [LANGUAGE]
290
+ # Args:
291
+ # 1: PROMPT_FILE
292
+ # 2: CODE_FILE
293
+ # 3: PROGRAM_FILE
294
+ # 4: CURRENT_OUTPUT_FILE
295
+ # 5: DESIRED_OUTPUT_FILE
296
+ _pdd_bug() {
297
+ _arguments -s \
298
+ $_pdd_global_opts \
299
+ '--output=[Where to save the generated unit test.]:filename:_files' \
300
+ '--language=[Programming language for the unit test (default: Python)]:string:_guard' \
301
+ '1:prompt-file:_files' \
302
+ '2:code-file:_files' \
303
+ '3:program-file:_files' \
304
+ '4:current-output-file:_files' \
305
+ '5:desired-output-file:_files' \
306
+ '*:filename:_files'
307
+ }
308
+
309
+ # auto-deps
310
+ # Usage: pdd [GLOBAL OPTIONS] auto-deps [OPTIONS] PROMPT_FILE DIRECTORY_PATH
311
+ # Options:
312
+ # --output [LOCATION]
313
+ # --csv [FILENAME]
314
+ # --force-scan
315
+ # Args:
316
+ # 1: PROMPT_FILE
317
+ # 2: DIRECTORY_PATH
318
+ _pdd_auto_deps() {
319
+ _arguments -s \
320
+ $_pdd_global_opts \
321
+ '--output=[Where to save the modified prompt file with dependencies inserted.]:filename:_files' \
322
+ '--csv=[CSV file for dependency info (default: project_dependencies.csv).]:filename:_files' \
323
+ '--force-scan[Force rescanning of all potential dependency files.]' \
324
+ '1:prompt-file:_files' \
325
+ '2:directory:_files -/' \
326
+ '*:filename:_files'
327
+ }
328
+
329
+ ##
330
+ # Main PDD completion dispatcher
331
+ ##
332
+ _pdd() {
333
+ local context="$curcontext" state line
334
+ typeset -A opt_args
335
+
336
+ # List of known subcommands with descriptions
337
+ local -a _pdd_subcommands
338
+ _pdd_subcommands=(
339
+ 'generate:Create runnable code from a prompt file'
340
+ 'example:Create an example file from an existing code file and the prompt'
341
+ 'test:Generate or enhance unit tests for a given code file'
342
+ 'preprocess:Preprocess prompt files and save the results'
343
+ 'fix:Fix errors in code and unit tests'
344
+ 'split:Split large complex prompt files'
345
+ 'change:Modify an input prompt file based on change instructions'
346
+ 'update:Update the original prompt file based on modified code'
347
+ 'detect:Analyze prompt files and a change description to see which need updating'
348
+ 'conflicts:Analyze two prompt files for conflicts'
349
+ 'crash:Fix errors in a code module and its calling program'
350
+ 'trace:Find the prompt file line number associated with a code line'
351
+ 'bug:Generate a unit test based on incorrect vs desired outputs'
352
+ 'auto-deps:Analyze a prompt file and directory for needed dependencies'
353
+ )
354
+
355
+ # If there's no subcommand yet (i.e., user typed only "pdd " or "pdd -<Tab>"), offer global opts or subcommands.
356
+ if (( CURRENT == 2 )); then
357
+ _arguments -s \
358
+ $_pdd_global_opts \
359
+ '1: :->subcmds' && return 0
360
+ # Show subcommands if user hasn't typed an option that consumes the argument.
361
+ _describe -t subcommands 'pdd subcommand' _pdd_subcommands
362
+ return
363
+ fi
364
+
365
+ # If the user typed a known subcommand, dispatch to that subcommand's completion function.
366
+ case $words[2] in
367
+ generate)
368
+ _pdd_generate
369
+ ;;
370
+ example)
371
+ _pdd_example
372
+ ;;
373
+ test)
374
+ _pdd_test
375
+ ;;
376
+ preprocess)
377
+ _pdd_preprocess
378
+ ;;
379
+ fix)
380
+ _pdd_fix
381
+ ;;
382
+ split)
383
+ _pdd_split
384
+ ;;
385
+ change)
386
+ _pdd_change
387
+ ;;
388
+ update)
389
+ _pdd_update
390
+ ;;
391
+ detect)
392
+ _pdd_detect
393
+ ;;
394
+ conflicts)
395
+ _pdd_conflicts
396
+ ;;
397
+ crash)
398
+ _pdd_crash
399
+ ;;
400
+ trace)
401
+ _pdd_trace
402
+ ;;
403
+ bug)
404
+ _pdd_bug
405
+ ;;
406
+ auto-deps)
407
+ _pdd_auto_deps
408
+ ;;
409
+ # If the subcommand is unknown or not typed yet, fall back to showing the list of subcommands.
410
+ *)
411
+ _describe -t subcommands 'pdd subcommand' _pdd_subcommands
412
+ ;;
413
+ esac
414
+ }
415
+
416
+ compdef _pdd pdd
417
+
418
+ # End of pdd_completion.zsh