@memfork/cli 0.1.28 → 0.1.29
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/commands/ops.js
CHANGED
|
@@ -67,6 +67,27 @@ export async function cmdLog(opts) {
|
|
|
67
67
|
console.log("");
|
|
68
68
|
}
|
|
69
69
|
// ─── recall ───────────────────────────────────────────────────────────────────
|
|
70
|
+
/**
|
|
71
|
+
* MemWal stores the full CommitPayload JSON as the blob text.
|
|
72
|
+
* Extract human-readable facts from `delta.facts[]` when present,
|
|
73
|
+
* falling through to `message`, and finally the raw text as a last resort.
|
|
74
|
+
*/
|
|
75
|
+
function unwrapRecallText(text) {
|
|
76
|
+
try {
|
|
77
|
+
const p = JSON.parse(text);
|
|
78
|
+
if (p["type"] === "commit") {
|
|
79
|
+
const delta = p["delta"];
|
|
80
|
+
const facts = delta?.["facts"];
|
|
81
|
+
if (facts?.length)
|
|
82
|
+
return facts.join(" · ");
|
|
83
|
+
const msg = p["message"];
|
|
84
|
+
if (msg)
|
|
85
|
+
return msg;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
catch { /* not JSON — fall through */ }
|
|
89
|
+
return text;
|
|
90
|
+
}
|
|
70
91
|
export async function cmdRecall(query, opts) {
|
|
71
92
|
const { client, cfg } = await getClient();
|
|
72
93
|
const branch = resolveBranch({ explicit: opts.branch, configDefault: cfg.defaultBranch });
|
|
@@ -85,7 +106,8 @@ export async function cmdRecall(query, opts) {
|
|
|
85
106
|
for (const r of results) {
|
|
86
107
|
const bar = r.distance < 0.2 ? chalk.green("███") :
|
|
87
108
|
r.distance < 0.35 ? chalk.yellow("██░") : chalk.dim("█░░");
|
|
88
|
-
|
|
109
|
+
const display = unwrapRecallText(r.text);
|
|
110
|
+
console.log(` ${bar} ${chalk.dim(r.distance.toFixed(3))} ${display}`);
|
|
89
111
|
}
|
|
90
112
|
}
|
|
91
113
|
console.log("");
|