agentlytics 0.2.9 → 0.2.11

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.
Files changed (2) hide show
  1. package/index.js +36 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -196,6 +196,42 @@ if (!collectOnly && !isUiDev && !fs.existsSync(publicIndex)) {
196
196
  process.exit(1);
197
197
  }
198
198
 
199
+ // ── Ensure better-sqlite3 native bindings exist ─────────────
200
+ try {
201
+ require('better-sqlite3');
202
+ } catch (e) {
203
+ if (e.message && e.message.includes('Could not locate the bindings file')) {
204
+ console.log(chalk.cyan(' ⟳ Native SQLite module not found, downloading prebuilt binary...'));
205
+ const bsqlDir = path.dirname(require.resolve('better-sqlite3/package.json'));
206
+ let rebuilt = false;
207
+ // 1) Use prebuild-install (dep of better-sqlite3) to download a prebuilt binary
208
+ try {
209
+ const prebuildBin = require.resolve('prebuild-install/bin.js');
210
+ execSync(`node "${prebuildBin}" -r napi`, { cwd: bsqlDir, stdio: 'pipe', timeout: 60000 });
211
+ rebuilt = true;
212
+ } catch {}
213
+ // 2) Fallback: compile from source via node-gyp
214
+ if (!rebuilt) {
215
+ console.log(chalk.cyan(' ⟳ Prebuilt unavailable, compiling from source...'));
216
+ try {
217
+ execSync('npx --yes node-gyp rebuild --release', { cwd: bsqlDir, stdio: 'pipe', timeout: 120000 });
218
+ rebuilt = true;
219
+ } catch {}
220
+ }
221
+ if (rebuilt) {
222
+ console.log(chalk.green(' ✓ Native module ready'));
223
+ // Clear require cache so the freshly built binding is picked up
224
+ delete require.cache[require.resolve('better-sqlite3')];
225
+ } else {
226
+ console.error(chalk.red(' ✗ Failed to build better-sqlite3.'));
227
+ console.error(chalk.dim(' Ensure build tools are installed (python3, make, g++).'));
228
+ process.exit(1);
229
+ }
230
+ } else {
231
+ throw e;
232
+ }
233
+ }
234
+
199
235
  const cache = require('./cache');
200
236
 
201
237
  // Wipe cache if --no-cache flag is passed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentlytics",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Comprehensive analytics dashboard for AI coding agents — Cursor, Windsurf, Claude Code, VS Code Copilot, Zed, Antigravity, OpenCode, Command Code",
5
5
  "main": "index.js",
6
6
  "bin": {