@edihasaj/recall 1.0.10 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +15 -1
  2. package/dist/{chunk-TGWUGUVH.js → chunk-5FY3HYGU.js} +92 -25
  3. package/dist/chunk-5FY3HYGU.js.map +1 -0
  4. package/dist/{chunk-WD55NWCC.js → chunk-B6KSSZUW.js} +8 -1
  5. package/dist/chunk-B6KSSZUW.js.map +1 -0
  6. package/dist/{chunk-TYXRTMDK.js → chunk-JP5YAQPQ.js} +2 -2
  7. package/dist/{chunk-SGL4ZDGZ.js → chunk-NFCBG4OH.js} +6 -6
  8. package/dist/{chunk-QAFWA4U6.js → chunk-PX4FAXGQ.js} +8 -6
  9. package/dist/chunk-PX4FAXGQ.js.map +1 -0
  10. package/dist/{chunk-LYTIYKXH.js → chunk-T5FOKQH2.js} +2 -2
  11. package/dist/{chunk-PGTHECO2.js → chunk-TUC6GU35.js} +2 -2
  12. package/dist/{chunk-YC64D4QN.js → chunk-UUCSHXES.js} +26 -18
  13. package/dist/{chunk-YC64D4QN.js.map → chunk-UUCSHXES.js.map} +1 -1
  14. package/dist/{cleanup-OJBSLUMO.js → cleanup-PT3VB3CG.js} +5 -3
  15. package/dist/cli.js +178 -53
  16. package/dist/cli.js.map +1 -1
  17. package/dist/daemon.js +9 -9
  18. package/dist/daemon.js.map +1 -1
  19. package/dist/{dispatcher-IIFTDIOW.js → dispatcher-2Q6LY57F.js} +3 -3
  20. package/dist/{ingest-NX53XWCU.js → ingest-ERAUAPMC.js} +2 -2
  21. package/dist/mcp.js +6 -6
  22. package/dist/{memory-value-LISBUR2V.js → memory-value-2NDAQNMS.js} +3 -3
  23. package/dist/{quality-TM5E6JCK.js → quality-WFWVU4FQ.js} +4 -4
  24. package/dist/{retrieval-63A775WR.js → retrieval-JOC63UXZ.js} +3 -3
  25. package/dist/{tasks-UEROYP6D.js → tasks-ANFQXOYX.js} +5 -3
  26. package/package.json +1 -1
  27. package/dist/chunk-QAFWA4U6.js.map +0 -1
  28. package/dist/chunk-TGWUGUVH.js.map +0 -1
  29. package/dist/chunk-WD55NWCC.js.map +0 -1
  30. /package/dist/{chunk-TYXRTMDK.js.map → chunk-JP5YAQPQ.js.map} +0 -0
  31. /package/dist/{chunk-SGL4ZDGZ.js.map → chunk-NFCBG4OH.js.map} +0 -0
  32. /package/dist/{chunk-LYTIYKXH.js.map → chunk-T5FOKQH2.js.map} +0 -0
  33. /package/dist/{chunk-PGTHECO2.js.map → chunk-TUC6GU35.js.map} +0 -0
  34. /package/dist/{cleanup-OJBSLUMO.js.map → cleanup-PT3VB3CG.js.map} +0 -0
  35. /package/dist/{dispatcher-IIFTDIOW.js.map → dispatcher-2Q6LY57F.js.map} +0 -0
  36. /package/dist/{ingest-NX53XWCU.js.map → ingest-ERAUAPMC.js.map} +0 -0
  37. /package/dist/{memory-value-LISBUR2V.js.map → memory-value-2NDAQNMS.js.map} +0 -0
  38. /package/dist/{quality-TM5E6JCK.js.map → quality-WFWVU4FQ.js.map} +0 -0
  39. /package/dist/{retrieval-63A775WR.js.map → retrieval-JOC63UXZ.js.map} +0 -0
  40. /package/dist/{tasks-UEROYP6D.js.map → tasks-ANFQXOYX.js.map} +0 -0
package/README.md CHANGED
@@ -157,7 +157,7 @@ Supported runtimes, and how deep the integration goes:
157
157
  | Runtime | Integration | Capture |
158
158
  | --- | --- | --- |
159
159
  | Claude Code | MCP + lifecycle hooks + managed `~/.claude/CLAUDE.md` block | automatic |
