@reepoe/plugin 1.3.26 → 1.3.27

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/bin/metrics.js CHANGED
@@ -39,29 +39,56 @@ async function showMetrics() {
39
39
  const localRes = await axios.get(`http://localhost:${port}/metrics`, { timeout: 1000 });
40
40
  const localRaw = localRes.data;
41
41
 
42
+ // Get today's date in YYYY-MM-DD format (LOCAL time, not UTC!)
43
+ const getLocalDateString = (d) => {
44
+ const year = d.getFullYear();
45
+ const month = String(d.getMonth() + 1).padStart(2, '0');
46
+ const day = String(d.getDate()).padStart(2, '0');
47
+ return `${year}-${month}-${day}`;
48
+ };
49
+
50
+ const today = getLocalDateString(new Date());
51
+ const todayData = localRaw.daily?.[today] || {};
52
+
53
+ // Calculate THIS WEEK metrics by aggregating last 7 days
54
+ const weekMetrics = { queries: 0, tokens_saved: 0, cost_saved: 0 };
55
+ const dailyData = localRaw.daily || {};
56
+
57
+ for (let i = 0; i < 7; i++) {
58
+ const date = new Date();
59
+ date.setDate(date.getDate() - i);
60
+ const dateKey = getLocalDateString(date);
61
+
62
+ if (dailyData[dateKey]) {
63
+ weekMetrics.queries += dailyData[dateKey].total_queries || 0;
64
+ weekMetrics.tokens_saved += dailyData[dateKey].tokens_saved || 0;
65
+ // Cost saved calculation based on tokens (approx $0.003 per 1k tokens)
66
+ weekMetrics.cost_saved += ((dailyData[dateKey].tokens_saved || 0) / 1000) * 0.003;
67
+ }
68
+ }
69
+
70
+ // Calculate cost saved for today
71
+ const todayCostSaved = ((todayData.tokens_saved || 0) / 1000) * 0.003;
72
+
42
73
  // Transform raw local metrics to view structure
43
74
  metricsData = {
44
75
  metrics: {
45
76
  today: {
46
- queries: localRaw.daily?.[new Date().toISOString().split('T')[0]]?.total_queries || 0,
47
- tokens_saved: localRaw.daily?.[new Date().toISOString().split('T')[0]]?.tokens_saved || 0,
48
- cost_saved: 0 // Local cost tracking not yet implemented in raw endpoint
49
- },
50
- week: {
51
- queries: 0, // Would need aggregation
52
- tokens_saved: 0,
53
- cost_saved: 0
77
+ queries: todayData.total_queries || 0,
78
+ tokens_saved: todayData.tokens_saved || 0,
79
+ cost_saved: todayCostSaved
54
80
  },
81
+ week: weekMetrics,
55
82
  alltime: {
56
83
  queries: localRaw.lifetime?.total_queries || 0,
57
84
  tokens_saved: localRaw.lifetime?.tokens_saved || 0,
58
- cost_saved: 0,
59
- patterns_learned: Object.keys(localRaw.query_types || {}).length, // Approx
60
- patterns_active: 0
85
+ cost_saved: ((localRaw.lifetime?.tokens_saved || 0) / 1000) * 0.003,
86
+ patterns_learned: Object.keys(localRaw.query_types || {}).length,
87
+ patterns_active: Object.keys(localRaw.query_types || {}).length
61
88
  }
62
89
  },
63
90
  account: {
64
- status: 'Local Dev',
91
+ status: 'Active (Local)',
65
92
  expires_at: null
66
93
  }
67
94
  };
package/bin/start.js CHANGED
@@ -420,10 +420,26 @@ async function main() {
420
420
  const pidFile = path.join(os.tmpdir(), `reepoe-${port}.pid`);
421
421
  fs.writeFileSync(pidFile, child.pid.toString());
422
422
 
423
- // Wait for server to start (FIX #3: Increased timeout)
424
- await new Promise(resolve => setTimeout(resolve, 5000));
423
+ // Wait for server to start with retry loop (FIX: More robust startup detection)
424
+ console.log(' Waiting for server to initialize...');
425
425
 
426
- const started = await isServerRunning(port);
426
+ let started = false;
427
+ const maxRetries = 15; // 15 retries * 2 seconds = 30 seconds max
428
+ const retryInterval = 2000; // 2 seconds between retries
429
+
430
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
431
+ await new Promise(resolve => setTimeout(resolve, retryInterval));
432
+
433
+ started = await isServerRunning(port);
434
+ if (started) {
435
+ break;
436
+ }
437
+
438
+ // Show progress dots for user feedback
439
+ if (attempt % 3 === 0) {
440
+ process.stdout.write('.');
441
+ }
442
+ }
427
443
 
428
444
  if (started) {
429
445
  console.log(`\nāœ… ReePoe server started successfully!`);
@@ -435,10 +451,13 @@ async function main() {
435
451
  console.log(`\nšŸ’” Try: reepoe query "what does this codebase do?"`);
436
452
  console.log(` Stop: reepoe-stop\n`);
437
453
  } else {
438
- console.error(`\nāŒ Server failed to start on port ${port}`);
439
- console.error(` Check logs: ${path.join(process.cwd(), 'logs', 'server.log')}`);
440
- console.error(' Status: reepoe-status');
441
- process.exit(1);
454
+ // Server might still be starting - don't exit, just warn
455
+ console.log(`\nā³ Server startup is taking longer than expected...`);
456
+ console.log(` The server may still be indexing your codebase.`);
457
+ console.log(`\nšŸ’” Check status: reepoe-status`);
458
+ console.log(` If server is running: curl http://localhost:${port}/health`);
459
+ console.log(` View logs: ${path.join(process.cwd(), 'logs', 'server.log')}`);
460
+ // Do NOT exit(1) - server is likely still starting
442
461
  }
443
462
  }
444
463
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reepoe/plugin",
3
- "version": "1.3.26",
3
+ "version": "1.3.27",
4
4
  "description": "ReePoe AI Code Manager - Install in any codebase for instant AI agent integration",
5
5
  "keywords": [
6
6
  "ai",