Skip to content

Commit da15580

Browse files
docs: update hook module references
1 parent bac1af7 commit da15580

3 files changed

Lines changed: 25 additions & 22 deletions

File tree

docs/AGENT-MEMORY-INTERCEPTION.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ hashes recorded under `[hooks.state]` in `config.toml`):
9191
**Key asymmetry vs Cursor:** Codex's `UserPromptSubmit` hook receives the
9292
prompt text *and* can inject `additionalContext` — a true per-prompt memory
9393
recall channel. TraceDecay already exploits this channel for tool-routing
94-
hints (`src/hooks.rs::hook_codex_user_prompt_submit`
94+
hints (`src/hooks/codex.rs::hook_codex_user_prompt_submit`
9595
`codex_user_prompt_submit_context_for_event`
9696
`codex_additional_context_json("UserPromptSubmit", …)`), just not for facts.
9797

@@ -138,7 +138,7 @@ cursor.com/docs/hooks): `sessionStart`/`sessionEnd`, `preToolUse`/`postToolUse`/
138138
`afterAgentResponse`/`afterAgentThought`, `workspaceOpen`.
139139

140140
Context-injection capability per event (verified against docs + forum + the
141-
comment in `src/hooks.rs::hook_cursor_before_submit_prompt`):
141+
comment in `src/hooks/cursor.rs::hook_cursor_before_submit_prompt`):
142142

143143
| Event | Injection field | Notes |
144144
| --- | --- | --- |
@@ -168,7 +168,7 @@ to `~/.cursor/plugins/local/tracedecay/`:
168168
`postToolUse`, `afterFileEdit`, `afterShellExecution`, `preCompact`,
169169
`sessionEnd`, `stop`, `workspaceOpen`, each shelling to
170170
`tracedecay hook-cursor-*` (dispatch: `src/hook_cmd.rs`, impls:
171-
`src/hooks.rs`).
171+
`src/hooks/`).
172172
- **`rules/tracedecay.mdc`** — always-applied rule; its **Recall** bullet
173173
steers models to `tracedecay_message_search` / `tracedecay_fact_store`
174174
search and the `recalling-project-memory` skill.
@@ -182,8 +182,8 @@ What the hooks currently do (all fail-open):
182182

183183
- `sessionStart` (`hook_cursor_session_start`) — catch-up transcript ingest,
184184
then emits `additional_context` built by `build_cursor_session_context`
185-
(`src/hooks.rs:1416`): **index status + skill list + tokens-saved counter.
186-
No facts.** Sets `TRACEDECAY_PROJECT_ROOT` env.
185+
(`src/hooks/steering.rs`): **index status + skill list + tokens-saved
186+
counter. No facts.** Sets `TRACEDECAY_PROJECT_ROOT` env.
187187
- `beforeSubmitPrompt` — hot transcript ingest only; emits
188188
`{"continue": true}` (no context possible, see §2.3).
189189
- `postToolUse` — tool-routing hints via `additional_context`
@@ -302,23 +302,24 @@ Codex is the lowest-effort path because `UserPromptSubmit` carries the prompt
302302
text and honors `hookSpecificOutput.additionalContext`, and the hook binary is
303303
`tracedecay` with in-process store access (no MCP hop, fits the 5s timeout).
304304

