claude-dev-cli 0.1.0__py3-none-any.whl → 0.2.0__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 claude-dev-cli might be problematic. Click here for more details.

@@ -9,7 +9,7 @@ Features:
9
9
  - Interactive and single-shot modes
10
10
  """
11
11
 
12
- __version__ = "0.1.0"
12
+ __version__ = "0.2.0"
13
13
  __author__ = "Julio"
14
14
  __license__ = "MIT"
15
15
 
claude_dev_cli/cli.py CHANGED
@@ -21,6 +21,7 @@ from claude_dev_cli.commands import (
21
21
  git_commit_message,
22
22
  )
23
23
  from claude_dev_cli.usage import UsageTracker
24
+ from claude_dev_cli import toon_utils
24
25
 
25
26
  console = Console()
26
27
 
@@ -394,5 +395,124 @@ def usage(ctx: click.Context, days: Optional[int], api: Optional[str]) -> None:
394
395
  sys.exit(1)
395
396
 
396
397
 
398
+ @main.group()
399
+ def toon() -> None:
400
+ """TOON format conversion tools."""
401
+ pass
402
+
403
+
404
+ @toon.command('encode')
405
+ @click.argument('input_file', type=click.Path(exists=True), required=False)
406
+ @click.option('-o', '--output', type=click.Path(), help='Output file')
407
+ @click.pass_context
408
+ def toon_encode(ctx: click.Context, input_file: Optional[str], output: Optional[str]) -> None:
409
+ """Convert JSON to TOON format."""
410
+ console = ctx.obj['console']
411
+
412
+ if not toon_utils.is_toon_available():
413
+ console.print("[red]TOON support not installed.[/red]")
414
+ console.print("Install with: [cyan]pip install claude-dev-cli[toon][/cyan]")
415
+ sys.exit(1)
416
+
417
+ try:
418
+ import json
419
+
420
+ # Read input
421
+ if input_file:
422
+ with open(input_file, 'r') as f:
423
+ data = json.load(f)
424
+ elif not sys.stdin.isatty():
425
+ data = json.load(sys.stdin)
426
+ else:
427
+ console.print("[red]Error: No input provided[/red]")
428
+ console.print("Usage: cdc toon encode [FILE] or pipe JSON via stdin")
429
+ sys.exit(1)
430
+
431
+ # Convert to TOON
432
+ toon_str = toon_utils.to_toon(data)
433
+
434
+ # Output
435
+ if output:
436
+ with open(output, 'w') as f:
437
+ f.write(toon_str)
438
+ console.print(f"[green]✓[/green] Converted to TOON: {output}")
439
+ else:
440
+ console.print(toon_str)
441
+
442
+ except Exception as e:
443
+ console.print(f"[red]Error: {e}[/red]")
444
+ sys.exit(1)
445
+
446
+
447
+ @toon.command('decode')
448
+ @click.argument('input_file', type=click.Path(exists=True), required=False)
449
+ @click.option('-o', '--output', type=click.Path(), help='Output file')
450
+ @click.pass_context
451
+ def toon_decode(ctx: click.Context, input_file: Optional[str], output: Optional[str]) -> None:
452
+ """Convert TOON format to JSON."""
453
+ console = ctx.obj['console']
454
+
455
+ if not toon_utils.is_toon_available():
456
+ console.print("[red]TOON support not installed.[/red]")
457
+ console.print("Install with: [cyan]pip install claude-dev-cli[toon][/cyan]")
458
+ sys.exit(1)
459
+
460
+ try:
461
+ import json
462
+
463
+ # Read input
464
+ if input_file:
465
+ with open(input_file, 'r') as f:
466
+ toon_str = f.read()
467
+ elif not sys.stdin.isatty():
468
+ toon_str = sys.stdin.read()
469
+ else:
470
+ console.print("[red]Error: No input provided[/red]")
471
+ console.print("Usage: cdc toon decode [FILE] or pipe TOON via stdin")
472
+ sys.exit(1)
473
+
474
+ # Convert from TOON
475
+ data = toon_utils.from_toon(toon_str)
476
+
477
+ # Output
478
+ json_str = json.dumps(data, indent=2)
479
+ if output:
480
+ with open(output, 'w') as f:
481
+ f.write(json_str)
482
+ console.print(f"[green]✓[/green] Converted to JSON: {output}")
483
+ else:
484
+ console.print(json_str)
485
+
486
+ except Exception as e:
487
+ console.print(f"[red]Error: {e}[/red]")
488
+ sys.exit(1)
489
+
490
+
491
+ @toon.command('info')
492
+ @click.pass_context
493
+ def toon_info(ctx: click.Context) -> None:
494
+ """Show TOON format installation status and token savings info."""
495
+ console = ctx.obj['console']
496
+
497
+ if toon_utils.is_toon_available():
498
+ console.print("[green]✓[/green] TOON format support is installed")
499
+ console.print("\n[bold]About TOON:[/bold]")
500
+ console.print("• Token-Oriented Object Notation")
501
+ console.print("• 30-60% fewer tokens than JSON")
502
+ console.print("• Optimized for LLM prompts")
503
+ console.print("• Human-readable and lossless")
504
+ console.print("\n[bold]Usage:[/bold]")
505
+ console.print(" cdc toon encode data.json -o data.toon")
506
+ console.print(" cdc toon decode data.toon -o data.json")
507
+ console.print(" cat data.json | cdc toon encode")
508
+ else:
509
+ console.print("[yellow]TOON format support not installed[/yellow]")
510
+ console.print("\nInstall with: [cyan]pip install claude-dev-cli[toon][/cyan]")
511
+ console.print("\n[bold]Benefits:[/bold]")
512
+ console.print("• Reduce API costs by 30-60%")
513
+ console.print("• Faster LLM response times")
514
+ console.print("• Same data, fewer tokens")
515
+
516
+
397
517
  if __name__ == '__main__':
398
518
  main(obj={})
@@ -0,0 +1,117 @@
1
+ """TOON format utilities for token-efficient LLM communication."""
2
+
3
+ from typing import Any, Optional
4
+
5
+ # Try to import toon-format, but make it optional
6
+ try:
7
+ from toon_format import encode as toon_encode, decode as toon_decode
8
+ TOON_AVAILABLE = True
9
+ except ImportError:
10
+ TOON_AVAILABLE = False
11
+ toon_encode = None
12
+ toon_decode = None
13
+
14
+
15
+ def is_toon_available() -> bool:
16
+ """Check if TOON format support is available."""
17
+ return TOON_AVAILABLE
18
+
19
+
20
+ def to_toon(data: Any) -> str:
21
+ """
22
+ Convert Python data to TOON format.
23
+
24
+ Args:
25
+ data: Python dict, list, or primitive to encode
26
+
27
+ Returns:
28
+ TOON-formatted string
29
+
30
+ Raises:
31
+ ImportError: If toon-format is not installed
32
+ """
33
+ if not TOON_AVAILABLE:
34
+ raise ImportError(
35
+ "TOON format support not installed. "
36
+ "Install with: pip install claude-dev-cli[toon]"
37
+ )
38
+
39
+ return toon_encode(data)
40
+
41
+
42
+ def from_toon(toon_str: str) -> Any:
43
+ """
44
+ Convert TOON format back to Python data.
45
+
46
+ Args:
47
+ toon_str: TOON-formatted string
48
+
49
+ Returns:
50
+ Python dict, list, or primitive
51
+
52
+ Raises:
53
+ ImportError: If toon-format is not installed
54
+ """
55
+ if not TOON_AVAILABLE:
56
+ raise ImportError(
57
+ "TOON format support not installed. "
58
+ "Install with: pip install claude-dev-cli[toon]"
59
+ )
60
+
61
+ return toon_decode(toon_str)
62
+
63
+
64
+ def format_for_llm(data: Any, use_toon: bool = True) -> str:
65
+ """
66
+ Format data for LLM consumption, preferring TOON if available.
67
+
68
+ Args:
69
+ data: Data to format
70
+ use_toon: Whether to use TOON format if available (default: True)
71
+
72
+ Returns:
73
+ Formatted string (TOON if available and requested, else JSON)
74
+ """
75
+ import json
76
+
77
+ if use_toon and TOON_AVAILABLE:
78
+ try:
79
+ return to_toon(data)
80
+ except Exception:
81
+ # Fall back to JSON if TOON encoding fails
82
+ pass
83
+
84
+ return json.dumps(data, indent=2)
85
+
86
+
87
+ def auto_detect_format(content: str) -> tuple[str, Any]:
88
+ """
89
+ Auto-detect if content is TOON or JSON and decode accordingly.
90
+
91
+ Args:
92
+ content: String content to decode
93
+
94
+ Returns:
95
+ Tuple of (format_name, decoded_data)
96
+
97
+ Raises:
98
+ ValueError: If content cannot be parsed as either format
99
+ """
100
+ import json
101
+
102
+ # Try TOON first if available
103
+ if TOON_AVAILABLE:
104
+ try:
105
+ data = from_toon(content)
106
+ return ("toon", data)
107
+ except Exception:
108
+ pass
109
+
110
+ # Try JSON
111
+ try:
112
+ data = json.loads(content)
113
+ return ("json", data)
114
+ except json.JSONDecodeError:
115
+ pass
116
+
117
+ raise ValueError("Content is neither valid TOON nor JSON")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: claude-dev-cli
3
- Version: 0.1.0
3
+ Version: 0.2.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
@@ -26,11 +26,14 @@ Requires-Dist: anthropic>=0.18.0
26
26
  Requires-Dist: click>=8.1.0
27
27
  Requires-Dist: rich>=13.0.0
28
28
  Requires-Dist: pydantic>=2.0.0
29
+ Provides-Extra: toon
30
+ Requires-Dist: toon-format>=0.9.0; extra == "toon"
29
31
  Provides-Extra: dev
30
32
  Requires-Dist: pytest>=7.0.0; extra == "dev"
31
33
  Requires-Dist: black>=23.0.0; extra == "dev"
32
34
  Requires-Dist: ruff>=0.1.0; extra == "dev"
33
35
  Requires-Dist: mypy>=1.0.0; extra == "dev"
36
+ Requires-Dist: toon-format>=0.9.0; extra == "dev"
34
37
  Dynamic: license-file
35
38
 
36
39
  # Claude Dev CLI
@@ -63,12 +66,27 @@ A powerful command-line tool for developers using Claude AI with multi-API routi
63
66
  - **Interactive**: Chat mode with conversation history
64
67
  - **Streaming**: Real-time responses
65
68
 
69
+ ### 🎒 TOON Format Support (Optional)
70
+ - **Token Reduction**: 30-60% fewer tokens than JSON
71
+ - **Cost Savings**: Reduce API costs significantly
72
+ - **Format Conversion**: JSON ↔ TOON with CLI tools
73
+ - **Auto-fallback**: Works without TOON installed
74
+
66
75
  ## Installation
67
76
 
77
+ ### Basic Installation
78
+
68
79
  ```bash
69
80
  pip install claude-dev-cli
70
81
  ```
71
82
 
83
+ ### With TOON Support (Recommended for Cost Savings)
84
+
85
+ ```bash
86
+ # Install with TOON format support for 30-60% token reduction
87
+ pip install claude-dev-cli[toon]
88
+ ```
89
+
72
90
  ## Quick Start
73
91
 
74
92
  ### 1. Set Up API Keys
@@ -141,6 +159,28 @@ cdc usage --days 7
141
159
  cdc usage --api client
142
160
  ```
143
161
 
162
+ ### 5. TOON Format (Optional - Reduces Tokens by 30-60%)
163
+
164
+ ```bash
165
+ # Check if TOON is installed
166
+ cdc toon info
167
+
168
+ # Convert JSON to TOON
169
+ echo '{"users": [{"id": 1, "name": "Alice"}]}' | cdc toon encode
170
+ # Output:
171
+ # users[1]{id,name}:
172
+ # 1,Alice
173
+
174
+ # Convert file
175
+ cdc toon encode data.json -o data.toon
176
+
177
+ # Convert TOON back to JSON
178
+ cdc toon decode data.toon -o data.json
179
+
180
+ # Use in workflows
181
+ cat large_data.json | cdc toon encode | cdc ask "analyze this data"
182
+ ```
183
+
144
184
  ## Configuration
145
185
 
146
186
  ### Global Configuration
@@ -0,0 +1,14 @@
1
+ claude_dev_cli/__init__.py,sha256=2ulyIQ3E-s6wBTKyeXAlqHMVA73zUGdaaNUsFiJ-nqs,469
2
+ claude_dev_cli/cli.py,sha256=vWjUgtYljbzutTcEQxWU6mITtboUWA3E17UynuHrXm0,15833
3
+ claude_dev_cli/commands.py,sha256=RKGx2rv56PM6eErvA2uoQ20hY8babuI5jav8nCUyUOk,3964
4
+ claude_dev_cli/config.py,sha256=YwJjVkW9S1O_iq_2O6YCjYtuFWUCmP18zA7esKDwkKU,5776
5
+ claude_dev_cli/core.py,sha256=97rR9BuNfnhJxFrd7dTdApGyPh6MeGNArcRmaiOY69I,4443
6
+ claude_dev_cli/templates.py,sha256=lKxH943ySfUKgyHaWa4W3LVv91SgznKgajRtSRp_4UY,2260
7
+ claude_dev_cli/toon_utils.py,sha256=S3px2UvmNEaltmTa5K-h21n2c0CPvYjZc9mc7kHGqNQ,2828
8
+ claude_dev_cli/usage.py,sha256=32rs0_dUn6ihha3vCfT3rwnvel_-sED7jvLpO7gu-KQ,7446
9
+ claude_dev_cli-0.2.0.dist-info/licenses/LICENSE,sha256=DGueuJwMJtMwgLO5mWlS0TaeBrFwQuNpNZ22PU9J2bw,1062
10
+ claude_dev_cli-0.2.0.dist-info/METADATA,sha256=uaSOqYhfDsIt3dEAh1iBtJHS8MUM6dWTC_aBJZF8m2M,10325
11
+ claude_dev_cli-0.2.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ claude_dev_cli-0.2.0.dist-info/entry_points.txt,sha256=zymgUIIVpFTARkFmxAuW2A4BQsNITh_L0uU-XunytHg,85
13
+ claude_dev_cli-0.2.0.dist-info/top_level.txt,sha256=m7MF6LOIuTe41IT5Fgt0lc-DK1EgM4gUU_IZwWxK0pg,15
14
+ claude_dev_cli-0.2.0.dist-info/RECORD,,
@@ -1,13 +0,0 @@
1
- claude_dev_cli/__init__.py,sha256=O2wq4c3zAUKOJ6liwykkHMqEyhhasrv69ybnAmP9BNU,469
2
- claude_dev_cli/cli.py,sha256=s5nYAvNQDYXfNXFs9NbVRib3EasqXMZayJNekl3JRX4,11574
3
- claude_dev_cli/commands.py,sha256=RKGx2rv56PM6eErvA2uoQ20hY8babuI5jav8nCUyUOk,3964
4
- claude_dev_cli/config.py,sha256=YwJjVkW9S1O_iq_2O6YCjYtuFWUCmP18zA7esKDwkKU,5776
5
- claude_dev_cli/core.py,sha256=97rR9BuNfnhJxFrd7dTdApGyPh6MeGNArcRmaiOY69I,4443
6
- claude_dev_cli/templates.py,sha256=lKxH943ySfUKgyHaWa4W3LVv91SgznKgajRtSRp_4UY,2260
7
- claude_dev_cli/usage.py,sha256=32rs0_dUn6ihha3vCfT3rwnvel_-sED7jvLpO7gu-KQ,7446
8
- claude_dev_cli-0.1.0.dist-info/licenses/LICENSE,sha256=DGueuJwMJtMwgLO5mWlS0TaeBrFwQuNpNZ22PU9J2bw,1062
9
- claude_dev_cli-0.1.0.dist-info/METADATA,sha256=mdYAz3MjH7qEZ-aOBsM3Jml8NNJUQz2HJvsSQZMioMM,9313
10
- claude_dev_cli-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
11
- claude_dev_cli-0.1.0.dist-info/entry_points.txt,sha256=zymgUIIVpFTARkFmxAuW2A4BQsNITh_L0uU-XunytHg,85
12
- claude_dev_cli-0.1.0.dist-info/top_level.txt,sha256=m7MF6LOIuTe41IT5Fgt0lc-DK1EgM4gUU_IZwWxK0pg,15
13
- claude_dev_cli-0.1.0.dist-info/RECORD,,