@aeondave/pi-persona-mind 0.0.0-stage → 0.8.4

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.
Files changed (43) hide show
  1. package/AGENTS.md +78 -0
  2. package/CHANGELOG.md +78 -0
  3. package/LICENSE +24 -0
  4. package/README.md +244 -2
  5. package/assets/banner.png +0 -0
  6. package/docs/DESIGN.md +282 -0
  7. package/docs/MEMORY-RESEARCH.md +112 -0
  8. package/package.json +93 -4
  9. package/src/core/auto-optimize.ts +239 -0
  10. package/src/core/backlog.ts +228 -0
  11. package/src/core/blocked.ts +38 -0
  12. package/src/core/capture.ts +146 -0
  13. package/src/core/context-budget.ts +74 -0
  14. package/src/core/host-compat.ts +13 -0
  15. package/src/core/ids.ts +59 -0
  16. package/src/core/inject.ts +247 -0
  17. package/src/core/memory-read.ts +34 -0
  18. package/src/core/memory.ts +308 -0
  19. package/src/core/migrate.ts +713 -0
  20. package/src/core/mind-settings.ts +54 -0
  21. package/src/core/optimize-history.ts +101 -0
  22. package/src/core/optimize-service.ts +182 -0
  23. package/src/core/optimize.ts +133 -0
  24. package/src/core/retrieval.ts +108 -0
  25. package/src/core/scanner.ts +146 -0
  26. package/src/core/scope.ts +205 -0
  27. package/src/core/service.ts +644 -0
  28. package/src/core/session-memory.ts +71 -0
  29. package/src/core/store.ts +948 -0
  30. package/src/extension/activity.ts +79 -0
  31. package/src/extension/auto-optimize-session.ts +118 -0
  32. package/src/extension/auto-optimize.ts +265 -0
  33. package/src/extension/mind-command.ts +335 -0
  34. package/src/extension/mind-worker.ts +32 -0
  35. package/src/extension/persona-dependency.ts +76 -0
  36. package/src/index.ts +1231 -0
  37. package/src/session-memory.ts +118 -0
  38. package/src/tools/backlog.ts +126 -0
  39. package/src/tools/memory-optimize.ts +133 -0
  40. package/src/tools/memory.ts +400 -0
  41. package/src/ui/mind-result-card.ts +15 -0
  42. package/src/ui/presentation.ts +97 -0
  43. package/src/ui/session-note-card.ts +50 -0