305-
- `SessionStart`: in `codex_session_context_for_event` (`src/hooks.rs:624`),
305+
- `SessionStart`: in `codex_session_context_for_event` (`src/hooks/codex.rs`),
306306
after workspace status, run `FactRetriever::search`/`list` for the top-K
307307
high-trust project facts (e.g. K=8, `min_trust` 0.6, category-diverse,
308308
newest-first tiebreak) and append a compact `## Project memory` block with
309309
fact ids ("rate with tracedecay_fact_feedback, correct with fact_store
310310
update"). Reuse the token-budget discipline the context builders already
311311
have.
312312
- `UserPromptSubmit`: in `codex_user_prompt_submit_context_for_event`
313-
(`src/hooks.rs:1738`), embed the prompt (`prompt_like_text`) via the
313+
(`src/hooks/codex.rs`), embed the prompt (`prompt_like_text`) via the
314314
existing HRR encoder and inject only facts above a similarity × trust
315315
threshold, deduped per session the same way tool hints are deduped
316316
(`deduped_codex_hint` pattern, `remember_hint_in_process`). Empty result →
317317
inject nothing (most prompts).
318318
- `SubagentStart`: optionally include the same session-start block so
319319
subagents inherit memory.
320320

321-
Implementation pointers: `src/hooks.rs` (context builders above),
321+
Implementation pointers: `src/hooks/codex.rs`, `src/hooks/cursor.rs`,
322+
`src/hooks/steering.rs`, and shared helpers in `src/hooks/mod.rs`,
322323
`src/memory/retrieval.rs` (`FactRetriever::search/probe`), analytics via
323324
`record_hint_analytics` so injection quality is measurable. No plugin schema
324325
change; hook hashes change → users re-trust via `/hooks` (already documented
@@ -333,7 +334,8 @@ channels that exist:
333334

334335
1. **`sessionStart.additional_context`** — extend
335336
`build_cursor_session_context` / `cursor_session_context_for_root`
336-
(`src/hooks.rs:1416,610`) with the same top-K fact block as design A.
337+
(`src/hooks/steering.rs`, `src/hooks/cursor.rs`) with the same top-K fact
338+
block as design A.
337339
Cheap, but treat as best-effort given the open forum bugs about dropped
338340
`additional_context`.
339341
2. **Materialized always-applied memory rule** — generate
@@ -348,7 +350,7 @@ channels that exist:
348350

349351
Implementation pointers: rule generation next to
350352
`cursor_plugin_manifest`/`write_embedded_plugin` (`src/agents/cursor.rs:404`),
351-
refresh in `hook_cursor_workspace_open` (`src/hooks.rs:666`); mark the file
353+
refresh in `hook_cursor_workspace_open` (`src/hooks/cursor.rs`); mark the file
352354
managed the same way the skill overlay marks generated skills
353355
(`managed_skill_format.rs`) so uninstall (`remove_cursor_plugin_install`) and
354356
doctor checks cover it.
@@ -451,7 +453,7 @@ alongside D and reusing the managed-file conventions from the skill overlay.
451453

452454
## 6. Recommended sequence
453455

454-
1. **A + B1** (hook-based injection, both agents) — one PR in `src/hooks.rs`
456+
1. **A + B1** (hook-based injection, both agents) — one PR across `src/hooks/`
455457
+ `src/memory/retrieval.rs` helpers; measurable via existing hook
456458
analytics.
457459
2. **B2 + C** (materialized Cursor memory rule + proactive storage wording) —

docs/HERMES-LOOPS-PARITY-AUDIT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Status: comparison audit, July 2026. Hermes agent codebase examined at
44
`/home/zack/projects/hermes-agent` (registered tracedecay project
55
"hermes-agent"). TraceDecay side examined at HEAD of
6-
`feat/dashboard-ux-improvements`.
6+
the current TraceDecay worktree after dashboard automation work landed.
77

88
This audit compares Hermes's self-improvement machinery (background review,
99
memory writing, skill writing, curator, cron) against TraceDecay's automation

docs/SKILL-ADOPTION-RESEARCH.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*Research date: 2026-07-02. Read-only study of the local superpowers plugin
44
(`~/.cursor/plugins/cache/cursor-public/superpowers/b7a8f76…/`), the installed
55
TraceDecay plugins (`~/.cursor/plugins/local/tracedecay/`, `~/.codex/…`), the
6-
repo sources (`cursor-plugin/`, `codex-plugin/`, `src/hooks.rs`,
6+
repo sources (`cursor-plugin/`, `codex-plugin/`, `src/hooks/`,
77
`src/mcp/tools/definitions.rs`), and TraceDecay's own analytics
88
(`http://127.0.0.1:7341/api/plugins/analytics/*`,
99
`~/.tracedecay/projects/proj_b4a8bbe4953823c4/hook_analytics.jsonl`).*
@@ -46,7 +46,8 @@ correlated usage**.
4646
So every session begins with the full bootstrap skill already in context — the
4747
model never has to *decide* to read it. Contrast: TraceDecay's Cursor
4848
session-start context is (by design, see the doc comment on
49-
`build_cursor_session_context` in `src/hooks.rs`) "intentionally lean":
49+
`build_cursor_session_context` in `src/hooks/steering.rs`) "intentionally
50+
lean":
5051

5152
> `tracedecay index status: initialized.\nWorkflow skills: tracedecay:architecture-overview, …`
5253
> *(a comma-separated list of 25 names, no instructions)*
@@ -143,16 +144,16 @@ deliberate design choice preventing ad-hoc work.
143144
| Layer | Mechanism | Character |
144145
|---|---|---|
145146
| Always-applied rule | `cursor-plugin/rules/tracedecay.mdc` | ~15 bullet points of routing advice; "prefer/first/fallback" phrasing; no decision procedure, no counters to rationalization |
146-
| Session start (Cursor) | `build_cursor_session_context` in `src/hooks.rs` | Index status line + bare list of 25 skill names + tokens-saved counter. Doc comment says steering is deliberately left to the rule |
147-
| Session start (Codex) | `build_codex_session_context` in `src/hooks.rs` | One paragraph: "Prefer tracedecay MCP tools … over broad file reads"; CLI fallback note; index status |
148-
| Mid-session hints | `postToolUse` hook → `cursor_post_tool_use_decision``deduped_project_hint` (`src/hooks.rs`), dedupe in `src/hooks/tool_hints.rs` | Fires after Grep/Read/etc., but deduped to **once per (session, category) forever** (`ToolHintDedupe::should_emit` is a plain `HashSet::insert`) |
147+
| Session start (Cursor) | `build_cursor_session_context` in `src/hooks/steering.rs` | Index status line + bare list of 25 skill names + tokens-saved counter. Doc comment says steering is deliberately left to the rule |
148+
| Session start (Codex) | `build_codex_session_context_for_workspace` in `src/hooks/steering.rs` | One paragraph: "Prefer tracedecay MCP tools … over broad file reads"; CLI fallback note; index status |
149+
| Mid-session hints | `postToolUse` hook → `cursor_post_tool_use_decision` (`src/hooks/cursor.rs`) `deduped_project_hint` (`src/hooks/mod.rs`), dedupe in `src/hooks/tool_hints.rs` | Fires after Grep/Read/etc., but deduped to **once per (session, category) forever** (`ToolHintDedupe::should_emit` is a plain `HashSet::insert`) |
149150
| Skills | `cursor-plugin/skills/` (40 dirs installed: 23 model-invocable + 15 `tracedecay-*` slash-command variants with `disable-model-invocation: true` + a `memorize-subject`/`memorizing-subject` near-duplicate pair); `codex-plugin/skills/` (25) | Descriptions are actually good "Use when…" trigger form; the problem is volume and overlap, not phrasing |
150151
| MCP tool descriptions | `src/mcp/tools/definitions.rs` (68+ tools) | Capability descriptions ("Search for symbols … by name or keyword"), not invocation triggers; only `tracedecay_outline` and `tracedecay_context` carry usage steering (the latter a *budget cap*, i.e. anti-usage steering) |
151152

152153
Two structural notes:
153154

154155
- The Cursor `beforeSubmitPrompt` hook **cannot inject context** (per the
155-
comment at `src/hooks.rs:351`, only `user_message` is available on that
156+
comment at `src/hooks/cursor.rs`, only `user_message` is available on that
156157
event), so per-prompt re-steering à la Codex's `UserPromptSubmit` is not
157158
available on Cursor — which makes sessionStart and postToolUse the only
158159
injection points, and both are currently minimal.
@@ -269,7 +270,7 @@ uses". `tracedecay_skill_list` was called 3 times ever;
269270
and default to the native tools they were RL-trained on. Superpowers shows
270271
that mandate framing + rationalization counters materially change this.
271272
2. **The session-start slot is spent on status, not behavior.** The lean
272-
injection was a deliberate token economy (`src/hooks.rs:1413`), but it
273+
injection was a deliberate token economy (`src/hooks/steering.rs`), but it
273274
delegates all steering to a rule that sits among *dozens* of other
274275
always-applied rules and skill listings, with no priority claim.
275276
3. **The mid-session correction loop is mostly inactive.** Once-per-session-per-category
@@ -295,7 +296,7 @@ uses". `tracedecay_skill_list` was called 3 times ever;
295296
## 6. Recommendations (prioritized)
296297

297298
### P0 — Inject a behavioral contract at session start
298-
*Files: `src/hooks.rs` (`build_cursor_session_context`,
299+
*Files: `src/hooks/steering.rs` (`build_cursor_session_context`,
299300
`build_codex_session_context_for_workspace`, `CURSOR_PLUGIN_SKILLS`);
300301
new skill `cursor-plugin/skills/using-tracedecay/SKILL.md` (mirror in
301302
`codex-plugin/skills/`).*
@@ -326,7 +327,7 @@ Index status: {status}. Tokens saved this session: {n}.
326327
Keep it under ~40 lines; the token cost is what buys reliability.
327328

328329
### P0 — Resurrect the hint loop
329-
*Files: `src/hooks/tool_hints.rs` (`should_emit`), `src/hooks.rs`
330+
*Files: `src/hooks/tool_hints.rs` (`should_emit`), `src/hooks/mod.rs`
330331
(`deduped_project_hint`), `src/mcp/tool_analytics.rs` +
331332
`src/dashboard/analytics_api.rs` for telemetry.*
332333

@@ -350,7 +351,7 @@ CLI-fallback and truncation-handle bullets (those are good).
350351

351352
### P1 — Consolidate the skill catalog to ~10 workflow-stage skills
352353
*Files: `cursor-plugin/skills/`, `codex-plugin/skills/`,
353-
`CURSOR_PLUGIN_SKILLS` in `src/hooks.rs`,
354+
`CURSOR_PLUGIN_SKILLS` in `src/hooks/steering.rs`,
354355
`tests/agent_suite/plugin_skill_contract_test.rs`.*
355356

356357
Merge along workflow stages, mirroring superpowers' shape: **explore**

0 commit comments

Comments
 (0)