pi-automem-bridge 0.2.1 → 0.2.2
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.
- package/README.md +71 -29
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
5
|
# pi-automem-bridge
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
> **AutoMem is the memory. This bridge ensures pi actually uses it.**
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
pi install npm:pi-automem-bridge
|
|
@@ -19,6 +19,30 @@ pi install npm:pi-automem-bridge
|
|
|
19
19
|
|
|
20
20
|
---
|
|
21
21
|
|
|
22
|
+
## Why pi-automem-bridge
|
|
23
|
+
|
|
24
|
+
Plenty of agents can store a memory. Far fewer reach for it when it counts — or check what they're scribbling down. pi-automem-bridge makes pi do both, automatically: startup + per-turn recall injected straight into the prompt, and a secret-scanning, policy-gated write pipeline guarding the door to AutoMem.
|
|
25
|
+
|
|
26
|
+
- **Per-project scoping** — recall limits and filters tuned to the repo or folder you're working in.
|
|
27
|
+
- **Bring your own AutoMem** — talks to your existing instance over MCP. No duplicate credentials or storage to manage.
|
|
28
|
+
|
|
29
|
+
> The storage and the recall/similarity intelligence are [AutoMem](https://github.com/verygoodplugins/automem)'s. This package is the guardrail-and-automation layer that makes them automatic inside pi.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## How it works
|
|
34
|
+
|
|
35
|
+
Once installed, the bridge hooks into pi's session lifecycle:
|
|
36
|
+
|
|
37
|
+
- **At session start** it runs your startup recall queries against AutoMem and injects the results — your preferences, working style, and environment — into the system prompt.
|
|
38
|
+
- **Before each turn** it recalls memories relevant to the current task and the detected project, again injected silently.
|
|
39
|
+
- **When the agent writes a memory** the candidate passes through the write pipeline — normalize → secret-scan → policy check → dedupe → confirm or auto-store — so nothing unvetted reaches AutoMem.
|
|
40
|
+
- **Relationship tools** let the agent link memories or record corrections with provenance, building a connected graph over time.
|
|
41
|
+
|
|
42
|
+
Recall display, write policy, and per-project scoping are all configurable — see the [Configuration reference](#configuration-reference).
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
22
46
|
## Before you begin
|
|
23
47
|
|
|
24
48
|
This package does not include pi or AutoMem — it connects them. You need both running independently first:
|
|
@@ -27,24 +51,25 @@ This package does not include pi or AutoMem — it connects them. You need both
|
|
|
27
51
|
2. **[AutoMem](https://github.com/verygoodplugins/automem)** — the graph-vector memory service (self-hosted or Railway)
|
|
28
52
|
3. **[mcp-automem](https://github.com/verygoodplugins/mcp-automem)** — the MCP bridge that exposes AutoMem's tools over the MCP protocol
|
|
29
53
|
|
|
30
|
-
Once those three are in place,
|
|
54
|
+
Once those three are in place, follow the setup below.
|
|
31
55
|
|
|
32
56
|
---
|
|
33
57
|
|
|
34
|
-
##
|
|
58
|
+
## Setup
|
|
35
59
|
|
|
36
|
-
|
|
37
|
-
- **Turn-level recall** — before each agent prompt, retrieves memories relevant to the current task and detected project
|
|
38
|
-
- **Silent injection** — memory context is injected into the system prompt, not the chat window
|
|
39
|
-
- **Policy-gated writes** — every memory write is validated, secret-scanned, deduplicated, and confirmed before storage
|
|
40
|
-
- **Relationship tools** — link memories to each other or record corrections with provenance history
|
|
41
|
-
- **Per-project tuning** — configure different recall limits and filters per detected project
|
|
60
|
+
Three steps to a working install, then optional tuning. The package install is automatic — the **only** thing you must configure by hand is the connection to your own AutoMem server, because that carries your private server URL and token, and no package can (or should) write those for you.
|
|
42
61
|
|
|
43
|
-
|
|
62
|
+
### 1. Install the package
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
pi install npm:pi-automem-bridge
|
|
66
|
+
```
|
|
44
67
|
|
|
45
|
-
|
|
68
|
+
This registers the extension's tools, commands, and recall hooks with pi automatically. Nothing runs yet — it has no server to talk to.
|
|
46
69
|
|
|
47
|
-
|
|
70
|
+
### 2. Connect it to your AutoMem server — *required*
|
|
71
|
+
|
|
72
|
+
Add an MCP server entry named `automem` to `~/.pi/agent/mcp.json`, pointing at the AutoMem instance from [Before you begin](#before-you-begin):
|
|
48
73
|
|
|
49
74
|
```json
|
|
50
75
|
{
|
|
@@ -59,9 +84,17 @@ Once those three are in place, add `mcp-automem` to pi's MCP config and install
|
|
|
59
84
|
}
|
|
60
85
|
```
|
|
61
86
|
|
|
62
|
-
Use `${ENV_VAR}` interpolation for secrets.
|
|
87
|
+
This is the one step that can't be automated: the package has no way to know your server's address or auth token, and writing credentials on your behalf would be unsafe. Use `${ENV_VAR}` interpolation for the token — never hardcode secrets. The entry must be named `automem` (the name the extension looks for by default), or set a different name via `mcpServerName` in step 4.
|
|
88
|
+
|
|
89
|
+
**Don't want to hand-edit JSON?** pi is a coding agent — tell it to do it: *"add an `automem` MCP server to my `mcp.json` at `https://my-server.example.com/mcp`, using `${AUTOMEM_TOKEN}` for auth."* Keep the real token in your environment so it never touches the file or the chat.
|
|
90
|
+
|
|
91
|
+
### 3. Reload pi
|
|
92
|
+
|
|
93
|
+
Start a new session or run `/reload`. **That's it — recall is now automatic and the bridge runs on sensible defaults** (`safe-auto` writes, `summary` recall display). From here, just work: pi recalls on its own and saves routine decisions automatically — tell it *"remember this"* anytime you want something kept. Confirm everything's live with `/automem-status`.
|
|
94
|
+
|
|
95
|
+
### 4. Tune behavior — *optional*
|
|
63
96
|
|
|
64
|
-
|
|
97
|
+
The bridge works fully without this file. To customize recall queries, write policy, per-project scoping, or display mode, create `~/.pi/agent/automem.json` — any value you leave out falls back to its default. (Or just tell pi what you want — *"only auto-save bug fixes and technical decisions, and hide the recall block"* — and have it write the file for you.)
|
|
65
98
|
|
|
66
99
|
```json
|
|
67
100
|
{
|
|
@@ -79,7 +112,7 @@ Use `${ENV_VAR}` interpolation for secrets. Never hardcode credentials.
|
|
|
79
112
|
}
|
|
80
113
|
```
|
|
81
114
|
|
|
82
|
-
|
|
115
|
+
Every option — with real values you can copy — is in the [Configuration reference](#configuration-reference) below.
|
|
83
116
|
|
|
84
117
|
---
|
|
85
118
|
|
|
@@ -92,6 +125,8 @@ Use `${ENV_VAR}` interpolation for secrets. Never hardcode credentials.
|
|
|
92
125
|
|
|
93
126
|
## Tools
|
|
94
127
|
|
|
128
|
+
You don't type these — pi does, in plain conversation. Tell it *"remember that I prefer Vitest over Jest"* and it runs the thought through the write pipeline before storing; say *"actually, we moved off Railway"* and it records a correction with provenance. In `safe-auto` mode it also captures routine decisions on its own, no prompting needed.
|
|
129
|
+
|
|
95
130
|
| Tool | What it does |
|
|
96
131
|
|---|---|
|
|
97
132
|
| `automem_propose_memory` | Preview a memory candidate — validates, scans for secrets, checks for duplicates. Does not write. |
|
|
@@ -135,16 +170,6 @@ When a commit finds a close match, `automem_commit_memory` returns `DUPLICATE_DE
|
|
|
135
170
|
|
|
136
171
|
---
|
|
137
172
|
|
|
138
|
-
## Recall display modes
|
|
139
|
-
|
|
140
|
-
| Mode | Behavior |
|
|
141
|
-
|---|---|
|
|
142
|
-
| `hidden` | Inject into system prompt only. Nothing shown in chat. |
|
|
143
|
-
| `summary` | Inject into system prompt + show a compact notification. |
|
|
144
|
-
| `full` | Show the full recall block. Useful for debugging. |
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
173
|
## Configuration reference
|
|
149
174
|
|
|
150
175
|
Config file: `~/.pi/agent/automem.json` (or `AUTOMEM_CONFIG_PATH`)
|
|
@@ -152,14 +177,31 @@ Config file: `~/.pi/agent/automem.json` (or `AUTOMEM_CONFIG_PATH`)
|
|
|
152
177
|
| Section | Purpose |
|
|
153
178
|
|---|---|
|
|
154
179
|
| `mcpServerName` | Which server in `mcp.json` to use |
|
|
155
|
-
| `startupRecall` | Queries, tags, limits, byte budget for session-start recall |
|
|
156
|
-
| `turnRecall` | Per-prompt recall: limits, memory types, relation/entity expansion |
|
|
180
|
+
| `startupRecall` | Queries, tags, limits, byte budget, and timeout for session-start recall |
|
|
181
|
+
| `turnRecall` | Per-prompt recall: limits, memory types, relation/entity expansion, and timeout |
|
|
157
182
|
| `projectDetection` | Map git repos and folder names to project tags for scoped recall |
|
|
158
183
|
| `projectOverrides` | Per-project overrides for turn recall limits and filters |
|
|
159
184
|
| `writePolicy` | Write mode, categories, importance threshold, dedupe settings |
|
|
160
185
|
| `behavior` | Display mode and content-length preferences |
|
|
161
186
|
|
|
162
|
-
|
|
187
|
+
Set only the keys you want to change — everything else uses its default. Two ready-to-edit starting points ship with the package:
|
|
188
|
+
|
|
189
|
+
- **[`config.minimal.json`](https://github.com/vaniteav/pi-automem-bridge/blob/main/examples/config.minimal.json)** — the smallest useful config.
|
|
190
|
+
- **[`config.advanced.json`](https://github.com/vaniteav/pi-automem-bridge/blob/main/examples/config.advanced.json)** — every option above, filled in with real values and sensible defaults. Copy it, trim what you don't need.
|
|
191
|
+
|
|
192
|
+
### Recall display (`behavior.displayRecall`)
|
|
193
|
+
|
|
194
|
+
Controls how much of the recalled context shows in chat. Injection into the system prompt happens regardless.
|
|
195
|
+
|
|
196
|
+
| Mode | Behavior |
|
|
197
|
+
|---|---|
|
|
198
|
+
| `hidden` | Inject into system prompt only. Nothing shown in chat. |
|
|
199
|
+
| `summary` | Inject into system prompt + show a compact notification. |
|
|
200
|
+
| `full` | Show the full recall block. Useful for debugging. |
|
|
201
|
+
|
|
202
|
+
### Recall timeouts
|
|
203
|
+
|
|
204
|
+
Recall is best-effort context enrichment, so it runs on a short, bounded timeout instead of the full MCP request timeout — a slow or unreachable AutoMem server degrades gracefully to no injection rather than blocking your prompt. Tune with `turnRecall.timeoutMs` (default `8000`) and `startupRecall.timeoutMs` (default `15000`).
|
|
163
205
|
|
|
164
206
|
---
|
|
165
207
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-automem-bridge",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Automatic long-term memory recall and policy-gated writes for pi agents via AutoMem MCP",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
"scripts": {
|
|
28
28
|
"test": "tsx tests/unit.ts && tsx tests/phase2-policy.ts && tsx tests/review-fixes.ts",
|
|
29
29
|
"test:smoke": "tsx tests/phase1-smoke.ts",
|
|
30
|
-
"test:live": "tsx tests/phase2-live-write.ts"
|
|
30
|
+
"test:live": "tsx tests/phase2-live-write.ts",
|
|
31
|
+
"preflight": "node scripts/preflight.mjs",
|
|
32
|
+
"prepublishOnly": "node scripts/preflight.mjs"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"tsx": "^4.20.6"
|