agentlytics 0.1.7 → 0.1.8

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/cache.js CHANGED
@@ -7,7 +7,7 @@ const { calculateCost, getModelPricing, normalizeModelName } = require('./pricin
7
7
 
8
8
  const CACHE_DIR = path.join(os.homedir(), '.agentlytics');
9
9
  const CACHE_DB = path.join(CACHE_DIR, 'cache.db');
10
- const SCHEMA_VERSION = 4; // bump this when schema changes to auto-revalidate
10
+ const SCHEMA_VERSION = 5; // bump this when schema changes to auto-revalidate
11
11
 
12
12
  let db = null;
13
13
 
@@ -516,7 +516,26 @@ function getCachedChat(id) {
516
516
  if (!chat) return null;
517
517
 
518
518
  const stats = db.prepare('SELECT * FROM chat_stats WHERE chat_id = ?').get(chat.id);
519
- const messages = db.prepare('SELECT role, content, model, input_tokens, output_tokens FROM messages WHERE chat_id = ? ORDER BY seq').all(chat.id);
519
+ let messages = db.prepare('SELECT role, content, model, input_tokens, output_tokens FROM messages WHERE chat_id = ? ORDER BY seq').all(chat.id);
520
+
521
+ // If no cached messages, try fetching live from the editor
522
+ if (messages.length === 0 && !chat.encrypted) {
523
+ try {
524
+ const meta = JSON.parse(chat._meta || '{}');
525
+ const reconstructed = {
526
+ composerId: chat.id, source: chat.source, name: chat.name, mode: chat.mode,
527
+ folder: chat.folder, createdAt: chat.created_at, lastUpdatedAt: chat.last_updated_at,
528
+ encrypted: !!chat.encrypted, bubbleCount: chat.bubble_count,
529
+ ...meta,
530
+ };
531
+ const liveMessages = getMessages(reconstructed);
532
+ if (liveMessages && liveMessages.length > 0) {
533
+ // Store for next time
534
+ try { analyzeAndStore(reconstructed); } catch {}
535
+ messages = db.prepare('SELECT role, content, model, input_tokens, output_tokens FROM messages WHERE chat_id = ? ORDER BY seq').all(chat.id);
536
+ }
537
+ } catch {}
538
+ }
520
539
 
521
540
  let parsedStats = null;
522
541
  if (stats) {
package/editors/cursor.js CHANGED
@@ -182,6 +182,7 @@ function getComposerBubbles(globalDb, composerId) {
182
182
  function bubblesToMessages(bubbles) {
183
183
  const messages = [];
184
184
  for (const b of bubbles) {
185
+ if (!b) continue;
185
186
  const type = b.type; // 1=user, 2=assistant
186
187
  if (type === 1) {
187
188
  const text = b.text || '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentlytics",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
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": {