@vibe-cafe/vibe-usage 0.6.2 → 0.6.4

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.
package/README.md CHANGED
@@ -5,7 +5,7 @@ Track your AI coding tool token usage and sync to [vibecafe.ai](https://vibecafe
5
5
  ## Quick Start
6
6
 
7
7
  ```bash
8
- npx vibe-usage
8
+ npx @vibe-cafe/vibe-usage
9
9
  ```
10
10
 
11
11
  This will:
@@ -16,13 +16,13 @@ This will:
16
16
  ## Commands
17
17
 
18
18
  ```bash
19
- npx vibe-usage # Init (first run) or sync (subsequent runs)
20
- npx vibe-usage init # Re-run setup
21
- npx vibe-usage sync # Manual sync
22
- npx vibe-usage daemon # Continuous sync (every 5 minutes)
23
- npx vibe-usage reset # Delete all data and re-upload from local logs
24
- npx vibe-usage reset --local # Delete this host's data only and re-upload
25
- npx vibe-usage status # Show config & detected tools
19
+ npx @vibe-cafe/vibe-usage # Init (first run) or sync (subsequent runs)
20
+ npx @vibe-cafe/vibe-usage init # Re-run setup
21
+ npx @vibe-cafe/vibe-usage sync # Manual sync
22
+ npx @vibe-cafe/vibe-usage daemon # Continuous sync (every 5 minutes)
23
+ npx @vibe-cafe/vibe-usage reset # Delete all data and re-upload from local logs
24
+ npx @vibe-cafe/vibe-usage reset --local # Delete this host's data only and re-upload
25
+ npx @vibe-cafe/vibe-usage status # Show config & detected tools
26
26
  ```
27
27
 
28
28
  ## Supported Tools
@@ -42,18 +42,18 @@ npx vibe-usage status # Show config & detected tools
42
42
 
43
43
  - Parses local session logs from each AI coding tool
44
44
  - Aggregates token usage into 30-minute buckets
45
- - Extracts session metadata from all 8 parsers: active time (sum of turn durations), total duration, message counts
45
+ - Extracts session metadata from all 8 parsers: active time (AI generation time, excluding queue/TTFT wait), total duration, message counts
46
46
  - Uploads buckets + sessions to your vibecafe.ai dashboard
47
47
  - Stateless: computes full totals from local logs each sync (idempotent, no state files)
48
- - For continuous syncing, use `npx vibe-usage daemon` or the [Vibe Usage Mac app](https://github.com/vibe-cafe/vibe-usage-app)
48
+ - For continuous syncing, use `npx @vibe-cafe/vibe-usage daemon` or the [Vibe Usage Mac app](https://github.com/vibe-cafe/vibe-usage-app)
49
49
 
50
50
  ## Development
51
51
 
52
52
  Test against a local vibe-cafe dev server without publishing:
53
53
 
54
54
  ```bash
55
- VIBE_USAGE_DEV=1 VIBE_USAGE_API_URL=http://localhost:3000 npx vibe-usage init
56
- VIBE_USAGE_DEV=1 npx vibe-usage sync
55
+ VIBE_USAGE_DEV=1 VIBE_USAGE_API_URL=http://localhost:3000 npx @vibe-cafe/vibe-usage init
56
+ VIBE_USAGE_DEV=1 npx @vibe-cafe/vibe-usage sync
57
57
  ```
58
58
 
59
59
  `VIBE_USAGE_DEV=1` uses a separate config file (`~/.vibe-usage/config.dev.json`).
@@ -67,10 +67,10 @@ Config stored at `~/.vibe-usage/config.json` (dev: `config.dev.json`). Contains
67
67
  Run continuous syncing in the foreground (every 5 minutes):
68
68
 
69
69
  ```bash
70
- npx vibe-usage daemon
70
+ npx @vibe-cafe/vibe-usage daemon
71
71
  ```
72
72
 
73
- Press Ctrl+C to stop. For background use: `nohup npx vibe-usage daemon &`
73
+ Press Ctrl+C to stop. For background use: `nohup npx @vibe-cafe/vibe-usage daemon &`
74
74
 
75
75
  ## License
76
76
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-cafe/vibe-usage",
3
- "version": "0.6.2",
3
+ "version": "0.6.4",
4
4
  "description": "Track your AI coding tool token usage and sync to vibecafe.ai",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -8,7 +8,7 @@ async function showStatus() {
8
8
 
9
9
  if (!config?.apiKey) {
10
10
  console.log(' Config: not configured');
11
- console.log(` Run \`npx vibe-usage init\` to set up.\n`);
11
+ console.log(` Run \`npx @vibe-cafe/vibe-usage init\` to set up.\n`);
12
12
  } else {
13
13
  console.log(` Config: ${getConfigPath()}`);
14
14
  console.log(` API key: ${config.apiKey.slice(0, 8)}...`);
@@ -128,17 +128,17 @@ export async function run(args) {
128
128
  vibe-usage - Vibe Usage Tracker by VibeCafé
129
129
 
130
130
  Usage:
131
- npx vibe-usage Init (first run) or sync
132
- npx vibe-usage init Set up API key
133
- npx vibe-usage sync Manually sync usage data
134
- npx vibe-usage daemon Continuous sync (every 5m)
135
- npx vibe-usage reset Delete all data and re-upload
136
- npx vibe-usage reset --local Delete data for this host only and re-upload
137
- npx vibe-usage status Show config and detected tools
138
- npx vibe-usage config show Show full config as JSON
139
- npx vibe-usage config get <key> Get a config value
140
- npx vibe-usage config set <key> <value> Set a config value
141
- npx vibe-usage help Show this help
131
+ npx @vibe-cafe/vibe-usage Init (first run) or sync
132
+ npx @vibe-cafe/vibe-usage init Set up API key
133
+ npx @vibe-cafe/vibe-usage sync Manually sync usage data
134
+ npx @vibe-cafe/vibe-usage daemon Continuous sync (every 5m)
135
+ npx @vibe-cafe/vibe-usage reset Delete all data and re-upload
136
+ npx @vibe-cafe/vibe-usage reset --local Delete data for this host only and re-upload
137
+ npx @vibe-cafe/vibe-usage status Show config and detected tools
138
+ npx @vibe-cafe/vibe-usage config show Show full config as JSON
139
+ npx @vibe-cafe/vibe-usage config get <key> Get a config value
140
+ npx @vibe-cafe/vibe-usage config set <key> <value> Set a config value
141
+ npx @vibe-cafe/vibe-usage help Show this help
142
142
  `);
143
143
  break;
144
144
  }
@@ -62,8 +62,9 @@ export function aggregateToBuckets(entries) {
62
62
  * Extract session metadata from timing events.
63
63
  * Each event: { sessionId, source, project, timestamp: Date, role: 'user'|'assistant' }
64
64
  *
65
- * Turn = user prompt → last agent message before next user prompt.
66
- * activeSeconds = sum(turn durations). durationSeconds = wall clock.
65
+ * Turn = first AI response → last AI response before next user prompt.
66
+ * activeSeconds = sum(generation durations), excluding queue/TTFT wait.
67
+ * durationSeconds = wall clock from first to last message.
67
68
  */
68
69
  export function extractSessions(events) {
69
70
  const groups = new Map();
@@ -83,14 +84,20 @@ export function extractSessions(events) {
83
84
  let activeSeconds = 0;
84
85
  let turnStart = null;
85
86
  let turnEnd = null;
87
+ let waitingForFirstResponse = false;
86
88
 
87
89
  for (const event of sessionEvents) {
88
90
  if (event.role === 'user') {
89
91
  if (turnStart !== null && turnEnd !== null && turnEnd > turnStart) {
90
92
  activeSeconds += Math.round((turnEnd - turnStart) / 1000);
91
93
  }
94
+ turnStart = null;
95
+ turnEnd = null;
96
+ waitingForFirstResponse = true;
97
+ } else if (waitingForFirstResponse) {
92
98
  turnStart = event.timestamp;
93
99
  turnEnd = event.timestamp;
100
+ waitingForFirstResponse = false;
94
101
  } else if (turnStart !== null) {
95
102
  turnEnd = event.timestamp;
96
103
  }
package/src/reset.js CHANGED
@@ -39,7 +39,7 @@ export async function runReset(args = []) {
39
39
  console.log(`Deleting remote data for host: ${currentHost}...`);
40
40
  try {
41
41
  const result = await deleteAllData(apiUrl, config.apiKey, { hostname: currentHost });
42
- console.log(`Deleted ${result.deleted} buckets from server.`);
42
+ console.log(`Deleted ${result.deleted} buckets, ${result.sessions ?? 0} sessions from server.`);
43
43
  } catch (err) {
44
44
  if (err.message === 'UNAUTHORIZED') {
45
45
  console.error('Invalid API key. Run `npx @vibe-cafe/vibe-usage init` to reconfigure.');
@@ -59,7 +59,7 @@ export async function runReset(args = []) {
59
59
  console.log('Deleting all remote data...');
60
60
  try {
61
61
  const result = await deleteAllData(apiUrl, config.apiKey);
62
- console.log(`Deleted ${result.deleted} buckets from server.`);
62
+ console.log(`Deleted ${result.deleted} buckets, ${result.sessions ?? 0} sessions from server.`);
63
63
  } catch (err) {
64
64
  if (err.message === 'UNAUTHORIZED') {
65
65
  console.error('Invalid API key. Run `npx @vibe-cafe/vibe-usage init` to reconfigure.');
package/src/sync.js CHANGED
@@ -132,6 +132,8 @@ export async function runSync({ throws = false, quiet = false } = {}) {
132
132
  console.log(` active: ${fmtTime(totalActive)} / total: ${fmtTime(totalDuration)}, ${totalMsgs} messages`);
133
133
  }
134
134
 
135
+ if (!quiet) console.log(`\nView your dashboard at: ${apiUrl}/usage`);
136
+
135
137
  return totalIngested;
136
138
  } catch (err) {
137
139
  if (err.message === 'UNAUTHORIZED') {