ccburn 0.1.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.
@@ -0,0 +1,127 @@
1
+ """Formatting utilities for ccburn."""
2
+
3
+ from datetime import datetime, timezone
4
+
5
+
6
+ def format_duration(minutes: int) -> str:
7
+ """Format minutes as human-readable duration.
8
+
9
+ Args:
10
+ minutes: Duration in minutes
11
+
12
+ Returns:
13
+ Formatted string like "2h 14m", "3d 5h", "45m"
14
+ """
15
+ if minutes < 0:
16
+ return "0m"
17
+
18
+ if minutes < 60:
19
+ return f"{minutes}m"
20
+
21
+ hours = minutes // 60
22
+ mins = minutes % 60
23
+
24
+ if hours < 24:
25
+ if mins:
26
+ return f"{hours}h {mins}m"
27
+ return f"{hours}h"
28
+
29
+ days = hours // 24
30
+ remaining_hours = hours % 24
31
+
32
+ if remaining_hours:
33
+ return f"{days}d {remaining_hours}h"
34
+ return f"{days}d"
35
+
36
+
37
+ def format_percentage(value: float, decimal_places: int = 0) -> str:
38
+ """Format 0-1 float as percentage string.
39
+
40
+ Args:
41
+ value: Float between 0 and 1
42
+ decimal_places: Number of decimal places (default 0)
43
+
44
+ Returns:
45
+ Formatted string like "62%" or "62.5%"
46
+ """
47
+ percent = value * 100
48
+ if decimal_places == 0:
49
+ return f"{percent:.0f}%"
50
+ return f"{percent:.{decimal_places}f}%"
51
+
52
+
53
+ def format_reset_time(resets_at: datetime, now: datetime | None = None) -> str:
54
+ """Format reset time as relative or absolute.
55
+
56
+ Args:
57
+ resets_at: When the limit resets
58
+ now: Current time (default: now)
59
+
60
+ Returns:
61
+ "Resets in 2h 14m" for < 24h, "Resets Tue 4:00 PM" otherwise
62
+ """
63
+ if now is None:
64
+ now = datetime.now(timezone.utc)
65
+
66
+ # Ensure both are timezone-aware
67
+ if resets_at.tzinfo is None:
68
+ resets_at = resets_at.replace(tzinfo=timezone.utc)
69
+ if now.tzinfo is None:
70
+ now = now.replace(tzinfo=timezone.utc)
71
+
72
+ delta = resets_at - now
73
+ total_minutes = int(delta.total_seconds() / 60)
74
+
75
+ if total_minutes < 0:
76
+ return "Reset pending"
77
+
78
+ if total_minutes < 24 * 60: # Less than 24 hours
79
+ return f"Resets in {format_duration(total_minutes)}"
80
+
81
+ # More than 24 hours - use absolute time
82
+ # Convert to local time for display
83
+ local_time = resets_at.astimezone()
84
+ day_name = local_time.strftime("%a") # "Tue"
85
+ time_str = local_time.strftime("%-I:%M %p") # "4:00 PM"
86
+ return f"Resets {day_name} {time_str}"
87
+
88
+
89
+ def get_utilization_color(utilization: float) -> str:
90
+ """Get color based on utilization percentage.
91
+
92
+ Args:
93
+ utilization: Float between 0 and 1
94
+
95
+ Returns:
96
+ Color name: "green", "yellow", "orange", or "red"
97
+ """
98
+ if utilization < 0.5:
99
+ return "green"
100
+ elif utilization < 0.75:
101
+ return "yellow"
102
+ elif utilization < 0.9:
103
+ return "bright_red" # Rich uses "bright_red" for orange-like
104
+ else:
105
+ return "red"
106
+
107
+
108
+ def get_status_indicator(utilization: float, budget_pace: float) -> str:
109
+ """Get status indicator for compact output.
110
+
111
+ Args:
112
+ utilization: Current usage (0-1)
113
+ budget_pace: How much of window has elapsed (0-1)
114
+
115
+ Returns:
116
+ Status indicator: "[ ]", "[*]", "[!]", or "[X]"
117
+ """
118
+ if utilization < 0.5:
119
+ return "[ ]" # Plenty available
120
+ elif utilization < 0.75:
121
+ if utilization <= budget_pace:
122
+ return "[*]" # On track
123
+ return "[!]" # Above pace
124
+ elif utilization < 0.9:
125
+ return "[!]" # Caution
126
+ else:
127
+ return "[X]" # Critical
@@ -0,0 +1,197 @@
1
+ Metadata-Version: 2.4
2
+ Name: ccburn
3
+ Version: 0.1.0
4
+ Summary: Terminal-based Claude Code usage limit visualizer with real-time burn-up charts
5
+ Author: JuanjoFuchs
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/JuanjoFuchs/ccburn
8
+ Project-URL: Repository, https://github.com/JuanjoFuchs/ccburn.git
9
+ Project-URL: Issues, https://github.com/JuanjoFuchs/ccburn/issues
10
+ Project-URL: Documentation, https://github.com/JuanjoFuchs/ccburn#readme
11
+ Keywords: claude,anthropic,usage,monitoring,tui,visualization,cli
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Utilities
22
+ Classifier: Topic :: System :: Monitoring
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: typer[all]>=0.9.0
27
+ Requires-Dist: rich>=13.0.0
28
+ Requires-Dist: plotext>=5.2.0
29
+ Requires-Dist: httpx>=0.25.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
32
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
33
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
34
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
35
+ Requires-Dist: build>=1.0.0; extra == "dev"
36
+ Requires-Dist: twine>=4.0.0; extra == "dev"
37
+ Requires-Dist: pyinstaller>=6.0.0; extra == "dev"
38
+ Dynamic: license-file
39
+
40
+ # ccburn
41
+
42
+ [![CI](https://img.shields.io/github/actions/workflow/status/JuanjoFuchs/ccburn/ci.yml?branch=main&label=CI)](https://github.com/JuanjoFuchs/ccburn/actions/workflows/ci.yml)
43
+ [![Release](https://img.shields.io/github/actions/workflow/status/JuanjoFuchs/ccburn/release.yml?label=Release)](https://github.com/JuanjoFuchs/ccburn/actions/workflows/release.yml)
44
+ [![PyPI](https://img.shields.io/pypi/v/ccburn)](https://pypi.org/project/ccburn/)
45
+ [![Python](https://img.shields.io/pypi/pyversions/ccburn)](https://pypi.org/project/ccburn/)
46
+ [![GitHub Release](https://img.shields.io/github/v/release/JuanjoFuchs/ccburn)](https://github.com/JuanjoFuchs/ccburn/releases)
47
+ [![WinGet](https://img.shields.io/badge/WinGet-JuanjoFuchs.ccburn-blue)](https://winstall.app/apps/JuanjoFuchs.ccburn)
48
+ [![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
49
+
50
+ TUI and CLI for Claude Code usage limits — burn-up charts, compact mode for status bars, JSON for automation.
51
+
52
+ ![ccburn screenshot](docs/ccburn.png)
53
+
54
+ ## Features
55
+
56
+ - **Real-time burn-up charts** — Visualize session and weekly usage with live-updating terminal graphics
57
+ - **Pace indicators** — See if you're ahead, on pace, or behind your usage budget (🧊/🔥/🚨)
58
+ - **Multiple output modes** — Full TUI, compact single-line for status bars, or JSON for scripting
59
+ - **Automatic data persistence** — SQLite-backed history for trend analysis
60
+ - **Dynamic window title** — Terminal tab shows current usage at a glance
61
+ - **Zoom views** — Focus on recent activity with `--since`
62
+
63
+ ## Installation
64
+
65
+ ### Windows (WinGet)
66
+
67
+ ```powershell
68
+ winget install JuanjoFuchs.ccburn
69
+ ```
70
+
71
+ ### Cross-Platform (pip)
72
+
73
+ ```bash
74
+ pip install ccburn
75
+ ```
76
+
77
+ ### From Source
78
+
79
+ ```bash
80
+ git clone https://github.com/JuanjoFuchs/ccburn.git
81
+ cd ccburn
82
+ pip install -e ".[dev]"
83
+ ```
84
+
85
+ ## Quick Start
86
+
87
+ 1. **Ensure Claude Code is installed** — ccburn reads credentials from Claude Code's config
88
+ 2. **Run ccburn:**
89
+ ```bash
90
+ ccburn # Session limit (default)
91
+ ccburn weekly # Weekly limit
92
+ ccburn weekly-sonnet # Weekly Sonnet limit
93
+ ```
94
+
95
+ ## Usage Examples
96
+
97
+ ```bash
98
+ # Full TUI with burn-up chart (default)
99
+ ccburn
100
+
101
+ # Weekly usage view
102
+ ccburn weekly
103
+
104
+ # Compact output for tmux/status bars
105
+ ccburn --compact
106
+ # Output: Session: 🔥 45% (2h14m) | Weekly: 🧊 12% | Sonnet: 🧊 3%
107
+
108
+ # JSON output for scripting/automation
109
+ ccburn --json
110
+
111
+ # Zoom to last 30 minutes
112
+ ccburn --since 30m
113
+
114
+ # Single snapshot (no live updates)
115
+ ccburn --once
116
+
117
+ # Custom refresh interval (seconds)
118
+ ccburn --interval 10
119
+ ```
120
+
121
+ ## Command Line Reference
122
+
123
+ ```
124
+ Usage: ccburn [OPTIONS] [LIMIT]
125
+
126
+ Arguments:
127
+ [LIMIT] Which limit to display [default: session]
128
+ Options: session, weekly, weekly-sonnet
129
+
130
+ Options:
131
+ -i, --interval INTEGER Refresh interval in seconds [default: 5/30]
132
+ -s, --since TEXT Only show data since (e.g., 30m, 2h, 1d)
133
+ -j, --json Output JSON and exit
134
+ -o, --once Print once and exit (no live updates)
135
+ -c, --compact Single-line output for status bars
136
+ --debug Show debug information
137
+ --version Show version and exit
138
+ --help Show this message and exit
139
+ ```
140
+
141
+ ## Pace Indicators
142
+
143
+ | Emoji | Status | Meaning |
144
+ |-------|--------|---------|
145
+ | 🧊 | Behind pace | Usage below expected budget — you have headroom |
146
+ | 🔥 | On pace | Usage tracking with expected budget |
147
+ | 🚨 | Ahead of pace | Usage above expected budget — slow down! |
148
+
149
+ ## Requirements
150
+
151
+ - **Python 3.10+**
152
+ - **Claude Code** installed with valid credentials
153
+ - Terminal with Unicode support (for charts and emojis)
154
+
155
+ ## How It Works
156
+
157
+ ccburn reads your Claude Code credentials and fetches usage data from the Anthropic API. It calculates:
158
+
159
+ - **Budget pace** — Where you "should" be based on time elapsed in the window
160
+ - **Burn rate** — How fast you're consuming your limit
161
+ - **Time to limit** — Estimated time until you hit 100% (if current rate continues)
162
+
163
+ Data is stored locally in SQLite for historical analysis and to minimize API calls when running multiple instances.
164
+
165
+ ## Troubleshooting
166
+
167
+ ### "Credentials not found"
168
+
169
+ Ensure Claude Code is installed and you've logged in at least once:
170
+ ```bash
171
+ claude # This will prompt for login if needed
172
+ ```
173
+
174
+ ### Chart not displaying correctly
175
+
176
+ Ensure your terminal supports Unicode and has a monospace font with emoji support. Recommended terminals:
177
+ - **Windows**: Windows Terminal
178
+ - **macOS**: iTerm2, Terminal.app
179
+ - **Linux**: Kitty, Alacritty, GNOME Terminal
180
+
181
+ ### Stale data indicator
182
+
183
+ If you see "(stale)" in the header, ccburn couldn't reach the API. It will continue showing cached data and retry automatically.
184
+
185
+ ## Contributing
186
+
187
+ Contributions are welcome! Please feel free to submit a Pull Request.
188
+
189
+ ## License
190
+
191
+ [MIT](LICENSE)
192
+
193
+ ## Acknowledgments
194
+
195
+ - [Rich](https://github.com/Textualize/rich) — Beautiful terminal formatting
196
+ - [Plotext](https://github.com/piccolomo/plotext) — Terminal plotting
197
+ - [Typer](https://github.com/tiangolo/typer) — CLI framework
@@ -0,0 +1,22 @@
1
+ ccburn/__init__.py,sha256=u8tlHJ2bTam19CROn2nufmcfCONN9BwlRLY-8AOu8Os,191
2
+ ccburn/app.py,sha256=FcVHLbnygKbMTGIFZRN5jS_Pve8VdKImfLi2KsDuEoU,15510
3
+ ccburn/cli.py,sha256=5qYYmOWcUXNYEdK-E3DBixfWQK4wKIQs6FPvTrIfOVI,7184
4
+ ccburn/main.py,sha256=TqWLl9xxOtbpTQr-ObomzSLG3jNec2GZ6RKEQYYdGLg,2474
5
+ ccburn/data/__init__.py,sha256=ZczEZwodQ-MMO5F7fVNsyIpUCRY8Ya9W4pwdOOJWxm4,803
6
+ ccburn/data/credentials.py,sha256=23ABImkZ3yC5CaArsFk3p5ujEHhEwQufJ7QUgWbSTIs,3569
7
+ ccburn/data/history.py,sha256=ouBxrXpMp_eTs0kba1Bg55TI6bsBSMToJ32tH1wNHQI,12879
8
+ ccburn/data/models.py,sha256=Sd2T36gH6OaNHl9zRlnnQXI-ziBA8Gl6rPYQIzmr7G4,5403
9
+ ccburn/data/usage_client.py,sha256=_dGwmI5vYPk4S-HUe2_fnTwSuAfTPaOFff7mKPFnhps,4570
10
+ ccburn/display/__init__.py,sha256=aL7TV53kU5oxlIwJ8M17stG2aC6UeGB-pj2u5BOpegs,495
11
+ ccburn/display/chart.py,sha256=j1qM6YX_K5SfKCxaob3-mT1vJjr8VMdsHIN8ORJu-2c,11421
12
+ ccburn/display/gauges.py,sha256=jkPy3BuPsN1__4Ynt0DxK8t3Su_2jl5HAJifCmdtiiA,8696
13
+ ccburn/display/layout.py,sha256=UndPxyh32jWGdDgOZCvedz06WcKxYMSchLwpOkkXQKo,8093
14
+ ccburn/utils/__init__.py,sha256=N6EzUX9hUJkuga_l9Ci3of1CWNtQgpNmMmNyY2DgYrg,1119
15
+ ccburn/utils/calculator.py,sha256=QcFm5X-VWZzucHdInEjjqKV5oZaNsdpMgl8oKvHAQYc,6174
16
+ ccburn/utils/formatting.py,sha256=vFpGY8v60G8OjTmZ1I1dYCr3h7YIfB8ezVMICb6RyZk,3327
17
+ ccburn-0.1.0.dist-info/licenses/LICENSE,sha256=Qf2mqNi2qJ35JytfoTdR1SgYhZ2Mt4Ohcf-tu_MuYC0,1068
18
+ ccburn-0.1.0.dist-info/METADATA,sha256=VKdT00_p1-erNPI_QzwCOjEHYn4X6ytdm2babq99uBs,6604
19
+ ccburn-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ ccburn-0.1.0.dist-info/entry_points.txt,sha256=GfFQ5VusMR8RJ9meygqWjaErdmYsf_arbILzf64WjLU,43
21
+ ccburn-0.1.0.dist-info/top_level.txt,sha256=SM8TwGQZqQKKIQObVWQkfpA0OI4gRut7bPl-iM3g5RI,7
22
+ ccburn-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ccburn = ccburn.main:app
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 JuanjoFuchs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ ccburn