@ghl-ai/aw 0.1.37-beta.40 → 0.1.37-beta.41
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 +22 -64
- package/package.json +1 -1
package/commands/memory.mjs
CHANGED
|
@@ -171,92 +171,50 @@ async function memoryPack(args) {
|
|
|
171
171
|
async function memoryStats(args) {
|
|
172
172
|
fmt.intro('aw memory stats');
|
|
173
173
|
|
|
174
|
-
const params = {};
|
|
175
|
-
if (args['--namespace']) params.namespace = args['--namespace'];
|
|
176
|
-
|
|
177
174
|
const s = fmt.spinner();
|
|
178
175
|
s.start('Fetching memory statistics...');
|
|
179
176
|
try {
|
|
180
|
-
|
|
181
|
-
const result = await callMemoryTool('memory_search', { query: '*', limit: 200, ...params });
|
|
177
|
+
const stats = await callMemoryTool('memory_stats', {});
|
|
182
178
|
s.stop('Stats loaded');
|
|
183
179
|
|
|
184
|
-
|
|
185
|
-
const total = memories.length;
|
|
186
|
-
|
|
187
|
-
// Aggregate by layer, overlay, angle
|
|
188
|
-
const byLayer = {};
|
|
189
|
-
const byOverlay = {};
|
|
190
|
-
const byAngle = {};
|
|
191
|
-
for (const mem of memories) {
|
|
192
|
-
const layer = mem.layer || 'unclassified';
|
|
193
|
-
byLayer[layer] = (byLayer[layer] || 0) + 1;
|
|
194
|
-
for (const o of (mem.overlay || mem.overlays || [])) {
|
|
195
|
-
byOverlay[o] = (byOverlay[o] || 0) + 1;
|
|
196
|
-
}
|
|
197
|
-
for (const a of (mem.angle || mem.angles || [])) {
|
|
198
|
-
byAngle[a] = (byAngle[a] || 0) + 1;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
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
|
-
|
|
180
|
+
// Health metrics — server returns counts directly
|
|
224
181
|
const healthLines = [
|
|
225
|
-
` ${chalk.green('Active:'.padEnd(20))} ${
|
|
226
|
-
` ${chalk.yellow('Archived:'.padEnd(20))} ${
|
|
227
|
-
` ${chalk.cyan('Superseded:'.padEnd(20))} ${
|
|
182
|
+
` ${chalk.green('Active:'.padEnd(20))} ${stats.active ?? 0}`,
|
|
183
|
+
` ${chalk.yellow('Archived:'.padEnd(20))} ${stats.archived ?? 0}`,
|
|
184
|
+
` ${chalk.cyan('Superseded:'.padEnd(20))} ${stats.superseded ?? 0}`,
|
|
228
185
|
` ${chalk.dim('─'.repeat(30))}`,
|
|
229
|
-
` ${chalk.yellow('Decaying (30d+):'.padEnd(20))} ${decaying}`,
|
|
230
|
-
` ${chalk.red('At risk (<0.3):'.padEnd(20))} ${
|
|
231
|
-
` ${chalk.green('Human validated:'.padEnd(20))} ${
|
|
186
|
+
` ${chalk.yellow('Decaying (30d+):'.padEnd(20))} ${stats.decaying ?? 0}`,
|
|
187
|
+
` ${chalk.red('At risk (<0.3):'.padEnd(20))} ${stats.at_risk ?? 0}`,
|
|
188
|
+
` ${chalk.green('Human validated:'.padEnd(20))} ${stats.human_validated ?? 0}`,
|
|
232
189
|
].join('\n');
|
|
233
190
|
fmt.note(healthLines, 'Memory Health');
|
|
234
191
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
192
|
+
// 3D distribution from server
|
|
193
|
+
const byLayer = stats.by_layer || [];
|
|
194
|
+
if (byLayer.length) {
|
|
195
|
+
const layerLines = byLayer
|
|
196
|
+
.map(({ layer, count }) => ` ${chalk.cyan((layer || 'unclassified').padEnd(20))} ${count}`)
|
|
239
197
|
.join('\n');
|
|
240
198
|
fmt.note(layerLines, 'By Layer');
|
|
241
199
|
}
|
|
242
200
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
.map((
|
|
201
|
+
const byOverlay = stats.by_overlay || [];
|
|
202
|
+
if (byOverlay.length) {
|
|
203
|
+
const overlayLines = byOverlay
|
|
204
|
+
.map(({ overlay, count }) => ` ${chalk.magenta((overlay || '?').padEnd(20))} ${count}`)
|
|
247
205
|
.join('\n');
|
|
248
206
|
fmt.note(overlayLines, 'By Overlay');
|
|
249
207
|
}
|
|
250
208
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
.map((
|
|
209
|
+
const byAngle = stats.by_angle || [];
|
|
210
|
+
if (byAngle.length) {
|
|
211
|
+
const angleLines = byAngle
|
|
212
|
+
.map(({ angle, count }) => ` ${chalk.yellow((angle || '?').padEnd(20))} ${count}`)
|
|
255
213
|
.join('\n');
|
|
256
214
|
fmt.note(angleLines, 'By Angle');
|
|
257
215
|
}
|
|
258
216
|
|
|
259
|
-
fmt.logStep(`Total memories: ${chalk.bold(total)}`);
|
|
217
|
+
fmt.logStep(`Total memories: ${chalk.bold(stats.total ?? 0)}`);
|
|
260
218
|
fmt.outro('Stats complete');
|
|
261
219
|
} catch (err) {
|
|
262
220
|
s.stop(chalk.red('Failed'));
|