monomind 1.17.0 → 1.17.1
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/.claude/agents/engineering/engineering-security-engineer.md +1 -1
- package/.claude/commands/mastermind/_repeat.md +4 -0
- package/.claude/commands/mastermind/master.md +52 -1
- package/.claude/scheduled_tasks.lock +1 -1
- package/.claude/skills/mastermind/_repeat.md +2 -0
- package/package.json +1 -1
- package/packages/@monomind/cli/.claude/agents/engineering/engineering-security-engineer.md +1 -1
- package/packages/@monomind/cli/.claude/commands/mastermind/_repeat.md +4 -0
- package/packages/@monomind/cli/.claude/commands/mastermind/master.md +52 -1
- package/packages/@monomind/cli/.claude/skills/mastermind/_repeat.md +2 -0
- package/packages/@monomind/cli/dist/src/__tests__/browse-analyzer.test.js +42 -59
- package/packages/@monomind/cli/dist/src/browser/dashboard/server.js +18 -0
- package/packages/@monomind/cli/dist/src/browser/dashboard/ui.html +37 -125
- package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.d.ts +17 -0
- package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.js +320 -0
- package/packages/@monomind/cli/dist/src/commands/agent-ops.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/commands/agent-ops.js +329 -0
- package/packages/@monomind/cli/dist/src/commands/agent.js +5 -907
- package/packages/@monomind/cli/dist/src/commands/analyze-ast.d.ts +26 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-ast.js +284 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-boundaries.d.ts +14 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-boundaries.js +295 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-diff.d.ts +8 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-diff.js +395 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-graph.d.ts +14 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-graph.js +304 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-imports.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-imports.js +287 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-symbols.d.ts +14 -0
- package/packages/@monomind/cli/dist/src/commands/analyze-symbols.js +302 -0
- package/packages/@monomind/cli/dist/src/commands/analyze.d.ts +38 -0
- package/packages/@monomind/cli/dist/src/commands/analyze.js +12 -1827
- package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.d.ts +26 -0
- package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.js +189 -0
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.d.ts +19 -0
- package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +388 -0
- package/packages/@monomind/cli/dist/src/commands/doctor.js +51 -942
- package/packages/@monomind/cli/dist/src/commands/hive-mind-comms.d.ts +11 -0
- package/packages/@monomind/cli/dist/src/commands/hive-mind-comms.js +242 -0
- package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.d.ts +35 -0
- package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.js +203 -0
- package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.d.ts +8 -0
- package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.js +233 -0
- package/packages/@monomind/cli/dist/src/commands/hive-mind-spawn.d.ts +12 -0
- package/packages/@monomind/cli/dist/src/commands/hive-mind-spawn.js +274 -0
- package/packages/@monomind/cli/dist/src/commands/hive-mind.js +10 -1129
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.d.ts +4 -4
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.js +19 -819
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.js +334 -0
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.js +399 -0
- package/packages/@monomind/cli/dist/src/commands/init-subcommands.d.ts +8 -0
- package/packages/@monomind/cli/dist/src/commands/init-subcommands.js +156 -0
- package/packages/@monomind/cli/dist/src/commands/init-upgrade.d.ts +6 -0
- package/packages/@monomind/cli/dist/src/commands/init-upgrade.js +203 -0
- package/packages/@monomind/cli/dist/src/commands/init-wizard.d.ts +6 -0
- package/packages/@monomind/cli/dist/src/commands/init-wizard.js +246 -0
- package/packages/@monomind/cli/dist/src/commands/init.js +6 -623
- package/packages/@monomind/cli/dist/src/commands/memory-admin.d.ts +10 -0
- package/packages/@monomind/cli/dist/src/commands/memory-admin.js +433 -0
- package/packages/@monomind/cli/dist/src/commands/memory-crud.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/commands/memory-crud.js +342 -0
- package/packages/@monomind/cli/dist/src/commands/memory-list.d.ts +10 -0
- package/packages/@monomind/cli/dist/src/commands/memory-list.js +321 -0
- package/packages/@monomind/cli/dist/src/commands/memory-transfer.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +372 -0
- package/packages/@monomind/cli/dist/src/commands/memory.d.ts +6 -0
- package/packages/@monomind/cli/dist/src/commands/memory.js +10 -1441
- package/packages/@monomind/cli/dist/src/commands/neural-core.d.ts +8 -0
- package/packages/@monomind/cli/dist/src/commands/neural-core.js +274 -0
- package/packages/@monomind/cli/dist/src/commands/neural-optimize.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/commands/neural-optimize.js +332 -0
- package/packages/@monomind/cli/dist/src/commands/neural-registry.d.ts +7 -0
- package/packages/@monomind/cli/dist/src/commands/neural-registry.js +290 -0
- package/packages/@monomind/cli/dist/src/commands/neural.js +3 -974
- package/packages/@monomind/cli/dist/src/commands/platforms.js +327 -7
- package/packages/@monomind/cli/dist/src/commands/security-cve.d.ts +6 -0
- package/packages/@monomind/cli/dist/src/commands/security-cve.js +310 -0
- package/packages/@monomind/cli/dist/src/commands/security-misc.d.ts +9 -0
- package/packages/@monomind/cli/dist/src/commands/security-misc.js +293 -0
- package/packages/@monomind/cli/dist/src/commands/security-scan.d.ts +18 -0
- package/packages/@monomind/cli/dist/src/commands/security-scan.js +328 -0
- package/packages/@monomind/cli/dist/src/commands/security.js +3 -958
- package/packages/@monomind/cli/dist/src/commands/session.js +1 -1
- package/packages/@monomind/cli/dist/src/commands/swarm.js +23 -17
- package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +77 -0
- package/packages/@monomind/cli/dist/src/parser.js +11 -6
- package/packages/@monomind/cli/dist/src/routing/llm-caller.js +1 -2
- package/packages/@monomind/cli/package.json +2 -3
- package/packages/@monomind/cli/scripts/understand-analyze.mjs +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Admin Commands
|
|
3
|
+
* deleteCommand, statsCommand, configureCommand, cleanupCommand
|
|
4
|
+
*/
|
|
5
|
+
import type { Command } from '../types.js';
|
|
6
|
+
export declare const deleteCommand: Command;
|
|
7
|
+
export declare const statsCommand: Command;
|
|
8
|
+
export declare const configureCommand: Command;
|
|
9
|
+
export declare const cleanupCommand: Command;
|
|
10
|
+
//# sourceMappingURL=memory-admin.d.ts.map
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Admin Commands
|
|
3
|
+
* deleteCommand, statsCommand, configureCommand, cleanupCommand
|
|
4
|
+
*/
|
|
5
|
+
import { output } from '../output.js';
|
|
6
|
+
import { select, confirm } from '../prompt.js';
|
|
7
|
+
import { callMCPTool, MCPClientError } from '../mcp-client.js';
|
|
8
|
+
import { configManager } from '../services/config-file-manager.js';
|
|
9
|
+
// Memory backends (needed for configureCommand)
|
|
10
|
+
const BACKENDS = [
|
|
11
|
+
{ value: 'lancedb', label: 'LanceDB', hint: 'Vector database with ANN indexing' },
|
|
12
|
+
{ value: 'sqlite', label: 'SQLite', hint: 'Lightweight local storage' },
|
|
13
|
+
{ value: 'hybrid', label: 'Hybrid', hint: 'SQLite + LanceDB (recommended)' },
|
|
14
|
+
{ value: 'memory', label: 'In-Memory', hint: 'Fast but non-persistent' }
|
|
15
|
+
];
|
|
16
|
+
// Delete command
|
|
17
|
+
export const deleteCommand = {
|
|
18
|
+
name: 'delete',
|
|
19
|
+
aliases: ['rm'],
|
|
20
|
+
description: 'Delete a memory entry (LanceDB, Memory Palace, or knowledge chunk)',
|
|
21
|
+
options: [
|
|
22
|
+
{
|
|
23
|
+
name: 'key',
|
|
24
|
+
short: 'k',
|
|
25
|
+
description: 'Storage key',
|
|
26
|
+
type: 'string'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: 'namespace',
|
|
30
|
+
short: 'n',
|
|
31
|
+
description: 'Memory namespace',
|
|
32
|
+
type: 'string',
|
|
33
|
+
default: 'default'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'source',
|
|
37
|
+
short: 's',
|
|
38
|
+
description: 'Source to delete from: lancedb, palace, knowledge',
|
|
39
|
+
type: 'string',
|
|
40
|
+
default: 'lancedb',
|
|
41
|
+
choices: ['lancedb', 'palace', 'knowledge']
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: 'id',
|
|
45
|
+
description: 'Entry ID (palace/knowledge)',
|
|
46
|
+
type: 'string'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'force',
|
|
50
|
+
short: 'f',
|
|
51
|
+
description: 'Skip confirmation',
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
default: false
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
examples: [
|
|
57
|
+
{ command: 'monomind memory delete -k "mykey"', description: 'Delete memory entry' },
|
|
58
|
+
{ command: 'monomind memory delete -k "lesson" -n "lessons"', description: 'Delete from specific namespace' },
|
|
59
|
+
{ command: 'monomind memory delete --source palace --id "abc123"', description: 'Delete Memory Palace drawer' },
|
|
60
|
+
{ command: 'monomind memory delete --source knowledge --id "chunk-42" -f', description: 'Delete knowledge chunk (no confirm)' }
|
|
61
|
+
],
|
|
62
|
+
action: async (ctx) => {
|
|
63
|
+
const source = ctx.flags.source || 'lancedb';
|
|
64
|
+
const force = ctx.flags.force;
|
|
65
|
+
if (source === 'lancedb') {
|
|
66
|
+
const key = ctx.flags.key || ctx.args[0];
|
|
67
|
+
const namespace = ctx.flags.namespace || 'default';
|
|
68
|
+
if (!key) {
|
|
69
|
+
output.printError('Key is required. Use: memory delete -k "key" [-n "namespace"]');
|
|
70
|
+
return { success: false, exitCode: 1 };
|
|
71
|
+
}
|
|
72
|
+
if (!force && ctx.interactive) {
|
|
73
|
+
const confirmed = await confirm({
|
|
74
|
+
message: `Delete memory entry "${key}" from namespace "${namespace}"?`,
|
|
75
|
+
default: false
|
|
76
|
+
});
|
|
77
|
+
if (!confirmed) {
|
|
78
|
+
output.printInfo('Operation cancelled');
|
|
79
|
+
return { success: true };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
83
|
+
const { deleteEntry } = await import('../memory/memory-initializer.js');
|
|
84
|
+
const result = await deleteEntry({ key, namespace });
|
|
85
|
+
if (!result.success) {
|
|
86
|
+
output.printError(result.error || 'Failed to delete');
|
|
87
|
+
return { success: false, exitCode: 1 };
|
|
88
|
+
}
|
|
89
|
+
if (result.deleted) {
|
|
90
|
+
output.printSuccess(`Deleted "${key}" from namespace "${namespace}"`);
|
|
91
|
+
output.printInfo(`Remaining entries: ${result.remainingEntries}`);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
output.printWarning(`Key not found: "${key}" in namespace "${namespace}"`);
|
|
95
|
+
}
|
|
96
|
+
return { success: result.deleted, data: result };
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
output.printError(`Failed to delete: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
100
|
+
return { success: false, exitCode: 1 };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// palace or knowledge — JSONL file delete
|
|
104
|
+
const id = ctx.flags.id || ctx.args[0];
|
|
105
|
+
if (!id) {
|
|
106
|
+
output.printError('Entry ID is required for palace/knowledge delete. Use --id');
|
|
107
|
+
return { success: false, exitCode: 1 };
|
|
108
|
+
}
|
|
109
|
+
if (!/^[a-zA-Z0-9_\-]{1,128}$/.test(id)) {
|
|
110
|
+
output.printError('ID must be 1-128 chars: alphanumeric, underscore, or hyphen only');
|
|
111
|
+
return { success: false, exitCode: 1 };
|
|
112
|
+
}
|
|
113
|
+
const fs = await import('fs');
|
|
114
|
+
const path = await import('path');
|
|
115
|
+
const filePath = source === 'palace'
|
|
116
|
+
? path.join(process.cwd(), '.monomind', 'palace', 'drawers.jsonl')
|
|
117
|
+
: path.join(process.cwd(), '.monomind', 'knowledge', 'chunks.jsonl');
|
|
118
|
+
if (!fs.existsSync(filePath)) {
|
|
119
|
+
output.printError(`File not found: ${filePath}`);
|
|
120
|
+
return { success: false, exitCode: 1 };
|
|
121
|
+
}
|
|
122
|
+
const MAX_MEMORY_FILE_BYTES = 50 * 1024 * 1024; // 50 MB
|
|
123
|
+
if (fs.statSync(filePath).size > MAX_MEMORY_FILE_BYTES) {
|
|
124
|
+
output.printError(`Memory file too large (> 50 MB): ${filePath}`);
|
|
125
|
+
return { success: false, exitCode: 1 };
|
|
126
|
+
}
|
|
127
|
+
let entries;
|
|
128
|
+
try {
|
|
129
|
+
const raw = fs.readFileSync(filePath, 'utf8');
|
|
130
|
+
entries = [];
|
|
131
|
+
for (const line of raw.split('\n').filter(Boolean)) {
|
|
132
|
+
try {
|
|
133
|
+
entries.push(JSON.parse(line));
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
output.printError(`Malformed JSONL entry in ${source} file`);
|
|
137
|
+
return { success: false, exitCode: 1 };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
output.printError(`Failed to read ${source} file: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
|
143
|
+
return { success: false, exitCode: 1 };
|
|
144
|
+
}
|
|
145
|
+
const idx = entries.findIndex(e => e.id === id);
|
|
146
|
+
if (idx === -1) {
|
|
147
|
+
output.printWarning(`Entry not found with id "${id}"`);
|
|
148
|
+
return { success: false, exitCode: 1 };
|
|
149
|
+
}
|
|
150
|
+
if (!force && ctx.interactive) {
|
|
151
|
+
const confirmed = await confirm({
|
|
152
|
+
message: `Delete ${source} entry "${id}"?`,
|
|
153
|
+
default: false
|
|
154
|
+
});
|
|
155
|
+
if (!confirmed) {
|
|
156
|
+
output.printInfo('Operation cancelled');
|
|
157
|
+
return { success: true };
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
entries.splice(idx, 1);
|
|
161
|
+
try {
|
|
162
|
+
const tmpPath = filePath + '.tmp';
|
|
163
|
+
fs.writeFileSync(tmpPath, entries.map(e => JSON.stringify(e)).join('\n') + (entries.length ? '\n' : ''));
|
|
164
|
+
fs.renameSync(tmpPath, filePath);
|
|
165
|
+
output.printSuccess(`Deleted ${source} entry "${id}"`);
|
|
166
|
+
output.printInfo(`Remaining entries: ${entries.length}`);
|
|
167
|
+
return { success: true, data: { id, deleted: true, remainingEntries: entries.length } };
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
output.printError(`Failed to write ${source} file: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
|
171
|
+
return { success: false, exitCode: 1 };
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
// Stats command
|
|
176
|
+
export const statsCommand = {
|
|
177
|
+
name: 'stats',
|
|
178
|
+
description: 'Show memory statistics',
|
|
179
|
+
action: async (ctx) => {
|
|
180
|
+
// Call MCP memory/stats tool for real statistics
|
|
181
|
+
try {
|
|
182
|
+
const statsResult = await callMCPTool('memory_stats', {});
|
|
183
|
+
const stats = {
|
|
184
|
+
backend: statsResult.backend,
|
|
185
|
+
entries: {
|
|
186
|
+
total: statsResult.totalEntries,
|
|
187
|
+
vectors: 0, // Would need vector backend support
|
|
188
|
+
text: statsResult.totalEntries
|
|
189
|
+
},
|
|
190
|
+
storage: {
|
|
191
|
+
total: statsResult.totalSize,
|
|
192
|
+
location: statsResult.location
|
|
193
|
+
},
|
|
194
|
+
version: statsResult.version,
|
|
195
|
+
oldestEntry: statsResult.oldestEntry,
|
|
196
|
+
newestEntry: statsResult.newestEntry
|
|
197
|
+
};
|
|
198
|
+
if (ctx.flags.format === 'json') {
|
|
199
|
+
output.printJson(stats);
|
|
200
|
+
return { success: true, data: stats };
|
|
201
|
+
}
|
|
202
|
+
output.writeln();
|
|
203
|
+
output.writeln(output.bold('Memory Statistics'));
|
|
204
|
+
output.writeln();
|
|
205
|
+
output.writeln(output.bold('Overview'));
|
|
206
|
+
output.printTable({
|
|
207
|
+
columns: [
|
|
208
|
+
{ key: 'metric', header: 'Metric', width: 20 },
|
|
209
|
+
{ key: 'value', header: 'Value', width: 30, align: 'right' }
|
|
210
|
+
],
|
|
211
|
+
data: [
|
|
212
|
+
{ metric: 'Backend', value: stats.backend },
|
|
213
|
+
{ metric: 'Version', value: stats.version },
|
|
214
|
+
{ metric: 'Total Entries', value: stats.entries.total.toLocaleString() },
|
|
215
|
+
{ metric: 'Total Storage', value: stats.storage.total },
|
|
216
|
+
{ metric: 'Location', value: stats.storage.location }
|
|
217
|
+
]
|
|
218
|
+
});
|
|
219
|
+
output.writeln();
|
|
220
|
+
output.writeln(output.bold('Timeline'));
|
|
221
|
+
output.printTable({
|
|
222
|
+
columns: [
|
|
223
|
+
{ key: 'metric', header: 'Metric', width: 20 },
|
|
224
|
+
{ key: 'value', header: 'Value', width: 30, align: 'right' }
|
|
225
|
+
],
|
|
226
|
+
data: [
|
|
227
|
+
{ metric: 'Oldest Entry', value: stats.oldestEntry || 'N/A' },
|
|
228
|
+
{ metric: 'Newest Entry', value: stats.newestEntry || 'N/A' }
|
|
229
|
+
]
|
|
230
|
+
});
|
|
231
|
+
output.writeln();
|
|
232
|
+
output.printInfo('v1 Performance: O(log n) pure-JS HNSW vector search');
|
|
233
|
+
return { success: true, data: stats };
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
output.printError(`Failed to get stats: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
237
|
+
return { success: false, exitCode: 1 };
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
// Configure command
|
|
242
|
+
export const configureCommand = {
|
|
243
|
+
name: 'configure',
|
|
244
|
+
aliases: ['config'],
|
|
245
|
+
description: 'Configure memory backend',
|
|
246
|
+
options: [
|
|
247
|
+
{
|
|
248
|
+
name: 'backend',
|
|
249
|
+
short: 'b',
|
|
250
|
+
description: 'Memory backend',
|
|
251
|
+
type: 'string',
|
|
252
|
+
choices: BACKENDS.map(b => b.value)
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'path',
|
|
256
|
+
description: 'Storage path',
|
|
257
|
+
type: 'string'
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'cache-size',
|
|
261
|
+
description: 'Cache size in MB',
|
|
262
|
+
type: 'number'
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'hnsw-m',
|
|
266
|
+
description: 'HNSW M parameter',
|
|
267
|
+
type: 'number',
|
|
268
|
+
default: 16
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
name: 'hnsw-ef',
|
|
272
|
+
description: 'HNSW ef parameter',
|
|
273
|
+
type: 'number',
|
|
274
|
+
default: 200
|
|
275
|
+
}
|
|
276
|
+
],
|
|
277
|
+
action: async (ctx) => {
|
|
278
|
+
let backend = ctx.flags.backend;
|
|
279
|
+
if (!backend && ctx.interactive) {
|
|
280
|
+
backend = await select({
|
|
281
|
+
message: 'Select memory backend:',
|
|
282
|
+
options: BACKENDS,
|
|
283
|
+
default: 'hybrid'
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
const config = {
|
|
287
|
+
backend: backend || 'hybrid',
|
|
288
|
+
path: ctx.flags.path || './data/memory',
|
|
289
|
+
cacheSize: ctx.flags['cache-size'] || 256,
|
|
290
|
+
hnsw: {
|
|
291
|
+
m: ctx.flags['hnsw-m'] || 16,
|
|
292
|
+
ef: ctx.flags['hnsw-ef'] || 200
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
output.writeln();
|
|
296
|
+
output.printInfo('Memory Configuration');
|
|
297
|
+
output.writeln();
|
|
298
|
+
output.printTable({
|
|
299
|
+
columns: [
|
|
300
|
+
{ key: 'setting', header: 'Setting', width: 20 },
|
|
301
|
+
{ key: 'value', header: 'Value', width: 25 }
|
|
302
|
+
],
|
|
303
|
+
data: [
|
|
304
|
+
{ setting: 'Backend', value: config.backend },
|
|
305
|
+
{ setting: 'Storage Path', value: config.path },
|
|
306
|
+
{ setting: 'Cache Size', value: `${config.cacheSize} MB` },
|
|
307
|
+
{ setting: 'HNSW M', value: config.hnsw.m },
|
|
308
|
+
{ setting: 'HNSW ef', value: config.hnsw.ef }
|
|
309
|
+
]
|
|
310
|
+
});
|
|
311
|
+
output.writeln();
|
|
312
|
+
configManager.set(ctx.cwd, 'memory', config);
|
|
313
|
+
output.printSuccess('Memory configuration updated');
|
|
314
|
+
return { success: true, data: config };
|
|
315
|
+
}
|
|
316
|
+
};
|
|
317
|
+
// Cleanup command
|
|
318
|
+
export const cleanupCommand = {
|
|
319
|
+
name: 'cleanup',
|
|
320
|
+
description: 'Clean up stale and expired memory entries',
|
|
321
|
+
options: [
|
|
322
|
+
{
|
|
323
|
+
name: 'dry-run',
|
|
324
|
+
short: 'd',
|
|
325
|
+
description: 'Show what would be deleted',
|
|
326
|
+
type: 'boolean',
|
|
327
|
+
default: false
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
name: 'older-than',
|
|
331
|
+
short: 'o',
|
|
332
|
+
description: 'Delete entries older than (e.g., "7d", "30d")',
|
|
333
|
+
type: 'string'
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
name: 'expired-only',
|
|
337
|
+
short: 'e',
|
|
338
|
+
description: 'Only delete expired TTL entries',
|
|
339
|
+
type: 'boolean',
|
|
340
|
+
default: false
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
name: 'low-quality',
|
|
344
|
+
short: 'l',
|
|
345
|
+
description: 'Delete low quality patterns (threshold)',
|
|
346
|
+
type: 'number'
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
name: 'namespace',
|
|
350
|
+
short: 'n',
|
|
351
|
+
description: 'Clean specific namespace only',
|
|
352
|
+
type: 'string'
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: 'force',
|
|
356
|
+
short: 'f',
|
|
357
|
+
description: 'Skip confirmation',
|
|
358
|
+
type: 'boolean',
|
|
359
|
+
default: false
|
|
360
|
+
}
|
|
361
|
+
],
|
|
362
|
+
examples: [
|
|
363
|
+
{ command: 'monomind memory cleanup --dry-run', description: 'Preview cleanup' },
|
|
364
|
+
{ command: 'monomind memory cleanup --older-than 30d', description: 'Delete entries older than 30 days' },
|
|
365
|
+
{ command: 'monomind memory cleanup --expired-only', description: 'Clean expired entries' }
|
|
366
|
+
],
|
|
367
|
+
action: async (ctx) => {
|
|
368
|
+
const dryRun = ctx.flags['dry-run'];
|
|
369
|
+
const force = ctx.flags.force;
|
|
370
|
+
if (dryRun) {
|
|
371
|
+
output.writeln(output.warning('DRY RUN - No changes will be made'));
|
|
372
|
+
}
|
|
373
|
+
output.printInfo('Analyzing memory for cleanup...');
|
|
374
|
+
try {
|
|
375
|
+
const result = await callMCPTool('memory_cleanup', {
|
|
376
|
+
dryRun,
|
|
377
|
+
olderThan: ctx.flags['older-than'],
|
|
378
|
+
expiredOnly: ctx.flags['expired-only'],
|
|
379
|
+
lowQualityThreshold: ctx.flags['low-quality'],
|
|
380
|
+
namespace: ctx.flags.namespace,
|
|
381
|
+
});
|
|
382
|
+
if (ctx.flags.format === 'json') {
|
|
383
|
+
output.printJson(result);
|
|
384
|
+
return { success: true, data: result };
|
|
385
|
+
}
|
|
386
|
+
output.writeln();
|
|
387
|
+
output.writeln(output.bold('Cleanup Analysis'));
|
|
388
|
+
output.printTable({
|
|
389
|
+
columns: [
|
|
390
|
+
{ key: 'category', header: 'Category', width: 20 },
|
|
391
|
+
{ key: 'count', header: 'Count', width: 15, align: 'right' }
|
|
392
|
+
],
|
|
393
|
+
data: [
|
|
394
|
+
{ category: 'Expired (TTL)', count: result.candidates.expired },
|
|
395
|
+
{ category: 'Stale (unused)', count: result.candidates.stale },
|
|
396
|
+
{ category: 'Low Quality', count: result.candidates.lowQuality },
|
|
397
|
+
{ category: output.bold('Total'), count: output.bold(String(result.candidates.total)) }
|
|
398
|
+
]
|
|
399
|
+
});
|
|
400
|
+
if (!dryRun && result.candidates.total > 0 && !force) {
|
|
401
|
+
const confirmed = await confirm({
|
|
402
|
+
message: `Delete ${result.candidates.total} entries (${result.freed.formatted})?`,
|
|
403
|
+
default: false
|
|
404
|
+
});
|
|
405
|
+
if (!confirmed) {
|
|
406
|
+
output.printInfo('Cleanup cancelled');
|
|
407
|
+
return { success: true, data: result };
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
if (!dryRun) {
|
|
411
|
+
output.writeln();
|
|
412
|
+
output.printSuccess(`Cleaned ${result.deleted.entries} entries`);
|
|
413
|
+
output.printList([
|
|
414
|
+
`Vectors removed: ${result.deleted.vectors}`,
|
|
415
|
+
`Patterns removed: ${result.deleted.patterns}`,
|
|
416
|
+
`Space freed: ${result.freed.formatted}`,
|
|
417
|
+
`Duration: ${result.duration}ms`
|
|
418
|
+
]);
|
|
419
|
+
}
|
|
420
|
+
return { success: true, data: result };
|
|
421
|
+
}
|
|
422
|
+
catch (error) {
|
|
423
|
+
if (error instanceof MCPClientError) {
|
|
424
|
+
output.printError(`Cleanup error: ${error.message}`);
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
output.printError(`Unexpected error: ${String(error)}`);
|
|
428
|
+
}
|
|
429
|
+
return { success: false, exitCode: 1 };
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
//# sourceMappingURL=memory-admin.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory CRUD Commands
|
|
3
|
+
* store, retrieve, search
|
|
4
|
+
*/
|
|
5
|
+
import type { Command } from '../types.js';
|
|
6
|
+
export declare const storeCommand: Command;
|
|
7
|
+
export declare const retrieveCommand: Command;
|
|
8
|
+
export declare const searchCommand: Command;
|
|
9
|
+
//# sourceMappingURL=memory-crud.d.ts.map
|