claude-dev-cli 0.7.0__tar.gz → 0.8.1__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 (41) hide show
  1. {claude_dev_cli-0.7.0/src/claude_dev_cli.egg-info → claude_dev_cli-0.8.1}/PKG-INFO +51 -5
  2. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/README.md +50 -4
  3. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/pyproject.toml +1 -1
  4. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/__init__.py +1 -1
  5. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/cli.py +150 -23
  6. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/config.py +31 -0
  7. claude_dev_cli-0.8.1/src/claude_dev_cli/context.py +559 -0
  8. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1/src/claude_dev_cli.egg-info}/PKG-INFO +51 -5
  9. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli.egg-info/SOURCES.txt +2 -0
  10. claude_dev_cli-0.8.1/tests/test_context.py +655 -0
  11. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/LICENSE +0 -0
  12. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/MANIFEST.in +0 -0
  13. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/setup.cfg +0 -0
  14. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/commands.py +0 -0
  15. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/core.py +0 -0
  16. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/history.py +0 -0
  17. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/plugins/__init__.py +0 -0
  18. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/plugins/base.py +0 -0
  19. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/plugins/diff_editor/__init__.py +0 -0
  20. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/plugins/diff_editor/plugin.py +0 -0
  21. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/plugins/diff_editor/viewer.py +0 -0
  22. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/secure_storage.py +0 -0
  23. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/template_manager.py +0 -0
  24. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/templates.py +0 -0
  25. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/toon_utils.py +0 -0
  26. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/usage.py +0 -0
  27. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/warp_integration.py +0 -0
  28. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/workflows.py +0 -0
  29. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli.egg-info/dependency_links.txt +0 -0
  30. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli.egg-info/entry_points.txt +0 -0
  31. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli.egg-info/requires.txt +0 -0
  32. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli.egg-info/top_level.txt +0 -0
  33. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/tests/test_cli.py +0 -0
  34. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/tests/test_commands.py +0 -0
  35. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/tests/test_config.py +0 -0
  36. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/tests/test_core.py +0 -0
  37. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/tests/test_diff_editor.py +0 -0
  38. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/tests/test_secure_storage.py +0 -0
  39. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/tests/test_template_manager.py +0 -0
  40. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/tests/test_toon_utils.py +0 -0
  41. {claude_dev_cli-0.7.0 → claude_dev_cli-0.8.1}/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.7.0
3
+ Version: 0.8.1
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
@@ -79,6 +79,17 @@ A powerful command-line tool for developers using Claude AI with multi-API routi
79
79
  - **Variable Substitution**: Use {{variable}} placeholders for dynamic content
80
80
  - **Categories**: Organize templates by category (review, testing, debugging, etc.)
81
81
 
82
+ ### 🧠 Context Intelligence (v0.8.0+)
83
+ - **Auto-Context**: `--auto-context` flag on 7 commands for intelligent context gathering
84
+ - `ask`, `review`, `debug`, `refactor` (v0.8.0)
85
+ - `git commit`, `generate tests`, `generate docs` (v0.8.1)
86
+ - **Git Integration**: Automatically include branch, commits, modified files
87
+ - **Dependency Analysis**: Parse imports and include related files
88
+ - **Error Parsing**: Structured Python traceback parsing
89
+ - **Smart Truncation**: Prevent token limits with configurable file size limits
90
+ - **Project Memory**: Remember preferences per project
91
+ - **Global Config**: Set context defaults in `~/.claude-dev-cli/config.json`
92
+
82
93
  ### 🎒 TOON Format Support (Optional)
83
94
  - **Token Reduction**: 30-60% fewer tokens than JSON
84
95
  - **Cost Savings**: Reduce API costs significantly
@@ -149,14 +160,20 @@ cdc generate tests mymodule.py -o tests/test_mymodule.py
149
160
  # Generate tests with interactive refinement
150
161
  cdc generate tests mymodule.py --interactive
151
162
 
