@vibe-cafe/vibe-usage 0.1.9 → 0.1.10
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/init.js +1 -1
- package/src/sync.js +22 -0
package/package.json
CHANGED
package/src/init.js
CHANGED
package/src/sync.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { loadConfig, saveConfig } from './config.js';
|
|
2
2
|
import { ingest } from './api.js';
|
|
3
3
|
import { parsers } from './parsers/index.js';
|
|
4
|
+
import { TOOLS } from './hooks.js';
|
|
4
5
|
|
|
5
6
|
const BATCH_SIZE = 500;
|
|
6
7
|
|
|
7
8
|
export async function runSync() {
|
|
9
|
+
// Self-heal: re-inject any missing hooks before syncing
|
|
10
|
+
ensureHooks();
|
|
11
|
+
|
|
8
12
|
const config = loadConfig();
|
|
9
13
|
if (!config?.apiKey) {
|
|
10
14
|
console.error('Not configured. Run `npx @vibe-cafe/vibe-usage init` first.');
|
|
@@ -73,3 +77,21 @@ export async function runSync() {
|
|
|
73
77
|
process.exit(1);
|
|
74
78
|
}
|
|
75
79
|
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Re-inject hooks for any installed tool whose hook is missing.
|
|
83
|
+
* Runs silently — meant as a self-healing side effect of sync.
|
|
84
|
+
*/
|
|
85
|
+
function ensureHooks() {
|
|
86
|
+
for (const tool of TOOLS) {
|
|
87
|
+
if (!tool.inject) continue;
|
|
88
|
+
try {
|
|
89
|
+
const result = tool.inject();
|
|
90
|
+
if (result.injected) {
|
|
91
|
+
process.stderr.write(`hook: re-installed ${tool.name} hook\n`);
|
|
92
|
+
}
|
|
93
|
+
} catch {
|
|
94
|
+
// ignore — best effort
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|