@fingerskier/augment 0.1.3 → 0.1.5

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.
@@ -0,0 +1,112 @@
1
+ # Verifying the auto-memory flow
2
+
3
+ Augment now *enforces* the memory loop through host lifecycle hooks rather than
4
+ relying on the agent to remember to call the MCP tools:
5
+
6
+ | Event | Hook command | Effect |
7
+ | ------------------ | ---------------------------------- | ------ |
8
+ | `SessionStart` | `augment hook session-start` | Warms the daemon and registers the project. |
9
+ | `UserPromptSubmit` | `augment hook user-prompt-submit` | Recalls relevant memory and injects it as `additionalContext` **before** the model sees the prompt. |
10
+ | `PreToolUse` | `augment hook pre-tool-use` | Recalls **additional** memory keyed to the matched tool action (the edited file / the Bash command) and injects it as `additionalContext`. Matcher-scoped to `Edit\|Write\|Bash` to bound the hot path; injection-only (never blocks, gates, or rewrites a tool call). |
11
+ | `Stop` | `augment hook stop` | Blocks the turn **once** with a directive to upsert a memory, then allows the stop (loop-guarded per turn). |
12
+
13
+ `PreToolUse` fires before **every matched** tool call, so it is the only hook with a tool-name
14
+ `matcher` (the others fire once per prompt/turn). Two host nuances: on Claude the injected text
15
+ rides alongside the *tool result* on the next model request (it supplements, rather than precedes,
16
+ the action); on Codex builds older than ~0.124.0 `PreToolUse` `additionalContext` is rejected and
17
+ silently dropped (the tool still runs). It is purely additive — `UserPromptSubmit` remains the
18
+ guaranteed memory path on both hosts.
19
+
20
+ The same `hooks/hooks.json` ships in both the Claude Code and Codex plugins
21
+ (Codex copied Claude's event names + stdin/stdout contract), so one set of
22
+ handlers serves both hosts.
23
+
24
+ This doc is the test process. Run the layers top-to-bottom; each is cheaper and
25
+ more isolated than the one below it.
26
+
27
+ ## 1. Automated (no network, no host) — `npm test`
28
+
29
+ ```sh
30
+ npm test
31
+ ```
32
+
33
+ Covers:
34
+ - `test/hooks.test.ts` — the stdin→stdout contract of every hook event
35
+ (UserPromptSubmit envelope, PreToolUse tool-query derivation + injection-only
36
+ envelope, Stop block-once loop guard, fail-open paths).
37
+ - `test/recall.test.ts` — recall degrades to `""` on any failure (a hook must
38
+ never break the agent).
39
+ - `test/cli.test.ts` — the `recall` and `hook` CLI commands.
40
+ - `test/install.test.ts` — the installer writes `hooks/hooks.json` for both hosts.
41
+ - `test/integration/memory-flow.test.ts` — a planted memory flows
42
+ upsert → index → `recall()` → UserPromptSubmit **and** PreToolUse envelopes, against a **real**
43
+ `AugmentService` (real store + sqlite index), using the deterministic hash
44
+ embedder. Proves the wiring end-to-end without a model download.
45
+
46
+ ## 2. CLI smoke (real daemon + real embeddings, one machine)
47
+
48
+ Build first, then drive the real daemon by hand. Use a throwaway memory root so
49
+ you don't pollute your real memories:
50
+
51
+ ```sh
52
+ npm run build
53
+ export AUGMENT_MEMORY_ROOT="$(mktemp -d)" # PowerShell: $env:AUGMENT_MEMORY_ROOT = (New-Item -ItemType Directory -Path $env:TEMP\augver -Force).FullName
54
+
55
+ # Plant a memory (project_id 1 after the first init), then recall it.
56
+ node ./dist/bin/augment.js recall "the deploy pipeline" # prints recalled text (empty until something is stored)
57
+
58
+ # Exercise the hook handlers exactly as a host would (JSON on stdin):
59
+ echo '{"user_input":"fix the deploy pipeline","cwd":"."}' | node ./dist/bin/augment.js hook user-prompt-submit
60
+ # -> {"hookSpecificOutput":{"hookEventName":"UserPromptSubmit","additionalContext":"## Augment memory ..."}} (or nothing if no match)
61
+
62
+ # PreToolUse keys the query off the tool action (Bash -> command, Edit/Write -> file_path):
63
+ echo '{"tool_name":"Bash","tool_input":{"command":"deploy the pipeline"},"cwd":"."}' | node ./dist/bin/augment.js hook pre-tool-use
64
+ # -> {"hookSpecificOutput":{"hookEventName":"PreToolUse","additionalContext":"## Augment memory ..."}} (or nothing if no match)
65
+ echo '{"tool_name":"Read","tool_input":{"file_path":"x"}}' | node ./dist/bin/augment.js hook pre-tool-use
66
+ # -> (empty) Read isn't in the installed matcher; even if invoked it derives a query but stays injection-only
67
+
68
+ echo '{"session_id":"s","prompt_id":"p"}' | node ./dist/bin/augment.js hook stop
69
+ # -> {"decision":"block","reason":"Before ending this turn, record durable memory ..."}
70
+ echo '{"session_id":"s","prompt_id":"p"}' | node ./dist/bin/augment.js hook stop
71
+ # -> (empty) second stop for the same turn is allowed — proves the loop guard
72
+ ```
73
+
74
+ The first `recall`/`hook user-prompt-submit` call auto-starts the daemon and, on
75
+ a cold machine, downloads the bge-small model — so the very first run is slow.
76
+ This is real-model retrieval; ranking quality (not just wiring) is what you're
77
+ eyeballing here.
78
+
79
+ ## 3. Real project (host-level hook firing)
80
+
81
+ 1. Install into a repo (or user scope):
82
+ ```sh
83
+ npm exec --yes --package @fingerskier/augment -- augment install all --scope repo --memory-root "<your shared memory root>"
84
+ ```
85
+ 2. Confirm the plugin is actually installed/enabled — hooks only fire when the
86
+ plugin is active:
87
+ - **Claude Code:** `/plugin` → `augment` listed and enabled. The installer
88
+ best-effort-registers it via the `claude` CLI; if that was skipped, run the
89
+ printed `/plugin marketplace add … && /plugin install …` commands.
90
+ - **Codex:** plugin-shipped hooks need a **one-time trust** — run `/hooks` and
91
+ approve the augment hooks. (Managed/enterprise distribution can pre-trust;
92
+ a plain plugin install cannot.)
93
+ 3. Observe the loop on a real task:
94
+ - **Inject:** start a session and give a task that matches something in your
95
+ memory. The recalled block ("## Augment memory (recalled for this task)")
96
+ should appear in the model's context — confirm it influenced the answer.
97
+ - **Capture:** finish the task. The Stop hook should prompt the agent to
98
+ `upsert` a WORK/ARCH/ISSUE/TODO/SPEC memory; confirm a new file appears under
99
+ your memory root and that `augment recall` surfaces it next time.
100
+
101
+ ## Known caveats (logged, not blockers)
102
+
103
+ - **Per-prompt latency.** Each hook shells out via `npm exec --yes` (self-bootstrapping,
104
+ matches the MCP server). On UserPromptSubmit that adds startup overhead before
105
+ every prompt. A direct-node invocation is a planned optimization.
106
+ - **Claude hook activation depends on plugin install.** The MCP server is also
107
+ direct-registered (so the tools always exist), but the hooks live in the plugin;
108
+ if the plugin isn't installed, the loop degrades to the CLAUDE.md prose guidance.
109
+ - **Retrieval floor calibration.** Real bge-small cosine is mis-normalized
110
+ (`(cos+1)/2`), so abstention is weaker than intended on the real model — see
111
+ `.council/memory/retrieval-quality-roadmap.md`. The flow still injects; it just
112
+ may inject loosely-related memory. Tracked separately.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fingerskier/augment",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Local RAG memory system for coding agents",
5
5
  "type": "module",
6
6
  "publishConfig": {