claude-code-statusline 0.7.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.
- claude_code_statusline-0.7.1/LICENSE +21 -0
- claude_code_statusline-0.7.1/PKG-INFO +439 -0
- claude_code_statusline-0.7.1/README.md +421 -0
- claude_code_statusline-0.7.1/pyproject.toml +88 -0
- claude_code_statusline-0.7.1/setup.cfg +4 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/__init__.py +6 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/config/__init__.py +0 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/config/defaults.py +29 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/config/loader.py +123 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/config/schema.py +25 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/parsers/__init__.py +0 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/parsers/jsonl.py +330 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/parsers/tokens.py +159 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/renderer.py +159 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/statusline.py +126 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/types.py +49 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/utils/__init__.py +0 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/utils/colors.py +112 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/utils/debug.py +48 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/utils/formatting.py +57 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/utils/git.py +120 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/utils/models.py +194 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/__init__.py +0 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/base.py +36 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/builtin/__init__.py +29 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/builtin/context.py +74 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/builtin/cost.py +111 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/builtin/directory.py +33 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/builtin/git.py +104 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/builtin/model.py +31 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/builtin/separator.py +26 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/builtin/session.py +54 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline/widgets/registry.py +65 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline.egg-info/PKG-INFO +439 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline.egg-info/SOURCES.txt +37 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline.egg-info/dependency_links.txt +1 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline.egg-info/entry_points.txt +2 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline.egg-info/requires.txt +2 -0
- claude_code_statusline-0.7.1/src/claude_code_statusline.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Will Pfleger
|
|
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,439 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: claude-code-statusline
|
|
3
|
+
Version: 0.7.1
|
|
4
|
+
Summary: A Python script for Claude Code statusline with context usage tracking
|
|
5
|
+
Author-email: Will Pfleger <pfleger.will@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/wpfleger96/claude-code-status-line
|
|
8
|
+
Project-URL: Repository, https://github.com/wpfleger96/claude-code-status-line.git
|
|
9
|
+
Project-URL: Documentation, https://github.com/wpfleger96/claude-code-status-line#readme
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/wpfleger96/claude-code-status-line/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/wpfleger96/claude-code-status-line/blob/main/CHANGELOG.md
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: pyyaml>=6.0
|
|
16
|
+
Requires-Dist: pydantic>=2.0
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# Claude Code Statusline Script
|
|
20
|
+
|
|
21
|
+
## Overview
|
|
22
|
+
|
|
23
|
+
A Python script that generates a formatted [status line](https://docs.anthropic.com/en/docs/claude-code/statusline) for Claude Code, displaying the current model, working directory, and context usage information. The script provides real-time feedback on token consumption relative to the model's context window limit.
|
|
24
|
+
|
|
25
|
+
<img width="1217" height="427" alt="image" src="https://github.com/user-attachments/assets/a5542835-f523-402c-8364-9a3efa156a04" />
|
|
26
|
+
|
|
27
|
+
## Project Structure
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
claude-code-status-line/
|
|
31
|
+
├── src/
|
|
32
|
+
│ └── claude_code_statusline/
|
|
33
|
+
│ ├── __init__.py # Package initialization
|
|
34
|
+
│ ├── __version__.py # Version tracking
|
|
35
|
+
│ ├── statusline.py # Main statusline command
|
|
36
|
+
│ ├── config/ # Configuration system
|
|
37
|
+
│ │ ├── defaults.py # Default widget configuration
|
|
38
|
+
│ │ ├── loader.py # Config file loading
|
|
39
|
+
│ │ └── schema.py # Pydantic schemas
|
|
40
|
+
│ ├── widgets/ # Widget system
|
|
41
|
+
│ │ ├── base.py # Base widget class
|
|
42
|
+
│ │ ├── registry.py # Widget registration
|
|
43
|
+
│ │ └── builtin/ # Built-in widgets
|
|
44
|
+
│ ├── parsers/ # Transcript parsing
|
|
45
|
+
│ │ ├── jsonl.py # JSONL parser
|
|
46
|
+
│ │ └── tokens.py # Real token counting
|
|
47
|
+
│ └── utils/ # Shared utilities
|
|
48
|
+
├── .github/workflows/
|
|
49
|
+
│ └── release.yml # Automated semantic versioning
|
|
50
|
+
├── pyproject.toml # Package configuration
|
|
51
|
+
└── README.md
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Requirements
|
|
55
|
+
|
|
56
|
+
- Python 3.9 or higher
|
|
57
|
+
- [uv](https://docs.astral.sh/uv/) for dependency management
|
|
58
|
+
- No installation needed (uses `uv run`)
|
|
59
|
+
|
|
60
|
+
## Installation
|
|
61
|
+
|
|
62
|
+
1. **Clone the repository:**
|
|
63
|
+
```bash
|
|
64
|
+
git clone https://github.com/wpfleger96/claude-code-status-line.git
|
|
65
|
+
cd claude-code-status-line
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
2. **Install dependencies:**
|
|
69
|
+
```bash
|
|
70
|
+
uv sync --no-config
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
3. **Verify installation:**
|
|
74
|
+
```bash
|
|
75
|
+
uv run --no-config claude-statusline --help
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
Add a `statusLine` section to your `~/.claude/settings.json` file:
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"statusLine": {
|
|
84
|
+
"type": "command",
|
|
85
|
+
"command": "sh -c 'cd /path/to/claude-code-status-line && uv run --no-config claude-statusline'",
|
|
86
|
+
"padding": 0
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Replace `/path/to/claude-code-status-line` with the absolute path to where you cloned this repository (e.g., `~/Development/Personal/claude-code-status-line`).
|
|
92
|
+
|
|
93
|
+
## Configuration
|
|
94
|
+
|
|
95
|
+
### Widget Customization
|
|
96
|
+
|
|
97
|
+
Customize your status line by creating `~/.config/claude-statusline/config.yaml`:
|
|
98
|
+
|
|
99
|
+
```yaml
|
|
100
|
+
version: 1
|
|
101
|
+
lines:
|
|
102
|
+
- - type: model
|
|
103
|
+
color: cyan
|
|
104
|
+
- type: separator
|
|
105
|
+
- type: directory
|
|
106
|
+
color: blue
|
|
107
|
+
- type: separator
|
|
108
|
+
- type: git-branch
|
|
109
|
+
color: magenta
|
|
110
|
+
- type: separator
|
|
111
|
+
- type: context-percentage
|
|
112
|
+
color: auto # auto-colors based on usage
|
|
113
|
+
- type: separator
|
|
114
|
+
- type: cost
|
|
115
|
+
color: auto # auto-colors based on amount
|
|
116
|
+
- type: separator
|
|
117
|
+
- type: session-clock
|
|
118
|
+
color: white
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Widget Options:**
|
|
122
|
+
- `type` (required): Widget identifier (see Available Widgets list below)
|
|
123
|
+
- `color` (optional): Color name or "auto" for dynamic coloring
|
|
124
|
+
- `bold` (optional): Make text bold (default: false)
|
|
125
|
+
- `metadata` (optional): Widget-specific configuration
|
|
126
|
+
|
|
127
|
+
**Color Options:** `white`, `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `dim`, `auto`, `none`
|
|
128
|
+
|
|
129
|
+
**Auto-Generated Config:**
|
|
130
|
+
If no config file exists, one is automatically created with all widgets enabled. Delete `~/.config/claude-statusline/config.yaml` to regenerate defaults.
|
|
131
|
+
|
|
132
|
+
**Stale Config Warning:**
|
|
133
|
+
When new widgets are added, the script warns you:
|
|
134
|
+
```
|
|
135
|
+
Warning: Config is missing widgets from defaults: session-clock.
|
|
136
|
+
Delete ~/.config/claude-statusline/config.yaml to regenerate with new defaults.
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Features
|
|
140
|
+
|
|
141
|
+
### Customizable Widget System
|
|
142
|
+
- **Configurable Layout**: Customize which widgets appear and in what order via `~/.config/claude-statusline/config.yaml`
|
|
143
|
+
- **Built-in Widgets**: 14 widgets including model, directory, git status, context, cost, session info
|
|
144
|
+
- **Flexible Styling**: Per-widget color customization and bold formatting
|
|
145
|
+
- **Automatic Fallback**: Missing config uses sensible defaults with all widgets enabled
|
|
146
|
+
- **Stale Config Detection**: Warns when config is missing newly-added widgets
|
|
147
|
+
|
|
148
|
+
**Available Widgets:**
|
|
149
|
+
- `model` - Claude model name (e.g., "Sonnet 4.5")
|
|
150
|
+
- `directory` - Current working directory
|
|
151
|
+
- `git-branch` - Active git branch name
|
|
152
|
+
- `git-changes` - Staged/unstaged changes count
|
|
153
|
+
- `git-worktree` - Git worktree name (if applicable)
|
|
154
|
+
- `context-percentage` - Context usage with progress bar
|
|
155
|
+
- `context-tokens` - Token count (current/limit)
|
|
156
|
+
- `cost` - Session cost in USD
|
|
157
|
+
- `lines-added` - Lines added in session
|
|
158
|
+
- `lines-removed` - Lines removed in session
|
|
159
|
+
- `lines-changed` - Combined added/removed
|
|
160
|
+
- `session-id` - Claude Code session UUID
|
|
161
|
+
- `session-clock` - Elapsed session time
|
|
162
|
+
- `separator` - Visual separator (default: "|")
|
|
163
|
+
|
|
164
|
+
### Real Token Counting
|
|
165
|
+
- **Actual Token Values**: Reads real token counts from Claude Code transcript files instead of estimating
|
|
166
|
+
- **Message-Level Accuracy**: Extracts exact `input_tokens` and `output_tokens` from message usage data
|
|
167
|
+
- **Compact-Aware**: Correctly handles `/compact` boundaries, counting only active context
|
|
168
|
+
- **System Overhead**: Automatically accounts for Claude Code's system prompt and tool definitions (21400 tokens default)
|
|
169
|
+
|
|
170
|
+
### Smart Context Tracking
|
|
171
|
+
- **JSONL Transcript Parsing**: Analyzes Claude Code's session files to find compact boundaries and count only relevant tokens
|
|
172
|
+
- **Fallback Compatibility**: Falls back to simple file size calculation for non-JSONL transcript formats
|
|
173
|
+
- **Calibration Tool**: Includes `calibrate_token_counting.py` to validate and improve accuracy
|
|
174
|
+
|
|
175
|
+
### Token Calculation
|
|
176
|
+
|
|
177
|
+
#### How It Works
|
|
178
|
+
- Reads actual token counts from transcript `message.usage` fields (input_tokens + output_tokens)
|
|
179
|
+
- Falls back to estimation (character count ÷ 3.31) only when usage data is unavailable
|
|
180
|
+
- Adds system overhead tokens (21400 by default) for Claude Code's system prompt, tools, and memory
|
|
181
|
+
- Retrieves model-specific context limits from cached API data, live fetches, or hardcoded fallbacks
|
|
182
|
+
|
|
183
|
+
#### Configuration
|
|
184
|
+
Customize token calculations via environment variables:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# System overhead (default: 21400 tokens)
|
|
188
|
+
export CLAUDE_CODE_SYSTEM_OVERHEAD=20000
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### API Cache System
|
|
192
|
+
Context limits are retrieved from:
|
|
193
|
+
1. **Local Cache**: `/tmp/claude_code_model_data_cache.json` (1-week TTL)
|
|
194
|
+
2. **Live API**: [LiteLLM Model Database](https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json)
|
|
195
|
+
3. **Fallback**: Hardcoded model limits
|
|
196
|
+
|
|
197
|
+
Cache benefits: Faster rendering, reduced network dependency, automatic refresh.
|
|
198
|
+
|
|
199
|
+
### Display Features
|
|
200
|
+
|
|
201
|
+
**Progress Bar**: 10-segment bar using filled (●) and empty (○) circles
|
|
202
|
+
|
|
203
|
+
**Context Usage Colors**:
|
|
204
|
+
| Color | Usage | Condition |
|
|
205
|
+
|-------|-------|-----------|
|
|
206
|
+
| Grey | 0% | No active transcript |
|
|
207
|
+
| Green | <50% | Low usage |
|
|
208
|
+
| Yellow| 50-79%| Medium usage |
|
|
209
|
+
| Red | 80%+ | High usage |
|
|
210
|
+
|
|
211
|
+
**Cost Tracking Colors**:
|
|
212
|
+
| Color | Cost Range |
|
|
213
|
+
|-------|------------|
|
|
214
|
+
| Grey | $0.00 (exactly zero) |
|
|
215
|
+
| Green | $0.01 - $4.99 |
|
|
216
|
+
| Yellow| $5.00 - $9.99 |
|
|
217
|
+
| Red | $10.00+ |
|
|
218
|
+
|
|
219
|
+
**Line Change Colors**:
|
|
220
|
+
| Metric | Zero (Grey) | Non-Zero |
|
|
221
|
+
|--------|-------------|----------|
|
|
222
|
+
| Lines Added | 0 lines | Green (>0) |
|
|
223
|
+
| Lines Removed | 0 lines | Red (>0) |
|
|
224
|
+
|
|
225
|
+
**Git Integration**:
|
|
226
|
+
- `git-branch`: Shows current branch with fallback text when not in a repo
|
|
227
|
+
- `git-changes`: Displays staged/unstaged changes (e.g., "+5 ~3 -2")
|
|
228
|
+
- `git-worktree`: Shows worktree name if working in a linked worktree
|
|
229
|
+
|
|
230
|
+
**Session Tracking**:
|
|
231
|
+
- `session-id`: Complete Claude Code session UUID for file matching
|
|
232
|
+
- `session-clock`: Elapsed session time (e.g., "Elapsed: 2hr 15m")
|
|
233
|
+
|
|
234
|
+
Widget rendering is intelligent - widgets with no data hide automatically, and orphaned separators are removed.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Example Outputs
|
|
239
|
+
|
|
240
|
+
**Default configuration with git integration:**
|
|
241
|
+
```
|
|
242
|
+
Sonnet 4.5 | claude-code-status-line | main | ●●●●●●○○○○ 60% (120K/200K tokens) | Cost: $2.50 USD | +150 ~25 -10 | Session: 852d18cc | Elapsed: 2hr 15m
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**High context usage:**
|
|
246
|
+
```
|
|
247
|
+
Sonnet 4.5 | my-project | feature/auth | ●●●●●●●●●○ 90% (180K/200K tokens) | Cost: $8.75 USD | +500 ~50 -100 | Session: a3f7b2cd | Elapsed: 45m
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
**Low usage (widgets hide when zero):**
|
|
251
|
+
```
|
|
252
|
+
Sonnet 4.5 | my-project | main | ○○○○○○○○○○ 0% (783/200K tokens) | Cost: $0.00 USD | Session: d6994160 | Elapsed: 5m
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
**No active transcript:**
|
|
256
|
+
```
|
|
257
|
+
Sonnet 4.5 | my-project | develop | No active transcript | Cost: $0.00 USD | Session: 7b89c123 | Elapsed: 1m
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
## Debug Logging
|
|
263
|
+
|
|
264
|
+
For debugging and understanding how the script processes Claude Code sessions, you can enable detailed logging:
|
|
265
|
+
|
|
266
|
+
### Enable Debug Mode
|
|
267
|
+
```bash
|
|
268
|
+
export CLAUDE_CODE_STATUSLINE_DEBUG=1
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Log Files Location
|
|
272
|
+
Debug logs are written to **per-session files** in the `logs/` directory:
|
|
273
|
+
|
|
274
|
+
- **Session-specific logs**: `logs/statusline_debug_<session_id>.log`
|
|
275
|
+
- **Examples**:
|
|
276
|
+
- `logs/statusline_debug_d6994160-5c39-4ecf-8922-65a36b984ec5.log` (UUID-based sessions)
|
|
277
|
+
- `logs/statusline_debug_unknown.log` (fallback for edge cases)
|
|
278
|
+
|
|
279
|
+
### Debug Features
|
|
280
|
+
- **Session metadata**: Model ID, version, working directory logging
|
|
281
|
+
- **Token analysis**: Per-message-type breakdown with percentages and field contributions
|
|
282
|
+
- **Compact detection**: Precise `/compact` boundary locations with token reduction stats
|
|
283
|
+
- **Per-session logs**: Isolated debug files (`logs/statusline_debug_<session_id>.log`)
|
|
284
|
+
- **Error handling**: Comprehensive parsing error logging and fallback behavior
|
|
285
|
+
|
|
286
|
+
### Example Debug Output
|
|
287
|
+
```
|
|
288
|
+
[2025-09-26 15:03:09] === SESSION METADATA ===
|
|
289
|
+
[2025-09-26 15:03:09] Model: claude-opus-4-1-20250805 (Opus 4.1) | Version: 0.8.5
|
|
290
|
+
[2025-09-26 15:03:09] Found compact boundary at line 148, using content from line 149 onwards
|
|
291
|
+
[2025-09-26 15:03:09] Token Breakdown: assistant: 17,816 tokens (57%) | user: 13,275 tokens (42%)
|
|
292
|
+
[2025-09-26 15:03:09] Total: Conversation=31,092, System=15,400, Reserved=45,000 → 91,492 tokens
|
|
293
|
+
[2025-09-26 15:03:09] Token reduction from compaction: 146,759 tokens saved
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**Note**: Debug logs are automatically excluded from git via `.gitignore` to prevent accidental commits of session data.
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## Token Counting Calibration Tool
|
|
301
|
+
|
|
302
|
+
The project includes `claude-calibrate`, a command-line tool to verify and improve token counting accuracy against Claude's official measurements.
|
|
303
|
+
|
|
304
|
+
### Purpose
|
|
305
|
+
- Compare script calculations against Claude's official `/context` command output
|
|
306
|
+
- Identify discrepancies and suggest calibration factors
|
|
307
|
+
- Validate token counting accuracy when new Claude Code versions are released
|
|
308
|
+
|
|
309
|
+
### Usage
|
|
310
|
+
|
|
311
|
+
#### Semi-Automated Mode (Default)
|
|
312
|
+
```bash
|
|
313
|
+
uv run --no-config claude-calibrate session1.jsonl session2.jsonl --verbose
|
|
314
|
+
```
|
|
315
|
+
The tool provides precise instructions for resuming each session and prompts you to enter the official token counts.
|
|
316
|
+
|
|
317
|
+
#### Manual Override Mode
|
|
318
|
+
```bash
|
|
319
|
+
uv run --no-config claude-calibrate session1.jsonl session2.jsonl \
|
|
320
|
+
--known-tokens 17.5k 68k --verbose
|
|
321
|
+
```
|
|
322
|
+
Provide known token counts to skip automatic session resumption (useful for sessions that can't be resumed).
|
|
323
|
+
|
|
324
|
+
#### Auto-Discovery Mode
|
|
325
|
+
```bash
|
|
326
|
+
uv run --no-config claude-calibrate --max-sessions 3 --verbose
|
|
327
|
+
```
|
|
328
|
+
Automatically finds recent session files from all Claude Code project directories and provides instructions for manual calibration.
|
|
329
|
+
|
|
330
|
+
### Example Calibration Report
|
|
331
|
+
```
|
|
332
|
+
📊 Successfully calibrated 2 session(s)
|
|
333
|
+
|
|
334
|
+
INDIVIDUAL RESULTS:
|
|
335
|
+
❌ session1.jsonl: Script 46,520 vs Claude 68,000 tokens (+31.6% difference)
|
|
336
|
+
✅ session2.jsonl: Script 17,470 vs Claude 17,500 tokens (+0.2% difference)
|
|
337
|
+
|
|
338
|
+
SUMMARY:
|
|
339
|
+
Average discrepancy: +15.9% | Suggested calibration factor: 1.231
|
|
340
|
+
⚠️ Token counting has moderate accuracy - consider adjusting CHARS_PER_TOKEN ratio
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Features
|
|
344
|
+
- **Auto-discovery**: Finds recent sessions from all Claude Code project directories
|
|
345
|
+
- **Semi-automated**: Provides precise resumption instructions for manual token collection
|
|
346
|
+
- **Directory decoding**: Handles hyphenated paths (`-Users-name-Project` → `/Users/name/Project`)
|
|
347
|
+
- **Flexible input**: Accepts raw numbers, K-suffixed values, or full `/context` output
|
|
348
|
+
- **Accuracy validation**: Compares against Claude's official measurements
|
|
349
|
+
- **Calibration recommendations**: Suggests specific improvements and correction factors
|
|
350
|
+
- **uv compatibility**: Uses `uv run` for portable execution across Python environments
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## Development
|
|
355
|
+
|
|
356
|
+
### Package Structure
|
|
357
|
+
|
|
358
|
+
The project uses a modern `src/` layout following Python packaging best practices:
|
|
359
|
+
|
|
360
|
+
- **`src/claude_code_statusline/`**: Main package directory
|
|
361
|
+
- Enables proper import resolution
|
|
362
|
+
- Makes the package PyPI-ready
|
|
363
|
+
- Prevents accidental imports from source during development
|
|
364
|
+
|
|
365
|
+
### Local Development
|
|
366
|
+
|
|
367
|
+
1. **Clone and setup:**
|
|
368
|
+
```bash
|
|
369
|
+
git clone https://github.com/wpfleger96/claude-code-status-line.git
|
|
370
|
+
cd claude-code-status-line
|
|
371
|
+
uv sync --no-config
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
2. **Make changes to source files:**
|
|
375
|
+
- Edit files in `src/claude_code_statusline/`
|
|
376
|
+
- Changes are automatically reflected when using `uv run`
|
|
377
|
+
|
|
378
|
+
3. **Test your changes:**
|
|
379
|
+
```bash
|
|
380
|
+
# Test statusline
|
|
381
|
+
echo '{"workspace": {"current_dir": "/test"}, "transcript_path": "", "model": {"id": "test", "display_name": "Test"}, "cost": {}, "version": "test"}' | uv run --no-config claude-statusline
|
|
382
|
+
|
|
383
|
+
# Test calibration
|
|
384
|
+
uv run --no-config claude-calibrate --help
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
4. **Debug mode:**
|
|
388
|
+
```bash
|
|
389
|
+
export CLAUDE_CODE_STATUSLINE_DEBUG=1
|
|
390
|
+
# Debug logs will be written to logs/ directory
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Releases
|
|
394
|
+
|
|
395
|
+
This project uses [semantic-release](https://python-semantic-release.readthedocs.io/) for automated versioning and releases.
|
|
396
|
+
|
|
397
|
+
**Commit Message Format:**
|
|
398
|
+
```
|
|
399
|
+
<type>(<scope>): <description>
|
|
400
|
+
|
|
401
|
+
[optional body]
|
|
402
|
+
|
|
403
|
+
[optional footer]
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Types:**
|
|
407
|
+
- `feat:` New feature (minor version bump)
|
|
408
|
+
- `fix:` Bug fix (patch version bump)
|
|
409
|
+
- `docs:` Documentation changes (patch version bump)
|
|
410
|
+
- `chore:` Maintenance tasks (patch version bump)
|
|
411
|
+
- `refactor:` Code refactoring (patch version bump)
|
|
412
|
+
- `BREAKING CHANGE:` in footer (major version bump)
|
|
413
|
+
|
|
414
|
+
**Example:**
|
|
415
|
+
```bash
|
|
416
|
+
git commit -m "feat: add support for new Claude models"
|
|
417
|
+
git commit -m "fix: correct token calculation for edge cases"
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**Release Process:**
|
|
421
|
+
1. Push commits to `main` branch
|
|
422
|
+
2. GitHub Actions automatically:
|
|
423
|
+
- Analyzes commit messages
|
|
424
|
+
- Determines version bump
|
|
425
|
+
- Updates version in files
|
|
426
|
+
- Generates CHANGELOG.md
|
|
427
|
+
- Creates GitHub release and tag
|
|
428
|
+
- Commits changes back to repository
|
|
429
|
+
|
|
430
|
+
### Contributing
|
|
431
|
+
|
|
432
|
+
Contributions are welcome! Please:
|
|
433
|
+
1. Fork the repository
|
|
434
|
+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
|
|
435
|
+
3. Use conventional commit messages
|
|
436
|
+
4. Push to your branch
|
|
437
|
+
5. Open a Pull Request
|
|
438
|
+
|
|
439
|
+
For bug reports or feature requests, please [open an issue](https://github.com/wpfleger96/claude-code-status-line/issues).
|