claude-dev-cli 0.11.0__tar.gz → 0.12.0__tar.gz

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 claude-dev-cli might be problematic. Click here for more details.

Files changed (46) hide show
  1. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/PKG-INFO +72 -5
  2. claude_dev_cli-0.11.0/src/claude_dev_cli.egg-info/PKG-INFO → claude_dev_cli-0.12.0/README.md +64 -48
  3. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/pyproject.toml +9 -1
  4. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/__init__.py +1 -1
  5. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/cli.py +309 -0
  6. claude_dev_cli-0.12.0/src/claude_dev_cli/input_sources.py +231 -0
  7. claude_dev_cli-0.11.0/README.md → claude_dev_cli-0.12.0/src/claude_dev_cli.egg-info/PKG-INFO +115 -4
  8. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli.egg-info/SOURCES.txt +2 -0
  9. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli.egg-info/requires.txt +8 -0
  10. claude_dev_cli-0.12.0/tests/test_input_sources.py +225 -0
  11. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/LICENSE +0 -0
  12. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/MANIFEST.in +0 -0
  13. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/setup.cfg +0 -0
  14. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/commands.py +0 -0
  15. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/config.py +0 -0
  16. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/context.py +0 -0
  17. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/core.py +0 -0
  18. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/history.py +0 -0
  19. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/path_utils.py +0 -0
  20. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/plugins/__init__.py +0 -0
  21. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/plugins/base.py +0 -0
  22. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/plugins/diff_editor/__init__.py +0 -0
  23. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/plugins/diff_editor/plugin.py +0 -0
  24. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/plugins/diff_editor/viewer.py +0 -0
  25. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/secure_storage.py +0 -0
  26. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/template_manager.py +0 -0
  27. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/templates.py +0 -0
  28. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/toon_utils.py +0 -0
  29. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/usage.py +0 -0
  30. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/warp_integration.py +0 -0
  31. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli/workflows.py +0 -0
  32. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli.egg-info/dependency_links.txt +0 -0
  33. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli.egg-info/entry_points.txt +0 -0
  34. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/src/claude_dev_cli.egg-info/top_level.txt +0 -0
  35. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_cli.py +0 -0
  36. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_commands.py +0 -0
  37. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_config.py +0 -0
  38. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_context.py +0 -0
  39. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_core.py +0 -0
  40. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_diff_editor.py +0 -0
  41. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_history.py +0 -0
  42. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_path_utils.py +0 -0
  43. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_secure_storage.py +0 -0
  44. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_template_manager.py +0 -0
  45. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_toon_utils.py +0 -0
  46. {claude_dev_cli-0.11.0 → claude_dev_cli-0.12.0}/tests/test_usage.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: claude-dev-cli
3
- Version: 0.11.0
3
+ Version: 0.12.0
4
4
  Summary: A powerful CLI tool for developers using Claude AI with multi-API routing, test generation, code review, and usage tracking
5
5
  Author-email: Julio <thinmanj@users.noreply.github.com>
6
6
  License: MIT
@@ -33,6 +33,10 @@ Provides-Extra: toon
33
33
  Requires-Dist: toon-format>=0.1.0; extra == "toon"
34
34
  Provides-Extra: plugins
35
35
  Requires-Dist: pygments>=2.0.0; extra == "plugins"
36
+ Provides-Extra: generation
37
+ Requires-Dist: pypdf>=3.0.0; extra == "generation"
38
+ Requires-Dist: requests>=2.28.0; extra == "generation"
39
+ Requires-Dist: beautifulsoup4>=4.0.0; extra == "generation"
36
40
  Provides-Extra: dev
37
41
  Requires-Dist: pytest>=7.0.0; extra == "dev"
38
42
  Requires-Dist: black>=23.0.0; extra == "dev"
@@ -40,13 +44,16 @@ Requires-Dist: ruff>=0.1.0; extra == "dev"
40
44
  Requires-Dist: mypy>=1.0.0; extra == "dev"
41
45
  Requires-Dist: toon-format>=0.1.0; extra == "dev"
42
46
  Requires-Dist: pygments>=2.0.0; extra == "dev"
