tokentracker-cli 0.2.25 → 0.2.26

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.
@@ -107,7 +107,7 @@
107
107
  ]
108
108
  }
109
109
  </script>
110
- <script type="module" crossorigin src="/assets/main-DepLUlUX.js"></script>
110
+ <script type="module" crossorigin src="/assets/main-B206gspN.js"></script>
111
111
  <link rel="stylesheet" crossorigin href="/assets/main-hwTpulbk.css">
112
112
  </head>
113
113
  <body>
@@ -51,7 +51,7 @@
51
51
  "description": "Shareable Token Tracker dashboard snapshot."
52
52
  }
53
53
  </script>
54
- <script type="module" crossorigin src="/assets/main-DepLUlUX.js"></script>
54
+ <script type="module" crossorigin src="/assets/main-B206gspN.js"></script>
55
55
  <link rel="stylesheet" crossorigin href="/assets/main-hwTpulbk.css">
56
56
  </head>
57
57
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tokentracker-cli",
3
- "version": "0.2.25",
3
+ "version": "0.2.26",
4
4
  "description": "Token usage tracker for AI agent CLIs (Codex, Claude Code, Gemini, OpenCode, OpenClaw)",
5
5
  "main": "src/cli.js",
6
6
  "bin": {
package/README.old.md DELETED
@@ -1,324 +0,0 @@
1
- <div align="center">
2
-
3
- <img src="dashboard/public/icon-192.png" width="96" alt="VibeUsage Icon" />
4
-
5
- # 🟢 VIBEUSAGE
6
-
7
- **QUANTIFY YOUR AI OUTPUT**
8
- _Real-time AI Analytics for Codex CLI_
9
-
10
- [**www.vibeusage.cc**](https://www.vibeusage.cc)
11
-
12
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
13
- [![Node.js Support](https://img.shields.io/badge/Node.js-%3E%3D18-brightgreen.svg)](https://nodejs.org/)
14
- [![Platform](https://img.shields.io/badge/Platform-macOS-lightgrey.svg)](https://www.apple.com/macos/)
15
-
16
- [**English**](README.md) • [**中文说明**](README.zh-CN.md)
17
-
18
- [**Documentation**](docs/) • [**Dashboard**](dashboard/) • [**Backend API**](BACKEND_API.md)
19
-
20
- <br/>
21
-
22
- <img src="docs/screenshots/dashboard.png" width="900" alt="VibeUsage Dashboard Preview"/>
23
-
24
- </div>
25
-
26
- ---
27
-
28
- ## 🌌 Overview
29
-
30
- **VibeUsage** is an intelligent token usage tracking system designed specifically for macOS developers. Through the all-new **Matrix-A Design System**, it provides a high-fidelity cyberpunk-style dashboard that transforms your **AI Output** into quantifiable metrics, supported by the **Neural Divergence Map** for real-time monitoring of multi-model compute distribution.
31
-
32
- > [!TIP] > **Core Index**: Our signature metric that reflects your flow state by analyzing token consumption rates and patterns.
33
-
34
- ## 🔒 Privacy-First Architecture (Stealth Protocol)
35
-
36
- We believe your code and thoughts are your own. VibeUsage is built with strict privacy pillars to ensure your data never leaves your control.
37
-
38
- - 🛡️ **No Content Upload**: We never upload prompts or responses. We only compute token counts locally and send counts plus minimal metadata (timestamps, model, device).
39
- - 📡 **Local Aggregation**: All token consumption analysis happens on your machine. We only relay quantized 30-minute usage buckets to the cloud.
40
- - 🔐 **Hashed Identity**: Device tokens are hashed using SHA-256 server-side. Your raw credentials never exist in our database.
41
- - 🔦 **Full Transparency**: Audit the sync logic yourself in `src/lib/rollout.js`. We literally only capture numbers and timestamps.
42
-
43
- ## 🚀 Key Features
44
-
45
- - 📡 **Auto-Sync**: Real-time interception of AI CLI pipes with **automatic background synchronization**. Once initialized, your tokens are tracked and synced without any manual commands.
46
- - 🧭 **Universal-Sync**: Native support for multiple AI CLI tools:
47
- - **Codex CLI** - OpenAI's official CLI
48
- - **Every Code** - Community Codex alternative
49
- - **Gemini CLI** - Google's AI CLI
50
- - **Opencode** - AI coding assistant
51
- - **Claude Code** - Anthropic's official CLI
52
- - Whether it's GPT-4, Claude 3.5 Sonnet, or o1/Gemini, token consumption from all models is unified and counted.
53
- - 📊 **Matrix Dashboard**: High-performance dashboard built with React + Vite, featuring the new **Matrix-A** design language.
54
- - **Neural Divergence Map**: Visualize multi-engine load balancing and compute distribution.
55
- - **Cost Intelligence**: Real-time, multi-dimensional cost breakdown and forecasting.
56
- - **Activity Heatmap**: GitHub-style contribution graph with streak tracking.
57
- - **Smart Notifications**: Non-intrusive system-level alerts using a Golden (Gold/Amber) visual style for high-value information.
58
- - ⚡ **AI Analytics**: Deep analysis of Input/Output tokens, with dedicated tracking for Cached and Reasoning components.
59
- - 📈 **Leaderboard**: Daily, weekly, monthly, and all-time rankings with privacy-safe display names.
60
- - 🌐 **Public View**: Share your AI usage journey with a privacy-safe public profile.
61
- - 📁 **Project Stats**: Track token usage by project/repository across all time.
62
- - 🔒 **Identity Core**: Robust authentication and permission management to secure your development data.
63
-
64
- ### 🌌 Visual Preview
65
-
66
- <img src="docs/screenshots/landing.png" width="900" alt="VibeUsage Landing Preview"/>
67
-
68
- ## 🛠️ Quick Start
69
-
70
- ### Installation
71
-
72
- Initialize your environment once and forget it. VibeUsage handles all synchronization in the background automatically.
73
-
74
- ```bash
75
- npx --yes vibeusage init
76
- ```
77
-
78
- **Authentication Methods:**
79
-
80
- 1. **Browser Auth** (default) - Opens browser for secure authentication
81
- 2. **Link Code** - Use `--link-code` to authenticate via dashboard-generated code
82
- 3. **Password** - Direct password authentication (fallback)
83
- 4. **Access Token** - For CI/automated environments
84
-
85
- **CLI Options:**
86
- - `--yes` - Skip consent prompts in non-interactive environments
87
- - `--dry-run` - Preview changes without writing files
88
- - `--link-code <code>` - Authenticate using a link code from dashboard
89
- - `--base-url <url>` - Override the default API endpoint
90
-
91
- **Supported CLI Tools Auto-Configuration:**
92
-
93
- | Tool | Config Location | Method |
94
- |------|----------------|--------|
95
- | Codex CLI | `~/.codex/config.toml` | `notify` hook |
96
- | Every Code | `~/.code/config.toml` (or `CODE_HOME`) | `notify` hook |
97
- | Gemini CLI | `~/.gemini/settings.json` (or `GEMINI_HOME`) | `SessionEnd` hook |
98
- | Opencode | Global plugins | Message parser plugin |
99
- | Claude Code | `~/.claude/hooks/` | Hook configuration |
100
-
101
- Once `init` completes, all supported CLI tools are automatically configured for data sync. No further intervention required.
102
-
103
- ### Sync & Status
104
-
105
- While sync happens automatically, you can manually trigger a synchronization or check status anytime:
106
-
107
- ```bash
108
- # Manually sync latest local session data (Optional)
109
- npx --yes vibeusage sync
110
-
111
- # Check current link status
112
- npx --yes vibeusage status
113
- ```
114
-
115
- ### Doctor
116
-
117
- ```bash
118
- # Run health checks
119
- npx --yes vibeusage doctor
120
-
121
- # Emit JSON report (and write to file)
122
- npx --yes vibeusage doctor --json --out doctor.json
123
-
124
- # Override base URL (diagnostics only)
125
- npx --yes vibeusage doctor --base-url https://example.invalid
126
- ```
127
-
128
- ### Uninstall
129
-
130
- ```bash
131
- # Standard uninstall (keeps data)
132
- npx --yes vibeusage uninstall
133
-
134
- # Full purge - removes all data including config and cached sessions
135
- npx --yes vibeusage uninstall --purge
136
- ```
137
-
138
- ### Log Sources
139
-
140
- | Tool | Log Location | Override Env |
141
- |------|-------------|--------------|
142
- | Codex CLI | `~/.codex/sessions/**/rollout-*.jsonl` | `CODEX_HOME` |
143
- | Every Code | `~/.code/sessions/**/rollout-*.jsonl` | `CODE_HOME` |
144
- | Gemini CLI | `~/.gemini/tmp/**/chats/session-*.json` | `GEMINI_HOME` |
145
- | Opencode | `~/.opencode/messages/*.json` | - |
146
- | Claude Code | Parsed from hook output | - |
147
-
148
- ## 🔧 Environment Variables
149
-
150
- ### Core Settings
151
-
152
- | Variable | Description | Default |
153
- |----------|-------------|---------|
154
- | `VIBEUSAGE_HTTP_TIMEOUT_MS` | CLI HTTP timeout in ms (`0` disables, clamped `1000..120000`) | `20000` |
155
- | `VITE_VIBEUSAGE_HTTP_TIMEOUT_MS` | Dashboard request timeout in ms (`0` disables, clamped `1000..30000`) | `15000` |
156
- | `VIBEUSAGE_DEBUG` | Enable debug output (`1` or `true` to enable) | - |
157
- | `VIBEUSAGE_DASHBOARD_URL` | Custom dashboard URL | `https://www.vibeusage.cc` |
158
- | `VIBEUSAGE_INSFORGE_BASE_URL` | Custom API base URL | `https://5tmappuk.us-east.insforge.app` |
159
- | `VIBEUSAGE_DEVICE_TOKEN` | Pre-configured device token (for CI) | - |
160
-
161
- ### CLI Tool Overrides
162
-
163
- | Variable | Description | Default |
164
- |----------|-------------|---------|
165
- | `CODEX_HOME` | Codex CLI directory override | `~/.codex` |
166
- | `CODE_HOME` | Every Code directory override | `~/.code` |
167
- | `GEMINI_HOME` | Gemini CLI directory override | `~/.gemini` |
168
-
169
- ### Deprecated
170
-
171
- - `VIBEUSAGE_ROLLUP_ENABLED`: Currently ignored; rollup aggregation is disabled pending table deployment.
172
-
173
- ## 🧰 Troubleshooting
174
-
175
- ### Debug Mode
176
-
177
- Enable debug output to see detailed request/response information:
178
-
179
- ```bash
180
- VIBEUSAGE_DEBUG=1 npx --yes vibeusage sync
181
- # or
182
- npx --yes vibeusage sync --debug
183
- ```
184
-
185
- ### Health Check
186
-
187
- Run the built-in doctor command to diagnose issues:
188
-
189
- ```bash
190
- # Basic health check
191
- npx --yes vibeusage doctor
192
-
193
- # JSON output for debugging
194
- npx --yes vibeusage doctor --json --out doctor.json
195
-
196
- # Test against a different endpoint
197
- npx --yes vibeusage doctor --base-url https://your-instance.insforge.app
198
- ```
199
-
200
- ### Streak shows 0 days while totals look correct
201
-
202
- - Streak is defined as consecutive days ending today. If today's total is 0, streak will be 0.
203
- - If you expect a non-zero streak, clear cached auth/heatmap data and sign in again:
204
-
205
- ```js
206
- localStorage.removeItem("vibeusage.dashboard.auth.v1");
207
- Object.keys(localStorage)
208
- .filter((k) => k.startsWith("vibeusage.heatmap."))
209
- .forEach((k) => localStorage.removeItem(k));
210
- location.reload();
211
- ```
212
-
213
- - Complete the landing page sign-in flow again after reload.
214
- - Note: `insforge-auth-token` is not used by the dashboard; use `vibeusage.dashboard.auth.v1`.
215
-
216
- ### Sync Issues
217
-
218
- If data isn't appearing in the dashboard:
219
-
220
- 1. Check status: `npx --yes vibeusage status`
221
- 2. Force manual sync: `npx --yes vibeusage sync`
222
- 3. Verify CLI tool hooks are configured (re-run `init` if needed)
223
- 4. Check debug output: `VIBEUSAGE_DEBUG=1 npx vibeusage sync`
224
-
225
- ### Timeout Errors
226
-
227
- Increase HTTP timeout for slow connections:
228
-
229
- ```bash
230
- VIBEUSAGE_HTTP_TIMEOUT_MS=60000 npx --yes vibeusage sync
231
- ```
232
-
233
- ## 🏗️ Architecture
234
-
235
- ```mermaid
236
- graph TD
237
- A[Codex CLI] -->|Rollout Logs| F(Tracker CLI)
238
- B[Every Code] -->|Rollout Logs| F
239
- C[Gemini CLI] -->|Session Logs| F
240
- D[Opencode] -->|Message Logs| F
241
- E[Claude Code] -->|Hook Output| F
242
- F -->|AI Tokens| G{Core Relay}
243
- G --> H[VibeUsage Dashboard]
244
- G --> I[AI Analytics Engine]
245
- G --> J[Leaderboard Service]
246
- G --> K[Public View API]
247
- ```
248
-
249
- ### Components
250
-
251
- - **Tracker CLI** (`src/`): Node.js CLI that parses logs from multiple AI tools and syncs token data
252
- - **Core Relay** (InsForge Edge Functions): Serverless backend handling ingestion, aggregation, and API
253
- - **Dashboard** (`dashboard/`): React + Vite frontend for visualization
254
- - **AI Analytics Engine**: Cost calculation, model breakdown, and usage forecasting
255
-
256
- ## 💻 Developer Guide
257
-
258
- To run locally or contribute:
259
-
260
- ### Dashboard Development
261
-
262
- ```bash
263
- # Install dependencies
264
- cd dashboard
265
- npm install
266
-
267
- # Start dev server
268
- npm run dev
269
- ```
270
-
271
- ### Debug Payload (Usage Endpoints)
272
-
273
- When `debug=1` is included in a usage endpoint request, the response adds a `debug` object that helps the dashboard attribute slow queries without relying on response headers.
274
-
275
- ```ts
276
- const res = await fetch(
277
- `${baseUrl}/functions/vibeusage-usage-summary?from=2025-12-30&to=2025-12-30&debug=1`,
278
- {
279
- headers: { Authorization: `Bearer ${userJwt}` }
280
- }
281
- );
282
- const data = await res.json();
283
-
284
- if (data.debug) {
285
- console.debug('usage debug', {
286
- requestId: data.debug.request_id,
287
- status: data.debug.status,
288
- queryMs: data.debug.query_ms,
289
- slowThresholdMs: data.debug.slow_threshold_ms,
290
- slowQuery: data.debug.slow_query
291
- });
292
- }
293
- ```
294
-
295
- ### Architecture Validation
296
-
297
- ```bash
298
- # Validate Copy Registry
299
- npm run validate:copy
300
-
301
- # Run smoke tests
302
- npm run smoke
303
- ```
304
-
305
- ### Architecture Canvas Focus
306
-
307
- ```bash
308
- # Generate a focused canvas for a top-level module
309
- node scripts/ops/architecture-canvas.cjs --focus src
310
-
311
- # Alias: --module
312
- node scripts/ops/architecture-canvas.cjs --module dashboard
313
- ```
314
-
315
- ## 📜 License
316
-
317
- This project is licensed under the [MIT License](LICENSE).
318
-
319
- ---
320
-
321
- <div align="center">
322
- <b>System_Ready // 2024 VibeUsage OS</b><br/>
323
- <i>"More Tokens. More Vibe."</i>
324
- </div>