@edihasaj/recall 1.4.1 → 1.4.15

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.
Files changed (86) hide show
  1. package/README.md +17 -7
  2. package/dist/{chunk-WZWXYBP6.js → chunk-2E7UCWNS.js} +6 -3
  3. package/dist/{chunk-WZWXYBP6.js.map → chunk-2E7UCWNS.js.map} +1 -1
  4. package/dist/{chunk-JYWURG5T.js → chunk-5W3CDNJ6.js} +12 -2
  5. package/dist/chunk-5W3CDNJ6.js.map +1 -0
  6. package/dist/chunk-ADWOKDF6.js +23 -0
  7. package/dist/chunk-ADWOKDF6.js.map +1 -0
  8. package/dist/{chunk-CW3XJDH7.js → chunk-FDIV6YFT.js} +6 -2
  9. package/dist/{chunk-CW3XJDH7.js.map → chunk-FDIV6YFT.js.map} +1 -1
  10. package/dist/{chunk-EAFRT7RX.js → chunk-GMRT5DJZ.js} +7 -2
  11. package/dist/{chunk-EAFRT7RX.js.map → chunk-GMRT5DJZ.js.map} +1 -1
  12. package/dist/{chunk-PUMEMKGF.js → chunk-IMCI2CLJ.js} +7 -1
  13. package/dist/{chunk-PUMEMKGF.js.map → chunk-IMCI2CLJ.js.map} +1 -1
  14. package/dist/{chunk-ZBQGZCFL.js → chunk-KF3EGZWM.js} +99 -9
  15. package/dist/chunk-KF3EGZWM.js.map +1 -0
  16. package/dist/{chunk-NAYFAUSM.js → chunk-LCIVSUQO.js} +61 -21
  17. package/dist/chunk-LCIVSUQO.js.map +1 -0
  18. package/dist/{chunk-LWY4Z626.js → chunk-MESKBXZZ.js} +8 -4
  19. package/dist/{chunk-LWY4Z626.js.map → chunk-MESKBXZZ.js.map} +1 -1
  20. package/dist/{chunk-FHEH6QDU.js → chunk-PQOGHXET.js} +6 -1
  21. package/dist/{chunk-FHEH6QDU.js.map → chunk-PQOGHXET.js.map} +1 -1
  22. package/dist/{chunk-ZXCKMEJA.js → chunk-RRNELZJV.js} +11 -6
  23. package/dist/{chunk-ZXCKMEJA.js.map → chunk-RRNELZJV.js.map} +1 -1
  24. package/dist/{chunk-7CFX774S.js → chunk-SWPXUPMX.js} +306 -167
  25. package/dist/chunk-SWPXUPMX.js.map +1 -0
  26. package/dist/{chunk-T274LVWB.js → chunk-TZ4EU4SW.js} +15 -11
  27. package/dist/chunk-TZ4EU4SW.js.map +1 -0
  28. package/dist/chunk-UTOM43G2.js +594 -0
  29. package/dist/chunk-UTOM43G2.js.map +1 -0
  30. package/dist/{chunk-AFD43EOE.js → chunk-UZ4GFLH6.js} +8 -4
  31. package/dist/{chunk-AFD43EOE.js.map → chunk-UZ4GFLH6.js.map} +1 -1
  32. package/dist/{chunk-LUIYWYOT.js → chunk-VI6NOUXB.js} +51 -3
  33. package/dist/chunk-VI6NOUXB.js.map +1 -0
  34. package/dist/{chunk-TA4WSV6A.js → chunk-VZ456OCO.js} +204 -13
  35. package/dist/chunk-VZ456OCO.js.map +1 -0
  36. package/dist/{chunk-4UHRAQFG.js → chunk-ZECQ2LQB.js} +376 -58
  37. package/dist/chunk-ZECQ2LQB.js.map +1 -0
  38. package/dist/{cleanup-RTL2UETA.js → cleanup-KXCEVJ7V.js} +11 -10
  39. package/dist/cli.js +639 -784
  40. package/dist/cli.js.map +1 -1
  41. package/dist/codex-trust-H7VKP4G3.js +74 -0
  42. package/dist/codex-trust-H7VKP4G3.js.map +1 -0
  43. package/dist/daemon.js +174 -54
  44. package/dist/daemon.js.map +1 -1
  45. package/dist/dispatcher-GHC6RX54.js +22 -0
  46. package/dist/{embeddings-MILTROKW.js → embeddings-GYQBZWBD.js} +7 -5
  47. package/dist/ingest-6GDZNYCY.js +20 -0
  48. package/dist/{keychain-5KXUHKMF.js → keychain-TKPVUZCH.js} +3 -3
  49. package/dist/mcp.js +18 -14
  50. package/dist/mcp.js.map +1 -1
  51. package/dist/{memory-value-WXI2Q6TO.js → memory-value-A4UCC3DY.js} +11 -10
  52. package/dist/provenance-M5YFD6DO.js +50 -0
  53. package/dist/provenance-M5YFD6DO.js.map +1 -0
  54. package/dist/quality-TQ7CVPRO.js +25 -0
  55. package/dist/retrieval-7R5LKJAM.js +15 -0
  56. package/dist/{store-5C7ZKKZF.js → store-QKP6HQ45.js} +4 -4
  57. package/dist/sync-server.js +5 -2
  58. package/dist/sync-server.js.map +1 -1
  59. package/dist/{tasks-7SE6VHSQ.js → tasks-M5HSQSWK.js} +11 -10
  60. package/dist/{usage-VQ5LJCNH.js → usage-TQTOHPL7.js} +7 -4
  61. package/dist/{usage-VQ5LJCNH.js.map → usage-TQTOHPL7.js.map} +1 -1
  62. package/drizzle/0011_compact_telemetry_dedupe_keys.sql +25 -0
  63. package/drizzle/meta/_journal.json +7 -0
  64. package/package.json +15 -12
  65. package/dist/chunk-4UHRAQFG.js.map +0 -1
  66. package/dist/chunk-7CFX774S.js.map +0 -1
  67. package/dist/chunk-LUIYWYOT.js.map +0 -1
  68. package/dist/chunk-NAYFAUSM.js.map +0 -1
  69. package/dist/chunk-T274LVWB.js.map +0 -1
  70. package/dist/chunk-TA4WSV6A.js.map +0 -1
  71. package/dist/chunk-ZBQGZCFL.js.map +0 -1
  72. package/dist/dispatcher-PP5OKOLS.js +0 -21
  73. package/dist/ingest-HEXVIAL6.js +0 -19
  74. package/dist/quality-VKQUCL66.js +0 -24
  75. package/dist/retrieval-4MEIABHC.js +0 -14
  76. package/dist/tasks-7SE6VHSQ.js.map +0 -1
  77. /package/dist/{chunk-JYWURG5T.js.map → cleanup-KXCEVJ7V.js.map} +0 -0
  78. /package/dist/{cleanup-RTL2UETA.js.map → dispatcher-GHC6RX54.js.map} +0 -0
  79. /package/dist/{dispatcher-PP5OKOLS.js.map → embeddings-GYQBZWBD.js.map} +0 -0
  80. /package/dist/{embeddings-MILTROKW.js.map → ingest-6GDZNYCY.js.map} +0 -0
  81. /package/dist/{ingest-HEXVIAL6.js.map → keychain-TKPVUZCH.js.map} +0 -0
  82. /package/dist/{keychain-5KXUHKMF.js.map → memory-value-A4UCC3DY.js.map} +0 -0
  83. /package/dist/{memory-value-WXI2Q6TO.js.map → quality-TQ7CVPRO.js.map} +0 -0
  84. /package/dist/{quality-VKQUCL66.js.map → retrieval-7R5LKJAM.js.map} +0 -0
  85. /package/dist/{retrieval-4MEIABHC.js.map → store-QKP6HQ45.js.map} +0 -0
  86. /package/dist/{store-5C7ZKKZF.js.map → tasks-M5HSQSWK.js.map} +0 -0
package/dist/cli.js CHANGED
@@ -1,4 +1,13 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ codexAdapter,
4
+ hasCommand,
5
+ installCodexHooks,
6
+ resolveCodexHomes,
7
+ resolveCodexHookTargets,
8
+ resolveUserHomeDir,
9
+ uninstallCodexHooks
10
+ } from "./chunk-UTOM43G2.js";
2
11
  import {
3
12
  dispatchCodexNotify,
4
13
  ensureDailyBackup,
@@ -11,6 +20,10 @@ import {
11
20
  formatMaintenanceBacklogContext,
12
21
  formatPendingConfirmationsContext,
13
22
  getHookCallStats,
23
+ handleAssistantCompletionHook,
24
+ handleSessionEndHook,
25
+ handleSessionStartHook,
26
+ handleToolHook,
14
27
  listBackups,
15
28
  parseInteger,
16
29
  parseRecentToolCallsOption,
@@ -22,8 +35,9 @@ import {
22
35
  readCodexSessionEndInputFromStdin,
23
36
  readCodexSessionStartInputFromStdin,
24
37
  readCodexToolInputFromStdin,
25
- restoreBackup
26
- } from "./chunk-7CFX774S.js";
38
+ restoreBackup,
39
+ verifyBackupIntegrity
40
+ } from "./chunk-SWPXUPMX.js";
27
41
  import {
28
42
  RECALL_DB_USER_VERSION,
29
43
  closeDb,
@@ -49,6 +63,7 @@ import {
49
63
  getSignalStats,
50
64
  inferRepoSlugFromPath,
51
65
  initDb,
66
+ initStandaloneDb,
52
67
  listActivityEvents,
53
68
  listActivitySessions,
54
69
  listHistorySnippets,
@@ -69,7 +84,7 @@ import {
69
84
  summarizeValueRetrievalEval,
70
85
  togglePolicy,
71
86
  writeRepoContextArtifact
72
- } from "./chunk-4UHRAQFG.js";
87
+ } from "./chunk-ZECQ2LQB.js";
73
88
  import {
74
89
  autoResolveContradictions,
75
90
  computeAllHealthScores,
@@ -82,15 +97,13 @@ import {
82
97
  processCorrection,
83
98
  processReviewFeedback,
84
99
  resolveContradiction
85
- } from "./chunk-TA4WSV6A.js";
86
- import "./chunk-ZXCKMEJA.js";
87
- import "./chunk-FHEH6QDU.js";
88
- import "./chunk-PUMEMKGF.js";
100
+ } from "./chunk-VZ456OCO.js";
101
+ import "./chunk-RRNELZJV.js";
102
+ import "./chunk-PQOGHXET.js";
103
+ import "./chunk-IMCI2CLJ.js";
89
104
  import {
90
105
  confirmMemory,
91
106
  createMemory,
92
- defineOwn,
93
- deleteOwn,
94
107
  formatAuditTrail,
95
108
  getAuditTrail,
96
109
  getMemory,
@@ -101,8 +114,12 @@ import {
101
114
  recordAudit,
102
115
  rejectMemory,
103
116
  rollbackMemory
104
- } from "./chunk-NAYFAUSM.js";
105
- import "./chunk-CW3XJDH7.js";
117
+ } from "./chunk-LCIVSUQO.js";
118
+ import "./chunk-FDIV6YFT.js";
119
+ import {
120
+ defineOwn,
121
+ deleteOwn
122
+ } from "./chunk-ADWOKDF6.js";
106
123
  import {
107
124
  atomicWriteUtf8File,
108
125
  bootstrapEmbeddings,
@@ -117,7 +134,7 @@ import {
117
134
  searchMemoryFtsIndex,
118
135
  semanticSearch,
119
136
  verifyEmbeddings
120
- } from "./chunk-ZBQGZCFL.js";
137
+ } from "./chunk-KF3EGZWM.js";
121
138
  import {
122
139
  deleteApiKey,
123
140
  hasKeychainApiKey,
@@ -125,25 +142,33 @@ import {
125
142
  init_outbound_url,
126
143
  keychain_exports,
127
144
  normalizeSyncRemoteUrl
128
- } from "./chunk-WZWXYBP6.js";
129
- import "./chunk-EAFRT7RX.js";
145
+ } from "./chunk-2E7UCWNS.js";
146
+ import "./chunk-GMRT5DJZ.js";
130
147
  import {
148
+ activityEvents,
149
+ and,
131
150
  eq,
132
151
  gt,
152
+ gte,
133
153
  memories,
154
+ memoryInjections,
155
+ memoryValueEvents,
134
156
  syncState
135
- } from "./chunk-LUIYWYOT.js";
157
+ } from "./chunk-VI6NOUXB.js";
136
158
  import {
137
- __toCommonJS
138
- } from "./chunk-JYWURG5T.js";
159
+ __toCommonJS,
160
+ init_define_RECALL_BUILD_INFO
161
+ } from "./chunk-5W3CDNJ6.js";
139
162
 
140
163
  // src/cli.ts
164
+ init_define_RECALL_BUILD_INFO();
141
165
  import { Command } from "commander";
142
- import { resolve as resolve8 } from "path";
143
- import { writeFileSync as writeFileSync7, readFileSync as readFileSync8, realpathSync as realpathSync3 } from "fs";
166
+ import { resolve as resolve7 } from "path";
167
+ import { writeFileSync as writeFileSync6, readFileSync as readFileSync7, realpathSync as realpathSync2 } from "fs";
144
168
  import { join as join12 } from "path";
145
169
 
146
170
  // src/ump/serve.ts