47
+ Requires-Dist: pypdf>=3.0.0; extra == "dev"
48
+ Requires-Dist: requests>=2.28.0; extra == "dev"
49
+ Requires-Dist: beautifulsoup4>=4.0.0; extra == "dev"
43
50
  Dynamic: license-file
44
51
 
45
52
  # Claude Dev CLI
46
53
 
47
54
  [![PyPI version](https://badge.fury.io/py/claude-dev-cli.svg)](https://badge.fury.io/py/claude-dev-cli)
48
55
  [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
49
- [![Tests](https://img.shields.io/badge/tests-285%20passing-brightgreen.svg)](https://github.com/thinmanj/claude-dev-cli)
56
+ [![Tests](https://img.shields.io/badge/tests-303%20passing-brightgreen.svg)](https://github.com/thinmanj/claude-dev-cli)
50
57
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
51
58
  [![Homebrew](https://img.shields.io/badge/homebrew-available-orange.svg)](https://github.com/thinmanj/homebrew-tap)
52
59
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
@@ -72,6 +79,26 @@ A powerful command-line tool for developers using Claude AI with multi-API routi
72
79
  - `smart`: Claude Sonnet 4 ($3.00/$15.00 per Mtok) - default
73
80
  - `powerful`: Claude Opus 4 ($15.00/$75.00 per Mtok)
74
81
 
82
+ ### 🚀 Code Generation (v0.12.0+)
83
+ - **Generate Code from Specs**: Create new code from descriptions, files, PDFs, or URLs
84
+ - `cdc generate code --description "REST API client" -o client.py`
85
+ - Multiple input sources: text, files (.md, .txt), PDFs, URLs
86
+ - Auto-detects target language from file extension
87
+ - Interactive refinement mode
88
+ - **Add Features to Projects**: Analyze existing code and generate implementation plans
89
+ - `cdc generate feature --description "Add authentication" src/`
90
+ - Multi-file analysis and modification
91
+ - Preview mode to review changes before applying
92
+ - Supports same input sources as code generation
93
+ - **Multiple Input Sources**:
94
+ - `--description TEXT`: Inline specification
95
+ - `-f/--file PATH`: Read from file
96
+ - `--pdf PATH`: Extract from PDF
97
+ - `--url URL`: Fetch from URL
98
+ - **Optional Dependencies**: Install with `pip install 'claude-dev-cli[generation]'`
99
+ - Enables PDF and URL support
100
+ - Graceful fallback if not installed
101
+
75
102
  ### 📁 Multi-File Support (v0.11.0+)
76
103
  - **Batch Processing**: Review, refactor, test, or document multiple files at once
77
104
  - **Directory Support**: Process all code files in a directory with `--max-files` limit
@@ -149,8 +176,14 @@ brew install thinmanj/tap/claude-dev-cli
149
176
  # Basic installation
150
177
  pip install claude-dev-cli
151
178
 
179
+ # With code generation support (PDF & URL input)
180
+ pip install claude-dev-cli[generation]
181
+
152
182
  # With TOON support (30-60% token reduction)
153
183
  pip install claude-dev-cli[toon]
184
+
185
+ # With all optional features
186
+ pip install claude-dev-cli[generation,toon]
154
187
  ```
155
188
 
156
189
  ### Via pipx (Recommended for CLI tools)
@@ -159,8 +192,14 @@ pip install claude-dev-cli[toon]
159
192
  # Isolated installation
160
193
  pipx install claude-dev-cli
161
194
 
195
+ # With code generation support
196
+ pipx install claude-dev-cli[generation]
197
+
162
198
  # With TOON support
163
199
  pipx install claude-dev-cli[toon]
200
+
201
+ # With all optional features
202
+ pipx install claude-dev-cli[generation,toon]
164
203
  ```
165
204
 
166
205
  ## Quick Start
@@ -242,7 +281,35 @@ cdc review -m powerful complex_file.py # More thorough review
242
281
  cdc generate tests -m smart mymodule.py # Balanced approach
243
282
  ```
244
283
 
245
- ### 3. Developer Commands
284
+ ### 3. Code Generation Commands (NEW in v0.12.0)
285
+
286
+ ```bash
287
+ # Generate code from specification
288
+ cdc generate code --description "REST API client for weather data" -o client.py
289
+ cdc generate code --file spec.md -o implementation.go
290
+ cdc generate code --pdf requirements.pdf -o app.js
291
+ cdc generate code --url https://example.com/api-spec -o service.py
292
+
293
+ # Generate code with interactive refinement
294
+ cdc generate code --description "Database ORM" -o orm.py --interactive
295
+
296
+ # Generate code with project context
297
+ cdc generate code --file spec.md -o service.py --auto-context
298
+
299
+ # Add features to existing project
300
+ cdc generate feature --description "Add user authentication with JWT" src/
301
+ cdc generate feature --file feature-spec.md
302
+ cdc generate feature --pdf product-requirements.pdf --preview
303
+ cdc generate feature --url https://example.com/feature-spec
304
+
305
+ # Preview feature changes before applying
306
+ cdc generate feature --description "Add caching layer" src/ --preview
307
+
308
+ # Interactive feature implementation
309
+ cdc generate feature --description "Add logging" src/ --interactive
310
+ ```
311
+
312
+ ### 4. Developer Commands
246
313
 
247
314
  ```bash
248
315
  # Generate tests (single file)
@@ -316,7 +383,7 @@ git add .
316
383
  cdc git commit --auto-context
317
384
  ```
318
385
 
319
- ### 4. Context-Aware Operations (v0.8.0+)
386
+ ### 5. Context-Aware Operations (v0.8.0+)
320
387
 
321
388
  ```bash
322
389
  # Auto-context includes: git info, dependencies, related files
@@ -345,7 +412,7 @@ cdc refactor app.py --auto-context
345
412
  # Automatically includes imported modules and dependencies
346
413
  ```
347
414
 
348
- ### 5. Custom Templates
415
+ ### 6. Custom Templates
349
416
 
350
417
  ```bash
351
418
  # List all templates (built-in and user)
@@ -1,52 +1,8 @@
1
- Metadata-Version: 2.4
2
- Name: claude-dev-cli
3
- Version: 0.11.0
4
- Summary: A powerful CLI tool for developers using Claude AI with multi-API routing, test generation, code review, and usage tracking
5
- Author-email: Julio <thinmanj@users.noreply.github.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/thinmanj/claude-dev-cli
8
- Project-URL: Repository, https://github.com/thinmanj/claude-dev-cli
9
- Project-URL: Issues, https://github.com/thinmanj/claude-dev-cli/issues
10
- Keywords: claude,ai,cli,development,testing,code-review,anthropic
11
- Classifier: Development Status :: 4 - Beta
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Topic :: Software Development
20
- Classifier: Topic :: Software Development :: Code Generators
21
- Classifier: Topic :: Software Development :: Testing
22
- Requires-Python: >=3.9
23
- Description-Content-Type: text/markdown
24
- License-File: LICENSE
25
- Requires-Dist: anthropic>=0.18.0
26
- Requires-Dist: click>=8.1.0
27
- Requires-Dist: rich>=13.0.0
28
- Requires-Dist: pydantic>=2.0.0
29
- Requires-Dist: keyring>=24.0.0
30
- Requires-Dist: cryptography>=41.0.0
31
- Requires-Dist: pyyaml>=6.0.0
32
- Provides-Extra: toon
33
- Requires-Dist: toon-format>=0.1.0; extra == "toon"
34
- Provides-Extra: plugins
35
- Requires-Dist: pygments>=2.0.0; extra == "plugins"
36
- Provides-Extra: dev
37
- Requires-Dist: pytest>=7.0.0; extra == "dev"
38
- Requires-Dist: black>=23.0.0; extra == "dev"
39
- Requires-Dist: ruff>=0.1.0; extra == "dev"
40
- Requires-Dist: mypy>=1.0.0; extra == "dev"
41
- Requires-Dist: toon-format>=0.1.0; extra == "dev"
42
- Requires-Dist: pygments>=2.0.0; extra == "dev"
43
- Dynamic: license-file
44
-
45
1
  # Claude Dev CLI
46
2
 
47
3
  [![PyPI version](https://badge.fury.io/py/claude-dev-cli.svg)](https://badge.fury.io/py/claude-dev-cli)
48
4
  [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
49
- [![Tests](https://img.shields.io/badge/tests-285%20passing-brightgreen.svg)](https://github.com/thinmanj/claude-dev-cli)
5
+ [![Tests](https://img.shields.io/badge/tests-303%20passing-brightgreen.svg)](https://github.com/thinmanj/claude-dev-cli)
50
6
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
51
7
  [![Homebrew](https://img.shields.io/badge/homebrew-available-orange.svg)](https://github.com/thinmanj/homebrew-tap)
52
8
  [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
@@ -72,6 +28,26 @@ A powerful command-line tool for developers using Claude AI with multi-API routi
72
28
  - `smart`: Claude Sonnet 4 ($3.00/$15.00 per Mtok) - default
73
29
  - `powerful`: Claude Opus 4 ($15.00/$75.00 per Mtok)
74
30
 
31
+ ### 🚀 Code Generation (v0.12.0+)
32
+ - **Generate Code from Specs**: Create new code from descriptions, files, PDFs, or URLs
33
+ - `cdc generate code --description "REST API client" -o client.py`
34
+ - Multiple input sources: text, files (.md, .txt), PDFs, URLs
35
+ - Auto-detects target language from file extension
36
+ - Interactive refinement mode
37
+ - **Add Features to Projects**: Analyze existing code and generate implementation plans
38
+ - `cdc generate feature --description "Add authentication" src/`
39
+ - Multi-file analysis and modification
40
+ - Preview mode to review changes before applying
41
+ - Supports same input sources as code generation
42
+ - **Multiple Input Sources**:
43
+ - `--description TEXT`: Inline specification
44
+ - `-f/--file PATH`: Read from file
45
+ - `--pdf PATH`: Extract from PDF
46
+ - `--url URL`: Fetch from URL
47
+ - **Optional Dependencies**: Install with `pip install 'claude-dev-cli[generation]'`
48
+ - Enables PDF and URL support
49
+ - Graceful fallback if not installed
50
+
75
51
  ### 📁 Multi-File Support (v0.11.0+)
76
52
  - **Batch Processing**: Review, refactor, test, or document multiple files at once
77
53
  - **Directory Support**: Process all code files in a directory with `--max-files` limit
@@ -149,8 +125,14 @@ brew install thinmanj/tap/claude-dev-cli
149
125
  # Basic installation
150
126
  pip install claude-dev-cli
151
127
 
128
+ # With code generation support (PDF & URL input)
129
+ pip install claude-dev-cli[generation]
130
+
152
131
  # With TOON support (30-60% token reduction)
153
132
  pip install claude-dev-cli[toon]
133
+
134
+ # With all optional features
135
+ pip install claude-dev-cli[generation,toon]
154
136
  ```
155
137
 
156
138
  ### Via pipx (Recommended for CLI tools)
@@ -159,8 +141,14 @@ pip install claude-dev-cli[toon]
159
141
  # Isolated installation
160
142
  pipx install claude-dev-cli
161
143
 
144
+ # With code generation support
145
+ pipx install claude-dev-cli[generation]
146
+
162
147
  # With TOON support
163
148
  pipx install claude-dev-cli[toon]
149
+
150
+ # With all optional features
151
+ pipx install claude-dev-cli[generation,toon]
164
152
  ```
165
153
 
166
154
  ## Quick Start
@@ -242,7 +230,35 @@ cdc review -m powerful complex_file.py # More thorough review
242
230
  cdc generate tests -m smart mymodule.py # Balanced approach
243
231
  ```
244
232
 
245
- ### 3. Developer Commands
233
+ ### 3. Code Generation Commands (NEW in v0.12.0)
234
+
235
+ ```bash
236
+ # Generate code from specification
237
+ cdc generate code --description "REST API client for weather data" -o client.py
238
+ cdc generate code --file spec.md -o implementation.go
239
+ cdc generate code --pdf requirements.pdf -o app.js
240
+ cdc generate code --url https://example.com/api-spec -o service.py
241
+
242
+ # Generate code with interactive refinement
243
+ cdc generate code --description "Database ORM" -o orm.py --interactive
244
+
245
+ # Generate code with project context
246
+ cdc generate code --file spec.md -o service.py --auto-context
247
+
248
+ # Add features to existing project
249
+ cdc generate feature --description "Add user authentication with JWT" src/
250
+ cdc generate feature --file feature-spec.md
251
+ cdc generate feature --pdf product-requirements.pdf --preview
252
+ cdc generate feature --url https://example.com/feature-spec
253
+
254
+ # Preview feature changes before applying
255
+ cdc generate feature --description "Add caching layer" src/ --preview
256
+
257
+ # Interactive feature implementation
258
+ cdc generate feature --description "Add logging" src/ --interactive
259
+ ```
260
+
261
+ ### 4. Developer Commands
246
262
 
247
263
  ```bash
248
264
  # Generate tests (single file)
@@ -316,7 +332,7 @@ git add .
316
332
  cdc git commit --auto-context
317
333
  ```
318
334
 
319
- ### 4. Context-Aware Operations (v0.8.0+)
335
+ ### 5. Context-Aware Operations (v0.8.0+)
320
336
 
321
337
  ```bash
322
338
  # Auto-context includes: git info, dependencies, related files
@@ -345,7 +361,7 @@ cdc refactor app.py --auto-context
345
361
  # Automatically includes imported modules and dependencies
346
362
  ```
347
363
 
348
- ### 5. Custom Templates
364
+ ### 6. Custom Templates
349
365
 
350
366
  ```bash
351
367
  # List all templates (built-in and user)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "claude-dev-cli"
7
- version = "0.11.0"
7
+ version = "0.12.0"
8
8
  description = "A powerful CLI tool for developers using Claude AI with multi-API routing, test generation, code review, and usage tracking"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -44,6 +44,11 @@ toon = [
44
44
  plugins = [
45
45
  "pygments>=2.0.0",
46
46
  ]
47
+ generation = [
48
+ "pypdf>=3.0.0",
49
+ "requests>=2.28.0",
50
+ "beautifulsoup4>=4.0.0",
51
+ ]
47
52
  dev = [
48
53
  "pytest>=7.0.0",
49
54
  "black>=23.0.0",
@@ -51,6 +56,9 @@ dev = [
51
56
  "mypy>=1.0.0",
52
57
  "toon-format>=0.1.0",
53
58
  "pygments>=2.0.0",
59
+ "pypdf>=3.0.0",
60
+ "requests>=2.28.0",
61
+ "beautifulsoup4>=4.0.0",
54
62
  ]
55
63
 
56
64
  [project.urls]
@@ -9,7 +9,7 @@ Features:
9
9
  - Interactive and single-shot modes
10
10
  """
11
11
 
12
- __version__ = "0.11.0"
12
+ __version__ = "0.12.0"
13
13
  __author__ = "Julio"
14
14
  __license__ = "MIT"
15
15
 
@@ -1060,6 +1060,315 @@ def gen_docs(
1060
1060
  sys.exit(1)
1061
1061
 
1062
1062
 
1063
+ @generate.command('code')
1064
+ @click.option('--description', help='Inline code specification')
1065
+ @click.option('-f', '--file', 'spec_file', type=click.Path(exists=True), help='Read specification from file')
1066
+ @click.option('--pdf', type=click.Path(exists=True), help='Read specification from PDF')
1067
+ @click.option('--url', help='Fetch specification from URL')
1068
+ @click.option('-o', '--output', required=True, type=click.Path(), help='Output file path (required)')
1069
+ @click.option('--language', help='Target language (auto-detected from output extension)')
1070
+ @click.option('-m', '--model', help='Model profile to use')
1071
+ @click.option('-a', '--api', help='API config to use')
1072
+ @click.option('-i', '--interactive', is_flag=True, help='Interactive refinement mode')
1073
+ @click.option('--auto-context', is_flag=True, help='Include project context')
1074
+ @click.pass_context
1075
+ def gen_code(
1076
+ ctx: click.Context,
1077
+ description: Optional[str],
1078
+ spec_file: Optional[str],
1079
+ pdf: Optional[str],
1080
+ url: Optional[str],
1081
+ output: str,
1082
+ language: Optional[str],
1083
+ model: Optional[str],
1084
+ api: Optional[str],
1085
+ interactive: bool,
1086
+ auto_context: bool
1087
+ ) -> None:
1088
+ """Generate code from a specification.
1089
+
1090
+ Reads specification from text, file, PDF, or URL and generates complete code.
1091
+
1092
+ Examples:
1093
+ cdc generate code --description "REST API client" -o client.py
1094
+ cdc generate code --file spec.md -o implementation.go
1095
+ cdc generate code --pdf requirements.pdf -o app.js
1096
+ cdc generate code --url https://example.com/spec -o service.py
1097
+ """
1098
+ console = ctx.obj['console']
1099
+ from claude_dev_cli.input_sources import get_input_content
1100
+ from pathlib import Path
1101
+
1102
+ try:
1103
+ # Get specification content
1104
+ spec_content, source_desc = get_input_content(
1105
+ description=description,
1106
+ file_path=spec_file,
1107
+ pdf_path=pdf,
1108
+ url=url,
1109
+ console=console
1110
+ )
1111
+
1112
+ # Detect language from output extension if not specified
1113
+ if not language:
1114
+ ext = Path(output).suffix.lstrip('.')
1115
+ language_map = {
1116
+ 'py': 'Python',
1117
+ 'js': 'JavaScript',
1118
+ 'ts': 'TypeScript',
1119
+ 'go': 'Go',
1120
+ 'rs': 'Rust',
1121
+ 'java': 'Java',
1122
+ 'cpp': 'C++',
1123
+ 'c': 'C',
1124
+ 'cs': 'C#',
1125
+ 'rb': 'Ruby',
1126
+ 'php': 'PHP',
1127
+ 'swift': 'Swift',
1128
+ 'kt': 'Kotlin',
1129
+ }
1130
+ language = language_map.get(ext, ext.upper() if ext else None)
1131
+
1132
+ console.print(f"[cyan]Generating code from:[/cyan] {source_desc}")
1133
+ if language:
1134
+ console.print(f"[cyan]Target language:[/cyan] {language}")
1135
+ console.print(f"[cyan]Output:[/cyan] {output}\n")
1136
+
1137
+ # Build prompt
1138
+ prompt = f"Specification:\n\n{spec_content}\n\n"
1139
+ if language:
1140
+ prompt += f"Generate complete, production-ready {language} code that implements this specification. "
1141
+ else:
1142
+ prompt += "Generate complete, production-ready code that implements this specification. "
1143
+ prompt += "Include proper error handling, documentation, and best practices."
1144
+
1145
+ # Add context if requested
1146
+ if auto_context:
1147
+ from claude_dev_cli.context import ContextGatherer
1148
+
1149
+ with console.status("[bold blue]Gathering project context..."):
1150
+ gatherer = ContextGatherer()
1151
+ # Gather context from current directory
1152
+ context = gatherer.gather_for_file(".", include_git=True)
1153
+ context_info = context.format_for_prompt()
1154
+
1155
+ console.print("[dim]✓ Context gathered[/dim]")
1156
+ prompt = f"{context_info}\n\n{prompt}"
1157
+
1158
+ # Generate code
1159
+ with console.status(f"[bold blue]Generating code..."):
1160
+ client = ClaudeClient(api_config_name=api, model=model)
1161
+ result = client.call(prompt)
1162
+
1163
+ # Interactive refinement
1164
+ if interactive:
1165
+ console.print("\n[bold]Initial Code:[/bold]\n")
1166
+ console.print(result)
1167
+
1168
+ client = ClaudeClient(api_config_name=api, model=model)
1169
+ conversation_context = [result]
1170
+
1171
+ while True:
1172
+ console.print("\n[dim]Commands: 'save' to save and exit, 'exit' to discard, or ask for changes[/dim]")
1173
+ user_input = console.input("[cyan]You:[/cyan] ").strip()
1174
+
1175
+ if user_input.lower() == 'exit':
1176
+ console.print("[yellow]Discarded changes[/yellow]")
1177
+ return
1178
+
1179
+ if user_input.lower() == 'save':
1180
+ result = conversation_context[-1]
1181
+ break
1182
+
1183
+ if not user_input:
1184
+ continue
1185
+
1186
+ # Get refinement
1187
+ refinement_prompt = f"Previous code:\n\n{conversation_context[-1]}\n\nUser request: {user_input}\n\nProvide the updated code."
1188
+
1189
+ console.print("\n[bold green]Claude:[/bold green] ", end='')
1190
+ response_parts = []
1191
+ for chunk in client.call_streaming(refinement_prompt):
1192
+ console.print(chunk, end='')
1193
+ response_parts.append(chunk)
1194
+ console.print()
1195
+
1196
+ result = ''.join(response_parts)
1197
+ conversation_context.append(result)
1198
+
1199
+ # Save output
1200
+ Path(output).write_text(result)
1201
+ console.print(f"\n[green]✓[/green] Code saved to: {output}")
1202
+
1203
+ except Exception as e:
1204
+ console.print(f"[red]Error: {e}[/red]")
1205
+ sys.exit(1)
1206
+
1207
+
1208
+ @generate.command('feature')
1209
+ @click.argument('paths', nargs=-1, type=click.Path(exists=True))
1210
+ @click.option('--description', help='Inline feature specification')
1211
+ @click.option('-f', '--file', 'spec_file', type=click.Path(exists=True), help='Read specification from file')
1212
+ @click.option('--pdf', type=click.Path(exists=True), help='Read specification from PDF')
1213
+ @click.option('--url', help='Fetch specification from URL')
1214
+ @click.option('--max-files', type=int, default=10, help='Maximum files to modify (default: 10)')
1215
+ @click.option('-m', '--model', help='Model profile to use')
1216
+ @click.option('-a', '--api', help='API config to use')
1217
+ @click.option('-i', '--interactive', is_flag=True, help='Interactive refinement mode')
1218
+ @click.option('--auto-context', is_flag=True, help='Include project context')
1219
+ @click.option('--preview', is_flag=True, help='Preview changes without applying')
1220
+ @click.pass_context
1221
+ def gen_feature(
1222
+ ctx: click.Context,
1223
+ paths: tuple,
1224
+ description: Optional[str],
1225
+ spec_file: Optional[str],
1226
+ pdf: Optional[str],
1227
+ url: Optional[str],
1228
+ max_files: int,
1229
+ model: Optional[str],
1230
+ api: Optional[str],
1231
+ interactive: bool,
1232
+ auto_context: bool,
1233
+ preview: bool
1234
+ ) -> None:
1235
+ """Generate code to add a feature to existing project.
1236
+
1237
+ Analyzes existing code and generates changes to implement a feature.
1238
+
1239
+ Examples:
1240
+ cdc generate feature --description "Add authentication" src/
1241
+ cdc generate feature --file feature-spec.md
1242
+ cdc generate feature --pdf requirements.pdf --preview
1243
+ cdc generate feature --url https://example.com/spec src/
1244
+ """
1245
+ console = ctx.obj['console']
1246
+ from claude_dev_cli.input_sources import get_input_content
1247
+ from claude_dev_cli.path_utils import expand_paths, auto_detect_files
1248
+
1249
+ try:
1250
+ # Get feature specification
1251
+ spec_content, source_desc = get_input_content(
1252
+ description=description,
1253
+ file_path=spec_file,
1254
+ pdf_path=pdf,
1255
+ url=url,
1256
+ console=console
1257
+ )
1258
+
1259
+ # Determine files to analyze
1260
+ if paths:
1261
+ files = expand_paths(list(paths), max_files=max_files)
1262
+ else:
1263
+ files = auto_detect_files()
1264
+ if files:
1265
+ console.print(f"[dim]Auto-detected {len(files)} file(s) from project[/dim]")
1266
+
1267
+ if not files:
1268
+ console.print("[yellow]No files found. Specify paths or run in a project directory.[/yellow]")
1269
+ return
1270
+
1271
+ console.print(f"[cyan]Feature specification from:[/cyan] {source_desc}")
1272
+ console.print(f"[cyan]Analyzing:[/cyan] {len(files)} file(s)\n")
1273
+
1274
+ # Show files
1275
+ if len(files) > 1:
1276
+ console.print(f"[bold]Files to analyze:[/bold]")
1277
+ for f in files[:5]:
1278
+ console.print(f" • {f}")
1279
+ if len(files) > 5:
1280
+ console.print(f" ... and {len(files) - 5} more")
1281
+ console.print()
1282
+
1283
+ # Build codebase content
1284
+ codebase_content = ""
1285
+ for file_path in files:
1286
+ try:
1287
+ with open(file_path, 'r') as f:
1288
+ content = f.read()
1289
+ codebase_content += f"\n\n## File: {file_path}\n\n```\n{content}\n```\n"
1290
+ except Exception as e:
1291
+ console.print(f"[yellow]Warning: Could not read {file_path}: {e}[/yellow]")
1292
+
1293
+ # Build prompt
1294
+ prompt = f"Feature Specification:\n\n{spec_content}\n\n"
1295
+ prompt += f"Existing Codebase:{codebase_content}\n\n"
1296
+ prompt += "Analyze the existing code and provide:\n"
1297
+ prompt += "1. Implementation plan for the feature\n"
1298
+ prompt += "2. List of files to modify or create\n"
1299
+ prompt += "3. Complete code changes (diffs or new files)\n"
1300
+ prompt += "4. Any necessary setup or configuration changes\n\n"
1301
+ prompt += "Be specific and provide complete, working code."
1302
+
1303
+ # Add context if requested
1304
+ if auto_context:
1305
+ from claude_dev_cli.context import ContextGatherer
1306
+
1307
+ with console.status("[bold blue]Gathering project context..."):
1308
+ gatherer = ContextGatherer()
1309
+ context = gatherer.gather_for_file(files[0], include_git=True)
1310
+ context_info = context.format_for_prompt()
1311
+
1312
+ console.print("[dim]✓ Context gathered[/dim]")
1313
+ prompt = f"{context_info}\n\n{prompt}"
1314
+
1315
+ # Generate feature implementation
1316
+ with console.status(f"[bold blue]Analyzing codebase and generating feature implementation..."):
1317
+ client = ClaudeClient(api_config_name=api, model=model)
1318
+ result = client.call(prompt)
1319
+
1320
+ # Show result
1321
+ from rich.markdown import Markdown
1322
+ md = Markdown(result)
1323
+ console.print(md)
1324
+
1325
+ if preview:
1326
+ console.print("\n[yellow]Preview mode - no changes applied[/yellow]")
1327
+ console.print("[dim]Remove --preview flag to apply changes[/dim]")
1328
+ return
1329
+
1330
+ # Interactive refinement
1331
+ if interactive:
1332
+ client = ClaudeClient(api_config_name=api, model=model)
1333
+ conversation_context = [result]
1334
+
1335
+ while True:
1336
+ console.print("\n[dim]Ask for changes, 'apply' to confirm, or 'exit' to cancel[/dim]")
1337
+ user_input = console.input("[cyan]You:[/cyan] ").strip()
1338
+
1339
+ if user_input.lower() == 'exit':
1340
+ console.print("[yellow]Cancelled[/yellow]")
1341
+ return
1342
+
1343
+ if user_input.lower() == 'apply':
1344
+ console.print("[green]✓[/green] Implementation plan ready")
1345
+ console.print("[dim]Apply the changes manually from the output above[/dim]")
1346
+ return
1347
+
1348
+ if not user_input:
1349
+ continue
1350
+
1351
+ # Get refinement
1352
+ refinement_prompt = f"Previous implementation plan:\n\n{conversation_context[-1]}\n\nUser request: {user_input}\n\nProvide the updated implementation."
1353
+
1354
+ console.print("\n[bold green]Claude:[/bold green] ", end='')
1355
+ response_parts = []
1356
+ for chunk in client.call_streaming(refinement_prompt):
1357
+ console.print(chunk, end='')
1358
+ response_parts.append(chunk)
1359
+ console.print()
1360
+
1361
+ result = ''.join(response_parts)
1362
+ conversation_context.append(result)
1363
+ else:
1364
+ console.print("\n[green]✓[/green] Feature implementation generated")
1365
+ console.print("[dim]Apply the changes manually from the output above[/dim]")
1366
+
1367
+ except Exception as e:
1368
+ console.print(f"[red]Error: {e}[/red]")
1369
+ sys.exit(1)
1370
+
1371
+
1063
1372
  @main.command('review')
1064
1373
  @click.argument('paths', nargs=-1, type=click.Path(exists=True))
1065
1374
  @click.option('-a', '--api', help='API config to use')