@lotargo/memory_plugin 1.5.2 → 1.6.0
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/CHANGELOG.md +108 -0
- package/README.md +383 -352
- package/mcp-server/admin/auth.js +13 -4
- package/mcp-server/admin/snapshot.js +24 -7
- package/mcp-server/cli/direct_commands.js +334 -313
- package/mcp-server/cli/handlers/engine_actions.js +41 -0
- package/mcp-server/cli/handlers/storage_actions.js +58 -0
- package/mcp-server/cli/secret_input.js +44 -0
- package/mcp-server/cli/ui.js +564 -565
- package/mcp-server/cli.js +356 -324
- package/mcp-server/config/auth_store.js +74 -16
- package/mcp-server/config/config_manager.js +4 -0
- package/mcp-server/db/database.js +33 -14
- package/mcp-server/db/sync_queue.js +9 -19
- package/mcp-server/index.js +112 -42
- package/mcp-server/ingest/normalizer.js +116 -29
- package/mcp-server/ingest/pipeline.js +94 -6
- package/mcp-server/logger.js +49 -0
- package/mcp-server/memory.js +6 -9
- package/mcp-server/ml/gpu_monitor.js +169 -166
- package/mcp-server/ml/model_manager.js +17 -4
- package/mcp-server/retrieval/retriever.js +35 -15
- package/mcp-server/security/path_guard.js +67 -0
- package/mcp-server/setup.js +10 -2
- package/mcp-server/storage/blob_store.js +15 -2
- package/mcp-server/tools/core/memory_core.js +393 -0
- package/mcp-server/tools/helpers.js +59 -39
- package/mcp-server/tools/memory_tools.js +123 -506
- package/mcp-server/tools/rag_tools.js +49 -1
- package/opencode-plugin/index.js +95 -387
- package/package.json +7 -1
- package/skills/using-memory/SKILL.md +7 -2
package/mcp-server/cli.js
CHANGED
|
@@ -1,324 +1,356 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import readline from "readline";
|
|
3
|
-
import { getConfig } from "./config/config_manager.js";
|
|
4
|
-
import { selectCategoryMenu, selectSimpleMenu } from "./cli/ui.js";
|
|
5
|
-
import { getQuickStats, invalidateQuickStats } from "./cli/quick_stats.js";
|
|
6
|
-
import { handleDirectCommands } from "./cli/direct_commands.js";
|
|
7
|
-
import { handleEngineAction } from "./cli/handlers/engine_actions.js";
|
|
8
|
-
import { handleStorageAction } from "./cli/handlers/storage_actions.js";
|
|
9
|
-
import { handleCloudAction } from "./cli/handlers/cloud_actions.js";
|
|
10
|
-
import { handlePromptAction } from "./cli/handlers/prompt_actions.js";
|
|
11
|
-
import { handleDiagnosticsAction } from "./cli/handlers/diagnostics_actions.js";
|
|
12
|
-
|
|
13
|
-
export async function runCli() {
|
|
14
|
-
const cliArgs = process.argv.slice(2);
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
label: "
|
|
50
|
-
value: "
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
{
|
|
128
|
-
label: "
|
|
129
|
-
badge: config.
|
|
130
|
-
value: "
|
|
131
|
-
info:
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
label: "
|
|
135
|
-
badge: `${
|
|
136
|
-
value: "
|
|
137
|
-
info: `
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
label: "
|
|
141
|
-
badge:
|
|
142
|
-
value: "
|
|
143
|
-
info: `
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
label: "
|
|
147
|
-
badge: config.
|
|
148
|
-
value: "
|
|
149
|
-
info: config.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
value: "
|
|
194
|
-
info: "
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
label: "[
|
|
198
|
-
value: "
|
|
199
|
-
info: "
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
label: "[
|
|
203
|
-
value: "
|
|
204
|
-
info: "
|
|
205
|
-
},
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
{
|
|
249
|
-
label: "[
|
|
250
|
-
value: "
|
|
251
|
-
info: "
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
label: "[
|
|
255
|
-
value: "
|
|
256
|
-
info: "
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
{
|
|
264
|
-
label: "
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import readline from "readline";
|
|
3
|
+
import { getConfig } from "./config/config_manager.js";
|
|
4
|
+
import { selectCategoryMenu, selectSimpleMenu } from "./cli/ui.js";
|
|
5
|
+
import { getQuickStats, invalidateQuickStats } from "./cli/quick_stats.js";
|
|
6
|
+
import { handleDirectCommands } from "./cli/direct_commands.js";
|
|
7
|
+
import { handleEngineAction } from "./cli/handlers/engine_actions.js";
|
|
8
|
+
import { handleStorageAction } from "./cli/handlers/storage_actions.js";
|
|
9
|
+
import { handleCloudAction } from "./cli/handlers/cloud_actions.js";
|
|
10
|
+
import { handlePromptAction } from "./cli/handlers/prompt_actions.js";
|
|
11
|
+
import { handleDiagnosticsAction } from "./cli/handlers/diagnostics_actions.js";
|
|
12
|
+
|
|
13
|
+
export async function runCli() {
|
|
14
|
+
const cliArgs = process.argv.slice(2);
|
|
15
|
+
|
|
16
|
+
if (cliArgs.includes("--help") || cliArgs.includes("-h") || cliArgs[0] === "help") {
|
|
17
|
+
console.log(`memory-cli — interactive control panel for @lotargo/memory_plugin
|
|
18
|
+
|
|
19
|
+
Usage:
|
|
20
|
+
memory-cli Launch the interactive TUI
|
|
21
|
+
memory-cli login [--from-env|--api-token|--db-url <URL>]
|
|
22
|
+
memory-cli logout [--api-key]
|
|
23
|
+
memory-cli auth-status
|
|
24
|
+
memory-cli link|unlink|relink|identity [--dir <path>] [--remote <url>]
|
|
25
|
+
memory-cli migrate_titles [--key <key>]
|
|
26
|
+
memory-cli enable-prompt | disable-prompt
|
|
27
|
+
|
|
28
|
+
Options:
|
|
29
|
+
-h, --help Show this help text`);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const handled = await handleDirectCommands(cliArgs);
|
|
34
|
+
if (handled) return;
|
|
35
|
+
|
|
36
|
+
readline.emitKeypressEvents(process.stdin);
|
|
37
|
+
|
|
38
|
+
let running = true;
|
|
39
|
+
let selectedCategory = 0;
|
|
40
|
+
|
|
41
|
+
while (running) {
|
|
42
|
+
let config = getConfig();
|
|
43
|
+
const stats = await getQuickStats();
|
|
44
|
+
const semPct = Math.round(config.alpha * 100);
|
|
45
|
+
const lexPct = 100 - semPct;
|
|
46
|
+
|
|
47
|
+
const categories = [
|
|
48
|
+
{
|
|
49
|
+
label: "ENGINE & HYBRID SEARCH SETTINGS",
|
|
50
|
+
value: "engine",
|
|
51
|
+
hint: `${config.fusionAlgorithm.toUpperCase()} | ${semPct}% Sem / ${lexPct}% Lex | ${config.embeddingModel.split("/").pop()}`,
|
|
52
|
+
info: "Configure search algorithm, embedding models, batch sizes, and hardware",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "KNOWLEDGE BASE & STORAGE MANAGEMENT",
|
|
56
|
+
value: "storage",
|
|
57
|
+
hint: `${stats.docCount} Docs | ${stats.chunkCount} Chunks | ${stats.factCount} Facts`,
|
|
58
|
+
info: "Manage facts, RAG documents, snapshots, models, and database",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: "CLOUD SYNCHRONIZATION & TURSO",
|
|
62
|
+
value: "cloud",
|
|
63
|
+
hint: config.mode.toUpperCase(),
|
|
64
|
+
info: "Login, logout, API keys, operational mode, and conflict strategy",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
label: "GLOBAL PROMPT & INTEGRATION MANAGEMENT",
|
|
68
|
+
value: "prompt",
|
|
69
|
+
info: "Enable or disable memory instructions in client configs",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
label: "DIAGNOSTICS & SYSTEM ACTIONS",
|
|
73
|
+
value: "diagnostics",
|
|
74
|
+
info: "Search verification, graph/notebook linking checks, and config reset",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
label: "EXIT",
|
|
78
|
+
value: "exit",
|
|
79
|
+
info: "Save configuration and exit to terminal",
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
const res = await selectCategoryMenu({
|
|
84
|
+
title: "MEMORY PLUGIN RAG ENGINE CONTROL PANEL",
|
|
85
|
+
stats,
|
|
86
|
+
categories,
|
|
87
|
+
initialIndex: selectedCategory,
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
if (res.action === "back" || res.value === "exit") {
|
|
91
|
+
running = false;
|
|
92
|
+
console.clear();
|
|
93
|
+
console.log("Exiting CLI. Configuration saved.");
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
selectedCategory = res.index;
|
|
98
|
+
|
|
99
|
+
let categoryRunning = true;
|
|
100
|
+
let categoryItemIndex = 0;
|
|
101
|
+
|
|
102
|
+
while (categoryRunning) {
|
|
103
|
+
config = getConfig();
|
|
104
|
+
invalidateQuickStats();
|
|
105
|
+
const currentStats = await getQuickStats();
|
|
106
|
+
const catRes = await showCategorySubmenu(res.value, config, currentStats, categoryItemIndex);
|
|
107
|
+
|
|
108
|
+
if (catRes.action === "back") {
|
|
109
|
+
categoryRunning = false;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
categoryItemIndex = catRes.index;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function showCategorySubmenu(category, config, stats, initialIndex = 0) {
|
|
119
|
+
const semPct = Math.round(config.alpha * 100);
|
|
120
|
+
const lexPct = 100 - semPct;
|
|
121
|
+
|
|
122
|
+
let items = [];
|
|
123
|
+
|
|
124
|
+
switch (category) {
|
|
125
|
+
case "engine":
|
|
126
|
+
items = [
|
|
127
|
+
{
|
|
128
|
+
label: "Fusion Algorithm",
|
|
129
|
+
badge: config.fusionAlgorithm.toUpperCase(),
|
|
130
|
+
value: "algo",
|
|
131
|
+
info: "Choose how vector similarity and BM25 text ranks are fused",
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
label: "RSF Alpha Balance",
|
|
135
|
+
badge: `${semPct}% Sem / ${lexPct}% Lex`,
|
|
136
|
+
value: "alpha",
|
|
137
|
+
info: `Current Alpha: ${config.alpha.toFixed(2)}. Adjust ratio of Vector vs BM25 Keyword score`,
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
label: "Embedding Model",
|
|
141
|
+
badge: config.embeddingModel.split("/").pop(),
|
|
142
|
+
value: "embedding",
|
|
143
|
+
info: `Model: ${config.embeddingModel}. ONNX Feature Extraction via @huggingface/transformers`,
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
label: "Vector Dimension",
|
|
147
|
+
badge: config.vectorDimension > 0 ? `${config.vectorDimension}D FIXED` : "AUTO",
|
|
148
|
+
value: "vector_dim",
|
|
149
|
+
info: config.vectorDimension > 0
|
|
150
|
+
? `Override embedding dimension to ${config.vectorDimension} (pads/truncates model output for consistency)`
|
|
151
|
+
: "Auto-detect vector dimension from embedding model output",
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
label: "Reranker Model",
|
|
155
|
+
badge: config.rerankerEnabled ? config.rerankerModel.split("/").pop() : "DISABLED",
|
|
156
|
+
value: "reranker",
|
|
157
|
+
info: config.rerankerEnabled ? `Reranker active: ${config.rerankerModel}` : "Optional Cross-Encoder re-ranking pass",
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
label: "Vector Batch Size",
|
|
161
|
+
badge: `${config.batchSize || 12} Chunks`,
|
|
162
|
+
value: "batch_size",
|
|
163
|
+
info: `Ingestion batch size: ${config.batchSize || 12} micro-chunks per ONNX pass`,
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
label: "GPU Attention Budget",
|
|
167
|
+
badge: `${((config.gpuAttentionBudget || 2000000) / 1000000).toFixed(1)}M Units`,
|
|
168
|
+
value: "gpu_budget",
|
|
169
|
+
info: `Micro-batch tensor budget: ${((config.gpuAttentionBudget || 2000000) / 1000000).toFixed(1)}M quadratic units (controls max peak VRAM usage on GPU)`,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
label: "CPU WASM Threads",
|
|
173
|
+
badge: config.onnxThreads > 0 ? `${config.onnxThreads} Threads` : "AUTO (CPU Cores)",
|
|
174
|
+
value: "onnx_threads",
|
|
175
|
+
info: config.onnxThreads > 0 ? `ONNX execution threads manually set to ${config.onnxThreads}` : "Auto-detect optimal physical CPU threads",
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
label: "Execution Hardware",
|
|
179
|
+
badge: (config.executionDevice || "cpu").toUpperCase() === "WEBGPU" || (config.executionDevice || "cpu").toUpperCase() === "GPU" ? "\x1b[31mGPU (EXPERIMENTAL)\x1b[0m" : "CPU (AVX2)",
|
|
180
|
+
value: "execution_device",
|
|
181
|
+
info: config.executionDevice === "webgpu" || config.executionDevice === "gpu"
|
|
182
|
+
? "⚠️ EXPERIMENTAL: ONNX DirectML GPU execution (high VRAM/padding overhead, CPU AVX2 recommended)"
|
|
183
|
+
: "CPU inference via AVX2 / WASM SIMD (Recommended for stability & speed)",
|
|
184
|
+
},
|
|
185
|
+
];
|
|
186
|
+
break;
|
|
187
|
+
|
|
188
|
+
case "storage":
|
|
189
|
+
items = [
|
|
190
|
+
{
|
|
191
|
+
label: "[NOTEBOOK] Layer 1 Facts",
|
|
192
|
+
badge: `${stats.factCount} Facts Saved`,
|
|
193
|
+
value: "notebook",
|
|
194
|
+
info: "Inspect & delete durable user identity facts (global & project)",
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
label: "[PROJECT IDENTITY] Manage Git Link & Aliases",
|
|
198
|
+
value: "git_identity",
|
|
199
|
+
info: "Link directory to Git project identity, unlink, relink, or view aliases",
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
label: "[FACTS] Migrate Titles to Legacy Facts",
|
|
203
|
+
value: "migrate_titles",
|
|
204
|
+
info: "Mass-stamp auto titles onto facts that lack a **Title** prefix",
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
label: "[RAG DOCS] Layer 2 RAG Base",
|
|
208
|
+
badge: `${stats.docCount} Docs / ${stats.chunkCount} Chunks`,
|
|
209
|
+
value: "rag_docs",
|
|
210
|
+
info: "Inspect ingested Markdown/code docs & delete chunks from SQLite",
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
label: "[REINDEX] Re-Embed Documents with Current Model",
|
|
214
|
+
badge: `${stats.docCount} Docs`,
|
|
215
|
+
value: "reindex_embeddings",
|
|
216
|
+
info: "Recompute all stored vectors with the active embedding model & vector dimension (use after switching model/dimension). Preserves facts, links, FTS & graph edges",
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
label: "[SNAPSHOT EXPORT] Export RAG Base Snapshot",
|
|
220
|
+
value: "export_snapshot",
|
|
221
|
+
info: "Export full RAG database, vectors & blobs into a snapshot file (.json or .json.gz)",
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
label: "[SNAPSHOT IMPORT] Import RAG Base Snapshot",
|
|
225
|
+
value: "import_snapshot",
|
|
226
|
+
info: "Import RAG database, vectors & blobs from a snapshot file (.json or .json.gz)",
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
label: "[MODELS] Manage & Purge ML Model Cache",
|
|
230
|
+
value: "manage_models",
|
|
231
|
+
info: "Inspect cached ONNX models on disk, check status (Ready / Partial / Not Downloaded) & delete models to free disk space",
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
label: "[HARD RESET] Purge RAG Base & Blob Storage",
|
|
235
|
+
value: "hard_reset",
|
|
236
|
+
info: "Permanently delete all documents, sections, vectors, FTS indexes, and blobs",
|
|
237
|
+
},
|
|
238
|
+
];
|
|
239
|
+
break;
|
|
240
|
+
|
|
241
|
+
case "cloud":
|
|
242
|
+
items = [
|
|
243
|
+
{
|
|
244
|
+
label: "[CLOUD] Login to Turso Cloud",
|
|
245
|
+
value: "cloud_login",
|
|
246
|
+
info: "Browser OAuth, account API token, database URL+token, or import from environment (.env) — token/env methods work headless in Docker, Google Jules and VPS",
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
label: "[CLOUD] Logout",
|
|
250
|
+
value: "cloud_logout",
|
|
251
|
+
info: "Sign out, purge encrypted secrets, and revert mode to only-local",
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
label: "[API KEY] Set / Replace Account API Token",
|
|
255
|
+
value: "cloud_api_set",
|
|
256
|
+
info: "Paste a Turso account API token to authorize headless (Docker, Google Jules, VPS) — validated and persisted",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
label: "[API KEY] Remove Account API Token",
|
|
260
|
+
value: "cloud_api_clear",
|
|
261
|
+
info: "Delete the stored API token; the resolved database session is kept",
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
label: "Operational Mode",
|
|
265
|
+
badge: config.mode.toUpperCase(),
|
|
266
|
+
value: "cloud_mode",
|
|
267
|
+
info: "Choose Operational Mode: only-local | only-cloud | hybrid-sync",
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
label: "Conflict Strategy",
|
|
271
|
+
badge: (config.conflictStrategy || "merge").toUpperCase(),
|
|
272
|
+
value: "conflict_strategy",
|
|
273
|
+
info: "How hybrid-sync resolves differing local vs cloud stores: merge | cloud-wins | local-wins",
|
|
274
|
+
},
|
|
275
|
+
];
|
|
276
|
+
break;
|
|
277
|
+
|
|
278
|
+
case "prompt":
|
|
279
|
+
items = [
|
|
280
|
+
{
|
|
281
|
+
label: "[PROMPT ENABLE] Enable Global Prompt (Antigravity / Codex / Claude)",
|
|
282
|
+
value: "enable_prompt",
|
|
283
|
+
info: "Inject memory instructions into ~/.gemini/config/AGENTS.md, ~/.codex/AGENTS.md, ~/.claude/CLAUDE.md",
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
label: "[PROMPT DISABLE] Disable Global Prompt",
|
|
287
|
+
value: "disable_prompt",
|
|
288
|
+
info: "Remove memory instructions from global AGENTS.md / CLAUDE.md files",
|
|
289
|
+
},
|
|
290
|
+
];
|
|
291
|
+
break;
|
|
292
|
+
|
|
293
|
+
case "diagnostics":
|
|
294
|
+
items = [
|
|
295
|
+
{
|
|
296
|
+
label: "[SEARCH] Run Search Verification Query",
|
|
297
|
+
value: "test",
|
|
298
|
+
info: "Execute hybrid search query and display result hit scores",
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
label: "[GRAPH] Graph & Notebook Linking Verification",
|
|
302
|
+
value: "graph_test",
|
|
303
|
+
info: "Ingest sample doc + save Notebook fact linked to line range + verify recall & raw document reader",
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
label: "[RESET] Reset Config to Factory Defaults",
|
|
307
|
+
value: "reset",
|
|
308
|
+
info: "Reset RSF alpha to 50/50 and restore factory default config",
|
|
309
|
+
},
|
|
310
|
+
];
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
items.push({ label: "< Back to Main Menu", value: "back" });
|
|
315
|
+
|
|
316
|
+
const titles = {
|
|
317
|
+
engine: "ENGINE & HYBRID SEARCH SETTINGS",
|
|
318
|
+
storage: "KNOWLEDGE BASE & STORAGE MANAGEMENT",
|
|
319
|
+
cloud: "CLOUD SYNCHRONIZATION & TURSO",
|
|
320
|
+
prompt: "GLOBAL PROMPT & INTEGRATION MANAGEMENT",
|
|
321
|
+
diagnostics: "DIAGNOSTICS & SYSTEM ACTIONS",
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const subRes = await selectSimpleMenu({
|
|
325
|
+
title: titles[category],
|
|
326
|
+
subtitle: "↑ / ↓ Navigate • ENTER Select • BACKSPACE Back",
|
|
327
|
+
items,
|
|
328
|
+
initialIndex,
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
if (subRes.action === "back" || subRes.value === "back") {
|
|
332
|
+
return { action: "back" };
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
await handleSubmenuItem(subRes.value, config, stats);
|
|
336
|
+
return { action: "select", index: subRes.index };
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async function handleSubmenuItem(value, config, stats) {
|
|
340
|
+
await handleEngineAction(value, config);
|
|
341
|
+
await handleStorageAction(value, config, stats);
|
|
342
|
+
await handleCloudAction(value, config);
|
|
343
|
+
await handlePromptAction(value);
|
|
344
|
+
await handleDiagnosticsAction(value, config, stats);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (process.argv[1] && process.argv[1].includes("cli.js")) {
|
|
348
|
+
if (typeof global.gc !== "function") {
|
|
349
|
+
const { spawn } = await import("node:child_process");
|
|
350
|
+
const args = ["--expose-gc", ...process.argv.slice(1)];
|
|
351
|
+
const child = spawn(process.execPath, args, { stdio: "inherit" });
|
|
352
|
+
child.on("exit", (code) => process.exit(code));
|
|
353
|
+
} else {
|
|
354
|
+
runCli().catch((err) => console.error("CLI error:", err));
|
|
355
|
+
}
|
|
356
|
+
}
|