163
+ # Generate tests with context (includes dependencies, related files) - NEW in v0.8.1
164
+ cdc generate tests mymodule.py --auto-context
165
+
152
166
  # Code review
153
167
  cdc review mymodule.py
154
168
 
169
+ # Code review with auto-context (includes git, dependencies, tests)
170
+ cdc review mymodule.py --auto-context
171
+
155
172
  # Code review with interactive follow-up questions
156
173
  cdc review mymodule.py --interactive
157
174
 
158
- # Debug errors
159
- python script.py 2>&1 | cdc debug
175
+ # Debug errors with intelligent error parsing
176
+ python script.py 2>&1 | cdc debug --auto-context
160
177
 
161
178
  # Generate documentation
162
179
  cdc generate docs mymodule.py
@@ -164,8 +181,11 @@ cdc generate docs mymodule.py
164
181
  # Generate docs with interactive refinement
165
182
  cdc generate docs mymodule.py --interactive
166
183
 
167
- # Refactor suggestions
168
- cdc refactor legacy_code.py
184
+ # Generate docs with context (includes dependencies) - NEW in v0.8.1
185
+ cdc generate docs mymodule.py --auto-context
186
+
187
+ # Refactor with context (includes related files)
188
+ cdc refactor legacy_code.py --auto-context
169
189
 
170
190
  # Refactor with interactive refinement
171
191
  cdc refactor legacy_code.py --interactive
@@ -173,6 +193,32 @@ cdc refactor legacy_code.py --interactive
173
193
  # Git commit message
174
194
  git add .
175
195
  cdc git commit