160
- | Codex | MCP + `hooks.json` (legacy `notify` bridge below 0.115.0) | automatic |
160
+ | Codex | MCP + `hooks.json` (legacy `notify` bridge below 0.115.0), wired into every `CODEX_HOME` profile | automatic |
161
161
  | GitHub Copilot | MCP (`~/.copilot/mcp-config.json`) + `.github/copilot-instructions.md` | model-driven |
162
162
  | opencode | MCP (`~/.config/opencode/opencode.json`) + `~/.config/opencode/AGENTS.md` | model-driven |
163
163
  | Cursor | MCP (`~/.cursor/mcp.json`) + `.cursor/rules/recall.mdc` | model-driven |
@@ -165,6 +165,20 @@ Supported runtimes, and how deep the integration goes:
165
165
 
166
166
  Runtimes without a lifecycle-hook API can't be called on prompt/tool/session events, so Recall installs a managed rules block instructing the agent to call `capture_correction` and `query` itself. Capture there depends on the model following it — the hook-based runtimes do not.
167
167
 
168
+ #### Codex profiles (multiple `CODEX_HOME`s)
169
+
170
+ Codex supports multiple homes, and tools that drive it (Paseo, per-account
171
+ setups) commonly point providers at `~/.codex-primary`, `~/.codex-secondary`,
172
+ and so on. `recall setup` wires **every** profile it finds, not just `~/.codex`:
173
+
174
+ - The default home (`CODEX_HOME` if set, else `~/.codex`), plus any `~/.codex-*`
175
+ sibling that looks like a real Codex home (`config.toml`, `auth.json`, or
176
+ `sessions/`). Backup-suffixed directories are skipped.
177
+ - Set `RECALL_CODEX_HOMES` to a `:`/`,` separated list to override discovery.
178
+ - Profiles that share a symlinked `config.toml` are written once, and the
179
+ symlink is followed rather than replaced — so a shared-config layout stays
180
+ shared instead of forking into diverging copies.
181
+
168
182
  Install + setup behavior:
169
183
 
170
184
  - Routine app launch, daemon start, and daemon restart are non-mutating for agent integrations. They do not re-add hooks or repo instruction files after you remove them.
