@reepoe/plugin 1.3.25 ā 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 +39 -12
- package/bin/start.js +26 -7
- package/binaries/reepoe-linux-x64 +0 -0
- package/binaries/reepoe-macos-arm64 +0 -0
- package/package.json +1 -1
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:
|
|
47
|
-
tokens_saved:
|
|
48
|
-
cost_saved:
|
|
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,
|
|
60
|
-
patterns_active:
|
|
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
|
|
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
|
|
424
|
-
|
|
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
|
-
|
|
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
|
-
|
|
439
|
-
console.
|
|
440
|
-
console.
|
|
441
|
-
|
|
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
|
|
|
Binary file
|
|
Binary file
|