code-meter 0.2.0__tar.gz → 0.3.0__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.
- {code_meter-0.2.0 → code_meter-0.3.0}/PKG-INFO +42 -23
- {code_meter-0.2.0 → code_meter-0.3.0}/README.md +41 -22
- {code_meter-0.2.0 → code_meter-0.3.0}/pyproject.toml +1 -1
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/cli.py +47 -25
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/watcher.py +16 -8
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter.egg-info/PKG-INFO +42 -23
- {code_meter-0.2.0 → code_meter-0.3.0}/setup.cfg +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/setup.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/__init__.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/analytics/__init__.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/analytics/costs.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/analytics/reports.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/analytics/tokens.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/config.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/models/__init__.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/models/project.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/models/usage.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/pricing/__init__.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/pricing/anthropic.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/pricing/engine.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/pricing/google.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/pricing/live.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/pricing/openai.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/providers/__init__.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/providers/antigravity.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/providers/base.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/providers/claude_code.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/providers/codex.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/storage/__init__.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/storage/database.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/storage/repository.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/ui/__init__.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/ui/dashboard.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter/ui/tables.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter.egg-info/SOURCES.txt +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter.egg-info/dependency_links.txt +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter.egg-info/entry_points.txt +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter.egg-info/requires.txt +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/src/code_meter.egg-info/top_level.txt +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/tests/test_analytics.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/tests/test_database.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/tests/test_pricing.py +0 -0
- {code_meter-0.2.0 → code_meter-0.3.0}/tests/test_scanner.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: code-meter
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Local AI coding token usage tracker and cost estimator for Claude Code and future agents.
|
|
5
5
|
Author-email: Dhanush Nayak <dhanushnayak.ram@mail.com>
|
|
6
6
|
License: MIT
|
|
@@ -71,18 +71,51 @@ This launches the interactive Rich terminal dashboard displaying key metrics, mo
|
|
|
71
71
|
|
|
72
72
|
---
|
|
73
73
|
|
|
74
|
+
## 🖥️ Interactive Rich Terminal UI
|
|
75
|
+
|
|
76
|
+
`code-meter` includes a full-featured, responsive **Rich Terminal User Interface** that presents live token metrics, USD costs, user queries, and model outputs in real-time.
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
+--------------------------------------------------------------------+
|
|
80
|
+
| CODE METER |
|
|
81
|
+
| Overview |
|
|
82
|
+
+--------------------------------------------------------------------+
|
|
83
|
+
+--------------------------- Key Metrics ----------------------------+
|
|
84
|
+
| Requests: 3 |
|
|
85
|
+
| Input Tokens: 1.5K |
|
|
86
|
+
| Output Tokens: 400 |
|
|
87
|
+
| Cache Read: 300 |
|
|
88
|
+
| Total Tokens: 2.2K |
|
|
89
|
+
| Estimated Cost: $0.02 |
|
|
90
|
+
+--------------------------------------------------------------------+
|
|
91
|
+
| BY MODEL | Tokens | Cost |
|
|
92
|
+
| gemini-2.5-flash | 2.20K | $0.02 |
|
|
93
|
+
+--------------------------------------------------------------------+
|
|
94
|
+
| RECENT USER QUERIES / PROMPTS |
|
|
95
|
+
| 09-01 12:00 | antigravity | Build an interactive dashboard UI |
|
|
96
|
+
+--------------------------------------------------------------------+
|
|
97
|
+
| RECENT OUTPUTS & CODE EDITS |
|
|
98
|
+
| 09-01 12:01 | WRITE_FILE | src/main.py | + print('Hello') |
|
|
99
|
+
+--------------------------------------------------------------------+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
74
104
|
## 🛠️ CLI Commands
|
|
75
105
|
|
|
76
106
|
| Command | Description |
|
|
77
107
|
| :--- | :--- |
|
|
78
|
-
| `code-meter` | Open interactive Rich terminal dashboard |
|
|
108
|
+
| `code-meter` | Open main interactive Rich terminal dashboard UI |
|
|
109
|
+
| `code-meter ui` | Launch live interactive Rich terminal UI watching all AI log directories |
|
|
110
|
+
| `code-meter watch` | Live watch mode (auto-refreshes UI as AI agents write logs) |
|
|
111
|
+
| `code-meter update-pricing` | Fetch latest real-time token pricing for 2,800+ models |
|
|
79
112
|
| `code-meter scan` | Force an incremental scan of local usage directories |
|
|
80
113
|
| `code-meter today` | Summary of token usage and cost for today |
|
|
81
114
|
| `code-meter week` | Summary of token usage and cost for the past 7 days |
|
|
82
115
|
| `code-meter month` | Summary of token usage and cost for the past 30 days |
|
|
83
116
|
| `code-meter status` | View system status (scanned files, records, prompts, code edits, DB size) |
|
|
84
|
-
| `code-meter prompts` | View log of user prompts
|
|
85
|
-
| `code-meter history` | View log of code
|
|
117
|
+
| `code-meter prompts` | View log of user prompts and queries asked over time |
|
|
118
|
+
| `code-meter history` | View log of code modifications, file writes, and assistant actions |
|
|
86
119
|
| `code-meter diffs` | View formatted code diff summaries saved in SQLite |
|
|
87
120
|
| `code-meter report` | Detailed aggregated report with optional filters |
|
|
88
121
|
| `code-meter models` | Usage and cost breakdown by model |
|
|
@@ -90,7 +123,6 @@ This launches the interactive Rich terminal dashboard displaying key metrics, mo
|
|
|
90
123
|
| `code-meter sessions` | Usage and cost breakdown by session ID |
|
|
91
124
|
| `code-meter export` | Export usage records to CSV or JSON format |
|
|
92
125
|
| `code-meter config` | Display active configuration settings and file paths |
|
|
93
|
-
| `code-meter watch` | Live file watcher mode for real-time dashboard updates |
|
|
94
126
|
|
|
95
127
|
---
|
|
96
128
|
|
|
@@ -99,6 +131,9 @@ This launches the interactive Rich terminal dashboard displaying key metrics, mo
|
|
|
99
131
|
Combine filters on reporting, prompts, and history commands:
|
|
100
132
|
|
|
101
133
|
```bash
|
|
134
|
+
# Update real-time token costs for 2,800+ models
|
|
135
|
+
code-meter update-pricing
|
|
136
|
+
|
|
102
137
|
# Filter report by provider, project, model, and timeframe
|
|
103
138
|
code-meter report --provider codex --model gpt-4o --days 30
|
|
104
139
|
code-meter report --provider antigravity --model gemini-2.5-flash
|
|
@@ -165,29 +200,13 @@ ClaudeCodeProvider CodexProvider AntigravityProvider
|
|
|
165
200
|
Database Repository & Incremental Scanner (SQLite)
|
|
166
201
|
│
|
|
167
202
|
▼
|
|
168
|
-
|
|
203
|
+
Pricing Engine (Auto Daily Sync & Live Model Pricing)
|
|
169
204
|
│
|
|
170
205
|
▼
|
|
171
206
|
Analytics Engine (Token counts, Costs, Aggregations)
|
|
172
207
|
│
|
|
173
208
|
▼
|
|
174
|
-
|
|
175
|
-
```
|
|
176
|
-
│
|
|
177
|
-
▼
|
|
178
|
-
UsageRecord / SessionPrompt / SessionCodeChange (Pydantic models)
|
|
179
|
-
│
|
|
180
|
-
▼
|
|
181
|
-
Database Repository & Incremental Scanner (SQLite)
|
|
182
|
-
│
|
|
183
|
-
▼
|
|
184
|
-
Pricing Engine (Model Pricing Tables)
|
|
185
|
-
│
|
|
186
|
-
▼
|
|
187
|
-
Analytics Engine (Token counts, Costs, Aggregations)
|
|
188
|
-
│
|
|
189
|
-
▼
|
|
190
|
-
Terminal UI & Typer CLI Commands
|
|
209
|
+
Rich Terminal UI & Interactive Dashboard Commands
|
|
191
210
|
```
|
|
192
211
|
|
|
193
212
|
---
|
|
@@ -49,18 +49,51 @@ This launches the interactive Rich terminal dashboard displaying key metrics, mo
|
|
|
49
49
|
|
|
50
50
|
---
|
|
51
51
|
|
|
52
|
+
## 🖥️ Interactive Rich Terminal UI
|
|
53
|
+
|
|
54
|
+
`code-meter` includes a full-featured, responsive **Rich Terminal User Interface** that presents live token metrics, USD costs, user queries, and model outputs in real-time.
|
|
55
|
+
|
|
56
|
+
```text
|
|
57
|
+
+--------------------------------------------------------------------+
|
|
58
|
+
| CODE METER |
|
|
59
|
+
| Overview |
|
|
60
|
+
+--------------------------------------------------------------------+
|
|
61
|
+
+--------------------------- Key Metrics ----------------------------+
|
|
62
|
+
| Requests: 3 |
|
|
63
|
+
| Input Tokens: 1.5K |
|
|
64
|
+
| Output Tokens: 400 |
|
|
65
|
+
| Cache Read: 300 |
|
|
66
|
+
| Total Tokens: 2.2K |
|
|
67
|
+
| Estimated Cost: $0.02 |
|
|
68
|
+
+--------------------------------------------------------------------+
|
|
69
|
+
| BY MODEL | Tokens | Cost |
|
|
70
|
+
| gemini-2.5-flash | 2.20K | $0.02 |
|
|
71
|
+
+--------------------------------------------------------------------+
|
|
72
|
+
| RECENT USER QUERIES / PROMPTS |
|
|
73
|
+
| 09-01 12:00 | antigravity | Build an interactive dashboard UI |
|
|
74
|
+
+--------------------------------------------------------------------+
|
|
75
|
+
| RECENT OUTPUTS & CODE EDITS |
|
|
76
|
+
| 09-01 12:01 | WRITE_FILE | src/main.py | + print('Hello') |
|
|
77
|
+
+--------------------------------------------------------------------+
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
52
82
|
## 🛠️ CLI Commands
|
|
53
83
|
|
|
54
84
|
| Command | Description |
|
|
55
85
|
| :--- | :--- |
|
|
56
|
-
| `code-meter` | Open interactive Rich terminal dashboard |
|
|
86
|
+
| `code-meter` | Open main interactive Rich terminal dashboard UI |
|
|
87
|
+
| `code-meter ui` | Launch live interactive Rich terminal UI watching all AI log directories |
|
|
88
|
+
| `code-meter watch` | Live watch mode (auto-refreshes UI as AI agents write logs) |
|
|
89
|
+
| `code-meter update-pricing` | Fetch latest real-time token pricing for 2,800+ models |
|
|
57
90
|
| `code-meter scan` | Force an incremental scan of local usage directories |
|
|
58
91
|
| `code-meter today` | Summary of token usage and cost for today |
|
|
59
92
|
| `code-meter week` | Summary of token usage and cost for the past 7 days |
|
|
60
93
|
| `code-meter month` | Summary of token usage and cost for the past 30 days |
|
|
61
94
|
| `code-meter status` | View system status (scanned files, records, prompts, code edits, DB size) |
|
|
62
|
-
| `code-meter prompts` | View log of user prompts
|
|
63
|
-
| `code-meter history` | View log of code
|
|
95
|
+
| `code-meter prompts` | View log of user prompts and queries asked over time |
|
|
96
|
+
| `code-meter history` | View log of code modifications, file writes, and assistant actions |
|
|
64
97
|
| `code-meter diffs` | View formatted code diff summaries saved in SQLite |
|
|
65
98
|
| `code-meter report` | Detailed aggregated report with optional filters |
|
|
66
99
|
| `code-meter models` | Usage and cost breakdown by model |
|
|
@@ -68,7 +101,6 @@ This launches the interactive Rich terminal dashboard displaying key metrics, mo
|
|
|
68
101
|
| `code-meter sessions` | Usage and cost breakdown by session ID |
|
|
69
102
|
| `code-meter export` | Export usage records to CSV or JSON format |
|
|
70
103
|
| `code-meter config` | Display active configuration settings and file paths |
|
|
71
|
-
| `code-meter watch` | Live file watcher mode for real-time dashboard updates |
|
|
72
104
|
|
|
73
105
|
---
|
|
74
106
|
|
|
@@ -77,6 +109,9 @@ This launches the interactive Rich terminal dashboard displaying key metrics, mo
|
|
|
77
109
|
Combine filters on reporting, prompts, and history commands:
|
|
78
110
|
|
|
79
111
|
```bash
|
|
112
|
+
# Update real-time token costs for 2,800+ models
|
|
113
|
+
code-meter update-pricing
|
|
114
|
+
|
|
80
115
|
# Filter report by provider, project, model, and timeframe
|
|
81
116
|
code-meter report --provider codex --model gpt-4o --days 30
|
|
82
117
|
code-meter report --provider antigravity --model gemini-2.5-flash
|
|
@@ -143,29 +178,13 @@ ClaudeCodeProvider CodexProvider AntigravityProvider
|
|
|
143
178
|
Database Repository & Incremental Scanner (SQLite)
|
|
144
179
|
│
|
|
145
180
|
▼
|
|
146
|
-
|
|
181
|
+
Pricing Engine (Auto Daily Sync & Live Model Pricing)
|
|
147
182
|
│
|
|
148
183
|
▼
|
|
149
184
|
Analytics Engine (Token counts, Costs, Aggregations)
|
|
150
185
|
│
|
|
151
186
|
▼
|
|
152
|
-
|
|
153
|
-
```
|
|
154
|
-
│
|
|
155
|
-
▼
|
|
156
|
-
UsageRecord / SessionPrompt / SessionCodeChange (Pydantic models)
|
|
157
|
-
│
|
|
158
|
-
▼
|
|
159
|
-
Database Repository & Incremental Scanner (SQLite)
|
|
160
|
-
│
|
|
161
|
-
▼
|
|
162
|
-
Pricing Engine (Model Pricing Tables)
|
|
163
|
-
│
|
|
164
|
-
▼
|
|
165
|
-
Analytics Engine (Token counts, Costs, Aggregations)
|
|
166
|
-
│
|
|
167
|
-
▼
|
|
168
|
-
Terminal UI & Typer CLI Commands
|
|
187
|
+
Rich Terminal UI & Interactive Dashboard Commands
|
|
169
188
|
```
|
|
170
189
|
|
|
171
190
|
---
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "code-meter"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Local AI coding token usage tracker and cost estimator for Claude Code and future agents."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Dhanush Nayak", email = "dhanushnayak.ram@mail.com" }]
|
|
@@ -88,10 +88,49 @@ def _perform_scan(quiet: bool = False) -> int:
|
|
|
88
88
|
return total_new_records
|
|
89
89
|
|
|
90
90
|
|
|
91
|
+
def _launch_live_ui() -> None:
|
|
92
|
+
"""Launch the live watch mode dashboard UI monitoring all active AI provider directories."""
|
|
93
|
+
config, repo, pricing_engine, providers, report_gen = _get_services()
|
|
94
|
+
|
|
95
|
+
def update_and_render():
|
|
96
|
+
_perform_scan(quiet=True)
|
|
97
|
+
records = repo.query_usage_events()
|
|
98
|
+
prompts = repo.query_prompts(limit=10)
|
|
99
|
+
code_changes = repo.query_code_changes(limit=10)
|
|
100
|
+
summary = report_gen.generate_summary(records, filter_date_str=datetime.now(timezone.utc).strftime("%Y-%m-%d"))
|
|
101
|
+
console.clear()
|
|
102
|
+
render_dashboard(
|
|
103
|
+
summary=summary,
|
|
104
|
+
prompts=prompts,
|
|
105
|
+
code_changes=code_changes,
|
|
106
|
+
title_suffix="Live Watch Dashboard",
|
|
107
|
+
console=console,
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
target_dirs = [
|
|
111
|
+
config.get_claude_dir(),
|
|
112
|
+
config.get_codex_dir(),
|
|
113
|
+
config.get_antigravity_dir(),
|
|
114
|
+
]
|
|
115
|
+
run_watch_loop(
|
|
116
|
+
target_dir=target_dirs,
|
|
117
|
+
on_change_callback=update_and_render,
|
|
118
|
+
refresh_seconds=config.get_refresh_seconds(),
|
|
119
|
+
console=console,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
|
|
91
123
|
@app.callback()
|
|
92
|
-
def main_callback(
|
|
124
|
+
def main_callback(
|
|
125
|
+
ctx: typer.Context,
|
|
126
|
+
watch: bool = typer.Option(False, "--watch", "-w", help="Launch live watch UI mode"),
|
|
127
|
+
):
|
|
93
128
|
"""Default action when running `code-meter` without subcommands."""
|
|
94
129
|
if ctx.invoked_subcommand is None:
|
|
130
|
+
if watch:
|
|
131
|
+
_launch_live_ui()
|
|
132
|
+
return
|
|
133
|
+
|
|
95
134
|
_perform_scan(quiet=True)
|
|
96
135
|
config, repo, pricing_engine, providers, report_gen = _get_services()
|
|
97
136
|
|
|
@@ -383,33 +422,16 @@ def update_pricing_cmd():
|
|
|
383
422
|
console.print("[yellow]Could not update pricing or offline using fallback pricing.[/yellow]")
|
|
384
423
|
|
|
385
424
|
|
|
425
|
+
@app.command("ui")
|
|
426
|
+
def ui_cmd():
|
|
427
|
+
"""Launch the live interactive Rich terminal UI with auto-refresh watch mode."""
|
|
428
|
+
_launch_live_ui()
|
|
429
|
+
|
|
430
|
+
|
|
386
431
|
@app.command("watch")
|
|
387
432
|
def watch_cmd():
|
|
388
433
|
"""Monitor local session log files in real-time and auto-update metrics."""
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
def update_and_render():
|
|
392
|
-
_perform_scan(quiet=True)
|
|
393
|
-
records = repo.query_usage_events()
|
|
394
|
-
prompts = repo.query_prompts(limit=10)
|
|
395
|
-
code_changes = repo.query_code_changes(limit=10)
|
|
396
|
-
summary = report_gen.generate_summary(records, filter_date_str=datetime.now(timezone.utc).strftime("%Y-%m-%d"))
|
|
397
|
-
console.clear()
|
|
398
|
-
render_dashboard(
|
|
399
|
-
summary=summary,
|
|
400
|
-
prompts=prompts,
|
|
401
|
-
code_changes=code_changes,
|
|
402
|
-
title_suffix="Watch Mode (Live)",
|
|
403
|
-
console=console,
|
|
404
|
-
)
|
|
405
|
-
|
|
406
|
-
target_dir = providers[0].claude_dir if providers else config.get_claude_dir()
|
|
407
|
-
run_watch_loop(
|
|
408
|
-
target_dir=target_dir,
|
|
409
|
-
on_change_callback=update_and_render,
|
|
410
|
-
refresh_seconds=config.get_refresh_seconds(),
|
|
411
|
-
console=console,
|
|
412
|
-
)
|
|
434
|
+
_launch_live_ui()
|
|
413
435
|
|
|
414
436
|
|
|
415
437
|
if __name__ == "__main__":
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import logging
|
|
4
4
|
import time
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Callable, Optional
|
|
6
|
+
from typing import Callable, List, Optional, Union
|
|
7
7
|
|
|
8
8
|
from rich.console import Console
|
|
9
9
|
|
|
@@ -18,26 +18,34 @@ logger = logging.getLogger(__name__)
|
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
def run_watch_loop(
|
|
21
|
-
target_dir: Path,
|
|
21
|
+
target_dir: Union[Path, List[Path]],
|
|
22
22
|
on_change_callback: Callable[[], None],
|
|
23
23
|
refresh_seconds: int = 2,
|
|
24
24
|
console: Optional[Console] = None,
|
|
25
25
|
) -> None:
|
|
26
|
-
"""Monitor
|
|
26
|
+
"""Monitor target directories and trigger on_change_callback whenever session log files update."""
|
|
27
27
|
c = console or Console()
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
dirs = [target_dir] if isinstance(target_dir, Path) else target_dir
|
|
29
|
+
existing_dirs = [d for d in dirs if d.exists()]
|
|
30
|
+
|
|
31
|
+
if existing_dirs:
|
|
32
|
+
dir_strs = ", ".join(str(d) for d in existing_dirs)
|
|
33
|
+
c.print(f"[bold green]Watching directories:[/bold green] {dir_strs}")
|
|
34
|
+
else:
|
|
35
|
+
c.print("[yellow]No target provider directories found yet. Waiting for logs...[/yellow]")
|
|
36
|
+
c.print("[dim]Press Ctrl+C to stop live watch UI mode.[/dim]\n")
|
|
30
37
|
|
|
31
38
|
on_change_callback()
|
|
32
39
|
|
|
33
|
-
if HAS_WATCHDOG and
|
|
40
|
+
if HAS_WATCHDOG and existing_dirs:
|
|
34
41
|
class JSONLHandler(FileSystemEventHandler):
|
|
35
42
|
def on_any_event(self, event):
|
|
36
|
-
if not event.is_directory and event.src_path.endswith(".jsonl"):
|
|
43
|
+
if not event.is_directory and (event.src_path.endswith(".jsonl") or event.src_path.endswith(".json")):
|
|
37
44
|
on_change_callback()
|
|
38
45
|
|
|
39
46
|
observer = Observer()
|
|
40
|
-
|
|
47
|
+
for d in existing_dirs:
|
|
48
|
+
observer.schedule(JSONLHandler(), str(d), recursive=True)
|
|
41
49
|
observer.start()
|
|
42
50
|
try:
|
|
43
51
|
while True:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: code-meter
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Local AI coding token usage tracker and cost estimator for Claude Code and future agents.
|
|
5
5
|
Author-email: Dhanush Nayak <dhanushnayak.ram@mail.com>
|
|
6
6
|
License: MIT
|
|
@@ -71,18 +71,51 @@ This launches the interactive Rich terminal dashboard displaying key metrics, mo
|
|
|
71
71
|
|
|
72
72
|
---
|
|
73
73
|
|
|
74
|
+
## 🖥️ Interactive Rich Terminal UI
|
|
75
|
+
|
|
76
|
+
`code-meter` includes a full-featured, responsive **Rich Terminal User Interface** that presents live token metrics, USD costs, user queries, and model outputs in real-time.
|
|
77
|
+
|
|
78
|
+
```text
|
|
79
|
+
+--------------------------------------------------------------------+
|
|
80
|
+
| CODE METER |
|
|
81
|
+
| Overview |
|
|
82
|
+
+--------------------------------------------------------------------+
|
|
83
|
+
+--------------------------- Key Metrics ----------------------------+
|
|
84
|
+
| Requests: 3 |
|
|
85
|
+
| Input Tokens: 1.5K |
|
|
86
|
+
| Output Tokens: 400 |
|
|
87
|
+
| Cache Read: 300 |
|
|
88
|
+
| Total Tokens: 2.2K |
|
|
89
|
+
| Estimated Cost: $0.02 |
|
|
90
|
+
+--------------------------------------------------------------------+
|
|
91
|
+
| BY MODEL | Tokens | Cost |
|
|
92
|
+
| gemini-2.5-flash | 2.20K | $0.02 |
|
|
93
|
+
+--------------------------------------------------------------------+
|
|
94
|
+
| RECENT USER QUERIES / PROMPTS |
|
|
95
|
+
| 09-01 12:00 | antigravity | Build an interactive dashboard UI |
|
|
96
|
+
+--------------------------------------------------------------------+
|
|
97
|
+
| RECENT OUTPUTS & CODE EDITS |
|
|
98
|
+
| 09-01 12:01 | WRITE_FILE | src/main.py | + print('Hello') |
|
|
99
|
+
+--------------------------------------------------------------------+
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
74
104
|
## 🛠️ CLI Commands
|
|
75
105
|
|
|
76
106
|
| Command | Description |
|
|
77
107
|
| :--- | :--- |
|
|
78
|
-
| `code-meter` | Open interactive Rich terminal dashboard |
|
|
108
|
+
| `code-meter` | Open main interactive Rich terminal dashboard UI |
|
|
109
|
+
| `code-meter ui` | Launch live interactive Rich terminal UI watching all AI log directories |
|
|
110
|
+
| `code-meter watch` | Live watch mode (auto-refreshes UI as AI agents write logs) |
|
|
111
|
+
| `code-meter update-pricing` | Fetch latest real-time token pricing for 2,800+ models |
|
|
79
112
|
| `code-meter scan` | Force an incremental scan of local usage directories |
|
|
80
113
|
| `code-meter today` | Summary of token usage and cost for today |
|
|
81
114
|
| `code-meter week` | Summary of token usage and cost for the past 7 days |
|
|
82
115
|
| `code-meter month` | Summary of token usage and cost for the past 30 days |
|
|
83
116
|
| `code-meter status` | View system status (scanned files, records, prompts, code edits, DB size) |
|
|
84
|
-
| `code-meter prompts` | View log of user prompts
|
|
85
|
-
| `code-meter history` | View log of code
|
|
117
|
+
| `code-meter prompts` | View log of user prompts and queries asked over time |
|
|
118
|
+
| `code-meter history` | View log of code modifications, file writes, and assistant actions |
|
|
86
119
|
| `code-meter diffs` | View formatted code diff summaries saved in SQLite |
|
|
87
120
|
| `code-meter report` | Detailed aggregated report with optional filters |
|
|
88
121
|
| `code-meter models` | Usage and cost breakdown by model |
|
|
@@ -90,7 +123,6 @@ This launches the interactive Rich terminal dashboard displaying key metrics, mo
|
|
|
90
123
|
| `code-meter sessions` | Usage and cost breakdown by session ID |
|
|
91
124
|
| `code-meter export` | Export usage records to CSV or JSON format |
|
|
92
125
|
| `code-meter config` | Display active configuration settings and file paths |
|
|
93
|
-
| `code-meter watch` | Live file watcher mode for real-time dashboard updates |
|
|
94
126
|
|
|
95
127
|
---
|
|
96
128
|
|
|
@@ -99,6 +131,9 @@ This launches the interactive Rich terminal dashboard displaying key metrics, mo
|
|
|
99
131
|
Combine filters on reporting, prompts, and history commands:
|
|
100
132
|
|
|
101
133
|
```bash
|
|
134
|
+
# Update real-time token costs for 2,800+ models
|
|
135
|
+
code-meter update-pricing
|
|
136
|
+
|
|
102
137
|
# Filter report by provider, project, model, and timeframe
|
|
103
138
|
code-meter report --provider codex --model gpt-4o --days 30
|
|
104
139
|
code-meter report --provider antigravity --model gemini-2.5-flash
|
|
@@ -165,29 +200,13 @@ ClaudeCodeProvider CodexProvider AntigravityProvider
|
|
|
165
200
|
Database Repository & Incremental Scanner (SQLite)
|
|
166
201
|
│
|
|
167
202
|
▼
|
|
168
|
-
|
|
203
|
+
Pricing Engine (Auto Daily Sync & Live Model Pricing)
|
|
169
204
|
│
|
|
170
205
|
▼
|
|
171
206
|
Analytics Engine (Token counts, Costs, Aggregations)
|
|
172
207
|
│
|
|
173
208
|
▼
|
|
174
|
-
|
|
175
|
-
```
|
|
176
|
-
│
|
|
177
|
-
▼
|
|
178
|
-
UsageRecord / SessionPrompt / SessionCodeChange (Pydantic models)
|
|
179
|
-
│
|
|
180
|
-
▼
|
|
181
|
-
Database Repository & Incremental Scanner (SQLite)
|
|
182
|
-
│
|
|
183
|
-
▼
|
|
184
|
-
Pricing Engine (Model Pricing Tables)
|
|
185
|
-
│
|
|
186
|
-
▼
|
|
187
|
-
Analytics Engine (Token counts, Costs, Aggregations)
|
|
188
|
-
│
|
|
189
|
-
▼
|
|
190
|
-
Terminal UI & Typer CLI Commands
|
|
209
|
+
Rich Terminal UI & Interactive Dashboard Commands
|
|
191
210
|
```
|
|
192
211
|
|
|
193
212
|
---
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|