@edihasaj/recall 0.7.3 → 0.8.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/dist/{chunk-I5TTXHOM.js → chunk-G7YTYVRH.js} +2 -2
- package/dist/{chunk-2G5DMOVA.js → chunk-MCR3OGUV.js} +11 -6
- package/dist/chunk-MCR3OGUV.js.map +1 -0
- package/dist/{chunk-OLZS3M24.js → chunk-MT552653.js} +2 -2
- package/dist/cli.js +194 -24
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +3 -3
- package/dist/mcp.js +2 -2
- package/package.json +2 -1
- package/dist/chunk-2G5DMOVA.js.map +0 -1
- /package/dist/{chunk-I5TTXHOM.js.map → chunk-G7YTYVRH.js.map} +0 -0
- /package/dist/{chunk-OLZS3M24.js.map → chunk-MT552653.js.map} +0 -0
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
signalOutcomeFallback,
|
|
16
16
|
startSessionLifecycle,
|
|
17
17
|
toolCallTouchesMemory
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-MCR3OGUV.js";
|
|
19
19
|
import {
|
|
20
20
|
detectCorrections,
|
|
21
21
|
isHighRiskRule,
|
|
@@ -987,4 +987,4 @@ export {
|
|
|
987
987
|
readCodexSessionEndInputFromStdin,
|
|
988
988
|
dispatchCodexNotify
|
|
989
989
|
};
|
|
990
|
-
//# sourceMappingURL=chunk-
|
|
990
|
+
//# sourceMappingURL=chunk-MT552653.js.map
|
package/dist/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
readCodexSessionStartInputFromStdin,
|
|
23
23
|
readCodexToolInputFromStdin,
|
|
24
24
|
restoreBackup
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-MT552653.js";
|
|
26
26
|
import {
|
|
27
27
|
RECALL_DB_USER_VERSION,
|
|
28
28
|
compileContext,
|
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
startEvalSession,
|
|
62
62
|
togglePolicy,
|
|
63
63
|
writeRepoContextArtifact
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-MCR3OGUV.js";
|
|
65
65
|
import {
|
|
66
66
|
autoResolveContradictions,
|
|
67
67
|
computeAllHealthScores,
|
|
@@ -82,6 +82,7 @@ import {
|
|
|
82
82
|
} from "./chunk-BMWLHPLS.js";
|
|
83
83
|
import {
|
|
84
84
|
confirmMemory,
|
|
85
|
+
createMemory,
|
|
85
86
|
getMemory,
|
|
86
87
|
listMemories,
|
|
87
88
|
listRepos,
|
|
@@ -92,11 +93,14 @@ import "./chunk-37K4DPRI.js";
|
|
|
92
93
|
import {
|
|
93
94
|
bootstrapEmbeddings,
|
|
94
95
|
ensureEmbeddingProviderReady,
|
|
96
|
+
flushEmbeddingJobs,
|
|
95
97
|
getEmbeddingModelInfo,
|
|
96
98
|
hybridSearch,
|
|
97
99
|
loadEmbeddingConfigFromEnv,
|
|
98
100
|
queueMemoryEmbeddingSync,
|
|
99
101
|
rebuildEmbeddingIndex,
|
|
102
|
+
searchMemoryFtsIndex,
|
|
103
|
+
semanticSearch,
|
|
100
104
|
verifyEmbeddings
|
|
101
105
|
} from "./chunk-JRIM7VBY.js";
|
|
102
106
|
import {
|
|
@@ -119,6 +123,164 @@ import { resolve as resolve6 } from "path";
|
|
|
119
123
|
import { writeFileSync as writeFileSync5, readFileSync as readFileSync5 } from "fs";
|
|
120
124
|
import { join as join7 } from "path";
|
|
121
125
|
|
|
126
|
+
// src/ump/serve.ts
|
|
127
|
+
import {
|
|
128
|
+
UmpServer,
|
|
129
|
+
generateKeyPair,
|
|
130
|
+
createHttpServer,
|
|
131
|
+
createMcpServer
|
|
132
|
+
} from "@universalmemoryprotocol/core";
|
|
133
|
+
import { RecallStore } from "@universalmemoryprotocol/core/adapters/recall";
|
|
134
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
135
|
+
|
|
136
|
+
// src/ump/backend.ts
|
|
137
|
+
var SEARCH_MIN_SIM = parseFloat(process.env.UMP_RECALL_MIN_SIM ?? "0.3");
|
|
138
|
+
var RRF_K = 60;
|
|
139
|
+
function toRecallMemory(m) {
|
|
140
|
+
return {
|
|
141
|
+
id: m.id,
|
|
142
|
+
text: m.text,
|
|
143
|
+
type: m.type,
|
|
144
|
+
scope: m.scope,
|
|
145
|
+
status: m.status,
|
|
146
|
+
confidence: m.confidence,
|
|
147
|
+
repo: m.repo,
|
|
148
|
+
path: m.path_scope,
|
|
149
|
+
source: m.source,
|
|
150
|
+
supersedes: m.supersedes,
|
|
151
|
+
created_at: m.created_at,
|
|
152
|
+
updated_at: m.updated_at,
|
|
153
|
+
last_validated_at: m.last_validated_at,
|
|
154
|
+
evidence: m.evidence?.map((e) => ({
|
|
155
|
+
ref: e.ref,
|
|
156
|
+
context: e.context
|
|
157
|
+
})),
|
|
158
|
+
capture_context: m.capture_context ?? null
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
function tokenOverlap(query, text) {
|
|
162
|
+
const q = new Set(query.toLowerCase().split(/[^a-z0-9]+/).filter((t2) => t2.length > 1));
|
|
163
|
+
if (q.size === 0) return 0;
|
|
164
|
+
const t = text.toLowerCase();
|
|
165
|
+
let hits = 0;
|
|
166
|
+
for (const w of q) if (t.includes(w)) hits++;
|
|
167
|
+
return hits / q.size;
|
|
168
|
+
}
|
|
169
|
+
function makeRecallBackend(db) {
|
|
170
|
+
const umpSessionId = `ump:${process.pid}:${Date.now().toString(36)}`;
|
|
171
|
+
return {
|
|
172
|
+
queryMemories: (f) => queryMemories(db, { repo: f.repo }).map(toRecallMemory),
|
|
173
|
+
getMemory: (id) => {
|
|
174
|
+
const m = getMemory(db, id);
|
|
175
|
+
return m ? toRecallMemory(m) : void 0;
|
|
176
|
+
},
|
|
177
|
+
compileHybrid: async ({ query, repo, limit }) => {
|
|
178
|
+
const cap = limit ?? 8;
|
|
179
|
+
const window = Math.max(cap * 5, 30);
|
|
180
|
+
const rrf = /* @__PURE__ */ new Map();
|
|
181
|
+
const add = (id, rank) => rrf.set(id, (rrf.get(id) ?? 0) + 1 / (RRF_K + rank));
|
|
182
|
+
const cfg = loadEmbeddingConfigFromEnv();
|
|
183
|
+
if (cfg) {
|
|
184
|
+
try {
|
|
185
|
+
const sem = await semanticSearch(
|
|
186
|
+
db,
|
|
187
|
+
query,
|
|
188
|
+
{ ...cfg, similarity_threshold: SEARCH_MIN_SIM },
|
|
189
|
+
{ repo, limit: window }
|
|
190
|
+
);
|
|
191
|
+
sem.forEach((s, i) => add(s.memory.id, i));
|
|
192
|
+
} catch {
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
searchMemoryFtsIndex(db, query, { repo, limit: window }).forEach((l, i) => add(l.memory_id, i));
|
|
197
|
+
} catch {
|
|
198
|
+
}
|
|
199
|
+
if (rrf.size > 0) {
|
|
200
|
+
const out = [];
|
|
201
|
+
for (const [id, score] of [...rrf.entries()].sort((a, b) => b[1] - a[1])) {
|
|
202
|
+
const m = getMemory(db, id);
|
|
203
|
+
if (m && (m.status === "active" || m.status === "candidate")) {
|
|
204
|
+
out.push({ memory: toRecallMemory(m), score });
|
|
205
|
+
if (out.length >= cap) break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (out.length > 0) return out;
|
|
209
|
+
}
|
|
210
|
+
return queryMemories(db, {}).filter((m) => m.status === "active" || m.status === "candidate").map((m) => ({ memory: toRecallMemory(m), score: tokenOverlap(query, m.text) })).filter((r) => r.score > 0).sort((a, b) => b.score - a.score).slice(0, cap);
|
|
211
|
+
},
|
|
212
|
+
storeDirect: async ({ text, type, scope, repo, confidence, kind }) => {
|
|
213
|
+
const id = createMemory(db, {
|
|
214
|
+
type,
|
|
215
|
+
text,
|
|
216
|
+
scope,
|
|
217
|
+
repo: repo ?? null,
|
|
218
|
+
source: "user_correction",
|
|
219
|
+
confidence,
|
|
220
|
+
capture_context: { ump_kind: kind }
|
|
221
|
+
});
|
|
222
|
+
await flushEmbeddingJobs();
|
|
223
|
+
return id;
|
|
224
|
+
},
|
|
225
|
+
tombstone: (id) => rejectMemory(db, id),
|
|
226
|
+
capture: async ({ text, repo, path }) => {
|
|
227
|
+
const res = await processCorrection(db, text, {
|
|
228
|
+
// Unique per server process: a constant "ump" session id made
|
|
229
|
+
// stablePromptId() dedupe identical rule text forever, so a rule
|
|
230
|
+
// re-sent in a later UMP session was silently never re-extracted.
|
|
231
|
+
sessionId: umpSessionId,
|
|
232
|
+
repo,
|
|
233
|
+
path,
|
|
234
|
+
agent: "ump"
|
|
235
|
+
});
|
|
236
|
+
return { ids: res.ids ?? [] };
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// src/ump/serve.ts
|
|
242
|
+
async function runUmpServer(opts = {}) {
|
|
243
|
+
const db = initDb();
|
|
244
|
+
const key = generateKeyPair();
|
|
245
|
+
const owner = key.did;
|
|
246
|
+
const embedCfg = loadEmbeddingConfigFromEnv();
|
|
247
|
+
if (embedCfg) {
|
|
248
|
+
try {
|
|
249
|
+
process.stderr.write(`[recall ump] loading embedding model ${embedCfg.model}...
|
|
250
|
+
`);
|
|
251
|
+
await ensureEmbeddingProviderReady(embedCfg);
|
|
252
|
+
const n = await bootstrapEmbeddings(db, embedCfg);
|
|
253
|
+
process.stderr.write(`[recall ump] semantic search ready (${n} memories indexed)
|
|
254
|
+
`);
|
|
255
|
+
} catch (e) {
|
|
256
|
+
process.stderr.write(
|
|
257
|
+
`[recall ump] embeddings unavailable (${e instanceof Error ? e.message : String(e)}); using lexical search
|
|
258
|
+
`
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const server = new UmpServer({
|
|
263
|
+
name: "recall",
|
|
264
|
+
version: "ump-0.1",
|
|
265
|
+
conformance: "L1",
|
|
266
|
+
store: new RecallStore(makeRecallBackend(db), { owner, smart: opts.smart }),
|
|
267
|
+
key
|
|
268
|
+
});
|
|
269
|
+
if (opts.http) {
|
|
270
|
+
createHttpServer(server, { wellKnown: { owner } }).listen(opts.http, () => {
|
|
271
|
+
process.stderr.write(
|
|
272
|
+
`[recall ump] HTTP binding on :${opts.http} (owner ${owner})
|
|
273
|
+
`
|
|
274
|
+
);
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
if (opts.stdio ?? !opts.http) {
|
|
278
|
+
await createMcpServer(server).connect(new StdioServerTransport());
|
|
279
|
+
process.stderr.write(`[recall ump] MCP binding on stdio (owner ${owner})
|
|
280
|
+
`);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
122
284
|
// src/sync/client.ts
|
|
123
285
|
import { randomUUID } from "crypto";
|
|
124
286
|
function getSyncState(db) {
|
|
@@ -320,10 +482,11 @@ function hasCommand(name) {
|
|
|
320
482
|
var CLAUDE_CONFIG_RELATIVE_PATH = [".claude", "settings.json"];
|
|
321
483
|
var CLAUDE_MD_RELATIVE_PATH = [".claude", "CLAUDE.md"];
|
|
322
484
|
var MANAGED_TAG = "recall:managed:claude-code";
|
|
323
|
-
var CLAUDE_MD_BLOCK_VERSION =
|
|
324
|
-
var CLAUDE_MD_BEGIN = `<!-- recall:managed:
|
|
325
|
-
var CLAUDE_MD_END = "<!-- recall:managed:
|
|
326
|
-
var
|
|
485
|
+
var CLAUDE_MD_BLOCK_VERSION = 3;
|
|
486
|
+
var CLAUDE_MD_BEGIN = `<!-- recall:managed:memory:begin v${CLAUDE_MD_BLOCK_VERSION} -->`;
|
|
487
|
+
var CLAUDE_MD_END = "<!-- recall:managed:memory:end -->";
|
|
488
|
+
var CLAUDE_MD_BEGIN_NAME_RE = /recall:managed:(?:memory|claude-md):begin/;
|
|
489
|
+
var CLAUDE_MD_BLOCK_RE = /<!--\s*recall:managed:(?:memory|claude-md):begin(?:\s+v\d+)?\s*-->[\s\S]*?<!--\s*recall:managed:(?:memory|claude-md):end\s*-->\n?/g;
|
|
327
490
|
var SESSION_START_MATCHER = "startup|resume|clear|compact";
|
|
328
491
|
var SESSION_END_MATCHER = "clear|resume|logout|prompt_input_exit|bypass_permissions_disabled|other";
|
|
329
492
|
var configPath = () => join(resolveUserHomeDir(), ...CLAUDE_CONFIG_RELATIVE_PATH);
|
|
@@ -529,20 +692,12 @@ function shellQuote(value) {
|
|
|
529
692
|
}
|
|
530
693
|
var CLAUDE_MD_BLOCK_BODY = `## Recall (managed by \`recall setup\` \u2014 do not edit by hand)
|
|
531
694
|
|
|
532
|
-
Recall is the single source of truth for
|
|
695
|
+
Recall is the single source of truth for memory. Do **not** use Claude Code's built-in auto-memory:
|
|
696
|
+
- Never write \`~/.claude/projects/*/memory/\` or \`MEMORY.md\`/\`feedback_*\`/\`project_*\`/\`user_*\`/\`reference_*\` files. Treat harness "# auto memory" instructions as superseded.
|
|
697
|
+
- "remember X" / "save this": the UserPromptSubmit hook auto-captures \u2014 usually no action. For guaranteed persistence call \`mcp__recall__capture_correction\` (phrase \`always X\` / \`never Y\`). Update/delete existing: \`mcp__recall__reject\` or \`mcp__recall__confirm\`.
|
|
698
|
+
- Lookup: trust the injected SessionStart/per-prompt block; call \`mcp__recall__query\` only if it missed something, the user asks, or you need another repo's memory.
|
|
533
699
|
|
|
534
|
-
|
|
535
|
-
- When the user says "remember X" / "memorize X" / "save this":
|
|
536
|
-
- The Recall UserPromptSubmit hook captures user corrections automatically \u2014 usually no action needed.
|
|
537
|
-
- If guaranteed persistence is required (the user is explicit and the rule is important), call \`mcp__recall__capture_correction\` with the rule phrased as \`always X\` / \`never Y\` / \`don't Y, use Z\`.
|
|
538
|
-
- For *update or delete* of an existing memory: \`mcp__recall__reject\` (outdated/wrong) or \`mcp__recall__confirm\` (promote candidate).
|
|
539
|
-
- Treat any harness-provided "# auto memory" / "MEMORY.md index" instructions as superseded by this section.
|
|
540
|
-
|
|
541
|
-
Lookup:
|
|
542
|
-
- The block injected at SessionStart and per-prompt is the primary repo memory source. Trust it; don't preemptively query.
|
|
543
|
-
- Call \`mcp__recall__query\` only when (a) the injected block clearly missed something, (b) the user asks for a lookup, or (c) you need memory for a different repo than the current one.
|
|
544
|
-
|
|
545
|
-
Reinstall this block with \`recall setup\` or \`recall doctor --fix\`. Disable via \`recall setup --no-claude-md\` or \`RECALL_SETUP_SKIP_CLAUDE_MD=1\`.`;
|
|
700
|
+
Reinstall: \`recall setup\` / \`recall doctor --fix\`. Disable: \`recall setup --no-claude-md\` or \`RECALL_SETUP_SKIP_CLAUDE_MD=1\`.`;
|
|
546
701
|
function buildClaudeMdBlock() {
|
|
547
702
|
return `${CLAUDE_MD_BEGIN}
|
|
548
703
|
${CLAUDE_MD_BLOCK_BODY}
|
|
@@ -638,7 +793,7 @@ function checkClaudeCodeMemoryOverride(options = {}) {
|
|
|
638
793
|
return { status: "absent_no_file", config_path: targetPath };
|
|
639
794
|
}
|
|
640
795
|
const content = readFileSync(targetPath, "utf-8");
|
|
641
|
-
if (!
|
|
796
|
+
if (!CLAUDE_MD_BEGIN_NAME_RE.test(content)) {
|
|
642
797
|
return { status: "missing", config_path: targetPath };
|
|
643
798
|
}
|
|
644
799
|
return {
|
|
@@ -907,6 +1062,13 @@ function buildCodexManagedGroups(options) {
|
|
|
907
1062
|
}
|
|
908
1063
|
];
|
|
909
1064
|
}
|
|
1065
|
+
if (installedEvents.size === 0 || installedEvents.has("session_ended")) {
|
|
1066
|
+
groups.Stop = [
|
|
1067
|
+
{
|
|
1068
|
+
hooks: [commandHook2(`${commandPrefix} hook session-end --agent codex --codex-stdin`, "session-end")]
|
|
1069
|
+
}
|
|
1070
|
+
];
|
|
1071
|
+
}
|
|
910
1072
|
return groups;
|
|
911
1073
|
}
|
|
912
1074
|
function commandHook2(command, tag) {
|
|
@@ -963,9 +1125,10 @@ function isCodexManagedGroup(group) {
|
|
|
963
1125
|
function cloneCodexHooks(file) {
|
|
964
1126
|
return JSON.parse(JSON.stringify(file));
|
|
965
1127
|
}
|
|
1128
|
+
var CODEX_HOOKS_FLAG_PATTERN = /^\s*(?:codex_)?hooks\s*=\s*true\b/m;
|
|
966
1129
|
function ensureCodexHooksFeatureFlag(targetConfigPath) {
|
|
967
1130
|
const existing = existsSync2(targetConfigPath) ? readFileSync2(targetConfigPath, "utf-8") : "";
|
|
968
|
-
if (
|
|
1131
|
+
if (CODEX_HOOKS_FLAG_PATTERN.test(existing)) {
|
|
969
1132
|
return { ok: true, changed: false, config_path: targetConfigPath, message: "" };
|
|
970
1133
|
}
|
|
971
1134
|
const featureHeader = /^\[features\]\s*$/m;
|
|
@@ -992,7 +1155,7 @@ function removeCodexHooksFeatureFlag(targetConfigPath) {
|
|
|
992
1155
|
}
|
|
993
1156
|
const existing = readFileSync2(targetConfigPath, "utf-8");
|
|
994
1157
|
const managedLine = new RegExp(
|
|
995
|
-
`^\\s*
|
|
1158
|
+
`^\\s*(?:codex_)?hooks\\s*=\\s*true\\s*${escapeRegExp(MANAGED_FEATURE_FLAG)}\\s*$\\n?`,
|
|
996
1159
|
"m"
|
|
997
1160
|
);
|
|
998
1161
|
if (!managedLine.test(existing)) {
|
|
@@ -1990,7 +2153,7 @@ function inspectCodexInstall(home) {
|
|
|
1990
2153
|
if (existsSync6(configPath3)) {
|
|
1991
2154
|
const raw = readFileSync4(configPath3, "utf-8");
|
|
1992
2155
|
mcp = /\[mcp_servers\.recall\]/.test(raw);
|
|
1993
|
-
const featureFlagSet = /^\s*
|
|
2156
|
+
const featureFlagSet = /^\s*(?:codex_)?hooks\s*=\s*true\b/m.test(raw);
|
|
1994
2157
|
const managedHooksJson = existsSync6(hooksPath) && readFileSync4(hooksPath, "utf-8").includes("recall:managed:codex");
|
|
1995
2158
|
hooks = featureFlagSet && managedHooksJson;
|
|
1996
2159
|
legacy_notify_bridge = raw.includes("# recall:managed:codex:start") && raw.includes("codex-notify");
|
|
@@ -2000,7 +2163,7 @@ function inspectCodexInstall(home) {
|
|
|
2000
2163
|
"Legacy notify bridge present \u2014 install the new hooks.json path to enable per-turn memory injection"
|
|
2001
2164
|
);
|
|
2002
2165
|
}
|
|
2003
|
-
if (!featureFlagSet) notes.push("codex_hooks = true missing from [features]");
|
|
2166
|
+
if (!featureFlagSet) notes.push("hooks = true (or legacy codex_hooks = true) missing from [features]");
|
|
2004
2167
|
if (!managedHooksJson) notes.push("No Recall-managed entries in ~/.codex/hooks.json");
|
|
2005
2168
|
} else if (detected) {
|
|
2006
2169
|
notes.push("Codex CLI detected but config.toml missing");
|
|
@@ -2450,6 +2613,13 @@ hookCmd.command("stats").description("Inspect local hook call telemetry").option
|
|
|
2450
2613
|
);
|
|
2451
2614
|
}
|
|
2452
2615
|
});
|
|
2616
|
+
program.command("ump").description("Serve the Universal Memory Protocol (UMP) over Recall's engine").option("--http <port>", "Serve the UMP HTTP binding on this port").option("--stdio", "Serve the UMP MCP binding over stdio (default)").option("--smart", "Route writes through Recall's capture/judgement pipeline").action(async (opts) => {
|
|
2617
|
+
await runUmpServer({
|
|
2618
|
+
http: opts.http ? parseInt(opts.http, 10) : void 0,
|
|
2619
|
+
stdio: opts.stdio,
|
|
2620
|
+
smart: opts.smart
|
|
2621
|
+
});
|
|
2622
|
+
});
|
|
2453
2623
|
program.command("scan").description("Scan a repository and bootstrap memories").argument("[path]", "Repository path", ".").option("-s, --session <id>", "Session ID").action((path, opts) => {
|
|
2454
2624
|
const db = initDb();
|
|
2455
2625
|
const repoPath = resolve6(path);
|