@vibe-cafe/vibe-usage 0.9.1 → 0.9.2
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 +1 -0
- package/package.json +1 -1
- package/src/parsers/antigravity.js +79 -17
package/README.md
CHANGED
|
@@ -66,6 +66,7 @@ npx @vibe-cafe/vibe-usage status # Show config & detected tools
|
|
|
66
66
|
| Kiro | `~/Library/Application Support/Kiro/User/globalStorage/kiro.kiroagent/dev_data/devdata.sqlite` (SQLite, JSONL fallback; model name resolved from `.chat` timeline) |
|
|
67
67
|
| Cline | `<host>/User/globalStorage/saoudrizwan.claude-dev/{state/taskHistory.json,tasks/<id>/ui_messages.json}` (walks all VSCode-fork hosts: Code, Cursor, Windsurf, VSCodium, Trae, ...) |
|
|
68
68
|
| Roo Code | `<host>/User/globalStorage/rooveterinaryinc.roo-cline/{tasks/_index.json,tasks/<id>/{history_item,ui_messages}.json}` (walks all VSCode-fork hosts) |
|
|
69
|
+
| Antigravity | `~/.gemini/antigravity/conversations/*.pb` to discover cascades, then reads token usage + sessions from the running language server via Connect RPC (process discovered with `ps`/`lsof` on macOS/Linux, PowerShell CIM with a `wmic` fallback on Windows) |
|
|
69
70
|
|
|
70
71
|
## How It Works
|
|
71
72
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
|
-
import { readdirSync
|
|
2
|
+
import { readdirSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { aggregateToBuckets, extractSessions } from './index.js';
|
|
@@ -57,27 +57,89 @@ function findLanguageServerUnix() {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
function findLanguageServerWin() {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
//
|
|
65
|
-
|
|
60
|
+
// Prefer PowerShell/CIM: wmic is disabled by default on Windows 11 23H2+
|
|
61
|
+
// and removed entirely from 25H2 onward. Fall back to wmic for old/stripped
|
|
62
|
+
// environments without PowerShell. Each probe is independently time-boxed and
|
|
63
|
+
// failures are swallowed, so a missing/hung tool never blocks the next one or
|
|
64
|
+
// the parsers that run after antigravity.
|
|
65
|
+
const out = queryProcessesWinPowerShell() ?? queryProcessesWinWmic();
|
|
66
|
+
if (!out) return null;
|
|
67
|
+
return parseWinProcessList(out);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Query language_server processes via PowerShell + CIM.
|
|
72
|
+
* Emits "ProcessId=..." / "CommandLine=..." lines (wmic /format:list shape)
|
|
73
|
+
* so parseWinProcessList handles either source. Returns null on failure.
|
|
74
|
+
*/
|
|
75
|
+
function queryProcessesWinPowerShell() {
|
|
76
|
+
// Filter is applied in PowerShell so the LIKE wildcards stay server-side.
|
|
77
|
+
// A "---" separator before each process's ProcessId/CommandLine lines keeps
|
|
78
|
+
// fields grouped even when multiple processes match.
|
|
79
|
+
const script =
|
|
80
|
+
"Get-CimInstance Win32_Process -Filter \"CommandLine LIKE '%antigravity%language_server%'\" | " +
|
|
81
|
+
'ForEach-Object { "---"; "ProcessId=" + $_.ProcessId; "CommandLine=" + $_.CommandLine }';
|
|
82
|
+
for (const exe of ['powershell.exe', 'pwsh.exe']) {
|
|
83
|
+
try {
|
|
84
|
+
const out = execSync(
|
|
85
|
+
`${exe} -NoProfile -NonInteractive -Command "${script.replace(/"/g, '\\"')}"`,
|
|
86
|
+
{ encoding: 'utf-8', timeout: 4000, windowsHide: true },
|
|
87
|
+
);
|
|
88
|
+
if (out && out.trim()) return out;
|
|
89
|
+
// Empty (no matching process) — no point trying another shell.
|
|
90
|
+
return null;
|
|
91
|
+
} catch {
|
|
92
|
+
// Try next shell (pwsh on systems without legacy powershell.exe).
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Legacy fallback: wmic /format:list. Returns null on failure. */
|
|
99
|
+
function queryProcessesWinWmic() {
|
|
100
|
+
try {
|
|
101
|
+
return execSync(
|
|
102
|
+
'wmic process where "CommandLine like \'%antigravity%language_server%\'" get ProcessId,CommandLine /format:list',
|
|
103
|
+
{ encoding: 'utf-8', timeout: 4000, shell: 'cmd.exe' },
|
|
104
|
+
);
|
|
105
|
+
} catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Parse "ProcessId=..." / "CommandLine=..." records (from either PowerShell or
|
|
112
|
+
* wmic /format:list) and return the first language_server that carries a
|
|
113
|
+
* --csrf_token, or null. PowerShell emits an explicit "---" separator per
|
|
114
|
+
* process; wmic does not and may emit the two fields in either order, so a
|
|
115
|
+
* record also ends whenever a field we've already captured reappears.
|
|
116
|
+
*/
|
|
117
|
+
function parseWinProcessList(out) {
|
|
66
118
|
let pid = '';
|
|
119
|
+
let cmdLine = '';
|
|
120
|
+
const finish = () => {
|
|
121
|
+
if (pid && cmdLine && !/WMIC\.exe|powershell\.exe|pwsh\.exe/i.test(cmdLine)) {
|
|
122
|
+
const csrfMatch = cmdLine.match(/--csrf_token\s+([0-9a-f-]+)/);
|
|
123
|
+
if (csrfMatch) return { pid, csrfToken: csrfMatch[1] };
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
};
|
|
127
|
+
const reset = () => { pid = ''; cmdLine = ''; };
|
|
67
128
|
for (const line of out.split('\n')) {
|
|
68
129
|
const trimmed = line.trim();
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
130
|
+
const isPid = trimmed.startsWith('ProcessId=');
|
|
131
|
+
const isCmd = trimmed.startsWith('CommandLine=');
|
|
132
|
+
// Record boundary: explicit "---", or a field that would overwrite one we
|
|
133
|
+
// already hold (next process began without a separator, e.g. wmic output).
|
|
134
|
+
if (trimmed === '---' || (isPid && pid) || (isCmd && cmdLine)) {
|
|
135
|
+
const found = finish();
|
|
136
|
+
if (found) return found;
|
|
137
|
+
reset();
|
|
73
138
|
}
|
|
74
|
-
if (
|
|
139
|
+
if (isPid) pid = trimmed.slice('ProcessId='.length);
|
|
140
|
+
else if (isCmd) cmdLine = trimmed.slice('CommandLine='.length);
|
|
75
141
|
}
|
|
76
|
-
|
|
77
|
-
const csrfMatch = cmdLine.match(/--csrf_token\s+([0-9a-f-]+)/);
|
|
78
|
-
const csrfToken = csrfMatch ? csrfMatch[1] : '';
|
|
79
|
-
if (!csrfToken) return null;
|
|
80
|
-
return { pid, csrfToken };
|
|
142
|
+
return finish();
|
|
81
143
|
}
|
|
82
144
|
|
|
83
145
|
function findListeningPorts(pid) {
|