@membank/cli 0.8.0 → 0.9.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/dist/index.mjs +55 -4
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -103,7 +103,6 @@ function exportCommand(db, formatter, opts) {
|
|
|
103
103
|
sourceHarness: row.source,
|
|
104
104
|
accessCount: row.access_count,
|
|
105
105
|
pinned: row.pinned !== 0,
|
|
106
|
-
needsReview: row.needs_review !== 0,
|
|
107
106
|
createdAt: row.created_at,
|
|
108
107
|
updatedAt: row.updated_at,
|
|
109
108
|
embedding: row.embedding !== null ? Buffer.from(row.embedding).toString("base64") : null
|
|
@@ -147,12 +146,12 @@ async function importCommand(filePath, db, formatter, prompt) {
|
|
|
147
146
|
if (formatter.isJson) process.stdout.write(`${JSON.stringify({ found: count })}\n`);
|
|
148
147
|
else process.stdout.write(`Found ${count} memories to import.\n`);
|
|
149
148
|
if (!await prompt.confirm("Import?")) return;
|
|
150
|
-
const insertMemory = db.db.prepare(`INSERT OR REPLACE INTO memories (id, content, type, tags, source, access_count, pinned,
|
|
151
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?,
|
|
149
|
+
const insertMemory = db.db.prepare(`INSERT OR REPLACE INTO memories (id, content, type, tags, source, access_count, pinned, created_at, updated_at)
|
|
150
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`);
|
|
152
151
|
const insertEmbedding = db.db.prepare(`INSERT OR REPLACE INTO embeddings (rowid, embedding) SELECT m.rowid, ? FROM memories m WHERE m.id = ?`);
|
|
153
152
|
db.db.transaction(() => {
|
|
154
153
|
for (const rec of parseResult.data.memories) {
|
|
155
|
-
insertMemory.run(rec.id, rec.content, rec.type, JSON.stringify(rec.tags ?? []), rec.sourceHarness ?? null, rec.accessCount ?? 0, rec.pinned ? 1 : 0, rec.
|
|
154
|
+
insertMemory.run(rec.id, rec.content, rec.type, JSON.stringify(rec.tags ?? []), rec.sourceHarness ?? null, rec.accessCount ?? 0, rec.pinned ? 1 : 0, rec.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(), rec.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString());
|
|
156
155
|
if (rec.embedding !== null && rec.embedding !== void 0) {
|
|
157
156
|
const buf = Buffer.from(rec.embedding, "base64");
|
|
158
157
|
insertEmbedding.run(buf, rec.id);
|
|
@@ -313,6 +312,24 @@ async function queryCommand(queryText, options, formatter) {
|
|
|
313
312
|
}
|
|
314
313
|
}
|
|
315
314
|
//#endregion
|
|
315
|
+
//#region src/commands/review.ts
|
|
316
|
+
async function reviewCommand(opts, formatter) {
|
|
317
|
+
const db = DatabaseManager.open();
|
|
318
|
+
try {
|
|
319
|
+
const repo = new MemoryRepository(db, new EmbeddingService(), new ProjectRepository(db));
|
|
320
|
+
if (opts.resolve !== void 0) {
|
|
321
|
+
repo.resolveReviewEvents(opts.resolve);
|
|
322
|
+
if (!formatter.isJson) process.stdout.write(`Resolved review events for memory ${opts.resolve}\n`);
|
|
323
|
+
else process.stdout.write(`${JSON.stringify({ resolved: opts.resolve })}\n`);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const flagged = repo.listFlagged();
|
|
327
|
+
formatter.outputReview(flagged);
|
|
328
|
+
} finally {
|
|
329
|
+
db.close();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
//#endregion
|
|
316
333
|
//#region src/commands/stats.ts
|
|
317
334
|
async function statsCommand(formatter) {
|
|
318
335
|
const db = DatabaseManager.open();
|
|
@@ -463,6 +480,30 @@ var Formatter = class Formatter {
|
|
|
463
480
|
}
|
|
464
481
|
process.stdout.write(`\n${table.toString()}\n\n`);
|
|
465
482
|
}
|
|
483
|
+
outputReview(memories) {
|
|
484
|
+
if (this.#isJson) {
|
|
485
|
+
process.stdout.write(`${JSON.stringify(memories)}\n`);
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
if (memories.length === 0) {
|
|
489
|
+
process.stdout.write(`${chalk.dim("No memories flagged for review.")}\n`);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
for (const m of memories) {
|
|
493
|
+
process.stdout.write("\n");
|
|
494
|
+
process.stdout.write(` ${colorType(m.type)} ${chalk.dim(m.id)}\n`);
|
|
495
|
+
process.stdout.write(` ${truncate(m.content, 80)}\n`);
|
|
496
|
+
for (const event of m.reviewEvents) this.#outputReviewEvent(event);
|
|
497
|
+
}
|
|
498
|
+
process.stdout.write("\n");
|
|
499
|
+
}
|
|
500
|
+
#outputReviewEvent(event) {
|
|
501
|
+
const pct = `${Math.round(event.similarity * 100)}%`;
|
|
502
|
+
const conflictRef = event.conflictingMemoryId ? chalk.dim(event.conflictingMemoryId) : chalk.dim("(deleted)");
|
|
503
|
+
const ts = new Date(event.createdAt).toLocaleString();
|
|
504
|
+
process.stdout.write(` ${chalk.yellow("⚠")} ${pct} similarity conflict: ${conflictRef} ${chalk.dim(ts)}\n`);
|
|
505
|
+
if (event.conflictContentSnapshot) process.stdout.write(` ${chalk.dim("snapshot:")} ${truncate(event.conflictContentSnapshot, 60)}\n`);
|
|
506
|
+
}
|
|
466
507
|
error(msg) {
|
|
467
508
|
if (this.#isJson) process.stderr.write(`${JSON.stringify({ error: msg })}\n`);
|
|
468
509
|
else process.stderr.write(`${chalk.red("Error:")} ${msg}\n`);
|
|
@@ -1489,6 +1530,16 @@ program.command("setup").description("detect installed harnesses and write MCP c
|
|
|
1489
1530
|
process.exit(2);
|
|
1490
1531
|
}
|
|
1491
1532
|
});
|
|
1533
|
+
program.command("review").description("list memories flagged for review, or resolve review events").option("--resolve <id>", "resolve all open review events for the given memory id").action(async (cmdOptions) => {
|
|
1534
|
+
const globalOpts = program.opts();
|
|
1535
|
+
const formatter = Formatter.create(globalOpts.json === true);
|
|
1536
|
+
try {
|
|
1537
|
+
await reviewCommand(cmdOptions, formatter);
|
|
1538
|
+
} catch (err) {
|
|
1539
|
+
formatter.error(err instanceof Error ? err.message : String(err));
|
|
1540
|
+
process.exit(2);
|
|
1541
|
+
}
|
|
1542
|
+
});
|
|
1492
1543
|
program.command("migrate <mode> [name]").description("list or run a named data migration (modes: list, run)").action(async (mode, name) => {
|
|
1493
1544
|
const modeResult = MigrateModeSchema.safeParse(mode);
|
|
1494
1545
|
if (!modeResult.success) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@membank/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"commander": "^14.0.3",
|
|
22
22
|
"ora": "^9.4.0",
|
|
23
23
|
"zod": "^4.4.3",
|
|
24
|
-
"@membank/
|
|
25
|
-
"@membank/
|
|
26
|
-
"@membank/
|
|
24
|
+
"@membank/dashboard": "0.5.0",
|
|
25
|
+
"@membank/core": "0.8.0",
|
|
26
|
+
"@membank/mcp": "0.10.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^25.6.0",
|