@edihasaj/recall 0.8.20 → 0.9.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/README.md +13 -0
- package/dist/{chunk-S7FJMV5O.js → chunk-3PPYB7BX.js} +8 -8
- package/dist/{chunk-ZBIJDXA7.js → chunk-4W4J7Z24.js} +17 -111
- package/dist/chunk-4W4J7Z24.js.map +1 -0
- package/dist/{chunk-O4KCMCJG.js → chunk-A27AP4NR.js} +21 -6
- package/dist/chunk-A27AP4NR.js.map +1 -0
- package/dist/{chunk-VT5VAEHY.js → chunk-CW3XJDH7.js} +2 -2
- package/dist/chunk-DWA2IO5N.js +105 -0
- package/dist/chunk-DWA2IO5N.js.map +1 -0
- package/dist/{chunk-M7OKBKKU.js → chunk-EAFRT7RX.js} +2 -2
- package/dist/{chunk-QKN6IWJ3.js → chunk-EZUMD27V.js} +68 -72
- package/dist/{chunk-QKN6IWJ3.js.map → chunk-EZUMD27V.js.map} +1 -1
- package/dist/{chunk-K6AFGQWR.js → chunk-FNQABJTM.js} +4 -4
- package/dist/{chunk-6I5U6KS3.js → chunk-G6YAXFT4.js} +70 -41
- package/dist/chunk-G6YAXFT4.js.map +1 -0
- package/dist/{chunk-LGTD5A4A.js → chunk-GE5BPNHC.js} +78 -16
- package/dist/chunk-GE5BPNHC.js.map +1 -0
- package/dist/{chunk-4CV4JOE5.js → chunk-JYWURG5T.js} +8 -3
- package/dist/{chunk-55KCGAOX.js → chunk-LUIYWYOT.js} +2 -2
- package/dist/{chunk-KG7YFARS.js → chunk-PQJRYAVG.js} +92 -14
- package/dist/chunk-PQJRYAVG.js.map +1 -0
- package/dist/{chunk-DNFKAHS6.js → chunk-VYZSP23L.js} +95 -12
- package/dist/chunk-VYZSP23L.js.map +1 -0
- package/dist/{chunk-NAYZL5XI.js → chunk-YDSCPOIJ.js} +4 -4
- package/dist/{cleanup-HWQCVPY4.js → cleanup-MBXKIGT6.js} +10 -9
- package/dist/cli.js +951 -161
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +113 -56
- package/dist/daemon.js.map +1 -1
- package/dist/dispatcher-YN6545TF.js +21 -0
- package/dist/{embeddings-LNMNKWB7.js → embeddings-E362AC3R.js} +5 -5
- package/dist/ingest-7FAOX7YV.js +18 -0
- package/dist/{keychain-5QG52ANO.js → keychain-PWFWKTZW.js} +3 -3
- package/dist/mcp.js +13 -12
- package/dist/mcp.js.map +1 -1
- package/dist/{memory-value-GH67CBQP.js → memory-value-ZLVZTE5M.js} +10 -9
- package/dist/quality-UUEBGSAQ.js +24 -0
- package/dist/retrieval-YU2PLBUS.js +13 -0
- package/dist/{store-OPRTGS73.js → store-5C7ZKKZF.js} +4 -4
- package/dist/sync-server.js +1 -1
- package/dist/{tasks-LOZ7XWON.js → tasks-AEKGKZZF.js} +10 -9
- package/dist/{usage-CAAACLUR.js → usage-VQ5LJCNH.js} +4 -4
- package/dist/webui/assets/{index-BODg2A9d.js → index-DAoAhOb4.js} +244 -244
- package/dist/webui/assets/{index-BODg2A9d.js.map → index-DAoAhOb4.js.map} +1 -1
- package/dist/webui/index.html +1 -1
- package/package.json +34 -2
- package/dist/chunk-6I5U6KS3.js.map +0 -1
- package/dist/chunk-DNFKAHS6.js.map +0 -1
- package/dist/chunk-KG7YFARS.js.map +0 -1
- package/dist/chunk-LGTD5A4A.js.map +0 -1
- package/dist/chunk-O4KCMCJG.js.map +0 -1
- package/dist/chunk-ZBIJDXA7.js.map +0 -1
- package/dist/dispatcher-RU25CZK3.js +0 -20
- package/dist/ingest-QSOE5XJZ.js +0 -18
- package/dist/quality-PZ36JND4.js +0 -23
- package/dist/retrieval-HIE5MASN.js +0 -13
- /package/dist/{chunk-S7FJMV5O.js.map → chunk-3PPYB7BX.js.map} +0 -0
- /package/dist/{chunk-VT5VAEHY.js.map → chunk-CW3XJDH7.js.map} +0 -0
- /package/dist/{chunk-M7OKBKKU.js.map → chunk-EAFRT7RX.js.map} +0 -0
- /package/dist/{chunk-K6AFGQWR.js.map → chunk-FNQABJTM.js.map} +0 -0
- /package/dist/{chunk-4CV4JOE5.js.map → chunk-JYWURG5T.js.map} +0 -0
- /package/dist/{chunk-55KCGAOX.js.map → chunk-LUIYWYOT.js.map} +0 -0
- /package/dist/{chunk-NAYZL5XI.js.map → chunk-YDSCPOIJ.js.map} +0 -0
- /package/dist/{cleanup-HWQCVPY4.js.map → cleanup-MBXKIGT6.js.map} +0 -0
- /package/dist/{dispatcher-RU25CZK3.js.map → dispatcher-YN6545TF.js.map} +0 -0
- /package/dist/{embeddings-LNMNKWB7.js.map → embeddings-E362AC3R.js.map} +0 -0
- /package/dist/{ingest-QSOE5XJZ.js.map → ingest-7FAOX7YV.js.map} +0 -0
- /package/dist/{keychain-5QG52ANO.js.map → keychain-PWFWKTZW.js.map} +0 -0
- /package/dist/{memory-value-GH67CBQP.js.map → memory-value-ZLVZTE5M.js.map} +0 -0
- /package/dist/{quality-PZ36JND4.js.map → quality-UUEBGSAQ.js.map} +0 -0
- /package/dist/{retrieval-HIE5MASN.js.map → retrieval-YU2PLBUS.js.map} +0 -0
- /package/dist/{store-OPRTGS73.js.map → store-5C7ZKKZF.js.map} +0 -0
- /package/dist/{tasks-LOZ7XWON.js.map → tasks-AEKGKZZF.js.map} +0 -0
- /package/dist/{usage-CAAACLUR.js.map → usage-VQ5LJCNH.js.map} +0 -0
package/dist/cli.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
readCodexSessionStartInputFromStdin,
|
|
24
24
|
readCodexToolInputFromStdin,
|
|
25
25
|
restoreBackup
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-GE5BPNHC.js";
|
|
27
27
|
import {
|
|
28
28
|
RECALL_DB_USER_VERSION,
|
|
29
29
|
compileContext,
|
|
@@ -66,7 +66,7 @@ import {
|
|
|
66
66
|
summarizeValueRetrievalEval,
|
|
67
67
|
togglePolicy,
|
|
68
68
|
writeRepoContextArtifact
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-EZUMD27V.js";
|
|
70
70
|
import {
|
|
71
71
|
autoResolveContradictions,
|
|
72
72
|
computeAllHealthScores,
|
|
@@ -84,20 +84,24 @@ import {
|
|
|
84
84
|
recordAudit,
|
|
85
85
|
resolveContradiction,
|
|
86
86
|
rollbackMemory
|
|
87
|
-
} from "./chunk-
|
|
88
|
-
import "./chunk-
|
|
89
|
-
import "./chunk-
|
|
87
|
+
} from "./chunk-G6YAXFT4.js";
|
|
88
|
+
import "./chunk-4W4J7Z24.js";
|
|
89
|
+
import "./chunk-DWA2IO5N.js";
|
|
90
|
+
import "./chunk-CW3XJDH7.js";
|
|
90
91
|
import "./chunk-PUMEMKGF.js";
|
|
91
92
|
import {
|
|
92
93
|
confirmMemory,
|
|
93
94
|
createMemory,
|
|
95
|
+
defineOwn,
|
|
96
|
+
deleteOwn,
|
|
94
97
|
getMemory,
|
|
95
98
|
listMemories,
|
|
96
99
|
listRepos,
|
|
97
100
|
queryMemories,
|
|
98
101
|
rejectMemory
|
|
99
|
-
} from "./chunk-
|
|
102
|
+
} from "./chunk-A27AP4NR.js";
|
|
100
103
|
import {
|
|
104
|
+
atomicWriteUtf8File,
|
|
101
105
|
bootstrapEmbeddings,
|
|
102
106
|
ensureEmbeddingProviderReady,
|
|
103
107
|
flushEmbeddingJobs,
|
|
@@ -105,31 +109,34 @@ import {
|
|
|
105
109
|
hybridSearch,
|
|
106
110
|
loadEmbeddingConfigFromEnv,
|
|
107
111
|
queueMemoryEmbeddingSync,
|
|
112
|
+
readUtf8FileIfExists,
|
|
108
113
|
rebuildEmbeddingIndex,
|
|
109
114
|
searchMemoryFtsIndex,
|
|
110
115
|
semanticSearch,
|
|
111
116
|
verifyEmbeddings
|
|
112
|
-
} from "./chunk-
|
|
117
|
+
} from "./chunk-PQJRYAVG.js";
|
|
113
118
|
import {
|
|
114
119
|
init_keychain,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
120
|
+
init_outbound_url,
|
|
121
|
+
keychain_exports,
|
|
122
|
+
normalizeSyncRemoteUrl
|
|
123
|
+
} from "./chunk-VYZSP23L.js";
|
|
124
|
+
import "./chunk-EAFRT7RX.js";
|
|
118
125
|
import {
|
|
119
126
|
eq,
|
|
120
127
|
gt,
|
|
121
128
|
memories,
|
|
122
129
|
syncState
|
|
123
|
-
} from "./chunk-
|
|
130
|
+
} from "./chunk-LUIYWYOT.js";
|
|
124
131
|
import {
|
|
125
132
|
__toCommonJS
|
|
126
|
-
} from "./chunk-
|
|
133
|
+
} from "./chunk-JYWURG5T.js";
|
|
127
134
|
|
|
128
135
|
// src/cli.ts
|
|
129
136
|
import { Command } from "commander";
|
|
130
|
-
import { resolve as
|
|
131
|
-
import { writeFileSync as
|
|
132
|
-
import { join as
|
|
137
|
+
import { resolve as resolve7 } from "path";
|
|
138
|
+
import { writeFileSync as writeFileSync7, readFileSync as readFileSync7 } from "fs";
|
|
139
|
+
import { join as join11 } from "path";
|
|
133
140
|
|
|
134
141
|
// src/ump/serve.ts
|
|
135
142
|
import {
|
|
@@ -304,6 +311,15 @@ async function runUmpServer(opts = {}) {
|
|
|
304
311
|
|
|
305
312
|
// src/sync/client.ts
|
|
306
313
|
import { randomUUID } from "crypto";
|
|
314
|
+
init_outbound_url();
|
|
315
|
+
var SYNC_REQUEST_TIMEOUT_MS = 3e4;
|
|
316
|
+
function syncRequestInit(init) {
|
|
317
|
+
return {
|
|
318
|
+
...init,
|
|
319
|
+
redirect: "error",
|
|
320
|
+
signal: AbortSignal.timeout(SYNC_REQUEST_TIMEOUT_MS)
|
|
321
|
+
};
|
|
322
|
+
}
|
|
307
323
|
function getSyncState(db) {
|
|
308
324
|
const row = db.select().from(syncState).where(eq(syncState.id, "local")).get();
|
|
309
325
|
if (row) return row;
|
|
@@ -323,6 +339,7 @@ function updateSyncState(db, updates) {
|
|
|
323
339
|
}
|
|
324
340
|
async function pushMemories(db, config) {
|
|
325
341
|
const state = getSyncState(db);
|
|
342
|
+
const remoteUrl = normalizeSyncRemoteUrl(config.remote_url);
|
|
326
343
|
const localMemories = db.select().from(memories).where(gt(memories.sync_version, state.last_push_version)).all();
|
|
327
344
|
if (localMemories.length === 0) {
|
|
328
345
|
return { pushed: 0, version: state.last_push_version };
|
|
@@ -332,7 +349,7 @@ async function pushMemories(db, config) {
|
|
|
332
349
|
origin_id: m.id,
|
|
333
350
|
evidence: typeof m.evidence === "string" ? JSON.parse(m.evidence) : m.evidence
|
|
334
351
|
}));
|
|
335
|
-
const resp = await fetch(`${
|
|
352
|
+
const resp = await fetch(`${remoteUrl}/api/push`, syncRequestInit({
|
|
336
353
|
method: "POST",
|
|
337
354
|
headers: {
|
|
338
355
|
"Content-Type": "application/json",
|
|
@@ -342,14 +359,14 @@ async function pushMemories(db, config) {
|
|
|
342
359
|
team_id: config.team_id,
|
|
343
360
|
memories: payload
|
|
344
361
|
})
|
|
345
|
-
});
|
|
362
|
+
}));
|
|
346
363
|
if (!resp.ok) {
|
|
347
364
|
const err = await resp.json().catch(() => ({ error: resp.statusText }));
|
|
348
365
|
throw new Error(`Push failed: ${err.error ?? resp.statusText}`);
|
|
349
366
|
}
|
|
350
367
|
const result = await resp.json();
|
|
351
368
|
updateSyncState(db, {
|
|
352
|
-
remote_url:
|
|
369
|
+
remote_url: remoteUrl,
|
|
353
370
|
team_id: config.team_id,
|
|
354
371
|
last_push_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
355
372
|
last_push_version: Math.max(
|
|
@@ -360,7 +377,8 @@ async function pushMemories(db, config) {
|
|
|
360
377
|
}
|
|
361
378
|
async function pullMemories(db, config) {
|
|
362
379
|
const state = getSyncState(db);
|
|
363
|
-
const
|
|
380
|
+
const remoteUrl = normalizeSyncRemoteUrl(config.remote_url);
|
|
381
|
+
const resp = await fetch(`${remoteUrl}/api/pull`, syncRequestInit({
|
|
364
382
|
method: "POST",
|
|
365
383
|
headers: {
|
|
366
384
|
"Content-Type": "application/json",
|
|
@@ -370,7 +388,7 @@ async function pullMemories(db, config) {
|
|
|
370
388
|
team_id: config.team_id,
|
|
371
389
|
since_version: state.last_pull_version
|
|
372
390
|
})
|
|
373
|
-
});
|
|
391
|
+
}));
|
|
374
392
|
if (!resp.ok) {
|
|
375
393
|
const err = await resp.json().catch(() => ({ error: resp.statusText }));
|
|
376
394
|
throw new Error(`Pull failed: ${err.error ?? resp.statusText}`);
|
|
@@ -444,33 +462,38 @@ async function sync(db, config) {
|
|
|
444
462
|
return { pushed, pulled, conflicts, errors };
|
|
445
463
|
}
|
|
446
464
|
async function createTeam(config, name) {
|
|
447
|
-
const
|
|
465
|
+
const remoteUrl = normalizeSyncRemoteUrl(config.remote_url);
|
|
466
|
+
const resp = await fetch(`${remoteUrl}/api/team`, syncRequestInit({
|
|
448
467
|
method: "POST",
|
|
449
468
|
headers: {
|
|
450
469
|
"Content-Type": "application/json",
|
|
451
470
|
Authorization: `Bearer ${config.api_key}`
|
|
452
471
|
},
|
|
453
472
|
body: JSON.stringify({ name })
|
|
454
|
-
});
|
|
473
|
+
}));
|
|
455
474
|
if (!resp.ok) throw new Error(`Failed to create team: ${resp.statusText}`);
|
|
456
475
|
const data = await resp.json();
|
|
457
476
|
return data.team_id;
|
|
458
477
|
}
|
|
459
478
|
async function joinTeam(config, teamId) {
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
479
|
+
const remoteUrl = normalizeSyncRemoteUrl(config.remote_url);
|
|
480
|
+
const resp = await fetch(
|
|
481
|
+
`${remoteUrl}/api/team/${encodeURIComponent(teamId)}/join`,
|
|
482
|
+
syncRequestInit({
|
|
483
|
+
method: "POST",
|
|
484
|
+
headers: {
|
|
485
|
+
"Content-Type": "application/json",
|
|
486
|
+
Authorization: `Bearer ${config.api_key}`
|
|
487
|
+
}
|
|
488
|
+
})
|
|
489
|
+
);
|
|
467
490
|
if (!resp.ok) throw new Error(`Failed to join team: ${resp.statusText}`);
|
|
468
491
|
}
|
|
469
492
|
|
|
470
493
|
// src/setup/local.ts
|
|
471
|
-
import { existsSync as
|
|
494
|
+
import { existsSync as existsSync6 } from "fs";
|
|
472
495
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
473
|
-
import { dirname as
|
|
496
|
+
import { dirname as dirname5, join as join7, resolve as resolve4 } from "path";
|
|
474
497
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
475
498
|
|
|
476
499
|
// src/agents/claude-code.ts
|
|
@@ -511,6 +534,52 @@ var CLAUDE_MD_BLOCK_RE = /<!--\s*recall:managed:(?:memory|claude-md):begin(?:\s+
|
|
|
511
534
|
var SESSION_START_MATCHER = "startup|resume|clear|compact";
|
|
512
535
|
var SESSION_END_MATCHER = "clear|resume|logout|prompt_input_exit|bypass_permissions_disabled|other";
|
|
513
536
|
var configPath = () => join(resolveUserHomeDir(), ...CLAUDE_CONFIG_RELATIVE_PATH);
|
|
537
|
+
var claudeCodeAdapter = {
|
|
538
|
+
name: "claude-code",
|
|
539
|
+
configPath,
|
|
540
|
+
detect() {
|
|
541
|
+
return existsSync(configPath()) || hasCommand("claude") ? "installed" : "not-installed";
|
|
542
|
+
},
|
|
543
|
+
capabilities() {
|
|
544
|
+
return {
|
|
545
|
+
supports: ["session_started", "prompt_submitted", "tool_invoked", "session_ended"],
|
|
546
|
+
supports_hook_install: true,
|
|
547
|
+
supports_mcp_fallback: true
|
|
548
|
+
};
|
|
549
|
+
},
|
|
550
|
+
installHooks(profile) {
|
|
551
|
+
return installClaudeCodeHooks({ profile });
|
|
552
|
+
},
|
|
553
|
+
uninstallHooks() {
|
|
554
|
+
return uninstallClaudeCodeHooks();
|
|
555
|
+
},
|
|
556
|
+
envMapping: {
|
|
557
|
+
prompt_submitted: {
|
|
558
|
+
prompt: "text",
|
|
559
|
+
session_id: "session_id",
|
|
560
|
+
cwd: "repo_path"
|
|
561
|
+
},
|
|
562
|
+
tool_invoked: {
|
|
563
|
+
tool_name: "name",
|
|
564
|
+
tool_input: "input_summary",
|
|
565
|
+
session_id: "session_id",
|
|
566
|
+
cwd: "repo_path"
|
|
567
|
+
},
|
|
568
|
+
session_started: {
|
|
569
|
+
session_id: "session_id",
|
|
570
|
+
cwd: "repo_path",
|
|
571
|
+
source: "matcher"
|
|
572
|
+
},
|
|
573
|
+
session_ended: {
|
|
574
|
+
session_id: "session_id",
|
|
575
|
+
cwd: "repo_path",
|
|
576
|
+
reason: "matcher"
|
|
577
|
+
}
|
|
578
|
+
},
|
|
579
|
+
writeMcpFallback() {
|
|
580
|
+
throw new Error("Claude Code MCP fallback wiring not implemented yet.");
|
|
581
|
+
}
|
|
582
|
+
};
|
|
514
583
|
function installClaudeCodeHooks(options = {}) {
|
|
515
584
|
const targetPath = options.configPath ?? configPath();
|
|
516
585
|
const current = readSettingsFile(targetPath);
|
|
@@ -528,7 +597,7 @@ function installClaudeCodeHooks(options = {}) {
|
|
|
528
597
|
const preserved = existing.filter((group) => !isManagedGroup(group));
|
|
529
598
|
const merged = [...preserved, ...groups];
|
|
530
599
|
if (!sameJson(existing, merged)) {
|
|
531
|
-
hooks
|
|
600
|
+
defineOwn(hooks, eventName, merged);
|
|
532
601
|
changed = true;
|
|
533
602
|
}
|
|
534
603
|
}
|
|
@@ -576,9 +645,9 @@ function uninstallClaudeCodeHooks(options = {}) {
|
|
|
576
645
|
if (!sameJson(existing, preserved)) {
|
|
577
646
|
changed = true;
|
|
578
647
|
if (preserved.length > 0) {
|
|
579
|
-
hooks
|
|
648
|
+
defineOwn(hooks, eventName, preserved);
|
|
580
649
|
} else {
|
|
581
|
-
|
|
650
|
+
deleteOwn(hooks, eventName);
|
|
582
651
|
}
|
|
583
652
|
}
|
|
584
653
|
}
|
|
@@ -743,10 +812,7 @@ function installClaudeCodeMemoryOverride(options = {}) {
|
|
|
743
812
|
mkdirSync(targetDir, { recursive: true });
|
|
744
813
|
}
|
|
745
814
|
const desired = buildClaudeMdBlock();
|
|
746
|
-
|
|
747
|
-
if (existsSync(targetPath)) {
|
|
748
|
-
existingContent = readFileSync(targetPath, "utf-8");
|
|
749
|
-
}
|
|
815
|
+
const existingContent = readUtf8FileIfExists(targetPath) ?? "";
|
|
750
816
|
if (existingContent.includes(CLAUDE_MD_BEGIN) && existingContent.includes(desired.trim())) {
|
|
751
817
|
return {
|
|
752
818
|
ok: true,
|
|
@@ -765,7 +831,7 @@ function installClaudeCodeMemoryOverride(options = {}) {
|
|
|
765
831
|
const separator = existingContent.endsWith("\n\n") ? "" : existingContent.endsWith("\n") ? "\n" : "\n\n";
|
|
766
832
|
nextContent = `${existingContent}${separator}${desired}`;
|
|
767
833
|
}
|
|
768
|
-
|
|
834
|
+
atomicWriteUtf8File(targetPath, nextContent);
|
|
769
835
|
return {
|
|
770
836
|
ok: true,
|
|
771
837
|
changed: true,
|
|
@@ -775,7 +841,8 @@ function installClaudeCodeMemoryOverride(options = {}) {
|
|
|
775
841
|
}
|
|
776
842
|
function uninstallClaudeCodeMemoryOverride(options = {}) {
|
|
777
843
|
const targetPath = options.configPath ?? claudeMdPath();
|
|
778
|
-
|
|
844
|
+
const existingContent = readUtf8FileIfExists(targetPath);
|
|
845
|
+
if (existingContent === null) {
|
|
779
846
|
return {
|
|
780
847
|
ok: true,
|
|
781
848
|
changed: false,
|
|
@@ -783,7 +850,6 @@ function uninstallClaudeCodeMemoryOverride(options = {}) {
|
|
|
783
850
|
message: "CLAUDE.md not present"
|
|
784
851
|
};
|
|
785
852
|
}
|
|
786
|
-
const existingContent = readFileSync(targetPath, "utf-8");
|
|
787
853
|
CLAUDE_MD_BLOCK_RE.lastIndex = 0;
|
|
788
854
|
if (!CLAUDE_MD_BLOCK_RE.test(existingContent)) {
|
|
789
855
|
return {
|
|
@@ -796,10 +862,13 @@ function uninstallClaudeCodeMemoryOverride(options = {}) {
|
|
|
796
862
|
CLAUDE_MD_BLOCK_RE.lastIndex = 0;
|
|
797
863
|
const stripped = existingContent.replace(CLAUDE_MD_BLOCK_RE, "").replace(/\n{3,}/g, "\n\n");
|
|
798
864
|
if (stripped.trim().length === 0) {
|
|
799
|
-
|
|
865
|
+
atomicWriteUtf8File(targetPath, "");
|
|
800
866
|
} else {
|
|
801
|
-
|
|
802
|
-
|
|
867
|
+
atomicWriteUtf8File(
|
|
868
|
+
targetPath,
|
|
869
|
+
stripped.endsWith("\n") ? stripped : `${stripped}
|
|
870
|
+
`
|
|
871
|
+
);
|
|
803
872
|
}
|
|
804
873
|
return {
|
|
805
874
|
ok: true,
|
|
@@ -843,6 +912,46 @@ var MANAGED_HOOK_TAG = "recall:managed:codex";
|
|
|
843
912
|
var DEFAULT_MIN_CODEX_HOOKS_VERSION = "0.115.0";
|
|
844
913
|
var configPath2 = () => join2(resolveUserHomeDir(), ...CODEX_CONFIG_RELATIVE_PATH);
|
|
845
914
|
var hooksJsonPath = () => join2(resolveUserHomeDir(), ...CODEX_HOOKS_RELATIVE_PATH);
|
|
915
|
+
var codexAdapter = {
|
|
916
|
+
name: "codex",
|
|
917
|
+
configPath: configPath2,
|
|
918
|
+
detect() {
|
|
919
|
+
return existsSync2(configPath2()) || hasCommand("codex") ? "installed" : "not-installed";
|
|
920
|
+
},
|
|
921
|
+
capabilities() {
|
|
922
|
+
return {
|
|
923
|
+
supports: ["session_started", "prompt_submitted", "tool_invoked", "session_ended"],
|
|
924
|
+
supports_hook_install: true,
|
|
925
|
+
supports_mcp_fallback: true
|
|
926
|
+
};
|
|
927
|
+
},
|
|
928
|
+
installHooks(profile) {
|
|
929
|
+
return installCodexHooks({ profile });
|
|
930
|
+
},
|
|
931
|
+
uninstallHooks() {
|
|
932
|
+
return uninstallCodexHooks();
|
|
933
|
+
},
|
|
934
|
+
envMapping: {
|
|
935
|
+
prompt_submitted: {
|
|
936
|
+
prompt: "text",
|
|
937
|
+
session_id: "session_id",
|
|
938
|
+
cwd: "repo_path"
|
|
939
|
+
},
|
|
940
|
+
tool_invoked: {
|
|
941
|
+
tool_name: "name",
|
|
942
|
+
cwd: "repo_path",
|
|
943
|
+
tool_input: "input_summary"
|
|
944
|
+
},
|
|
945
|
+
session_ended: {
|
|
946
|
+
session_id: "session_id",
|
|
947
|
+
cwd: "repo_path",
|
|
948
|
+
reason: "event"
|
|
949
|
+
}
|
|
950
|
+
},
|
|
951
|
+
writeMcpFallback() {
|
|
952
|
+
throw new Error("Codex MCP fallback wiring not implemented yet.");
|
|
953
|
+
}
|
|
954
|
+
};
|
|
846
955
|
function installCodexNotifyBridge(options = {}) {
|
|
847
956
|
const targetPath = options.configPath ?? configPath2();
|
|
848
957
|
const existing = existsSync2(targetPath) ? readFileSync2(targetPath, "utf-8") : "";
|
|
@@ -1007,7 +1116,7 @@ function writeCodexHooksJson(targetPath, options) {
|
|
|
1007
1116
|
const preserved = current.filter((group) => !isCodexManagedGroup(group));
|
|
1008
1117
|
const merged = [...preserved, ...groups];
|
|
1009
1118
|
if (JSON.stringify(current) !== JSON.stringify(merged)) {
|
|
1010
|
-
hooks
|
|
1119
|
+
defineOwn(hooks, eventName, merged);
|
|
1011
1120
|
changed = true;
|
|
1012
1121
|
}
|
|
1013
1122
|
}
|
|
@@ -1044,9 +1153,9 @@ function removeCodexHooksJson(targetPath) {
|
|
|
1044
1153
|
if (preserved.length !== current.length) {
|
|
1045
1154
|
changed = true;
|
|
1046
1155
|
if (preserved.length > 0) {
|
|
1047
|
-
hooks
|
|
1156
|
+
defineOwn(hooks, eventName, preserved);
|
|
1048
1157
|
} else {
|
|
1049
|
-
|
|
1158
|
+
deleteOwn(hooks, eventName);
|
|
1050
1159
|
}
|
|
1051
1160
|
}
|
|
1052
1161
|
}
|
|
@@ -1256,24 +1365,622 @@ function escapeRegExp(value) {
|
|
|
1256
1365
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1257
1366
|
}
|
|
1258
1367
|
|
|
1368
|
+
// src/agents/cursor.ts
|
|
1369
|
+
import { join as join3 } from "path";
|
|
1370
|
+
|
|
1371
|
+
// src/agents/hookless.ts
|
|
1372
|
+
import { existsSync as existsSync5 } from "fs";
|
|
1373
|
+
import { resolve as resolve3 } from "path";
|
|
1374
|
+
|
|
1375
|
+
// src/agents/mcp-json.ts
|
|
1376
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
1377
|
+
import { dirname as dirname3 } from "path";
|
|
1378
|
+
var RECALL_SERVER_KEY = "recall";
|
|
1379
|
+
function commandArgsEntry(spec) {
|
|
1380
|
+
return {
|
|
1381
|
+
command: spec.nodePath,
|
|
1382
|
+
args: [spec.mcpPath],
|
|
1383
|
+
env: {}
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
function copilotEntry(spec) {
|
|
1387
|
+
return {
|
|
1388
|
+
type: "local",
|
|
1389
|
+
command: spec.nodePath,
|
|
1390
|
+
args: [spec.mcpPath],
|
|
1391
|
+
env: {},
|
|
1392
|
+
tools: ["*"]
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
function opencodeEntry(spec) {
|
|
1396
|
+
return {
|
|
1397
|
+
type: "local",
|
|
1398
|
+
command: [spec.nodePath, spec.mcpPath],
|
|
1399
|
+
enabled: true
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
function writeMcpServerEntry(target, spec) {
|
|
1403
|
+
const serverKey = target.serverKey ?? RECALL_SERVER_KEY;
|
|
1404
|
+
const read = readJsonConfig(target.configPath);
|
|
1405
|
+
if (read.error) {
|
|
1406
|
+
return { ok: false, changed: false, config_path: target.configPath, message: read.error };
|
|
1407
|
+
}
|
|
1408
|
+
const next = clone(read.parsed);
|
|
1409
|
+
const container = ensureContainer(next, target.containerKey);
|
|
1410
|
+
if (!container) {
|
|
1411
|
+
return {
|
|
1412
|
+
ok: false,
|
|
1413
|
+
changed: false,
|
|
1414
|
+
config_path: target.configPath,
|
|
1415
|
+
message: `"${target.containerKey}" in ${target.configPath} is not an object \u2014 leaving it alone`
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
const desired = target.buildEntry(spec);
|
|
1419
|
+
if (sameJson2(container[serverKey], desired)) {
|
|
1420
|
+
return {
|
|
1421
|
+
ok: true,
|
|
1422
|
+
changed: false,
|
|
1423
|
+
config_path: target.configPath,
|
|
1424
|
+
message: `Recall MCP server already registered in ${target.configPath}`
|
|
1425
|
+
};
|
|
1426
|
+
}
|
|
1427
|
+
container[serverKey] = desired;
|
|
1428
|
+
writeJsonConfig(target.configPath, read.raw, next);
|
|
1429
|
+
return {
|
|
1430
|
+
ok: true,
|
|
1431
|
+
changed: true,
|
|
1432
|
+
config_path: target.configPath,
|
|
1433
|
+
message: read.raw == null ? `Created ${target.configPath} with Recall MCP server` : `Registered Recall MCP server in ${target.configPath}`
|
|
1434
|
+
};
|
|
1435
|
+
}
|
|
1436
|
+
function removeMcpServerEntry(target) {
|
|
1437
|
+
const serverKey = target.serverKey ?? RECALL_SERVER_KEY;
|
|
1438
|
+
if (!existsSync3(target.configPath)) {
|
|
1439
|
+
return {
|
|
1440
|
+
ok: true,
|
|
1441
|
+
changed: false,
|
|
1442
|
+
config_path: target.configPath,
|
|
1443
|
+
message: `${target.configPath} not found`
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
const read = readJsonConfig(target.configPath);
|
|
1447
|
+
if (read.error) {
|
|
1448
|
+
return { ok: false, changed: false, config_path: target.configPath, message: read.error };
|
|
1449
|
+
}
|
|
1450
|
+
const next = clone(read.parsed);
|
|
1451
|
+
const container = asObject(next[target.containerKey]);
|
|
1452
|
+
if (!container || !(serverKey in container)) {
|
|
1453
|
+
return {
|
|
1454
|
+
ok: true,
|
|
1455
|
+
changed: false,
|
|
1456
|
+
config_path: target.configPath,
|
|
1457
|
+
message: `No Recall MCP server registered in ${target.configPath}`
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
delete container[serverKey];
|
|
1461
|
+
if (Object.keys(container).length === 0) {
|
|
1462
|
+
delete next[target.containerKey];
|
|
1463
|
+
}
|
|
1464
|
+
writeJsonConfig(target.configPath, read.raw, next);
|
|
1465
|
+
return {
|
|
1466
|
+
ok: true,
|
|
1467
|
+
changed: true,
|
|
1468
|
+
config_path: target.configPath,
|
|
1469
|
+
message: `Removed Recall MCP server from ${target.configPath}`
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
function hasMcpServerEntry(target) {
|
|
1473
|
+
if (!existsSync3(target.configPath)) return false;
|
|
1474
|
+
const read = readJsonConfig(target.configPath);
|
|
1475
|
+
if (read.error) return false;
|
|
1476
|
+
const container = asObject(read.parsed[target.containerKey]);
|
|
1477
|
+
return Boolean(container && (target.serverKey ?? RECALL_SERVER_KEY) in container);
|
|
1478
|
+
}
|
|
1479
|
+
function readJsonConfig(configPath3) {
|
|
1480
|
+
if (!existsSync3(configPath3)) return { raw: null, parsed: {} };
|
|
1481
|
+
const raw = readFileSync3(configPath3, "utf-8");
|
|
1482
|
+
if (raw.trim().length === 0) return { raw, parsed: {} };
|
|
1483
|
+
let parsed;
|
|
1484
|
+
try {
|
|
1485
|
+
parsed = JSON.parse(raw);
|
|
1486
|
+
} catch {
|
|
1487
|
+
return {
|
|
1488
|
+
raw,
|
|
1489
|
+
parsed: {},
|
|
1490
|
+
error: `Could not parse ${configPath3} as JSON \u2014 add the Recall MCP server manually`
|
|
1491
|
+
};
|
|
1492
|
+
}
|
|
1493
|
+
const object = asObject(parsed);
|
|
1494
|
+
if (!object) {
|
|
1495
|
+
return { raw, parsed: {}, error: `${configPath3} must contain a JSON object` };
|
|
1496
|
+
}
|
|
1497
|
+
return { raw, parsed: object };
|
|
1498
|
+
}
|
|
1499
|
+
function writeJsonConfig(configPath3, previousRaw, value) {
|
|
1500
|
+
mkdirSync3(dirname3(configPath3), { recursive: true });
|
|
1501
|
+
if (previousRaw != null) {
|
|
1502
|
+
writeFileSync3(`${configPath3}.recall.bak.${Date.now()}`, previousRaw);
|
|
1503
|
+
}
|
|
1504
|
+
const tmpPath = `${configPath3}.tmp.${process.pid}`;
|
|
1505
|
+
writeFileSync3(tmpPath, `${JSON.stringify(value, null, 2)}
|
|
1506
|
+
`);
|
|
1507
|
+
renameSync3(tmpPath, configPath3);
|
|
1508
|
+
}
|
|
1509
|
+
function ensureContainer(config, key) {
|
|
1510
|
+
if (config[key] === void 0) {
|
|
1511
|
+
config[key] = {};
|
|
1512
|
+
}
|
|
1513
|
+
return asObject(config[key]);
|
|
1514
|
+
}
|
|
1515
|
+
function asObject(value) {
|
|
1516
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
1517
|
+
}
|
|
1518
|
+
function clone(value) {
|
|
1519
|
+
return JSON.parse(JSON.stringify(value));
|
|
1520
|
+
}
|
|
1521
|
+
function sameJson2(left, right) {
|
|
1522
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
// src/agents/rules-block.ts
|
|
1526
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync4, rmSync, writeFileSync as writeFileSync4 } from "fs";
|
|
1527
|
+
import { dirname as dirname4 } from "path";
|
|
1528
|
+
function beginMarker(block) {
|
|
1529
|
+
return `<!-- recall:managed:${block.name}:begin v${block.version} -->`;
|
|
1530
|
+
}
|
|
1531
|
+
function endMarker(block) {
|
|
1532
|
+
return `<!-- recall:managed:${block.name}:end -->`;
|
|
1533
|
+
}
|
|
1534
|
+
function anyBeginMarkerRe(block) {
|
|
1535
|
+
return new RegExp(`<!--\\s*recall:managed:${escapeRegExp2(block.name)}:begin(?:\\s+v\\d+)?\\s*-->`);
|
|
1536
|
+
}
|
|
1537
|
+
function blockRe(block) {
|
|
1538
|
+
return new RegExp(
|
|
1539
|
+
`<!--\\s*recall:managed:${escapeRegExp2(block.name)}:begin(?:\\s+v\\d+)?\\s*-->[\\s\\S]*?<!--\\s*recall:managed:${escapeRegExp2(block.name)}:end\\s*-->\\n?`,
|
|
1540
|
+
"g"
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
function renderManagedBlock(block) {
|
|
1544
|
+
return `${beginMarker(block)}
|
|
1545
|
+
${block.body}
|
|
1546
|
+
${endMarker(block)}
|
|
1547
|
+
`;
|
|
1548
|
+
}
|
|
1549
|
+
function installManagedRules(targetPath, block) {
|
|
1550
|
+
const desired = renderManagedBlock(block);
|
|
1551
|
+
const existing = existsSync4(targetPath) ? readFileSync4(targetPath, "utf-8") : "";
|
|
1552
|
+
if (existing.includes(beginMarker(block)) && existing.includes(block.body)) {
|
|
1553
|
+
return {
|
|
1554
|
+
ok: true,
|
|
1555
|
+
changed: false,
|
|
1556
|
+
config_path: targetPath,
|
|
1557
|
+
message: `Recall rules already current in ${targetPath}`
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
const next = block.ownsFile ? `${block.preamble ?? ""}${desired}` : mergeIntoExisting(existing, desired, block);
|
|
1561
|
+
mkdirSync4(dirname4(targetPath), { recursive: true });
|
|
1562
|
+
writeFileSync4(targetPath, next);
|
|
1563
|
+
return {
|
|
1564
|
+
ok: true,
|
|
1565
|
+
changed: true,
|
|
1566
|
+
config_path: targetPath,
|
|
1567
|
+
message: existing.length === 0 ? `Created ${targetPath} with Recall rules` : `Updated Recall rules in ${targetPath}`
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
function uninstallManagedRules(targetPath, block) {
|
|
1571
|
+
if (!existsSync4(targetPath)) {
|
|
1572
|
+
return { ok: true, changed: false, config_path: targetPath, message: `${targetPath} not present` };
|
|
1573
|
+
}
|
|
1574
|
+
const existing = readFileSync4(targetPath, "utf-8");
|
|
1575
|
+
if (!anyBeginMarkerRe(block).test(existing)) {
|
|
1576
|
+
return {
|
|
1577
|
+
ok: true,
|
|
1578
|
+
changed: false,
|
|
1579
|
+
config_path: targetPath,
|
|
1580
|
+
message: `No Recall-managed rules in ${targetPath}`
|
|
1581
|
+
};
|
|
1582
|
+
}
|
|
1583
|
+
const stripped = existing.replace(blockRe(block), "").replace(/\n{3,}/g, "\n\n");
|
|
1584
|
+
if (block.ownsFile && stripped.trim() === (block.preamble ?? "").trim()) {
|
|
1585
|
+
rmSync(targetPath, { force: true });
|
|
1586
|
+
return { ok: true, changed: true, config_path: targetPath, message: `Removed ${targetPath}` };
|
|
1587
|
+
}
|
|
1588
|
+
writeFileSync4(targetPath, stripped.trim().length === 0 ? "" : ensureTrailingNewline(stripped));
|
|
1589
|
+
return {
|
|
1590
|
+
ok: true,
|
|
1591
|
+
changed: true,
|
|
1592
|
+
config_path: targetPath,
|
|
1593
|
+
message: `Removed Recall rules from ${targetPath}`
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
function checkManagedRules(targetPath, block) {
|
|
1597
|
+
if (!existsSync4(targetPath)) {
|
|
1598
|
+
return { status: "absent_no_file", config_path: targetPath };
|
|
1599
|
+
}
|
|
1600
|
+
const content = readFileSync4(targetPath, "utf-8");
|
|
1601
|
+
if (!anyBeginMarkerRe(block).test(content)) {
|
|
1602
|
+
return { status: "missing", config_path: targetPath };
|
|
1603
|
+
}
|
|
1604
|
+
return {
|
|
1605
|
+
status: content.includes(beginMarker(block)) && content.includes(block.body) ? "current" : "stale",
|
|
1606
|
+
config_path: targetPath
|
|
1607
|
+
};
|
|
1608
|
+
}
|
|
1609
|
+
function mergeIntoExisting(existing, desired, block) {
|
|
1610
|
+
if (anyBeginMarkerRe(block).test(existing)) {
|
|
1611
|
+
return existing.replace(blockRe(block), desired);
|
|
1612
|
+
}
|
|
1613
|
+
if (existing.length === 0) return desired;
|
|
1614
|
+
const separator = existing.endsWith("\n\n") ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
|
|
1615
|
+
return `${existing}${separator}${desired}`;
|
|
1616
|
+
}
|
|
1617
|
+
function ensureTrailingNewline(content) {
|
|
1618
|
+
return content.endsWith("\n") ? content : `${content}
|
|
1619
|
+
`;
|
|
1620
|
+
}
|
|
1621
|
+
function escapeRegExp2(value) {
|
|
1622
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1623
|
+
}
|
|
1624
|
+
function buildRecallRulesBody(toolLabel) {
|
|
1625
|
+
return `## Recall (managed by \`recall setup\` \u2014 do not edit by hand)
|
|
1626
|
+
|
|
1627
|
+
Recall is the single source of truth for durable memory across agents and sessions. It is wired into ${toolLabel} through the \`recall\` MCP server.
|
|
1628
|
+
|
|
1629
|
+
- ${toolLabel} has no lifecycle hooks, so capture is **manual**: when the user corrects you, states a durable preference, or says "remember this", call \`capture_correction\` on the \`recall\` MCP server. Phrase it as \`always X\` / \`never Y\`.
|
|
1630
|
+
- Before non-trivial work in a repo, call \`query\` to pull relevant memories. Do it again when you move to an unfamiliar area.
|
|
1631
|
+
- A memory that turns out to be wrong or outdated: \`reject\` it. One that proves right: \`confirm\` it.
|
|
1632
|
+
- Do not keep a second memory store (scratch note files, tool-native memory) \u2014 it drifts from Recall.
|
|
1633
|
+
|
|
1634
|
+
Reinstall: \`recall setup\`. Remove: \`recall setup --uninstall-hooks\`.`;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
// src/agents/hookless.ts
|
|
1638
|
+
function createHooklessAdapter(spec) {
|
|
1639
|
+
const configPath3 = (options = {}) => spec.mcpTarget(options).configPath;
|
|
1640
|
+
return {
|
|
1641
|
+
name: spec.name,
|
|
1642
|
+
configPath: configPath3,
|
|
1643
|
+
detect(options = {}) {
|
|
1644
|
+
const byCommand = (spec.commands ?? []).some((command) => hasCommand(command));
|
|
1645
|
+
const byPath = (spec.markerPaths?.(options) ?? []).some((path) => existsSync5(path));
|
|
1646
|
+
return byCommand || byPath ? "installed" : "not-installed";
|
|
1647
|
+
},
|
|
1648
|
+
capabilities() {
|
|
1649
|
+
return {
|
|
1650
|
+
// No hook API: nothing observes prompts, tools or session lifecycle.
|
|
1651
|
+
supports: [],
|
|
1652
|
+
supports_hook_install: false,
|
|
1653
|
+
supports_mcp_fallback: true
|
|
1654
|
+
};
|
|
1655
|
+
},
|
|
1656
|
+
installHooks(_profile) {
|
|
1657
|
+
return {
|
|
1658
|
+
ok: false,
|
|
1659
|
+
changed: false,
|
|
1660
|
+
config_path: null,
|
|
1661
|
+
message: `${spec.label} exposes no hook API \u2014 use writeMcpFallback() and installRules() instead`
|
|
1662
|
+
};
|
|
1663
|
+
},
|
|
1664
|
+
uninstallHooks() {
|
|
1665
|
+
return {
|
|
1666
|
+
ok: true,
|
|
1667
|
+
changed: false,
|
|
1668
|
+
config_path: null,
|
|
1669
|
+
message: `${spec.label} has no Recall-managed hooks`
|
|
1670
|
+
};
|
|
1671
|
+
},
|
|
1672
|
+
envMapping: {},
|
|
1673
|
+
writeMcpFallback(options = {}) {
|
|
1674
|
+
const serverSpec = resolveServerSpec(options, spec.label);
|
|
1675
|
+
if ("error" in serverSpec) {
|
|
1676
|
+
return { ok: false, changed: false, config_path: null, message: serverSpec.error };
|
|
1677
|
+
}
|
|
1678
|
+
return writeMcpServerEntry(spec.mcpTarget(options), serverSpec);
|
|
1679
|
+
},
|
|
1680
|
+
removeMcpFallback(options = {}) {
|
|
1681
|
+
return removeMcpServerEntry(spec.mcpTarget(options));
|
|
1682
|
+
},
|
|
1683
|
+
hasMcpRegistration(options = {}) {
|
|
1684
|
+
return hasMcpServerEntry(spec.mcpTarget(options));
|
|
1685
|
+
},
|
|
1686
|
+
installRules(options = {}) {
|
|
1687
|
+
return installManagedRules(rulesTarget(spec, options), spec.rulesBlock);
|
|
1688
|
+
},
|
|
1689
|
+
uninstallRules(options = {}) {
|
|
1690
|
+
return uninstallManagedRules(rulesTarget(spec, options), spec.rulesBlock);
|
|
1691
|
+
},
|
|
1692
|
+
checkRules(options = {}) {
|
|
1693
|
+
return checkManagedRules(rulesTarget(spec, options), spec.rulesBlock);
|
|
1694
|
+
},
|
|
1695
|
+
rulesScope: spec.rulesScope
|
|
1696
|
+
};
|
|
1697
|
+
}
|
|
1698
|
+
function rulesTarget(spec, options) {
|
|
1699
|
+
return options.configPath ?? spec.rulesPath(options);
|
|
1700
|
+
}
|
|
1701
|
+
function resolveServerSpec(options, label) {
|
|
1702
|
+
const nodePath = options.nodePath ?? process.env.RECALL_NODE_PATH ?? process.execPath;
|
|
1703
|
+
const mcpPath = options.mcpPath ?? process.env.RECALL_MCP_PATH;
|
|
1704
|
+
if (!mcpPath) {
|
|
1705
|
+
return {
|
|
1706
|
+
error: `Unable to resolve the Recall MCP entrypoint for ${label} \u2014 pass mcpPath or set RECALL_MCP_PATH`
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
return { nodePath, mcpPath };
|
|
1710
|
+
}
|
|
1711
|
+
function projectPath(options, ...segments) {
|
|
1712
|
+
return resolve3(options.cwd ?? process.cwd(), ...segments);
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
// src/agents/cursor.ts
|
|
1716
|
+
var LABEL = "Cursor";
|
|
1717
|
+
function cursorHome(options = {}) {
|
|
1718
|
+
return join3(options.homeDir ?? resolveUserHomeDir(), ".cursor");
|
|
1719
|
+
}
|
|
1720
|
+
function cursorGlobalMcpPath(options = {}) {
|
|
1721
|
+
return join3(cursorHome(options), "mcp.json");
|
|
1722
|
+
}
|
|
1723
|
+
function cursorProjectMcpPath(options = {}) {
|
|
1724
|
+
return projectPath(options, ".cursor", "mcp.json");
|
|
1725
|
+
}
|
|
1726
|
+
function cursorRulesPath(options = {}) {
|
|
1727
|
+
return projectPath(options, ".cursor", "rules", "recall.mdc");
|
|
1728
|
+
}
|
|
1729
|
+
var CURSOR_MDC_FRONTMATTER = `---
|
|
1730
|
+
description: Route durable memory through the Recall MCP server
|
|
1731
|
+
alwaysApply: true
|
|
1732
|
+
---
|
|
1733
|
+
|
|
1734
|
+
`;
|
|
1735
|
+
var cursorAdapter = createHooklessAdapter({
|
|
1736
|
+
name: "cursor",
|
|
1737
|
+
label: LABEL,
|
|
1738
|
+
commands: ["cursor"],
|
|
1739
|
+
markerPaths: (options) => [cursorHome(options)],
|
|
1740
|
+
mcpTarget: (options) => ({
|
|
1741
|
+
configPath: options.configPath ?? (options.scope === "project" ? cursorProjectMcpPath(options) : cursorGlobalMcpPath(options)),
|
|
1742
|
+
containerKey: "mcpServers",
|
|
1743
|
+
buildEntry: commandArgsEntry
|
|
1744
|
+
}),
|
|
1745
|
+
rulesPath: (options) => cursorRulesPath(options),
|
|
1746
|
+
rulesBlock: {
|
|
1747
|
+
name: "memory",
|
|
1748
|
+
version: 1,
|
|
1749
|
+
body: buildRecallRulesBody(LABEL),
|
|
1750
|
+
ownsFile: true,
|
|
1751
|
+
preamble: CURSOR_MDC_FRONTMATTER
|
|
1752
|
+
},
|
|
1753
|
+
rulesScope: "project"
|
|
1754
|
+
});
|
|
1755
|
+
|
|
1756
|
+
// src/agents/gemini-cli.ts
|
|
1757
|
+
var geminiCliAdapter = {
|
|
1758
|
+
name: "gemini-cli",
|
|
1759
|
+
configPath() {
|
|
1760
|
+
return "";
|
|
1761
|
+
},
|
|
1762
|
+
detect() {
|
|
1763
|
+
return "not-installed";
|
|
1764
|
+
},
|
|
1765
|
+
capabilities() {
|
|
1766
|
+
return {
|
|
1767
|
+
supports: ["prompt_submitted", "tool_invoked", "session_ended"],
|
|
1768
|
+
supports_hook_install: false,
|
|
1769
|
+
supports_mcp_fallback: true
|
|
1770
|
+
};
|
|
1771
|
+
},
|
|
1772
|
+
installHooks(_profile) {
|
|
1773
|
+
throw new Error("Gemini CLI hook installation not implemented yet.");
|
|
1774
|
+
},
|
|
1775
|
+
uninstallHooks() {
|
|
1776
|
+
throw new Error("Gemini CLI hook removal not implemented yet.");
|
|
1777
|
+
},
|
|
1778
|
+
envMapping: {
|
|
1779
|
+
prompt_submitted: {
|
|
1780
|
+
prompt: "text",
|
|
1781
|
+
session_id: "session_id"
|
|
1782
|
+
},
|
|
1783
|
+
tool_invoked: {
|
|
1784
|
+
tool_name: "name",
|
|
1785
|
+
session_id: "session_id"
|
|
1786
|
+
},
|
|
1787
|
+
session_ended: {
|
|
1788
|
+
session_id: "session_id",
|
|
1789
|
+
reason: "reason"
|
|
1790
|
+
}
|
|
1791
|
+
},
|
|
1792
|
+
writeMcpFallback() {
|
|
1793
|
+
throw new Error("Gemini CLI MCP fallback wiring not implemented yet.");
|
|
1794
|
+
}
|
|
1795
|
+
};
|
|
1796
|
+
|
|
1797
|
+
// src/agents/github-copilot.ts
|
|
1798
|
+
import { join as join4 } from "path";
|
|
1799
|
+
var LABEL2 = "GitHub Copilot";
|
|
1800
|
+
function copilotHome(options = {}) {
|
|
1801
|
+
if (options.homeDir) return join4(options.homeDir, ".copilot");
|
|
1802
|
+
return process.env.COPILOT_HOME ?? join4(resolveUserHomeDir(), ".copilot");
|
|
1803
|
+
}
|
|
1804
|
+
function copilotMcpConfigPath(options = {}) {
|
|
1805
|
+
return join4(copilotHome(options), "mcp-config.json");
|
|
1806
|
+
}
|
|
1807
|
+
function copilotInstructionsPath(options = {}) {
|
|
1808
|
+
return projectPath(options, ".github", "copilot-instructions.md");
|
|
1809
|
+
}
|
|
1810
|
+
var githubCopilotAdapter = createHooklessAdapter({
|
|
1811
|
+
name: "github-copilot",
|
|
1812
|
+
label: LABEL2,
|
|
1813
|
+
commands: ["copilot"],
|
|
1814
|
+
markerPaths: (options) => [copilotHome(options)],
|
|
1815
|
+
mcpTarget: (options) => ({
|
|
1816
|
+
configPath: options.configPath ?? copilotMcpConfigPath(options),
|
|
1817
|
+
containerKey: "mcpServers",
|
|
1818
|
+
buildEntry: copilotEntry
|
|
1819
|
+
}),
|
|
1820
|
+
rulesPath: (options) => copilotInstructionsPath(options),
|
|
1821
|
+
rulesBlock: {
|
|
1822
|
+
name: "memory",
|
|
1823
|
+
version: 1,
|
|
1824
|
+
body: buildRecallRulesBody(LABEL2)
|
|
1825
|
+
},
|
|
1826
|
+
rulesScope: "project"
|
|
1827
|
+
});
|
|
1828
|
+
|
|
1829
|
+
// src/agents/opencode.ts
|
|
1830
|
+
import { join as join5 } from "path";
|
|
1831
|
+
var LABEL3 = "opencode";
|
|
1832
|
+
function opencodeConfigDir(options = {}) {
|
|
1833
|
+
return join5(options.homeDir ?? resolveUserHomeDir(), ".config", "opencode");
|
|
1834
|
+
}
|
|
1835
|
+
function opencodeConfigPath(options = {}) {
|
|
1836
|
+
return join5(opencodeConfigDir(options), "opencode.json");
|
|
1837
|
+
}
|
|
1838
|
+
function opencodeAgentsPath(options = {}) {
|
|
1839
|
+
return join5(opencodeConfigDir(options), "AGENTS.md");
|
|
1840
|
+
}
|
|
1841
|
+
var opencodeAdapter = createHooklessAdapter({
|
|
1842
|
+
name: "opencode",
|
|
1843
|
+
label: LABEL3,
|
|
1844
|
+
commands: ["opencode"],
|
|
1845
|
+
markerPaths: (options) => [opencodeConfigDir(options)],
|
|
1846
|
+
mcpTarget: (options) => ({
|
|
1847
|
+
configPath: options.configPath ?? opencodeConfigPath(options),
|
|
1848
|
+
// opencode nests servers directly under "mcp", not "mcpServers".
|
|
1849
|
+
containerKey: "mcp",
|
|
1850
|
+
buildEntry: opencodeEntry
|
|
1851
|
+
}),
|
|
1852
|
+
rulesPath: (options) => opencodeAgentsPath(options),
|
|
1853
|
+
rulesBlock: {
|
|
1854
|
+
name: "memory",
|
|
1855
|
+
version: 1,
|
|
1856
|
+
body: buildRecallRulesBody(LABEL3)
|
|
1857
|
+
},
|
|
1858
|
+
rulesScope: "global"
|
|
1859
|
+
});
|
|
1860
|
+
|
|
1861
|
+
// src/agents/qwen.ts
|
|
1862
|
+
var qwenAdapter = {
|
|
1863
|
+
name: "qwen",
|
|
1864
|
+
configPath() {
|
|
1865
|
+
return "";
|
|
1866
|
+
},
|
|
1867
|
+
detect() {
|
|
1868
|
+
return "not-installed";
|
|
1869
|
+
},
|
|
1870
|
+
capabilities() {
|
|
1871
|
+
return {
|
|
1872
|
+
supports: ["prompt_submitted", "tool_invoked", "session_ended"],
|
|
1873
|
+
supports_hook_install: false,
|
|
1874
|
+
supports_mcp_fallback: true
|
|
1875
|
+
};
|
|
1876
|
+
},
|
|
1877
|
+
installHooks(_profile) {
|
|
1878
|
+
throw new Error("Qwen hook installation not implemented yet.");
|
|
1879
|
+
},
|
|
1880
|
+
uninstallHooks() {
|
|
1881
|
+
throw new Error("Qwen hook removal not implemented yet.");
|
|
1882
|
+
},
|
|
1883
|
+
envMapping: {
|
|
1884
|
+
prompt_submitted: {
|
|
1885
|
+
prompt: "text",
|
|
1886
|
+
session_id: "session_id"
|
|
1887
|
+
},
|
|
1888
|
+
tool_invoked: {
|
|
1889
|
+
tool_name: "name",
|
|
1890
|
+
session_id: "session_id"
|
|
1891
|
+
},
|
|
1892
|
+
session_ended: {
|
|
1893
|
+
session_id: "session_id",
|
|
1894
|
+
reason: "reason"
|
|
1895
|
+
}
|
|
1896
|
+
},
|
|
1897
|
+
writeMcpFallback() {
|
|
1898
|
+
throw new Error("Qwen MCP fallback wiring not implemented yet.");
|
|
1899
|
+
}
|
|
1900
|
+
};
|
|
1901
|
+
|
|
1902
|
+
// src/agents/windsurf.ts
|
|
1903
|
+
import { join as join6 } from "path";
|
|
1904
|
+
var LABEL4 = "Windsurf";
|
|
1905
|
+
function windsurfConfigDir(options = {}) {
|
|
1906
|
+
return join6(options.homeDir ?? resolveUserHomeDir(), ".codeium", "windsurf");
|
|
1907
|
+
}
|
|
1908
|
+
function windsurfMcpConfigPath(options = {}) {
|
|
1909
|
+
return join6(windsurfConfigDir(options), "mcp_config.json");
|
|
1910
|
+
}
|
|
1911
|
+
function windsurfGlobalRulesPath(options = {}) {
|
|
1912
|
+
return join6(windsurfConfigDir(options), "memories", "global_rules.md");
|
|
1913
|
+
}
|
|
1914
|
+
var windsurfAdapter = createHooklessAdapter({
|
|
1915
|
+
name: "windsurf",
|
|
1916
|
+
label: LABEL4,
|
|
1917
|
+
commands: ["windsurf"],
|
|
1918
|
+
markerPaths: (options) => [windsurfConfigDir(options)],
|
|
1919
|
+
mcpTarget: (options) => ({
|
|
1920
|
+
configPath: options.configPath ?? windsurfMcpConfigPath(options),
|
|
1921
|
+
containerKey: "mcpServers",
|
|
1922
|
+
buildEntry: commandArgsEntry
|
|
1923
|
+
}),
|
|
1924
|
+
rulesPath: (options) => windsurfGlobalRulesPath(options),
|
|
1925
|
+
rulesBlock: {
|
|
1926
|
+
name: "memory",
|
|
1927
|
+
version: 1,
|
|
1928
|
+
body: buildRecallRulesBody(LABEL4)
|
|
1929
|
+
},
|
|
1930
|
+
rulesScope: "global"
|
|
1931
|
+
});
|
|
1932
|
+
|
|
1933
|
+
// src/agents/index.ts
|
|
1934
|
+
var adapters = {
|
|
1935
|
+
"claude-code": claudeCodeAdapter,
|
|
1936
|
+
codex: codexAdapter,
|
|
1937
|
+
"github-copilot": githubCopilotAdapter,
|
|
1938
|
+
opencode: opencodeAdapter,
|
|
1939
|
+
cursor: cursorAdapter,
|
|
1940
|
+
windsurf: windsurfAdapter,
|
|
1941
|
+
"gemini-cli": geminiCliAdapter,
|
|
1942
|
+
qwen: qwenAdapter
|
|
1943
|
+
};
|
|
1944
|
+
var hooklessAgents = [
|
|
1945
|
+
"github-copilot",
|
|
1946
|
+
"opencode",
|
|
1947
|
+
"cursor",
|
|
1948
|
+
"windsurf"
|
|
1949
|
+
];
|
|
1950
|
+
function listAgentNames() {
|
|
1951
|
+
return Object.keys(adapters);
|
|
1952
|
+
}
|
|
1953
|
+
function isHooklessAgent(name) {
|
|
1954
|
+
return hooklessAgents.includes(name);
|
|
1955
|
+
}
|
|
1956
|
+
function resolveAdapter(name) {
|
|
1957
|
+
const adapter = adapters[name];
|
|
1958
|
+
if (adapter) {
|
|
1959
|
+
return adapter;
|
|
1960
|
+
}
|
|
1961
|
+
throw new Error(
|
|
1962
|
+
`Unknown agent adapter: ${name}. Supported adapters: ${listAgentNames().join(", ")}. Reserved v2 stubs: gemini-cli, qwen.`
|
|
1963
|
+
);
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1259
1966
|
// src/setup/local.ts
|
|
1260
1967
|
function resolveRuntimePaths(appPath) {
|
|
1261
|
-
if (appPath || process.platform === "darwin" &&
|
|
1968
|
+
if (appPath || process.platform === "darwin" && existsSync6("/Applications/Recall.app")) {
|
|
1262
1969
|
const resolvedAppPath = appPath ?? "/Applications/Recall.app";
|
|
1263
|
-
const runtimeRoot =
|
|
1970
|
+
const runtimeRoot = join7(resolvedAppPath, "Contents", "Resources", "Runtime");
|
|
1264
1971
|
return {
|
|
1265
1972
|
appPath: resolvedAppPath,
|
|
1266
|
-
runtimeNodePath:
|
|
1267
|
-
runtimeCliPath:
|
|
1268
|
-
runtimeMcpPath:
|
|
1973
|
+
runtimeNodePath: join7(runtimeRoot, "bin", "node"),
|
|
1974
|
+
runtimeCliPath: join7(runtimeRoot, "dist", "cli.js"),
|
|
1975
|
+
runtimeMcpPath: join7(runtimeRoot, "dist", "mcp.js")
|
|
1269
1976
|
};
|
|
1270
1977
|
}
|
|
1271
|
-
const distDir =
|
|
1978
|
+
const distDir = dirname5(fileURLToPath3(import.meta.url));
|
|
1272
1979
|
return {
|
|
1273
1980
|
appPath: distDir,
|
|
1274
1981
|
runtimeNodePath: process.execPath,
|
|
1275
|
-
runtimeCliPath:
|
|
1276
|
-
runtimeMcpPath:
|
|
1982
|
+
runtimeCliPath: join7(distDir, "cli.js"),
|
|
1983
|
+
runtimeMcpPath: join7(distDir, "mcp.js")
|
|
1277
1984
|
};
|
|
1278
1985
|
}
|
|
1279
1986
|
function runLocalSetup(opts = {}) {
|
|
@@ -1313,17 +2020,17 @@ function runRecallSetup(opts = {}) {
|
|
|
1313
2020
|
const uninstallHooks = opts.uninstallHooks ?? false;
|
|
1314
2021
|
const runner = opts.runner ?? defaultRunner;
|
|
1315
2022
|
const paths = resolveRuntimePaths(opts.appPath);
|
|
1316
|
-
if (!
|
|
2023
|
+
if (!existsSync6(paths.runtimeNodePath)) {
|
|
1317
2024
|
throw new Error(`Node runtime not found at ${paths.runtimeNodePath}`);
|
|
1318
2025
|
}
|
|
1319
|
-
if (!
|
|
2026
|
+
if (!existsSync6(paths.runtimeCliPath)) {
|
|
1320
2027
|
throw new Error(`Recall CLI entry not found at ${paths.runtimeCliPath}`);
|
|
1321
2028
|
}
|
|
1322
|
-
if (!
|
|
2029
|
+
if (!existsSync6(paths.runtimeMcpPath)) {
|
|
1323
2030
|
throw new Error(`Recall MCP entry not found at ${paths.runtimeMcpPath}`);
|
|
1324
2031
|
}
|
|
1325
2032
|
const targetAgents = resolveTargetAgents(opts.agent);
|
|
1326
|
-
const cwd =
|
|
2033
|
+
const cwd = resolve4(opts.cwd ?? process.cwd());
|
|
1327
2034
|
const claudeMdEnabled = opts.claudeMd ?? true;
|
|
1328
2035
|
const agents = targetAgents.map(
|
|
1329
2036
|
(agent) => setupAgent(agent, {
|
|
@@ -1351,15 +2058,30 @@ function runRecallSetup(opts = {}) {
|
|
|
1351
2058
|
}
|
|
1352
2059
|
function setupAgent(agent, options) {
|
|
1353
2060
|
const detected = detectAgent(agent);
|
|
1354
|
-
const
|
|
2061
|
+
const hookless = isHooklessAgent(agent);
|
|
2062
|
+
const hookConfigPath = hookless ? null : resolveHookConfigPath(agent, options.scope, options.cwd);
|
|
1355
2063
|
const mcp = options.hooksOnly ? skipped("hooks-only") : configureMcp(agent, options);
|
|
1356
|
-
const hooks = options.mcpOnly ? skipped("mcp-only") : configureHooks(agent, {
|
|
2064
|
+
const hooks = options.mcpOnly ? skipped("mcp-only") : hookless ? skipped(`${agent} exposes no hook API \u2014 memory routes through MCP + rules file`) : configureHooks(agent, {
|
|
1357
2065
|
configPath: hookConfigPath,
|
|
1358
2066
|
dryRun: options.dryRun,
|
|
1359
2067
|
paths: options.paths,
|
|
1360
2068
|
uninstallHooks: options.uninstallHooks,
|
|
1361
2069
|
promptInjection: options.promptInjection
|
|
1362
2070
|
});
|
|
2071
|
+
let rules;
|
|
2072
|
+
let rulesPath = null;
|
|
2073
|
+
if (hookless && !options.mcpOnly) {
|
|
2074
|
+
const adapter = resolveAdapter(agent);
|
|
2075
|
+
if (options.dryRun) {
|
|
2076
|
+
rules = ok(
|
|
2077
|
+
options.uninstallHooks ? "would remove Recall rules block" : "would install Recall rules block"
|
|
2078
|
+
);
|
|
2079
|
+
} else {
|
|
2080
|
+
const result = options.uninstallHooks ? adapter.uninstallRules({ cwd: options.cwd }) : adapter.installRules({ cwd: options.cwd });
|
|
2081
|
+
rules = { enabled: true, ok: result.ok, message: result.message };
|
|
2082
|
+
rulesPath = result.config_path;
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
1363
2085
|
let claudeMd;
|
|
1364
2086
|
let claudeMdPath2 = null;
|
|
1365
2087
|
if (agent === "claude-code" && !options.mcpOnly && options.claudeMd !== false) {
|
|
@@ -1382,10 +2104,31 @@ function setupAgent(agent, options) {
|
|
|
1382
2104
|
hooks,
|
|
1383
2105
|
hook_config_path: options.mcpOnly ? null : hookConfigPath,
|
|
1384
2106
|
claude_md: claudeMd,
|
|
1385
|
-
claude_md_path: claudeMdPath2
|
|
2107
|
+
claude_md_path: claudeMdPath2,
|
|
2108
|
+
rules,
|
|
2109
|
+
rules_path: rulesPath
|
|
1386
2110
|
};
|
|
1387
2111
|
}
|
|
1388
2112
|
function configureMcp(agent, options) {
|
|
2113
|
+
if (isHooklessAgent(agent)) {
|
|
2114
|
+
const adapter = resolveAdapter(agent);
|
|
2115
|
+
if (adapter.detect() !== "installed") {
|
|
2116
|
+
return skipped(`${agent} not detected`);
|
|
2117
|
+
}
|
|
2118
|
+
if (options.dryRun) {
|
|
2119
|
+
return ok(`would register Recall MCP server in ${adapter.configPath()}`);
|
|
2120
|
+
}
|
|
2121
|
+
const result = adapter.writeMcpFallback({
|
|
2122
|
+
nodePath: options.paths.runtimeNodePath,
|
|
2123
|
+
mcpPath: options.paths.runtimeMcpPath,
|
|
2124
|
+
scope: options.scope,
|
|
2125
|
+
cwd: options.cwd
|
|
2126
|
+
});
|
|
2127
|
+
return { enabled: true, ok: result.ok, message: result.message };
|
|
2128
|
+
}
|
|
2129
|
+
if (agent === "gemini-cli" || agent === "qwen") {
|
|
2130
|
+
return skipped(`${agent} adapter is a reserved stub`);
|
|
2131
|
+
}
|
|
1389
2132
|
if (agent === "codex") {
|
|
1390
2133
|
if (!hasCommand("codex")) return skipped("codex not found on PATH");
|
|
1391
2134
|
if (options.scope === "project") {
|
|
@@ -1413,7 +2156,7 @@ function configureHooks(agent, options) {
|
|
|
1413
2156
|
options.uninstallHooks ? `would remove hooks from ${options.configPath}` : `would install hooks into ${options.configPath}${options.promptInjection === false ? " (prompt injection opt-out)" : ""}`
|
|
1414
2157
|
);
|
|
1415
2158
|
}
|
|
1416
|
-
const codexHooksPath = agent === "codex" ?
|
|
2159
|
+
const codexHooksPath = agent === "codex" ? join7(dirname5(options.configPath), "hooks.json") : void 0;
|
|
1417
2160
|
const result = agent === "claude-code" ? options.uninstallHooks ? uninstallClaudeCodeHooks({ configPath: options.configPath }) : installClaudeCodeHooks({
|
|
1418
2161
|
configPath: options.configPath,
|
|
1419
2162
|
cliPath: options.paths.runtimeCliPath,
|
|
@@ -1436,22 +2179,22 @@ function resolveTargetAgents(target) {
|
|
|
1436
2179
|
if (target && target.length > 0) {
|
|
1437
2180
|
return [...new Set(target)];
|
|
1438
2181
|
}
|
|
1439
|
-
|
|
1440
|
-
if (detectAgent("codex")) detected.push("codex");
|
|
1441
|
-
if (detectAgent("claude-code")) detected.push("claude-code");
|
|
1442
|
-
return detected;
|
|
2182
|
+
return listAgentNames().filter((agent) => detectAgent(agent));
|
|
1443
2183
|
}
|
|
1444
2184
|
function detectAgent(agent) {
|
|
1445
2185
|
if (agent === "codex") {
|
|
1446
|
-
return hasCommand("codex") ||
|
|
2186
|
+
return hasCommand("codex") || existsSync6(join7(resolveUserHomeDir(), ".codex", "config.toml"));
|
|
2187
|
+
}
|
|
2188
|
+
if (agent === "claude-code") {
|
|
2189
|
+
return hasCommand("claude") || existsSync6(join7(resolveUserHomeDir(), ".claude", "settings.json"));
|
|
1447
2190
|
}
|
|
1448
|
-
return
|
|
2191
|
+
return resolveAdapter(agent).detect() === "installed";
|
|
1449
2192
|
}
|
|
1450
2193
|
function resolveHookConfigPath(agent, scope, cwd) {
|
|
1451
2194
|
if (scope === "project") {
|
|
1452
|
-
return agent === "codex" ?
|
|
2195
|
+
return agent === "codex" ? join7(cwd, ".codex", "config.toml") : join7(cwd, ".claude", "settings.json");
|
|
1453
2196
|
}
|
|
1454
|
-
return agent === "codex" ?
|
|
2197
|
+
return agent === "codex" ? join7(resolveUserHomeDir(), ".codex", "config.toml") : join7(resolveUserHomeDir(), ".claude", "settings.json");
|
|
1455
2198
|
}
|
|
1456
2199
|
function defaultRunner(command, args) {
|
|
1457
2200
|
execFileSync3(command, args, stdioOpts());
|
|
@@ -1480,22 +2223,22 @@ import { createRequire } from "module";
|
|
|
1480
2223
|
import { pathToFileURL } from "url";
|
|
1481
2224
|
|
|
1482
2225
|
// src/doctor/report.ts
|
|
1483
|
-
import { existsSync as
|
|
1484
|
-
import { join as
|
|
2226
|
+
import { existsSync as existsSync9, readFileSync as readFileSync6 } from "fs";
|
|
2227
|
+
import { join as join10 } from "path";
|
|
1485
2228
|
import Database from "better-sqlite3";
|
|
1486
2229
|
|
|
1487
2230
|
// src/daemon/launchd.ts
|
|
1488
|
-
import { existsSync as
|
|
2231
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync5, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
|
|
1489
2232
|
import { homedir as homedir2 } from "os";
|
|
1490
|
-
import { dirname as
|
|
2233
|
+
import { dirname as dirname6, join as join8, resolve as resolve5 } from "path";
|
|
1491
2234
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
1492
2235
|
var DEFAULT_LABEL = "com.recall.daemon";
|
|
1493
2236
|
function installLaunchAgent(opts = {}) {
|
|
1494
2237
|
assertDarwin();
|
|
1495
2238
|
const cfg = resolveConfig(opts);
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
2239
|
+
mkdirSync5(dirname6(cfg.plistPath), { recursive: true });
|
|
2240
|
+
mkdirSync5(dirname6(cfg.stdoutPath), { recursive: true });
|
|
2241
|
+
writeFileSync5(cfg.plistPath, renderPlist(cfg));
|
|
1499
2242
|
tryRun2("launchctl", ["bootout", domainTarget(), cfg.plistPath]);
|
|
1500
2243
|
execFileSync4("launchctl", ["bootstrap", domainTarget(), cfg.plistPath], stdioOpts2());
|
|
1501
2244
|
execFileSync4("launchctl", ["enable", `${domainTarget()}/${cfg.label}`], stdioOpts2());
|
|
@@ -1507,7 +2250,7 @@ function uninstallLaunchAgent(label = DEFAULT_LABEL) {
|
|
|
1507
2250
|
const cfg = resolveConfig({ label });
|
|
1508
2251
|
tryRun2("launchctl", ["bootout", domainTarget(), cfg.plistPath]);
|
|
1509
2252
|
tryRun2("launchctl", ["disable", `${domainTarget()}/${cfg.label}`]);
|
|
1510
|
-
|
|
2253
|
+
rmSync2(cfg.plistPath, { force: true });
|
|
1511
2254
|
return getLaunchAgentStatus(cfg.label);
|
|
1512
2255
|
}
|
|
1513
2256
|
function startLaunchAgent(label = DEFAULT_LABEL) {
|
|
@@ -1582,15 +2325,15 @@ function resolveConfig(opts) {
|
|
|
1582
2325
|
const home = homedir2();
|
|
1583
2326
|
const port = opts.port ?? parseInt(process.env.RECALL_PORT ?? "7890", 10);
|
|
1584
2327
|
const maintenanceIntervalSeconds = opts.maintenanceIntervalSeconds ?? parseInt(process.env.RECALL_MAINTENANCE_INTERVAL_SECONDS ?? "300", 10);
|
|
1585
|
-
const dataDir =
|
|
1586
|
-
opts.dataDir ?? process.env.RECALL_DATA_DIR ??
|
|
2328
|
+
const dataDir = resolve5(
|
|
2329
|
+
opts.dataDir ?? process.env.RECALL_DATA_DIR ?? join8(home, ".recall")
|
|
1587
2330
|
);
|
|
1588
|
-
const nodePath =
|
|
1589
|
-
const daemonScript =
|
|
1590
|
-
opts.daemonScript ??
|
|
2331
|
+
const nodePath = resolve5(opts.nodePath ?? process.execPath);
|
|
2332
|
+
const daemonScript = resolve5(
|
|
2333
|
+
opts.daemonScript ?? join8(process.cwd(), "dist", "daemon.js")
|
|
1591
2334
|
);
|
|
1592
|
-
const plistPath =
|
|
1593
|
-
const logDir =
|
|
2335
|
+
const plistPath = join8(home, "Library", "LaunchAgents", `${label}.plist`);
|
|
2336
|
+
const logDir = join8(dataDir, "logs");
|
|
1594
2337
|
return {
|
|
1595
2338
|
label,
|
|
1596
2339
|
port,
|
|
@@ -1599,8 +2342,8 @@ function resolveConfig(opts) {
|
|
|
1599
2342
|
nodePath,
|
|
1600
2343
|
daemonScript,
|
|
1601
2344
|
plistPath,
|
|
1602
|
-
stdoutPath:
|
|
1603
|
-
stderrPath:
|
|
2345
|
+
stdoutPath: join8(logDir, "daemon.stdout.log"),
|
|
2346
|
+
stderrPath: join8(logDir, "daemon.stderr.log"),
|
|
1604
2347
|
repoRoots: opts.repoRoots ?? process.env.RECALL_REPO_ROOTS,
|
|
1605
2348
|
embeddingProvider: opts.embeddingProvider ?? process.env.RECALL_EMBEDDING_PROVIDER,
|
|
1606
2349
|
embeddingDims: opts.embeddingDims ?? process.env.RECALL_EMBEDDING_DIMS,
|
|
@@ -1726,7 +2469,7 @@ function stdioOpts2() {
|
|
|
1726
2469
|
};
|
|
1727
2470
|
}
|
|
1728
2471
|
function exists(path) {
|
|
1729
|
-
return
|
|
2472
|
+
return existsSync7(path);
|
|
1730
2473
|
}
|
|
1731
2474
|
function escapeXml(value) {
|
|
1732
2475
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
@@ -1738,18 +2481,18 @@ function assertDarwin() {
|
|
|
1738
2481
|
}
|
|
1739
2482
|
|
|
1740
2483
|
// src/daemon/systemd.ts
|
|
1741
|
-
import { existsSync as
|
|
2484
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync5, rmSync as rmSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
1742
2485
|
import { homedir as homedir3 } from "os";
|
|
1743
|
-
import { dirname as
|
|
2486
|
+
import { dirname as dirname7, join as join9, resolve as resolve6 } from "path";
|
|
1744
2487
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
1745
2488
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
1746
2489
|
var DEFAULT_LABEL2 = "recall-daemon";
|
|
1747
2490
|
function installSystemdUnit(opts = {}) {
|
|
1748
2491
|
assertLinux();
|
|
1749
2492
|
const cfg = resolveConfig2(opts);
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
2493
|
+
mkdirSync6(dirname7(cfg.unitPath), { recursive: true });
|
|
2494
|
+
mkdirSync6(cfg.logDir, { recursive: true });
|
|
2495
|
+
writeFileSync6(cfg.unitPath, renderUnit(cfg));
|
|
1753
2496
|
systemctl(["--user", "daemon-reload"]);
|
|
1754
2497
|
systemctl(["--user", "enable", "--now", `${cfg.label}.service`]);
|
|
1755
2498
|
return getSystemdStatus(cfg.label);
|
|
@@ -1758,14 +2501,14 @@ function uninstallSystemdUnit(label = DEFAULT_LABEL2) {
|
|
|
1758
2501
|
assertLinux();
|
|
1759
2502
|
const cfg = resolveConfig2({ label });
|
|
1760
2503
|
trySystemctl(["--user", "disable", "--now", `${cfg.label}.service`]);
|
|
1761
|
-
|
|
2504
|
+
rmSync3(cfg.unitPath, { force: true });
|
|
1762
2505
|
trySystemctl(["--user", "daemon-reload"]);
|
|
1763
2506
|
return getSystemdStatus(cfg.label);
|
|
1764
2507
|
}
|
|
1765
2508
|
function startSystemdUnit(label = DEFAULT_LABEL2) {
|
|
1766
2509
|
assertLinux();
|
|
1767
2510
|
const cfg = resolveConfig2({ label });
|
|
1768
|
-
if (!
|
|
2511
|
+
if (!existsSync8(cfg.unitPath)) {
|
|
1769
2512
|
throw new Error(`systemd unit not installed: ${cfg.unitPath}`);
|
|
1770
2513
|
}
|
|
1771
2514
|
systemctl(["--user", "start", `${cfg.label}.service`]);
|
|
@@ -1774,7 +2517,7 @@ function startSystemdUnit(label = DEFAULT_LABEL2) {
|
|
|
1774
2517
|
function stopSystemdUnit(label = DEFAULT_LABEL2) {
|
|
1775
2518
|
assertLinux();
|
|
1776
2519
|
const cfg = resolveConfig2({ label });
|
|
1777
|
-
if (
|
|
2520
|
+
if (existsSync8(cfg.unitPath)) {
|
|
1778
2521
|
trySystemctl(["--user", "stop", `${cfg.label}.service`]);
|
|
1779
2522
|
}
|
|
1780
2523
|
return getSystemdStatus(cfg.label);
|
|
@@ -1782,7 +2525,7 @@ function stopSystemdUnit(label = DEFAULT_LABEL2) {
|
|
|
1782
2525
|
function getSystemdStatus(label = DEFAULT_LABEL2) {
|
|
1783
2526
|
assertLinux();
|
|
1784
2527
|
const cfg = resolveConfig2({ label });
|
|
1785
|
-
const installed =
|
|
2528
|
+
const installed = existsSync8(cfg.unitPath);
|
|
1786
2529
|
const active = trySystemctlOutput(["--user", "is-active", `${cfg.label}.service`]);
|
|
1787
2530
|
const loaded = active.ok && active.output.trim() === "active";
|
|
1788
2531
|
const state = active.output.trim() || void 0;
|
|
@@ -1831,16 +2574,16 @@ function resolveConfig2(opts) {
|
|
|
1831
2574
|
const home = homedir3();
|
|
1832
2575
|
const port = opts.port ?? parseInt(process.env.RECALL_PORT ?? "7890", 10);
|
|
1833
2576
|
const maintenanceIntervalSeconds = opts.maintenanceIntervalSeconds ?? parseInt(process.env.RECALL_MAINTENANCE_INTERVAL_SECONDS ?? "300", 10);
|
|
1834
|
-
const dataDir =
|
|
1835
|
-
opts.dataDir ?? process.env.RECALL_DATA_DIR ??
|
|
2577
|
+
const dataDir = resolve6(
|
|
2578
|
+
opts.dataDir ?? process.env.RECALL_DATA_DIR ?? join9(home, ".recall")
|
|
1836
2579
|
);
|
|
1837
|
-
const nodePath =
|
|
1838
|
-
const daemonScript =
|
|
2580
|
+
const nodePath = resolve6(opts.nodePath ?? process.execPath);
|
|
2581
|
+
const daemonScript = resolve6(
|
|
1839
2582
|
opts.daemonScript ?? defaultDaemonScript()
|
|
1840
2583
|
);
|
|
1841
|
-
const configHome = process.env.XDG_CONFIG_HOME ??
|
|
1842
|
-
const unitPath =
|
|
1843
|
-
const logDir =
|
|
2584
|
+
const configHome = process.env.XDG_CONFIG_HOME ?? join9(home, ".config");
|
|
2585
|
+
const unitPath = join9(configHome, "systemd", "user", `${label}.service`);
|
|
2586
|
+
const logDir = join9(dataDir, "logs");
|
|
1844
2587
|
return {
|
|
1845
2588
|
label,
|
|
1846
2589
|
port,
|
|
@@ -1857,8 +2600,8 @@ function resolveConfig2(opts) {
|
|
|
1857
2600
|
};
|
|
1858
2601
|
}
|
|
1859
2602
|
function defaultDaemonScript() {
|
|
1860
|
-
const here =
|
|
1861
|
-
return
|
|
2603
|
+
const here = dirname7(fileURLToPath4(import.meta.url));
|
|
2604
|
+
return join9(here, "daemon.js");
|
|
1862
2605
|
}
|
|
1863
2606
|
function renderUnit(cfg) {
|
|
1864
2607
|
const envLines = [
|
|
@@ -1887,13 +2630,13 @@ WantedBy=default.target
|
|
|
1887
2630
|
`;
|
|
1888
2631
|
}
|
|
1889
2632
|
function readInstalledConfig2(unitPath) {
|
|
1890
|
-
if (!
|
|
2633
|
+
if (!existsSync8(unitPath)) return null;
|
|
1891
2634
|
try {
|
|
1892
|
-
const raw =
|
|
2635
|
+
const raw = readFileSync5(unitPath, "utf8");
|
|
1893
2636
|
const exec = raw.match(/^ExecStart=(.+)$/m)?.[1]?.trim().split(/\s+/);
|
|
1894
2637
|
const env = {};
|
|
1895
2638
|
for (const m of raw.matchAll(/^Environment=([^=]+)=(.+)$/gm)) {
|
|
1896
|
-
env
|
|
2639
|
+
defineOwn(env, m[1], m[2]);
|
|
1897
2640
|
}
|
|
1898
2641
|
return {
|
|
1899
2642
|
nodePath: exec?.[0],
|
|
@@ -1982,7 +2725,7 @@ function getDoctorReport() {
|
|
|
1982
2725
|
};
|
|
1983
2726
|
}
|
|
1984
2727
|
function readDispatcherHealth(dbPath) {
|
|
1985
|
-
if (!
|
|
2728
|
+
if (!existsSync9(dbPath)) return null;
|
|
1986
2729
|
let sqlite = null;
|
|
1987
2730
|
try {
|
|
1988
2731
|
sqlite = new Database(dbPath, { readonly: true, fileMustExist: true });
|
|
@@ -2030,7 +2773,7 @@ function readDispatcherHealth(dbPath) {
|
|
|
2030
2773
|
}
|
|
2031
2774
|
}
|
|
2032
2775
|
function readCleanupHealth(dbPath) {
|
|
2033
|
-
if (!
|
|
2776
|
+
if (!existsSync9(dbPath)) return null;
|
|
2034
2777
|
let sqlite = null;
|
|
2035
2778
|
try {
|
|
2036
2779
|
sqlite = new Database(dbPath, { readonly: true, fileMustExist: true });
|
|
@@ -2105,7 +2848,7 @@ function computeUpgradeSignal(agents) {
|
|
|
2105
2848
|
}
|
|
2106
2849
|
if (agent.mcp && !agent.hooks) {
|
|
2107
2850
|
reasons.push(
|
|
2108
|
-
`${agent.agent}: MCP configured but lifecycle hooks missing \u2014 memory injection depends on the model calling query`
|
|
2851
|
+
agent.hookless ? `${agent.agent}: MCP configured but the Recall rules block is missing or stale \u2014 run \`recall setup\`` : `${agent.agent}: MCP configured but lifecycle hooks missing \u2014 memory injection depends on the model calling query`
|
|
2109
2852
|
);
|
|
2110
2853
|
}
|
|
2111
2854
|
}
|
|
@@ -2115,18 +2858,49 @@ function inspectAgentInstalls(homeDir) {
|
|
|
2115
2858
|
const home = homeDir ?? resolveUserHomeDir();
|
|
2116
2859
|
return [
|
|
2117
2860
|
inspectClaudeCodeInstall(home),
|
|
2118
|
-
inspectCodexInstall(home)
|
|
2861
|
+
inspectCodexInstall(home),
|
|
2862
|
+
// Hookless agents are only listed once detected — most users have none of
|
|
2863
|
+
// them and four permanent "not detected" rows would just be noise.
|
|
2864
|
+
...listAgentNames().filter((agent) => isHooklessAgent(agent)).map((agent) => inspectHooklessInstall(agent, home)).filter((entry) => entry !== null)
|
|
2119
2865
|
];
|
|
2120
2866
|
}
|
|
2867
|
+
function inspectHooklessInstall(agent, home) {
|
|
2868
|
+
const adapter = resolveAdapter(agent);
|
|
2869
|
+
if (adapter.detect({ homeDir: home }) !== "installed") return null;
|
|
2870
|
+
const configPath3 = adapter.configPath({ homeDir: home });
|
|
2871
|
+
const mcp = adapter.hasMcpRegistration?.({ homeDir: home }) ?? false;
|
|
2872
|
+
const rules = adapter.checkRules?.({ homeDir: home });
|
|
2873
|
+
const notes = [];
|
|
2874
|
+
if (!mcp) {
|
|
2875
|
+
notes.push(`Recall MCP server not registered in ${configPath3} \u2014 run \`recall setup\``);
|
|
2876
|
+
}
|
|
2877
|
+
if (rules && rules.status !== "current") {
|
|
2878
|
+
notes.push(
|
|
2879
|
+
rules.status === "stale" ? `Recall rules block in ${rules.config_path} is out of date \u2014 run \`recall setup\`` : `No Recall rules block in ${rules.config_path} \u2014 ${agent} will not capture memories on its own`
|
|
2880
|
+
);
|
|
2881
|
+
}
|
|
2882
|
+
return {
|
|
2883
|
+
agent,
|
|
2884
|
+
detected: true,
|
|
2885
|
+
mcp,
|
|
2886
|
+
// No hook API exists, so "hooks" tracks the rules block that stands in for it.
|
|
2887
|
+
hooks: rules?.status === "current",
|
|
2888
|
+
hookless: true,
|
|
2889
|
+
config_path: configPath3,
|
|
2890
|
+
rules: rules?.status,
|
|
2891
|
+
rules_path: rules?.config_path,
|
|
2892
|
+
notes
|
|
2893
|
+
};
|
|
2894
|
+
}
|
|
2121
2895
|
function inspectClaudeCodeInstall(home) {
|
|
2122
|
-
const configPath3 =
|
|
2123
|
-
const detected =
|
|
2896
|
+
const configPath3 = join10(home, ".claude", "settings.json");
|
|
2897
|
+
const detected = existsSync9(configPath3) || hasCommand("claude");
|
|
2124
2898
|
const notes = [];
|
|
2125
2899
|
let mcp = false;
|
|
2126
2900
|
let hooks = false;
|
|
2127
|
-
if (
|
|
2901
|
+
if (existsSync9(configPath3)) {
|
|
2128
2902
|
try {
|
|
2129
|
-
const parsed = JSON.parse(
|
|
2903
|
+
const parsed = JSON.parse(readFileSync6(configPath3, "utf-8"));
|
|
2130
2904
|
mcp = Boolean(parsed?.mcpServers?.recall);
|
|
2131
2905
|
const hookGroups = parsed?.hooks ?? {};
|
|
2132
2906
|
hooks = Object.values(hookGroups).some(
|
|
@@ -2143,7 +2917,7 @@ function inspectClaudeCodeInstall(home) {
|
|
|
2143
2917
|
notes.push("Claude CLI detected but settings.json missing");
|
|
2144
2918
|
}
|
|
2145
2919
|
const claudeMd = checkClaudeCodeMemoryOverride({
|
|
2146
|
-
configPath:
|
|
2920
|
+
configPath: join10(home, ".claude", "CLAUDE.md")
|
|
2147
2921
|
});
|
|
2148
2922
|
if (claudeMd.status === "stale") {
|
|
2149
2923
|
notes.push("CLAUDE.md memory-override block is out of date \u2014 run `recall doctor --fix`");
|
|
@@ -2164,18 +2938,18 @@ function inspectClaudeCodeInstall(home) {
|
|
|
2164
2938
|
};
|
|
2165
2939
|
}
|
|
2166
2940
|
function inspectCodexInstall(home) {
|
|
2167
|
-
const configPath3 =
|
|
2168
|
-
const hooksPath =
|
|
2169
|
-
const detected =
|
|
2941
|
+
const configPath3 = join10(home, ".codex", "config.toml");
|
|
2942
|
+
const hooksPath = join10(home, ".codex", "hooks.json");
|
|
2943
|
+
const detected = existsSync9(configPath3) || hasCommand("codex");
|
|
2170
2944
|
const notes = [];
|
|
2171
2945
|
let mcp = false;
|
|
2172
2946
|
let hooks = false;
|
|
2173
2947
|
let legacy_notify_bridge = false;
|
|
2174
|
-
if (
|
|
2175
|
-
const raw =
|
|
2948
|
+
if (existsSync9(configPath3)) {
|
|
2949
|
+
const raw = readFileSync6(configPath3, "utf-8");
|
|
2176
2950
|
mcp = /\[mcp_servers\.recall\]/.test(raw);
|
|
2177
2951
|
const featureFlagSet = /^\s*(?:codex_)?hooks\s*=\s*true\b/m.test(raw);
|
|
2178
|
-
const managedHooksJson =
|
|
2952
|
+
const managedHooksJson = existsSync9(hooksPath) && readFileSync6(hooksPath, "utf-8").includes("recall:managed:codex");
|
|
2179
2953
|
hooks = featureFlagSet && managedHooksJson;
|
|
2180
2954
|
legacy_notify_bridge = raw.includes("# recall:managed:codex:start") && raw.includes("codex-notify");
|
|
2181
2955
|
if (!mcp) notes.push("MCP block [mcp_servers.recall] not in config.toml");
|
|
@@ -2231,16 +3005,16 @@ function formatDoctorReport(report) {
|
|
|
2231
3005
|
}
|
|
2232
3006
|
lines.push("", "## Agents");
|
|
2233
3007
|
for (const agent of report.agents) {
|
|
2234
|
-
const label = agent.agent.padEnd(
|
|
3008
|
+
const label = agent.agent.padEnd(14);
|
|
2235
3009
|
if (!agent.detected) {
|
|
2236
3010
|
lines.push(`${label} not detected`);
|
|
2237
3011
|
continue;
|
|
2238
3012
|
}
|
|
2239
3013
|
const mcp = agent.mcp ? "ok" : "MISSING";
|
|
2240
|
-
const hooks = agent.hooks ? "ok" : "MISSING";
|
|
2241
3014
|
const legacy = agent.legacy_notify_bridge ? " (legacy notify bridge)" : "";
|
|
2242
3015
|
const claudeMd = agent.claude_md ? ` claude.md:${agent.claude_md === "current" ? "ok" : agent.claude_md.toUpperCase()}` : "";
|
|
2243
|
-
|
|
3016
|
+
const wiring = agent.hookless ? ` rules:${agent.rules === "current" ? "ok" : (agent.rules ?? "missing").toUpperCase()}` : ` hooks:${agent.hooks ? "ok" : "MISSING"}`;
|
|
3017
|
+
lines.push(`${label} mcp:${mcp}${wiring}${claudeMd}${legacy}`);
|
|
2244
3018
|
for (const note of agent.notes) {
|
|
2245
3019
|
lines.push(` - ${note}`);
|
|
2246
3020
|
}
|
|
@@ -2469,6 +3243,12 @@ setupCmd.option("--app-path <path>", "Override Recall.app path", "/Applications/
|
|
|
2469
3243
|
console.log(` file: ${agent.claude_md_path}`);
|
|
2470
3244
|
}
|
|
2471
3245
|
}
|
|
3246
|
+
if (agent.rules) {
|
|
3247
|
+
console.log(` rules: ${formatSetupStep(agent.rules)}`);
|
|
3248
|
+
if (agent.rules_path) {
|
|
3249
|
+
console.log(` file: ${agent.rules_path}`);
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
2472
3252
|
}
|
|
2473
3253
|
});
|
|
2474
3254
|
setupCmd.command("local").description("Configure local agent MCP + hooks against the installed Recall.app").option("--app-path <path>", "Override Recall.app path", "/Applications/Recall.app").option("--codex-only", "Configure only Codex").option("--claude-only", "Configure only Claude").option("--no-prompt-injection", "Opt out of per-prompt memory injection (writes RECALL_HOOK_INJECT_PROMPT=false inline into the agent hook command)").option("--no-claude-md", "Skip installing the managed CLAUDE.md memory-override block for Claude Code").action((opts) => {
|
|
@@ -2498,20 +3278,20 @@ function safeHookAction(event, action) {
|
|
|
2498
3278
|
} catch (error) {
|
|
2499
3279
|
let logPath = "~/.recall/logs/hook-errors.log";
|
|
2500
3280
|
try {
|
|
2501
|
-
const { appendFileSync, mkdirSync:
|
|
3281
|
+
const { appendFileSync, mkdirSync: mkdirSync7, statSync, renameSync: renameSync4, rmSync: rmSync4 } = await import("fs");
|
|
2502
3282
|
const { homedir: homedir4 } = await import("os");
|
|
2503
|
-
const dir =
|
|
2504
|
-
|
|
2505
|
-
logPath =
|
|
3283
|
+
const dir = join11(homedir4(), ".recall", "logs");
|
|
3284
|
+
mkdirSync7(dir, { recursive: true });
|
|
3285
|
+
logPath = join11(dir, "hook-errors.log");
|
|
2506
3286
|
try {
|
|
2507
3287
|
const maxBytes = parseInt(process.env.RECALL_HOOK_LOG_MAX_BYTES ?? String(1024 * 1024), 10);
|
|
2508
3288
|
if (maxBytes > 0 && statSync(logPath).size >= maxBytes) {
|
|
2509
3289
|
const rotated = `${logPath}.1`;
|
|
2510
3290
|
try {
|
|
2511
|
-
|
|
3291
|
+
rmSync4(rotated, { force: true });
|
|
2512
3292
|
} catch {
|
|
2513
3293
|
}
|
|
2514
|
-
|
|
3294
|
+
renameSync4(logPath, rotated);
|
|
2515
3295
|
}
|
|
2516
3296
|
} catch {
|
|
2517
3297
|
}
|
|
@@ -2659,7 +3439,7 @@ program.command("ump").description("Serve the Universal Memory Protocol (UMP) ov
|
|
|
2659
3439
|
});
|
|
2660
3440
|
program.command("scan").description("Scan a repository and bootstrap memories").argument("[path]", "Repository path", ".").option("-s, --session <id>", "Session ID").action((path, opts) => {
|
|
2661
3441
|
const db = initDb();
|
|
2662
|
-
const repoPath =
|
|
3442
|
+
const repoPath = resolve7(path);
|
|
2663
3443
|
const ids = scanAndStore(db, repoPath);
|
|
2664
3444
|
const artifact = writeRepoContextArtifact(db, {
|
|
2665
3445
|
repo: inferRepoSlugFromPath(repoPath),
|
|
@@ -2668,10 +3448,10 @@ program.command("scan").description("Scan a repository and bootstrap memories").
|
|
|
2668
3448
|
const scanned = ids.map((id) => getMemory(db, id)).filter((mem) => mem != null);
|
|
2669
3449
|
const activeCount = scanned.filter((mem) => mem.status === "active").length;
|
|
2670
3450
|
const candidateCount = scanned.filter((mem) => mem.status === "candidate").length;
|
|
2671
|
-
console.log(
|
|
3451
|
+
console.log("Scanned repo:", { path: repoPath });
|
|
2672
3452
|
console.log(`Created ${ids.length} memories (${activeCount} active, ${candidateCount} candidate).`);
|
|
2673
3453
|
if (artifact.output_path) {
|
|
2674
|
-
console.log(
|
|
3454
|
+
console.log("Updated context artifact:", { path: artifact.output_path });
|
|
2675
3455
|
}
|
|
2676
3456
|
createActivityEvent(db, {
|
|
2677
3457
|
session_id: opts.session ?? null,
|
|
@@ -2905,7 +3685,7 @@ program.command("export").description("Export memories as markdown instruction f
|
|
|
2905
3685
|
console.error(`Could not resolve local repo path for ${opts.repo}`);
|
|
2906
3686
|
process.exit(1);
|
|
2907
3687
|
}
|
|
2908
|
-
content =
|
|
3688
|
+
content = readFileSync7(artifact.output_path, "utf-8");
|
|
2909
3689
|
if (!opts.output) {
|
|
2910
3690
|
console.log(content);
|
|
2911
3691
|
return;
|
|
@@ -2916,7 +3696,7 @@ program.command("export").description("Export memories as markdown instruction f
|
|
|
2916
3696
|
content = exportMarkdown(db, opts.repo);
|
|
2917
3697
|
}
|
|
2918
3698
|
if (opts.output) {
|
|
2919
|
-
|
|
3699
|
+
writeFileSync7(opts.output, content);
|
|
2920
3700
|
console.log(`Exported to ${opts.output}`);
|
|
2921
3701
|
} else {
|
|
2922
3702
|
console.log(content);
|
|
@@ -2924,7 +3704,7 @@ program.command("export").description("Export memories as markdown instruction f
|
|
|
2924
3704
|
});
|
|
2925
3705
|
program.command("publish").description("Write repo-local .recall/context.md for the current repo").argument("[path]", "Repository path", ".").action((path) => {
|
|
2926
3706
|
const db = initDb();
|
|
2927
|
-
const repoPath =
|
|
3707
|
+
const repoPath = resolve7(path);
|
|
2928
3708
|
const artifact = writeRepoContextArtifact(db, {
|
|
2929
3709
|
repo: inferRepoSlugFromPath(repoPath),
|
|
2930
3710
|
repo_path: repoPath
|
|
@@ -2933,7 +3713,7 @@ program.command("publish").description("Write repo-local .recall/context.md for
|
|
|
2933
3713
|
console.error(`Could not write repo-local context for ${repoPath}`);
|
|
2934
3714
|
process.exit(1);
|
|
2935
3715
|
}
|
|
2936
|
-
console.log(
|
|
3716
|
+
console.log("Wrote context artifact:", { path: artifact.output_path });
|
|
2937
3717
|
});
|
|
2938
3718
|
var historyCmd = program.command("history").description("Inspect rolled-up history snippets");
|
|
2939
3719
|
historyCmd.command("list").description("List history snippets").option("-r, --repo <repo>", "Filter by repository").option("-s, --session <id>", "Filter by session id").option("-k, --kind <kind>", "Filter by kind").option("-n, --limit <n>", "Limit results", "20").action((opts) => {
|
|
@@ -3053,7 +3833,7 @@ evalCmd.command("value-retrieval").description("Run retrieval eval cases synthes
|
|
|
3053
3833
|
});
|
|
3054
3834
|
let snapshot = null;
|
|
3055
3835
|
if (opts.snapshot) {
|
|
3056
|
-
const { computeQualityReport, recordQualitySnapshot } = await import("./quality-
|
|
3836
|
+
const { computeQualityReport, recordQualitySnapshot } = await import("./quality-UUEBGSAQ.js");
|
|
3057
3837
|
const qualityReport = computeQualityReport(db, { sinceIso: report.since });
|
|
3058
3838
|
snapshot = recordQualitySnapshot(
|
|
3059
3839
|
db,
|
|
@@ -3539,15 +4319,15 @@ uiCmd.command("status").description("Show WebUI status").option("--daemon-port <
|
|
|
3539
4319
|
var graphCmd = program.command("graph").description("Inspect and rebuild the knowledge graph (entities + relations)");
|
|
3540
4320
|
graphCmd.command("stats").description("Show entity/relation counts").action(async () => {
|
|
3541
4321
|
const db = initDb();
|
|
3542
|
-
const { countEntities, countRelations } = await import("./store-
|
|
4322
|
+
const { countEntities, countRelations } = await import("./store-5C7ZKKZF.js");
|
|
3543
4323
|
console.log(`entities: ${countEntities(db)}`);
|
|
3544
4324
|
console.log(`relations: ${countRelations(db)}`);
|
|
3545
4325
|
});
|
|
3546
4326
|
graphCmd.command("backfill").description("Run the heuristic extractor over every active memory (idempotent)").option("--repo <repo>", "Limit to a single repo").option("--limit <n>", "Cap rows processed", "10000").option("--rebuild", "Clear all existing entities/relations first, then re-extract").action(async (opts) => {
|
|
3547
4327
|
const db = initDb();
|
|
3548
|
-
const { ingestMemoryHeuristic } = await import("./ingest-
|
|
4328
|
+
const { ingestMemoryHeuristic } = await import("./ingest-7FAOX7YV.js");
|
|
3549
4329
|
if (opts.rebuild) {
|
|
3550
|
-
const { clearGraph } = await import("./store-
|
|
4330
|
+
const { clearGraph } = await import("./store-5C7ZKKZF.js");
|
|
3551
4331
|
clearGraph(db);
|
|
3552
4332
|
console.log("Cleared existing graph entities and relations.");
|
|
3553
4333
|
}
|
|
@@ -3569,7 +4349,7 @@ graphCmd.command("backfill").description("Run the heuristic extractor over every
|
|
|
3569
4349
|
});
|
|
3570
4350
|
graphCmd.command("entities").description("List entities").option("--repo <repo>", "Filter by repo").option("--kind <kind>", "Filter by entity kind").option("--search <q>", "Substring filter on name").option("--limit <n>", "Max rows", "50").action(async (opts) => {
|
|
3571
4351
|
const db = initDb();
|
|
3572
|
-
const { listEntities } = await import("./store-
|
|
4352
|
+
const { listEntities } = await import("./store-5C7ZKKZF.js");
|
|
3573
4353
|
const rows = listEntities(db, {
|
|
3574
4354
|
repo: opts.repo,
|
|
3575
4355
|
kind: opts.kind,
|
|
@@ -3588,8 +4368,8 @@ graphCmd.command("entities").description("List entities").option("--repo <repo>"
|
|
|
3588
4368
|
});
|
|
3589
4369
|
graphCmd.command("query <query...>").description("Run graph-aware retrieval for a query").option("--repo <repo>", "Restrict to repo").option("--hops <n>", "Graph hops", "2").option("--limit <n>", "Max hits", "10").action(async (queryTokens, opts) => {
|
|
3590
4370
|
const db = initDb();
|
|
3591
|
-
const { graphQuery } = await import("./retrieval-
|
|
3592
|
-
const { loadEmbeddingConfigFromEnv: loadEmbeddingConfigFromEnv2 } = await import("./embeddings-
|
|
4371
|
+
const { graphQuery } = await import("./retrieval-YU2PLBUS.js");
|
|
4372
|
+
const { loadEmbeddingConfigFromEnv: loadEmbeddingConfigFromEnv2 } = await import("./embeddings-E362AC3R.js");
|
|
3593
4373
|
const embeddingConfig = loadEmbeddingConfigFromEnv2();
|
|
3594
4374
|
const result = await graphQuery(db, queryTokens.join(" "), embeddingConfig, {
|
|
3595
4375
|
repo: opts.repo,
|
|
@@ -3605,7 +4385,7 @@ graphCmd.command("query <query...>").description("Run graph-aware retrieval for
|
|
|
3605
4385
|
});
|
|
3606
4386
|
var maintenanceCmd = program.command("maintenance").description("Inspect and manage the delegated maintenance task queue");
|
|
3607
4387
|
maintenanceCmd.command("stats").description("Show backlog counts, completion stats, and mean latency").action(async () => {
|
|
3608
|
-
const { getTaskStats } = await import("./tasks-
|
|
4388
|
+
const { getTaskStats } = await import("./tasks-AEKGKZZF.js");
|
|
3609
4389
|
const db = initDb();
|
|
3610
4390
|
const stats = getTaskStats(db);
|
|
3611
4391
|
console.log(`Total tasks: ${stats.total}`);
|
|
@@ -3631,7 +4411,7 @@ maintenanceCmd.command("stats").description("Show backlog counts, completion sta
|
|
|
3631
4411
|
}
|
|
3632
4412
|
});
|
|
3633
4413
|
maintenanceCmd.command("list").description("List tasks (default: pending)").option("-s, --status <status>", "pending|claimed|completed|abandoned", "pending").option("-k, --kind <kind>", "Filter by kind").option("-r, --repo <repo>", "Filter by repo").option("-n, --limit <n>", "Max entries", "20").action(async (opts) => {
|
|
3634
|
-
const { listTasks } = await import("./tasks-
|
|
4414
|
+
const { listTasks } = await import("./tasks-AEKGKZZF.js");
|
|
3635
4415
|
const db = initDb();
|
|
3636
4416
|
const tasks = listTasks(db, {
|
|
3637
4417
|
status: opts.status,
|
|
@@ -3653,7 +4433,7 @@ maintenanceCmd.command("list").description("List tasks (default: pending)").opti
|
|
|
3653
4433
|
}
|
|
3654
4434
|
});
|
|
3655
4435
|
maintenanceCmd.command("drop").description("Delete a task by id (or id prefix)").argument("<task-id>", "Task id or prefix").action(async (taskIdArg) => {
|
|
3656
|
-
const { deleteTask, listTasks } = await import("./tasks-
|
|
4436
|
+
const { deleteTask, listTasks } = await import("./tasks-AEKGKZZF.js");
|
|
3657
4437
|
const db = initDb();
|
|
3658
4438
|
const all = listTasks(db, { limit: 1e4 });
|
|
3659
4439
|
const matches = all.filter((t) => t.id === taskIdArg || t.id.startsWith(taskIdArg));
|
|
@@ -3672,7 +4452,7 @@ maintenanceCmd.command("drop").description("Delete a task by id (or id prefix)")
|
|
|
3672
4452
|
});
|
|
3673
4453
|
var credentialsCmd = maintenanceCmd.command("credentials").description("Manage LLM provider API keys in macOS Keychain (env fallback on other platforms)");
|
|
3674
4454
|
credentialsCmd.command("list", { isDefault: true }).description("Show which providers have credentials available").action(async () => {
|
|
3675
|
-
const { listCredentials } = await import("./keychain-
|
|
4455
|
+
const { listCredentials } = await import("./keychain-PWFWKTZW.js");
|
|
3676
4456
|
const creds = listCredentials();
|
|
3677
4457
|
if (creds.length === 0) {
|
|
3678
4458
|
console.log("No API keys configured. Set one with:");
|
|
@@ -3686,7 +4466,7 @@ credentialsCmd.command("list", { isDefault: true }).description("Show which prov
|
|
|
3686
4466
|
}
|
|
3687
4467
|
});
|
|
3688
4468
|
credentialsCmd.command("set").description("Store credentials for an LLM provider in the macOS Keychain").argument("<provider>", "openai|anthropic|azure").argument("[key]", "API key (prompts via stdin if omitted; required for openai/anthropic and for azure unless --stdin-json is used)").option("--endpoint <url>", "Azure OpenAI resource endpoint (e.g. https://myresource.openai.azure.com)").option("--deployment <name>", "Azure OpenAI deployment name").option("--api-version <version>", "Azure OpenAI api-version (e.g. 2024-10-21)").option("--stdin-json", "Read the azure config (endpoint/deployment/api_version/key) as a JSON object from stdin").action(async (providerArg, keyArg, opts) => {
|
|
3689
|
-
const { setApiKey, setAzureConfig } = await import("./keychain-
|
|
4469
|
+
const { setApiKey, setAzureConfig } = await import("./keychain-PWFWKTZW.js");
|
|
3690
4470
|
const provider = providerArg === "azure" ? "azure-openai" : providerArg;
|
|
3691
4471
|
if (provider === "openai" || provider === "anthropic") {
|
|
3692
4472
|
const key = keyArg ?? await readStdinKey();
|
|
@@ -3748,7 +4528,7 @@ credentialsCmd.command("set").description("Store credentials for an LLM provider
|
|
|
3748
4528
|
process.exit(1);
|
|
3749
4529
|
});
|
|
3750
4530
|
credentialsCmd.command("clear").description("Remove provider credentials from the macOS Keychain").argument("<provider>", "openai|anthropic|azure").action(async (providerArg) => {
|
|
3751
|
-
const { deleteApiKey } = await import("./keychain-
|
|
4531
|
+
const { deleteApiKey } = await import("./keychain-PWFWKTZW.js");
|
|
3752
4532
|
const provider = providerArg === "azure" ? "azure-openai" : providerArg;
|
|
3753
4533
|
if (provider !== "openai" && provider !== "anthropic" && provider !== "azure-openai") {
|
|
3754
4534
|
console.error(`Provider must be "openai", "anthropic", or "azure", got "${providerArg}".`);
|
|
@@ -3759,8 +4539,8 @@ credentialsCmd.command("clear").description("Remove provider credentials from th
|
|
|
3759
4539
|
else console.log(`No ${provider} credentials found in Keychain.`);
|
|
3760
4540
|
});
|
|
3761
4541
|
maintenanceCmd.command("dispatch").description("Run the daemon-owned dispatcher once against pending maintenance tasks (requires a configured LLM provider)").option("--provider <provider>", "openai|anthropic|azure-openai (defaults to whichever is configured)").option("--model <model>", "Model override").option("--kind <kind>", "Restrict to a single task kind (repeatable)", (value, acc = []) => [...acc, value], []).option("--repo <repo>", "Restrict to a single repo").option("--max <n>", "Max tasks to run this round", "5").option("--dry-run", "Show which tasks would be dispatched; do not call the LLM").option("--preview", "Show the actual prompts that would be sent (no provider needed; no LLM call)").option("--json", "Emit the raw JSON report").action(async (opts) => {
|
|
3762
|
-
const { dispatchPendingTasks, formatDispatchReport, buildPrompt } = await import("./dispatcher-
|
|
3763
|
-
const { listTasks } = await import("./tasks-
|
|
4542
|
+
const { dispatchPendingTasks, formatDispatchReport, buildPrompt } = await import("./dispatcher-YN6545TF.js");
|
|
4543
|
+
const { listTasks } = await import("./tasks-AEKGKZZF.js");
|
|
3764
4544
|
const db = initDb();
|
|
3765
4545
|
if (opts.preview) {
|
|
3766
4546
|
const pending = listTasks(db, {
|
|
@@ -3817,7 +4597,7 @@ ${p.prompt.max_output_tokens}
|
|
|
3817
4597
|
console.log(formatDispatchReport(report));
|
|
3818
4598
|
});
|
|
3819
4599
|
maintenanceCmd.command("cleanup").description("Run deterministic, LLM-free cleanup for duplicate, low-quality, stale, and mis-scoped memories").option("--apply", "Persist changes (default is dry-run)").option("--only <action>", "Restrict to one action: dedupe_exact_merge|reject_fragment_candidate|promote_repeat_correction|suppress_unproductive_command|globalize_cross_repo|reject_test_fixture_repo|reject_invalid_scope|reject_generic_scanned_tooling").option("--revert <run-id>", "Revert a previous cleanup run (id or 8-char prefix)").option("--list", "List recent cleanup runs").option("--json", "Emit the raw JSON report").action(async (opts) => {
|
|
3820
|
-
const { runDeterministicCleanup, formatCleanupReport, revertCleanupRun, listCleanupRuns } = await import("./cleanup-
|
|
4600
|
+
const { runDeterministicCleanup, formatCleanupReport, revertCleanupRun, listCleanupRuns } = await import("./cleanup-MBXKIGT6.js");
|
|
3821
4601
|
const db = initDb();
|
|
3822
4602
|
if (opts.list) {
|
|
3823
4603
|
const runs = listCleanupRuns(db);
|
|
@@ -3871,7 +4651,7 @@ maintenanceCmd.command("quality").description("Show injection outcome distributi
|
|
|
3871
4651
|
recordQualitySnapshot,
|
|
3872
4652
|
listQualitySnapshots,
|
|
3873
4653
|
diffQualitySnapshots
|
|
3874
|
-
} = await import("./quality-
|
|
4654
|
+
} = await import("./quality-UUEBGSAQ.js");
|
|
3875
4655
|
const db = initDb();
|
|
3876
4656
|
if (opts.history) {
|
|
3877
4657
|
const snaps = listQualitySnapshots(db);
|
|
@@ -3932,7 +4712,7 @@ maintenanceCmd.command("value-backfill").description("Backfill memory value even
|
|
|
3932
4712
|
const {
|
|
3933
4713
|
backfillMemoryValueEvents,
|
|
3934
4714
|
formatMemoryValueBackfillReport
|
|
3935
|
-
} = await import("./memory-value-
|
|
4715
|
+
} = await import("./memory-value-ZLVZTE5M.js");
|
|
3936
4716
|
const db = initDb();
|
|
3937
4717
|
const report = backfillMemoryValueEvents(db, {
|
|
3938
4718
|
sinceIso: opts.since,
|
|
@@ -3945,7 +4725,7 @@ maintenanceCmd.command("value-backfill").description("Backfill memory value even
|
|
|
3945
4725
|
console.log(formatMemoryValueBackfillReport(report));
|
|
3946
4726
|
});
|
|
3947
4727
|
maintenanceCmd.command("usage").description("Summarize LLM API usage (tokens, cost) across recent maintenance runs").option("--since <iso>", "Window start (default: last 30 days)").option("--limit <n>", "Recent-call rows to show", "10").option("--json", "Emit raw JSON summary").action(async (opts) => {
|
|
3948
|
-
const { summarizeUsage, formatUsageReport } = await import("./usage-
|
|
4728
|
+
const { summarizeUsage, formatUsageReport } = await import("./usage-VQ5LJCNH.js");
|
|
3949
4729
|
const db = initDb();
|
|
3950
4730
|
const summary = summarizeUsage(db, {
|
|
3951
4731
|
sinceIso: opts.since,
|
|
@@ -3988,8 +4768,18 @@ function formatSetupStep(step) {
|
|
|
3988
4768
|
if (!step.enabled) return `skipped (${step.message})`;
|
|
3989
4769
|
return step.ok ? `ok (${step.message})` : `error (${step.message})`;
|
|
3990
4770
|
}
|
|
4771
|
+
var AGENT_LABELS = {
|
|
4772
|
+
"claude-code": "Claude Code",
|
|
4773
|
+
codex: "Codex",
|
|
4774
|
+
"github-copilot": "GitHub Copilot",
|
|
4775
|
+
opencode: "opencode",
|
|
4776
|
+
cursor: "Cursor",
|
|
4777
|
+
windsurf: "Windsurf",
|
|
4778
|
+
"gemini-cli": "Gemini CLI",
|
|
4779
|
+
qwen: "Qwen"
|
|
4780
|
+
};
|
|
3991
4781
|
function formatAgentName(agent) {
|
|
3992
|
-
return agent
|
|
4782
|
+
return AGENT_LABELS[agent] ?? agent;
|
|
3993
4783
|
}
|
|
3994
4784
|
function collectAgents(value, previous) {
|
|
3995
4785
|
return [...previous, value];
|