@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibe-cafe/vibe-usage",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Track your AI coding tool token usage and sync to vibecafe.ai",
5
5
  "type": "module",
6
6
  "bin": {
package/src/init.js CHANGED
@@ -62,7 +62,7 @@ export async function runInit() {
62
62
  const config = {
63
63
  apiKey,
64
64
  apiUrl,
65
- lastSync: null,
65
+ lastSync: existing?.lastSync || null,
66
66
  };
67
67
  saveConfig(config);
68
68
 
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
+ }