@vibe-cafe/vibe-usage 0.2.2 → 0.2.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/package.json +1 -1
- package/src/hooks.js +11 -6
- package/src/parsers/codex.js +12 -2
- package/src/sync.js +1 -1
package/package.json
CHANGED
package/src/hooks.js
CHANGED
|
@@ -85,20 +85,25 @@ export function injectCodex() {
|
|
|
85
85
|
mkdirSync(dirname(configPath), { recursive: true });
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const notifyLine = `notify =
|
|
88
|
+
const notifyLine = `notify = "sh -c \\"${SYNC_CMD}\\""`;
|
|
89
89
|
|
|
90
90
|
if (content.includes('vibe-usage')) {
|
|
91
|
-
// Migrate broken [[notify]] / [notify] table format from previous versions
|
|
92
|
-
// to correct
|
|
91
|
+
// Migrate broken [[notify]] / [notify] table format and array format from previous versions
|
|
92
|
+
// to correct string format: notify = "sh -c \"...\""
|
|
93
93
|
content = content.replace(
|
|
94
94
|
/^\[\[?notify\]\]?\n(?:command\s*=\s*["'][^"']*["']\n?)?/gm,
|
|
95
95
|
notifyLine + '\n',
|
|
96
96
|
);
|
|
97
|
-
//
|
|
97
|
+
// Migrate array format: notify = ["sh", "-c", "..."]
|
|
98
98
|
content = content.replace(
|
|
99
99
|
/^notify\s*=\s*\[.*vibe-usage.*\]$/gm,
|
|
100
100
|
notifyLine,
|
|
101
101
|
);
|
|
102
|
+
// Update existing string format notify = "..." to use latest command
|
|
103
|
+
content = content.replace(
|
|
104
|
+
/^notify\s*=\s*".*vibe-usage.*"$/gm,
|
|
105
|
+
notifyLine,
|
|
106
|
+
);
|
|
102
107
|
writeFileSync(configPath, content, 'utf-8');
|
|
103
108
|
return { injected: false, reason: 'already installed (updated)' };
|
|
104
109
|
}
|
|
@@ -106,8 +111,8 @@ export function injectCodex() {
|
|
|
106
111
|
// Check if any notify line already exists
|
|
107
112
|
const hasNotify = /^notify\s*=/m.test(content);
|
|
108
113
|
if (hasNotify) {
|
|
109
|
-
//
|
|
110
|
-
content = content.replace(/^notify\s*=\s
|
|
114
|
+
// Replace existing notify value
|
|
115
|
+
content = content.replace(/^notify\s*=\s*.+$/gm, notifyLine);
|
|
111
116
|
} else {
|
|
112
117
|
content += `\n${notifyLine}\n`;
|
|
113
118
|
}
|
package/src/parsers/codex.js
CHANGED
|
@@ -72,6 +72,8 @@ export async function parse(lastSync) {
|
|
|
72
72
|
} catch { break; }
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
// Track model from turn_context events (fallback when token_count lacks model)
|
|
76
|
+
let turnContextModel = 'unknown';
|
|
75
77
|
// Track previous cumulative totals per model to compute deltas when only total_token_usage is available
|
|
76
78
|
const prevTotal = new Map();
|
|
77
79
|
for (const line of content.split('\n')) {
|
|
@@ -83,7 +85,15 @@ export async function parse(lastSync) {
|
|
|
83
85
|
if (obj.type !== 'event_msg') continue;
|
|
84
86
|
|
|
85
87
|
const payload = obj.payload;
|
|
86
|
-
if (!payload
|
|
88
|
+
if (!payload) continue;
|
|
89
|
+
|
|
90
|
+
// Capture model from turn_context events
|
|
91
|
+
if (payload.type === 'turn_context' && payload.model) {
|
|
92
|
+
turnContextModel = payload.model;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (payload.type !== 'token_count') continue;
|
|
87
97
|
|
|
88
98
|
const info = payload.info;
|
|
89
99
|
if (!info) continue;
|
|
@@ -113,7 +123,7 @@ export async function parse(lastSync) {
|
|
|
113
123
|
}
|
|
114
124
|
if (!usage) continue;
|
|
115
125
|
|
|
116
|
-
const model = info.model || payload.model || sessionModel;
|
|
126
|
+
const model = info.model || payload.model || turnContextModel || sessionModel;
|
|
117
127
|
|
|
118
128
|
entries.push({
|
|
119
129
|
source: 'codex',
|
package/src/sync.js
CHANGED