@vibe-cafe/vibe-usage 0.7.1 → 0.7.3
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 +14 -2
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/init.js +2 -1
- package/src/parsers/openclaw.js +22 -8
- package/src/sync.js +6 -1
- package/src/tools.js +24 -2
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ npx @vibe-cafe/vibe-usage status # Show config & detected tools
|
|
|
41
41
|
| GitHub Copilot CLI | `~/.copilot/session-state/*/events.jsonl` |
|
|
42
42
|
| Gemini CLI | `~/.gemini/tmp/` |
|
|
43
43
|
| OpenCode | `~/.local/share/opencode/opencode.db` (SQLite, `json_extract` query) |
|
|
44
|
-
| OpenClaw | `~/.openclaw/agents/` |
|
|
44
|
+
| OpenClaw | `~/.openclaw/agents/`, `~/.openclaw-<profile>/agents/` (profile deployments) |
|
|
45
45
|
| pi | `~/.pi/agent/sessions/` |
|
|
46
46
|
| Qwen Code | `~/.qwen/tmp/` |
|
|
47
47
|
| Kimi Code | `~/.kimi/sessions/` |
|
|
@@ -90,7 +90,19 @@ VIBE_USAGE_DEV=1 npx @vibe-cafe/vibe-usage sync
|
|
|
90
90
|
|
|
91
91
|
## Config
|
|
92
92
|
|
|
93
|
-
Config stored at `~/.vibe-usage/config.json` (dev: `config.dev.json`).
|
|
93
|
+
Config stored at `~/.vibe-usage/config.json` (dev: `config.dev.json`).
|
|
94
|
+
|
|
95
|
+
| Key | Description |
|
|
96
|
+
|-----|-------------|
|
|
97
|
+
| `apiKey` | Your API key (starts with `vbu_`) |
|
|
98
|
+
| `apiUrl` | Server URL (default: `https://vibecafe.ai`) |
|
|
99
|
+
| `hostname` | Stable device name for usage tracking (set at init, reused across syncs) |
|
|
100
|
+
|
|
101
|
+
The `hostname` is captured once during `init` and reused for all future syncs. This prevents macOS mDNS hostname changes (e.g., `MacBook-Pro` → `MacBook-Pro-2`) from creating duplicate device entries. To change it manually:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npx @vibe-cafe/vibe-usage config set hostname my-device-name
|
|
105
|
+
```
|
|
94
106
|
|
|
95
107
|
## Daemon Mode
|
|
96
108
|
|
package/package.json
CHANGED
package/src/index.js
CHANGED
package/src/init.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline';
|
|
2
2
|
import { execFile } from 'node:child_process';
|
|
3
|
-
import { platform } from 'node:os';
|
|
3
|
+
import { hostname as osHostname, platform } from 'node:os';
|
|
4
4
|
import { loadConfig, saveConfig } from './config.js';
|
|
5
5
|
import { ingest } from './api.js';
|
|
6
6
|
import { runSync } from './sync.js';
|
|
@@ -61,6 +61,7 @@ export async function runInit() {
|
|
|
61
61
|
const config = {
|
|
62
62
|
apiKey,
|
|
63
63
|
apiUrl,
|
|
64
|
+
hostname: existing?.hostname || osHostname().replace(/\.local$/, ''),
|
|
64
65
|
};
|
|
65
66
|
saveConfig(config);
|
|
66
67
|
|
package/src/parsers/openclaw.js
CHANGED
|
@@ -1,16 +1,30 @@
|
|
|
1
|
-
import { readdirSync, readFileSync,
|
|
1
|
+
import { readdirSync, readFileSync, existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { aggregateToBuckets, extractSessions } from './index.js';
|
|
5
5
|
|
|
6
6
|
// OpenClaw stores data at ~/.openclaw/agents/<agentId>/sessions/*.jsonl
|
|
7
|
+
// Profile deployments use ~/.openclaw-<profile>/agents/...
|
|
7
8
|
// Legacy paths: ~/.clawdbot, ~/.moltbot, ~/.moldbot
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
function getPossibleRoots() {
|
|
10
|
+
const home = homedir();
|
|
11
|
+
const roots = [
|
|
12
|
+
join(home, '.clawdbot'),
|
|
13
|
+
join(home, '.moltbot'),
|
|
14
|
+
join(home, '.moldbot'),
|
|
15
|
+
];
|
|
16
|
+
try {
|
|
17
|
+
for (const entry of readdirSync(home, { withFileTypes: true })) {
|
|
18
|
+
if (!entry.isDirectory()) continue;
|
|
19
|
+
if (entry.name === '.openclaw' || /^\.openclaw-.+/.test(entry.name)) {
|
|
20
|
+
roots.push(join(home, entry.name));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
} catch {
|
|
24
|
+
// ignore read errors
|
|
25
|
+
}
|
|
26
|
+
return roots;
|
|
27
|
+
}
|
|
14
28
|
|
|
15
29
|
/** Normalize usage fields — OpenClaw supports multiple naming conventions */
|
|
16
30
|
function getTokens(usage, ...keys) {
|
|
@@ -24,7 +38,7 @@ export async function parse() {
|
|
|
24
38
|
const entries = [];
|
|
25
39
|
const sessionEvents = [];
|
|
26
40
|
|
|
27
|
-
for (const root of
|
|
41
|
+
for (const root of getPossibleRoots()) {
|
|
28
42
|
const agentsDir = join(root, 'agents');
|
|
29
43
|
if (!existsSync(agentsDir)) continue;
|
|
30
44
|
|
package/src/sync.js
CHANGED
|
@@ -59,7 +59,12 @@ export async function runSync({ throws = false, quiet = false } = {}) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
let host = config.hostname;
|
|
63
|
+
if (!host) {
|
|
64
|
+
host = osHostname().replace(/\.local$/, '');
|
|
65
|
+
config.hostname = host;
|
|
66
|
+
saveConfig(config);
|
|
67
|
+
}
|
|
63
68
|
for (const b of allBuckets) {
|
|
64
69
|
b.hostname = host;
|
|
65
70
|
}
|
package/src/tools.js
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
1
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
|
|
5
|
+
/** Find all OpenClaw data roots: ~/.openclaw and ~/.openclaw-<profile> */
|
|
6
|
+
function findOpenclawDataDirs() {
|
|
7
|
+
const home = homedir();
|
|
8
|
+
const dirs = [];
|
|
9
|
+
try {
|
|
10
|
+
for (const entry of readdirSync(home, { withFileTypes: true })) {
|
|
11
|
+
if (!entry.isDirectory()) continue;
|
|
12
|
+
if (entry.name === '.openclaw' || /^\.openclaw-.+/.test(entry.name)) {
|
|
13
|
+
const agentsDir = join(home, entry.name, 'agents');
|
|
14
|
+
if (existsSync(agentsDir)) dirs.push(agentsDir);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
} catch {
|
|
18
|
+
// ignore read errors
|
|
19
|
+
}
|
|
20
|
+
return dirs;
|
|
21
|
+
}
|
|
22
|
+
|
|
5
23
|
export const TOOLS = [
|
|
6
24
|
{
|
|
7
25
|
name: 'Antigravity',
|
|
@@ -37,6 +55,7 @@ export const TOOLS = [
|
|
|
37
55
|
name: 'OpenClaw',
|
|
38
56
|
id: 'openclaw',
|
|
39
57
|
dataDir: join(homedir(), '.openclaw', 'agents'),
|
|
58
|
+
detectDataDirs: findOpenclawDataDirs,
|
|
40
59
|
},
|
|
41
60
|
{
|
|
42
61
|
name: 'pi',
|
|
@@ -66,5 +85,8 @@ export const TOOLS = [
|
|
|
66
85
|
];
|
|
67
86
|
|
|
68
87
|
export function detectInstalledTools() {
|
|
69
|
-
return TOOLS.filter(t =>
|
|
88
|
+
return TOOLS.filter(t => {
|
|
89
|
+
if (t.detectDataDirs) return t.detectDataDirs().length > 0;
|
|
90
|
+
return existsSync(t.dataDir);
|
|
91
|
+
});
|
|
70
92
|
}
|