196
+
197
+ # Git commit message with context (includes history, branch) - NEW in v0.8.1
198
+ git add .
199
+ cdc git commit --auto-context
200
+ ```
201
+
202
+ ### 4. Context-Aware Operations (NEW in v0.8.0)
203
+
204
+ ```bash
205
+ # Auto-context includes: git info, dependencies, related files
206
+
207
+ # Review with full project context
208
+ cdc review mymodule.py --auto-context
209
+ # ✓ Context gathered (git, dependencies, tests)
210
+
211
+ # Debug with parsed error details
212
+ python broken.py 2>&1 | cdc debug -f broken.py --auto-context
213
+ # ✓ Context gathered (error details, git context)
214
+
215
+ # Ask questions with file context
216
+ cdc ask -f mycode.py --auto-context "how can I improve this?"
217
+ # ✓ Context gathered
218
+
219
+ # Refactor with related files
220
+ cdc refactor app.py --auto-context
221
+ # Automatically includes imported modules and dependencies
176
222
  ```
177
223
 
178
224
  ### 5. Custom Templates
@@ -35,6 +35,17 @@ A powerful command-line tool for developers using Claude AI with multi-API routi
35
35
  - **Variable Substitution**: Use {{variable}} placeholders for dynamic content
36
36
  - **Categories**: Organize templates by category (review, testing, debugging, etc.)
37
37
 
38
+ ### 🧠 Context Intelligence (v0.8.0+)
39
+ - **Auto-Context**: `--auto-context` flag on 7 commands for intelligent context gathering
40
+ - `ask`, `review`, `debug`, `refactor` (v0.8.0)
41
+ - `git commit`, `generate tests`, `generate docs` (v0.8.1)
42
+ - **Git Integration**: Automatically include branch, commits, modified files
43
+ - **Dependency Analysis**: Parse imports and include related files
44
+ - **Error Parsing**: Structured Python traceback parsing
45
+ - **Smart Truncation**: Prevent token limits with configurable file size limits
46
+ - **Project Memory**: Remember preferences per project
47
+ - **Global Config**: Set context defaults in `~/.claude-dev-cli/config.json`
48
+
38
49
  ### 🎒 TOON Format Support (Optional)
39
50
  - **Token Reduction**: 30-60% fewer tokens than JSON
40
51
  - **Cost Savings**: Reduce API costs significantly
@@ -105,14 +116,20 @@ cdc generate tests mymodule.py -o tests/test_mymodule.py
105
116
  # Generate tests with interactive refinement
106
117
  cdc generate tests mymodule.py --interactive
107
118
 
119
+ # Generate tests with context (includes dependencies, related files) - NEW in v0.8.1
120
+ cdc generate tests mymodule.py --auto-context
121
+
108
122
  # Code review
109
123
  cdc review mymodule.py
110
124
 
125
+ # Code review with auto-context (includes git, dependencies, tests)
126
+ cdc review mymodule.py --auto-context
127
+
111
128
  # Code review with interactive follow-up questions
112
129
  cdc review mymodule.py --interactive
113
130
 
114
- # Debug errors
115
- python script.py 2>&1 | cdc debug
131
+ # Debug errors with intelligent error parsing
132
+ python script.py 2>&1 | cdc debug --auto-context
116
133
 
117
134
  # Generate documentation
118
135
  cdc generate docs mymodule.py
@@ -120,8 +137,11 @@ cdc generate docs mymodule.py
120
137
  # Generate docs with interactive refinement
121
138
  cdc generate docs mymodule.py --interactive
122
139
 
123
- # Refactor suggestions
124
- cdc refactor legacy_code.py
140
+ # Generate docs with context (includes dependencies) - NEW in v0.8.1
141
+ cdc generate docs mymodule.py --auto-context
142
+
143
+ # Refactor with context (includes related files)
144
+ cdc refactor legacy_code.py --auto-context
125
145
 
126
146
  # Refactor with interactive refinement
127
147
  cdc refactor legacy_code.py --interactive
@@ -129,6 +149,32 @@ cdc refactor legacy_code.py --interactive
129
149
  # Git commit message
130
150
  git add .
131
151
  cdc git commit
152
+
153
+ # Git commit message with context (includes history, branch) - NEW in v0.8.1
154
+ git add .
155
+ cdc git commit --auto-context
156
+ ```
157
+
158
+ ### 4. Context-Aware Operations (NEW in v0.8.0)
159
+
160
+ ```bash
161
+ # Auto-context includes: git info, dependencies, related files
162
+
163
+ # Review with full project context
164
+ cdc review mymodule.py --auto-context
165
+ # ✓ Context gathered (git, dependencies, tests)
166
+
167
+ # Debug with parsed error details
168
+ python broken.py 2>&1 | cdc debug -f broken.py --auto-context
169
+ # ✓ Context gathered (error details, git context)
170
+
171
+ # Ask questions with file context
172
+ cdc ask -f mycode.py --auto-context "how can I improve this?"
173
+ # ✓ Context gathered
174
+
175
+ # Refactor with related files
176
+ cdc refactor app.py --auto-context
177
+ # Automatically includes imported modules and dependencies
132
178
  ```
133
179
 
134
180
  ### 5. Custom Templates
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "claude-dev-cli"
7
- version = "0.7.0"
7
+ version = "0.8.1"
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"
@@ -9,7 +9,7 @@ Features:
9
9
  - Interactive and single-shot modes
