@ghl-ai/aw 0.1.37-beta.39 → 0.1.37-beta.40
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/commands/memory.mjs +33 -0
- package/package.json +1 -1
package/commands/memory.mjs
CHANGED
|
@@ -199,6 +199,39 @@ async function memoryStats(args) {
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
// Health metrics
|
|
203
|
+
const now = Date.now();
|
|
204
|
+
const thirtyDaysMs = 30 * 24 * 60 * 60 * 1000;
|
|
205
|
+
|
|
206
|
+
const byState = { active: 0, archived: 0, superseded: 0 };
|
|
207
|
+
let decaying = 0; // untouched 30+ days
|
|
208
|
+
let atRisk = 0; // confidence < 0.3
|
|
209
|
+
let humanValidated = 0;
|
|
210
|
+
|
|
211
|
+
for (const mem of memories) {
|
|
212
|
+
const state = mem.state || 'active';
|
|
213
|
+
byState[state] = (byState[state] || 0) + 1;
|
|
214
|
+
|
|
215
|
+
const lastAccessed = mem.last_accessed ? new Date(mem.last_accessed).getTime() : 0;
|
|
216
|
+
if (lastAccessed > 0 && (now - lastAccessed) > thirtyDaysMs) decaying++;
|
|
217
|
+
|
|
218
|
+
const confidence = mem.confidence ?? 0.7;
|
|
219
|
+
if (confidence < 0.3) atRisk++;
|
|
220
|
+
|
|
221
|
+
if (mem.human_validated) humanValidated++;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const healthLines = [
|
|
225
|
+
` ${chalk.green('Active:'.padEnd(20))} ${byState.active || 0}`,
|
|
226
|
+
` ${chalk.yellow('Archived:'.padEnd(20))} ${byState.archived || 0}`,
|
|
227
|
+
` ${chalk.cyan('Superseded:'.padEnd(20))} ${byState.superseded || 0}`,
|
|
228
|
+
` ${chalk.dim('─'.repeat(30))}`,
|
|
229
|
+
` ${chalk.yellow('Decaying (30d+):'.padEnd(20))} ${decaying}`,
|
|
230
|
+
` ${chalk.red('At risk (<0.3):'.padEnd(20))} ${atRisk}`,
|
|
231
|
+
` ${chalk.green('Human validated:'.padEnd(20))} ${humanValidated}`,
|
|
232
|
+
].join('\n');
|
|
233
|
+
fmt.note(healthLines, 'Memory Health');
|
|
234
|
+
|
|
202
235
|
if (Object.keys(byLayer).length) {
|
|
203
236
|
const layerLines = Object.entries(byLayer)
|
|
204
237
|
.sort((a, b) => b[1] - a[1])
|