package/docs/DESIGN.md ADDED
@@ -0,0 +1,282 @@
1
+ # pi-persona-mind — current design
2
+
3
+ This is the binding implementation contract. Release history belongs in [CHANGELOG](../CHANGELOG.md);
4
+ the user workflow is in [README](../README.md). Evidence behind consolidation decisions is in
5
+ [MEMORY-RESEARCH](MEMORY-RESEARCH.md).
6
+
7
+ ## Host and module boundaries
8
+
9
+ Target the latest stable Pi only, currently 1.4.0, and Node >=22.19. All four development Pi packages
10
+ are pinned together; runtime host/typebox packages remain optional wildcard peers. No second host
11
+ runtime or historical hook-shape adapter is bundled. A development-only security override does not
12
+ patch an installed host.
13
+
14
+ Mind requires a loaded compatible pi-persona through its versioned local companion handshake.
15
+ Missing/incompatible presence leaves tools inactive and suppresses capture, storage/import,
16
+ injection and reminders. A settings file or installed npm package is not proof of an active
17
+ companion. Mind 0.8.4 requires Persona 1.17.5 or later for these paired contracts. Its optional npm
18
+ peer declares that requirement without auto-installing or activating another extension.
19
+
20
+ The node-only core has no Pi imports. The factory wires native Pi hooks, tools, scope, scheduling
21
+ and lifecycle owners. Session persistence uses Pi's public SessionManager and appendEntry contracts.
22
+ Command parsing/presentation lives outside the factory. Important seams:
23
+
24
+ | Module | Responsibility |
25
+ |---|---|
26
+ | core/service.ts | Scope-bound memory/backlog operations, mutation ordering |
27
+ | core/store.ts | Atomic writes, exclusive ownership, recovery, strict snapshots and CAS |
28
+ | core/memory.ts, backlog.ts | Validated facts and deferred-work state |
29
+ | core/scope.ts, mind-settings.ts | Project identity, safe paths and canonical Mind preferences |
30
+ | extension/persona-dependency.ts | Loaded capability and actual memory-owner contracts |
31
+ | core/migrate.ts | Bounded, non-destructive import of previous memory layouts |
32
+ | core/session-memory.ts, session-memory.ts | Session event validation/replay and native owner adapter |
33
+ | core/optimize.ts, optimize-service.ts | Pure consolidation rules and short-lived staged plans |
34
+ | core/optimize-history.ts | Bounded durable before images and conflict-checked undo |
35
+ | core/retrieval.ts, context-budget.ts | Explainable task ranking and shared context estimate |
36
+ | core/memory-read.ts | Full explicit retrieval without clipped discovery or recovery writes |
37
+ | tools/memory.ts, memory-optimize.ts | Model-facing action validation and result formatting |
38
+ | extension/mind-command.ts | One command handler for persona-mind and mind |
39
+ | ui/ | Sanitized compact cards, full expansion and native custom-entry renderers |
40
+
41
+ ## Four lifetimes
42
+
43
+ - **Durable facts:** persona-private LTM, explicit shared LTM and repository-scoped project LTM.
44
+ Never expire automatically. Project facts remain repository-bound across persona changes.
45
+ - **Working project facts:** STM with persona attribution; 48-hour default TTL. Project injection can include
46
+ other personas' observations, but optimizer mutations require the current persona's ownership.
47
+ - **Session notes:** native custom entries on the active branch, including source session identity.
48
+ - **Deferred intent:** project backlog, open/taken/done/dropped. Default expiry is 48 hours; a later
49
+ reminder extends it. A repeated take is idempotent; re-add does not reopen completed work.
50
+
51
+ LTM/STM facts have content identity based on kind, text and sorted tags; provenance is excluded.
52
+ Exact re-recording updates identical normalized content (not semantic equivalence). lastSeenAt tracks recording/promotion, not
53
+ recall frequency. Read operations do not boost ranking or reset expiry. An objective is durable
54
+ in the ordinary store; an explicitly session-scoped objective remains in that session.
55
+
56
+ Supersession retires an active row. derivedFrom stores bounded IDs. Optimizer before images provide
57
+ bounded recoverability; ordinary supersession/forget are not a temporal database or unlimited undo.
58
+ Promotion defaults to project LTM and requires an owned live STM source; persona/shared destinations
59
+ must be explicit. Existing persona facts are never reassigned to guessed projects. Promotion removes
60
+ only its exact source row; equal-text observations from another owner retain their provenance.
61
+
62
+ ## Scope and companion integration
63
+
64
+ The active persona comes only from pi-persona:memory-owner:v1, a synchronous query bound to the
65
+ native session ID. Its response identifies the loaded provider, readiness and actual persona (or
66
+ null for no persona). pi-persona:memory-owner-changed:v1 broadcasts readiness and selection changes.
67
+ Before Persona finishes startup, Mind returns without memory IO; it must not await a later extension's
68
+ session_start. Missing, ambiguous or stale owners refuse access. Saved selection and CLI flags are
69
+ not substitutes for the runtime owner, including when Persona persistence is disabled.
70
+
71
+ Mind capture/nudge preferences are session snapshots from canonical
72
+ <agentDir>/persona/settings.json. The retired state.json and PI_PERSONA_STATE_FILE are not runtime
73
+ sources; Persona owns its settings migration. Contribute effective Mind preferences through
74
+ pi-persona:settings:collect:v1; never edit companion settings or start another service.
75
+
76
+ Use the canonical project path and collision-safe persona scope names. Reserved shared/default
77
+ names, lossy Unicode conversions and Windows device names must not merge unrelated personas.
78
+ Home is not a project: skip project injection and reminders there.
79
+
80
+ A delegated leg is sampled at factory activation through PI_PERSONA_LEG / PI_PERSONA_CHILD.
81
+ PI_PERSONA_DISABLE alone does not designate a worker. Workers get lean objective/LTM injection,
82
+ no project/session notes, no memory/backlog tools and no reminders. Both Persona engines freeze the
83
+ launching persona. In-process workers receive it through their own extension bus; child processes
84
+ receive a scrubbed spawn-local payload. A later parent selection cannot move a worker's memory scope.
85
+
86
+ Intercom/Exocom and worker output stay foreign reference material, not automatic capture requests.
87
+ Only the reserved pi-persona-deferred-input custom type replays direct user input. This is a
88
+ trusted-extension convention, not authentication against other code running in the same process.
89
+ Do not read Persona's private result archive. The supervisor explicitly retrieves a report through
90
+ Intercom before curating a fact. A saved ref remains an opaque source string, not a cross-session grant.
91
+
92
+ ## Session notes
93
+
94
+ Version-1 save/forget events live under pi-persona-mind-session-note. Reads replay only the active
95
+ branch; all session events count toward the lifetime budget. Branching/forking follows native Pi
96
+ history; new sessions do not inherit notes. Forked notes preserve originSessionId. A forget appends
97
+ a branch-local tombstone and does not erase previous transcript bytes.
98
+
99
+ Limits: 64 active notes, 8,000 text characters per note, 1,000 source characters, 256 lifetime events,
100
+ 512 KiB encoded event data. Unknown versions, unsafe history or exceeded bounds fail closed.
101
+ Admission and replay both scan content. No append occurs after owner revocation; owner identity
102
+ includes the native manager, session ID and file. No asynchronous gap separates validation and append.
103
+
104
+ Receipts distinguish session storage from memory-only storage; Pi controls disk flushing.
105
+ Injection is reference data, escaped and bounded to a 600-token planning estimate (UTF-8 bytes / 3)
106
+ with excerpts of at most 700 characters. It shares the total memory budget. Current task matching
107
+ precedes recency, with objective priority. Omitted entries and clipping are disclosed. Explicit read returns the whole note.
108
+ An in-memory session is not advertised as restart-durable.
109
+
110
+ ## Explicit consolidation
111
+
112
+ The explicit workflow is inspect → stage exact replacements → apply plan ID. An omitted replacement tag
113
+ list inherits the normalized union from selected sources; an explicit empty list clears tags. Lexical
114
+ rules never approve semantic changes. Learned decay rates, recall counters and age-based LTM deletion
115
+ remain outside the contract.
116
+
117
+ Inspection reads a strict store snapshot without recovery/quarantine writes. It returns at most 100
118
+ safe entries (20 by default), an exact raw-byte fingerprint, omission counts and at most 12 lexical
119
+ candidate pairs. Similarity is advisory: negation can preserve nearly all words while reversing meaning.
120
+ Inspection exposes offset/matched/nextOffset so old facts remain reachable in bounded pages;
121
+ fingerprint changes invalidate a paginated inspection's snapshot. Pairs compare one page only.
122
+ The foreground agent must inspect full text and current evidence before proposing replacements.
123
+
124
+ Each plan affects one store: `project` STM, `project-long` durable repository memory, persona LTM,
125
+ or shared LTM. Both project tiers require the current persona's ownership. One source rewrites a fact;
126
+ multiple sources consolidate facts. Explicit deletion remains memory forget. Operations specify exact
127
+ persisted source IDs; ambiguous/overlapping IDs, unsafe content, mixed ownership, replacement collisions,
128
+ expired sources, malformed stores and provenance overflow refuse the plan.
129
+
130
+ A replacement keeps earliest recording time, all bounded source origins and lineage. Project replacements
131
+ keep the earliest source expiry; consolidation cannot revive or extend stale working context.
132
+ Unselected entries are preserved. No capacity-enforcing truncation is allowed.
133
+
134
+ At most four plans per session/scope owner, ten-minute lifetime. Preview is immutable to callers.
135
+ Apply rechecks raw-byte fingerprint, lifetime, source expiry and owner invalidation under the store lock
136
+ and Mind's mutation lock. Even a same-sequence external file replacement invalidates the fingerprint.
137
+ Concurrent apply cannot commit twice. Session/scope changes discard plans; applying never spawns a model.
138
+
139
+ Before replacement, persist a scoped before/after receipt to `<store>.optimize-history.json`, under
140
+ its transaction lock and the memory mutation lock. Maximum 32 receipts / 2 MiB per target, plus the
141
+ standard backup. Evict settled receipts only; refuse the replacement if unresolved prepared receipts
142
+ or the new receipt exceed capacity. A generic IO failure may occur after the memory rename, so its
143
+ receipt remains prepared with outcome uncertainty. Known pre-write conflicts/lifecycle refusals are
144
+ rejected. Finalization failure after a successful memory commit returns success with a warning.
145
+
146
+ History/undo survive optimizer recreation. History is bounded, owner-filtered and scanner-filtered.
147
+ Undo restores only exact affected facts, preserving unrelated current records; it refuses changed
148
+ replacements, source collisions, expired facts and owner revocation. Check the lifecycle generation
149
+ inside the store mutation callback. An ambiguous interrupted receipt is never presumed applied or
150
+ discarded; unresolved IO failures can require manual recovery. This is consolidation recovery,
151
+ not rollback of arbitrary user edits or a claim of semantic correctness.
152
+
153
+ These are authorization mechanics, not truth verification: an explicit memory tool call has the same
154
+ mutation authority as existing remember/forget. The runtime does not silently invent operator approval.
155
+ The full proposal is reviewable before application; no additional mandatory confirmation loop is added.
156
+
157
+ ## Automatic semantic review
158
+
159
+ The user-authorized automatic path uses the same validation and fingerprint-checked mutation boundary.
160
+ It is session-scoped, on by default unless `PI_PERSONA_MIND_OPTIMIZE=off`; `/mind optimize auto
161
+ [status|on|off]` reads or changes that session's setting. Off cancels running review and clears queued
162
+ targets/retry permissions; saves while off do not queue work. On waits for the next successful save.
163
+ Doctor reports the scheduler's current status. No persistent preference is silently written.
164
+
165
+ A successful remember/promotion marks its eligible tier dirty. The first eligible burst needs no
166
+ token minimum. Later attempts require dirty memories and 1,000,000 main-session input tokens since
167
+ the preceding actual launch; output, cache read/write and worker tokens are excluded. Usage alone
168
+ cannot dirty a tier. Rapid additions coalesce, and dirty tiers left after a review wait for the same
169
+ token gate rather than launching in a cleanup loop. Token counters restart at zero on activation;
170
+ the native session's attempt records preserve whether the first attempt already happened.
171
+ Requests coalesce for two seconds after native `agent_settled`, while idle and without queued work.
172
+ Actual worker attempts have a five-minute cooldown and only one may be in flight per Mind instance.
173
+ Separate started/settled receipts preserve the attempt target and cooldown without treating an
174
+ interrupted review as completed. A semantic digest skips unchanged settled inputs, including terminal
175
+ refusals and the state already produced by a successful apply. Only a retry of the interrupted attempt
176
+ bypasses the token gate; it still requires a later native settled event and cooldown. Cancellation
177
+ alone never rearms it. Incoming input, `agent_start`, off,
178
+ session/persona/workspace changes and shutdown cancel and invalidate pending plans. Delegated legs
179
+ do not recursively schedule automatic workers. Shared memories are excluded.
180
+
181
+ Persona hosts a real asynchronous Mind worker, visible in its standard agent view. The exact current
182
+ session model is the only allowed selection: no alternate provider/model or fallback. The worker has
183
+ no arbitrary tools, a 180-second deadline, and at most 12 full source records within 24,000 JSON
184
+ characters, with explicit IDs and provenance. Selection reserves the newest eligible record and
185
+ rotates bounded windows within a page and across older pages. Progress is session/scope-local and
186
+ advances only for completed reviews or explicitly ineligible/already-reviewed sets; cancelled work
187
+ does not count as reviewed. Byte-excluded records remain eligible on later passes. Coverage requires
188
+ further admitted triggers, never an unbounded autonomous sweep. Its output is strict JSON with at most four replacement
189
+ operations and at most 12 source IDs per operation, never direct storage writes. The parent rejects malformed, unsafe,
190
+ unattributed, stale or foreign-owner changes and applies accepted replacements through the existing
191
+ plan/CAS boundary. STM expiry cannot be extended, unrelated rows survive, and semantic deletion by age
192
+ is not introduced. The before/after proposal is recorded in a durable operator card before applying;
193
+ no semantic-quality guarantee or
194
+ invented token savings follows from successful execution.
195
+
196
+ ## Durable files and recovery
197
+
198
+ Under <agentDir>/persona-mind/:
199
+
200
+ - memory/ltm/<persona>.json and memory/ltm/_shared.json
201
+ - memory/project/<project>.json
202
+ - memory/stm/<project>.json
203
+ - backlog/<project>.json
204
+
205
+ Stores carry version, sequence, updatedAt and entries. Mutations use same-directory temporary writes,
206
+ fsync, atomic rename, exclusive lockfiles and ownership checks. Directory fsync is best-effort on
207
+ Windows. A live/foreign/malformed lock holder is never stolen merely for being old. Corruption is
208
+ recovered or quarantined with diagnostics, never silently treated as an empty valid store.
209
+ The atomic-store pattern is adapted from OpenLore (MIT).
210
+
211
+ Multi-store memory decisions serialize through one profile-wide memory transaction lock, anchored
212
+ beside shared LTM. A project-only lock is insufficient: persona/shared facts are visible across
213
+ projects, and another Pi could otherwise invalidate an ambiguity check before deletion. Lock order
214
+ is memory transaction → target history transaction → individual store; backlog remains independently
215
+ serialized. This is local same-profile coordination, not cross-host replication. Exocom scope aliases
216
+ do not change Mind's actual workspace identity or import another Pi's memory. Intercom/Exocom reports
217
+ remain untrusted material for explicit supervisor curation.
218
+
219
+ Ordinary recovery and migrations preserve user data. Imports scan bounded historical layouts,
220
+ deduplicate by semantic identity and reconcile the later record; originals are not removed.
221
+ A background import is bounded per turn and may finish after the turn continues. Incomplete import
222
+ means imported facts may not yet be available; it does not by itself prove corruption.
223
+ While import is pending, startup/injection defer disk expiry cleanup instead of waiting again on
224
+ the import's transaction lock. Read-time expiry filtering stays active; a later ordinary turn resumes
225
+ disk cleanup. Progress is informational, shown once per import and cleared when the import settles.
226
+
227
+ Expiry cleanup operates on the current entries under the mutation lock. Never compute a retained
228
+ backlog snapshot before acquiring the write lock: a concurrent add would otherwise be erased.
229
+ Promotion writes LTM before removing STM, so interruption leaves a duplicate rather than data loss.
230
+ Backlog cleanup retains active items and bounded terminal history.
231
+
232
+ ## Capture, injection and UI
233
+
234
+ Persona exposes pi-persona:companion:v1 as a synchronous local capability query. Exactly one
235
+ valid loaded provider is required; disabled, absent, ambiguous or incompatible responses refuse
236
+ Mind access. Tools remain guarded even through programmatic executeTool. Real delegated legs
237
+ receive memory capability for lean injection, not write tools or activity publishing.
238
+
239
+ Local explicit optimization publishes pi-persona:activity:v1 only for actual inspect/stage/apply work. The closed
240
+ payload contains session identity, activity identity, phase, state and target, never memory text,
241
+ paths, model or token claims. Persona projects it as a Mind activity row, separate from agents and
242
+ wake sources. It cannot be steered, stopped as a worker, counted as an agent or exported as agent
243
+ telemetry. Pending proposals are staged, not running. Native owner and scope changes suppress
244
+ late events; terminal rows have bounded retention. This is cooperative UI, not task authority.
245
+
246
+ Direct-user strong persistence cues may be captured deterministically before the model starts;
247
+ casual cues only suggest a tool call. Prompt/off modes preserve their declared behavior. Quoted,
248
+ fenced, peer and worker material is not a direct-user capture request. No-cue input skips migration
249
+ waits. Lifecycle generations prevent late capture receipts from leaking into a replacement session;
250
+ an accepted write may finish in its original store.
251
+
252
+ Normal injection uses entry caps (8 persona/shared LTM, 4 project LTM, 5 STM, 6 backlog), plus a
253
+ combined 2,400-token planning estimate across all memory blocks, including session notes (up to 600),
254
+ wrappers and omission notices. The estimate is UTF-8 bytes / 3, not a provider tokenizer or billing
255
+ guarantee. Whole excerpts are admitted, with bounded objective/invariant priority; they never bypass
256
+ the cap. Full reads are
257
+ explicit; no whole worker report is inserted as a memory merely because it exists. Scanner checks
258
+ run on admission and resurfacing, including new full-read source/tags. Scanning/fencing mitigates
259
+ unsafe content but cannot prove semantic truth or provide a security boundary against same-process code.
260
+
261
+ Nested report provenance follows Pi parentToolCallId, never guessed ID syntax. Only a visible relayed
262
+ blocked report from delegate/council/flow can suggest backlog capture. Discarded nested reports do not.
263
+ Bound and clear relay state at settlement.
264
+
265
+ Wakes are display-only appendEntry plus a short toast, never sendUserMessage/triggerTurn. Acknowledged
266
+ due reminders are not replayed. Newly due reminders are armed immediately and cancel on closure.
267
+ Keep pending/delivered deadline identity across maintenance re-arms.
268
+
269
+ Use shared expandable-card helpers: compact sanitized chrome, terminal-width clipping, full safe body
270
+ on expansion. Saved-memory tool bodies do not repeat their call title. A session read is not a save
271
+ receipt. Commands retain reports in custom-entry history; warnings/toasts stay short. Display callbacks
272
+ must still belong to their accepting session and scope after asynchronous reads.
273
+
274
+ ## Verification boundaries
275
+
276
+ Tests isolate PI_PERSONA_* and a throwaway PI_AGENT_DIR, use the actual Pi 1.4 SDK/tool pipeline and
277
+ offline providers, and join session_shutdown before SDK disposal. Native session tests cover persisted
278
+ reopen, branch/fork, in-memory behavior and owner revocation. Store tests cover lost writes, stale plans,
279
+ invalid inputs and concurrent apply. Installed-host/package qualification complements source tests.
280
+
281
+ Passing these checks proves tested behavior, not perfect memory, semantic compression quality, external
282
+ provider authentication or every operating system. CI provides separate Windows/Linux/macOS evidence.
@@ -0,0 +1,112 @@
1
+ # Memory consolidation: evidence and decisions
2
+
3
+ Reviewed 2026-10-25 against Mind 0.8.3, the current working changes, Pi 1.4.0 and
4
+ pi-persona main 476d3a3. Tavily was unavailable because its quota was exhausted; primary
5
+ sources were opened directly. This is an architectural review, not a Mind quality benchmark.
6
+
7
+ ## What the sources actually establish
8
+
9
+ - [Mem0 update prompt](https://raw.githubusercontent.com/mem0ai/mem0/main/mem0/configs/prompts.py)
10
+ specifies ADD, UPDATE, DELETE and NONE. It delegates semantic decisions to a model; this is
11
+ useful precedent for explicit operations, not proof that lexical rules safely choose them.
12
+ See also the [Mem0 paper](https://arxiv.org/abs/2504.19413).
13
+ - [Letta memory documentation](https://docs.letta.com/configuration/memory) describes editable
14
+ memory and background dreaming over agent experience. Background compute requires its own
15
+ lifecycle and model budget. Mind's explicit tools remain available; its user-authorized automatic
16
+ review now supplies a separate idle-only worker lifecycle using the current session model.
17
+ - [Graphiti](https://github.com/getzep/graphiti) retains temporal relationships and episode
18
+ provenance. That is stronger historical storage than Mind's active-row supersession plus lineage
19
+ IDs. Mind should not claim equivalent temporal history or recoverability.
20
+ - [Human-Inspired Memory Architecture for LLM Agents](https://arxiv.org/html/2605.08538v1)
21
+ reports 97.2% retention precision and roughly 58% store reduction on its VSCode issue-event
22
+ dataset, not LongMemEval. On LongMemEval S-tier, raw accuracy was 78.4%, deduplicated 76.8%,
23
+ with overlapping intervals; aggressive consolidation fell to 48.4%. The paper's roughly
24
+ 29-day half-life concerns events awaiting consolidation in its tested configuration, not a
25
+ universal expiry policy for durable facts. The preference result was directional, not an
26
+ individually significant general guarantee. Its embedding/calibration pipeline does not
27
+ validate automatic lexical merging in Mind. Detail loss is a concrete risk, not a minor nit.
28
+ - [Vectorize's consolidation discussion](https://hindsight.vectorize.io/blog/2026/05/21/agent-memory-consolidation)
29
+ is a useful design framing around importance, merging, decay and eviction. It is vendor guidance,
30
+ not independent evidence that applying all four improves this project.
31
+
32
+ ## Related systems checked 2026-10-25
33
+
34
+ These are source-level feature comparisons against the current [Mind design](DESIGN.md), not hands-on
35
+ reviews or quality rankings. Repository links pin the surveyed `main` revision; descriptions are not
36
+ evidence of comparative accuracy.
37
+
38
+ - [jayzeng/pi-memory](https://github.com/jayzeng/pi-memory/tree/1e276a762a666a7031459fdf7af018cc7966663e)
39
+ uses editable Markdown, daily logs and a scratchpad, with optional qmd BM25, vector and hybrid
40
+ search. That gives it a semantic route for differently worded queries, at the cost of qmd and an
41
+ embedding model for semantic modes. Its default stable snapshot also intentionally delays prompt
42
+ refresh after writes. Mind instead ranks explicit records by task terms, paths, tags and bounded
43
+ priority without an embedding/index service; it cannot claim the same paraphrase recall.
44
+ - [josephkern/pi-memory](https://github.com/josephkern/pi-memory/tree/312627ffc5a47de690b3066276009e7d651f8729f)
45
+ keeps global and trusted-project Markdown, injects a capped index and reads detail pages on demand;
46
+ its current README also describes staged writes and page-table sidecars. Project files can be
47
+ reviewed and shared through Git. Mind has more distinct owner/lifetime tiers, native branch-scoped
48
+ session notes and a combined bounded injection, while its project facts live in the local Mind
49
+ profile rather than as team-edited repository files.
50
+ - [feveromo/pi-hybrid-memory](https://github.com/feveromo/pi-hybrid-memory/tree/068977fd09e3c3dd9b9fbeb7c5b7de71558282a4)
51
+ is the closest Pi-side overlap: local JSONL/Markdown, repo-map context, lexical/path/symbol ranking,
52
+ bounded redacted injection and explicit untrusted-memory framing. Its optional model-assisted audit
53
+ is separate from retrieval. Mind shares deterministic path-aware ranking and trust fences, but does
54
+ not build a repo map or infer symbol links; it focuses on Persona-owned memory lifetimes, project
55
+ facts/backlog and native session notes. Neither repository's feature list establishes retrieval
56
+ quality on real tasks.
57
+ - [Letta Code](https://github.com/letta-ai/letta-code/tree/6f4e4886caa0934341eea75c306fc0364509218e)
58
+ is a stateful agent harness: its README describes editable memory blocks, self-improvement and
59
+ scheduled dreaming, message search, and Git-tracked MemFS. That supports broader agent learning and
60
+ cross-agent history search, but adopts Letta's agent/runtime and lifecycle model. Mind remains a
61
+ Pi extension integrated with the active Persona owner and Pi's native session branches; it does not
62
+ rewrite its own harness or provide Letta-wide message search.
63
+ - [Graphiti](https://github.com/getzep/graphiti/tree/5c27edfa8d3e0f49b2571bcebb4261bcc89ee037)
64
+ models entities, temporal relationships and source episodes, and documents hybrid semantic,
65
+ keyword and graph retrieval. It can answer historical validity/provenance questions that Mind's
66
+ active-row supersession and bounded lineage do not represent. Graphiti's usual setup adds a graph
67
+ backend and model/embedder configuration (the README also documents embedded FalkorDB Lite); Mind
68
+ avoids that infrastructure and does not offer temporal-graph queries.
69
+ - [claude-mem](https://github.com/thedotmack/claude-mem/tree/abd9aaab61995c53060a6bd15ce41e236f7c53e)
70
+ advertises automatic lifecycle-hook capture and model compression, then serves SQLite/FTS and
71
+ Chroma hybrid search through a local worker and progressive-disclosure tools. Its README lists
72
+ several host integrations, so it is not limited to Claude Code, but its hook/worker/database stack
73
+ and broad activity capture are a different operational and privacy choice. Mind is narrower:
74
+ Pi/Persona owner-scoped records and cue-gated direct-user capture, with deterministic retrieval and
75
+ no embedding database. Mind consequently has no semantic search index over captured activity.
76
+
77
+ No benchmark superiority is claimed. These upstream descriptions do not establish how any system
78
+ performs on Mind's users, memories or real project histories.
79
+
80
+ ## Decisions for Mind
81
+
82
+ 1. Keep exact deduplication and STM/backlog expiry automatic. They already existed.
83
+ 2. Add genuine branch-scoped session notes through Pi's native persistence instead of another
84
+ cross-session scratch store. Full retrieval is separate from bounded discovery/injection.
85
+ 3. Let the foreground model reassess facts against new evidence, with explicit source IDs and
86
+ reviewable before/after text. The user additionally authorized automatic semantic review through
87
+ a visible Mind subagent. Similarity suggests pairs; it never approves merging or deletion.
88
+ 4. Stage immutable plans and apply through fingerprint-checked transactions. Preserve unrelated
89
+ facts, source origins, lineage and the shortest STM lifetime. Reject ambiguity rather than guess.
90
+ 5. Do not infer obsolescence from age, store size or recall frequency. No automatic LTM decay or
91
+ semantic eviction is introduced. The earlier foreground-only decision is superseded by the user's
92
+ explicit request for automatic review: same session model, visible worker, idle admission,
93
+ cancellation on new input, bounded records and strict JSON, parent ownership/freshness/CAS checks.
94
+ Shared memory stays excluded. New memories mark work pending; the first burst may run when idle.
95
+ Subsequent attempts need new pending memories AND 1,000,000 main-session input tokens since the
96
+ preceding attempt, excluding output/cache/worker usage. Usage alone never schedules work. This
97
+ user-selected threshold, two-second idle coalescing and five-minute cooldown are cost-control
98
+ choices, not findings established by these papers. Interrupted attempts may retry after a later
99
+ settled event and cooldown without another token floor.
100
+ 6. Measure actual changes (entries/text), not invented token savings or accuracy. Fewer lines
101
+ are useful only when they retain the exceptions and evidence needed for future work.
102
+
103
+ ## Corrections to the preliminary GLM plan
104
+
105
+ The preliminary plan confused dataset results and proposed a universal decay heuristic without
106
+ adequate support. It also described reset as merely explanatory and entry renderers as missing;
107
+ both reset and native wake renderers already existed. Exact deduplication, lineage IDs, expiry,
108
+ bounded injection and atomic stores were foundations to reuse, not features to rebuild.
109
+
110
+ The current implementation contracts are in [DESIGN](DESIGN.md), and the callable command list
111
+ is in [README](../README.md). No claim of a “perfect memory” or benchmark superiority is made.
112
+ Semantic evaluation across real project histories remains separate from runtime correctness tests.
package/package.json CHANGED
@@ -1,6 +1,95 @@
1
1
  {
2
2
  "name": "@aeondave/pi-persona-mind",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.8.4",
4
+ "private": false,
5
+ "type": "module",
6
+ "description": "Local memory for Pi with pi-persona — durable project and persona facts, session notes, bounded retrieval, and supervised automatic consolidation.",
7
+ "keywords": [
8
+ "pi-package",
9
+ "pi-extension",
10
+ "pi-coding-agent",
11
+ "pi",
12
+ "memory",
13
+ "agent-memory",
14
+ "persistent-memory",
15
+ "persona",
16
+ "long-term-memory",
17
+ "short-term-memory",
18
+ "backlog",
19
+ "pi-persona"
20
+ ],
21
+ "author": "AeonDave",
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/AeonDave/pi-persona-mind.git"
26
+ },
27
+ "homepage": "https://github.com/AeonDave/pi-persona-mind#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/AeonDave/pi-persona-mind/issues"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "files": [
35
+ "src",
36
+ "docs/DESIGN.md",
37
+ "docs/MEMORY-RESEARCH.md",
38
+ "assets/banner.png",
39
+ "README.md",
40
+ "CHANGELOG.md",
41
+ "AGENTS.md",
42
+ "LICENSE"
43
+ ],
44
+ "main": "src/index.ts",
45
+ "engines": {
46
+ "node": ">=22.19.0"
47
+ },
48
+ "scripts": {
49
+ "typecheck": "tsc --noEmit",
50
+ "test": "node --import tsx --import ./test/setup/hermetic-env.ts --test test/*.test.ts",
51
+ "eval:memory": "node --import tsx scripts/evaluate-memory.ts",
52
+ "verify": "npm run typecheck && npm test"
53
+ },
54
+ "overrides": {
55
+ "@earendil-works/pi-coding-agent@1.4.0": {
56
+ "undici": "8.12.3"
57
+ }
58
+ },
59
+ "pi": {
60
+ "image": "https://raw.githubusercontent.com/AeonDave/pi-persona-mind/v0.8.4/assets/banner.png",
61
+ "extensions": [
62
+ "./src/index.ts"
63
+ ]
64
+ },
65
+ "peerDependencies": {
66
+ "@aeondave/pi-persona": ">=1.17.5",
67
+ "@earendil-works/pi-coding-agent": "*",
68
+ "@earendil-works/pi-tui": "*",
69
+ "typebox": "*"
70
+ },
71
+ "peerDependenciesMeta": {
72
+ "@aeondave/pi-persona": {
73
+ "optional": true
74
+ },
75
+ "@earendil-works/pi-coding-agent": {
76
+ "optional": true
77
+ },
78
+ "@earendil-works/pi-tui": {
79
+ "optional": true
80
+ },
81
+ "typebox": {
82
+ "optional": true
83
+ }
84
+ },
85
+ "devDependencies": {
86
+ "@earendil-works/pi-agent-core": "1.4.0",
87
+ "@earendil-works/pi-ai": "1.4.0",
88
+ "@earendil-works/pi-coding-agent": "1.4.0",
89
+ "@earendil-works/pi-tui": "1.4.0",
90
+ "@types/node": "^22.0.0",
91
+ "tsx": "^4.19.0",
92
+ "typebox": "*",
93
+ "typescript": "^7.0.2"
94
+ }
95
+ }