11# Agent Memory Interception: Codex CLI & Cursor × TraceDecay Fact Store
22
3- ** Status:** research + design proposal (2026-07-02).
3+ ** Status:** research + design proposal (2026-07-02; plugin paths refreshed
4+ 2026-07-03).
45** Goal:** make Codex CLI and Cursor use the TraceDecay holographic fact store
56(` tracedecay_fact_store ` add/search/probe/reason, ` memory_facts ` table, HRR
67vectors + trust scores) as their agent memory for both ** recall** (facts reach
78the model at the right moment) and ** storage** (new durable facts get written),
89instead of — or layered on top of — each agent's native memory mechanism.
910
10- All file paths below were verified on this machine (Codex CLI 0.142.4, Cursor
11- with hooks + plugins, tracedecay plugin v0.0.23 installed for both agents).
12-
13- > ** Note (as of 2026-07-03):** the per-host ` cursor-plugin/ ` / ` codex-plugin/ `
14- > source trees have since collapsed into a single shared ` plugin/ ` tree, so
15- > skill/command/agent sources now live under ` plugin/skills/… ` ,
16- > ` plugin/commands/… ` , and ` plugin/agents/… ` (Cursor-only surfaces under
17- > ` plugin/overlays/cursor/… ` ). The ` recalling-project-memory ` and
18- > ` curating-project-memory ` skills were also merged into a single
19- > ` project-memory ` skill. References below to the old paths/slugs are retained
20- > as historical design context; the current locations are the shared-tree
21- > equivalents.
11+ Current plugin source lives under the shared ` plugin/ ` tree: shared skills in
12+ ` plugin/skills/ ` , Claude commands in ` plugin/commands/ ` , shared agents in
13+ ` plugin/agents/ ` , and Cursor-only surfaces in ` plugin/overlays/cursor/ ` .
2214
2315---
2416
@@ -169,8 +161,9 @@ tool calls (reliable but discretionary). **Storage** interception rides on
169161
170162### 3.1 ` tracedecay install --agent cursor ` (` src/agents/cursor.rs ` )
171163
172- Writes an embedded plugin (` EMBEDDED_PLUGIN_FILES ` , ` src/agents/cursor.rs:175 ` )
173- to ` ~/.cursor/plugins/local/tracedecay/ ` :
164+ Writes the Cursor projection of the shared plugin bundle
165+ (` src/agents/plugin_bundle.rs::cursor_files ` ) to
166+ ` ~/.cursor/plugins/local/tracedecay/ ` :
174167
175168- ** ` mcp.json ` ** — stdio server ` tracedecay serve --path ${workspaceFolder} `
176169 (all fact-store/memory/graph tools available to the model).
@@ -182,11 +175,12 @@ to `~/.cursor/plugins/local/tracedecay/`:
182175- ** ` rules/tracedecay.mdc ` ** — always-applied rule; its ** Recall** bullet
183176 steers models to ` tracedecay_message_search ` / ` tracedecay_fact_store `
184177 search and the ` project-memory ` skill.
185- - ** ` skills/ ` ** — 25+ workflow skills incl. ` project-memory ` (the merged
186- recall+curate memory skill) and ` recalling-session-context ` ; plus an
187- agent-managed skill overlay (` install_cursor_managed_skill_overlay ` ).
188- - ** ` agents/ ` ** — ` code-explorer ` , ` code-health-auditor ` , ` session-historian `
189- subagent definitions.
178+ - ** ` skills/ ` ** — shared model-invocable skills, excluding the
179+ ` tracedecay-* ` dispatcher skills that Cursor exposes as native commands.
180+ - ** ` commands/ ` ** — Cursor-native workflow commands from
181+ ` plugin/overlays/cursor/commands/ ` .
182+ - ** ` agents/ ` ** — Cursor agent definitions from
183+ ` plugin/overlays/cursor/agents/ ` .
190184
191185What the hooks currently do (all fail-open):
192186
@@ -205,8 +199,8 @@ What the hooks currently do (all fail-open):
205199
206200### 3.2 ` tracedecay install --agent codex ` (` src/agents/codex.rs ` )
207201
208- Installs a ** plugin bundle** ( ` CODEX_EMBEDDED_PLUGIN_FILES ` ,
209- ` src/agents/codex .rs:209 ` ) to
202+ Installs the Codex projection of the shared plugin bundle
203+ ( ` src/agents/plugin_bundle .rs::codex_files ` ) to
210204` ~/.codex/plugins/cache/personal/tracedecay/<version>/ ` plus a personal
211205marketplace entry (` install_codex_marketplace_entry ` ) and
212206` [plugins."tracedecay@personal"] enabled = true ` in ` config.toml ` :
@@ -218,7 +212,8 @@ marketplace entry (`install_codex_marketplace_entry`) and
218212 ` PostToolUse ` (matcher ` Bash|apply_patch ` ), ` PostCompact `
219213 (matcher ` auto|manual ` ). Hooks require one-time ` /hooks ` trust
220214 (` print_hook_trust_guidance ` ); trusted hashes live in ` [hooks.state] ` .
221- - ** ` skills/ ` ** — same 25 workflow skills + ` agent-managed/ ` overlay.
215+ - ** ` skills/ ` ** — shared skills from ` plugin/skills/ ` plus the
216+ ` agent-managed/ ` overlay.
222217- ** No rule surface exists in Codex** , so the steering text Cursor gets via
223218 ` tracedecay.mdc ` is injected through ` SessionStart ` /` UserPromptSubmit `
224219 ` additionalContext ` instead (` build_codex_session_context ` ,
@@ -300,13 +295,9 @@ model electing to call an MCP tool; storage depends on the user saying
300295
301296---
302297
303- ## 5. Ranked integration designs
304-
305- Ranked by effect ÷ effort. A + B are the core; C–F layer on.
298+ ## 5. Integration designs
306299
307- ### A. Codex per-prompt & session-start fact injection via existing hooks — ** do first**
308-
309- * Effort: S–M. Effect: high. Risk: low (fail-open, additive).*
300+ ### A. Codex per-prompt & session-start fact injection via existing hooks
310301
311302Codex is the lowest-effort path because ` UserPromptSubmit ` carries the prompt
312303text and honors ` hookSpecificOutput.additionalContext ` , and the hook binary is
@@ -335,9 +326,7 @@ Implementation pointers: `src/hooks/codex.rs`, `src/hooks/cursor.rs`,
335326change; hook hashes change → users re-trust via ` /hooks ` (already documented
336327in the Codex plugin README).
337328
338- ### B. Cursor session-start injection + a materialized memory rule — ** do with A**
339-
340- * Effort: M. Effect: high (rule) / medium (hook, due to Cursor bugs). Risk: low.*
329+ ### B. Cursor session-start injection + a materialized memory rule
341330
342331Per-prompt injection is impossible in Cursor (§2.3), so combine the two
343332channels that exist:
@@ -358,16 +347,13 @@ channels that exist:
358347 and/or a scheduler task. Keep it small (facts are one-liners; cap ~ 1–2 KB)
359348 and deterministic (sorted) so diffs are reviewable.
360349
361- Implementation pointers: rule generation next to
362- ` cursor_plugin_manifest ` /` write_embedded_plugin ` (` src/agents/cursor.rs:404 ` ),
363- refresh in ` hook_cursor_workspace_open ` (` src/hooks/cursor.rs ` ); mark the file
364- managed the same way the skill overlay marks generated skills
365- (` managed_skill_format.rs ` ) so uninstall (` remove_cursor_plugin_install ` ) and
366- doctor checks cover it.
350+ Implementation pointers: add the managed rule to the Cursor projection in
351+ ` src/agents/plugin_bundle.rs ` / ` src/agents/cursor.rs ` , refresh it from
352+ ` hook_cursor_workspace_open ` (` src/hooks/cursor.rs ` ), and mark it managed the
353+ same way generated skills are marked (` managed_skill_format.rs ` ) so uninstall
354+ and doctor checks cover it.
367355
368- ### C. Rule/skill text: make storage proactive — ** small, ship with A/B**
369-
370- * Effort: XS. Effect: medium. Risk: memory spam (mitigated by write-time dedupe).*
356+ ### C. Rule/skill text: make storage proactive
371357
372358Today ` project-memory ` 's guardrail says add facts "** only when the
373359user asks** " — the opposite of agent-memory behavior. Change the instruction
@@ -384,9 +370,7 @@ user asks**" — the opposite of agent-memory behavior. Change the instruction
384370This mirrors Cursor's hybrid design (sidecar + tool calls), with the tool-call
385371half pointed at TraceDecay.
386372
387- ### D. Enable the reflection loop (sidecar-equivalent storage) — ** medium**
388-
389- * Effort: S (config/UX) — the code exists. Effect: high over time.*
373+ ### D. Enable the reflection loop (sidecar-equivalent storage)
390374
391375session_reflector is the background sidecar analog: transcripts (both agents,
392376already ingested by the hooks) → evidence-cited fact proposals → dashboard
@@ -404,9 +388,7 @@ Pointers: `src/automation/config.rs` (defaults/validation),
404388dashboard curation UI (concurrent work in ` dashboard/ ` — coordinate, don't
405389touch).
406390
407- ### E. Codex-native-memory coexistence policy — ** decide, small change**
408-
409- * Effort: XS–S. Effect: avoids divergence/duplication.*
391+ ### E. Codex-native-memory coexistence policy
410392
411393With ` features.memories = true ` , Codex builds a parallel memory in
412394` ~/.codex/memories/ ` from the same sessions. Options:
@@ -430,9 +412,7 @@ is the Settings toggle. Once B+C are live, recommend users disable "Generate
430412Memories" to keep one memory system (document in ` KIRO-INTEGRATION.md ` -style
431413agent doc; can't be automated).
432414
433- ### F. Materialized ` AGENTS.md ` / memory-file generation — ** fallback, partial overlap with B2**
434-
435- * Effort: M. Effect: medium. Risk: touches user-owned files.*
415+ ### F. Materialized ` AGENTS.md ` / memory-file generation
436416
437417Scheduled materialization of facts into files agents read natively without
438418any tool call: a ` ## Memory (generated by tracedecay) ` fenced section in repo
@@ -466,8 +446,8 @@ alongside D and reusing the managed-file conventions from the skill overlay.
466446 + ` src/memory/retrieval.rs ` helpers; measurable via existing hook
467447 analytics.
4684482 . ** B2 + C** (materialized Cursor memory rule + proactive storage wording) —
469- one PR in ` src/agents/cursor.rs ` embedded files + plugin rule/skill text
470- (shared skill text under ` plugin/skills/ ` ).
449+ one PR in ` src/agents/plugin_bundle.rs ` , ` src/agents/ cursor.rs` , and plugin
450+ rule/skill text (shared skill text under ` plugin/skills/ ` ).
4714513 . ** D** (reflector enablement UX) — config/doctor/dashboard nudge.
4724524 . ** E** (coexistence policy + optional Codex-memories harvest importer).
4734535 . ** F** (generalized AGENTS.md materialization across all 15 agent
0 commit comments