@chendpoc/pi-memory 0.2.4 → 0.3.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 +92 -43
- package/dist/adapters/llm/standalone.js +1 -1
- package/dist/cli/init.js +20 -3
- package/dist/cli/parseArgs.d.ts +5 -2
- package/dist/cli/parseArgs.js +13 -0
- package/dist/cli/schedulerSync.d.ts +2 -0
- package/dist/cli/schedulerSync.js +26 -0
- package/dist/cli/status.d.ts +4 -40
- package/dist/cli/status.js +6 -230
- package/dist/cli/theme.d.ts +2 -0
- package/dist/cli/theme.js +8 -0
- package/dist/cli.js +5 -0
- package/dist/commands/status.js +2 -2
- package/dist/compact/parseMemoryExport.js +2 -1
- package/dist/compact/register.js +1 -1
- package/dist/compact/runSummary.js +1 -16
- package/dist/compact/subagentDelta.js +3 -5
- package/dist/consolidate/index.d.ts +1 -0
- package/dist/consolidate/index.js +1 -0
- package/dist/consolidate/mergeEntries.js +3 -3
- package/dist/consolidate/mergeMemoryEntries.d.ts +8 -0
- package/dist/consolidate/mergeMemoryEntries.js +23 -0
- package/dist/consolidate/mergePrompt.js +2 -2
- package/dist/consolidate/mergeWithLlm.js +2 -2
- package/dist/consolidate/runJob.d.ts +2 -2
- package/dist/consolidate/runJob.js +6 -12
- package/dist/consolidate/scheduler.d.ts +2 -2
- package/dist/consolidate/scheduler.js +1 -1
- package/dist/constants/env.d.ts +1 -0
- package/dist/constants/env.js +1 -0
- package/dist/constants/paths.d.ts +3 -1
- package/dist/constants/paths.js +6 -1
- package/dist/extension/createMemoryRuntime.d.ts +3 -0
- package/dist/extension/createMemoryRuntime.js +203 -0
- package/dist/extension/index.d.ts +2 -0
- package/dist/extension/index.js +1 -0
- package/dist/extension/lifecycle.d.ts +28 -0
- package/dist/extension/lifecycle.js +52 -0
- package/dist/extension/messageUtils.d.ts +4 -0
- package/dist/extension/messageUtils.js +18 -0
- package/dist/extension/types.d.ts +35 -0
- package/dist/extension/types.js +1 -0
- package/dist/index.d.ts +7 -9
- package/dist/index.js +7 -9
- package/dist/pi-extension.js +26 -236
- package/dist/preflight/episodic.js +13 -30
- package/dist/preflight/queryIntent.js +1 -1
- package/dist/preflight/render.js +1 -1
- package/dist/preflight/strip.d.ts +0 -1
- package/dist/preflight/strip.js +0 -24
- package/dist/redaction/index.d.ts +4 -0
- package/dist/redaction/index.js +3 -0
- package/dist/redaction/patterns/constants.d.ts +6 -0
- package/dist/redaction/patterns/constants.js +6 -0
- package/dist/redaction/patterns/crypto.d.ts +3 -0
- package/dist/redaction/patterns/crypto.js +17 -0
- package/dist/redaction/patterns/generic.d.ts +3 -0
- package/dist/redaction/patterns/generic.js +38 -0
- package/dist/redaction/patterns/index.d.ts +16 -0
- package/dist/redaction/patterns/index.js +23 -0
- package/dist/redaction/patterns/llm.d.ts +3 -0
- package/dist/redaction/patterns/llm.js +144 -0
- package/dist/redaction/patterns/platform.d.ts +3 -0
- package/dist/redaction/patterns/platform.js +87 -0
- package/dist/redaction/patterns/types.d.ts +18 -0
- package/dist/redaction/patterns/types.js +1 -0
- package/dist/redaction/redactText.d.ts +9 -0
- package/dist/redaction/redactText.js +31 -0
- package/dist/redaction/types.d.ts +19 -0
- package/dist/redaction/types.js +1 -0
- package/dist/redaction/utils.d.ts +28 -0
- package/dist/redaction/utils.js +106 -0
- package/dist/scheduler/index.d.ts +3 -0
- package/dist/scheduler/index.js +3 -0
- package/dist/scheduler/launchd.d.ts +14 -0
- package/dist/scheduler/launchd.js +69 -0
- package/dist/scheduler/launchdPlist.d.ts +14 -0
- package/dist/scheduler/launchdPlist.js +62 -0
- package/dist/scheduler/sync.d.ts +36 -0
- package/dist/scheduler/sync.js +79 -0
- package/dist/shutdown/enqueue.d.ts +1 -1
- package/dist/shutdown/enqueue.js +2 -5
- package/dist/shutdown/readQueue.js +1 -1
- package/dist/shutdown/runDrainJob.js +8 -37
- package/dist/shutdown/sessionReader.js +1 -14
- package/dist/sidecar/client.d.ts +6 -2
- package/dist/sidecar/client.js +49 -14
- package/dist/{preflight → sidecar}/queryCache.d.ts +1 -1
- package/dist/sidecar/reindexBridge.js +2 -2
- package/dist/sidecar/server/server.js +1 -1
- package/dist/sidecar/server/vec/chunkQuery.d.ts +4 -0
- package/dist/sidecar/server/vec/chunkQuery.js +46 -0
- package/dist/sidecar/server/vec/chunkReindex.d.ts +5 -0
- package/dist/sidecar/server/vec/chunkReindex.js +40 -0
- package/dist/sidecar/server/vec/embeddingCodec.d.ts +2 -0
- package/dist/sidecar/server/vec/embeddingCodec.js +6 -0
- package/dist/sidecar/server/vec/schema.d.ts +20 -0
- package/dist/sidecar/server/vec/schema.js +61 -0
- package/dist/sidecar/server/vec/store.d.ts +2 -13
- package/dist/sidecar/server/vec/store.js +12 -139
- package/dist/sidecar/sidecarManager.js +4 -58
- package/dist/sidecar/spawnLock.d.ts +2 -0
- package/dist/sidecar/spawnLock.js +57 -0
- package/dist/sidecar/syncIndex.d.ts +3 -0
- package/dist/sidecar/syncIndex.js +12 -0
- package/dist/sidecar/warmup.js +1 -1
- package/dist/status/copy.d.ts +2 -0
- package/dist/status/copy.js +2 -0
- package/dist/status/format.d.ts +7 -0
- package/dist/status/format.js +133 -0
- package/dist/status/gather.d.ts +2 -0
- package/dist/status/gather.js +88 -0
- package/dist/status/index.d.ts +4 -0
- package/dist/status/index.js +3 -0
- package/dist/status/types.d.ts +33 -0
- package/dist/status/types.js +1 -0
- package/dist/store/consolidatePort.d.ts +11 -0
- package/dist/store/consolidatePort.js +1 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.js +1 -0
- package/dist/store/ingestEntries.d.ts +16 -0
- package/dist/store/ingestEntries.js +22 -0
- package/dist/{init/workspace.d.ts → store/initWorkspace.d.ts} +1 -1
- package/dist/{init/workspace.js → store/initWorkspace.js} +7 -5
- package/dist/store/listeners.d.ts +11 -0
- package/dist/store/listeners.js +27 -0
- package/dist/store/markdown/insert.d.ts +3 -0
- package/dist/store/markdown/insert.js +23 -0
- package/dist/store/memoryStore.d.ts +9 -22
- package/dist/store/memoryStore.js +71 -205
- package/dist/store/resolveEntries.d.ts +11 -0
- package/dist/store/resolveEntries.js +23 -0
- package/dist/store/types.d.ts +0 -1
- package/dist/store/writePath.d.ts +20 -0
- package/dist/store/writePath.js +123 -0
- package/dist/ui/memoryStatusWidget.d.ts +4 -8
- package/dist/ui/memoryStatusWidget.js +5 -17
- package/dist/utils/async.d.ts +11 -0
- package/dist/utils/async.js +24 -0
- package/dist/utils/index.d.ts +5 -1
- package/dist/utils/index.js +5 -1
- package/dist/{ipc/jsonlFramer.d.ts → utils/jsonl.d.ts} +1 -1
- package/dist/{ipc/jsonlFramer.js → utils/jsonl.js} +1 -1
- package/dist/utils/memory/index.d.ts +10 -0
- package/dist/utils/memory/index.js +43 -0
- package/dist/utils/paths.d.ts +4 -0
- package/dist/utils/paths.js +13 -3
- package/dist/utils/scheduler.d.ts +1 -1
- package/dist/utils/scheduler.js +6 -6
- package/dist/{preflight/session.d.ts → utils/session/index.d.ts} +1 -0
- package/dist/{preflight/session.js → utils/session/index.js} +5 -2
- package/doc/LAUNCH-KIT.md +229 -0
- package/doc/README-zh.md +445 -0
- package/doc/ROADMAP-zh.md +114 -0
- package/doc/ROADMAP.md +114 -0
- package/package.json +16 -4
- package/scripts/postinstall.mjs +11 -1
- package/templates/com.pi.memory.consolidate.plist.example +41 -0
- package/templates/consolidate.cmd.example +15 -0
- package/templates/crontab.example +14 -0
- package/templates/schtasks.example.txt +34 -0
- package/dist/consolidate/entryKey.d.ts +0 -5
- package/dist/consolidate/entryKey.js +0 -4
- /package/dist/{preflight → sidecar}/queryCache.js +0 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# @chendpoc/pi-memory Launch Kit
|
|
2
|
+
|
|
3
|
+
This document is copy-ready material for sharing `@chendpoc/pi-memory`.
|
|
4
|
+
Before each launch, re-check the package version and public links.
|
|
5
|
+
|
|
6
|
+
## Public Links
|
|
7
|
+
|
|
8
|
+
- GitHub: https://github.com/chendpoc/pi-memory
|
|
9
|
+
- npm: https://www.npmjs.com/package/@chendpoc/pi-memory
|
|
10
|
+
- Pi package page: https://pi.dev/packages/@chendpoc/pi-memory
|
|
11
|
+
- Install command:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pi install npm:@chendpoc/pi-memory
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Positioning
|
|
18
|
+
|
|
19
|
+
One-liner:
|
|
20
|
+
|
|
21
|
+
> Local-first Markdown memory for the Pi coding agent: remember preferences, project conventions, decisions, and todos across sessions without making a hosted database the source of truth.
|
|
22
|
+
|
|
23
|
+
Short pitch:
|
|
24
|
+
|
|
25
|
+
> `pi-memory` gives Pi cross-session memory that stays local and inspectable. It writes durable facts to `MEMORY.md`, recalls relevant entries before Pi answers, redacts common secrets before saving, and degrades gracefully when recall is unavailable.
|
|
26
|
+
|
|
27
|
+
Longer pitch:
|
|
28
|
+
|
|
29
|
+
> Pi compaction helps a long conversation continue, but it does not make future sessions remember stable preferences, project rules, prior decisions, or unresolved todos. `pi-memory` fills that gap with a local-first loop: explicit `/remember` notes, durable memory export from compaction and shutdown maintenance, `MEMORY.md` as the editable ground truth, and bounded pre-answer recall through a sidecar-derived index.
|
|
30
|
+
|
|
31
|
+
## Proof Points
|
|
32
|
+
|
|
33
|
+
Lead with behavior, not architecture:
|
|
34
|
+
|
|
35
|
+
- A new Pi session can answer from previously saved preferences instead of asking the user to repeat context.
|
|
36
|
+
- `/remember` writes user-authored entries that consolidation must preserve.
|
|
37
|
+
- `MEMORY.md` remains editable, greppable, copyable, and versionable.
|
|
38
|
+
- Common secrets are redacted before durable memory writes.
|
|
39
|
+
- Recall has a bounded preflight budget and falls back instead of blocking the agent turn.
|
|
40
|
+
- Maintenance runs outside ordinary interactive turns.
|
|
41
|
+
|
|
42
|
+
## Two-Minute Demo
|
|
43
|
+
|
|
44
|
+
Use a fresh memory directory for recording so the demo does not expose personal memory:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
export PI_MEMORY_AGENT_DIR="$(mktemp -d)"
|
|
48
|
+
pi install npm:@chendpoc/pi-memory
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In Pi:
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
/remember Preferences Prefer pnpm over npm in JavaScript projects.
|
|
55
|
+
/remember Conventions Public docs should be English-first, with Chinese docs under doc/.
|
|
56
|
+
/memory-status expand
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Show the ground-truth file:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cat "$PI_MEMORY_AGENT_DIR/MEMORY.md"
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Start a new Pi session and ask:
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
For this package, which package manager should I use, and where should Chinese docs live?
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The expected story is not "magic memory". The expected story is:
|
|
72
|
+
|
|
73
|
+
1. The user explicitly saved stable preferences.
|
|
74
|
+
2. The memory is visible in Markdown.
|
|
75
|
+
3. A later session can use it before answering.
|
|
76
|
+
4. If recall is unavailable, Pi still answers without memory injection.
|
|
77
|
+
|
|
78
|
+
## Demo Asset Checklist
|
|
79
|
+
|
|
80
|
+
The launch posts should link to the repo, but the repo alone is not enough for cold readers. Prepare one short visual proof before posting outside the Pi community.
|
|
81
|
+
|
|
82
|
+
Recommended asset:
|
|
83
|
+
|
|
84
|
+
- Length: 30-60 seconds.
|
|
85
|
+
- Format: GIF or short MP4.
|
|
86
|
+
- First frame: package name, install command, and the phrase "local Markdown memory for Pi".
|
|
87
|
+
- Main sequence: `/remember` -> `MEMORY.md` -> new Pi session -> recalled answer -> `/memory-status`.
|
|
88
|
+
- Final frame: GitHub URL and `pi install npm:@chendpoc/pi-memory`.
|
|
89
|
+
|
|
90
|
+
Recording script:
|
|
91
|
+
|
|
92
|
+
```text
|
|
93
|
+
1. Open a clean terminal with PI_MEMORY_AGENT_DIR pointing at a temp directory.
|
|
94
|
+
2. Install or show the installed package.
|
|
95
|
+
3. In Pi, run two /remember commands.
|
|
96
|
+
4. Open MEMORY.md and show the exact saved bullets.
|
|
97
|
+
5. Start a new Pi session and ask a question that depends on those bullets.
|
|
98
|
+
6. Show /memory-status expand.
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Do not record a personal `MEMORY.md`. Do not show real API keys, private repo names, or private session paths.
|
|
102
|
+
|
|
103
|
+
## Copy Blocks
|
|
104
|
+
|
|
105
|
+
### X / Bluesky
|
|
106
|
+
|
|
107
|
+
```text
|
|
108
|
+
I shipped @chendpoc/pi-memory: local-first Markdown memory for the Pi coding agent.
|
|
109
|
+
|
|
110
|
+
It keeps preferences, project conventions, decisions, and todos in MEMORY.md, recalls relevant entries before Pi answers, and redacts common secrets before saving.
|
|
111
|
+
|
|
112
|
+
Install:
|
|
113
|
+
pi install npm:@chendpoc/pi-memory
|
|
114
|
+
|
|
115
|
+
https://github.com/chendpoc/pi-memory
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Hacker News / Reddit
|
|
119
|
+
|
|
120
|
+
Title:
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
Show HN: pi-memory - local Markdown memory for the Pi coding agent
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Body:
|
|
127
|
+
|
|
128
|
+
```text
|
|
129
|
+
I built pi-memory because Pi compaction helps continue one long session, but I wanted future sessions to remember stable preferences, project conventions, decisions, and open todos.
|
|
130
|
+
|
|
131
|
+
The design is intentionally local and inspectable:
|
|
132
|
+
|
|
133
|
+
- MEMORY.md is the ground truth.
|
|
134
|
+
- /remember writes explicit user notes.
|
|
135
|
+
- compaction and shutdown maintenance can export durable facts.
|
|
136
|
+
- a sidecar builds a derived index for pre-answer recall.
|
|
137
|
+
- common secrets are redacted before durable memory writes.
|
|
138
|
+
- recall is best-effort, so the agent still runs if memory is slow or unavailable.
|
|
139
|
+
|
|
140
|
+
Install:
|
|
141
|
+
pi install npm:@chendpoc/pi-memory
|
|
142
|
+
|
|
143
|
+
GitHub:
|
|
144
|
+
https://github.com/chendpoc/pi-memory
|
|
145
|
+
|
|
146
|
+
npm:
|
|
147
|
+
https://www.npmjs.com/package/@chendpoc/pi-memory
|
|
148
|
+
|
|
149
|
+
I would especially like feedback on recall quality, memory review UX, and whether hybrid lexical + vector recall should be the next milestone.
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Pi Community
|
|
153
|
+
|
|
154
|
+
```text
|
|
155
|
+
I published @chendpoc/pi-memory for Pi.
|
|
156
|
+
|
|
157
|
+
It adds local cross-session memory: /remember, editable MEMORY.md ground truth, pre-answer recall, compaction/shutdown export, status diagnostics, and secret redaction before durable writes.
|
|
158
|
+
|
|
159
|
+
Install:
|
|
160
|
+
pi install npm:@chendpoc/pi-memory
|
|
161
|
+
|
|
162
|
+
Pi package page:
|
|
163
|
+
https://pi.dev/packages/@chendpoc/pi-memory
|
|
164
|
+
|
|
165
|
+
GitHub:
|
|
166
|
+
https://github.com/chendpoc/pi-memory
|
|
167
|
+
|
|
168
|
+
Feedback I am looking for: install friction, recall quality, and what memory review/edit commands should look like.
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Chinese Short Post
|
|
172
|
+
|
|
173
|
+
```text
|
|
174
|
+
我做了一个 Pi 插件 @chendpoc/pi-memory:给 Pi 加 local-first 跨会话记忆。
|
|
175
|
+
|
|
176
|
+
核心不是把聊天记录塞进数据库,而是把稳定偏好、项目约定、决策和 TODO 写进可编辑的 MEMORY.md;每次回答前尽量召回相关记忆;写入前会对常见 token/secret 做脱敏;召回失败也不会阻塞正常对话。
|
|
177
|
+
|
|
178
|
+
安装:
|
|
179
|
+
pi install npm:@chendpoc/pi-memory
|
|
180
|
+
|
|
181
|
+
GitHub:
|
|
182
|
+
https://github.com/chendpoc/pi-memory
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Launch Sequence
|
|
186
|
+
|
|
187
|
+
This material can improve conversion, but it will not create demand by itself. The highest-leverage launch path is narrow first, then broader technical audiences.
|
|
188
|
+
|
|
189
|
+
| Step | Channel | Goal | Success signal |
|
|
190
|
+
| --- | --- | --- | --- |
|
|
191
|
+
| 1 | GitHub repo metadata | Make the first click understandable | Description, topics, README, and demo asset all tell the same story |
|
|
192
|
+
| 2 | Pi community / Discord | Find install friction quickly | 3-5 people try `pi install npm:@chendpoc/pi-memory` |
|
|
193
|
+
| 3 | X / Bluesky | Lightweight awareness | Clicks, stars, replies asking what Pi memory does |
|
|
194
|
+
| 4 | Reddit / HN | Technical feedback | Comments about design tradeoffs, recall quality, local-first boundary |
|
|
195
|
+
| 5 | Technical article | Durable search traffic | People arrive via "Pi agent memory", "local agent memory", or "Markdown memory" searches |
|
|
196
|
+
|
|
197
|
+
Suggested order:
|
|
198
|
+
|
|
199
|
+
1. Update the GitHub repo description to the one-liner above.
|
|
200
|
+
2. Add one demo GIF/MP4 or screenshot to the README near the top.
|
|
201
|
+
3. Share in the Pi package/community channel first, because the install path is Pi-specific.
|
|
202
|
+
4. Fix install friction reported by early users before posting broadly.
|
|
203
|
+
5. Post the Show HN / Reddit version after the README and demo are stable.
|
|
204
|
+
6. Follow up with a technical post comparing local Markdown ground truth, sidecar-derived indexes, and hosted memory APIs.
|
|
205
|
+
|
|
206
|
+
Track these numbers for one week:
|
|
207
|
+
|
|
208
|
+
- npm downloads.
|
|
209
|
+
- GitHub stars / forks.
|
|
210
|
+
- Pi community installs or replies.
|
|
211
|
+
- Issues filed about install, recall quality, or memory review UX.
|
|
212
|
+
- Number of users who complete the two-minute demo.
|
|
213
|
+
|
|
214
|
+
## Do Not Claim
|
|
215
|
+
|
|
216
|
+
- Do not call it a full session search product.
|
|
217
|
+
- Do not imply it stores or indexes full chat transcripts as memory.
|
|
218
|
+
- Do not claim perfect privacy; the accurate claim is local-first memory files plus redaction before durable memory writes.
|
|
219
|
+
- Do not pitch it as a Mem0/Zep replacement; it is a Pi-native, Markdown-first memory loop.
|
|
220
|
+
- Do not promise multi-hop graph reasoning or autonomous memory editing before those features ship.
|
|
221
|
+
- Do not lead with future cloud sync; for the current product, lead with local-first Ground Truth and optional derived indexes.
|
|
222
|
+
|
|
223
|
+
## Feedback Questions
|
|
224
|
+
|
|
225
|
+
- Did install work with `pi install npm:@chendpoc/pi-memory`?
|
|
226
|
+
- Was `MEMORY.md` created where you expected?
|
|
227
|
+
- Did `/memory-status expand` explain the state clearly?
|
|
228
|
+
- Did recall retrieve the memory you expected in a new session?
|
|
229
|
+
- Would you rather edit memory through Markdown, commands, or a TUI review panel?
|
package/doc/README-zh.md
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="../assets/pi-memory-logo.png" alt="pi-memory logo" width="720" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
# @chendpoc/pi-memory
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="../README.md">English</a> |
|
|
9
|
+
<a href="README-zh.md">简体中文</a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
给 Pi coding agent 使用的本地记忆扩展,让 Pi 能跨 session 记住你的偏好、项目约定、历史决策和未完成 TODO。
|
|
13
|
+
|
|
14
|
+
`pi-memory` 把长期笔记保存在本地 Markdown 中,在 Pi 回答前自动召回相关内容,并在写入前脱敏常见 secret。目标很简单:新开的 Pi session 应该带着你希望它记住的上下文开始,而不是依赖不透明的托管记忆服务。
|
|
15
|
+
|
|
16
|
+
## 🧠 这个 Package 做什么
|
|
17
|
+
|
|
18
|
+
Pi 已经有长 session compaction,它能帮助当前长对话继续下去;但它不负责让未来的新 session 记住你的稳定偏好、项目规则、历史决策和未完成 TODO。
|
|
19
|
+
|
|
20
|
+
`pi-memory` 补的是这条链路:
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
值得记住的事实 -> 本地 Markdown 记忆 -> 未来 turn 的私有上下文
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
它提供:
|
|
27
|
+
|
|
28
|
+
- ✍️ 用 `/remember` 保存明确要记住的内容。
|
|
29
|
+
- 🔁 从 Pi compaction 中带出长期事实。
|
|
30
|
+
- 📥 从短 session 或漏处理 session 中补捞有用信息。
|
|
31
|
+
- 🔦 在每次回答前自动召回相关记忆,并作为私有上下文注入。
|
|
32
|
+
- 🛡️ 在保存记忆前脱敏常见 secret 和 token。
|
|
33
|
+
- 📄 用 Markdown 保存可审查、可编辑的记忆。
|
|
34
|
+
- ☂️ 召回不可用时优雅降级,不打断 Pi 正常工作。
|
|
35
|
+
- ⏳ 把较重的清理和整理放到离线维护任务中。
|
|
36
|
+
|
|
37
|
+
## 🚀 0.3.0 新增内容
|
|
38
|
+
|
|
39
|
+
- **更安全的记忆写入**:常见 API key、Bearer token、私钥、service account JSON、连接串和 `.env` 风格 secret 会在保存前被脱敏。
|
|
40
|
+
- **更可靠的召回体验**:Pi turn 被取消时,记忆召回也会一起取消,不再等内部 timeout。
|
|
41
|
+
- **更清晰的状态与维护输出**:`/memory-status`、`pi-memory status`、queue drain 和 reindex 触发使用更一致的统计。
|
|
42
|
+
- **面向后续版本的更健康基础**:内部实现被简化并拆成更小的模块。这主要是维护者视角的变化,但能降低后续功能迭代风险。
|
|
43
|
+
|
|
44
|
+
## 📦 安装与启用
|
|
45
|
+
|
|
46
|
+
要求:
|
|
47
|
+
|
|
48
|
+
- Node.js `>=24 <25`
|
|
49
|
+
- pnpm
|
|
50
|
+
- Pi 提供的 extension runtime packages
|
|
51
|
+
|
|
52
|
+
通过 Pi 安装:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pi install npm:@chendpoc/pi-memory
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
从本仓库本地开发:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pnpm install
|
|
62
|
+
pnpm build
|
|
63
|
+
pnpm typecheck
|
|
64
|
+
pnpm test
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
通过 Pi 的 extension 加载机制启用。本包声明:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"pi": {
|
|
72
|
+
"extensions": ["./dist/pi-extension.js"]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
发布的 npm 包自带编译后的 `dist/`;`pi install npm:@chendpoc/pi-memory` 会直接加载编译产物。
|
|
78
|
+
|
|
79
|
+
### 🌱 记忆工作区(自动初始化)
|
|
80
|
+
|
|
81
|
+
**大多数用户不需要手动运行 `pi-memory init`。** 记忆工作区会自动准备好,且**不会覆盖非空的 `MEMORY.md`**:
|
|
82
|
+
|
|
83
|
+
| 时机 | 行为 |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| **`pnpm install`** | `postinstall` 执行 `pi-memory init`(或 pre-build 回退脚本) |
|
|
86
|
+
| **首次 Pi session** | Pi 检查或创建记忆工作区 |
|
|
87
|
+
| **手动(可选)** | `pi-memory init` |
|
|
88
|
+
|
|
89
|
+
仅在以下情况需要显式运行 `pi-memory init`:
|
|
90
|
+
|
|
91
|
+
- 安装**之后**才设置 **`PI_MEMORY_AGENT_DIR`**(postinstall 可能已按默认路径初始化)。
|
|
92
|
+
- 安装脚本被跳过(`--ignore-scripts` 或企业策略)。
|
|
93
|
+
- 想在打开 Pi 之前先 bootstrap,或配合 `pi-memory status` 做排查。
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pi-memory init # 可选;见上文
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## ✨ 为什么选择 `pi-memory`
|
|
100
|
+
|
|
101
|
+
### 🔄 Agent 使用前后差异
|
|
102
|
+
|
|
103
|
+
| 场景 | 未使用 `pi-memory` | 使用 `pi-memory` 后 |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| 新 session 问“继续上次计划” | Agent 只能追问上下文,或基于当前仓库猜测。 | Preflight 召回匹配的 `MEMORY.md` 事实并注入私有参考上下文。 |
|
|
106
|
+
| 用户说“记住这个 repo 用 Vitest” | 事实可能只留在当前 session 摘要里。 | `/remember` 写入 `[user]` 条目,consolidate 必须保留。 |
|
|
107
|
+
| 长 session 触发压缩 | Compaction 只帮助当前 session 续聊,不必然产生跨 session 事实。 | 一次 dual-purpose summary 同时保留当前上下文并导出长期事实。 |
|
|
108
|
+
| 启动 subagent | 可能继承过多上下文,或重复父 session 的记忆写入。 | Subagent 默认使用更小的记忆视图,减少噪声和重复写入。 |
|
|
109
|
+
| 记忆召回不可用 | 如果是硬依赖,会直接影响对话。 | Pi 回退到 Markdown 或空注入,主模型照常运行。 |
|
|
110
|
+
| 记忆持续增长 | 文件容易变成无边界流水账。 | `MEMORY.md` 150 行上限,`auto-*.md` 溢出,consolidate 合并去重。 |
|
|
111
|
+
|
|
112
|
+
### 🌟 核心优势
|
|
113
|
+
|
|
114
|
+
- 📓 **可审计的记忆**:`MEMORY.md` 和 `auto-*.md` 可以直接打开、审查、编辑、grep、复制或纳入版本控制。
|
|
115
|
+
- 🔎 **回答前自动带上上下文**:Pi 在主模型回答前拿到相关私有记忆,不需要你手动粘贴旧上下文。
|
|
116
|
+
- 🔒 **用户显式记忆受保护**:`/remember` 写入的条目会标记为用户创建,consolidate 必须保留。
|
|
117
|
+
- 🛡️ **默认更安全**:常见 secret 和 token 会在进入长期记忆前被替换。
|
|
118
|
+
- ☂️ **召回不是硬依赖**:召回为空、变慢或不可用时,当前 turn 仍然继续。
|
|
119
|
+
- 💤 **减少交互打扰**:较重的整理和清理通过 maintenance 任务执行,不阻塞普通 Pi turn。
|
|
120
|
+
- 🧹 **控制记忆增长**:主记忆文件有行数上限,溢出进入可审查文件,consolidate 合并重复内容。
|
|
121
|
+
- 👥 **理解 subagent 场景**:root session 使用更完整召回;subagent 默认使用更小的记忆视图,减少噪声。
|
|
122
|
+
|
|
123
|
+
### ⚖️ 对比
|
|
124
|
+
|
|
125
|
+
`pi-memory` 不试图成为所有 memory 系统的集合。它的价值是一个 Pi-native 闭环:本地 Markdown 记忆、回答前私有召回、compaction export 和离线 maintenance。
|
|
126
|
+
|
|
127
|
+
| 系统 | 优势 | 与 `@chendpoc/pi-memory` 的差异 |
|
|
128
|
+
| --- | --- | --- |
|
|
129
|
+
| Cursor Rules / OpenCode `AGENTS.md` | 静态项目指令,注入行为可预测。 | 主要是用户手写规则,没有自动长期事实提取,也没有每轮回答前的记忆召回。 |
|
|
130
|
+
| Claude Code Auto Memory | Agent 可以写本地记忆文件。 | 也是文件记忆,但没有 Pi 的 compaction/shutdown 集成,也没有回答前私有召回闭环。 |
|
|
131
|
+
| `pi-hermes-memory` | 功能丰富,有 FTS5、失败记忆、纠正学习、安全扫描。 | 自动化更重;`pi-memory` 更窄,更强调 Markdown-first 和回答前私有召回。 |
|
|
132
|
+
| OpenClaw memory-core | 成熟的文件+索引设计,有 dreaming、混合搜索、本地 embedding。 | OpenClaw 是更大的 memory 平台;`pi-memory` 更窄,聚焦 Pi extension。 |
|
|
133
|
+
| Mem0 / Zep | 托管 memory API,有混合搜索、图和时序建模。 | 检索基础设施更强,但更偏外部服务/数据库,不以 Markdown 事实源为第一原则。 |
|
|
134
|
+
| Letta | 上下文工程,git-backed memory repo 和 sleep-time compute。 | 自主记忆管理更强,但心智模型比 Pi extension lifecycle 更重。 |
|
|
135
|
+
| Cognee | 知识引擎,图/向量/关系存储和多种检索模式。 | 更适合知识图谱;对轻量编码 agent 偏好/约定来说偏重。 |
|
|
136
|
+
|
|
137
|
+
其他系统更强的地方:
|
|
138
|
+
|
|
139
|
+
- `pi-hermes-memory`:失败记忆、纠正检测、工具怪癖、安全扫描。
|
|
140
|
+
- OpenClaw:dreaming 阶段、memory wiki、FTS/vector 混合搜索、本地 embedding provider。
|
|
141
|
+
- Zep/Cognee:时序图推理和多跳图检索。
|
|
142
|
+
- Mem0:托管多租户 memory API。
|
|
143
|
+
- Letta:自主 context repository 和 sleep-time memory work。
|
|
144
|
+
|
|
145
|
+
## ⚙️ 工作方式
|
|
146
|
+
|
|
147
|
+
### ⚙️ 技术说明
|
|
148
|
+
|
|
149
|
+
这些选择主要面向运维和贡献者,用来说明用户看到的“本地、可审查、有边界”的行为是如何实现的。
|
|
150
|
+
|
|
151
|
+
| 选择 | 为什么重要 |
|
|
152
|
+
| --- | --- |
|
|
153
|
+
| `MEMORY.md` 作为 Ground Truth | 长期记忆保持可审查、可编辑,而不是变成不透明数据库状态。 |
|
|
154
|
+
| 基于 `node:net` 的 UDS JSONL | IPC 只在本机发生,避免 HTTP 端口,同时保持简单的 request/response frame。 |
|
|
155
|
+
| spawn 独立 sidecar 进程 | 向量 query/reindex 与 Pi extension 进程隔离;失败时可降级到 Markdown fallback。 |
|
|
156
|
+
| 离线 `maintenance` job | consolidate 和 shutdown-queue drain 可以在交互 turn 之外执行。 |
|
|
157
|
+
| 有预算的 Preflight | QueryIntent、sidecar query、cache 和 fallback 都在明确延迟边界内运行。 |
|
|
158
|
+
|
|
159
|
+
### 🏗️ 架构
|
|
160
|
+
|
|
161
|
+
```text
|
|
162
|
+
Pi 扩展进程(MemoryRuntime)
|
|
163
|
+
|- session_start
|
|
164
|
+
| |- 初始化 MEMORY.md
|
|
165
|
+
| |- 启动/warm sidecar
|
|
166
|
+
| |- 重建派生向量索引
|
|
167
|
+
| `- 预加载 Memory Cap
|
|
168
|
+
|
|
|
169
|
+
|- before_agent_start / context
|
|
170
|
+
| `- Preflight recall(AbortSignal 感知 sidecar query)-> <private_memory> 注入
|
|
171
|
+
|
|
|
172
|
+
|- /remember
|
|
173
|
+
| `- 追加 [user] Memory Entry
|
|
174
|
+
|
|
|
175
|
+
|- session_before_compact / session_compact
|
|
176
|
+
| `- dual-purpose summary -> Memory Export ingest
|
|
177
|
+
|
|
|
178
|
+
|- session_shutdown
|
|
179
|
+
| `- 只追加 shutdown 元数据
|
|
180
|
+
|
|
|
181
|
+
`- consolidate scheduler
|
|
182
|
+
`- 合并/去重 -> 重写 Ground Truth -> reindex
|
|
183
|
+
|
|
184
|
+
通过 UDS JSONL 通信的 Sidecar 进程(`node:net`,不走 HTTP 端口)
|
|
185
|
+
|- ping
|
|
186
|
+
|- stats
|
|
187
|
+
|- query: embed -> cosine scan -> MMR
|
|
188
|
+
`- reindex: upsert chunks into memory.vec.sqlite
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### 🔎 读取路径
|
|
192
|
+
|
|
193
|
+
Root session:
|
|
194
|
+
|
|
195
|
+
```text
|
|
196
|
+
来自 Ground Truth 的 Memory Cap
|
|
197
|
+
+ 当前用户消息的 Episodic Preflight
|
|
198
|
+
-> 合并为 <private_memory>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Subagent session:
|
|
202
|
+
|
|
203
|
+
```text
|
|
204
|
+
只使用 Memory Cap
|
|
205
|
+
-> 默认不跑 episodic QueryIntent / sidecar query
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
回退链:
|
|
209
|
+
|
|
210
|
+
```text
|
|
211
|
+
Sidecar 结果
|
|
212
|
+
-> 空结果、错误或超时:回退到 MEMORY.md
|
|
213
|
+
-> 仍为空:不注入
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### ✍️ 写入路径
|
|
217
|
+
|
|
218
|
+
| 路径 | 触发 | LLM? | 是否阻塞 | 目的 |
|
|
219
|
+
| --- | --- | --- | --- | --- |
|
|
220
|
+
| `/remember` | 用户命令 | 否 | 是 | 显式长期记忆 |
|
|
221
|
+
| Compaction | `session_before_compact` + `session_compact` | 一次摘要调用 | 摘要阻塞,入库后台执行 | 当前 session 续聊 + 导出长期事实 |
|
|
222
|
+
| Shutdown Queue | `session_shutdown` + `pi-memory maintenance` | 仅离线且无 compaction summary 时 | shutdown 时不阻塞 | 补捞短 session 或漏处理事实 |
|
|
223
|
+
| Consolidate | overflow >= 12、7 天或每日 cron | 可选 | 离线或后台 | 去重、合并、清理过期 TODO |
|
|
224
|
+
|
|
225
|
+
### 🛡️ 脱敏覆盖范围
|
|
226
|
+
|
|
227
|
+
`pi-memory` 0.3.0 会在长期记忆写入前脱敏疑似 secret。所有能持久化到 `MEMORY.md`、`auto-*.md` 或派生向量索引的增量写入路径都会应用这个规则。
|
|
228
|
+
|
|
229
|
+
覆盖的写入路径:
|
|
230
|
+
|
|
231
|
+
- `/remember`
|
|
232
|
+
- `append` / `appendUser` / `appendIfAbsent` / `appendMany`
|
|
233
|
+
- compaction `Memory Export` ingest
|
|
234
|
+
- shutdown queue drain ingest
|
|
235
|
+
|
|
236
|
+
当前 MVP 聚焦 **secret 和 token**,包括常见 API key、Bearer/JWT、私钥块、service account JSON、连接串、Basic Auth URL 和 `.env` 风格的 secret 赋值。命中内容会替换为 `[REDACTED]`;如果脱敏后没有有意义内容,该条 memory 会被跳过,而不是写入一个孤立占位符。
|
|
237
|
+
|
|
238
|
+
当前边界:
|
|
239
|
+
|
|
240
|
+
- 脱敏作用于**长期记忆条目**,不扫描完整 Pi session JSONL 或 LLM 请求体。
|
|
241
|
+
- 已存在的历史 `MEMORY.md` 内容不会被自动重写。
|
|
242
|
+
- 0.3.0 暂不做 PII 检测。
|
|
243
|
+
- Debug 日志只记录命中数量和 policy version,不打印命中的 secret 原文。
|
|
244
|
+
|
|
245
|
+
对贡献者来说,共用写入闸口是 `prepareEntryForWrite`。
|
|
246
|
+
|
|
247
|
+
## 💾 数据和 MEMORY.md 格式
|
|
248
|
+
|
|
249
|
+
所有产物都放在同一个 memory agent directory 下。
|
|
250
|
+
|
|
251
|
+
解析顺序:
|
|
252
|
+
|
|
253
|
+
1. `--agent-dir` CLI flag
|
|
254
|
+
2. `PI_MEMORY_AGENT_DIR`
|
|
255
|
+
3. 默认 `~/.pi/pi-memory-data`
|
|
256
|
+
|
|
257
|
+
| 文件 | 作用 |
|
|
258
|
+
| --- | --- |
|
|
259
|
+
| `MEMORY.md` | 事实源文件 |
|
|
260
|
+
| `auto-*.md` | 150 行上限后的溢出文件 |
|
|
261
|
+
| `.memory_gc` | 上次 consolidate 时间 |
|
|
262
|
+
| `.memory_compactions.json` | compaction 幂等状态 |
|
|
263
|
+
| `.memory_shutdown_queue.jsonl` | append-only shutdown 元数据 |
|
|
264
|
+
| `.memory_shutdown_processed.json` | drain 幂等状态 |
|
|
265
|
+
| `memory.vec.sqlite` | 派生向量索引 |
|
|
266
|
+
| `memory.sock` | Sidecar UDS socket |
|
|
267
|
+
| `logs/maintenance.log` | 定时 `maintenance --cron` 的 stdout 日志 |
|
|
268
|
+
| `logs/maintenance.err.log` | 定时 maintenance 的 stderr 日志(launchd / Windows) |
|
|
269
|
+
|
|
270
|
+
`logs/` 会在 **extension `session_start`**、`pi-memory init`、或 CLI `maintenance`/`consolidate` 时自动创建,无需手动 `mkdir`。
|
|
271
|
+
|
|
272
|
+
标准模板:[`templates/MEMORY.md.example`](../templates/MEMORY.md.example)
|
|
273
|
+
|
|
274
|
+
```markdown
|
|
275
|
+
# Memory
|
|
276
|
+
|
|
277
|
+
## Preferences
|
|
278
|
+
|
|
279
|
+
## Conventions
|
|
280
|
+
|
|
281
|
+
## Findings
|
|
282
|
+
|
|
283
|
+
## Todos
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
每条记忆是一个 Markdown bullet:
|
|
287
|
+
|
|
288
|
+
```markdown
|
|
289
|
+
- [user] Prefer pnpm over npm <!-- id:abc123 user ts:2026-07-04T09:00:00.000+08:00 -->
|
|
290
|
+
- Project tests use Vitest <!-- id:def456 ts:2026-07-04T09:05:00.000+08:00 -->
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
规则:
|
|
294
|
+
|
|
295
|
+
- `/remember` 写入 `[user]` 条目。
|
|
296
|
+
- Consolidate 不能删除或改写 `[user]` 条目。
|
|
297
|
+
- `MEMORY.md` 上限为 150 行。
|
|
298
|
+
- 溢出条目写入 `auto-*.md`,并在 `MEMORY.md` 留指针。
|
|
299
|
+
- 向量 chunk 从条目派生;默认超过 `PI_MEMORY_CHUNK_MAX_CHARS=512` 的长条目会拆分。
|
|
300
|
+
|
|
301
|
+
## 🎛️ 配置
|
|
302
|
+
|
|
303
|
+
可选 env 文件按以下顺序加载:
|
|
304
|
+
|
|
305
|
+
1. `PI_MEMORY_ENV_FILE`
|
|
306
|
+
2. 项目 `.env`
|
|
307
|
+
3. 项目 `.env.local`
|
|
308
|
+
4. `~/.pi/agent/pi-memory.env`
|
|
309
|
+
|
|
310
|
+
常用变量:
|
|
311
|
+
|
|
312
|
+
| 变量 | 默认 | 用途 |
|
|
313
|
+
| --- | --- | --- |
|
|
314
|
+
| `PI_MEMORY_AGENT_DIR` | `~/.pi/pi-memory-data` | 记忆数据根目录 |
|
|
315
|
+
| `PI_MEMORY_EMBEDDER` | `hash` | 支持 `hash`、`ollama`、`openai` |
|
|
316
|
+
| `PI_MEMORY_HELPER_MODEL` | `deepseek/deepseek-v4-flash` | QueryIntent 和 consolidate 使用的辅助模型 |
|
|
317
|
+
| `PI_MEMORY_PREFLIGHT_BUDGET_MS` | `800` | Preflight 共享预算,限制在 250-1500ms |
|
|
318
|
+
| `PI_MEMORY_INTENT_RETRIES` | `0` | 首次尝试后的 helper LLM 重试次数 |
|
|
319
|
+
| `PI_MEMORY_WARM_SIDECAR` | `1` | 在 `session_start` warm sidecar |
|
|
320
|
+
| `PI_MEMORY_INTENT_CACHE` | `1` | session 级 QueryIntent 缓存 |
|
|
321
|
+
| `PI_MEMORY_REINDEX_DEBOUNCE_MS` | `500` | 写入后的 sidecar reindex debounce |
|
|
322
|
+
| `PI_MEMORY_TOP_K` | `3` | 向量召回条数 |
|
|
323
|
+
| `PI_MEMORY_MMR_LAMBDA` | `0.8` | MMR 相关性与多样性权重 |
|
|
324
|
+
| `PI_MEMORY_MIN_RELEVANCE` | `0.4` | 最小 cosine similarity |
|
|
325
|
+
| `PI_MEMORY_CHUNK_MAX_CHARS` | `512` | 索引长条目拆分阈值;`0` 表示关闭 |
|
|
326
|
+
| `PI_MEMORY_DEBUG` | 未设置 | `1` 打印 debug timing logs |
|
|
327
|
+
| `PI_MEMORY_SKIP_SCHEDULER_SYNC` | 未设置 | 设置为 `1` 时跳过 scheduler sync,包括自动 sync 和手动 `scheduler sync` |
|
|
328
|
+
|
|
329
|
+
完整列表见 [`.env.example`](../.env.example)。
|
|
330
|
+
|
|
331
|
+
### 🛰️ Embedding Provider
|
|
332
|
+
|
|
333
|
+
| Embedder | 适用场景 | 说明 |
|
|
334
|
+
| --- | --- | --- |
|
|
335
|
+
| `hash` | 零配置本地开发 | 离线、确定性、语义质量较低 |
|
|
336
|
+
| `ollama` | 本地语义 embedding | 使用 `PI_MEMORY_OLLAMA_BASE_URL` 和 `PI_MEMORY_OLLAMA_EMBED_MODEL` |
|
|
337
|
+
| `openai` | 更高质量云端 embedding | 需要 `PI_MEMORY_OPENAI_API_KEY` 或 `OPENAI_API_KEY` |
|
|
338
|
+
|
|
339
|
+
Vector Index 会保存 embedding provider、model 和 dimension 元数据。配置变化时会清空旧 chunks 并重建。
|
|
340
|
+
|
|
341
|
+
## ⌨️ 命令
|
|
342
|
+
|
|
343
|
+
Pi 内部:
|
|
344
|
+
|
|
345
|
+
```text
|
|
346
|
+
/remember [section] <content>
|
|
347
|
+
/memory-status [refresh|expand|collapse|hide]
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
CLI:
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
pi-memory status
|
|
354
|
+
pi-memory maintenance --cron --verbose
|
|
355
|
+
pi-memory consolidate --force --verbose
|
|
356
|
+
pi-memory drain-shutdown-queue --verbose
|
|
357
|
+
pi-memory init # 可选 — 安装后 + 首次 session 通常已自动完成
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
`maintenance` 是推荐的调度入口:
|
|
361
|
+
|
|
362
|
+
```text
|
|
363
|
+
consolidate -> drain-shutdown-queue
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**macOS launchd 会自动管理**:`postinstall`、`pi-memory init`、以及 Pi **每次 `session_start`** 都会 best-effort 调用 `scheduler sync`(失败不影响安装或会话),写入 `~/Library/LaunchAgents/com.pi.memory.maintenance.plist`,并移除旧 label(如 `dev.pi.memory-consolidate`)。一般无需手动改 plist。
|
|
367
|
+
|
|
368
|
+
手动触发或排查:
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
pi-memory scheduler sync --verbose
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
如果环境里设置了 `PI_MEMORY_SKIP_SCHEDULER_SYNC=1`,手动 sync 前需要先取消该变量。
|
|
375
|
+
|
|
376
|
+
Linux / Windows 仍参考模板手动安装:
|
|
377
|
+
|
|
378
|
+
- [`templates/crontab.example`](../templates/crontab.example)
|
|
379
|
+
- [`templates/consolidate.cmd.example`](../templates/consolidate.cmd.example)
|
|
380
|
+
- [`templates/schtasks.example.txt`](../templates/schtasks.example.txt)
|
|
381
|
+
|
|
382
|
+
macOS 参考 plist(内容与自动生成一致):
|
|
383
|
+
|
|
384
|
+
- [`templates/com.pi.memory.consolidate.plist.example`](../templates/com.pi.memory.consolidate.plist.example)
|
|
385
|
+
|
|
386
|
+
## 🩺 诊断
|
|
387
|
+
|
|
388
|
+
使用 `/memory-status` 或 `pi-memory status` 检查:
|
|
389
|
+
|
|
390
|
+
- memory agent 目录
|
|
391
|
+
- `MEMORY.md` 行数
|
|
392
|
+
- 条目数
|
|
393
|
+
- overflow 文件数
|
|
394
|
+
- 上次 consolidate 时间
|
|
395
|
+
- sidecar socket 状态
|
|
396
|
+
- vector index generation 和 chunk 数
|
|
397
|
+
- 当前配置的 embedder
|
|
398
|
+
- 索引 embedder 是否与当前配置不一致
|
|
399
|
+
|
|
400
|
+
设置 `PI_MEMORY_DEBUG=1` 可打印 Preflight timing 日志:
|
|
401
|
+
|
|
402
|
+
```json
|
|
403
|
+
{
|
|
404
|
+
"phase": "preflight",
|
|
405
|
+
"event": "recall",
|
|
406
|
+
"intent_ms": 0,
|
|
407
|
+
"intent_skipped": true,
|
|
408
|
+
"intent_cache_hit": false,
|
|
409
|
+
"sidecar_ms": 42,
|
|
410
|
+
"cache_hit": true,
|
|
411
|
+
"total_ms": 45,
|
|
412
|
+
"fallback": false,
|
|
413
|
+
"results": 3
|
|
414
|
+
}
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
## 🚫 非目标
|
|
418
|
+
|
|
419
|
+
- 不替代 Pi compaction。
|
|
420
|
+
- 不替代 session search;历史对话搜索应使用专门的 session-search 扩展。
|
|
421
|
+
- 不在本包内维护图数据库。
|
|
422
|
+
- 不让 sidecar 成为事实源。
|
|
423
|
+
- 不把完整聊天记录当作 memory 存储。
|
|
424
|
+
- 不给每轮用户消息增加多秒级 reflection。
|
|
425
|
+
|
|
426
|
+
## 🛠️ 开发
|
|
427
|
+
|
|
428
|
+
```bash
|
|
429
|
+
pnpm typecheck
|
|
430
|
+
pnpm test
|
|
431
|
+
pnpm build
|
|
432
|
+
```
|
|
433
|
+
|
|
434
|
+
sidecar IPC 测试会打开 Unix domain socket。如果在受限沙盒中因为 `listen EPERM` 失败,请在正常本地 shell 中运行。
|
|
435
|
+
|
|
436
|
+
## 📚 文档
|
|
437
|
+
|
|
438
|
+
- [English README](../README.md)
|
|
439
|
+
- [路线图](./ROADMAP-zh.md)
|
|
440
|
+
- [架构 refactor 计划](../dev-doc/architecture-refactor-plan.md)
|
|
441
|
+
- [UBIQUITOUS_LANGUAGE.md](../UBIQUITOUS_LANGUAGE.md) - 领域术语表
|
|
442
|
+
|
|
443
|
+
## 📜 许可证
|
|
444
|
+
|
|
445
|
+
MIT
|