@@ -19,8 +19,9 @@ import {
19
19
  normalizeDedupeText,
20
20
  promoteMemory,
21
21
  queryMemories,
22
+ restoreAutoInject,
22
23
  updateMemoryCaptureContext
23
- } from "./chunk-WD55NWCC.js";
24
+ } from "./chunk-B6KSSZUW.js";
24
25
  import {
25
26
  CONFIDENCE,
26
27
  LlmCredentialError,
@@ -1232,6 +1233,7 @@ var INJECTION_ARTIFACT_RE = new RegExp(
1232
1233
  "i"
1233
1234
  );
1234
1235
  var EPHEMERAL_TASK_CONTEXT_RE = /(?:^\s*\/goal\b|pause for (?:the )?user\b|this is task def(?:inition)?:|key details\s+description\s+(?:goal|background)\b|link to jira ticket|what(?:'|’)s changed\?|this article lists the tools we use for development|required software on node)/i;
1236
+ var LLM_WORKER_PROMPT_RE = /(?:^\s*you are (?:the|an?)\s+[^\n]{0,80}?\b(?:worker|judge|extractor|summari[sz]er|compactor|classifier|grader|scorer|labeler)\b|\bfor a personal agent runtime\b|\breturn json only\b[^\n]{0,60}\bno (?:markdown|prose)\b)/i;
1235
1237
  var CODEX_INTERNAL_PROMPT_RE = /(?:^\s*generate a title and a git branch name for a coding agent\b|^\s*#\s*overview\s+generate\s+0\s+to\s+3\s+hyperpersonalized suggestions for what this user can do with codex\b|^\s*you are an expert at upholding safety and compliance standards for codex ambient suggestions\b|^\s*you are the implementation worker for one isolated git worktree\b|^\s*you are reviewing github pull request\b[^\n]*\bon behalf of the maintainer\b|^\s*#\s*github issue workorder\s*:|^\s*continue the previous coding task using user-provided context only\b)/i;
1236
1238
  function looksLikeQuestionContext(text) {
1237
1239
  if (/\b(?:always|never|remember|memorize|save this|from now on|by default|make it a rule)\b/i.test(text)) {
@@ -1247,7 +1249,7 @@ function looksLikeQuestionContext(text) {
1247
1249
  return /\?\s*$/.test(text.trim()) || /(?:^|[.!?]\s+)(?:how|why|what|where|which|who|can|could|should|would|do|does|did|is|are|was|were|have|has)\b/i.test(text);
1248
1250
  }
1249
1251
  function isNonUserCaptureContext(text) {
1250
- return SYSTEM_SCAFFOLD_RE.test(text) || NON_USER_CONTEXT_RE.test(text) || INJECTION_ARTIFACT_RE.test(text) || EPHEMERAL_TASK_CONTEXT_RE.test(text) || CODEX_INTERNAL_PROMPT_RE.test(text) || looksLikeQuestionContext(text);
1252
+ return SYSTEM_SCAFFOLD_RE.test(text) || NON_USER_CONTEXT_RE.test(text) || INJECTION_ARTIFACT_RE.test(text) || EPHEMERAL_TASK_CONTEXT_RE.test(text) || LLM_WORKER_PROMPT_RE.test(text) || CODEX_INTERNAL_PROMPT_RE.test(text) || looksLikeQuestionContext(text);
1251
1253
  }
1252
1254
 
1253
1255
  // src/scanner/signal.ts
@@ -2594,6 +2596,7 @@ async function processCorrection(db, text, ctx) {
2594
2596
  if (duplicate) {
2595
2597
  const before = getMemory(db, duplicate.id);
2596
2598
  appendEvidence(db, duplicate.id, evidence);
2599
+ restoreAutoInject(db, duplicate.id);
2597
2600
  if (captureContext) {
2598
2601
  updateMemoryCaptureContext(db, duplicate.id, captureContext);
2599
2602
  }
@@ -2770,10 +2773,18 @@ function textSimilarity(a, b) {
2770
2773
  }
2771
2774
  var REJECTED_EXEMPLAR_THRESHOLD = 0.7;
2772
2775
  var REJECTED_EXEMPLAR_SEMANTIC_THRESHOLD = 0.85;
2776
+ function isMachineRejection(db, memoryId) {
2777
+ const latest = db.select({ actor: auditTrail.actor }).from(auditTrail).where(and(eq(auditTrail.memory_id, memoryId), eq(auditTrail.action, "rejected"))).orderBy(desc(auditTrail.timestamp)).limit(1).get();
2778
+ if (!latest) return false;
2779
+ return MACHINE_REJECTION_ACTORS.some((actor) => latest.actor.startsWith(actor));
2780
+ }
2781
+ var MACHINE_REJECTION_ACTORS = ["auto-pruner", "cleanup_script", "maintenance:cleanup"];
2773
2782
  function isSimilarToRejectedFragment(db, text, threshold = REJECTED_EXEMPLAR_THRESHOLD) {
2774
2783
  const rejected = queryMemories(db, { status: "rejected" }).filter((m) => m.source === "user_correction" || m.source === "user_reported_review");
2775
2784
  for (const exemplar of rejected) {
2776
- if (textSimilarity(text, exemplar.text) >= threshold) return true;
2785
+ if (textSimilarity(text, exemplar.text) < threshold) continue;
2786
+ if (isMachineRejection(db, exemplar.id)) continue;
2787
+ return true;
2777
2788
  }
2778
2789
  return false;
2779
2790
  }
@@ -2787,8 +2798,7 @@ async function isSimilarToRejectedFragmentSemantic(db, text, options = {}) {
2787
2798
  return match != null;
2788
2799
  }
2789
2800
  async function findDuplicateMemory(db, repo, type, text, threshold) {
2790
- if (!repo) return void 0;
2791
- const existing = queryMemories(db, { repo }).filter((m) => m.status !== "rejected" && m.type === type);
2801
+ const existing = queryMemories(db, repo ? { repo } : {}).filter((m) => repo ? true : m.repo == null).filter((m) => m.status !== "rejected" && m.type === type);
2792
2802
  let best;
2793
2803
  let bestScore = 0;
2794
2804
  for (const memory of existing) {
@@ -2806,9 +2816,15 @@ async function findDuplicateMemory(db, repo, type, text, threshold) {
2806
2816
  text,
2807
2817
  config,
2808
2818
  threshold,
2809
- { repo, type, limit: 1 }
2819
+ { repo, type, limit: repo ? 1 : 5 }
2810
2820
  );
2811
- return semantic[0] ? getMemory(db, semantic[0].id) : void 0;
2821
+ for (const hit of semantic) {
2822
+ const memory = getMemory(db, hit.id);
2823
+ if (!memory) continue;
2824
+ if (!repo && memory.repo != null) continue;
2825
+ return memory;
2826
+ }
2827
+ return void 0;
2812
2828
  }
2813
2829
 
2814
2830
  // src/maintenance/appliers.ts
@@ -3053,15 +3069,57 @@ function applyExtractRulesFromPrompt(db, task, result) {
3053
3069
  return { audit_entry_id: null, target_id: task.id, changed_fields: [] };
3054
3070
  }
3055
3071
  const captureContext = {
3056
- prev_assistant_text: void 0,
3057
- recent_tool_calls: [],
3072
+ prev_assistant_text: payload.prev_assistant_turn ?? void 0,
3073
+ recent_tool_calls: (payload.recent_tool_calls ?? []).slice(-5).map((toolCall) => ({
3074
+ name: toolCall.name,
3075
+ path: toolCall.path,
3076
+ exit_code: toolCall.exit_code
3077
+ })),
3058
3078
  repo,
3059
3079
  path: payload.path ?? null,
3060
3080
  agent: payload.agent ?? void 0
3061
3081
  };
3062
3082
  const createdIds = [];
3083
+ const reinforcedIds = [];
3084
+ const sessionId = payload.session_id ?? "unknown";
3063
3085
  for (const rule of result.rules) {
3064
- if (existsSimilar(db, repo, rule)) continue;
3086
+ const evidence = {
3087
+ type: "session_correction",
3088
+ session: sessionId,
3089
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3090
+ context: payload.raw_prompt ?? ""
3091
+ };
3092
+ const duplicate = findSimilar(db, repo, rule);
3093
+ if (duplicate) {
3094
+ const before = getMemory(db, duplicate.id);
3095
+ appendEvidence(db, duplicate.id, evidence);
3096
+ restoreAutoInject(db, duplicate.id);
3097
+ if (isRicherCaptureContext(captureContext, before?.capture_context ?? null)) {
3098
+ updateMemoryCaptureContext(db, duplicate.id, captureContext);
3099
+ }
3100
+ const alreadySeenThisSession = before?.evidence.some(
3101
+ (entry) => entry.type === "session_correction" && entry.session === sessionId
3102
+ );
3103
+ if (before && !alreadySeenThisSession) {
3104
+ incrementMemoryRepetition(db, duplicate.id);
3105
+ }
3106
+ const updated = getMemory(db, duplicate.id);
3107
+ if (updated && updated.status !== "active" && !rule.is_destructive_risky && !isHighRiskRule(updated.text) && countDistinctCorrectionSessions(updated) >= profile.repeat_sessions_required) {
3108
+ promoteMemory(db, duplicate.id, "repeat_correction");
3109
+ const after2 = getMemory(db, duplicate.id);
3110
+ recordAuditWithSnapshot(
3111
+ db,
3112
+ duplicate.id,
3113
+ "promoted",
3114
+ `maintenance:${task.claimed_by ?? "llm"}`,
3115
+ `repetition:${after2?.repetition_count ?? updated.repetition_count}`,
3116
+ before ?? null,
3117
+ after2 ?? null
3118
+ );
3119
+ }
3120
+ reinforcedIds.push(duplicate.id);
3121
+ continue;
3122
+ }
3065
3123
  const memoryType = rule.type ?? "rule";
3066
3124
  const id = createMemory(db, {
3067
3125
  type: memoryType,
@@ -3071,14 +3129,7 @@ function applyExtractRulesFromPrompt(db, task, result) {
3071
3129
  repo,
3072
3130
  source: "user_correction",
3073
3131
  confidence: seedCandidateConfidence(rule.confidence, profile),
3074
- evidence: [
3075
- {
3076
- type: "session_correction",
3077
- session: payload.session_id ?? "unknown",
3078
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3079
- context: payload.raw_prompt ?? ""
3080
- }
3081
- ],
3132
+ evidence: [evidence],
3082
3133
  capture_context: captureContext
3083
3134
  });
3084
3135
  createdIds.push(id);
@@ -3095,21 +3146,30 @@ function applyExtractRulesFromPrompt(db, task, result) {
3095
3146
  if (rule.is_destructive_risky || isHighRiskRule(rule.text)) {
3096
3147
  }
3097
3148
  }
3149
+ const changed = [];
3150
+ if (createdIds.length > 0) changed.push("created_memories");
3151
+ if (reinforcedIds.length > 0) changed.push("reinforced_memories");
3098
3152
  return {
3099
3153
  audit_entry_id: null,
3100
- target_id: createdIds[0] ?? task.id,
3101
- changed_fields: createdIds.length > 0 ? ["created_memories"] : []
3154
+ target_id: createdIds[0] ?? reinforcedIds[0] ?? task.id,
3155
+ changed_fields: changed
3102
3156
  };
3103
3157
  }
3104
- function existsSimilar(db, repo, rule) {
3105
- if (!repo) return false;
3158
+ function captureContextDetail(context) {
3159
+ if (!context) return -1;
3160
+ return (context.prev_assistant_text ? 1 : 0) + (context.recent_tool_calls?.length ?? 0) + (context.path ? 1 : 0) + (context.agent ? 1 : 0);
3161
+ }
3162
+ function isRicherCaptureContext(next, current) {
3163
+ return captureContextDetail(next) >= captureContextDetail(current);
3164
+ }
3165
+ function findSimilar(db, repo, rule) {
3106
3166
  const ruleIsHighRisk = rule.is_destructive_risky || isHighRiskRule(rule.text);
3107
3167
  const candidates = queryMemories(db, {
3108
3168
  repo: repo ?? void 0,
3109
3169
  ...ruleIsHighRisk ? {} : { type: rule.type }
3110
- }).filter((memory) => memory.status !== "rejected");
3170
+ }).filter((memory) => repo ? true : memory.repo == null).filter((memory) => memory.status !== "rejected");
3111
3171
  const normalized = rule.text.toLowerCase().trim();
3112
- return candidates.some((memory) => {
3172
+ return candidates.find((memory) => {
3113
3173
  if (memory.text.toLowerCase().trim() === normalized) return true;
3114
3174
  if (ruleIsHighRisk && isHighRiskRule(memory.text)) {
3115
3175
  return containmentOverlap(memory.text, rule.text) >= 0.65;
@@ -3354,6 +3414,9 @@ function invalidTaskScopeReasons(repo) {
3354
3414
  if (isTempPath2(repo)) reasons.push("repo_field_is_temp_path");
3355
3415
  return reasons;
3356
3416
  }
3417
+ function isInvalidTaskRepo(repo) {
3418
+ return invalidTaskScopeReasons(repo).length > 0;
3419
+ }
3357
3420
  function payloadString(payload, key) {
3358
3421
  const value = payload[key];
3359
3422
  return typeof value === "string" && value.trim() ? value : null;
@@ -3504,6 +3567,7 @@ function produceSummarizeHistoryTasks(db, config) {
3504
3567
  let enqueued = 0;
3505
3568
  for (const snippet of snippets) {
3506
3569
  if (!snippetHasMeaningfulContent(snippet.text)) continue;
3570
+ if (isInvalidTaskRepo(snippet.repo ?? null)) continue;
3507
3571
  const id = insertTaskIdempotent(db, {
3508
3572
  kind: "summarize_history",
3509
3573
  target: snippet.id,
@@ -3592,6 +3656,7 @@ function produceSummarizeSessionTasks(db, config) {
3592
3656
  )).get();
3593
3657
  if (existing) continue;
3594
3658
  const repo = end.repo ?? events.find((e) => e.repo)?.repo ?? null;
3659
+ if (isInvalidTaskRepo(repo)) continue;
3595
3660
  const eventTypes = [...new Set(events.map((e) => e.event_type))];
3596
3661
  const id = insertTaskIdempotent(db, {
3597
3662
  kind: "summarize_session",
@@ -3920,6 +3985,7 @@ export {
3920
3985
  sweepExpiredLeases,
3921
3986
  expireStalePendingTasks,
3922
3987
  abandonOverAttemptTasks,
3988
+ isInvalidTaskRepo,
3923
3989
  abandonInvalidOpenTasks,
3924
3990
  applyBacklogCaps,
3925
3991
  enqueueExtractRulesFromPrompt,
@@ -3952,6 +4018,7 @@ export {
3952
4018
  planRejectFragments,
3953
4019
  qualityReasons,
3954
4020
  planRejectTestFixtureRepos,
4021
+ isWorkspaceRootAlias,
3955
4022
  planRejectInvalidScopes,
3956
4023
  planRejectGenericScannedTooling,
3957
4024
  planPromoteRepeats,
@@ -3968,4 +4035,4 @@ export {
3968
4035
  processCorrection,
3969
4036
  processReviewFeedback
3970
4037
  };
3971
- //# sourceMappingURL=chunk-TGWUGUVH.js.map
4038
+ //# sourceMappingURL=chunk-5FY3HYGU.js.map