@memfork/cli 0.1.29 → 0.1.31
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/ui-server.js +45 -23
- package/package.json +1 -1
- package/ui/assets/{index-BfVUDXw0.js → index-C2a3M4qs.js} +16 -16
- package/ui/assets/{index-BfVUDXw0.js.map → index-C2a3M4qs.js.map} +1 -1
- package/ui/assets/index-DxId_009.css +1 -0
- package/ui/index.html +2 -2
- package/ui/assets/index-paYDwRGH.css +0 -1
|
@@ -15,6 +15,8 @@ import http from "node:http";
|
|
|
15
15
|
import fs from "node:fs";
|
|
16
16
|
import path from "node:path";
|
|
17
17
|
import { readProjectConfig, readCredentials, MEMWAL_CONSTANTS } from "../config.js";
|
|
18
|
+
import { MemWal } from "@mysten-incubation/memwal";
|
|
19
|
+
import { branchNamespace } from "@memfork/core";
|
|
18
20
|
const MIME = {
|
|
19
21
|
".html": "text/html; charset=utf-8",
|
|
20
22
|
".js": "application/javascript",
|
|
@@ -55,21 +57,44 @@ async function handleApiConfig(res) {
|
|
|
55
57
|
hasMemwal: !!(stored?.memwalKey && stored?.memwalAccountId),
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Recall entries from a MemWal namespace using the SDK (signed requests).
|
|
62
|
+
*
|
|
63
|
+
* The MemWal HTTP API requires a cryptographically signed request; a plain
|
|
64
|
+
* Bearer token is rejected. We use the SDK directly so auth is handled
|
|
65
|
+
* correctly. We issue three broad queries that cover all CommitPayload
|
|
66
|
+
* blobs and merge/deduplicate by blob_id.
|
|
67
|
+
*/
|
|
68
|
+
async function memwalRecall(relayer, key, accountId, namespace, limit = 200) {
|
|
69
|
+
const mw = MemWal.create({
|
|
70
|
+
key,
|
|
71
|
+
accountId,
|
|
72
|
+
serverUrl: relayer,
|
|
73
|
+
namespace,
|
|
68
74
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
// Three broad queries that collectively cover all CommitPayload blobs.
|
|
76
|
+
const queries = [
|
|
77
|
+
"commit facts delta project memory",
|
|
78
|
+
"branch convention decision preference setup",
|
|
79
|
+
"error handling architecture pattern configuration",
|
|
80
|
+
];
|
|
81
|
+
const perQuery = Math.ceil(limit / queries.length);
|
|
82
|
+
const seen = new Set();
|
|
83
|
+
const merged = [];
|
|
84
|
+
await Promise.allSettled(queries.map(async (query) => {
|
|
85
|
+
try {
|
|
86
|
+
const result = await mw.recall({ query, limit: perQuery });
|
|
87
|
+
for (const r of result.results) {
|
|
88
|
+
const blobId = String(r.blob_id ?? "");
|
|
89
|
+
if (blobId && !seen.has(blobId)) {
|
|
90
|
+
seen.add(blobId);
|
|
91
|
+
merged.push({ blob_id: blobId, text: String(r.text ?? ""), distance: r.distance });
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch { /* one query failing shouldn't break the others */ }
|
|
96
|
+
}));
|
|
97
|
+
return merged;
|
|
73
98
|
}
|
|
74
99
|
async function handleApiFacts(res, url) {
|
|
75
100
|
const branch = url.searchParams.get("branch") ?? "main";
|
|
@@ -83,10 +108,9 @@ async function handleApiFacts(res, url) {
|
|
|
83
108
|
return;
|
|
84
109
|
}
|
|
85
110
|
const relayer = stored.memwalRelayer ?? MEMWAL_CONSTANTS[network].relayer;
|
|
86
|
-
const
|
|
87
|
-
const namespace = `memforks/${treeHex}/${branch}`;
|
|
111
|
+
const namespace = branchNamespace(treeId, branch);
|
|
88
112
|
try {
|
|
89
|
-
const facts = await
|
|
113
|
+
const facts = await memwalRecall(relayer, stored.memwalKey, stored.memwalAccountId, namespace);
|
|
90
114
|
json(res, { facts });
|
|
91
115
|
}
|
|
92
116
|
catch (e) {
|
|
@@ -116,14 +140,12 @@ async function handleApiHistory(res, url) {
|
|
|
116
140
|
return;
|
|
117
141
|
}
|
|
118
142
|
const relayer = stored.memwalRelayer ?? MEMWAL_CONSTANTS[network].relayer;
|
|
119
|
-
const
|
|
120
|
-
const namespace = `memforks/${treeHexH}/${branch}`;
|
|
143
|
+
const namespace = branchNamespace(treeId, branch);
|
|
121
144
|
try {
|
|
122
|
-
const results = await
|
|
145
|
+
const results = await memwalRecall(relayer, stored.memwalKey, stored.memwalAccountId, namespace, limit);
|
|
123
146
|
const commits = results.flatMap((entry) => {
|
|
124
|
-
const
|
|
125
|
-
const
|
|
126
|
-
const text = String(e["text"] ?? "");
|
|
147
|
+
const blobId = entry.blob_id;
|
|
148
|
+
const text = entry.text;
|
|
127
149
|
// Try to parse the stored text as a CommitPayload JSON.
|
|
128
150
|
let payload = null;
|
|
129
151
|
try {
|