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