10
10
  """
11
11
 
12
- __version__ = "0.7.0"
12
+ __version__ = "0.8.1"
13
13
  __author__ = "Julio"
14
14
  __license__ = "MIT"
15
15
 
@@ -57,6 +57,7 @@ except Exception:
57
57
  @click.option('-a', '--api', help='API config to use')
58
58
  @click.option('-m', '--model', help='Claude model to use')
59
59
  @click.option('--stream/--no-stream', default=True, help='Stream response')
60
+ @click.option('--auto-context', is_flag=True, help='Automatically include git, dependencies, and related files')
60
61
  @click.pass_context
61
62
  def ask(
62
63
  ctx: click.Context,
@@ -65,7 +66,8 @@ def ask(
65
66
  system: Optional[str],
66
67
  api: Optional[str],
67
68
  model: Optional[str],
68
- stream: bool
69
+ stream: bool,
70
+ auto_context: bool
69
71
  ) -> None:
70
72
  """Ask Claude a question (single-shot mode)."""
71
73
  console = ctx.obj['console']
@@ -73,7 +75,18 @@ def ask(
73
75
  # Build prompt
74
76
  prompt_parts = []
75
77
 
76
- if file:
78
+ # Gather context if requested
79
+ if auto_context and file:
80
+ from claude_dev_cli.context import ContextGatherer
81
+
82
+ with console.status("[bold blue]Gathering context..."):
83
+ gatherer = ContextGatherer()
84
+ context = gatherer.gather_for_file(Path(file))
85
+ context_info = context.format_for_prompt()
86
+
87
+ console.print("[dim]✓ Context gathered[/dim]")
88
+ prompt_parts.append(context_info)
89
+ elif file:
77
90
  with open(file, 'r') as f:
78
91
  file_content = f.read()
79
92
  prompt_parts.append(f"File: {file}\n\n{file_content}\n\n")
@@ -448,20 +461,37 @@ def generate() -> None:
448
461
  @click.option('-o', '--output', type=click.Path(), help='Output file path')
449
462
  @click.option('-a', '--api', help='API config to use')
450
463
  @click.option('-i', '--interactive', is_flag=True, help='Interactive refinement mode')
464
+ @click.option('--auto-context', is_flag=True, help='Include dependencies and related files')
451
465
  @click.pass_context
452
466
  def gen_tests(
453
467
  ctx: click.Context,
454
468
  file_path: str,
455
469
  output: Optional[str],
456
470
  api: Optional[str],
457
- interactive: bool
471
+ interactive: bool,
472
+ auto_context: bool
458
473
  ) -> None:
459
474
  """Generate pytest tests for a Python file."""
460
475
  console = ctx.obj['console']
461
476
 
462
477
  try:
463
- with console.status("[bold blue]Generating tests..."):
464
- result = generate_tests(file_path, api_config_name=api)
478
+ if auto_context:
479
+ from claude_dev_cli.context import ContextGatherer
480
+
481
+ with console.status("[bold blue]Gathering context..."):
482
+ gatherer = ContextGatherer()
483
+ context = gatherer.gather_for_file(Path(file_path), include_git=False)
484
+ context_info = context.format_for_prompt()
485
+
486
+ console.print("[dim]✓ Context gathered (dependencies, related files)[/dim]")
487
+
488
+ # Use context-aware test generation
489
+ client = ClaudeClient(api_config_name=api)
490
+ enhanced_prompt = f"{context_info}\n\nPlease generate comprehensive pytest tests for the main file, including fixtures, edge cases, and proper mocking where needed."
491
+ result = client.call(enhanced_prompt)
492
+ else:
493
+ with console.status("[bold blue]Generating tests..."):
494
+ result = generate_tests(file_path, api_config_name=api)
465
495
 
466
496
  if interactive:
467
497
  # Show initial result
@@ -517,20 +547,37 @@ def gen_tests(
517
547
  @click.option('-o', '--output', type=click.Path(), help='Output file path')
518
548
  @click.option('-a', '--api', help='API config to use')
519
549
  @click.option('-i', '--interactive', is_flag=True, help='Interactive refinement mode')
550
+ @click.option('--auto-context', is_flag=True, help='Include dependencies and related files')
520
551
  @click.pass_context
521
552
  def gen_docs(
522
553
  ctx: click.Context,
523
554
  file_path: str,
524
555
  output: Optional[str],
525
556
  api: Optional[str],
526
- interactive: bool
557
+ interactive: bool,
558
+ auto_context: bool
527
559
  ) -> None:
528
560
  """Generate documentation for a Python file."""
529
561
  console = ctx.obj['console']
530
562
 
531
563
  try:
532
- with console.status("[bold blue]Generating documentation..."):
533
- result = generate_docs(file_path, api_config_name=api)
564
+ if auto_context:
565
+ from claude_dev_cli.context import ContextGatherer
566
+
567
+ with console.status("[bold blue]Gathering context..."):
568
+ gatherer = ContextGatherer()
569
+ context = gatherer.gather_for_file(Path(file_path), include_git=False)
570
+ context_info = context.format_for_prompt()
571
+
572
+ console.print("[dim]✓ Context gathered (dependencies, related files)[/dim]")
573
+
574
+ # Use context-aware documentation generation
575
+ client = ClaudeClient(api_config_name=api)
576
+ enhanced_prompt = f"{context_info}\n\nPlease generate comprehensive documentation for the main file, including API reference, usage examples, and integration notes."
577
+ result = client.call(enhanced_prompt)
578
+ else:
579
+ with console.status("[bold blue]Generating documentation..."):
580
+ result = generate_docs(file_path, api_config_name=api)
534
581
 
535
582
  if interactive:
536
583
  console.print("\n[bold]Initial Documentation:[/bold]\n")
@@ -584,19 +631,42 @@ def gen_docs(
584
631
  @click.argument('file_path', type=click.Path(exists=True))
585
632
  @click.option('-a', '--api', help='API config to use')
586
633
  @click.option('-i', '--interactive', is_flag=True, help='Interactive follow-up questions')
634
+ @click.option('--auto-context', is_flag=True, help='Automatically include git, dependencies, and related files')
587
635
  @click.pass_context
588
636
  def review(
589
637
  ctx: click.Context,
590
638
  file_path: str,
591
639
  api: Optional[str],
592
- interactive: bool
640
+ interactive: bool,
641
+ auto_context: bool
593
642
  ) -> None:
594
643
  """Review code for bugs and improvements."""
595
644
  console = ctx.obj['console']
596
645
 
597
646
  try:
647
+ # Gather context if requested
648
+ context_info = ""
649
+ if auto_context:
650
+ from claude_dev_cli.context import ContextGatherer
651
+
652
+ with console.status("[bold blue]Gathering context..."):
653
+ gatherer = ContextGatherer()
654
+ context = gatherer.gather_for_review(Path(file_path))
655
+ context_info = context.format_for_prompt()
656
+
657
+ console.print("[dim]✓ Context gathered (git, dependencies, tests)[/dim]")
658
+
598
659
  with console.status("[bold blue]Reviewing code..."):
599
- result = code_review(file_path, api_config_name=api)
660
+ # If we have context, prepend it to the file analysis
661
+ if context_info:
662
+ # Read file separately for context-aware review
663
+ result = code_review(file_path, api_config_name=api)
664
+ # The context module already includes the file, so we use it differently
665
+ client = ClaudeClient(api_config_name=api)
666
+ enhanced_prompt = f"{context_info}\n\nPlease review this code for bugs and improvements."
667
+ result = client.call(enhanced_prompt)
668
+ else:
669
+ result = code_review(file_path, api_config_name=api)
600
670
 
601
671
  md = Markdown(result)
602
672
  console.print(md)
@@ -633,12 +703,14 @@ def review(
633
703
  @click.option('-f', '--file', type=click.Path(exists=True), help='File to debug')
634
704
  @click.option('-e', '--error', help='Error message to analyze')
635
705
  @click.option('-a', '--api', help='API config to use')
706
+ @click.option('--auto-context', is_flag=True, help='Automatically include git context and parse error details')
636
707
  @click.pass_context
637
708
  def debug(
638
709
  ctx: click.Context,
639
710
  file: Optional[str],
640
711
  error: Optional[str],
641
- api: Optional[str]
712
+ api: Optional[str],
713
+ auto_context: bool
642
714
  ) -> None:
643
715
  """Debug code and analyze errors."""
644
716
  console = ctx.obj['console']
@@ -648,13 +720,33 @@ def debug(
648
720
  if not sys.stdin.isatty():
649
721
  stdin_content = sys.stdin.read().strip()
650
722
 
723
+ error_text = error or stdin_content
724
+
651
725
  try:
652
- with console.status("[bold blue]Analyzing error..."):
653
- result = debug_code(
654
- file_path=file,
655
- error_message=error or stdin_content,
656
- api_config_name=api
657
- )
726
+ # Gather context if requested
727
+ if auto_context and error_text:
728
+ from claude_dev_cli.context import ContextGatherer
729
+
730
+ with console.status("[bold blue]Gathering context..."):
731
+ gatherer = ContextGatherer()
732
+ file_path = Path(file) if file else None
733
+ context = gatherer.gather_for_error(error_text, file_path=file_path)
734
+ context_info = context.format_for_prompt()
735
+
736
+ console.print("[dim]✓ Context gathered (error details, git context)[/dim]")
737
+
738
+ # Use context-aware analysis
739
+ client = ClaudeClient(api_config_name=api)
740
+ enhanced_prompt = f"{context_info}\n\nPlease analyze this error and suggest fixes."
741
+ result = client.call(enhanced_prompt)
742
+ else:
743
+ # Original behavior
744
+ with console.status("[bold blue]Analyzing error..."):
745
+ result = debug_code(
746
+ file_path=file,
747
+ error_message=error_text,
748
+ api_config_name=api
749
+ )
658
750
 
659
751
  md = Markdown(result)
660
752
  console.print(md)
@@ -669,20 +761,38 @@ def debug(
669
761
  @click.option('-o', '--output', type=click.Path(), help='Output file path')
670
762
  @click.option('-a', '--api', help='API config to use')
671
763
  @click.option('-i', '--interactive', is_flag=True, help='Interactive refinement mode')
764
+ @click.option('--auto-context', is_flag=True, help='Automatically include git, dependencies, and related files')
672
765
  @click.pass_context
673
766
  def refactor(
674
767
  ctx: click.Context,
675
768
  file_path: str,
676
769
  output: Optional[str],
677
770
  api: Optional[str],
678
- interactive: bool
771
+ interactive: bool,
772
+ auto_context: bool
679
773
  ) -> None:
680
774
  """Suggest refactoring improvements."""
681
775
  console = ctx.obj['console']
682
776
 
683
777
  try:
684
- with console.status("[bold blue]Analyzing code..."):
685
- result = refactor_code(file_path, api_config_name=api)
778
+ # Gather context if requested
779
+ if auto_context:
780
+ from claude_dev_cli.context import ContextGatherer
781
+
782
+ with console.status("[bold blue]Gathering context..."):
783
+ gatherer = ContextGatherer()
784
+ context = gatherer.gather_for_file(Path(file_path))
785
+ context_info = context.format_for_prompt()
786
+
787
+ console.print("[dim]✓ Context gathered[/dim]")
788
+
789
+ # Use context-aware refactoring
790
+ client = ClaudeClient(api_config_name=api)
791
+ enhanced_prompt = f"{context_info}\n\nPlease suggest refactoring improvements for the main file."
792
+ result = client.call(enhanced_prompt)
793
+ else:
794
+ with console.status("[bold blue]Analyzing code..."):
795
+ result = refactor_code(file_path, api_config_name=api)
686
796
 
687
797
  if interactive:
688
798
  console.print("\n[bold]Initial Refactoring:[/bold]\n")
@@ -740,14 +850,31 @@ def git() -> None:
740
850
 
741
851
  @git.command('commit')
742
852
  @click.option('-a', '--api', help='API config to use')
853
+ @click.option('--auto-context', is_flag=True, help='Include git history and branch context')
743
854
  @click.pass_context
744
- def git_commit(ctx: click.Context, api: Optional[str]) -> None:
855
+ def git_commit(ctx: click.Context, api: Optional[str], auto_context: bool) -> None:
745
856
  """Generate commit message from staged changes."""
746
857
  console = ctx.obj['console']
747
858
 
748
859
  try:
749
- with console.status("[bold blue]Analyzing changes..."):
750
- result = git_commit_message(api_config_name=api)
860
+ if auto_context:
861
+ from claude_dev_cli.context import ContextGatherer
862
+
863
+ with console.status("[bold blue]Gathering context..."):
864
+ gatherer = ContextGatherer()
865
+ # Get git context with recent commits and branch info
866
+ git_context = gatherer.git.gather(include_diff=True)
867
+ context_info = git_context.format_for_prompt()
868
+
869
+ console.print("[dim]✓ Context gathered (branch, commits, diff)[/dim]")
870
+
871
+ # Use context-aware commit message generation
872
+ client = ClaudeClient(api_config_name=api)
873
+ enhanced_prompt = f"{context_info}\n\nPlease generate a concise, conventional commit message for the staged changes. Follow best practices: imperative mood, clear scope, explain what and why."
874
+ result = client.call(enhanced_prompt)
875
+ else:
876
+ with console.status("[bold blue]Analyzing changes..."):
877
+ result = git_commit_message(api_config_name=api)
751
878
 
752
879
  console.print("\n[bold green]Suggested commit message:[/bold green]")
753
880
  console.print(Panel(result, border_style="green"))
@@ -9,6 +9,18 @@ from pydantic import BaseModel, Field
9
9
  from claude_dev_cli.secure_storage import SecureStorage
10
10
 
11
11
 
12
+ class ContextConfig(BaseModel):
13
+ """Global context gathering configuration."""
14
+
15
+ auto_context_default: bool = False # Default for --auto-context flag
16
+ max_file_lines: int = 1000 # Maximum lines per file in context
17
+ max_related_files: int = 5 # Maximum related files to include
18
+ max_diff_lines: int = 200 # Maximum lines of diff to include
19
+ include_git: bool = True # Include git context by default
20
+ include_dependencies: bool = True # Include dependencies by default
21
+ include_tests: bool = True # Include test files by default
22
+
23
+
12
24
  class APIConfig(BaseModel):
13
25
  """Configuration for a Claude API key."""
14
26
 
@@ -25,6 +37,19 @@ class ProjectProfile(BaseModel):
25
37
  api_config: str # Name of the API config to use
26
38
  system_prompt: Optional[str] = None
27
39
  allowed_commands: List[str] = Field(default_factory=lambda: ["all"])
40
+
41
+ # Project memory - preferences and patterns
42
+ auto_context: bool = False # Default value for --auto-context flag
43
+ coding_style: Optional[str] = None # Preferred coding style
44
+ test_framework: Optional[str] = None # Preferred test framework
45
+ preferences: Dict[str, str] = Field(default_factory=dict) # Custom preferences
46
+
47
+ # Context gathering configuration
48
+ max_context_files: int = 5 # Maximum number of related files to include
49
+ max_diff_lines: int = 200 # Maximum lines of diff to include
50
+ max_file_lines: int = 1000 # Maximum lines per file in context
51
+ include_tests_by_default: bool = True # Include test files in review context
52
+ context_depth: int = 2 # How deep to search for related modules
28
53
 
29
54
 
30
55
  class Config:
@@ -61,6 +86,7 @@ class Config:
61
86
  "project_profiles": [],
62
87
  "default_model": "claude-3-5-sonnet-20241022",
63
88
  "max_tokens": 4096,
89
+ "context": ContextConfig().model_dump(),
64
90
  }
65
91
  self._save_config(default_config)
66
92
  return default_config
@@ -232,3 +258,8 @@ class Config:
232
258
  def get_max_tokens(self) -> int:
233
259
  """Get default max tokens."""
234
260
  return self._data.get("max_tokens", 4096)
261
+
262
+ def get_context_config(self) -> ContextConfig:
263
+ """Get context gathering configuration."""
264
+ context_data = self._data.get("context", {})
265
+ return ContextConfig(**context_data) if context_data else ContextConfig()