pi-memory-evolution 0.2.0
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/CHANGELOG.md +246 -0
- package/LICENSE +21 -0
- package/README.md +106 -0
- package/docs/conversation-recall.md +94 -0
- package/docs/core-quality.md +224 -0
- package/docs/design.md +328 -0
- package/docs/progress-pipeline.md +188 -0
- package/docs/quality-validation.md +85 -0
- package/docs/review-0.2.md +82 -0
- package/docs/testing.md +102 -0
- package/docs/usage.md +386 -0
- package/package.json +61 -0
- package/src/adapter/operations.ts +95 -0
- package/src/adapter/pi-api.ts +24 -0
- package/src/adapter/progress-observation.ts +83 -0
- package/src/adapter/session-context.ts +36 -0
- package/src/child-process.ts +8 -0
- package/src/index.ts +256 -0
- package/src/injector/digest.ts +29 -0
- package/src/memory/evolution.ts +64 -0
- package/src/memory/extractor.ts +63 -0
- package/src/memory/feedback.ts +11 -0
- package/src/memory/learning.ts +24 -0
- package/src/memory/legacy.ts +92 -0
- package/src/memory/memory-store.ts +502 -0
- package/src/memory/privacy.ts +51 -0
- package/src/memory/progress-targets.ts +52 -0
- package/src/memory/quality.ts +81 -0
- package/src/memory/query.ts +87 -0
- package/src/memory/recovery.ts +23 -0
- package/src/memory/retriever.ts +181 -0
- package/src/memory/search.ts +105 -0
- package/src/memory/sqlite.ts +7 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to pi-memory-evolution are documented here.
|
|
4
|
+
|
|
5
|
+
## [0.2.0] - 2026-09-08
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Rewrite the README as a concise Chinese project introduction and installation guide; move detailed operation/migration behavior to `docs/usage.md`
|
|
10
|
+
- Declare public npm distribution alongside native Pi Git/local installation
|
|
11
|
+
- Replace print-only package inspection with runtime-source, peer-dependency and documentation-link assertions
|
|
12
|
+
- Separate operation/project-based progress nomination from answer retrieval; pending states naming a bare repository remain eligible without per-path top-2 or answer deduplication
|
|
13
|
+
- Preserve important commit/push/test observations ahead of late inspection; retain completed operations before error/aborted responses without claiming whole-task completion
|
|
14
|
+
- Expand bounded active-user context scanning to 4096 entries/messages and collapse repeated topic-less continuations while preserving reset/unknown-topic barriers
|
|
15
|
+
- Capture natural requirement/preference/priority declarations without requiring a remember keyword; mixed statement/work sources are serialized separately instead of discarding progress
|
|
16
|
+
- Exclude internal memory lookups/owned-state observations from progress evidence; include operation-resource hints and explicit observation omissions
|
|
17
|
+
- Evidence-aware self-ranking after lexical gates, with separate host-assigned source weights, type-specific gradual freshness decay and non-cumulative explicit feedback
|
|
18
|
+
- Schema 2/3/4 → 5 transactionally adds feedback receipts without rewriting old memories/history or inventing evidence
|
|
19
|
+
- Withhold weaker proposed replacements and quarantine new conflicting variants instead of overwriting stronger user/tool evidence; fresh tool progress can still supersede prior manually corrected states
|
|
20
|
+
- Short named-attribute queries cannot substitute another subject/attribute after the right answer is suppressed; query-only Chinese `多少` cleanup and numeric-value handling
|
|
21
|
+
- General conversational query planning: separate asking/remembering phrases from the subject, retain current focus across multi-hop user follow-ups, and stop inheritance on explicit/unknown/reset topics
|
|
22
|
+
- Evidence-based IDF for unseen terms, mandatory literal resource constraints, focused-context gates, bounded length normalization, and reduced weight for quoted questions rather than their answers
|
|
23
|
+
- Track redundant facets per origin and evidence kind so a project-state replay note cannot hide a preference/fact answering the same question
|
|
24
|
+
- Increase model deadline from 30 to 120 seconds and output cap from 2048 to 8192 tokens (bounded by model capability); allow up to 64 KB of validated result JSON without relaxing claim limits
|
|
25
|
+
- Replaced signal/maturity/speak/proposal/approval/plan machinery with direct automatic memory evolution
|
|
26
|
+
- Reuse Pi 0.85's active model and public `modelRegistry.complete`, including provider authentication
|
|
27
|
+
- Store claims, sources, jobs and actual before/after history in transactional SQLite (built-in Bun/Node APIs)
|
|
28
|
+
- One-time, read-only JSONL migration; unknown origins retain a visible `legacy` label, originals preserved
|
|
29
|
+
- Topic-based recall across sessions and directories, including existing legacy claims without adoption
|
|
30
|
+
- Capture origin is provenance and a conservative write safeguard, no longer a recall eligibility filter
|
|
31
|
+
- Raw summaries never provide a lifecycle-bypassing fallback
|
|
32
|
+
- Require Node 22.19+ for Node development/runtime, matching Pi 0.85's engine requirement; support the standalone Pi Bun binary
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Isolated real-Pi installation smoke tests for packed artifacts, Git install/update/old-pin transitions, and native npm install through a loopback registry; verify idempotent registration and memory/history preservation on removal
|
|
37
|
+
- `docs/testing.md` describing installation, fake-model integration and live-provider validation boundaries
|
|
38
|
+
- `/memory learning` capture/nomination diagnostics and persistent changed-record outcomes in status, distinguishing processed jobs from actual learning
|
|
39
|
+
- Long-task, interruption/cancel-recovery, operation-resource, natural-intent and mixed-authority regressions; real-Pi commit/failed-push followed by 12 diagnostics, plus read-only historical replay
|
|
40
|
+
- Host-assigned evidence basis/method/source/date, bounded evidence and aging labels in injection, separate quality factors in show/explain, lifecycle exclusion diagnostics
|
|
41
|
+
- `/memory feedback <id> useful|unhelpful|accurate|incorrect` and narrow exact-ID user feedback statements, without paid learning calls; replay/late-event protection, quarantine/undo, unchanged evidence clock
|
|
42
|
+
- Read-only `memory_recall` tool for a second explicit-topic lookup during a task, bounded to 3 claims / 2048 bytes with no query persistence in the memory database
|
|
43
|
+
- Core-quality regressions and real Pi tool/feedback/provider-payload round trips with a loopback fake model
|
|
44
|
+
- `/memory explain [query]`: bounded transient recall diagnostics, normalized focus/context, candidate rejection reasons and last automatic injection counts; no query/body history persisted
|
|
45
|
+
- Multi-domain Chinese/English natural-question regressions, learned-alias paraphrases, multi-hop attribute refinement, unknown-topic barriers, quoted-question distractors and real-Pi provider-payload validation
|
|
46
|
+
- Automatic startup and 15-second timer recovery across origins, with persisted 1m/5m/15m/1h backoff and a five-failure per-source cap plus pause warning
|
|
47
|
+
- Safe fixed-code failure diagnostics, attempt/failure counts, last failure and next retry times in `/memory status`; manual evolve remains an optional one-off override
|
|
48
|
+
- Transactional schema 2/3 → 4 migration preserving memory/history, automatically discovering old failures without inventing missing diagnostics
|
|
49
|
+
- Recovery regressions for durable scheduling, cancellations, concurrent leases, backlog draining, migration and real-Pi timer-driven retries with a loopback fake model
|
|
50
|
+
- Background consolidation after compaction or explicit user corrections, with bounded output/deadline and shutdown cancellation
|
|
51
|
+
- Source idempotency, job leases, stale-result guards, exact-content suppression, and indexed/cached reads
|
|
52
|
+
- Direct history/undo/search/status/evolve/adopt commands; no owner approval required
|
|
53
|
+
- Strict typechecking, reproducible development dependencies, real multi-process tests and an optional real-Pi loopback-model test (local commands, not an installed CI workflow)
|
|
54
|
+
- Current-branch installation/update, source deduplication, bounded retry behavior, command limits and storage recovery documentation
|
|
55
|
+
- Paginated current/all/legacy memory browsing and provenance in `/memory show`
|
|
56
|
+
- Follow-up regression cases and mixed lifecycle sequence testing
|
|
57
|
+
- Bounded active-user context for vague follow-ups, without assistant/tool/digest feedback
|
|
58
|
+
- Origin/source labels in injected claims; global list/search/history/retry and an optional `list here` view
|
|
59
|
+
- Real-Pi tests that restart in another directory to verify cross-session recall, topic changes and forget
|
|
60
|
+
- Word/concept retrieval with query coverage, document-frequency weighting, weak-result cutoffs and literal path handling
|
|
61
|
+
- Bounded bilingual `searchTerms`, validated/persisted/undoable without refreshing evidence dates
|
|
62
|
+
- Tool-backed completed-work observations that may only replace host-nominated existing project states
|
|
63
|
+
- Schema 2 → 3 marker upgrade preserving existing records/history; older builds require a matching backup for rollback
|
|
64
|
+
- Real-Pi bilingual/alias and temporary Git commit + failed-push tests, with no live model charges
|
|
65
|
+
|
|
66
|
+
### Fixed
|
|
67
|
+
|
|
68
|
+
- Natural recall questions failing or selecting the memory implementation because generic asking words diluted the actual topic
|
|
69
|
+
- Recall questions containing `remember` accidentally triggering a paid learning call; explicit learning instructions remain supported
|
|
70
|
+
- Unknown single-character subjects and Chinese question-particle cleanup accidentally becoming topic-less continuations or spurious query fragments
|
|
71
|
+
- Failed jobs remaining stuck until manual retry, and missing durable failure reasons/times
|
|
72
|
+
- Synchronize leases with longer deadlines (150 seconds by default); recover expired jobs with bounded backoff and release shutdown-cancelled work without consuming failure budgets
|
|
73
|
+
- False approval/verification, ineffective thresholds and dropped deferred proposals: obsolete workflow removed
|
|
74
|
+
- Cross-process lost updates and partial JSONL writes: transactional database replaces multi-file mutation
|
|
75
|
+
- Parent-summary recall bypass, correction/backfill invalidation and repeated startup scans
|
|
76
|
+
- CJK byte-budget overflow, truncated trust guidance, literal identifier corruption and timestamp string ordering
|
|
77
|
+
- Common credential leaks, pending-source replay after suppression, async error handling and provider timeout handling
|
|
78
|
+
- Control-character normalization and multiline quoted/YAML credential redaction
|
|
79
|
+
- Nested/mixed Markdown fences, recursive glob preservation and sibling progress headings
|
|
80
|
+
- Colon-ambiguous scoped IDs, implicit wildcard recall and same-batch cross-kind duplicates
|
|
81
|
+
- Pending repeats surviving forget, unchanged legacy children lost on correction, and suppression history lost on adoption
|
|
82
|
+
- Invalid before/after undo pairings, indexed identity/hash mismatches, malformed source jobs and DDL on unsupported schemas
|
|
83
|
+
- Model-switch provenance, poisoned background queues, UI errors misreporting committed changes and post-shutdown reopening
|
|
84
|
+
- English and long-sentence matching excerpts, unreachable legacy pages and smoke-test startup/cleanup failures
|
|
85
|
+
- Pin/unpin, adoption and undo making old project-state evidence appear fresh
|
|
86
|
+
- Cwd-restricted recall that contradicted the intended cross-session memory behavior
|
|
87
|
+
- Weak matches such as `有没有问题` selecting `没有 CI`, and context-free continuation pulling arbitrary recent claims
|
|
88
|
+
- Recall deduplication hiding distinct same-text facts from different origins
|
|
89
|
+
- Weak secondary results promoted by CJK fragments, path-component words and insufficient relevance coverage
|
|
90
|
+
- Current-cwd tie preference; source labels are not authority or verification weights
|
|
91
|
+
- Common Chinese/English memory-boundary questions missing the actual user preference
|
|
92
|
+
- Ordinary completed work not reaching evolution, leaving tracked project progress stale until compaction
|
|
93
|
+
- Corrections retaining search aliases from old content, and forgetting a target leaving queued progress observers eligible
|
|
94
|
+
|
|
95
|
+
## Legacy 0.1 history
|
|
96
|
+
|
|
97
|
+
The phase entries below are historical implementation notes, **not current behavior or
|
|
98
|
+
current safety guarantees**. Approval, shadow mode, thresholds, raw-summary recall and
|
|
99
|
+
execution plans described here were removed in 0.2. Legacy document paths refer to the
|
|
100
|
+
files as they existed then; see Git history or the `v0.1.0` tag for those versions.
|
|
101
|
+
|
|
102
|
+
## [P11] - 2026-09-03
|
|
103
|
+
|
|
104
|
+
### Added
|
|
105
|
+
|
|
106
|
+
- Bounded structural extraction from labeled compaction-summary sections
|
|
107
|
+
- Provisional `fact`, `preference`, `decision` and `project_state` records
|
|
108
|
+
- Idempotent startup hydration for summaries created before the extractor
|
|
109
|
+
- Regression coverage for section boundaries, deduplication, limits and sensitive bullets
|
|
110
|
+
|
|
111
|
+
### Safety
|
|
112
|
+
|
|
113
|
+
- Extraction is deterministic and offline; it never infers facts from unlabeled prose
|
|
114
|
+
- Extracted records remain provisional until explicitly confirmed by the owner
|
|
115
|
+
|
|
116
|
+
## [P10] - 2026-09-03
|
|
117
|
+
|
|
118
|
+
### Added
|
|
119
|
+
|
|
120
|
+
- Local `recent` / `durable` / `pinned` memory layers
|
|
121
|
+
- Deterministic lexical + layer-authority retrieval fused with Reciprocal Rank Fusion
|
|
122
|
+
- Append-only `memory-actions.jsonl` lifecycle projection
|
|
123
|
+
- Explicit `/memory` commands for list, confirm, correct, forget, pin, conflict and resolve
|
|
124
|
+
- Fail-closed exclusion of forgotten, conflicted and expired memories
|
|
125
|
+
|
|
126
|
+
### Changed
|
|
127
|
+
|
|
128
|
+
- Compaction summaries enter the recent/provisional layer by default
|
|
129
|
+
|
|
130
|
+
## [P9] - 2026-09-03
|
|
131
|
+
|
|
132
|
+
### Added
|
|
133
|
+
|
|
134
|
+
- Durable `memories.jsonl` storage for successful Pi compaction summaries
|
|
135
|
+
- Prompt-relevant cross-session retrieval using Latin-word and CJK-bigram matching
|
|
136
|
+
- Continuation-prompt fallback to the most recent durable context
|
|
137
|
+
- Runtime digest injection of selected durable memories
|
|
138
|
+
- Basic redaction of common API keys, tokens, passwords and secrets before persistence
|
|
139
|
+
- Deduplication by source compaction entry id and malformed-record tolerance
|
|
140
|
+
|
|
141
|
+
### Changed
|
|
142
|
+
|
|
143
|
+
- `session_compact` now persists the actual `compactionEntry.summary` while continuing to enable signal collection
|
|
144
|
+
- `before_agent_start` now uses the raw user prompt to select relevant durable memories
|
|
145
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/), grouped by phase.
|
|
146
|
+
|
|
147
|
+
## [P8] - 2026-08-13
|
|
148
|
+
|
|
149
|
+
### Added
|
|
150
|
+
|
|
151
|
+
- Evidence contribution derived as `weight × relevance` (replaces hardcoded 0) and read into maturity scoring
|
|
152
|
+
- Configurable speak-gate thresholds (`thresholds.json`): speakThreshold / priorityQueueThreshold / dailyDigestThreshold / suggestionLimit / strategicLimit, defaulting to Hermes values
|
|
153
|
+
- Real-environment drill evidence: current pi session verified to emit agent_end signals and maturation runs in real time
|
|
154
|
+
- Real pi compact fix: rpc sessions now compact successfully via multi-message accumulation (10+ alternating turns), firing a real session_compact event
|
|
155
|
+
- Compact-drill configuration reverted: the temporary `compaction.keepRecentTokens=2000` setting (drill aid) was removed — multi-message accumulation is the actual fix (25K-token sessions compact under the default 20000 budget)
|
|
156
|
+
|
|
157
|
+
### Changed
|
|
158
|
+
|
|
159
|
+
- `evaluateCandidate` accepts optional thresholds (defaults unchanged)
|
|
160
|
+
- Evidence strength now sums the contribution field
|
|
161
|
+
|
|
162
|
+
### Fixed
|
|
163
|
+
|
|
164
|
+
- Contribution field was a hardcoded 0 in evidence records (P2 gap)
|
|
165
|
+
- Feedback collection (P1 gap): real pi `turn_end.message` carries the assistant reply, not the user input, so correction keywords were never extracted in production; feedback is now collected from user-role messages in the `agent_end` batch (verified in a real rpc session)
|
|
166
|
+
|
|
167
|
+
## [P7] - 2026-08-13
|
|
168
|
+
|
|
169
|
+
### Added
|
|
170
|
+
|
|
171
|
+
- Approval identity recording: `approvedBy`/`approvedAt` now carry the deciding role (`assistant`/`user`) or `expiry` for auto-rejected proposals
|
|
172
|
+
- Verified signal word-boundary matching: `unverified`/`未验证通过`/`not verified` no longer trigger a verified transition
|
|
173
|
+
- Negated verification guard (`未验证通过`/`未验证完成`/`未通过验证`/`not verified`/`not verification passed`/`never verified`)
|
|
174
|
+
- Shadow calibration observation guide in `docs/design.md`
|
|
175
|
+
|
|
176
|
+
### Changed
|
|
177
|
+
|
|
178
|
+
- `transitionProposal` accepts an optional approval identity payload (approved/rejected only)
|
|
179
|
+
- Auto-approval journal lines now include the deciding role
|
|
180
|
+
|
|
181
|
+
### Fixed
|
|
182
|
+
|
|
183
|
+
- `unverified P-xxx` previously advanced implemented proposals to verified (substring match on `verified`); now stays implemented
|
|
184
|
+
|
|
185
|
+
## [P6] - 2026-08-13
|
|
186
|
+
|
|
187
|
+
### Added
|
|
188
|
+
|
|
189
|
+
- Word-boundary approval matching: `approved`/`token`/`okay` no longer trigger approval decisions
|
|
190
|
+
- Negated approval guard (`不执行`/`不批准`/`不同意`/`不可以` now reject instead of approve)
|
|
191
|
+
- Evidence carry: matured candidates and execution plans now include real collected evidence records
|
|
192
|
+
- Execution plan archive: terminal proposals move plans to `executions/archive/`, purged after 90 days
|
|
193
|
+
- Verified signal trigger: implemented proposals advance to verified via agent message with a verification keyword
|
|
194
|
+
|
|
195
|
+
### Fixed
|
|
196
|
+
|
|
197
|
+
- Residual false-approval vector: tool results can no longer trigger approval decisions (role whitelist)
|
|
198
|
+
|
|
199
|
+
## [P5] - 2026-08-13
|
|
200
|
+
|
|
201
|
+
### Added
|
|
202
|
+
|
|
203
|
+
- Proposal lifecycle state machine (pending_user_approval → approved/rejected → implemented → verified, with failed/rollback_required paths)
|
|
204
|
+
- Auto-approval channel: proposals surface in the runtime digest; the agent approves/rejects by referencing the proposal id; 24h expiry auto-rejects
|
|
205
|
+
- Record-first evolution executor: approved proposals produce markdown execution plans in `executions/`
|
|
206
|
+
|
|
207
|
+
### Changed
|
|
208
|
+
|
|
209
|
+
- Proposal approval moved from `ui.confirm()` to the auto-approval channel
|
|
210
|
+
|
|
211
|
+
## [P4] - 2026-08-13
|
|
212
|
+
|
|
213
|
+
### Added
|
|
214
|
+
|
|
215
|
+
- Speak gate consuming matured candidates: priority/speak scoring, risk dampeners, daily quotas, traceable decisions
|
|
216
|
+
- Proposal queue: approved candidates written as proposals
|
|
217
|
+
|
|
218
|
+
## [P3] - 2026-08-13
|
|
219
|
+
|
|
220
|
+
### Added
|
|
221
|
+
|
|
222
|
+
- Runtime digest injection into every session (`before_agent_start`), <2KB, expiry-stamped, advisory-only
|
|
223
|
+
|
|
224
|
+
## [P2] - 2026-08-07
|
|
225
|
+
|
|
226
|
+
### Added
|
|
227
|
+
|
|
228
|
+
- Memory evaluation using the Hermes maturation formula (evidence-driven, "time is not evidence")
|
|
229
|
+
- Agenda engine: state machine, unmatched-signal clustering, maturation pipeline
|
|
230
|
+
- Shadow mode: evaluation writes candidates and journal only, never triggers user-visible actions
|
|
231
|
+
|
|
232
|
+
## [P1] - 2026-08-05
|
|
233
|
+
|
|
234
|
+
### Added
|
|
235
|
+
|
|
236
|
+
- Signal collection: session stats, projection notices, user feedback → `signals.jsonl`
|
|
237
|
+
- Evolution journal (`evolution_journal.md`)
|
|
238
|
+
- Compaction-gated collection trigger and subagent-process skip
|
|
239
|
+
|
|
240
|
+
## [P0] - 2026-08-04
|
|
241
|
+
|
|
242
|
+
### Added
|
|
243
|
+
|
|
244
|
+
- Extension skeleton with capability probing and version-decoupling adapter layer
|
|
245
|
+
- `before_agent_start` lifecycle hook placeholder
|
|
246
|
+
- node:test suites
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 btnalit
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# pi-memory-evolution
|
|
2
|
+
|
|
3
|
+
为 [Pi](https://pi.dev) 提供持久记忆,让项目背景、个人偏好和工作进展能够跨会话延续。
|
|
4
|
+
|
|
5
|
+
扩展自动学习值得保留的信息,在后续对话中按主题注入相关内容,也支持跨目录召回。不需要反复说“记住”,不需要维护审批队列。
|
|
6
|
+
|
|
7
|
+
## 功能
|
|
8
|
+
|
|
9
|
+
- **自动学习与更新**:从对话摘要、需求和纠正中提取记忆,根据实际工具结果更新已有项目状态;保留来源和变更历史,支持衰退、排序与撤销。
|
|
10
|
+
- **相关内容注入**:结合当前问题和近期用户上下文选择记忆,过滤弱匹配和失效状态;没有匹配就不填充无关内容。
|
|
11
|
+
- **跨会话召回**:在共享记忆库的不同会话、目录中查找背景;提供只读 `memory_recall` 工具,供助手在任务中途补查。
|
|
12
|
+
|
|
13
|
+
学习使用 Pi 当前模型和已有认证,无需另配 API Key、向量数据库或嵌入服务。
|
|
14
|
+
|
|
15
|
+
## 安装
|
|
16
|
+
|
|
17
|
+
需要 **Pi 0.85+**,并已配置可用模型。使用 npm 版 Pi 时需要 **Node.js 22.19+**。
|
|
18
|
+
|
|
19
|
+
### npm
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pi install npm:pi-memory-evolution
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Git
|
|
26
|
+
|
|
27
|
+
也可以直接安装 Git 默认分支,需要本机有 Git 和 npm:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pi install https://github.com/btnalit/pi-memory-evolution
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**两种方式选一种**,不要重复安装。然后在 Pi 中执行:
|
|
34
|
+
|
|
35
|
+
```text
|
|
36
|
+
/reload
|
|
37
|
+
/memory status
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
出现 `SQLite ok (schema 5)` 表示存储初始化成功。后续正常使用 Pi 即可,学习和召回会自动运行。
|
|
41
|
+
|
|
42
|
+
## 使用
|
|
43
|
+
|
|
44
|
+
在对话中说明需求,例如:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
atlas-service 的核心需求是自动备份和故障恢复。
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
之后可以在新会话中继续询问:
|
|
51
|
+
|
|
52
|
+
```text
|
|
53
|
+
你还记得 atlas-service 的核心需求吗?
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
学习在后台完成,并非每句话都会保存。可用以下命令查看和维护记忆:
|
|
57
|
+
|
|
58
|
+
| 命令 | 用途 |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `/memory list` | 浏览记忆 |
|
|
61
|
+
| `/memory search <主题>` | 搜索相关内容 |
|
|
62
|
+
| `/memory show <id>` | 查看内容和来源 |
|
|
63
|
+
| `/memory learning` | 查看采集、更新及实际变更结果 |
|
|
64
|
+
| `/memory explain` | 查看上一次自动注入的选择原因 |
|
|
65
|
+
| `/memory correct <id> <内容>` | 纠正记忆 |
|
|
66
|
+
| `/memory forget <id>` | 停止召回该记忆 |
|
|
67
|
+
|
|
68
|
+
完整命令、安装迁移和排错方法见[使用指南](docs/usage.md)。
|
|
69
|
+
|
|
70
|
+
## 更新与卸载
|
|
71
|
+
|
|
72
|
+
npm 安装:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pi update npm:pi-memory-evolution
|
|
76
|
+
pi remove npm:pi-memory-evolution
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Git 安装请把上面的包来源替换为安装时使用的仓库 URL。操作后执行 `/reload` 或重启 Pi。卸载扩展不会删除记忆库;升级数据库结构前请先退出共用该库的 Pi 进程并备份。
|
|
80
|
+
|
|
81
|
+
## 数据与边界
|
|
82
|
+
|
|
83
|
+
数据默认保存在 `~/.pi/agent/agent-suite/memory-evolution/`,使用本地 SQLite。`PI_CODING_AGENT_DIR` 可改变存储前缀;不同工作目录默认共享记忆库。
|
|
84
|
+
|
|
85
|
+
学习会将经过过滤的来源内容发送给当前模型,并消耗相应额度。记忆不是经过独立验证的事实,匹配和敏感信息过滤也并非万无一失;重要内容仍需核实。详见[存储与隐私](docs/usage.md#local-storage-and-provenance)。
|
|
86
|
+
|
|
87
|
+
## 开发
|
|
88
|
+
|
|
89
|
+
在源码仓库中运行:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npm ci --ignore-scripts
|
|
93
|
+
npm run check
|
|
94
|
+
npm run test:install
|
|
95
|
+
npm run test:pi
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
安装测试使用隔离环境,集成测试使用真实 Pi 和模拟模型,不产生付费模型调用。环境要求和测试范围见[测试说明](docs/testing.md)。
|
|
99
|
+
|
|
100
|
+
## 文档
|
|
101
|
+
|
|
102
|
+
[使用指南](docs/usage.md) · [架构设计](docs/design.md) · [记忆质量](docs/core-quality.md) · [更新记录](CHANGELOG.md)
|
|
103
|
+
|
|
104
|
+
## 许可证
|
|
105
|
+
|
|
106
|
+
[MIT](LICENSE)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Conversational recall follow-up
|
|
2
|
+
|
|
3
|
+
Version 0.2.0 remains unreleased. This change improves automatic **per-user-turn**
|
|
4
|
+
recall, not only startup recall, and does not add a special case for a device/topic.
|
|
5
|
+
No schema change, production-memory rewrite or additional recall-time model call.
|
|
6
|
+
|
|
7
|
+
## Reproduced failures
|
|
8
|
+
|
|
9
|
+
The initial 13 regression groups had **9 failures** on the preceding implementation.
|
|
10
|
+
Six groups each exercise Chinese/English questions about a different domain: device,
|
|
11
|
+
database, backup, font, coffee and travel. Recall framing could either dilute the actual
|
|
12
|
+
subject or retrieve an unrelated memory about the memory system itself. Other failures
|
|
13
|
+
covered exact-resource precision, corpus-size sensitivity and learned-alias paraphrases.
|
|
14
|
+
|
|
15
|
+
A read-only production-database replay separately reproduced the original issue:
|
|
16
|
+
a one-word topic found records, while the natural question yielded none. This was not
|
|
17
|
+
a missing record, a cwd restriction, an expired job or a need for another model API key.
|
|
18
|
+
|
|
19
|
+
## Implementation
|
|
20
|
+
|
|
21
|
+
- **Query planning:** query-only cleanup removes conversational framing while preserving
|
|
22
|
+
actual technical memory questions and exact paths. Stored text is unchanged.
|
|
23
|
+
- **Multi-hop context:** a structured plan separates current focus from its supporting
|
|
24
|
+
subject. `SQLite 数据库 → 端口呢? → 认证呢? → 继续` retains SQLite and answers the
|
|
25
|
+
authentication question, not the earlier port question. Only bounded active-branch
|
|
26
|
+
user texts/retained user tails supply context; never assistant/tool/injected text.
|
|
27
|
+
- **Topic barriers:** new subjects, including unknown subjects, do not inherit the last
|
|
28
|
+
successful database match. Reset phrases break the chain. Context-free continuation
|
|
29
|
+
stays empty. Unindexed single-character subjects are not treated as empty chit-chat.
|
|
30
|
+
- **Multi-signal ranking:** words, exact identifiers, bilingual concepts and validated
|
|
31
|
+
learned aliases contribute field-weighted evidence. Unseen terms get base weight,
|
|
32
|
+
not maximum IDF. Coverage, current-focus and supporting-subject gates, mandatory
|
|
33
|
+
literal constraints, mild length normalization and relative relevance filtering
|
|
34
|
+
protect precision rather than indiscriminately lowering thresholds.
|
|
35
|
+
- **Question vs answer:** quoted questions in replay/incident notes have reduced weight
|
|
36
|
+
and cannot qualify by themselves. Facet deduplication is separated by evidence kind,
|
|
37
|
+
preventing a project-state mention from hiding a preference that answers the question.
|
|
38
|
+
- **No accidental learning:** asking `What do you remember about X?` does not turn the
|
|
39
|
+
question into a learning source simply because it contains `remember`. Explicit
|
|
40
|
+
`Please remember that ...` instructions still work.
|
|
41
|
+
- **Inspection:** `/memory explain` shows the last automatic snapshot, including actual
|
|
42
|
+
injection count/bytes. `/memory explain <query>` previews an explicit query without
|
|
43
|
+
conversation inheritance or replacing that snapshot. Diagnostics contain bounded,
|
|
44
|
+
sanitized features/IDs/counts/reasons, not memory bodies, and are not persisted.
|
|
45
|
+
They show selection/injection decisions, not whether the model understood them.
|
|
46
|
+
|
|
47
|
+
The exact scoring rules, lifecycle exclusions and limits are in [design.md](design.md).
|
|
48
|
+
The digest still contains at most three claims / 2,048 UTF-8 bytes, with reserved trust
|
|
49
|
+
and provenance guidance and an explicit warning that this is not the full inventory.
|
|
50
|
+
|
|
51
|
+
## Validation
|
|
52
|
+
|
|
53
|
+
- **164 tests passed**, including existing transactional/lifecycle/privacy tests and new
|
|
54
|
+
conversational regressions. Strict TypeScript checking and package dry-run inspection
|
|
55
|
+
are included in `npm run check`.
|
|
56
|
+
- Six domains × six natural-question forms, positive learned-alias paraphrases and
|
|
57
|
+
unsupported-paraphrase negatives. These are deterministic fixtures, not a universal
|
|
58
|
+
natural-language benchmark or an independent semantic-accuracy evaluation.
|
|
59
|
+
- Multi-hop current-focus tests distinguish SQLite authentication from PostgreSQL
|
|
60
|
+
authentication and from SQLite's old port answer. Unknown facets do not fall back to
|
|
61
|
+
old answers; new subjects and resets do not resurrect older matched topics.
|
|
62
|
+
- Real installed Pi 0.85/Bun with a **loopback fake model** verifies actual outgoing
|
|
63
|
+
provider digests, fresh cross-directory sessions, Chinese/English question framing,
|
|
64
|
+
multi-hop refinements, unknown-topic barriers, diagnostics, forget and no accidental
|
|
65
|
+
learning calls. Existing model/auth, actual temporary Git work, failed-push and timer
|
|
66
|
+
recovery checks remain included. No live paid provider was used for these tests.
|
|
67
|
+
- A separate **read-only SQLite connection** evaluated 14 distinct query/context cases
|
|
68
|
+
against a snapshot of **154 real records** (17 executions including repeats). The
|
|
69
|
+
original natural questions now retrieve the stored topic. Both language variants of
|
|
70
|
+
the project-boundary question rank the actual preference first, not a replay note
|
|
71
|
+
quoting the question or a weak storage-directory fact. Unknown/reset/context-free
|
|
72
|
+
cases remain empty. Model/auth questions retrieve corresponding implementation facts.
|
|
73
|
+
The connection reported `total_changes() = 0`. Sample timing was 0–56 ms per evaluation
|
|
74
|
+
(empty queries at 0 ms); this is one local sample, not a performance guarantee.
|
|
75
|
+
|
|
76
|
+
The live Pi process may independently learn from later completed turns; these counts
|
|
77
|
+
refer to the diagnostic snapshot, not a promise that the running database stays frozen.
|
|
78
|
+
|
|
79
|
+
## Limits and activation
|
|
80
|
+
|
|
81
|
+
This is **local concept/alias-assisted retrieval**, not an embedding service or a general
|
|
82
|
+
LLM semantic reasoner. Learned aliases extend vocabulary without translating at recall
|
|
83
|
+
time; absent aliases, unsupported paraphrases can still be missed. Conservative subject
|
|
84
|
+
and literal gates can miss useful ambiguous references. Negation, complex comparisons
|
|
85
|
+
and arbitrary coreference are not fully understood. The system deliberately prefers no
|
|
86
|
+
injection over filling a quota with unrelated memories.
|
|
87
|
+
|
|
88
|
+
Selection is not truth verification. Historical states may be stale even inside their
|
|
89
|
+
seven-day window, and inferred claims/aliases remain provisional. Existing facts are
|
|
90
|
+
not marked complete or rewritten merely because the algorithm changed.
|
|
91
|
+
|
|
92
|
+
The local Pi installation references the checkout directly. Run **`/reload`** (or restart)
|
|
93
|
+
to activate the updated extension in an existing session. This change does not migrate
|
|
94
|
+
or reset the database. It neither commits nor publishes the repository automatically.
|