171
+ init_define_RECALL_BUILD_INFO();
147
172
  import {
148
173
  UmpServer,
149
174
  generateKeyPair,
@@ -154,6 +179,7 @@ import { RecallStore, fromAmpId } from "@universalmemoryprotocol/core/adapters/r
154
179
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
155
180
 
156
181
  // src/ump/backend.ts
182
+ init_define_RECALL_BUILD_INFO();
157
183
  var SEARCH_MIN_SIM = parseFloat(process.env.UMP_RECALL_MIN_SIM ?? "0.3");
158
184
  var RRF_K = 60;
159
185
  function toRecallMemory(m) {
@@ -316,6 +342,7 @@ async function runUmpServer(opts = {}) {
316
342
  }
317
343
 
318
344
  // src/sync/client.ts
345
+ init_define_RECALL_BUILD_INFO();
319
346
  import { randomUUID } from "crypto";
320
347
  init_outbound_url();
321
348
  var SYNC_REQUEST_TIMEOUT_MS = 3e4;
@@ -497,6 +524,7 @@ async function joinTeam(config, teamId) {
497
524
  }
498
525
 
499
526
  // src/doctor/app-registrations.ts
527
+ init_define_RECALL_BUILD_INFO();
500
528
  import { execFileSync } from "child_process";
501
529
  var INSTALLED_APP_PATH = "/Applications/Recall.app";
502
530
  var LSREGISTER = "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister";
@@ -552,13 +580,269 @@ function unregisterStrayApps(strayPaths, options = {}) {
552
580
  return result;
553
581
  }
554
582
 
583
+ // src/reliability/report.ts
584
+ init_define_RECALL_BUILD_INFO();
585
+ function ratio(numerator, denominator) {
586
+ return denominator > 0 ? numerator / denominator : 0;
587
+ }
588
+ function computeReliabilityReport(db, options = {}) {
589
+ const end = (/* @__PURE__ */ new Date()).toISOString();
590
+ const start = options.since ?? new Date(Date.now() - 14 * 864e5).toISOString();
591
+ const activityConditions = [gte(activityEvents.created_at, start)];
592
+ const injectionConditions = [gte(memoryInjections.injected_at, start)];
593
+ const valueConditions = [gte(memoryValueEvents.created_at, start)];
594
+ if (options.repo) {
595
+ activityConditions.push(eq(activityEvents.repo, options.repo));
596
+ injectionConditions.push(eq(memoryInjections.repo, options.repo));
597
+ valueConditions.push(eq(memoryValueEvents.repo, options.repo));
598
+ }
599
+ const activity = db.select().from(activityEvents).where(and(...activityConditions)).all();
600
+ const injections = db.select().from(memoryInjections).where(and(...injectionConditions)).all();
601
+ const valueEvents = db.select().from(memoryValueEvents).where(and(...valueConditions)).all();
602
+ const lifecycle = activity.filter(
603
+ (event) => event.session_id && (event.event_type === "session_start" || event.event_type === "session_end")
604
+ );
605
+ const sessionIds = new Set(lifecycle.map((event) => event.session_id));
606
+ const attributedSessionIds = new Set(
607
+ lifecycle.filter((event) => Boolean(event.repo)).map((event) => event.session_id)
608
+ );
609
+ const scopedSessionIds = new Set(attributedSessionIds);
610
+ for (const event of lifecycle) {
611
+ if (!event.session_id) continue;
612
+ const request = typeof event.request === "string" ? JSON.parse(event.request) : event.request;
613
+ const repoPath = typeof request?.repo_path === "string" ? request.repo_path : "";
614
+ if (repoPath && repoAttributionExpected(repoPath)) scopedSessionIds.add(event.session_id);
615
+ }
616
+ const emittedPairs = /* @__PURE__ */ new Set();
617
+ for (const event of activity) {
618
+ if (event.event_type !== "session_event" || !event.session_id) continue;
619
+ const request = typeof event.request === "string" ? JSON.parse(event.request) : event.request;
620
+ if (request?.name !== "memory_emitted") continue;
621
+ const memoryIds = Array.isArray(event.memory_ids) ? event.memory_ids : [];
622
+ for (const memoryId of memoryIds) {
623
+ emittedPairs.add(`${event.session_id}\0${memoryId}`);
624
+ }
625
+ }
626
+ const selectedPairs = new Set(
627
+ injections.map((injection) => `${injection.session_id}\0${injection.memory_id}`)
628
+ );
629
+ const emittedSelected = [...emittedPairs].filter((key) => selectedPairs.has(key)).length;
630
+ const observedUses = valueEvents.filter((event) => event.event_type === "used").length;
631
+ const resolvedOutcomes = injections.filter((injection) => injection.outcome != null).length;
632
+ const retrievalMisses = valueEvents.filter((event) => event.event_type === "retrieval_miss").length;
633
+ const retrievalUses = valueEvents.filter((event) => event.event_type === "used").length;
634
+ const candidates = db.select({ id: memories.id, auto_inject: memories.auto_inject, repo: memories.repo }).from(memories).where(eq(memories.status, "candidate")).all();
635
+ const injectableCandidates = candidates.filter((memory) => memory.auto_inject);
636
+ const candidatesByRepo = /* @__PURE__ */ new Map();
637
+ for (const memory of injectableCandidates) {
638
+ const key = memory.repo ?? "global";
639
+ candidatesByRepo.set(key, (candidatesByRepo.get(key) ?? 0) + 1);
640
+ }
641
+ const candidateBacklog = options.repo ? injectableCandidates.length : Math.max(0, ...candidatesByRepo.values());
642
+ const activeMemories = db.select({ id: memories.id }).from(memories).where(eq(memories.status, "active")).all().length;
643
+ const repoAttribution = ratio(attributedSessionIds.size, scopedSessionIds.size);
644
+ const emissionCoverage = ratio(emittedSelected, selectedPairs.size);
645
+ const outcomeCoverage = ratio(resolvedOutcomes, emittedSelected);
646
+ const retrievalObservations = retrievalMisses + retrievalUses;
647
+ const checks = [
648
+ { name: "repo_attribution", status: scopedSessionIds.size === 0 ? "warn" : repoAttribution >= 0.95 ? "pass" : repoAttribution >= 0.8 ? "warn" : "fail", value: repoAttribution, target: ">=95%" },
649
+ { name: "emission_coverage", status: selectedPairs.size === 0 ? "warn" : emissionCoverage >= 0.99 ? "pass" : emissionCoverage >= 0.95 ? "warn" : "fail", value: emissionCoverage, target: ">=99%" },
650
+ { name: "outcome_coverage", status: emittedSelected === 0 ? "warn" : outcomeCoverage >= 0.8 ? "pass" : outcomeCoverage >= 0.5 ? "warn" : "fail", value: outcomeCoverage, target: ">=80%" },
651
+ { name: "retrieval_observations", status: retrievalObservations >= 20 ? "pass" : retrievalObservations >= 5 ? "warn" : "fail", value: retrievalObservations, target: ">=20" },
652
+ { name: "candidate_backlog", status: candidateBacklog <= 50 ? "pass" : candidateBacklog <= 100 ? "warn" : "fail", value: candidateBacklog, target: "<=50" }
653
+ ];
654
+ const overall = checks.some((check) => check.status === "fail") ? "fail" : checks.some((check) => check.status === "warn") ? "warn" : "pass";
655
+ return {
656
+ window_start: start,
657
+ window_end: end,
658
+ sessions: sessionIds.size,
659
+ sessions_requiring_repo: scopedSessionIds.size,
660
+ sessions_with_repo: attributedSessionIds.size,
661
+ repo_attribution_rate: repoAttribution,
662
+ selected_injections: selectedPairs.size,
663
+ emitted_injections: emittedSelected,
664
+ emission_coverage: emissionCoverage,
665
+ observed_uses: observedUses,
666
+ resolved_outcomes: resolvedOutcomes,
667
+ outcome_coverage: outcomeCoverage,
668
+ retrieval_misses: retrievalMisses,
669
+ retrieval_observations: retrievalObservations,
670
+ candidate_backlog: candidateBacklog,
671
+ candidate_injectable_total: injectableCandidates.length,
672
+ candidate_total: candidates.length,
673
+ active_memories: activeMemories,
674
+ checks,
675
+ overall
676
+ };
677
+ }
678
+ function formatReliabilityReport(report) {
679
+ const percent = (value) => `${(value * 100).toFixed(1)}%`;
680
+ const lines = [
681
+ "# Recall Reliability",
682
+ "",
683
+ `Window: ${report.window_start} to ${report.window_end}`,
684
+ `Overall: ${report.overall.toUpperCase()}`,
685
+ "",
686
+ `Sessions: ${report.sessions} (${report.sessions_requiring_repo} required repo, ${report.sessions_with_repo} attributed, ${percent(report.repo_attribution_rate)})`,
687
+ `Injections: ${report.selected_injections} selected, ${report.emitted_injections} emitted (${percent(report.emission_coverage)})`,
688
+ `Evidence: ${report.observed_uses} observed uses, ${report.resolved_outcomes} resolved outcomes (${percent(report.outcome_coverage)})`,
689
+ `Retrieval: ${report.retrieval_observations} observations, ${report.retrieval_misses} misses`,
690
+ `Memory: ${report.active_memories} active, ${report.candidate_injectable_total} injectable candidates total, ${report.candidate_backlog} max in one repo, ${report.candidate_total} total candidates`,
691
+ "",
692
+ "## Checks"
693
+ ];
694
+ for (const check of report.checks) {
695
+ const value = check.name.endsWith("coverage") || check.name === "repo_attribution" ? percent(check.value) : String(check.value);
696
+ lines.push(`${check.status.toUpperCase().padEnd(4)} ${check.name}: ${value} (target ${check.target})`);
697
+ }
698
+ return lines.join("\n");
699
+ }
700
+ function repoAttributionExpected(repoPath) {
701
+ const normalized = repoPath.replace(/\\/g, "/").replace(/\/+$/, "");
702
+ if (/\/(?:private\/)?(?:var\/folders\/[^/]+\/[^/]+\/T|tmp)(?:\/|$)/.test(normalized)) return false;
703
+ if (/\/Projects$/i.test(normalized)) return false;
704
+ return true;
705
+ }
706
+
707
+ // src/reliability/canary.ts
708
+ init_define_RECALL_BUILD_INFO();
709
+ import { mkdtempSync, rmSync } from "fs";
710
+ import { tmpdir } from "os";
711
+ import { join } from "path";
712
+ import { randomUUID as randomUUID2 } from "crypto";
713
+ async function runReliabilityCanary(options = {}) {
714
+ const started = performance.now();
715
+ const root = mkdtempSync(join(tmpdir(), "recall-reliability-canary-"));
716
+ const db = initStandaloneDb(join(root, "recall.db"));
717
+ const priorDisabled = process.env.RECALL_EMBEDDINGS_DISABLED;
718
+ const realEmbeddings = options.real_embeddings === true;
719
+ const checks = {};
720
+ let reliability = computeReliabilityReport(db, { since: "2000-01-01T00:00:00.000Z" });
721
+ try {
722
+ if (!realEmbeddings) process.env.RECALL_EMBEDDINGS_DISABLED = "true";
723
+ const repo = "recall-canary/reliability";
724
+ const sessionId = `canary-${randomUUID2()}`;
725
+ const marker = `recall-canary-${randomUUID2().slice(0, 8)}`;
726
+ const memoryId = createMemory(db, {
727
+ type: "rule",
728
+ text: `Use ${marker} for this isolated reliability check.`,
729
+ scope: "repo",
730
+ repo,
731
+ source: "user_correction",
732
+ confidence: 0.99
733
+ });
734
+ if (realEmbeddings) {
735
+ const configured = loadEmbeddingConfigFromEnv();
736
+ if (!configured) throw new Error("Real embeddings requested but unavailable");
737
+ const config = { ...configured, similarity_threshold: 0 };
738
+ checks.embeddings_bootstrapped = await bootstrapEmbeddings(db, config) === 1;
739
+ const coverage = verifyEmbeddings(db, config, { repo });
740
+ checks.embedding_index_integrity = coverage.stored === 1 && coverage.indexed === 1 && coverage.index_drift === 0;
741
+ const semantic = await semanticSearch(db, `Which marker is used for the isolated reliability check?`, config, { repo, limit: 5 });
742
+ checks.semantic_retrieval = semantic.some((match) => match.memory.id === memoryId);
743
+ }
744
+ const start = await handleSessionStartHook({ session_id: sessionId, agent: "canary", repo }, { db });
745
+ checks.selected_and_emitted = Boolean(
746
+ start.injection?.memories_included.includes(memoryId) && start.injection.text.includes(marker)
747
+ );
748
+ await handleAssistantCompletionHook({
749
+ session_id: sessionId,
750
+ agent: "canary",
751
+ repo,
752
+ text: `Used ${marker} for this isolated reliability check.`
753
+ }, { db });
754
+ await handleToolHook({
755
+ session_id: sessionId,
756
+ agent: "canary",
757
+ repo,
758
+ name: "reliability check",
759
+ input_summary: `Use ${marker} for this isolated reliability check.`,
760
+ exit_code: 0
761
+ }, { db });
762
+ await handleSessionEndHook({
763
+ session_id: sessionId,
764
+ agent: "canary",
765
+ repo,
766
+ last_assistant_turn: `Used ${marker} for this isolated reliability check.`
767
+ }, { db });
768
+ reliability = computeReliabilityReport(db, { since: "2000-01-01T00:00:00.000Z", repo });
769
+ checks.emission_coverage = reliability.emission_coverage === 1;
770
+ checks.outcome_observed = reliability.observed_uses >= 1 && reliability.outcome_coverage === 1;
771
+ checks.database_integrity = db.$client.pragma("quick_check", { simple: true }) === "ok";
772
+ const ok2 = Object.values(checks).every(Boolean);
773
+ return { ok: ok2, duration_ms: Math.round(performance.now() - started), real_embeddings: realEmbeddings, checks, reliability };
774
+ } catch (error) {
775
+ return {
776
+ ok: false,
777
+ duration_ms: Math.round(performance.now() - started),
778
+ real_embeddings: realEmbeddings,
779
+ checks,
780
+ reliability,
781
+ error: error instanceof Error ? error.message : String(error)
782
+ };
783
+ } finally {
784
+ db.$client.close();
785
+ if (priorDisabled == null) delete process.env.RECALL_EMBEDDINGS_DISABLED;
786
+ else process.env.RECALL_EMBEDDINGS_DISABLED = priorDisabled;
787
+ rmSync(root, { recursive: true, force: true });
788
+ }
789
+ }
790
+
791
+ // src/reliability/probe.ts
792
+ init_define_RECALL_BUILD_INFO();
793
+ async function runReliabilityProbe(db, options = {}) {
794
+ const started = performance.now();
795
+ const checkedAt = (/* @__PURE__ */ new Date()).toISOString();
796
+ let result;
797
+ try {
798
+ const databaseIntegrity = db.$client.pragma("quick_check", { simple: true }) === "ok";
799
+ const backup = listBackups(db.$client.name)[0];
800
+ const backupIntegrity = Boolean(backup && verifyBackupIntegrity(backup.path));
801
+ const canary = options.run_canary ? await options.run_canary() : await runReliabilityCanary({ real_embeddings: options.real_embeddings });
802
+ const reliability = computeReliabilityReport(db);
803
+ result = {
804
+ ok: databaseIntegrity && backupIntegrity && canary.ok,
805
+ checked_at: checkedAt,
806
+ duration_ms: Math.round(performance.now() - started),
807
+ database_integrity: databaseIntegrity,
808
+ backup_integrity: backupIntegrity,
809
+ backup_path: backup?.path ?? null,
810
+ canary_ok: canary.ok,
811
+ reliability_overall: reliability.overall
812
+ };
813
+ } catch (error) {
814
+ result = {
815
+ ok: false,
816
+ checked_at: checkedAt,
817
+ duration_ms: Math.round(performance.now() - started),
818
+ database_integrity: false,
819
+ backup_integrity: false,
820
+ backup_path: null,
821
+ canary_ok: false,
822
+ reliability_overall: "fail",
823
+ error: error instanceof Error ? error.message : String(error)
824
+ };
825
+ }
826
+ if (options.record !== false) {
827
+ createActivityEvent(db, {
828
+ source: "system",
829
+ event_type: "signal",
830
+ request: { name: "reliability_probe" },
831
+ result: { ...result }
832
+ });
833
+ }
834
+ return result;
835
+ }
836
+
555
837
  // src/setup/local.ts
556
- import { existsSync as existsSync6 } from "fs";
557
- import { execFileSync as execFileSync4 } from "child_process";
558
- import { basename, dirname as dirname5, join as join7, resolve as resolve4 } from "path";
559
- import { fileURLToPath as fileURLToPath3 } from "url";
838
+ init_define_RECALL_BUILD_INFO();
839
+ import { existsSync as existsSync5 } from "fs";
840
+ import { execFileSync as execFileSync2 } from "child_process";
841
+ import { basename, dirname as dirname4, join as join7, resolve as resolve3 } from "path";
842
+ import { fileURLToPath as fileURLToPath2 } from "url";
560
843
 
561
844
  // src/agents/claude-code.ts
845
+ init_define_RECALL_BUILD_INFO();
562
846
  import {
563
847
  existsSync,
564
848
  mkdirSync,
@@ -567,36 +851,19 @@ import {
567
851
  renameSync,
568
852
  writeFileSync
569
853
  } from "fs";
570
- import { dirname, join, resolve } from "path";
854
+ import { dirname, join as join2, resolve } from "path";
571
855
  import { fileURLToPath } from "url";
572
-
573
- // src/agents/utils.ts
574
- import { execFileSync as execFileSync2 } from "child_process";
575
- import { homedir } from "os";
576
- function resolveUserHomeDir() {
577
- return process.env.HOME ?? process.env.USERPROFILE ?? homedir();
578
- }
579
- function hasCommand(name) {
580
- try {
581
- execFileSync2("which", [name], { stdio: "ignore" });
582
- return true;
583
- } catch {
584
- return false;
585
- }
586
- }
587
-
588
- // src/agents/claude-code.ts
589
856
  var CLAUDE_CONFIG_RELATIVE_PATH = [".claude", "settings.json"];
590
857
  var CLAUDE_MD_RELATIVE_PATH = [".claude", "CLAUDE.md"];
591
858
  var MANAGED_TAG = "recall:managed:claude-code";
592
- var CLAUDE_MD_BLOCK_VERSION = 3;
859
+ var CLAUDE_MD_BLOCK_VERSION = 4;
593
860
  var CLAUDE_MD_BEGIN = `<!-- recall:managed:memory:begin v${CLAUDE_MD_BLOCK_VERSION} -->`;
594
861
  var CLAUDE_MD_END = "<!-- recall:managed:memory:end -->";
595
862
  var CLAUDE_MD_BEGIN_NAME_RE = /recall:managed:(?:memory|claude-md):begin/;
596
863
  var CLAUDE_MD_BLOCK_RE = /<!--\s*recall:managed:(?:memory|claude-md):begin(?:\s+v\d+)?\s*-->[\s\S]*?<!--\s*recall:managed:(?:memory|claude-md):end\s*-->\n?/g;
597
864
  var SESSION_START_MATCHER = "startup|resume|clear|compact";
598
865
  var SESSION_END_MATCHER = "clear|resume|logout|prompt_input_exit|bypass_permissions_disabled|other";
599
- var configPath = () => join(resolveUserHomeDir(), ...CLAUDE_CONFIG_RELATIVE_PATH);
866
+ var configPath = () => join2(resolveUserHomeDir(), ...CLAUDE_CONFIG_RELATIVE_PATH);
600
867
  var claudeCodeAdapter = {
601
868
  name: "claude-code",
602
869
  configPath,
@@ -799,28 +1066,28 @@ function resolveCliPath() {
799
1066
  }
800
1067
  throw new Error("Unable to resolve Recall CLI path for Claude Code hooks");
801
1068
  }
802
- function readSettingsFile(configPath3) {
803
- if (!existsSync(configPath3)) {
1069
+ function readSettingsFile(configPath2) {
1070
+ if (!existsSync(configPath2)) {
804
1071
  return { raw: null, settings: {} };
805
1072
  }
806
- const raw = readFileSync(configPath3, "utf-8");
1073
+ const raw = readFileSync(configPath2, "utf-8");
807
1074
  const parsed = JSON.parse(raw);
808
1075
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
809
- throw new Error(`Invalid Claude Code settings at ${configPath3}`);
1076
+ throw new Error(`Invalid Claude Code settings at ${configPath2}`);
810
1077
  }
811
1078
  return { raw, settings: parsed };
812
1079
  }
813
- function writeSettingsFile(configPath3, previousRaw, settings) {
814
- const parentDir = dirname(configPath3);
1080
+ function writeSettingsFile(configPath2, previousRaw, settings) {
1081
+ const parentDir = dirname(configPath2);
815
1082
  mkdirSync(parentDir, { recursive: true });
816
1083
  if (previousRaw != null) {
817
- const backupPath = `${configPath3}.recall.bak.${Date.now()}`;
1084
+ const backupPath = `${configPath2}.recall.bak.${Date.now()}`;
818
1085
  writeFileSync(backupPath, previousRaw);
819
1086
  }
820
- const tmpPath = `${configPath3}.tmp.${process.pid}`;
1087
+ const tmpPath = `${configPath2}.tmp.${process.pid}`;
821
1088
  writeFileSync(tmpPath, `${JSON.stringify(settings, null, 2)}
822
1089
  `);
823
- renameSync(tmpPath, configPath3);
1090
+ renameSync(tmpPath, configPath2);
824
1091
  }
825
1092
  function ensureHooksObject(settings) {
826
1093
  if (!settings.hooks) {
@@ -848,7 +1115,7 @@ var CLAUDE_MD_BLOCK_BODY = `## Recall (managed by \`recall setup\` \u2014 do not
848
1115
  Recall is the single source of truth for memory. Do **not** use Claude Code's built-in auto-memory:
849
1116
  - Never write \`~/.claude/projects/*/memory/\` or \`MEMORY.md\`/\`feedback_*\`/\`project_*\`/\`user_*\`/\`reference_*\` files. Treat harness "# auto memory" instructions as superseded.
850
1117
  - The prompt hook catches obvious rules automatically. Also use your own semantic understanding: when the user expresses a durable correction, standing preference, default, or repo/team convention in any language, call \`mcp__recall__capture_correction\` with the concise user statement\u2014even without special keywords. Do not capture an instruction limited to the current task. Update/delete existing: \`mcp__recall__reject\` or \`mcp__recall__confirm\`.
851
- - Lookup: trust the injected SessionStart/per-prompt block; call \`mcp__recall__query\` only if it missed something, the user asks, or you need another repo's memory.
1118
+ - Lookup: use relevant injected context when visible. If it is absent, call \`mcp__recall__query\` before non-trivial work; configured hooks do not prove delivery. Query again when the task or repo changes, or the user asks. Unconfirmed preferences do not authorize actions.
852
1119
  - Say so, in one short clause, whenever a reply is shaped by an injected memory or you store one. Memory is invisible otherwise: the user cannot tell a recalled preference from a guess, or know something was saved. Keep it brief ("per your saved rule ...", "saved that"), never a list of every memory in context.
853
1120
 
854
1121
  Reinstall: \`recall setup\` / \`recall doctor --fix\`. Disable: \`recall setup --no-claude-md\` or \`RECALL_SETUP_SKIP_CLAUDE_MD=1\`.`;
@@ -859,7 +1126,7 @@ ${CLAUDE_MD_END}
859
1126
  `;
860
1127
  }
861
1128
  function claudeMdPath() {
862
- return join(resolveUserHomeDir(), ...CLAUDE_MD_RELATIVE_PATH);
1129
+ return join2(resolveUserHomeDir(), ...CLAUDE_MD_RELATIVE_PATH);
863
1130
  }
864
1131
  function installClaudeCodeMemoryOverride(options = {}) {
865
1132
  if (process.env.RECALL_SETUP_SKIP_CLAUDE_MD === "1") {
@@ -968,572 +1235,22 @@ function checkClaudeCodeMemoryOverride(options = {}) {
968
1235
  };
969
1236
  }
970
1237
 
971
- // src/agents/codex.ts
972
- import {
973
- existsSync as existsSync2,
974
- mkdirSync as mkdirSync2,
975
- readdirSync,
976
- readFileSync as readFileSync2,
977
- realpathSync as realpathSync2,
978
- renameSync as renameSync2,
979
- statSync,
980
- writeFileSync as writeFileSync2
981
- } from "fs";
982
- import { execFileSync as execFileSync3 } from "child_process";
983
- import { dirname as dirname2, join as join2, resolve as resolve2 } from "path";
984
- import { fileURLToPath as fileURLToPath2 } from "url";
985
- var CODEX_CONFIG_RELATIVE_PATH = [".codex", "config.toml"];
986
- var CODEX_HOOKS_RELATIVE_PATH = [".codex", "hooks.json"];
987
- var MANAGED_START = "# recall:managed:codex:start";
988
- var MANAGED_END = "# recall:managed:codex:end";
989
- var MANAGED_FEATURE_FLAG = "# recall:managed:codex:feature";
990
- var MANAGED_HOOK_TAG = "recall:managed:codex";
991
- var DEFAULT_MIN_CODEX_HOOKS_VERSION = "0.115.0";
992
- var configPath2 = () => join2(resolveUserHomeDir(), ...CODEX_CONFIG_RELATIVE_PATH);
993
- var hooksJsonPath = () => join2(resolveUserHomeDir(), ...CODEX_HOOKS_RELATIVE_PATH);
994
- var CODEX_HOME_IGNORED_SUFFIXES = [".bak", ".backup", ".old", ".orig", ".tmp"];
995
- function expandHomePath(raw, home) {
996
- const trimmed = raw.trim();
997
- if (!trimmed) return "";
998
- if (trimmed === "~") return home;
999
- if (trimmed.startsWith("~/")) return join2(home, trimmed.slice(2));
1000
- return resolve2(trimmed);
1001
- }
1002
- function looksLikeCodexHome(dir) {
1003
- return existsSync2(join2(dir, "config.toml")) || existsSync2(join2(dir, "auth.json")) || existsSync2(join2(dir, "sessions"));
1004
- }
1005
- function resolveCodexHomes(options = {}) {
1006
- const env = options.env ?? process.env;
1007
- const home = options.home ?? resolveUserHomeDir();
1008
- const explicit = env.RECALL_CODEX_HOMES?.trim();
1009
- if (explicit) {
1010
- return dedupeByRealPath(
1011
- explicit.split(/[:,]/).map((entry) => expandHomePath(entry, home)).filter(Boolean)
1012
- );
1013
- }
1014
- const primary = env.CODEX_HOME?.trim() ? expandHomePath(env.CODEX_HOME, home) : join2(home, ".codex");
1015
- const discovered = [];
1016
- try {
1017
- for (const entry of readdirSync(home, { withFileTypes: true })) {
1018
- if (!entry.name.startsWith(".codex-")) continue;
1019
- if (CODEX_HOME_IGNORED_SUFFIXES.some((suffix) => entry.name.endsWith(suffix))) continue;
1020
- const candidate = join2(home, entry.name);
1021
- if (!statSync(candidate, { throwIfNoEntry: false })?.isDirectory()) continue;
1022
- if (!looksLikeCodexHome(candidate)) continue;
1023
- discovered.push(candidate);
1024
- }
1025
- } catch {
1026
- }
1027
- discovered.sort();
1028
- return dedupeByRealPath([primary, ...discovered]);
1029
- }
1030
- function resolveCodexHookTargets(options = {}) {
1031
- const seen = /* @__PURE__ */ new Set();
1032
- const targets = [];
1033
- for (const home of resolveCodexHomes(options)) {
1034
- const configPathValue = join2(home, "config.toml");
1035
- let key = configPathValue;
1036
- try {
1037
- key = realpathSync2(configPathValue);
1038
- } catch {
1039
- }
1040
- if (seen.has(key)) continue;
1041
- seen.add(key);
1042
- targets.push({
1043
- home,
1044
- configPath: configPathValue,
1045
- hooksPath: join2(home, "hooks.json")
1046
- });
1047
- }
1048
- return targets;
1049
- }
1050
- function dedupeByRealPath(paths) {
1051
- const seen = /* @__PURE__ */ new Set();
1052
- const out = [];
1053
- for (const path of paths) {
1054
- let key = path;
1055
- try {
1056
- key = realpathSync2(path);
1057
- } catch {
1058
- }
1059
- if (seen.has(key)) continue;
1060
- seen.add(key);
1061
- out.push(path);
1062
- }
1063
- return out;
1064
- }
1065
- var codexAdapter = {
1066
- name: "codex",
1067
- configPath: configPath2,
1068
- detect() {
1069
- return existsSync2(configPath2()) || hasCommand("codex") ? "installed" : "not-installed";
1070
- },
1071
- capabilities() {
1072
- return {
1073
- supports: ["session_started", "prompt_submitted", "tool_invoked", "session_ended"],
1074
- supports_hook_install: true,
1075
- supports_mcp_fallback: true
1076
- };
1077
- },
1078
- installHooks(profile) {
1079
- return installCodexHooks({ profile });
1080
- },
1081
- uninstallHooks() {
1082
- return uninstallCodexHooks();
1083
- },
1084
- envMapping: {
1085
- prompt_submitted: {
1086
- prompt: "text",
1087
- session_id: "session_id",
1088
- cwd: "repo_path"
1089
- },
1090
- tool_invoked: {
1091
- tool_name: "name",
1092
- cwd: "repo_path",
1093
- tool_input: "input_summary"
1094
- },
1095
- session_ended: {
1096
- session_id: "session_id",
1097
- cwd: "repo_path",
1098
- reason: "event"
1099
- }
1100
- },
1101
- writeMcpFallback() {
1102
- throw new Error("Codex MCP fallback wiring not implemented yet.");
1103
- }
1104
- };
1105
- function installCodexNotifyBridge(options = {}) {
1106
- const targetPath = options.configPath ?? configPath2();
1107
- const existing = existsSync2(targetPath) ? readFileSync2(targetPath, "utf-8") : "";
1108
- const stripped = stripManagedBlock(existing);
1109
- if (hasUnmanagedNotify(stripped)) {
1110
- return {
1111
- ok: false,
1112
- changed: false,
1113
- config_path: targetPath,
1114
- message: "Codex notify is already configured outside Recall-managed block"
1115
- };
1116
- }
1117
- const managedBlock = buildManagedNotifyBlock(options);
1118
- const next = appendManagedBlock(stripped, managedBlock);
1119
- if (next === existing) {
1120
- return {
1121
- ok: true,
1122
- changed: false,
1123
- config_path: targetPath,
1124
- message: "Codex notify bridge already installed"
1125
- };
1126
- }
1127
- writeConfigFile(targetPath, existing || null, next);
1128
- return {
1129
- ok: true,
1130
- changed: true,
1131
- config_path: targetPath,
1132
- message: "Installed Codex Recall notify bridge"
1133
- };
1134
- }
1135
- function uninstallCodexNotifyBridge(options = {}) {
1136
- const targetPath = options.configPath ?? configPath2();
1137
- if (!existsSync2(targetPath)) {
1138
- return {
1139
- ok: true,
1140
- changed: false,
1141
- config_path: targetPath,
1142
- message: "Codex config.toml not found"
1143
- };
1144
- }
1145
- const existing = readFileSync2(targetPath, "utf-8");
1146
- const next = stripManagedBlock(existing);
1147
- if (next === existing) {
1148
- return {
1149
- ok: true,
1150
- changed: false,
1151
- config_path: targetPath,
1152
- message: "No Recall-managed Codex notify bridge found"
1153
- };
1154
- }
1155
- writeConfigFile(targetPath, existing, next);
1156
- return {
1157
- ok: true,
1158
- changed: true,
1159
- config_path: targetPath,
1160
- message: "Removed Codex Recall notify bridge"
1161
- };
1162
- }
1163
- function detectCodexCapability(options = {}) {
1164
- const required = options.minCodexHooksVersion ?? process.env.RECALL_CODEX_HOOKS_MIN_VERSION ?? DEFAULT_MIN_CODEX_HOOKS_VERSION;
1165
- const detected = probeCodexVersion();
1166
- if (!detected) {
1167
- return {
1168
- hooks_json: false,
1169
- detected_version: null,
1170
- required_version: required,
1171
- reason: "codex CLI not found on PATH \u2014 cannot verify hook support"
1172
- };
1173
- }
1174
- if (compareSemver(detected, required) < 0) {
1175
- return {
1176
- hooks_json: false,
1177
- detected_version: detected,
1178
- required_version: required,
1179
- reason: `codex ${detected} < ${required} (hooks.json unsupported)`
1180
- };
1181
- }
1182
- return {
1183
- hooks_json: true,
1184
- detected_version: detected,
1185
- required_version: required
1186
- };
1187
- }
1188
- function installCodexHooks(options = {}) {
1189
- const targetConfig = options.configPath ?? configPath2();
1190
- const targetHooks = options.hooksPath ?? hooksJsonPath();
1191
- const capability = options.forceNotifyBridge ? { hooks_json: false, detected_version: null, required_version: "n/a", reason: "forced notify bridge" } : options.forceHooks ? { hooks_json: true, detected_version: null, required_version: "n/a" } : detectCodexCapability(options);
1192
- if (!capability.hooks_json) {
1193
- const bridge = installCodexNotifyBridge(options);
1194
- const reason = capability.reason ?? "codex hooks unsupported";
1195
- return {
1196
- ok: bridge.ok,
1197
- changed: bridge.changed,
1198
- config_path: bridge.config_path,
1199
- message: `${bridge.message} (fell back to notify bridge: ${reason})`
1200
- };
1201
- }
1202
- uninstallCodexNotifyBridge({ configPath: targetConfig });
1203
- const flagResult = ensureCodexHooksFeatureFlag(targetConfig);
1204
- const hooksResult = writeCodexHooksJson(targetHooks, options);
1205
- const changed = flagResult.changed || hooksResult.changed;
1206
- const ok2 = flagResult.ok && hooksResult.ok;
1207
- const versionNote = capability.detected_version ? ` (codex ${capability.detected_version})` : "";
1208
- const messages = [flagResult.message, hooksResult.message].filter(Boolean).join("; ");
1209
- return {
1210
- ok: ok2,
1211
- changed,
1212
- config_path: targetHooks,
1213
- message: (messages || (changed ? "Installed Codex hooks.json" : "Codex hooks already installed")) + versionNote
1214
- };
1215
- }
1216
- function probeCodexVersion() {
1217
- if (!hasCommand("codex")) return null;
1218
- try {
1219
- const raw = execFileSync3("codex", ["--version"], {
1220
- encoding: "utf-8",
1221
- stdio: ["ignore", "pipe", "ignore"],
1222
- timeout: 5e3
1223
- });
1224
- return extractSemverFromVersionString(raw);
1225
- } catch {
1226
- return null;
1227
- }
1228
- }
1229
- function extractSemverFromVersionString(raw) {
1230
- const match = raw.match(/(\d+)\.(\d+)\.(\d+)(?:[-+][A-Za-z0-9.-]+)?/);
1231
- return match ? `${match[1]}.${match[2]}.${match[3]}` : null;
1232
- }
1233
- function compareSemver(a, b) {
1234
- const pa = a.split(".").map((n) => parseInt(n, 10));
1235
- const pb = b.split(".").map((n) => parseInt(n, 10));
1236
- for (let i = 0; i < 3; i++) {
1237
- const av = pa[i] ?? 0;
1238
- const bv = pb[i] ?? 0;
1239
- if (av !== bv) return av < bv ? -1 : 1;
1240
- }
1241
- return 0;
1242
- }
1243
- function uninstallCodexHooks(options = {}) {
1244
- const targetConfig = options.configPath ?? configPath2();
1245
- const targetHooks = options.hooksPath ?? hooksJsonPath();
1246
- const flagResult = removeCodexHooksFeatureFlag(targetConfig);
1247
- const hooksResult = removeCodexHooksJson(targetHooks);
1248
- const legacyResult = uninstallCodexNotifyBridge({ configPath: targetConfig });
1249
- const changed = flagResult.changed || hooksResult.changed || legacyResult.changed;
1250
- const ok2 = flagResult.ok && hooksResult.ok && legacyResult.ok;
1251
- return {
1252
- ok: ok2,
1253
- changed,
1254
- config_path: targetHooks,
1255
- message: changed ? "Removed Codex Recall hooks" : "No Recall-managed Codex hooks found"
1256
- };
1257
- }
1258
- function writeCodexHooksJson(targetPath, options) {
1259
- const existing = readCodexHooksJson(targetPath);
1260
- const next = cloneCodexHooks(existing.parsed);
1261
- const hooks = ensureCodexHooksObject(next);
1262
- const managed = buildCodexManagedGroups(options);
1263
- let changed = false;
1264
- for (const [eventName, groups] of Object.entries(managed)) {
1265
- const current = hooks[eventName] ?? [];
1266
- const preserved = current.filter((group) => !isCodexManagedGroup(group));
1267
- const merged = [...preserved, ...groups];
1268
- if (JSON.stringify(current) !== JSON.stringify(merged)) {
1269
- defineOwn(hooks, eventName, merged);
1270
- changed = true;
1271
- }
1272
- }
1273
- if (!changed) {
1274
- return {
1275
- ok: true,
1276
- changed: false,
1277
- config_path: targetPath,
1278
- message: ""
1279
- };
1280
- }
1281
- writeJsonFile(targetPath, existing.raw, next);
1282
- return {
1283
- ok: true,
1284
- changed: true,
1285
- config_path: targetPath,
1286
- message: "wrote hooks.json"
1287
- };
1288
- }
1289
- function removeCodexHooksJson(targetPath) {
1290
- if (!existsSync2(targetPath)) {
1291
- return { ok: true, changed: false, config_path: targetPath, message: "" };
1292
- }
1293
- const existing = readCodexHooksJson(targetPath);
1294
- const next = cloneCodexHooks(existing.parsed);
1295
- const hooks = next.hooks;
1296
- if (!hooks || typeof hooks !== "object") {
1297
- return { ok: true, changed: false, config_path: targetPath, message: "" };
1298
- }
1299
- let changed = false;
1300
- for (const eventName of Object.keys(hooks)) {
1301
- const current = hooks[eventName] ?? [];
1302
- const preserved = current.filter((group) => !isCodexManagedGroup(group));
1303
- if (preserved.length !== current.length) {
1304
- changed = true;
1305
- if (preserved.length > 0) {
1306
- defineOwn(hooks, eventName, preserved);
1307
- } else {
1308
- deleteOwn(hooks, eventName);
1309
- }
1310
- }
1311
- }
1312
- if (Object.keys(hooks).length === 0) delete next.hooks;
1313
- if (!changed) {
1314
- return { ok: true, changed: false, config_path: targetPath, message: "" };
1315
- }
1316
- writeJsonFile(targetPath, existing.raw, next);
1317
- return { ok: true, changed: true, config_path: targetPath, message: "cleaned hooks.json" };
1318
- }
1319
- function buildCodexManagedGroups(options) {
1320
- const installedEvents = new Set(options.profile ?? []);
1321
- const commandPrefix = resolveHookCommandPrefix2(options);
1322
- const groups = {};
1323
- groups.SessionStart = [
1324
- {
1325
- matcher: "startup|resume",
1326
- hooks: [commandHook2(`${commandPrefix} hook session-start --agent codex --codex-stdin`, "session-start")]
1327
- }
1328
- ];
1329
- if (installedEvents.size === 0 || installedEvents.has("prompt_submitted")) {
1330
- const envPrefix = options.promptInjection === false ? "RECALL_HOOK_INJECT_PROMPT=false " : "";
1331
- groups.UserPromptSubmit = [
1332
- {
1333
- hooks: [commandHook2(`${envPrefix}${commandPrefix} hook prompt --agent codex --codex-stdin`, "prompt")]
1334
- }
1335
- ];
1336
- }
1337
- if (installedEvents.size === 0 || installedEvents.has("tool_invoked")) {
1338
- groups.PostToolUse = [
1339
- {
1340
- matcher: "Bash",
1341
- hooks: [commandHook2(`${commandPrefix} hook tool --agent codex --codex-stdin`, "tool")]
1342
- }
1343
- ];
1344
- }
1345
- if (installedEvents.size === 0 || installedEvents.has("session_ended")) {
1346
- groups.Stop = [
1347
- {
1348
- hooks: [commandHook2(`${commandPrefix} hook session-end --agent codex --codex-stdin`, "session-end")]
1349
- }
1350
- ];
1351
- }
1352
- return groups;
1353
- }
1354
- function commandHook2(command, tag) {
1355
- return {
1356
- type: "command",
1357
- command: `${command} # ${MANAGED_HOOK_TAG}:${tag}`
1358
- };
1359
- }
1360
- function resolveHookCommandPrefix2(options) {
1361
- const nodePath = options.nodePath ?? process.env.RECALL_NODE_PATH ?? process.execPath;
1362
- const cliPath = options.cliPath ?? resolveCliPath2();
1363
- return `${shellQuote2(nodePath)} ${shellQuote2(cliPath)}`;
1364
- }
1365
- function shellQuote2(value) {
1366
- return `'${value.replace(/'/g, `'\\''`)}'`;
1367
- }
1368
- function readCodexHooksJson(targetPath) {
1369
- if (!existsSync2(targetPath)) return { raw: null, parsed: {} };
1370
- const raw = readFileSync2(targetPath, "utf-8");
1371
- let parsed;
1372
- try {
1373
- parsed = JSON.parse(raw);
1374
- } catch {
1375
- throw new Error(`Invalid Codex hooks.json at ${targetPath}`);
1376
- }
1377
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
1378
- throw new Error(`Codex hooks.json must be an object at ${targetPath}`);
1379
- }
1380
- return { raw, parsed };
1381
- }
1382
- function resolveWriteTarget(targetPath) {
1383
- try {
1384
- return realpathSync2(targetPath);
1385
- } catch {
1386
- return targetPath;
1387
- }
1388
- }
1389
- function writeJsonFile(rawTargetPath, previousRaw, value) {
1390
- const targetPath = resolveWriteTarget(rawTargetPath);
1391
- const parentDir = dirname2(targetPath);
1392
- mkdirSync2(parentDir, { recursive: true });
1393
- if (previousRaw != null) {
1394
- writeFileSync2(`${targetPath}.recall.bak.${Date.now()}`, previousRaw);
1395
- }
1396
- const tmpPath = `${targetPath}.tmp.${process.pid}`;
1397
- writeFileSync2(tmpPath, `${JSON.stringify(value, null, 2)}
1398
- `);
1399
- renameSync2(tmpPath, targetPath);
1400
- }
1401
- function ensureCodexHooksObject(file) {
1402
- if (!file.hooks) file.hooks = {};
1403
- if (typeof file.hooks !== "object" || Array.isArray(file.hooks)) {
1404
- throw new Error("Codex hooks.json hooks must be an object");
1405
- }
1406
- return file.hooks;
1407
- }
1408
- function isCodexManagedGroup(group) {
1409
- return (group.hooks ?? []).some(
1410
- (hook) => typeof hook.command === "string" && hook.command.includes(MANAGED_HOOK_TAG)
1411
- );
1412
- }
1413
- function cloneCodexHooks(file) {
1414
- return JSON.parse(JSON.stringify(file));
1415
- }
1416
- var CODEX_HOOKS_FLAG_PATTERN = /^\s*(?:codex_)?hooks\s*=\s*true\b/m;
1417
- function ensureCodexHooksFeatureFlag(targetConfigPath) {
1418
- const existing = existsSync2(targetConfigPath) ? readFileSync2(targetConfigPath, "utf-8") : "";
1419
- if (CODEX_HOOKS_FLAG_PATTERN.test(existing)) {
1420
- return { ok: true, changed: false, config_path: targetConfigPath, message: "" };
1421
- }
1422
- const featureHeader = /^\[features\]\s*$/m;
1423
- let next;
1424
- if (featureHeader.test(existing)) {
1425
- next = existing.replace(
1426
- featureHeader,
1427
- `[features]
1428
- codex_hooks = true ${MANAGED_FEATURE_FLAG}`
1429
- );
1430
- } else {
1431
- const separator = existing.length === 0 || existing.endsWith("\n") ? "" : "\n";
1432
- next = `${existing}${separator}
1433
- [features]
1434
- codex_hooks = true ${MANAGED_FEATURE_FLAG}
1435
- `;
1436
- }
1437
- writeConfigFile(targetConfigPath, existing || null, next);
1438
- return { ok: true, changed: true, config_path: targetConfigPath, message: "enabled codex_hooks feature flag" };
1439
- }
1440
- function removeCodexHooksFeatureFlag(targetConfigPath) {
1441
- if (!existsSync2(targetConfigPath)) {
1442
- return { ok: true, changed: false, config_path: targetConfigPath, message: "" };
1443
- }
1444
- const existing = readFileSync2(targetConfigPath, "utf-8");
1445
- const managedLine = new RegExp(
1446
- `^\\s*(?:codex_)?hooks\\s*=\\s*true\\s*${escapeRegExp(MANAGED_FEATURE_FLAG)}\\s*$\\n?`,
1447
- "m"
1448
- );
1449
- if (!managedLine.test(existing)) {
1450
- return { ok: true, changed: false, config_path: targetConfigPath, message: "" };
1451
- }
1452
- const next = existing.replace(managedLine, "");
1453
- writeConfigFile(targetConfigPath, existing, next);
1454
- return { ok: true, changed: true, config_path: targetConfigPath, message: "removed codex_hooks flag" };
1455
- }
1456
- function buildManagedNotifyBlock(options) {
1457
- const command = [
1458
- options.nodePath ?? process.env.RECALL_NODE_PATH ?? process.execPath,
1459
- options.cliPath ?? resolveCliPath2(),
1460
- "hook",
1461
- "codex-notify"
1462
- ];
1463
- return `${MANAGED_START}
1464
- notify = ${renderTomlStringArray(command)}
1465
- ${MANAGED_END}
1466
- `;
1467
- }
1468
- function resolveCliPath2() {
1469
- const fromEnv = process.env.RECALL_CLI_PATH;
1470
- if (fromEnv && existsSync2(fromEnv)) {
1471
- return resolve2(fromEnv);
1472
- }
1473
- const fromArgv = process.argv[1];
1474
- if (fromArgv && /(?:^|\/)cli\.[cm]?js$/.test(fromArgv) && existsSync2(fromArgv)) {
1475
- return resolve2(fromArgv);
1476
- }
1477
- const sibling = resolve2(dirname2(fileURLToPath2(import.meta.url)), "..", "cli.js");
1478
- if (existsSync2(sibling)) {
1479
- return sibling;
1480
- }
1481
- const distCli = resolve2(process.cwd(), "dist", "cli.js");
1482
- if (existsSync2(distCli)) {
1483
- return distCli;
1484
- }
1485
- throw new Error("Unable to resolve Recall CLI path for Codex notify bridge");
1486
- }
1487
- function stripManagedBlock(content) {
1488
- if (!content.includes(MANAGED_START)) {
1489
- return content;
1490
- }
1491
- return content.replace(new RegExp(`${escapeRegExp(MANAGED_START)}[\\s\\S]*?${escapeRegExp(MANAGED_END)}\\n?`, "g"), "").replace(/\n{3,}/g, "\n\n").replace(/^\n+/, "").replace(/\s+$/, "");
1492
- }
1493
- function appendManagedBlock(content, block) {
1494
- const trimmed = content.trim();
1495
- if (trimmed.length === 0) {
1496
- return block;
1497
- }
1498
- return `${trimmed}
1499
-
1500
- ${block}`;
1501
- }
1502
- function hasUnmanagedNotify(content) {
1503
- return /^\s*notify\s*=.*$/m.test(content);
1504
- }
1505
- function renderTomlStringArray(values) {
1506
- return `[${values.map((value) => JSON.stringify(value)).join(", ")}]`;
1507
- }
1508
- function writeConfigFile(rawConfigPath, previousRaw, nextRaw) {
1509
- const configPathValue = resolveWriteTarget(rawConfigPath);
1510
- const parentDir = dirname2(configPathValue);
1511
- mkdirSync2(parentDir, { recursive: true });
1512
- if (previousRaw != null) {
1513
- writeFileSync2(`${configPathValue}.recall.bak.${Date.now()}`, previousRaw);
1514
- }
1515
- const tmpPath = `${configPathValue}.tmp.${process.pid}`;
1516
- writeFileSync2(tmpPath, normalizeTrailingNewline(nextRaw));
1517
- renameSync2(tmpPath, configPathValue);
1518
- }
1519
- function normalizeTrailingNewline(content) {
1520
- return content.trim().length === 0 ? "" : `${content.trimEnd()}
1521
- `;
1522
- }
1523
- function escapeRegExp(value) {
1524
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1525
- }
1238
+ // src/agents/index.ts
1239
+ init_define_RECALL_BUILD_INFO();
1526
1240
 
1527
1241
  // src/agents/cursor.ts
1242
+ init_define_RECALL_BUILD_INFO();
1528
1243
  import { join as join3 } from "path";
1529
1244
 
1530
1245
  // src/agents/hookless.ts
1531
- import { existsSync as existsSync5 } from "fs";
1532
- import { resolve as resolve3 } from "path";
1246
+ init_define_RECALL_BUILD_INFO();
1247
+ import { existsSync as existsSync4 } from "fs";
1248
+ import { resolve as resolve2 } from "path";
1533
1249
 
1534
1250
  // src/agents/mcp-json.ts
1535
- import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, renameSync as renameSync3, writeFileSync as writeFileSync3 } from "fs";
1536
- import { dirname as dirname3 } from "path";
1251
+ init_define_RECALL_BUILD_INFO();
1252
+ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "fs";
1253
+ import { dirname as dirname2 } from "path";
1537
1254
  var RECALL_SERVER_KEY = "recall";
1538
1255
  function commandArgsEntry(spec) {
1539
1256
  return {
@@ -1594,7 +1311,7 @@ function writeMcpServerEntry(target, spec) {
1594
1311
  }
1595
1312
  function removeMcpServerEntry(target) {
1596
1313
  const serverKey = target.serverKey ?? RECALL_SERVER_KEY;
1597
- if (!existsSync3(target.configPath)) {
1314
+ if (!existsSync2(target.configPath)) {
1598
1315
  return {
1599
1316
  ok: true,
1600
1317
  changed: false,
@@ -1629,15 +1346,15 @@ function removeMcpServerEntry(target) {
1629
1346
  };
1630
1347
  }
1631
1348
  function hasMcpServerEntry(target) {
1632
- if (!existsSync3(target.configPath)) return false;
1349
+ if (!existsSync2(target.configPath)) return false;
1633
1350
  const read = readJsonConfig(target.configPath);
1634
1351
  if (read.error) return false;
1635
1352
  const container = asObject(read.parsed[target.containerKey]);
1636
1353
  return Boolean(container && (target.serverKey ?? RECALL_SERVER_KEY) in container);
1637
1354
  }
1638
- function readJsonConfig(configPath3) {
1639
- if (!existsSync3(configPath3)) return { raw: null, parsed: {} };
1640
- const raw = readFileSync3(configPath3, "utf-8");
1355
+ function readJsonConfig(configPath2) {
1356
+ if (!existsSync2(configPath2)) return { raw: null, parsed: {} };
1357
+ const raw = readFileSync2(configPath2, "utf-8");
1641
1358
  if (raw.trim().length === 0) return { raw, parsed: {} };
1642
1359
  let parsed;
1643
1360
  try {
@@ -1646,24 +1363,24 @@ function readJsonConfig(configPath3) {
1646
1363
  return {
1647
1364
  raw,
1648
1365
  parsed: {},
1649
- error: `Could not parse ${configPath3} as JSON \u2014 add the Recall MCP server manually`
1366
+ error: `Could not parse ${configPath2} as JSON \u2014 add the Recall MCP server manually`
1650
1367
  };
1651
1368
  }
1652
1369
  const object = asObject(parsed);
1653
1370
  if (!object) {
1654
- return { raw, parsed: {}, error: `${configPath3} must contain a JSON object` };
1371
+ return { raw, parsed: {}, error: `${configPath2} must contain a JSON object` };
1655
1372
  }
1656
1373
  return { raw, parsed: object };
1657
1374
  }
1658
- function writeJsonConfig(configPath3, previousRaw, value) {
1659
- mkdirSync3(dirname3(configPath3), { recursive: true });
1375
+ function writeJsonConfig(configPath2, previousRaw, value) {
1376
+ mkdirSync2(dirname2(configPath2), { recursive: true });
1660
1377
  if (previousRaw != null) {
1661
- writeFileSync3(`${configPath3}.recall.bak.${Date.now()}`, previousRaw);
1378
+ writeFileSync2(`${configPath2}.recall.bak.${Date.now()}`, previousRaw);
1662
1379
  }
1663
- const tmpPath = `${configPath3}.tmp.${process.pid}`;
1664
- writeFileSync3(tmpPath, `${JSON.stringify(value, null, 2)}
1380
+ const tmpPath = `${configPath2}.tmp.${process.pid}`;
1381
+ writeFileSync2(tmpPath, `${JSON.stringify(value, null, 2)}
1665
1382
  `);
1666
- renameSync3(tmpPath, configPath3);
1383
+ renameSync2(tmpPath, configPath2);
1667
1384
  }
1668
1385
  function ensureContainer(config, key) {
1669
1386
  if (config[key] === void 0) {
@@ -1682,8 +1399,9 @@ function sameJson2(left, right) {
1682
1399
  }
1683
1400
 
1684
1401
  // src/agents/rules-block.ts
1685
- import { existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync4, rmSync, writeFileSync as writeFileSync4 } from "fs";
1686
- import { dirname as dirname4 } from "path";
1402
+ init_define_RECALL_BUILD_INFO();
1403
+ import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
1404
+ import { dirname as dirname3 } from "path";
1687
1405
  function beginMarker(block) {
1688
1406
  return `<!-- recall:managed:${block.name}:begin v${block.version} -->`;
1689
1407
  }
@@ -1691,14 +1409,14 @@ function endMarker(block) {
1691
1409
  return `<!-- recall:managed:${block.name}:end -->`;
1692
1410
  }
1693
1411
  function anyBeginMarkerRe(block) {
1694
- return new RegExp(`<!--\\s*recall:managed:${escapeRegExp2(block.name)}:begin(?:\\s+v\\d+)?\\s*-->`);
1412
+ return new RegExp(`<!--\\s*recall:managed:${escapeRegExp(block.name)}:begin(?:\\s+v\\d+)?\\s*-->`);
1695
1413
  }
1696
1414
  function blockRe(block) {
1697
1415
  return blockReForName(block.name);
1698
1416
  }
1699
1417
  function blockReForName(name) {
1700
1418
  return new RegExp(
1701
- `<!--\\s*recall:managed:${escapeRegExp2(name)}:begin(?:\\s+v\\d+)?\\s*-->[\\s\\S]*?<!--\\s*recall:managed:${escapeRegExp2(name)}:end\\s*-->\\n?`,
1419
+ `<!--\\s*recall:managed:${escapeRegExp(name)}:begin(?:\\s+v\\d+)?\\s*-->[\\s\\S]*?<!--\\s*recall:managed:${escapeRegExp(name)}:end\\s*-->\\n?`,
1702
1420
  "g"
1703
1421
  );
1704
1422
  }
@@ -1710,7 +1428,7 @@ ${endMarker(block)}
1710
1428
  }
1711
1429
  function installManagedRules(targetPath, block) {
1712
1430
  const desired = renderManagedBlock(block);
1713
- const existing = existsSync4(targetPath) ? readFileSync4(targetPath, "utf-8") : "";
1431
+ const existing = existsSync3(targetPath) ? readFileSync3(targetPath, "utf-8") : "";
1714
1432
  if (existing.includes(beginMarker(block)) && existing.includes(block.body)) {
1715
1433
  return {
1716
1434
  ok: true,
@@ -1720,8 +1438,8 @@ function installManagedRules(targetPath, block) {
1720
1438
  };
1721
1439
  }
1722
1440
  const next = block.ownsFile ? `${block.preamble ?? ""}${desired}` : mergeIntoExisting(existing, desired, block);
1723
- mkdirSync4(dirname4(targetPath), { recursive: true });
1724
- writeFileSync4(targetPath, next);
1441
+ mkdirSync3(dirname3(targetPath), { recursive: true });
1442
+ writeFileSync3(targetPath, next);
1725
1443
  return {
1726
1444
  ok: true,
1727
1445
  changed: true,
@@ -1730,10 +1448,10 @@ function installManagedRules(targetPath, block) {
1730
1448
  };
1731
1449
  }
1732
1450
  function uninstallManagedRules(targetPath, block) {
1733
- if (!existsSync4(targetPath)) {
1451
+ if (!existsSync3(targetPath)) {
1734
1452
  return { ok: true, changed: false, config_path: targetPath, message: `${targetPath} not present` };
1735
1453
  }
1736
- const existing = readFileSync4(targetPath, "utf-8");
1454
+ const existing = readFileSync3(targetPath, "utf-8");
1737
1455
  const hasCurrent = anyBeginMarkerRe(block).test(existing);
1738
1456
  const hasLegacy = findLegacyBlock(existing, block) !== null;
1739
1457
  if (!hasCurrent && !hasLegacy) {
@@ -1746,10 +1464,10 @@ function uninstallManagedRules(targetPath, block) {
1746
1464
  }
1747
1465
  const stripped = removeLegacyBlocks(existing.replace(blockRe(block), ""), block).replace(/\n{3,}/g, "\n\n");
1748
1466
  if (block.ownsFile && stripped.trim() === (block.preamble ?? "").trim()) {
1749
- rmSync(targetPath, { force: true });
1467
+ rmSync2(targetPath, { force: true });
1750
1468
  return { ok: true, changed: true, config_path: targetPath, message: `Removed ${targetPath}` };
1751
1469
  }
1752
- writeFileSync4(targetPath, stripped.trim().length === 0 ? "" : ensureTrailingNewline(stripped));
1470
+ writeFileSync3(targetPath, stripped.trim().length === 0 ? "" : ensureTrailingNewline(stripped));
1753
1471
  return {
1754
1472
  ok: true,
1755
1473
  changed: true,
@@ -1758,10 +1476,10 @@ function uninstallManagedRules(targetPath, block) {
1758
1476
  };
1759
1477
  }
1760
1478
  function checkManagedRules(targetPath, block) {
1761
- if (!existsSync4(targetPath)) {
1479
+ if (!existsSync3(targetPath)) {
1762
1480
  return { status: "absent_no_file", config_path: targetPath };
1763
1481
  }
1764
- const content = readFileSync4(targetPath, "utf-8");
1482
+ const content = readFileSync3(targetPath, "utf-8");
1765
1483
  if (!anyBeginMarkerRe(block).test(content)) {
1766
1484
  if (findLegacyBlock(content, block)) {
1767
1485
  return { status: "stale", config_path: targetPath };
@@ -1804,7 +1522,7 @@ function ensureTrailingNewline(content) {
1804
1522
  return content.endsWith("\n") ? content : `${content}
1805
1523
  `;
1806
1524
  }
1807
- function escapeRegExp2(value) {
1525
+ function escapeRegExp(value) {
1808
1526
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1809
1527
  }
1810
1528
  function buildRecallRulesBody(toolLabel) {
@@ -1823,13 +1541,13 @@ Reinstall: \`recall setup\`. Remove: \`recall setup --uninstall-hooks\`.`;
1823
1541
 
1824
1542
  // src/agents/hookless.ts
1825
1543
  function createHooklessAdapter(spec) {
1826
- const configPath3 = (options = {}) => spec.mcpTarget(options).configPath;
1544
+ const configPath2 = (options = {}) => spec.mcpTarget(options).configPath;
1827
1545
  return {
1828
1546
  name: spec.name,
1829
- configPath: configPath3,
1547
+ configPath: configPath2,
1830
1548
  detect(options = {}) {
1831
1549
  const byCommand = (spec.commands ?? []).some((command) => hasCommand(command));
1832
- const byPath = (spec.markerPaths?.(options) ?? []).some((path) => existsSync5(path));
1550
+ const byPath = (spec.markerPaths?.(options) ?? []).some((path) => existsSync4(path));
1833
1551
  return byCommand || byPath ? "installed" : "not-installed";
1834
1552
  },
1835
1553
  capabilities() {
@@ -1896,7 +1614,7 @@ function resolveServerSpec(options, label) {
1896
1614
  return { nodePath, mcpPath };
1897
1615
  }
1898
1616
  function projectPath(options, ...segments) {
1899
- return resolve3(options.cwd ?? process.cwd(), ...segments);
1617
+ return resolve2(options.cwd ?? process.cwd(), ...segments);
1900
1618
  }
1901
1619
 
1902
1620
  // src/agents/cursor.ts
@@ -1942,6 +1660,7 @@ var cursorAdapter = createHooklessAdapter({
1942
1660
  });
1943
1661
 
1944
1662
  // src/agents/gemini-cli.ts
1663
+ init_define_RECALL_BUILD_INFO();
1945
1664
  var geminiCliAdapter = {
1946
1665
  name: "gemini-cli",
1947
1666
  configPath() {
@@ -1983,6 +1702,7 @@ var geminiCliAdapter = {
1983
1702
  };
1984
1703
 
1985
1704
  // src/agents/github-copilot.ts
1705
+ init_define_RECALL_BUILD_INFO();
1986
1706
  import { join as join4 } from "path";
1987
1707
  var LABEL2 = "GitHub Copilot";
1988
1708
  function copilotHome(options = {}) {
@@ -2016,6 +1736,7 @@ var githubCopilotAdapter = createHooklessAdapter({
2016
1736
  });
2017
1737
 
2018
1738
  // src/agents/opencode.ts
1739
+ init_define_RECALL_BUILD_INFO();
2019
1740
  import { join as join5 } from "path";
2020
1741
  var LABEL3 = "opencode";
2021
1742
  function opencodeConfigDir(options = {}) {
@@ -2049,6 +1770,7 @@ var opencodeAdapter = createHooklessAdapter({
2049
1770
  });
2050
1771
 
2051
1772
  // src/agents/qwen.ts
1773
+ init_define_RECALL_BUILD_INFO();
2052
1774
  var qwenAdapter = {
2053
1775
  name: "qwen",
2054
1776
  configPath() {
@@ -2090,6 +1812,7 @@ var qwenAdapter = {
2090
1812
  };
2091
1813
 
2092
1814
  // src/agents/windsurf.ts
1815
+ init_define_RECALL_BUILD_INFO();
2093
1816
  import { join as join6 } from "path";
2094
1817
  var LABEL4 = "Windsurf";
2095
1818
  function windsurfConfigDir(options = {}) {
@@ -2121,6 +1844,9 @@ var windsurfAdapter = createHooklessAdapter({
2121
1844
  rulesScope: "global"
2122
1845
  });
2123
1846
 
1847
+ // src/agents/types.ts
1848
+ init_define_RECALL_BUILD_INFO();
1849
+
2124
1850
  // src/agents/index.ts
2125
1851
  var adapters = {
2126
1852
  "claude-code": claudeCodeAdapter,
@@ -2156,7 +1882,16 @@ function resolveAdapter(name) {
2156
1882
 
2157
1883
  // src/setup/local.ts
2158
1884
  function resolveRuntimePaths(appPath) {
2159
- if (appPath || process.platform === "darwin" && existsSync6("/Applications/Recall.app")) {
1885
+ const override = process.env.RECALL_RUNTIME_DIR;
1886
+ if (override) {
1887
+ return {
1888
+ appPath: override,
1889
+ runtimeNodePath: join7(override, "bin", "node"),
1890
+ runtimeCliPath: join7(override, "dist", "cli.js"),
1891
+ runtimeMcpPath: join7(override, "dist", "mcp.js")
1892
+ };
1893
+ }
1894
+ if (appPath || process.platform === "darwin" && existsSync5("/Applications/Recall.app")) {
2160
1895
  const resolvedAppPath = appPath ?? "/Applications/Recall.app";
2161
1896
  const runtimeRoot = join7(resolvedAppPath, "Contents", "Resources", "Runtime");
2162
1897
  return {
@@ -2166,7 +1901,7 @@ function resolveRuntimePaths(appPath) {
2166
1901
  runtimeMcpPath: join7(runtimeRoot, "dist", "mcp.js")
2167
1902
  };
2168
1903
  }
2169
- const distDir = dirname5(fileURLToPath3(import.meta.url));
1904
+ const distDir = dirname4(fileURLToPath2(import.meta.url));
2170
1905
  return {
2171
1906
  appPath: distDir,
2172
1907
  runtimeNodePath: process.execPath,
@@ -2211,17 +1946,17 @@ function runRecallSetup(opts = {}) {
2211
1946
  const uninstallHooks = opts.uninstallHooks ?? false;
2212
1947
  const runner = opts.runner ?? defaultRunner;
2213
1948
  const paths = resolveRuntimePaths(opts.appPath);
2214
- if (!existsSync6(paths.runtimeNodePath)) {
1949
+ if (!existsSync5(paths.runtimeNodePath)) {
2215
1950
  throw new Error(`Node runtime not found at ${paths.runtimeNodePath}`);
2216
1951
  }
2217
- if (!existsSync6(paths.runtimeCliPath)) {
1952
+ if (!existsSync5(paths.runtimeCliPath)) {
2218
1953
  throw new Error(`Recall CLI entry not found at ${paths.runtimeCliPath}`);
2219
1954
  }
2220
- if (!existsSync6(paths.runtimeMcpPath)) {
1955
+ if (!existsSync5(paths.runtimeMcpPath)) {
2221
1956
  throw new Error(`Recall MCP entry not found at ${paths.runtimeMcpPath}`);
2222
1957
  }
2223
1958
  const targetAgents = resolveTargetAgents(opts.agent);
2224
- const cwd = resolve4(opts.cwd ?? process.cwd());
1959
+ const cwd = resolve3(opts.cwd ?? process.cwd());
2225
1960
  const claudeMdEnabled = opts.claudeMd ?? true;
2226
1961
  const agents = targetAgents.map(
2227
1962
  (agent) => setupAgent(agent, {
@@ -2352,9 +2087,9 @@ function configureMcp(agent, options) {
2352
2087
  }
2353
2088
  function configureHooks(agent, options) {
2354
2089
  const codexTargets = agent === "codex" ? options.scope === "project" ? [{
2355
- home: dirname5(options.configPath),
2090
+ home: dirname4(options.configPath),
2356
2091
  configPath: options.configPath,
2357
- hooksPath: join7(dirname5(options.configPath), "hooks.json")
2092
+ hooksPath: join7(dirname4(options.configPath), "hooks.json")
2358
2093
  }] : resolveCodexHookTargets() : [];
2359
2094
  if (options.dryRun) {
2360
2095
  const base = options.uninstallHooks ? `would remove hooks from ${options.configPath}` : `would install hooks into ${options.configPath}${options.promptInjection === false ? " (prompt injection opt-out)" : ""}`;
@@ -2403,10 +2138,10 @@ function resolveTargetAgents(target) {
2403
2138
  }
2404
2139
  function detectAgent(agent) {
2405
2140
  if (agent === "codex") {
2406
- return hasCommand("codex") || existsSync6(join7(resolveUserHomeDir(), ".codex", "config.toml"));
2141
+ return hasCommand("codex") || existsSync5(join7(resolveUserHomeDir(), ".codex", "config.toml"));
2407
2142
  }
2408
2143
  if (agent === "claude-code") {
2409
- return hasCommand("claude") || existsSync6(join7(resolveUserHomeDir(), ".claude", "settings.json"));
2144
+ return hasCommand("claude") || existsSync5(join7(resolveUserHomeDir(), ".claude", "settings.json"));
2410
2145
  }
2411
2146
  return resolveAdapter(agent).detect() === "installed";
2412
2147
  }
@@ -2417,7 +2152,7 @@ function resolveHookConfigPath(agent, scope, cwd) {
2417
2152
  return agent === "codex" ? join7(resolveUserHomeDir(), ".codex", "config.toml") : join7(resolveUserHomeDir(), ".claude", "settings.json");
2418
2153
  }
2419
2154
  function defaultRunner(command, args, options) {
2420
- execFileSync4(command, args, { ...stdioOpts(), ...options?.env ? { env: options.env } : {} });
2155
+ execFileSync2(command, args, { ...stdioOpts(), ...options?.env ? { env: options.env } : {} });
2421
2156
  }
2422
2157
  function tryRun(runner, command, args, options) {
2423
2158
  try {
@@ -2440,20 +2175,23 @@ function skipped(message) {
2440
2175
 
2441
2176
  // src/cli.ts
2442
2177
  import { createRequire } from "module";
2443
- import { fileURLToPath as fileURLToPath5 } from "url";
2178
+ import { fileURLToPath as fileURLToPath4 } from "url";
2444
2179
 
2445
2180
  // src/doctor/report.ts
2446
- import { existsSync as existsSync9, readFileSync as readFileSync6 } from "fs";
2181
+ init_define_RECALL_BUILD_INFO();
2182
+ import { existsSync as existsSync8, readFileSync as readFileSync5 } from "fs";
2447
2183
  import { basename as basename2, join as join10 } from "path";
2448
- import Database from "better-sqlite3";
2184
+ import Database2 from "better-sqlite3";
2449
2185
 
2450
2186
  // src/daemon/launchd.ts
2451
- import { chmodSync, existsSync as existsSync7, mkdirSync as mkdirSync5, rmSync as rmSync2, writeFileSync as writeFileSync5 } from "fs";
2452
- import { homedir as homedir2 } from "os";
2453
- import { dirname as dirname6, join as join8, resolve as resolve5 } from "path";
2454
- import { execFileSync as execFileSync5 } from "child_process";
2187
+ init_define_RECALL_BUILD_INFO();
2188
+ import { chmodSync, existsSync as existsSync6, mkdirSync as mkdirSync4, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "fs";
2189
+ import { homedir } from "os";
2190
+ import { dirname as dirname5, join as join8, resolve as resolve4 } from "path";
2191
+ import { execFileSync as execFileSync3 } from "child_process";
2455
2192
 
2456
2193
  // src/daemon/provider-env.ts
2194
+ init_define_RECALL_BUILD_INFO();
2457
2195
  var DAEMON_PROVIDER_ENV_KEYS = [
2458
2196
  "OPENAI_API_KEY",
2459
2197
  "ANTHROPIC_API_KEY",
@@ -2488,14 +2226,14 @@ var DEFAULT_LABEL = "com.recall.daemon";
2488
2226
  function installLaunchAgent(opts = {}) {
2489
2227
  assertDarwin();
2490
2228
  const cfg = resolveConfig(opts);
2491
- mkdirSync5(dirname6(cfg.plistPath), { recursive: true });
2492
- mkdirSync5(dirname6(cfg.stdoutPath), { recursive: true });
2493
- writeFileSync5(cfg.plistPath, renderPlist(cfg), { mode: 384 });
2229
+ mkdirSync4(dirname5(cfg.plistPath), { recursive: true });
2230
+ mkdirSync4(dirname5(cfg.stdoutPath), { recursive: true });
2231
+ writeFileSync4(cfg.plistPath, renderPlist(cfg), { mode: 384 });
2494
2232
  chmodSync(cfg.plistPath, 384);
2495
2233
  tryRun2("launchctl", ["bootout", domainTarget(), cfg.plistPath]);
2496
- execFileSync5("launchctl", ["bootstrap", domainTarget(), cfg.plistPath], stdioOpts2());
2497
- execFileSync5("launchctl", ["enable", `${domainTarget()}/${cfg.label}`], stdioOpts2());
2498
- execFileSync5("launchctl", ["kickstart", "-k", `${domainTarget()}/${cfg.label}`], stdioOpts2());
2234
+ execFileSync3("launchctl", ["bootstrap", domainTarget(), cfg.plistPath], stdioOpts2());
2235
+ execFileSync3("launchctl", ["enable", `${domainTarget()}/${cfg.label}`], stdioOpts2());
2236
+ execFileSync3("launchctl", ["kickstart", "-k", `${domainTarget()}/${cfg.label}`], stdioOpts2());
2499
2237
  return getLaunchAgentStatus(cfg.label);
2500
2238
  }
2501
2239
  function uninstallLaunchAgent(label = DEFAULT_LABEL) {
@@ -2503,7 +2241,7 @@ function uninstallLaunchAgent(label = DEFAULT_LABEL) {
2503
2241
  const cfg = resolveConfig({ label });
2504
2242
  tryRun2("launchctl", ["bootout", domainTarget(), cfg.plistPath]);
2505
2243
  tryRun2("launchctl", ["disable", `${domainTarget()}/${cfg.label}`]);
2506
- rmSync2(cfg.plistPath, { force: true });
2244
+ rmSync3(cfg.plistPath, { force: true });
2507
2245
  return getLaunchAgentStatus(cfg.label);
2508
2246
  }
2509
2247
  function startLaunchAgent(label = DEFAULT_LABEL) {
@@ -2512,9 +2250,9 @@ function startLaunchAgent(label = DEFAULT_LABEL) {
2512
2250
  if (!exists(cfg.plistPath)) {
2513
2251
  throw new Error(`LaunchAgent not installed: ${cfg.plistPath}`);
2514
2252
  }
2515
- execFileSync5("launchctl", ["enable", `${domainTarget()}/${cfg.label}`], stdioOpts2());
2253
+ execFileSync3("launchctl", ["enable", `${domainTarget()}/${cfg.label}`], stdioOpts2());
2516
2254
  tryRun2("launchctl", ["bootstrap", domainTarget(), cfg.plistPath]);
2517
- execFileSync5("launchctl", ["kickstart", "-k", `${domainTarget()}/${cfg.label}`], stdioOpts2());
2255
+ execFileSync3("launchctl", ["kickstart", "-k", `${domainTarget()}/${cfg.label}`], stdioOpts2());
2518
2256
  return getLaunchAgentStatus(cfg.label);
2519
2257
  }
2520
2258
  function stopLaunchAgent(label = DEFAULT_LABEL) {
@@ -2557,6 +2295,9 @@ function getLaunchAgentInfo(label = DEFAULT_LABEL) {
2557
2295
  if (installed?.repoRoots ?? cfg.repoRoots) {
2558
2296
  lines.push(`Repos: ${installed?.repoRoots ?? cfg.repoRoots}`);
2559
2297
  }
2298
+ if (installed?.repoOverride ?? cfg.repoOverride) {
2299
+ lines.push(`Repo: ${installed?.repoOverride ?? cfg.repoOverride}`);
2300
+ }
2560
2301
  if (installed?.embeddingProvider ?? cfg.embeddingProvider) {
2561
2302
  lines.push(`EmbedProv: ${installed?.embeddingProvider ?? cfg.embeddingProvider}`);
2562
2303
  }
@@ -2575,14 +2316,14 @@ function getLaunchAgentInfo(label = DEFAULT_LABEL) {
2575
2316
  }
2576
2317
  function resolveConfig(opts) {
2577
2318
  const label = opts.label ?? DEFAULT_LABEL;
2578
- const home = homedir2();
2319
+ const home = homedir();
2579
2320
  const port = opts.port ?? parseInt(process.env.RECALL_PORT ?? "7890", 10);
2580
- const maintenanceIntervalSeconds = opts.maintenanceIntervalSeconds ?? parseInt(process.env.RECALL_MAINTENANCE_INTERVAL_SECONDS ?? "300", 10);
2581
- const dataDir = resolve5(
2321
+ const maintenanceIntervalSeconds = opts.maintenanceIntervalSeconds ?? parseInt(process.env.RECALL_MAINTENANCE_INTERVAL_SECONDS ?? "3600", 10);
2322
+ const dataDir = resolve4(
2582
2323
  opts.dataDir ?? process.env.RECALL_DATA_DIR ?? join8(home, ".recall")
2583
2324
  );
2584
- const nodePath = resolve5(opts.nodePath ?? process.execPath);
2585
- const daemonScript = resolve5(
2325
+ const nodePath = resolve4(opts.nodePath ?? process.execPath);
2326
+ const daemonScript = resolve4(
2586
2327
  opts.daemonScript ?? join8(process.cwd(), "dist", "daemon.js")
2587
2328
  );
2588
2329
  const plistPath = join8(home, "Library", "LaunchAgents", `${label}.plist`);
@@ -2599,6 +2340,7 @@ function resolveConfig(opts) {
2599
2340
  stdoutPath: join8(logDir, "daemon.stdout.log"),
2600
2341
  stderrPath: join8(logDir, "daemon.stderr.log"),
2601
2342
  repoRoots: opts.repoRoots ?? process.env.RECALL_REPO_ROOTS,
2343
+ repoOverride: opts.repoOverride ?? process.env.RECALL_REPO_OVERRIDE ?? installed?.repoOverride,
2602
2344
  embeddingProvider: opts.embeddingProvider ?? process.env.RECALL_EMBEDDING_PROVIDER,
2603
2345
  embeddingDims: opts.embeddingDims ?? process.env.RECALL_EMBEDDING_DIMS,
2604
2346
  embeddingsDisabled: opts.embeddingsDisabled ?? process.env.RECALL_EMBEDDINGS_DISABLED,
@@ -2615,6 +2357,7 @@ function renderPlist(cfg) {
2615
2357
  RECALL_DATA_DIR: cfg.dataDir,
2616
2358
  PATH: process.env.PATH ?? "/usr/bin:/bin:/usr/sbin:/sbin",
2617
2359
  ...cfg.repoRoots ? { RECALL_REPO_ROOTS: cfg.repoRoots } : {},
2360
+ ...cfg.repoOverride ? { RECALL_REPO_OVERRIDE: cfg.repoOverride } : {},
2618
2361
  ...cfg.embeddingProvider ? { RECALL_EMBEDDING_PROVIDER: cfg.embeddingProvider } : {},
2619
2362
  ...cfg.embeddingDims ? { RECALL_EMBEDDING_DIMS: cfg.embeddingDims } : {},
2620
2363
  ...cfg.embeddingsDisabled ? { RECALL_EMBEDDINGS_DISABLED: cfg.embeddingsDisabled } : {},
@@ -2665,14 +2408,14 @@ function extractState(output) {
2665
2408
  }
2666
2409
  function tryRun2(cmd, args) {
2667
2410
  try {
2668
- execFileSync5(cmd, args, stdioOpts2());
2411
+ execFileSync3(cmd, args, stdioOpts2());
2669
2412
  } catch {
2670
2413
  return;
2671
2414
  }
2672
2415
  }
2673
2416
  function tryOutput(cmd, args) {
2674
2417
  try {
2675
- const output = execFileSync5(cmd, args, {
2418
+ const output = execFileSync3(cmd, args, {
2676
2419
  encoding: "utf8",
2677
2420
  stdio: ["ignore", "pipe", "pipe"]
2678
2421
  });
@@ -2687,7 +2430,7 @@ function tryOutput(cmd, args) {
2687
2430
  function readInstalledConfig(plistPath) {
2688
2431
  if (!exists(plistPath)) return null;
2689
2432
  try {
2690
- const raw = execFileSync5("plutil", ["-convert", "json", "-o", "-", plistPath], {
2433
+ const raw = execFileSync3("plutil", ["-convert", "json", "-o", "-", plistPath], {
2691
2434
  encoding: "utf8",
2692
2435
  stdio: ["ignore", "pipe", "pipe"]
2693
2436
  });
@@ -2699,6 +2442,7 @@ function readInstalledConfig(plistPath) {
2699
2442
  maintenanceIntervalSeconds: parsed?.EnvironmentVariables?.RECALL_MAINTENANCE_INTERVAL_SECONDS,
2700
2443
  dataDir: parsed?.EnvironmentVariables?.RECALL_DATA_DIR,
2701
2444
  repoRoots: parsed?.EnvironmentVariables?.RECALL_REPO_ROOTS,
2445
+ repoOverride: parsed?.EnvironmentVariables?.RECALL_REPO_OVERRIDE,
2702
2446
  embeddingProvider: parsed?.EnvironmentVariables?.RECALL_EMBEDDING_PROVIDER,
2703
2447
  embeddingDims: parsed?.EnvironmentVariables?.RECALL_EMBEDDING_DIMS,
2704
2448
  embeddingsDisabled: parsed?.EnvironmentVariables?.RECALL_EMBEDDINGS_DISABLED,
@@ -2718,7 +2462,7 @@ function stdioOpts2() {
2718
2462
  };
2719
2463
  }
2720
2464
  function exists(path) {
2721
- return existsSync7(path);
2465
+ return existsSync6(path);
2722
2466
  }
2723
2467
  function escapeXml(value) {
2724
2468
  return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&apos;");
@@ -2730,18 +2474,19 @@ function assertDarwin() {
2730
2474
  }
2731
2475
 
2732
2476
  // src/daemon/systemd.ts
2733
- import { chmodSync as chmodSync2, existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync5, rmSync as rmSync3, writeFileSync as writeFileSync6 } from "fs";
2734
- import { homedir as homedir3 } from "os";
2735
- import { dirname as dirname7, join as join9, resolve as resolve6 } from "path";
2736
- import { fileURLToPath as fileURLToPath4 } from "url";
2737
- import { execFileSync as execFileSync6 } from "child_process";
2477
+ init_define_RECALL_BUILD_INFO();
2478
+ import { chmodSync as chmodSync2, existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync4, rmSync as rmSync4, writeFileSync as writeFileSync5 } from "fs";
2479
+ import { homedir as homedir2 } from "os";
2480
+ import { dirname as dirname6, join as join9, resolve as resolve5 } from "path";
2481
+ import { fileURLToPath as fileURLToPath3 } from "url";
2482
+ import { execFileSync as execFileSync4 } from "child_process";
2738
2483
  var DEFAULT_LABEL2 = "recall-daemon";
2739
2484
  function installSystemdUnit(opts = {}) {
2740
2485
  assertLinux();
2741
2486
  const cfg = resolveConfig2(opts);
2742
- mkdirSync6(dirname7(cfg.unitPath), { recursive: true });
2743
- mkdirSync6(cfg.logDir, { recursive: true });
2744
- writeFileSync6(cfg.unitPath, renderUnit(cfg), { mode: 384 });
2487
+ mkdirSync5(dirname6(cfg.unitPath), { recursive: true });
2488
+ mkdirSync5(cfg.logDir, { recursive: true });
2489
+ writeFileSync5(cfg.unitPath, renderUnit(cfg), { mode: 384 });
2745
2490
  chmodSync2(cfg.unitPath, 384);
2746
2491
  for (const args of systemdInstallCommands(cfg.label)) systemctl(args);
2747
2492
  return getSystemdStatus(cfg.label);
@@ -2760,14 +2505,14 @@ function uninstallSystemdUnit(label = DEFAULT_LABEL2) {
2760
2505
  assertLinux();
2761
2506
  const cfg = resolveConfig2({ label });
2762
2507
  trySystemctl(["--user", "disable", "--now", `${cfg.label}.service`]);
2763
- rmSync3(cfg.unitPath, { force: true });
2508
+ rmSync4(cfg.unitPath, { force: true });
2764
2509
  trySystemctl(["--user", "daemon-reload"]);
2765
2510
  return getSystemdStatus(cfg.label);
2766
2511
  }
2767
2512
  function startSystemdUnit(label = DEFAULT_LABEL2) {
2768
2513
  assertLinux();
2769
2514
  const cfg = resolveConfig2({ label });
2770
- if (!existsSync8(cfg.unitPath)) {
2515
+ if (!existsSync7(cfg.unitPath)) {
2771
2516
  throw new Error(`systemd unit not installed: ${cfg.unitPath}`);
2772
2517
  }
2773
2518
  systemctl(["--user", "start", `${cfg.label}.service`]);
@@ -2776,7 +2521,7 @@ function startSystemdUnit(label = DEFAULT_LABEL2) {
2776
2521
  function stopSystemdUnit(label = DEFAULT_LABEL2) {
2777
2522
  assertLinux();
2778
2523
  const cfg = resolveConfig2({ label });
2779
- if (existsSync8(cfg.unitPath)) {
2524
+ if (existsSync7(cfg.unitPath)) {
2780
2525
  trySystemctl(["--user", "stop", `${cfg.label}.service`]);
2781
2526
  }
2782
2527
  return getSystemdStatus(cfg.label);
@@ -2784,7 +2529,7 @@ function stopSystemdUnit(label = DEFAULT_LABEL2) {
2784
2529
  function getSystemdStatus(label = DEFAULT_LABEL2) {
2785
2530
  assertLinux();
2786
2531
  const cfg = resolveConfig2({ label });
2787
- const installed = existsSync8(cfg.unitPath);
2532
+ const installed = existsSync7(cfg.unitPath);
2788
2533
  const active = trySystemctlOutput(["--user", "is-active", `${cfg.label}.service`]);
2789
2534
  const loaded = active.ok && active.output.trim() === "active";
2790
2535
  const state = active.output.trim() || void 0;
@@ -2813,6 +2558,9 @@ function getSystemdInfo(label = DEFAULT_LABEL2) {
2813
2558
  if (installed?.repoRoots ?? cfg.repoRoots) {
2814
2559
  lines.push(`Repos: ${installed?.repoRoots ?? cfg.repoRoots}`);
2815
2560
  }
2561
+ if (installed?.repoOverride ?? cfg.repoOverride) {
2562
+ lines.push(`Repo: ${installed?.repoOverride ?? cfg.repoOverride}`);
2563
+ }
2816
2564
  if (installed?.embeddingProvider ?? cfg.embeddingProvider) {
2817
2565
  lines.push(`EmbedProv: ${installed?.embeddingProvider ?? cfg.embeddingProvider}`);
2818
2566
  }
@@ -2830,14 +2578,14 @@ function getSystemdInfo(label = DEFAULT_LABEL2) {
2830
2578
  }
2831
2579
  function resolveConfig2(opts) {
2832
2580
  const label = opts.label ?? DEFAULT_LABEL2;
2833
- const home = homedir3();
2581
+ const home = homedir2();
2834
2582
  const port = opts.port ?? parseInt(process.env.RECALL_PORT ?? "7890", 10);
2835
- const maintenanceIntervalSeconds = opts.maintenanceIntervalSeconds ?? parseInt(process.env.RECALL_MAINTENANCE_INTERVAL_SECONDS ?? "300", 10);
2836
- const dataDir = resolve6(
2583
+ const maintenanceIntervalSeconds = opts.maintenanceIntervalSeconds ?? parseInt(process.env.RECALL_MAINTENANCE_INTERVAL_SECONDS ?? "3600", 10);
2584
+ const dataDir = resolve5(
2837
2585
  opts.dataDir ?? process.env.RECALL_DATA_DIR ?? join9(home, ".recall")
2838
2586
  );
2839
- const nodePath = resolve6(opts.nodePath ?? process.execPath);
2840
- const daemonScript = resolve6(
2587
+ const nodePath = resolve5(opts.nodePath ?? process.execPath);
2588
+ const daemonScript = resolve5(
2841
2589
  opts.daemonScript ?? defaultDaemonScript()
2842
2590
  );
2843
2591
  const configHome = process.env.XDG_CONFIG_HOME ?? join9(home, ".config");
@@ -2854,6 +2602,7 @@ function resolveConfig2(opts) {
2854
2602
  unitPath,
2855
2603
  logDir,
2856
2604
  repoRoots: opts.repoRoots ?? process.env.RECALL_REPO_ROOTS,
2605
+ repoOverride: opts.repoOverride ?? process.env.RECALL_REPO_OVERRIDE ?? installed?.repoOverride,
2857
2606
  embeddingProvider: opts.embeddingProvider ?? process.env.RECALL_EMBEDDING_PROVIDER,
2858
2607
  embeddingDims: opts.embeddingDims ?? process.env.RECALL_EMBEDDING_DIMS,
2859
2608
  embeddingsDisabled: opts.embeddingsDisabled ?? process.env.RECALL_EMBEDDINGS_DISABLED,
@@ -2864,7 +2613,7 @@ function resolveConfig2(opts) {
2864
2613
  };
2865
2614
  }
2866
2615
  function defaultDaemonScript() {
2867
- const here = dirname7(fileURLToPath4(import.meta.url));
2616
+ const here = dirname6(fileURLToPath3(import.meta.url));
2868
2617
  return join9(here, "daemon.js");
2869
2618
  }
2870
2619
  function renderUnit(cfg) {
@@ -2875,6 +2624,7 @@ function renderUnit(cfg) {
2875
2624
  `Environment=RECALL_DATA_DIR=${cfg.dataDir}`
2876
2625
  ];
2877
2626
  if (cfg.repoRoots) envLines.push(`Environment=RECALL_REPO_ROOTS=${cfg.repoRoots}`);
2627
+ if (cfg.repoOverride) envLines.push(`Environment="RECALL_REPO_OVERRIDE=${escapeSystemdValue(cfg.repoOverride)}"`);
2878
2628
  if (cfg.embeddingProvider) envLines.push(`Environment=RECALL_EMBEDDING_PROVIDER=${cfg.embeddingProvider}`);
2879
2629
  if (cfg.embeddingDims) envLines.push(`Environment=RECALL_EMBEDDING_DIMS=${cfg.embeddingDims}`);
2880
2630
  if (cfg.embeddingsDisabled) envLines.push(`Environment=RECALL_EMBEDDINGS_DISABLED=${cfg.embeddingsDisabled}`);
@@ -2897,9 +2647,9 @@ WantedBy=default.target
2897
2647
  `;
2898
2648
  }
2899
2649
  function readInstalledConfig2(unitPath) {
2900
- if (!existsSync8(unitPath)) return null;
2650
+ if (!existsSync7(unitPath)) return null;
2901
2651
  try {
2902
- const raw = readFileSync5(unitPath, "utf8");
2652
+ const raw = readFileSync4(unitPath, "utf8");
2903
2653
  const exec = raw.match(/^ExecStart=(.+)$/m)?.[1]?.trim().split(/\s+/);
2904
2654
  const env = parseSystemdEnvironment(raw);
2905
2655
  return {
@@ -2909,6 +2659,7 @@ function readInstalledConfig2(unitPath) {
2909
2659
  maintenanceIntervalSeconds: env.RECALL_MAINTENANCE_INTERVAL_SECONDS,
2910
2660
  dataDir: env.RECALL_DATA_DIR,
2911
2661
  repoRoots: env.RECALL_REPO_ROOTS,
2662
+ repoOverride: env.RECALL_REPO_OVERRIDE,
2912
2663
  embeddingProvider: env.RECALL_EMBEDDING_PROVIDER,
2913
2664
  embeddingDims: env.RECALL_EMBEDDING_DIMS,
2914
2665
  embeddingsDisabled: env.RECALL_EMBEDDINGS_DISABLED,
@@ -2936,18 +2687,18 @@ function unescapeSystemdValue(value) {
2936
2687
  return value.replaceAll("%%", "%").replaceAll('\\"', '"').replaceAll("\\\\", "\\");
2937
2688
  }
2938
2689
  function systemctl(args) {
2939
- execFileSync6("systemctl", args, { stdio: "pipe" });
2690
+ execFileSync4("systemctl", args, { stdio: "pipe" });
2940
2691
  }
2941
2692
  function trySystemctl(args) {
2942
2693
  try {
2943
- execFileSync6("systemctl", args, { stdio: "pipe" });
2694
+ execFileSync4("systemctl", args, { stdio: "pipe" });
2944
2695
  } catch {
2945
2696
  return;
2946
2697
  }
2947
2698
  }
2948
2699
  function trySystemctlOutput(args) {
2949
2700
  try {
2950
- const output = execFileSync6("systemctl", args, {
2701
+ const output = execFileSync4("systemctl", args, {
2951
2702
  encoding: "utf8",
2952
2703
  stdio: ["ignore", "pipe", "pipe"]
2953
2704
  });
@@ -2965,6 +2716,47 @@ function assertLinux() {
2965
2716
  }
2966
2717
  }
2967
2718
 
2719
+ // src/doctor/hook-activity.ts
2720
+ init_define_RECALL_BUILD_INFO();
2721
+ import Database from "better-sqlite3";
2722
+ function readHookActivity(dbPath, agent, now = Date.now()) {
2723
+ let db;
2724
+ try {
2725
+ db = new Database(dbPath, { readonly: true, fileMustExist: true });
2726
+ const rows = db.prepare(
2727
+ "SELECT event, MAX(created_at) AS latest FROM hook_calls WHERE agent=? AND ok=1 GROUP BY event"
2728
+ ).all(agent);
2729
+ const events = Object.fromEntries(rows.map((r) => [r.event, r.latest]));
2730
+ const last = rows.map((r) => r.latest).sort().at(-1) ?? null;
2731
+ return {
2732
+ status: !last ? "never" : now - Date.parse(last) > 7 * 864e5 ? "stale" : "recent",
2733
+ last_success_at: last,
2734
+ events
2735
+ };
2736
+ } catch {
2737
+ return { status: "unavailable", last_success_at: null, events: {} };
2738
+ } finally {
2739
+ db?.close();
2740
+ }
2741
+ }
2742
+ function missingCodexTrustKeys(config, hooksPath, definition) {
2743
+ const events = definition?.hooks ?? {};
2744
+ const missing = [];
2745
+ for (const [event, groups] of Object.entries(events)) {
2746
+ if (!Array.isArray(groups)) continue;
2747
+ const snake = event.replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
2748
+ groups.forEach((group, gi) => group.hooks?.forEach((hook, hi) => {
2749
+ if (!hook.command?.includes("recall:managed:codex:")) return;
2750
+ const key = `${hooksPath}:${snake}:${gi}:${hi}`;
2751
+ const header = `[hooks.state.${JSON.stringify(key)}]`;
2752
+ const start = config.indexOf(header);
2753
+ const section = start < 0 ? "" : config.slice(start + header.length).split(/\n\s*\[/, 1)[0];
2754
+ if (!/\btrusted_hash\s*=\s*"sha256:[a-f0-9]+"/.test(section)) missing.push(key);
2755
+ }));
2756
+ }
2757
+ return missing;
2758
+ }
2759
+
2968
2760
  // src/doctor/report.ts
2969
2761
  function getDoctorReport() {
2970
2762
  const dbPath = getDbPath();
@@ -2993,6 +2785,9 @@ function getDoctorReport() {
2993
2785
  }
2994
2786
  })() : null;
2995
2787
  const agents = inspectAgentInstalls();
2788
+ for (const agent of agents) {
2789
+ if (agent.detected && !agent.hookless) agent.hook_activity = readHookActivity(dbPath, agent.agent);
2790
+ }
2996
2791
  return {
2997
2792
  db_path: dbPath,
2998
2793
  db_user_version: getDbUserVersion(dbPath),
@@ -3008,10 +2803,10 @@ function getDoctorReport() {
3008
2803
  };
3009
2804
  }
3010
2805
  function readDispatcherHealth(dbPath) {
3011
- if (!existsSync9(dbPath)) return null;
2806
+ if (!existsSync8(dbPath)) return null;
3012
2807
  let sqlite = null;
3013
2808
  try {
3014
- sqlite = new Database(dbPath, { readonly: true, fileMustExist: true });
2809
+ sqlite = new Database2(dbPath, { readonly: true, fileMustExist: true });
3015
2810
  const tables = sqlite.prepare(
3016
2811
  "SELECT name FROM sqlite_master WHERE type='table' AND name IN ('memory_maintenance_tasks','llm_usage')"
3017
2812
  ).all();
@@ -3056,10 +2851,10 @@ function readDispatcherHealth(dbPath) {
3056
2851
  }
3057
2852
  }
3058
2853
  function readCleanupHealth(dbPath) {
3059
- if (!existsSync9(dbPath)) return null;
2854
+ if (!existsSync8(dbPath)) return null;
3060
2855
  let sqlite = null;
3061
2856
  try {
3062
- sqlite = new Database(dbPath, { readonly: true, fileMustExist: true });
2857
+ sqlite = new Database2(dbPath, { readonly: true, fileMustExist: true });
3063
2858
  const tables = sqlite.prepare(
3064
2859
  "SELECT name FROM sqlite_master WHERE type='table' AND name IN ('maintenance_cleanup_log','memories','memory_injections')"
3065
2860
  ).all();
@@ -3091,6 +2886,7 @@ function readCleanupHealth(dbPath) {
3091
2886
  }
3092
2887
  let followedRate = null;
3093
2888
  let resolvedInjections = 0;
2889
+ let totalInjections = 0;
3094
2890
  if (names.has("memory_injections")) {
3095
2891
  const since = new Date(Date.now() - 14 * 864e5).toISOString();
3096
2892
  const rows = sqlite.prepare(
@@ -3098,6 +2894,7 @@ function readCleanupHealth(dbPath) {
3098
2894
  ).all(since);
3099
2895
  let followed = 0;
3100
2896
  for (const r of rows) {
2897
+ totalInjections += r.c;
3101
2898
  if (!r.outcome) continue;
3102
2899
  resolvedInjections += r.c;
3103
2900
  if (r.outcome === "followed") followed += r.c;
@@ -3111,7 +2908,8 @@ function readCleanupHealth(dbPath) {
3111
2908
  total_runs: totals.runs,
3112
2909
  pending_candidate_corrections: pending,
3113
2910
  followed_rate_resolved: followedRate,
3114
- resolved_injections: resolvedInjections
2911
+ resolved_injections: resolvedInjections,
2912
+ total_injections: totalInjections
3115
2913
  };
3116
2914
  } catch {
3117
2915
  return null;
@@ -3150,12 +2948,12 @@ function inspectAgentInstalls(homeDir) {
3150
2948
  function inspectHooklessInstall(agent, home) {
3151
2949
  const adapter = resolveAdapter(agent);
3152
2950
  if (adapter.detect({ homeDir: home }) !== "installed") return null;
3153
- const configPath3 = adapter.configPath({ homeDir: home });
2951
+ const configPath2 = adapter.configPath({ homeDir: home });
3154
2952
  const mcp = adapter.hasMcpRegistration?.({ homeDir: home }) ?? false;
3155
2953
  const rules = adapter.checkRules?.({ homeDir: home });
3156
2954
  const notes = [];
3157
2955
  if (!mcp) {
3158
- notes.push(`Recall MCP server not registered in ${configPath3} \u2014 run \`recall setup\``);
2956
+ notes.push(`Recall MCP server not registered in ${configPath2} \u2014 run \`recall setup\``);
3159
2957
  }
3160
2958
  if (rules && rules.status !== "current") {
3161
2959
  notes.push(
@@ -3169,22 +2967,22 @@ function inspectHooklessInstall(agent, home) {
3169
2967
  // No hook API exists, so "hooks" tracks the rules block that stands in for it.
3170
2968
  hooks: rules?.status === "current",
3171
2969
  hookless: true,
3172
- config_path: configPath3,
2970
+ config_path: configPath2,
3173
2971
  rules: rules?.status,
3174
2972
  rules_path: rules?.config_path,
3175
2973
  notes
3176
2974
  };
3177
2975
  }
3178
2976
  function inspectClaudeCodeInstall(home) {
3179
- const configPath3 = join10(home, ".claude", "settings.json");
2977
+ const configPath2 = join10(home, ".claude", "settings.json");
3180
2978
  const userConfigPath = join10(home, ".claude.json");
3181
- const detected = existsSync9(configPath3) || existsSync9(userConfigPath) || hasCommand("claude");
2979
+ const detected = existsSync8(configPath2) || existsSync8(userConfigPath) || hasCommand("claude");
3182
2980
  const notes = [];
3183
2981
  let mcp = false;
3184
2982
  let hooks = false;
3185
- if (existsSync9(configPath3)) {
2983
+ if (existsSync8(configPath2)) {
3186
2984
  try {
3187
- const parsed = JSON.parse(readFileSync6(configPath3, "utf-8"));
2985
+ const parsed = JSON.parse(readFileSync5(configPath2, "utf-8"));
3188
2986
  mcp = Boolean(parsed?.mcpServers?.recall);
3189
2987
  const hookGroups = parsed?.hooks ?? {};
3190
2988
  hooks = Object.values(hookGroups).some(
@@ -3194,14 +2992,14 @@ function inspectClaudeCodeInstall(home) {
3194
2992
  );
3195
2993
  if (!hooks) notes.push("No Recall-managed hooks found in settings.json");
3196
2994
  } catch (err) {
3197
- notes.push(`Could not parse ${configPath3}: ${err.message}`);
2995
+ notes.push(`Could not parse ${configPath2}: ${err.message}`);
3198
2996
  }
3199
2997
  } else if (detected) {
3200
2998
  notes.push("Claude CLI detected but settings.json missing");
3201
2999
  }
3202
- if (!mcp && existsSync9(userConfigPath)) {
3000
+ if (!mcp && existsSync8(userConfigPath)) {
3203
3001
  try {
3204
- const parsed = JSON.parse(readFileSync6(userConfigPath, "utf-8"));
3002
+ const parsed = JSON.parse(readFileSync5(userConfigPath, "utf-8"));
3205
3003
  mcp = Boolean(parsed?.mcpServers?.recall);
3206
3004
  } catch (err) {
3207
3005
  notes.push(`Could not parse ${userConfigPath}: ${err.message}`);
@@ -3223,26 +3021,34 @@ function inspectClaudeCodeInstall(home) {
3223
3021
  detected,
3224
3022
  mcp,
3225
3023
  hooks,
3226
- config_path: configPath3,
3024
+ config_path: configPath2,
3227
3025
  claude_md: claudeMd.status,
3228
3026
  claude_md_path: claudeMd.config_path,
3229
3027
  notes
3230
3028
  };
3231
3029
  }
3232
3030
  function inspectCodexHome(codexHome) {
3233
- const configPath3 = join10(codexHome, "config.toml");
3031
+ const configPath2 = join10(codexHome, "config.toml");
3234
3032
  const hooksPath = join10(codexHome, "hooks.json");
3235
- const detected = existsSync9(configPath3) || hasCommand("codex");
3033
+ const detected = existsSync8(configPath2) || hasCommand("codex");
3236
3034
  const notes = [];
3237
3035
  let mcp = false;
3238
3036
  let hooks = false;
3239
3037
  let legacy_notify_bridge = false;
3240
- if (existsSync9(configPath3)) {
3241
- const raw = readFileSync6(configPath3, "utf-8");
3038
+ if (existsSync8(configPath2)) {
3039
+ const raw = readFileSync5(configPath2, "utf-8");
3242
3040
  mcp = /\[mcp_servers\.recall\]/.test(raw);
3243
3041
  const featureFlagSet = /^\s*(?:codex_)?hooks\s*=\s*true\b/m.test(raw);
3244
- const managedHooksJson = existsSync9(hooksPath) && readFileSync6(hooksPath, "utf-8").includes("recall:managed:codex");
3042
+ const managedHooksJson = existsSync8(hooksPath) && readFileSync5(hooksPath, "utf-8").includes("recall:managed:codex");
3245
3043
  hooks = featureFlagSet && managedHooksJson;
3044
+ if (managedHooksJson) {
3045
+ try {
3046
+ const missing = missingCodexTrustKeys(raw, hooksPath, JSON.parse(readFileSync5(hooksPath, "utf-8")));
3047
+ if (missing.length) notes.push(`${missing.length} Recall hooks lack trust for this profile path. Review them with Codex /hooks; setup does not grant trust.`);
3048
+ } catch {
3049
+ notes.push("hooks.json could not be parsed for trust inspection");
3050
+ }
3051
+ }
3246
3052
  legacy_notify_bridge = raw.includes("# recall:managed:codex:start") && raw.includes("codex-notify");
3247
3053
  if (!mcp) notes.push("MCP block [mcp_servers.recall] not in config.toml");
3248
3054
  if (legacy_notify_bridge) {
@@ -3255,7 +3061,7 @@ function inspectCodexHome(codexHome) {
3255
3061
  } else if (detected) {
3256
3062
  notes.push("Codex CLI detected but config.toml missing");
3257
3063
  }
3258
- return { codexHome, configPath: configPath3, hooksPath, detected, mcp, hooks, legacy_notify_bridge, notes };
3064
+ return { codexHome, configPath: configPath2, hooksPath, detected, mcp, hooks, legacy_notify_bridge, notes };
3259
3065
  }
3260
3066
  function inspectCodexInstall(home) {
3261
3067
  const homes = resolveCodexHomes({ home });
@@ -3318,8 +3124,19 @@ function formatDoctorReport(report) {
3318
3124
  const mcp = agent.mcp ? "ok" : "MISSING";
3319
3125
  const legacy = agent.legacy_notify_bridge ? " (legacy notify bridge)" : "";
3320
3126
  const claudeMd = agent.claude_md ? ` claude.md:${agent.claude_md === "current" ? "ok" : agent.claude_md.toUpperCase()}` : "";
3321
- const wiring = agent.hookless ? ` rules:${agent.rules === "current" ? "ok" : (agent.rules ?? "missing").toUpperCase()}` : ` hooks:${agent.hooks ? "ok" : "MISSING"}`;
3127
+ const wiring = agent.hookless ? ` rules:${agent.rules === "current" ? "ok" : (agent.rules ?? "missing").toUpperCase()}` : ` hooks:${agent.hooks ? "configured" : "MISSING"}`;
3322
3128
  lines.push(`${label} mcp:${mcp}${wiring}${claudeMd}${legacy}`);
3129
+ if (agent.hook_activity) {
3130
+ const activity = agent.hook_activity;
3131
+ lines.push(` invocation:${activity.status} last-success:${activity.last_success_at ?? "none"} (model delivery unverified)`);
3132
+ for (const event of ["session_started", "prompt_submitted", "tool_invoked", "session_ended"]) {
3133
+ lines.push(` ${event}: ${activity.events[event] ?? "never"}`);
3134
+ }
3135
+ }
3136
+ for (const trust of agent.hook_trust ?? []) {
3137
+ lines.push(` ${basename2(trust.home)} trust:${trust.status}${trust.error ? ` (${trust.error})` : ""}`);
3138
+ if (trust.status === "review-required") lines.push(" Review the current Recall commands in Codex /hooks for this profile.");
3139
+ }
3323
3140
  for (const note of agent.notes) {
3324
3141
  lines.push(` - ${note}`);
3325
3142
  }
@@ -3335,6 +3152,9 @@ function formatDoctorReport(report) {
3335
3152
  }
3336
3153
  lines.push(`Total runs: ${report.cleanup.total_runs}`);
3337
3154
  lines.push(`Pending correction candidates: ${report.cleanup.pending_candidate_corrections}`);
3155
+ const total = report.cleanup.total_injections ?? report.cleanup.resolved_injections;
3156
+ const resolved = report.cleanup.resolved_injections;
3157
+ lines.push(`Outcome coverage (last 14d): ${resolved}/${total} resolved; ${total - resolved} unknown. Selection is not proof of model delivery.`);
3338
3158
  if (report.cleanup.followed_rate_resolved != null) {
3339
3159
  const pct = (report.cleanup.followed_rate_resolved * 100).toFixed(1);
3340
3160
  lines.push(`Followed rate (last 14d, of ${report.cleanup.resolved_injections} resolved): ${pct}%`);
@@ -3345,7 +3165,7 @@ function formatDoctorReport(report) {
3345
3165
  if (report.dispatcher) {
3346
3166
  lines.push("", "## Dispatcher (LLM refinement)");
3347
3167
  const provs = report.dispatcher.providers_configured;
3348
- lines.push(`Providers: ${provs.length === 0 ? "none configured (LLM tier dormant)" : provs.join(", ")}`);
3168
+ lines.push(`Providers visible to this CLI: ${provs.length === 0 ? "none; daemon may have separate credentials" : provs.join(", ")}`);
3349
3169
  const pendingEntries = Object.entries(report.dispatcher.pending_tasks);
3350
3170
  if (pendingEntries.length === 0) {
3351
3171
  lines.push("Pending tasks: 0");
@@ -3359,7 +3179,7 @@ function formatDoctorReport(report) {
3359
3179
  lines.push("Last dispatch: never");
3360
3180
  }
3361
3181
  if (provs.length === 0 && pendingEntries.length > 0) {
3362
- lines.push("Tasks are queued but no provider is configured. Run `recall maintenance dispatch --preview` to inspect prompts, or `recall maintenance credentials set <provider> <key>` to enable.");
3182
+ lines.push("Tasks are queued. Check the running daemon's dispatch status before changing credentials; this CLI may have a different environment.");
3363
3183
  }
3364
3184
  }
3365
3185
  if (report.app_registrations?.supported && report.app_registrations.stray_paths.length > 0) {
@@ -3383,19 +3203,21 @@ function formatDoctorReport(report) {
3383
3203
  }
3384
3204
 
3385
3205
  // src/data/purge.ts
3386
- import { execFileSync as execFileSync7 } from "child_process";
3206
+ init_define_RECALL_BUILD_INFO();
3207
+ import { execFileSync as execFileSync5 } from "child_process";
3387
3208
  import {
3388
- existsSync as existsSync10,
3389
- readFileSync as readFileSync7,
3390
- readdirSync as readdirSync2,
3391
- rmSync as rmSync4,
3209
+ existsSync as existsSync9,
3210
+ readFileSync as readFileSync6,
3211
+ readdirSync,
3212
+ rmSync as rmSync5,
3392
3213
  rmdirSync
3393
3214
  } from "fs";
3394
- import { homedir as homedir4 } from "os";
3395
- import { dirname as dirname8, join as join11, parse, resolve as resolve7 } from "path";
3215
+ import { homedir as homedir3 } from "os";
3216
+ import { dirname as dirname7, join as join11, parse, resolve as resolve6 } from "path";
3396
3217
  init_keychain();
3397
3218
 
3398
3219
  // src/daemon/service.ts
3220
+ init_define_RECALL_BUILD_INFO();
3399
3221
  var isLinux = process.platform === "linux";
3400
3222
  var isDarwin = process.platform === "darwin";
3401
3223
  function unsupported() {
@@ -3440,12 +3262,12 @@ var PROVIDERS = [
3440
3262
  "azure-openai"
3441
3263
  ];
3442
3264
  function resolveRecallDataDir(options = {}) {
3443
- const home = resolve7(options.homeDir ?? homedir4());
3444
- return resolve7(options.dataDir ?? process.env.RECALL_DATA_DIR ?? join11(home, ".recall"));
3265
+ const home = resolve6(options.homeDir ?? homedir3());
3266
+ return resolve6(options.dataDir ?? process.env.RECALL_DATA_DIR ?? join11(home, ".recall"));
3445
3267
  }
3446
3268
  function purgeLocalData(options = {}) {
3447
3269
  const dryRun = options.dryRun ?? false;
3448
- const home = resolve7(options.homeDir ?? homedir4());
3270
+ const home = resolve6(options.homeDir ?? homedir3());
3449
3271
  const dataDir = resolveRecallDataDir({ dataDir: options.dataDir, homeDir: home });
3450
3272
  assertSafeDataDir(dataDir, home);
3451
3273
  const repoRoots = options.repoRoots ?? configuredRepoRoots(home);
@@ -3498,8 +3320,8 @@ function purgeLocalData(options = {}) {
3498
3320
  continue;
3499
3321
  }
3500
3322
  try {
3501
- rmSync4(contextPath, { force: true });
3502
- removeDirectoryIfEmpty(dirname8(contextPath));
3323
+ rmSync5(contextPath, { force: true });
3324
+ removeDirectoryIfEmpty(dirname7(contextPath));
3503
3325
  actions.push({
3504
3326
  category: "artifact",
3505
3327
  target: contextPath,
@@ -3513,14 +3335,14 @@ function purgeLocalData(options = {}) {
3513
3335
  actions.push({
3514
3336
  category: "data",
3515
3337
  target: dataDir,
3516
- status: existsSync10(dataDir) ? "planned" : "absent",
3338
+ status: existsSync9(dataDir) ? "planned" : "absent",
3517
3339
  detail: "database, WAL, backups, logs, caches, models, and sync state"
3518
3340
  });
3519
3341
  } else {
3520
3342
  try {
3521
3343
  closeDb();
3522
- const existed = existsSync10(dataDir);
3523
- rmSync4(dataDir, { recursive: true, force: true });
3344
+ const existed = existsSync9(dataDir);
3345
+ rmSync5(dataDir, { recursive: true, force: true });
3524
3346
  actions.push({
3525
3347
  category: "data",
3526
3348
  target: dataDir,
@@ -3547,7 +3369,7 @@ function assertSafeDataDir(dataDir, home) {
3547
3369
  }
3548
3370
  function configuredRepoRoots(home) {
3549
3371
  const configured = process.env.RECALL_REPO_ROOTS?.split(",").map((value) => value.trim()).filter(Boolean);
3550
- return configured?.length ? configured.map((value) => resolve7(value)) : [join11(home, "Projects")];
3372
+ return configured?.length ? configured.map((value) => resolve6(value)) : [join11(home, "Projects")];
3551
3373
  }
3552
3374
  function findGeneratedContextArtifacts(repoRoots) {
3553
3375
  const paths = /* @__PURE__ */ new Set();
@@ -3560,9 +3382,9 @@ function findGeneratedContextArtifacts(repoRoots) {
3560
3382
  return [...paths].sort();
3561
3383
  }
3562
3384
  function isGeneratedContext(path) {
3563
- if (!existsSync10(path)) return false;
3385
+ if (!existsSync9(path)) return false;
3564
3386
  try {
3565
- return readFileSync7(path, "utf8").startsWith(GENERATED_CONTEXT_MARKER);
3387
+ return readFileSync6(path, "utf8").startsWith(GENERATED_CONTEXT_MARKER);
3566
3388
  } catch {
3567
3389
  return false;
3568
3390
  }
@@ -3630,7 +3452,7 @@ function removeIntegrations(repoRoots) {
3630
3452
  function removeCliMcp(command, args, cwd) {
3631
3453
  const target = `${command} Recall MCP${cwd ? ` in ${cwd}` : ""}`;
3632
3454
  try {
3633
- execFileSync7(command, ["mcp", "get", "recall"], {
3455
+ execFileSync5(command, ["mcp", "get", "recall"], {
3634
3456
  cwd,
3635
3457
  stdio: "ignore",
3636
3458
  timeout: 1e4
@@ -3644,7 +3466,7 @@ function removeCliMcp(command, args, cwd) {
3644
3466
  };
3645
3467
  }
3646
3468
  try {
3647
- execFileSync7(command, args, {
3469
+ execFileSync5(command, args, {
3648
3470
  cwd,
3649
3471
  stdio: "ignore",
3650
3472
  timeout: 1e4
@@ -3702,7 +3524,7 @@ function failed(category, target, error) {
3702
3524
  }
3703
3525
  function removeDirectoryIfEmpty(path) {
3704
3526
  try {
3705
- if (readdirSync2(path).length === 0) rmdirSync(path);
3527
+ if (readdirSync(path).length === 0) rmdirSync(path);
3706
3528
  } catch {
3707
3529
  }
3708
3530
  }
@@ -3719,7 +3541,7 @@ program.command("init").description("Initialize Recall database").action(() => {
3719
3541
  initDb();
3720
3542
  console.log("Recall initialized. Database ready.");
3721
3543
  });
3722
- program.command("doctor").description("Show local Recall runtime, DB, embedding, and agent-install health").option("--json", "Emit raw JSON report").option("--fix", "Install missing hooks/MCP for detected agents").action((opts) => {
3544
+ program.command("doctor").description("Show local Recall runtime, DB, embedding, and agent-install health").option("--json", "Emit raw JSON report").option("--fix", "Install missing hooks/MCP for detected agents").action(async (opts) => {
3723
3545
  const report = getDoctorReport();
3724
3546
  if (opts.fix) {
3725
3547
  const detectedAgents = report.agents.filter((a) => {
@@ -3759,6 +3581,11 @@ program.command("doctor").description("Show local Recall runtime, DB, embedding,
3759
3581
  }
3760
3582
  }
3761
3583
  const finalReport = opts.fix ? getDoctorReport() : report;
3584
+ const codexEntry = finalReport.agents.find((agent) => agent.agent === "codex" && agent.detected);
3585
+ if (codexEntry) {
3586
+ const { inspectCodexTrust } = await import("./codex-trust-H7VKP4G3.js");
3587
+ codexEntry.hook_trust = await inspectCodexTrust();
3588
+ }
3762
3589
  if (opts.json) {
3763
3590
  console.log(JSON.stringify(finalReport, null, 2));
3764
3591
  return;
@@ -3803,7 +3630,7 @@ dbCmd.command("backups").description("List available database snapshots").action
3803
3630
  for (const b of backups) {
3804
3631
  const mb = (b.size_bytes / 1024 / 1024).toFixed(2);
3805
3632
  total += b.size_bytes;
3806
- const tag = b.kind === "one_off" ? " [one-off]" : "";
3633
+ const tag = b.kind === "one_off" ? " [one-off]" : b.kind === "install" ? " [install]" : "";
3807
3634
  console.log(`${b.date} ${mb} MB ${b.path}${tag}`);
3808
3635
  }
3809
3636
  console.log(`
@@ -3927,20 +3754,20 @@ function safeHookAction(event, action) {
3927
3754
  } catch (error) {
3928
3755
  let logPath = "~/.recall/logs/hook-errors.log";
3929
3756
  try {
3930
- const { appendFileSync, mkdirSync: mkdirSync7, statSync: statSync2, renameSync: renameSync4, rmSync: rmSync5 } = await import("fs");
3931
- const { homedir: homedir5 } = await import("os");
3932
- const dir = join12(homedir5(), ".recall", "logs");
3933
- mkdirSync7(dir, { recursive: true });
3757
+ const { appendFileSync, mkdirSync: mkdirSync6, statSync, renameSync: renameSync3, rmSync: rmSync6 } = await import("fs");
3758
+ const { homedir: homedir4 } = await import("os");
3759
+ const dir = join12(homedir4(), ".recall", "logs");
3760
+ mkdirSync6(dir, { recursive: true });
3934
3761
  logPath = join12(dir, "hook-errors.log");
3935
3762
  try {
3936
3763
  const maxBytes = parseInt(process.env.RECALL_HOOK_LOG_MAX_BYTES ?? String(1024 * 1024), 10);
3937
- if (maxBytes > 0 && statSync2(logPath).size >= maxBytes) {
3764
+ if (maxBytes > 0 && statSync(logPath).size >= maxBytes) {
3938
3765
  const rotated = `${logPath}.1`;
3939
3766
  try {
3940
- rmSync5(rotated, { force: true });
3767
+ rmSync6(rotated, { force: true });
3941
3768
  } catch {
3942
3769
  }
3943
- renameSync4(logPath, rotated);
3770
+ renameSync3(logPath, rotated);
3944
3771
  }
3945
3772
  } catch {
3946
3773
  }
@@ -4088,7 +3915,7 @@ program.command("ump").description("Serve the Universal Memory Protocol (UMP) ov
4088
3915
  });
4089
3916
  program.command("scan").description("Scan a repository and bootstrap memories").argument("[path]", "Repository path", ".").option("-s, --session <id>", "Session ID").action((path, opts) => {
4090
3917
  const db = initDb();
4091
- const repoPath = resolve8(path);
3918
+ const repoPath = resolve7(path);
4092
3919
  const ids = scanAndStore(db, repoPath);
4093
3920
  const artifact = writeRepoContextArtifact(db, {
4094
3921
  repo: inferRepoSlugFromPath(repoPath),
@@ -4217,7 +4044,7 @@ program.command("compile").description("Compile active memories into injection p
4217
4044
  query_text: opts.query,
4218
4045
  config: {
4219
4046
  ...opts.threshold ? { confidence_threshold: parseFloat(opts.threshold) } : {},
4220
- include_candidates: opts.includeCandidates ?? false
4047
+ ...opts.includeCandidates ? { include_candidates: true } : {}
4221
4048
  }
4222
4049
  }) : compileContext(db, {
4223
4050
  repo: opts.repo,
@@ -4335,7 +4162,7 @@ program.command("export").description("Export memories as markdown instruction f
4335
4162
  console.error(`Could not resolve local repo path for ${opts.repo}`);
4336
4163
  process.exit(1);
4337
4164
  }
4338
- content = readFileSync8(artifact.output_path, "utf-8");
4165
+ content = readFileSync7(artifact.output_path, "utf-8");
4339
4166
  if (!opts.output) {
4340
4167
  console.log(content);
4341
4168
  return;
@@ -4346,7 +4173,7 @@ program.command("export").description("Export memories as markdown instruction f
4346
4173
  content = exportMarkdown(db, opts.repo);
4347
4174
  }
4348
4175
  if (opts.output) {
4349
- writeFileSync7(opts.output, content);
4176
+ writeFileSync6(opts.output, content);
4350
4177
  console.log(`Exported to ${opts.output}`);
4351
4178
  } else {
4352
4179
  console.log(content);
@@ -4354,7 +4181,7 @@ program.command("export").description("Export memories as markdown instruction f
4354
4181
  });
4355
4182
  program.command("publish").description("Write repo-local .recall/context.md for the current repo").argument("[path]", "Repository path", ".").action((path) => {
4356
4183
  const db = initDb();
4357
- const repoPath = resolve8(path);
4184
+ const repoPath = resolve7(path);
4358
4185
  const artifact = writeRepoContextArtifact(db, {
4359
4186
  repo: inferRepoSlugFromPath(repoPath),
4360
4187
  repo_path: repoPath
@@ -4483,7 +4310,7 @@ evalCmd.command("value-retrieval").description("Run retrieval eval cases synthes
4483
4310
  });
4484
4311
  let snapshot = null;
4485
4312
  if (opts.snapshot) {
4486
- const { computeQualityReport, recordQualitySnapshot } = await import("./quality-VKQUCL66.js");
4313
+ const { computeQualityReport, recordQualitySnapshot } = await import("./quality-TQ7CVPRO.js");
4487
4314
  const qualityReport = computeQualityReport(db, { sinceIso: report.since });
4488
4315
  snapshot = recordQualitySnapshot(
4489
4316
  db,
@@ -4768,10 +4595,11 @@ contradictCmd.command("auto-resolve").description("Auto-resolve contradictions (
4768
4595
  const count = autoResolveContradictions(db, opts.repo);
4769
4596
  console.log(`Auto-resolved ${count} contradiction(s).`);
4770
4597
  });
4771
- program.command("prune").description("Auto-prune stale and unhealthy memories").option("-r, --repo <repo>", "Limit pruning to one repo").option("--stale-days <n>", "Days before rejecting stale memories", "90").option("--rejected-days <n>", "Days before deleting rejected memories", "30").option("--transient-days <n>", "Days before deleting transient memories", "7").option("--min-health <n>", "Min health score for active memories", "0.2").option("--dry-run", "Preview without making changes").action((opts) => {
4598
+ program.command("prune").description("Auto-prune stale and unhealthy memories").option("-r, --repo <repo>", "Limit pruning to one repo").option("--candidate-days <n>", "Days before archiving an unconfirmed, never-selected candidate", "30").option("--stale-days <n>", "Days before rejecting stale memories", "90").option("--rejected-days <n>", "Days before deleting rejected memories", "30").option("--transient-days <n>", "Days before deleting transient memories", "7").option("--min-health <n>", "Min health score for active memories", "0.2").option("--dry-run", "Preview without making changes").action((opts) => {
4772
4599
  const db = initDb();
4773
4600
  const result = pruneMemories(db, {
4774
4601
  repo: opts.repo,
4602
+ candidate_unconfirmed_days: parseInt(opts.candidateDays),
4775
4603
  stale_days: parseInt(opts.staleDays),
4776
4604
  rejected_retention_days: parseInt(opts.rejectedDays),
4777
4605
  transient_retention_days: parseInt(opts.transientDays),
@@ -4825,6 +4653,28 @@ program.command("quality").description("Show repo quality profile and dynamic th
4825
4653
  console.log(`Compile threshold: ${profile.compile_confidence_threshold.toFixed(2)}`);
4826
4654
  console.log(`Dedup similarity: ${profile.dedup_similarity_threshold.toFixed(2)}`);
4827
4655
  });
4656
+ program.command("reliability").description("Report measured delivery, outcome, retrieval, and backlog coverage").option("-r, --repo <repo>", "Repository name").option("--since <iso>", "Window start as an ISO timestamp").option("--json", "Print machine-readable JSON").option("--canary", "Run a disposable capture-to-outcome canary").option("--probe", "Check the live database, newest backup, and disposable canary").option("--real-embeddings", "Use the configured local embedding model in the canary").action(async (opts) => {
4657
+ if (opts.canary) {
4658
+ const result = await runReliabilityCanary({ real_embeddings: opts.realEmbeddings });
4659
+ console.log(JSON.stringify(result, null, 2));
4660
+ if (!result.ok) process.exitCode = 1;
4661
+ return;
4662
+ }
4663
+ const db = initDb();
4664
+ if (opts.probe) {
4665
+ const result = await runReliabilityProbe(db, {
4666
+ real_embeddings: opts.realEmbeddings
4667
+ });
4668
+ console.log(JSON.stringify(result, null, 2));
4669
+ if (!result.ok) process.exitCode = 1;
4670
+ return;
4671
+ }
4672
+ const report = computeReliabilityReport(db, {
4673
+ repo: opts.repo,
4674
+ since: opts.since
4675
+ });
4676
+ console.log(opts.json ? JSON.stringify(report, null, 2) : formatReliabilityReport(report));
4677
+ });
4828
4678
  program.command("activity").description("List recent activity events").option("-r, --repo <repo>", "Filter by repo").option("-s, --session <id>", "Filter by session ID").option("--source <source>", "Filter by source: cli|daemon|mcp|system").option("--type <type>", "Filter by event type: compile|query|scan|correction|review|feedback|signal|session_start|session_event|session_end").option("--since <iso>", "Filter by created_at >= ISO timestamp").option("-n, --limit <n>", "Max events", "20").action((opts) => {
4829
4679
  const db = initDb();
4830
4680
  const events = listActivityEvents(db, {
@@ -4969,15 +4819,15 @@ uiCmd.command("status").description("Show WebUI status").option("--daemon-port <
4969
4819
  var graphCmd = program.command("graph").description("Inspect and rebuild the knowledge graph (entities + relations)");
4970
4820
  graphCmd.command("stats").description("Show entity/relation counts").action(async () => {
4971
4821
  const db = initDb();
4972
- const { countEntities, countRelations } = await import("./store-5C7ZKKZF.js");
4822
+ const { countEntities, countRelations } = await import("./store-QKP6HQ45.js");
4973
4823
  console.log(`entities: ${countEntities(db)}`);
4974
4824
  console.log(`relations: ${countRelations(db)}`);
4975
4825
  });
4976
4826
  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) => {
4977
4827
  const db = initDb();
4978
- const { ingestMemoryHeuristic } = await import("./ingest-HEXVIAL6.js");
4828
+ const { ingestMemoryHeuristic } = await import("./ingest-6GDZNYCY.js");
4979
4829
  if (opts.rebuild) {
4980
- const { clearGraph } = await import("./store-5C7ZKKZF.js");
4830
+ const { clearGraph } = await import("./store-QKP6HQ45.js");
4981
4831
  clearGraph(db);
4982
4832
  console.log("Cleared existing graph entities and relations.");
4983
4833
  }
@@ -4999,7 +4849,7 @@ graphCmd.command("backfill").description("Run the heuristic extractor over every
4999
4849
  });
5000
4850
  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) => {
5001
4851
  const db = initDb();
5002
- const { listEntities } = await import("./store-5C7ZKKZF.js");
4852
+ const { listEntities } = await import("./store-QKP6HQ45.js");
5003
4853
  const rows = listEntities(db, {
5004
4854
  repo: opts.repo,
5005
4855
  kind: opts.kind,
@@ -5018,8 +4868,8 @@ graphCmd.command("entities").description("List entities").option("--repo <repo>"
5018
4868
  });
5019
4869
  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) => {
5020
4870
  const db = initDb();
5021
- const { graphQuery } = await import("./retrieval-4MEIABHC.js");
5022
- const { loadEmbeddingConfigFromEnv: loadEmbeddingConfigFromEnv2 } = await import("./embeddings-MILTROKW.js");
4871
+ const { graphQuery } = await import("./retrieval-7R5LKJAM.js");
4872
+ const { loadEmbeddingConfigFromEnv: loadEmbeddingConfigFromEnv2 } = await import("./embeddings-GYQBZWBD.js");
5023
4873
  const embeddingConfig = loadEmbeddingConfigFromEnv2();
5024
4874
  const result = await graphQuery(db, queryTokens.join(" "), embeddingConfig, {
5025
4875
  repo: opts.repo,
@@ -5035,7 +4885,7 @@ graphCmd.command("query <query...>").description("Run graph-aware retrieval for
5035
4885
  });
5036
4886
  var maintenanceCmd = program.command("maintenance").description("Inspect and manage the delegated maintenance task queue");
5037
4887
  maintenanceCmd.command("stats").description("Show backlog counts, completion stats, and mean latency").action(async () => {
5038
- const { getTaskStats } = await import("./tasks-7SE6VHSQ.js");
4888
+ const { getTaskStats } = await import("./tasks-M5HSQSWK.js");
5039
4889
  const db = initDb();
5040
4890
  const stats = getTaskStats(db);
5041
4891
  console.log(`Total tasks: ${stats.total}`);
@@ -5061,7 +4911,7 @@ maintenanceCmd.command("stats").description("Show backlog counts, completion sta
5061
4911
  }
5062
4912
  });
5063
4913
  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) => {
5064
- const { listTasks } = await import("./tasks-7SE6VHSQ.js");
4914
+ const { listTasks } = await import("./tasks-M5HSQSWK.js");
5065
4915
  const db = initDb();
5066
4916
  const tasks = listTasks(db, {
5067
4917
  status: opts.status,
@@ -5083,7 +4933,7 @@ maintenanceCmd.command("list").description("List tasks (default: pending)").opti
5083
4933
  }
5084
4934
  });
5085
4935
  maintenanceCmd.command("drop").description("Delete a task by id (or id prefix)").argument("<task-id>", "Task id or prefix").action(async (taskIdArg) => {
5086
- const { deleteTask, listTasks } = await import("./tasks-7SE6VHSQ.js");
4936
+ const { deleteTask, listTasks } = await import("./tasks-M5HSQSWK.js");
5087
4937
  const db = initDb();
5088
4938
  const all = listTasks(db, { limit: 1e4 });
5089
4939
  const matches = all.filter((t) => t.id === taskIdArg || t.id.startsWith(taskIdArg));
@@ -5102,7 +4952,7 @@ maintenanceCmd.command("drop").description("Delete a task by id (or id prefix)")
5102
4952
  });
5103
4953
  var credentialsCmd = maintenanceCmd.command("credentials").description("Manage LLM provider API keys in macOS Keychain (env fallback on other platforms)");
5104
4954
  credentialsCmd.command("list", { isDefault: true }).description("Show which providers have credentials available").action(async () => {
5105
- const { listCredentials } = await import("./keychain-5KXUHKMF.js");
4955
+ const { listCredentials } = await import("./keychain-TKPVUZCH.js");
5106
4956
  const creds = listCredentials();
5107
4957
  if (creds.length === 0) {
5108
4958
  console.log("No API keys configured. Set one with:");
@@ -5116,7 +4966,7 @@ credentialsCmd.command("list", { isDefault: true }).description("Show which prov
5116
4966
  }
5117
4967
  });
5118
4968
  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) => {
5119
- const { setApiKey, setAzureConfig } = await import("./keychain-5KXUHKMF.js");
4969
+ const { setApiKey, setAzureConfig } = await import("./keychain-TKPVUZCH.js");
5120
4970
  const provider = providerArg === "azure" ? "azure-openai" : providerArg;
5121
4971
  if (provider === "openai" || provider === "anthropic") {
5122
4972
  const key = keyArg ?? await readStdinKey();
@@ -5178,7 +5028,7 @@ credentialsCmd.command("set").description("Store credentials for an LLM provider
5178
5028
  process.exit(1);
5179
5029
  });
5180
5030
  credentialsCmd.command("clear").description("Remove provider credentials from the macOS Keychain").argument("<provider>", "openai|anthropic|azure").action(async (providerArg) => {
5181
- const { deleteApiKey: deleteApiKey2 } = await import("./keychain-5KXUHKMF.js");
5031
+ const { deleteApiKey: deleteApiKey2 } = await import("./keychain-TKPVUZCH.js");
5182
5032
  const provider = providerArg === "azure" ? "azure-openai" : providerArg;
5183
5033
  if (provider !== "openai" && provider !== "anthropic" && provider !== "azure-openai") {
5184
5034
  console.error(`Provider must be "openai", "anthropic", or "azure", got "${providerArg}".`);
@@ -5189,8 +5039,8 @@ credentialsCmd.command("clear").description("Remove provider credentials from th
5189
5039
  else console.log(`No ${provider} credentials found in Keychain.`);
5190
5040
  });
5191
5041
  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) => {
5192
- const { dispatchPendingTasks, formatDispatchReport, buildPrompt } = await import("./dispatcher-PP5OKOLS.js");
5193
- const { listTasks } = await import("./tasks-7SE6VHSQ.js");
5042
+ const { dispatchPendingTasks, formatDispatchReport, buildPrompt } = await import("./dispatcher-GHC6RX54.js");
5043
+ const { listTasks } = await import("./tasks-M5HSQSWK.js");
5194
5044
  const db = initDb();
5195
5045
  if (opts.preview) {
5196
5046
  const pending = listTasks(db, {
@@ -5246,8 +5096,13 @@ ${p.prompt.max_output_tokens}
5246
5096
  }
5247
5097
  console.log(formatDispatchReport(report));
5248
5098
  });
5099
+ maintenanceCmd.command("quarantine-generated").description("Preview memories supported only by generated messages; preserve them outside injection").option("--apply", "Quarantine matching memories with reversible audit snapshots").action(async (opts) => {
5100
+ const { quarantineGeneratedMemories } = await import("./provenance-M5YFD6DO.js");
5101
+ const ids = quarantineGeneratedMemories(initDb(), Boolean(opts.apply));
5102
+ console.log(JSON.stringify({ applied: Boolean(opts.apply), count: ids.length, memory_ids: ids }, null, 2));
5103
+ });
5249
5104
  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) => {
5250
- const { runDeterministicCleanup, formatCleanupReport, revertCleanupRun, listCleanupRuns } = await import("./cleanup-RTL2UETA.js");
5105
+ const { runDeterministicCleanup, formatCleanupReport, revertCleanupRun, listCleanupRuns } = await import("./cleanup-KXCEVJ7V.js");
5251
5106
  const db = initDb();
5252
5107
  if (opts.list) {
5253
5108
  const runs = listCleanupRuns(db);
@@ -5301,7 +5156,7 @@ maintenanceCmd.command("quality").description("Show injection outcome distributi
5301
5156
  recordQualitySnapshot,
5302
5157
  listQualitySnapshots,
5303
5158
  diffQualitySnapshots
5304
- } = await import("./quality-VKQUCL66.js");
5159
+ } = await import("./quality-TQ7CVPRO.js");
5305
5160
  const db = initDb();
5306
5161
  if (opts.history) {
5307
5162
  const snaps = listQualitySnapshots(db);
@@ -5362,7 +5217,7 @@ maintenanceCmd.command("value-backfill").description("Backfill memory value even
5362
5217
  const {
5363
5218
  backfillMemoryValueEvents,
5364
5219
  formatMemoryValueBackfillReport
5365
- } = await import("./memory-value-WXI2Q6TO.js");
5220
+ } = await import("./memory-value-A4UCC3DY.js");
5366
5221
  const db = initDb();
5367
5222
  const report = backfillMemoryValueEvents(db, {
5368
5223
  sinceIso: opts.since,
@@ -5375,7 +5230,7 @@ maintenanceCmd.command("value-backfill").description("Backfill memory value even
5375
5230
  console.log(formatMemoryValueBackfillReport(report));
5376
5231
  });
5377
5232
  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) => {
5378
- const { summarizeUsage, formatUsageReport } = await import("./usage-VQ5LJCNH.js");
5233
+ const { summarizeUsage, formatUsageReport } = await import("./usage-TQTOHPL7.js");
5379
5234
  const db = initDb();
5380
5235
  const summary = summarizeUsage(db, {
5381
5236
  sinceIso: opts.since,
@@ -5504,7 +5359,7 @@ function findByPrefix(db, prefix) {
5504
5359
  function isDirectCliInvocation(moduleUrl, argvPath) {
5505
5360
  if (!argvPath) return false;
5506
5361
  try {
5507
- return realpathSync3(fileURLToPath5(moduleUrl)) === realpathSync3(argvPath);
5362
+ return realpathSync2(fileURLToPath4(moduleUrl)) === realpathSync2(argvPath);
5508
5363
  } catch {
5509
5364
  return false;
5510
5365
  }