claude-dev-cli 0.8.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.
- {claude_dev_cli-0.8.0/src/claude_dev_cli.egg-info → claude_dev_cli-0.8.1}/PKG-INFO +17 -3
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/README.md +16 -2
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/pyproject.toml +1 -1
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/__init__.py +1 -1
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/cli.py +60 -9
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/config.py +25 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/context.py +83 -18
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1/src/claude_dev_cli.egg-info}/PKG-INFO +17 -3
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli.egg-info/SOURCES.txt +1 -0
- claude_dev_cli-0.8.1/tests/test_context.py +655 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/LICENSE +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/MANIFEST.in +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/setup.cfg +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/commands.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/core.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/history.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/plugins/__init__.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/plugins/base.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/plugins/diff_editor/__init__.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/plugins/diff_editor/plugin.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/plugins/diff_editor/viewer.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/secure_storage.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/template_manager.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/templates.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/toon_utils.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/usage.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/warp_integration.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli/workflows.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli.egg-info/dependency_links.txt +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli.egg-info/entry_points.txt +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli.egg-info/requires.txt +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/src/claude_dev_cli.egg-info/top_level.txt +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/tests/test_cli.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/tests/test_commands.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/tests/test_config.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/tests/test_core.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/tests/test_diff_editor.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/tests/test_secure_storage.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/tests/test_template_manager.py +0 -0
- {claude_dev_cli-0.8.0 → claude_dev_cli-0.8.1}/tests/test_toon_utils.py +0 -0
- {claude_dev_cli-0.8.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.8.
|
|
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,12 +79,16 @@ 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 (
|
|
83
|
-
- **Auto-Context**: `--auto-context` flag for intelligent context gathering
|
|
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)
|
|
84
86
|
- **Git Integration**: Automatically include branch, commits, modified files
|
|
85
87
|
- **Dependency Analysis**: Parse imports and include related files
|
|
86
88
|
- **Error Parsing**: Structured Python traceback parsing
|
|
89
|
+
- **Smart Truncation**: Prevent token limits with configurable file size limits
|
|
87
90
|
- **Project Memory**: Remember preferences per project
|
|
91
|
+
- **Global Config**: Set context defaults in `~/.claude-dev-cli/config.json`
|
|
88
92
|
|
|
89
93
|
### 🎒 TOON Format Support (Optional)
|
|
90
94
|
- **Token Reduction**: 30-60% fewer tokens than JSON
|
|
@@ -156,6 +160,9 @@ cdc generate tests mymodule.py -o tests/test_mymodule.py
|
|
|
156
160
|
# Generate tests with interactive refinement
|
|
157
161
|
cdc generate tests mymodule.py --interactive
|
|
158
162
|
|
|
163
|
+
# Generate tests with context (includes dependencies, related files) - NEW in v0.8.1
|
|
164
|
+
cdc generate tests mymodule.py --auto-context
|
|
165
|
+
|
|
159
166
|
# Code review
|
|
160
167
|
cdc review mymodule.py
|
|
161
168
|
|
|
@@ -174,6 +181,9 @@ cdc generate docs mymodule.py
|
|
|
174
181
|
# Generate docs with interactive refinement
|
|
175
182
|
cdc generate docs mymodule.py --interactive
|
|
176
183
|
|
|
184
|
+
# Generate docs with context (includes dependencies) - NEW in v0.8.1
|
|
185
|
+
cdc generate docs mymodule.py --auto-context
|
|
186
|
+
|
|
177
187
|
# Refactor with context (includes related files)
|
|
178
188
|
cdc refactor legacy_code.py --auto-context
|
|
179
189
|
|
|
@@ -183,6 +193,10 @@ cdc refactor legacy_code.py --interactive
|
|
|
183
193
|
# Git commit message
|
|
184
194
|
git add .
|
|
185
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
|
|
186
200
|
```
|
|
187
201
|
|
|
188
202
|
### 4. Context-Aware Operations (NEW in v0.8.0)
|
|
@@ -35,12 +35,16 @@ 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 (
|
|
39
|
-
- **Auto-Context**: `--auto-context` flag for intelligent context gathering
|
|
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)
|
|
40
42
|
- **Git Integration**: Automatically include branch, commits, modified files
|
|
41
43
|
- **Dependency Analysis**: Parse imports and include related files
|
|
42
44
|
- **Error Parsing**: Structured Python traceback parsing
|
|
45
|
+
- **Smart Truncation**: Prevent token limits with configurable file size limits
|
|
43
46
|
- **Project Memory**: Remember preferences per project
|
|
47
|
+
- **Global Config**: Set context defaults in `~/.claude-dev-cli/config.json`
|
|
44
48
|
|
|
45
49
|
### 🎒 TOON Format Support (Optional)
|
|
46
50
|
- **Token Reduction**: 30-60% fewer tokens than JSON
|
|
@@ -112,6 +116,9 @@ cdc generate tests mymodule.py -o tests/test_mymodule.py
|
|
|
112
116
|
# Generate tests with interactive refinement
|
|
113
117
|
cdc generate tests mymodule.py --interactive
|
|
114
118
|
|
|
119
|
+
# Generate tests with context (includes dependencies, related files) - NEW in v0.8.1
|
|
120
|
+
cdc generate tests mymodule.py --auto-context
|
|
121
|
+
|
|
115
122
|
# Code review
|
|
116
123
|
cdc review mymodule.py
|
|
117
124
|
|
|
@@ -130,6 +137,9 @@ cdc generate docs mymodule.py
|
|
|
130
137
|
# Generate docs with interactive refinement
|
|
131
138
|
cdc generate docs mymodule.py --interactive
|
|
132
139
|
|
|
140
|
+
# Generate docs with context (includes dependencies) - NEW in v0.8.1
|
|
141
|
+
cdc generate docs mymodule.py --auto-context
|
|
142
|
+
|
|
133
143
|
# Refactor with context (includes related files)
|
|
134
144
|
cdc refactor legacy_code.py --auto-context
|
|
135
145
|
|
|
@@ -139,6 +149,10 @@ cdc refactor legacy_code.py --interactive
|
|
|
139
149
|
# Git commit message
|
|
140
150
|
git add .
|
|
141
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
|
|
142
156
|
```
|
|
143
157
|
|
|
144
158
|
### 4. Context-Aware Operations (NEW in v0.8.0)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "claude-dev-cli"
|
|
7
|
-
version = "0.8.
|
|
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"
|
|
@@ -461,20 +461,37 @@ def generate() -> None:
|
|
|
461
461
|
@click.option('-o', '--output', type=click.Path(), help='Output file path')
|
|
462
462
|
@click.option('-a', '--api', help='API config to use')
|
|
463
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')
|
|
464
465
|
@click.pass_context
|
|
465
466
|
def gen_tests(
|
|
466
467
|
ctx: click.Context,
|
|
467
468
|
file_path: str,
|
|
468
469
|
output: Optional[str],
|
|
469
470
|
api: Optional[str],
|
|
470
|
-
interactive: bool
|
|
471
|
+
interactive: bool,
|
|
472
|
+
auto_context: bool
|
|
471
473
|
) -> None:
|
|
472
474
|
"""Generate pytest tests for a Python file."""
|
|
473
475
|
console = ctx.obj['console']
|
|
474
476
|
|
|
475
477
|
try:
|
|
476
|
-
|
|
477
|
-
|
|
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)
|
|
478
495
|
|
|
479
496
|
if interactive:
|
|
480
497
|
# Show initial result
|
|
@@ -530,20 +547,37 @@ def gen_tests(
|
|
|
530
547
|
@click.option('-o', '--output', type=click.Path(), help='Output file path')
|
|
531
548
|
@click.option('-a', '--api', help='API config to use')
|
|
532
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')
|
|
533
551
|
@click.pass_context
|
|
534
552
|
def gen_docs(
|
|
535
553
|
ctx: click.Context,
|
|
536
554
|
file_path: str,
|
|
537
555
|
output: Optional[str],
|
|
538
556
|
api: Optional[str],
|
|
539
|
-
interactive: bool
|
|
557
|
+
interactive: bool,
|
|
558
|
+
auto_context: bool
|
|
540
559
|
) -> None:
|
|
541
560
|
"""Generate documentation for a Python file."""
|
|
542
561
|
console = ctx.obj['console']
|
|
543
562
|
|
|
544
563
|
try:
|
|
545
|
-
|
|
546
|
-
|
|
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)
|
|
547
581
|
|
|
548
582
|
if interactive:
|
|
549
583
|
console.print("\n[bold]Initial Documentation:[/bold]\n")
|
|
@@ -816,14 +850,31 @@ def git() -> None:
|
|
|
816
850
|
|
|
817
851
|
@git.command('commit')
|
|
818
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')
|
|
819
854
|
@click.pass_context
|
|
820
|
-
def git_commit(ctx: click.Context, api: Optional[str]) -> None:
|
|
855
|
+
def git_commit(ctx: click.Context, api: Optional[str], auto_context: bool) -> None:
|
|
821
856
|
"""Generate commit message from staged changes."""
|
|
822
857
|
console = ctx.obj['console']
|
|
823
858
|
|
|
824
859
|
try:
|
|
825
|
-
|
|
826
|
-
|
|
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)
|
|
827
878
|
|
|
828
879
|
console.print("\n[bold green]Suggested commit message:[/bold green]")
|
|
829
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
|
|
|
@@ -31,6 +43,13 @@ class ProjectProfile(BaseModel):
|
|
|
31
43
|
coding_style: Optional[str] = None # Preferred coding style
|
|
32
44
|
test_framework: Optional[str] = None # Preferred test framework
|
|
33
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
|
|
34
53
|
|
|
35
54
|
|
|
36
55
|
class Config:
|
|
@@ -67,6 +86,7 @@ class Config:
|
|
|
67
86
|
"project_profiles": [],
|
|
68
87
|
"default_model": "claude-3-5-sonnet-20241022",
|
|
69
88
|
"max_tokens": 4096,
|
|
89
|
+
"context": ContextConfig().model_dump(),
|
|
70
90
|
}
|
|
71
91
|
self._save_config(default_config)
|
|
72
92
|
return default_config
|
|
@@ -238,3 +258,8 @@ class Config:
|
|
|
238
258
|
def get_max_tokens(self) -> int:
|
|
239
259
|
"""Get default max tokens."""
|
|
240
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()
|
|
@@ -16,11 +16,30 @@ class ContextItem:
|
|
|
16
16
|
content: str
|
|
17
17
|
metadata: Dict[str, Any] = field(default_factory=dict)
|
|
18
18
|
|
|
19
|
+
def truncate(self, max_lines: Optional[int] = None) -> 'ContextItem':
|
|
20
|
+
"""Truncate content to specified number of lines."""
|
|
21
|
+
if max_lines is None:
|
|
22
|
+
return self
|
|
23
|
+
|
|
24
|
+
lines = self.content.split('\n')
|
|
25
|
+
if len(lines) <= max_lines:
|
|
26
|
+
return self
|
|
27
|
+
|
|
28
|
+
truncated_lines = lines[:max_lines]
|
|
29
|
+
truncated_lines.append(f"\n... (truncated {len(lines) - max_lines} more lines)")
|
|
30
|
+
|
|
31
|
+
return ContextItem(
|
|
32
|
+
type=self.type,
|
|
33
|
+
content='\n'.join(truncated_lines),
|
|
34
|
+
metadata={**self.metadata, 'truncated': True, 'original_lines': len(lines)}
|
|
35
|
+
)
|
|
36
|
+
|
|
19
37
|
def format_for_prompt(self) -> str:
|
|
20
38
|
"""Format this context item for inclusion in a prompt."""
|
|
21
39
|
if self.type == 'file':
|
|
22
40
|
path = self.metadata.get('path', 'unknown')
|
|
23
|
-
|
|
41
|
+
truncated_note = " (truncated)" if self.metadata.get('truncated') else ""
|
|
42
|
+
return f"# File: {path}{truncated_note}\n\n{self.content}\n"
|
|
24
43
|
elif self.type == 'git':
|
|
25
44
|
return f"# Git Context\n\n{self.content}\n"
|
|
26
45
|
elif self.type == 'dependency':
|
|
@@ -165,8 +184,13 @@ class GitContext:
|
|
|
165
184
|
except Exception:
|
|
166
185
|
return []
|
|
167
186
|
|
|
168
|
-
def gather(self, include_diff: bool = False) -> ContextItem:
|
|
169
|
-
"""Gather all git context.
|
|
187
|
+
def gather(self, include_diff: bool = False, max_diff_lines: int = 200) -> ContextItem:
|
|
188
|
+
"""Gather all git context.
|
|
189
|
+
|
|
190
|
+
Args:
|
|
191
|
+
include_diff: Include staged diff in context
|
|
192
|
+
max_diff_lines: Maximum lines of diff to include
|
|
193
|
+
"""
|
|
170
194
|
parts = []
|
|
171
195
|
|
|
172
196
|
branch = self.get_current_branch()
|
|
@@ -186,7 +210,12 @@ class GitContext:
|
|
|
186
210
|
if include_diff:
|
|
187
211
|
staged = self.get_staged_diff()
|
|
188
212
|
if staged:
|
|
189
|
-
|
|
213
|
+
diff_lines = staged.split('\n')
|
|
214
|
+
if len(diff_lines) > max_diff_lines:
|
|
215
|
+
truncated_diff = '\n'.join(diff_lines[:max_diff_lines])
|
|
216
|
+
parts.append(f"\nStaged changes (truncated {len(diff_lines) - max_diff_lines} lines):\n{truncated_diff}\n... (diff truncated)")
|
|
217
|
+
else:
|
|
218
|
+
parts.append(f"\nStaged changes:\n{staged}")
|
|
190
219
|
|
|
191
220
|
content = "\n".join(parts) if parts else "No git context available"
|
|
192
221
|
|
|
@@ -400,29 +429,42 @@ class ErrorContext:
|
|
|
400
429
|
class ContextGatherer:
|
|
401
430
|
"""Main context gathering coordinator."""
|
|
402
431
|
|
|
403
|
-
def __init__(self, project_root: Optional[Path] = None):
|
|
432
|
+
def __init__(self, project_root: Optional[Path] = None, max_file_lines: int = 1000, max_related_files: int = 5):
|
|
404
433
|
self.project_root = project_root or Path.cwd()
|
|
405
434
|
self.git = GitContext(self.project_root)
|
|
406
435
|
self.dependencies = DependencyAnalyzer(self.project_root)
|
|
407
436
|
self.error_parser = ErrorContext()
|
|
437
|
+
self.max_file_lines = max_file_lines
|
|
438
|
+
self.max_related_files = max_related_files
|
|
408
439
|
|
|
409
440
|
def gather_for_file(
|
|
410
441
|
self,
|
|
411
442
|
file_path: Path,
|
|
412
443
|
include_git: bool = True,
|
|
413
444
|
include_dependencies: bool = True,
|
|
414
|
-
include_related: bool = True
|
|
445
|
+
include_related: bool = True,
|
|
446
|
+
max_lines: Optional[int] = None
|
|
415
447
|
) -> Context:
|
|
416
|
-
"""Gather context for a specific file operation.
|
|
448
|
+
"""Gather context for a specific file operation.
|
|
449
|
+
|
|
450
|
+
Args:
|
|
451
|
+
file_path: Path to the file to gather context for
|
|
452
|
+
include_git: Include git context
|
|
453
|
+
include_dependencies: Include dependency information
|
|
454
|
+
include_related: Include related files
|
|
455
|
+
max_lines: Maximum lines per file (uses instance default if None)
|
|
456
|
+
"""
|
|
417
457
|
context = Context()
|
|
458
|
+
max_lines = max_lines or self.max_file_lines
|
|
418
459
|
|
|
419
460
|
# Add the file itself
|
|
420
461
|
if file_path.exists():
|
|
421
|
-
|
|
462
|
+
item = ContextItem(
|
|
422
463
|
type='file',
|
|
423
464
|
content=file_path.read_text(),
|
|
424
465
|
metadata={'path': str(file_path)}
|
|
425
|
-
)
|
|
466
|
+
)
|
|
467
|
+
context.add(item.truncate(max_lines))
|
|
426
468
|
|
|
427
469
|
# Add git context
|
|
428
470
|
if include_git and self.git.is_git_repo():
|
|
@@ -438,21 +480,31 @@ class ContextGatherer:
|
|
|
438
480
|
self,
|
|
439
481
|
error_text: str,
|
|
440
482
|
file_path: Optional[Path] = None,
|
|
441
|
-
include_git: bool = True
|
|
483
|
+
include_git: bool = True,
|
|
484
|
+
max_lines: Optional[int] = None
|
|
442
485
|
) -> Context:
|
|
443
|
-
"""Gather context for error debugging.
|
|
486
|
+
"""Gather context for error debugging.
|
|
487
|
+
|
|
488
|
+
Args:
|
|
489
|
+
error_text: The error message or traceback
|
|
490
|
+
file_path: Optional file path related to the error
|
|
491
|
+
include_git: Include git context
|
|
492
|
+
max_lines: Maximum lines per file (uses instance default if None)
|
|
493
|
+
"""
|
|
444
494
|
context = Context()
|
|
495
|
+
max_lines = max_lines or self.max_file_lines
|
|
445
496
|
|
|
446
497
|
# Add error context
|
|
447
498
|
context.add(self.error_parser.gather(error_text))
|
|
448
499
|
|
|
449
500
|
# Add file if provided
|
|
450
501
|
if file_path and file_path.exists():
|
|
451
|
-
|
|
502
|
+
item = ContextItem(
|
|
452
503
|
type='file',
|
|
453
504
|
content=file_path.read_text(),
|
|
454
505
|
metadata={'path': str(file_path)}
|
|
455
|
-
)
|
|
506
|
+
)
|
|
507
|
+
context.add(item.truncate(max_lines))
|
|
456
508
|
|
|
457
509
|
# Add git context
|
|
458
510
|
if include_git and self.git.is_git_repo():
|
|
@@ -464,16 +516,27 @@ class ContextGatherer:
|
|
|
464
516
|
self,
|
|
465
517
|
file_path: Path,
|
|
466
518
|
include_git: bool = True,
|
|
467
|
-
include_tests: bool = True
|
|
519
|
+
include_tests: bool = True,
|
|
520
|
+
max_lines: Optional[int] = None
|
|
468
521
|
) -> Context:
|
|
469
|
-
"""Gather context for code review.
|
|
522
|
+
"""Gather context for code review.
|
|
523
|
+
|
|
524
|
+
Args:
|
|
525
|
+
file_path: Path to the file to review
|
|
526
|
+
include_git: Include git context
|
|
527
|
+
include_tests: Try to find and include test files
|
|
528
|
+
max_lines: Maximum lines per file (uses instance default if None)
|
|
529
|
+
"""
|
|
470
530
|
context = self.gather_for_file(
|
|
471
531
|
file_path,
|
|
472
532
|
include_git=include_git,
|
|
473
533
|
include_dependencies=True,
|
|
474
|
-
include_related=True
|
|
534
|
+
include_related=True,
|
|
535
|
+
max_lines=max_lines
|
|
475
536
|
)
|
|
476
537
|
|
|
538
|
+
max_lines = max_lines or self.max_file_lines
|
|
539
|
+
|
|
477
540
|
# Try to find test file
|
|
478
541
|
if include_tests:
|
|
479
542
|
test_patterns = [
|
|
@@ -484,11 +547,13 @@ class ContextGatherer:
|
|
|
484
547
|
|
|
485
548
|
for test_file in test_patterns:
|
|
486
549
|
if test_file.exists():
|
|
487
|
-
|
|
550
|
+
item = ContextItem(
|
|
488
551
|
type='file',
|
|
489
552
|
content=test_file.read_text(),
|
|
490
553
|
metadata={'path': str(test_file), 'is_test': True}
|
|
491
|
-
)
|
|
554
|
+
)
|
|
555
|
+
context.add(item.truncate(max_lines))
|
|
492
556
|
break
|
|
493
557
|
|
|
494
558
|
return context
|
|
559
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: claude-dev-cli
|
|
3
|
-
Version: 0.8.
|
|
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,12 +79,16 @@ 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 (
|
|
83
|
-
- **Auto-Context**: `--auto-context` flag for intelligent context gathering
|
|
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)
|
|
84
86
|
- **Git Integration**: Automatically include branch, commits, modified files
|
|
85
87
|
- **Dependency Analysis**: Parse imports and include related files
|
|
86
88
|
- **Error Parsing**: Structured Python traceback parsing
|
|
89
|
+
- **Smart Truncation**: Prevent token limits with configurable file size limits
|
|
87
90
|
- **Project Memory**: Remember preferences per project
|
|
91
|
+
- **Global Config**: Set context defaults in `~/.claude-dev-cli/config.json`
|
|
88
92
|
|
|
89
93
|
### 🎒 TOON Format Support (Optional)
|
|
90
94
|
- **Token Reduction**: 30-60% fewer tokens than JSON
|
|
@@ -156,6 +160,9 @@ cdc generate tests mymodule.py -o tests/test_mymodule.py
|
|
|
156
160
|
# Generate tests with interactive refinement
|
|
157
161
|
cdc generate tests mymodule.py --interactive
|
|
158
162
|
|
|
163
|
+
# Generate tests with context (includes dependencies, related files) - NEW in v0.8.1
|
|
164
|
+
cdc generate tests mymodule.py --auto-context
|
|
165
|
+
|
|
159
166
|
# Code review
|
|
160
167
|
cdc review mymodule.py
|
|
161
168
|
|
|
@@ -174,6 +181,9 @@ cdc generate docs mymodule.py
|
|
|
174
181
|
# Generate docs with interactive refinement
|
|
175
182
|
cdc generate docs mymodule.py --interactive
|
|
176
183
|
|
|
184
|
+
# Generate docs with context (includes dependencies) - NEW in v0.8.1
|
|
185
|
+
cdc generate docs mymodule.py --auto-context
|
|
186
|
+
|
|
177
187
|
# Refactor with context (includes related files)
|
|
178
188
|
cdc refactor legacy_code.py --auto-context
|
|
179
189
|
|
|
@@ -183,6 +193,10 @@ cdc refactor legacy_code.py --interactive
|
|
|
183
193
|
# Git commit message
|
|
184
194
|
git add .
|
|
185
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
|
|
186
200
|
```
|
|
187
201
|
|
|
188
202
|
### 4. Context-Aware Operations (NEW in v0.8.0)
|