pi-automem-bridge 0.2.0 → 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 CHANGED
@@ -1,19 +1,48 @@
1
1
  <div align="center">
2
2
 
3
+ ![pi-automem-bridge](assets/banner.png)
4
+
3
5
  # pi-automem-bridge
4
6
 
5
- The missing link between [pi](https://github.com/earendil-works/pi) and [AutoMem](https://github.com/verygoodplugins/automem). If you already have both set up, this package connects them — giving pi automatic long-term memory: startup recall, turn-level recall, policy-gated writes, and relationship tools.
7
+ > **AutoMem is the memory. This bridge ensures pi actually uses it.**
6
8
 
7
9
  ```bash
8
10
  pi install npm:pi-automem-bridge
9
11
  ```
10
12
 
13
+ [![npm version](https://badge.fury.io/js/pi-automem-bridge.svg)](https://badge.fury.io/js/pi-automem-bridge)
14
+ [![npm downloads](https://img.shields.io/npm/dw/pi-automem-bridge)](https://www.npmjs.com/package/pi-automem-bridge)
15
+
11
16
  [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/L2J320X82M)
12
17
 
13
18
  </div>
14
19
 
15
20
  ---
16
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
+
17
46
  ## Before you begin
18
47
 
19
48
  This package does not include pi or AutoMem — it connects them. You need both running independently first:
@@ -22,24 +51,25 @@ This package does not include pi or AutoMem — it connects them. You need both
22
51
  2. **[AutoMem](https://github.com/verygoodplugins/automem)** — the graph-vector memory service (self-hosted or Railway)
23
52
  3. **[mcp-automem](https://github.com/verygoodplugins/mcp-automem)** — the MCP bridge that exposes AutoMem's tools over the MCP protocol
24
53
 
25
- Once those three are in place, add `mcp-automem` to pi's MCP config and install this package. That's all the wiring this package needs.
54
+ Once those three are in place, follow the setup below.
26
55
 
27
56
  ---
28
57
 
29
- ## What it does
58
+ ## Setup
30
59
 
31
- - **Startup recall**at session start, queries AutoMem for your preferences, working style, and environment
32
- - **Turn-level recall** — before each agent prompt, retrieves memories relevant to the current task and detected project
33
- - **Silent injection** — memory context is injected into the system prompt, not the chat window
34
- - **Policy-gated writes** — every memory write is validated, secret-scanned, deduplicated, and confirmed before storage
35
- - **Relationship tools** — link memories to each other or record corrections with provenance history
36
- - **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.
37
61
 
38
- ---
62
+ ### 1. Install the package
39
63
 
40
- ## Getting started
64
+ ```bash
65
+ pi install npm:pi-automem-bridge
66
+ ```
41
67
 
42
- **1. Add your AutoMem server to `~/.pi/agent/mcp.json`:**
68
+ This registers the extension's tools, commands, and recall hooks with pi automatically. Nothing runs yet — it has no server to talk to.
69
+
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):
43
73
 
44
74
  ```json
45
75
  {
@@ -54,9 +84,17 @@ Once those three are in place, add `mcp-automem` to pi's MCP config and install
54
84
  }
55
85
  ```
56
86
 
57
- Use `${ENV_VAR}` interpolation for secrets. Never hardcode credentials.
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`.
58
94
 
59
- **2. Create `~/.pi/agent/automem.json`:**
95
+ ### 4. Tune behavior — *optional*
96
+
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.)
60
98
 
61
99
  ```json
62
100
  {
@@ -74,7 +112,7 @@ Use `${ENV_VAR}` interpolation for secrets. Never hardcode credentials.
74
112
  }
75
113
  ```
76
114
 
77
- **3. Start or reload pi.** Recall is now automatic.
115
+ Every option with real values you can copy — is in the [Configuration reference](#configuration-reference) below.
78
116
 
79
117
  ---
80
118
 
@@ -87,6 +125,8 @@ Use `${ENV_VAR}` interpolation for secrets. Never hardcode credentials.
87
125
 
88
126
  ## Tools
89
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
+
90
130
  | Tool | What it does |
91
131
  |---|---|
92
132
  | `automem_propose_memory` | Preview a memory candidate — validates, scans for secrets, checks for duplicates. Does not write. |
@@ -130,16 +170,6 @@ When a commit finds a close match, `automem_commit_memory` returns `DUPLICATE_DE
130
170
 
131
171
  ---
132
172
 
133
- ## Recall display modes
134
-
135
- | Mode | Behavior |
136
- |---|---|
137
- | `hidden` | Inject into system prompt only. Nothing shown in chat. |
138
- | `summary` | Inject into system prompt + show a compact notification. |
139
- | `full` | Show the full recall block. Useful for debugging. |
140
-
141
- ---
142
-
143
173
  ## Configuration reference
144
174
 
145
175
  Config file: `~/.pi/agent/automem.json` (or `AUTOMEM_CONFIG_PATH`)
@@ -147,14 +177,31 @@ Config file: `~/.pi/agent/automem.json` (or `AUTOMEM_CONFIG_PATH`)
147
177
  | Section | Purpose |
148
178
  |---|---|
149
179
  | `mcpServerName` | Which server in `mcp.json` to use |
150
- | `startupRecall` | Queries, tags, limits, byte budget for session-start recall |
151
- | `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 |
152
182
  | `projectDetection` | Map git repos and folder names to project tags for scoped recall |
153
183
  | `projectOverrides` | Per-project overrides for turn recall limits and filters |
154
184
  | `writePolicy` | Write mode, categories, importance threshold, dedupe settings |
155
185
  | `behavior` | Display mode and content-length preferences |
156
186
 
157
- See [`examples/config.minimal.json`](examples/config.minimal.json) and [`examples/config.advanced.json`](examples/config.advanced.json).
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`).
158
205
 
159
206
  ---
160
207
 
@@ -169,7 +216,6 @@ npm run test:smoke # live smoke test (requires AutoMem)
169
216
  npm run test:live # full round-trip write test (requires AutoMem)
170
217
  ```
171
218
 
172
- See [CONTRIBUTING.md](CONTRIBUTING.md) for architecture notes, test descriptions, and release process.
173
219
 
174
220
  ---
175
221
 
@@ -1,59 +1,61 @@
1
- {
2
- "mcpServerName": "automem",
3
- "startupRecall": {
4
- "queries": [
5
- "user preferences working style",
6
- "agent operating guidelines",
7
- "local development environment",
8
- "active projects recent decisions"
9
- ],
10
- "tags": ["source:pi"],
11
- "tagMode": "any",
12
- "limit": 6,
13
- "maxBytes": 5000
14
- },
15
- "turnRecall": {
16
- "enabled": true,
17
- "limit": 5,
18
- "maxBytes": 3000,
19
- "contextTypes": ["Preference", "Decision", "Pattern", "Insight", "Context"],
20
- "expandRelations": true,
21
- "expandEntities": true
22
- },
23
- "projectDetection": {
24
- "tagPrefix": "project:",
25
- "folderTags": {
26
- "projects": ["project"],
27
- "areas": ["area"],
28
- "resources": ["resource"]
29
- },
30
- "gitRepoToTag": {
31
- "my-project": "project:my-project"
32
- }
33
- },
34
- "writePolicy": {
35
- "mode": "safe-auto",
36
- "autoWriteCategories": ["technical-decision", "agent-pattern", "bug-fix", "tooling-lesson"],
37
- "confirmCategories": ["personal", "financial", "private", "identity"],
38
- "blockedCategories": ["secret", "credential", "api-key", "raw-transcript"],
39
- "alwaysTag": ["source:pi"],
40
- "minImportanceToWrite": 0.7,
41
- "dedupeBeforeWrite": true,
42
- "dedupeLimit": 3
43
- },
44
- "behavior": {
45
- "displayRecall": "hidden",
46
- "maxContentLength": 2000,
47
- "preferredContentLength": 500
48
- },
49
- "projectOverrides": {
50
- "project:my-large-project": {
51
- "limit": 10,
52
- "maxBytes": 6000
53
- },
54
- "project:quick-scripts": {
55
- "limit": 2,
56
- "maxBytes": 1000
57
- }
58
- }
59
- }
1
+ {
2
+ "mcpServerName": "automem",
3
+ "startupRecall": {
4
+ "queries": [
5
+ "user preferences working style",
6
+ "agent operating guidelines",
7
+ "local development environment",
8
+ "active projects recent decisions"
9
+ ],
10
+ "tags": ["source:pi"],
11
+ "tagMode": "any",
12
+ "limit": 6,
13
+ "maxBytes": 5000,
14
+ "timeoutMs": 15000
15
+ },
16
+ "turnRecall": {
17
+ "enabled": true,
18
+ "limit": 5,
19
+ "maxBytes": 3000,
20
+ "contextTypes": ["Preference", "Decision", "Pattern", "Insight", "Context"],
21
+ "expandRelations": true,
22
+ "expandEntities": true,
23
+ "timeoutMs": 8000
24
+ },
25
+ "projectDetection": {
26
+ "tagPrefix": "project:",
27
+ "folderTags": {
28
+ "projects": ["project"],
29
+ "areas": ["area"],
30
+ "resources": ["resource"]
31
+ },
32
+ "gitRepoToTag": {
33
+ "my-project": "project:my-project"
34
+ }
35
+ },
36
+ "writePolicy": {
37
+ "mode": "safe-auto",
38
+ "autoWriteCategories": ["technical-decision", "agent-pattern", "bug-fix", "tooling-lesson"],
39
+ "confirmCategories": ["personal", "financial", "private", "identity"],
40
+ "blockedCategories": ["secret", "credential", "api-key", "raw-transcript"],
41
+ "alwaysTag": ["source:pi"],
42
+ "minImportanceToWrite": 0.7,
43
+ "dedupeBeforeWrite": true,
44
+ "dedupeLimit": 3
45
+ },
46
+ "behavior": {
47
+ "displayRecall": "hidden",
48
+ "maxContentLength": 2000,
49
+ "preferredContentLength": 500
50
+ },
51
+ "projectOverrides": {
52
+ "project:my-large-project": {
53
+ "limit": 10,
54
+ "maxBytes": 6000
55
+ },
56
+ "project:quick-scripts": {
57
+ "limit": 2,
58
+ "maxBytes": 1000
59
+ }
60
+ }
61
+ }
package/package.json CHANGED
@@ -1,58 +1,61 @@
1
- {
2
- "name": "pi-automem-bridge",
3
- "version": "0.2.0",
4
- "description": "Automatic long-term memory recall and policy-gated writes for pi agents via AutoMem MCP",
5
- "keywords": [
6
- "pi-package",
7
- "pi-extension",
8
- "automem",
9
- "mcp",
10
- "memory",
11
- "long-term-memory",
12
- "semantic-memory",
13
- "memory-write-policy",
14
- "agent-memory"
15
- ],
16
- "license": "MIT",
17
- "author": "vaniteav",
18
- "repository": {
19
- "type": "git",
20
- "url": "https://github.com/vaniteav/pi-automem-bridge.git"
21
- },
22
- "peerDependencies": {
23
- "@earendil-works/pi-coding-agent": ">=0.78.0",
24
- "typebox": "*"
25
- },
26
- "scripts": {
27
- "test": "tsx tests/unit.ts && tsx tests/write-policy.ts",
28
- "test:smoke": "tsx tests/smoke.ts",
29
- "test:live": "tsx tests/live-write.ts"
30
- },
31
- "devDependencies": {
32
- "tsx": "^4.20.6"
33
- },
34
- "dependencies": {},
35
- "pi": {
36
- "extensions": [
37
- "./src/index.ts"
38
- ],
39
- "skills": [
40
- "./skills"
41
- ],
42
- "prompts": [
43
- "./prompts"
44
- ]
45
- },
46
- "bugs": {
47
- "url": "https://github.com/vaniteav/pi-automem-bridge/issues"
48
- },
49
- "homepage": "https://github.com/vaniteav/pi-automem-bridge#readme",
50
- "files": [
51
- "src",
52
- "skills",
53
- "prompts",
54
- "examples",
55
- "README.md",
56
- "LICENSE"
57
- ]
58
- }
1
+ {
2
+ "name": "pi-automem-bridge",
3
+ "version": "0.2.2",
4
+ "description": "Automatic long-term memory recall and policy-gated writes for pi agents via AutoMem MCP",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi-extension",
8
+ "automem",
9
+ "mcp",
10
+ "memory",
11
+ "long-term-memory",
12
+ "semantic-memory",
13
+ "memory-write-policy",
14
+ "agent-memory"
15
+ ],
16
+ "license": "MIT",
17
+ "author": "vaniteav",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/vaniteav/pi-automem-bridge.git"
21
+ },
22
+ "peerDependencies": {
23
+ "@earendil-works/pi-coding-agent": ">=0.78.0",
24
+ "@verygoodplugins/mcp-automem": "*",
25
+ "typebox": "*"
26
+ },
27
+ "scripts": {
28
+ "test": "tsx tests/unit.ts && tsx tests/phase2-policy.ts && tsx tests/review-fixes.ts",
29
+ "test:smoke": "tsx tests/phase1-smoke.ts",
30
+ "test:live": "tsx tests/phase2-live-write.ts",
31
+ "preflight": "node scripts/preflight.mjs",
32
+ "prepublishOnly": "node scripts/preflight.mjs"
33
+ },
34
+ "devDependencies": {
35
+ "tsx": "^4.20.6"
36
+ },
37
+ "dependencies": {},
38
+ "pi": {
39
+ "extensions": [
40
+ "./src/index.ts"
41
+ ],
42
+ "skills": [
43
+ "./skills"
44
+ ],
45
+ "prompts": [
46
+ "./prompts"
47
+ ]
48
+ },
49
+ "bugs": {
50
+ "url": "https://github.com/vaniteav/pi-automem-bridge/issues"
51
+ },
52
+ "homepage": "https://github.com/vaniteav/pi-automem-bridge#readme",
53
+ "files": [
54
+ "src",
55
+ "skills",
56
+ "prompts",
57
+ "examples",
58
+ "README.md",
59
+ "LICENSE"
60
+ ]
61
+ }