@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.
Files changed (164) hide show
  1. package/README.md +92 -43
  2. package/dist/adapters/llm/standalone.js +1 -1
  3. package/dist/cli/init.js +20 -3
  4. package/dist/cli/parseArgs.d.ts +5 -2
  5. package/dist/cli/parseArgs.js +13 -0
  6. package/dist/cli/schedulerSync.d.ts +2 -0
  7. package/dist/cli/schedulerSync.js +26 -0
  8. package/dist/cli/status.d.ts +4 -40
  9. package/dist/cli/status.js +6 -230
  10. package/dist/cli/theme.d.ts +2 -0
  11. package/dist/cli/theme.js +8 -0
  12. package/dist/cli.js +5 -0
  13. package/dist/commands/status.js +2 -2
  14. package/dist/compact/parseMemoryExport.js +2 -1
  15. package/dist/compact/register.js +1 -1
  16. package/dist/compact/runSummary.js +1 -16
  17. package/dist/compact/subagentDelta.js +3 -5
  18. package/dist/consolidate/index.d.ts +1 -0
  19. package/dist/consolidate/index.js +1 -0
  20. package/dist/consolidate/mergeEntries.js +3 -3
  21. package/dist/consolidate/mergeMemoryEntries.d.ts +8 -0
  22. package/dist/consolidate/mergeMemoryEntries.js +23 -0
  23. package/dist/consolidate/mergePrompt.js +2 -2
  24. package/dist/consolidate/mergeWithLlm.js +2 -2
  25. package/dist/consolidate/runJob.d.ts +2 -2
  26. package/dist/consolidate/runJob.js +6 -12
  27. package/dist/consolidate/scheduler.d.ts +2 -2
  28. package/dist/consolidate/scheduler.js +1 -1
  29. package/dist/constants/env.d.ts +1 -0
  30. package/dist/constants/env.js +1 -0
  31. package/dist/constants/paths.d.ts +3 -1
  32. package/dist/constants/paths.js +6 -1
  33. package/dist/extension/createMemoryRuntime.d.ts +3 -0
  34. package/dist/extension/createMemoryRuntime.js +203 -0
  35. package/dist/extension/index.d.ts +2 -0
  36. package/dist/extension/index.js +1 -0
  37. package/dist/extension/lifecycle.d.ts +28 -0
  38. package/dist/extension/lifecycle.js +52 -0
  39. package/dist/extension/messageUtils.d.ts +4 -0
  40. package/dist/extension/messageUtils.js +18 -0
  41. package/dist/extension/types.d.ts +35 -0
  42. package/dist/extension/types.js +1 -0
  43. package/dist/index.d.ts +7 -9
  44. package/dist/index.js +7 -9
  45. package/dist/pi-extension.js +26 -236
  46. package/dist/preflight/episodic.js +13 -30
  47. package/dist/preflight/queryIntent.js +1 -1
  48. package/dist/preflight/render.js +1 -1
  49. package/dist/preflight/strip.d.ts +0 -1
  50. package/dist/preflight/strip.js +0 -24
  51. package/dist/redaction/index.d.ts +4 -0
  52. package/dist/redaction/index.js +3 -0
  53. package/dist/redaction/patterns/constants.d.ts +6 -0
  54. package/dist/redaction/patterns/constants.js +6 -0
  55. package/dist/redaction/patterns/crypto.d.ts +3 -0
  56. package/dist/redaction/patterns/crypto.js +17 -0
  57. package/dist/redaction/patterns/generic.d.ts +3 -0
  58. package/dist/redaction/patterns/generic.js +38 -0
  59. package/dist/redaction/patterns/index.d.ts +16 -0
  60. package/dist/redaction/patterns/index.js +23 -0
  61. package/dist/redaction/patterns/llm.d.ts +3 -0
  62. package/dist/redaction/patterns/llm.js +144 -0
  63. package/dist/redaction/patterns/platform.d.ts +3 -0
  64. package/dist/redaction/patterns/platform.js +87 -0
  65. package/dist/redaction/patterns/types.d.ts +18 -0
  66. package/dist/redaction/patterns/types.js +1 -0
  67. package/dist/redaction/redactText.d.ts +9 -0
  68. package/dist/redaction/redactText.js +31 -0
  69. package/dist/redaction/types.d.ts +19 -0
  70. package/dist/redaction/types.js +1 -0
  71. package/dist/redaction/utils.d.ts +28 -0
  72. package/dist/redaction/utils.js +106 -0
  73. package/dist/scheduler/index.d.ts +3 -0
  74. package/dist/scheduler/index.js +3 -0
  75. package/dist/scheduler/launchd.d.ts +14 -0
  76. package/dist/scheduler/launchd.js +69 -0
  77. package/dist/scheduler/launchdPlist.d.ts +14 -0
  78. package/dist/scheduler/launchdPlist.js +62 -0
  79. package/dist/scheduler/sync.d.ts +36 -0
  80. package/dist/scheduler/sync.js +79 -0
  81. package/dist/shutdown/enqueue.d.ts +1 -1
  82. package/dist/shutdown/enqueue.js +2 -5
  83. package/dist/shutdown/readQueue.js +1 -1
  84. package/dist/shutdown/runDrainJob.js +8 -37
  85. package/dist/shutdown/sessionReader.js +1 -14
  86. package/dist/sidecar/client.d.ts +6 -2
  87. package/dist/sidecar/client.js +49 -14
  88. package/dist/{preflight → sidecar}/queryCache.d.ts +1 -1
  89. package/dist/sidecar/reindexBridge.js +2 -2
  90. package/dist/sidecar/server/server.js +1 -1
  91. package/dist/sidecar/server/vec/chunkQuery.d.ts +4 -0
  92. package/dist/sidecar/server/vec/chunkQuery.js +46 -0
  93. package/dist/sidecar/server/vec/chunkReindex.d.ts +5 -0
  94. package/dist/sidecar/server/vec/chunkReindex.js +40 -0
  95. package/dist/sidecar/server/vec/embeddingCodec.d.ts +2 -0
  96. package/dist/sidecar/server/vec/embeddingCodec.js +6 -0
  97. package/dist/sidecar/server/vec/schema.d.ts +20 -0
  98. package/dist/sidecar/server/vec/schema.js +61 -0
  99. package/dist/sidecar/server/vec/store.d.ts +2 -13
  100. package/dist/sidecar/server/vec/store.js +12 -139
  101. package/dist/sidecar/sidecarManager.js +4 -58
  102. package/dist/sidecar/spawnLock.d.ts +2 -0
  103. package/dist/sidecar/spawnLock.js +57 -0
  104. package/dist/sidecar/syncIndex.d.ts +3 -0
  105. package/dist/sidecar/syncIndex.js +12 -0
  106. package/dist/sidecar/warmup.js +1 -1
  107. package/dist/status/copy.d.ts +2 -0
  108. package/dist/status/copy.js +2 -0
  109. package/dist/status/format.d.ts +7 -0
  110. package/dist/status/format.js +133 -0
  111. package/dist/status/gather.d.ts +2 -0
  112. package/dist/status/gather.js +88 -0
  113. package/dist/status/index.d.ts +4 -0
  114. package/dist/status/index.js +3 -0
  115. package/dist/status/types.d.ts +33 -0
  116. package/dist/status/types.js +1 -0
  117. package/dist/store/consolidatePort.d.ts +11 -0
  118. package/dist/store/consolidatePort.js +1 -0
  119. package/dist/store/index.d.ts +2 -0
  120. package/dist/store/index.js +1 -0
  121. package/dist/store/ingestEntries.d.ts +16 -0
  122. package/dist/store/ingestEntries.js +22 -0
  123. package/dist/{init/workspace.d.ts → store/initWorkspace.d.ts} +1 -1
  124. package/dist/{init/workspace.js → store/initWorkspace.js} +7 -5
  125. package/dist/store/listeners.d.ts +11 -0
  126. package/dist/store/listeners.js +27 -0
  127. package/dist/store/markdown/insert.d.ts +3 -0
  128. package/dist/store/markdown/insert.js +23 -0
  129. package/dist/store/memoryStore.d.ts +9 -22
  130. package/dist/store/memoryStore.js +71 -205
  131. package/dist/store/resolveEntries.d.ts +11 -0
  132. package/dist/store/resolveEntries.js +23 -0
  133. package/dist/store/types.d.ts +0 -1
  134. package/dist/store/writePath.d.ts +20 -0
  135. package/dist/store/writePath.js +123 -0
  136. package/dist/ui/memoryStatusWidget.d.ts +4 -8
  137. package/dist/ui/memoryStatusWidget.js +5 -17
  138. package/dist/utils/async.d.ts +11 -0
  139. package/dist/utils/async.js +24 -0
  140. package/dist/utils/index.d.ts +5 -1
  141. package/dist/utils/index.js +5 -1
  142. package/dist/{ipc/jsonlFramer.d.ts → utils/jsonl.d.ts} +1 -1
  143. package/dist/{ipc/jsonlFramer.js → utils/jsonl.js} +1 -1
  144. package/dist/utils/memory/index.d.ts +10 -0
  145. package/dist/utils/memory/index.js +43 -0
  146. package/dist/utils/paths.d.ts +4 -0
  147. package/dist/utils/paths.js +13 -3
  148. package/dist/utils/scheduler.d.ts +1 -1
  149. package/dist/utils/scheduler.js +6 -6
  150. package/dist/{preflight/session.d.ts → utils/session/index.d.ts} +1 -0
  151. package/dist/{preflight/session.js → utils/session/index.js} +5 -2
  152. package/doc/LAUNCH-KIT.md +229 -0
  153. package/doc/README-zh.md +445 -0
  154. package/doc/ROADMAP-zh.md +114 -0
  155. package/doc/ROADMAP.md +114 -0
  156. package/package.json +16 -4
  157. package/scripts/postinstall.mjs +11 -1
  158. package/templates/com.pi.memory.consolidate.plist.example +41 -0
  159. package/templates/consolidate.cmd.example +15 -0
  160. package/templates/crontab.example +14 -0
  161. package/templates/schtasks.example.txt +34 -0
  162. package/dist/consolidate/entryKey.d.ts +0 -5
  163. package/dist/consolidate/entryKey.js +0 -4
  164. /package/dist/{preflight → sidecar}/queryCache.js +0 -0
@@ -0,0 +1,114 @@
1
+ # @chendpoc/pi-memory 路线图
2
+
3
+ <p align="center">
4
+ <a href="ROADMAP.md">English</a> |
5
+ <a href="ROADMAP-zh.md">简体中文</a>
6
+ </p>
7
+
8
+ 这是 `@chendpoc/pi-memory` 的公开产品路线图。它聚焦用户可感知的结果,不链接未随 npm 包发布的内部 `dev-doc/` 设计笔记。
9
+
10
+ ## 版本规划
11
+
12
+ | 版本 | 主题 | 用户可感知结果 |
13
+ | --- | --- | --- |
14
+ | **0.3.x** | 信任与安全 | 记忆写入更安全、有边界,也更容易诊断。 |
15
+ | **0.4.x** | 召回质量 | Pi 在 Preflight 预算内更常召回正确记忆。 |
16
+ | **0.5.x** | 记忆生命周期 | 用户能审查、淘汰、纠正长期记忆,减少手动清理。 |
17
+ | **0.6.x** | 可观测 + 控制面 | 用户能检查、排障、编辑、审查,并在本地迁移 Pi 记忆。 |
18
+ | **0.7.x** | 可选同步 | 在不强制上云的前提下,支持多 agent / 多设备协同记忆。 |
19
+
20
+ 进入 **0.7** 之前,必须先完成三件事:debug/trace、memory edit/review、本地 import/export。Cloud 或多 agent 同步应保持可选,并默认 local-first。
21
+
22
+ ## 产品原则
23
+
24
+ - `MEMORY.md` 继续作为可编辑的 Ground Truth。
25
+ - derived index、sidecar、trace、未来 sync state 都必须能从本地记忆工件重建。
26
+ - 召回应改善普通 agent 行为,但不能给每轮对话加入多秒级反思。
27
+ - 安全能力对记忆写入应 fail closed;对 agent 回答应 fail open。
28
+ - `pi-memory` 不应变成完整 transcript search 产品;旧会话搜索应由专门的 session-search 包负责。
29
+
30
+ ## 当前基础
31
+
32
+ - 带 overflow 的 `MEMORY.md` Ground Truth。
33
+ - `/remember` 和 `/memory-status`。
34
+ - 基于 UDS JSONL 的 sidecar。
35
+ - `memory.vec.sqlite` 向量索引。
36
+ - QueryIntent + raw-query fallback。
37
+ - 800ms 共享 Preflight 预算,sidecar query 支持 AbortSignal 取消。
38
+ - sidecar warm、intent cache、query cache。
39
+ - dual-purpose compaction summary。
40
+ - Shutdown Queue + `maintenance`。
41
+ - Consolidate + reindex。
42
+ - Subagent Memory Cap + Compact Delta。
43
+ - Ground Truth 写入前 secret 脱敏。
44
+ - `MemoryRuntime` 扩展生命周期与重构后的 store/sidecar 模块。
45
+
46
+ ## P0:信任与安全
47
+
48
+ **目标版本:0.3.x** · [GitHub milestone](https://github.com/chendpoc/pi-memory/milestone/1)
49
+
50
+ 用户目标:记忆能力足够安全,可以默认开启。
51
+
52
+ - ✅ durable memory 写入前做 secret/token redaction — **0.3.0 已交付**。
53
+ - ✅ 拆小并澄清 store、ingest、status、lifecycle、sidecar 等运行模块 — **0.3.0 已交付**。
54
+ - 为 LLM 生成的 Memory Export 增加 prompt-injection guardrails。
55
+ - 针对用户明确纠正做 correction detector,优先限定在 `/remember` 链路。
56
+ - 为跳过写入和 fallback 决策提供轻量 reason code;完整 trace UX 放在 **0.6**。
57
+
58
+ ## P1:召回质量
59
+
60
+ **目标版本:0.4.x** · [GitHub milestone](https://github.com/chendpoc/pi-memory/milestone/2)
61
+
62
+ 用户目标:Pi 更常召回正确的稳定事实,同时保持交互轮次足够快。
63
+
64
+ - 对 `MEMORY.md` 条目做 lexical + vector 混合召回:SQLite FTS5 + 现有 vector chunks,RRF merge 后再 MMR。
65
+ - 为常见 coding-agent 问题建立 recall eval fixtures。
66
+ - debug metrics 拆分 intent、embed、scan、MMR、render、fallback、总 Preflight 时间。
67
+ - 改进 Ollama 之外的 embedding provider,在可行时支持免费/开源 embedding API。
68
+ - sidecar 检索优化:增量 reindex、batch embed、更清晰的 reindex/query 隔离。
69
+ - 只有在延迟预算允许时,才在 MMR 后加入可选 reranker。
70
+
71
+ ## P2:记忆生命周期
72
+
73
+ **目标版本:0.5.x** · [GitHub milestone](https://github.com/chendpoc/pi-memory/milestone/3)
74
+
75
+ 用户目标:长期记忆保持有用,而不是变成不断增长的过期事实堆。
76
+
77
+ - 增加 failure 和 tool-quirk 类别。
78
+ - 晋升前提供人类可审查的 memory draft 或 diary。
79
+ - 基于使用信号的晋升和裁剪。
80
+ - rewrite 前提供更安全的 consolidate preview。
81
+ - 显式处理 stale / superseded fact,而不是只做简单 TODO 清理。
82
+ - lifecycle 事件进入共享 debug/trace event schema;面向用户的 trace surface 在 **0.6** 交付。
83
+
84
+ ## P3:可观测 + 控制面
85
+
86
+ **目标版本:0.6.x** · [GitHub milestone](https://github.com/chendpoc/pi-memory/milestone/4)
87
+
88
+ 用户目标:当记忆行为不符合预期时,用户能看懂原因并修正,而不必阅读底层内部状态。
89
+
90
+ 必须完成的出口标准:
91
+
92
+ - 本地 trace ring buffer,例如 `logs/trace.jsonl`,包含稳定 event name 和 reason code。
93
+ - `pi-memory status --verbose` 与 `/memory-status` 能总结最近 skip、fallback、write、reindex、recall 事件。
94
+ - memory edit/review 命令,并配合 **0.5** 的 stale/supersede 语义。
95
+ - 不同 Pi 安装之间的本地 import/export,并提供 dry-run,为未来 sync 做准备。
96
+
97
+ 0.6 可选 backlog:
98
+
99
+ - 更好的 TUI status panel。
100
+ - 常见 Pi 配置的文档 recipes。
101
+ - 剩余 sidecar tuning,例如并行 raw+intent recall、MMR lambda 调参、consolidate 后 recall 抽检,由 p99 延迟和 eval 数据驱动。
102
+
103
+ ## P4:可选同步
104
+
105
+ **目标版本:0.7.x**
106
+
107
+ 用户目标:跨多个 Pi agent 或设备工作时,可以协同记忆,但不放弃本地控制权。
108
+
109
+ - 多 agent 跨 session 记忆协同。
110
+ - 可选 cloud Pi agent <-> local Pi agent session-memory sync。
111
+ - `MEMORY.md` 仍是 source of truth;vector index 在各设备本地 rebuild。
112
+ - 默认不自动上传。
113
+ - sync 设计必须先定义冲突处理、trust boundary、redaction guarantee、rollback,再进入实现。
114
+ - 前置条件:injection + redaction 闭环、stale/edit 语义、本地 import/export、debug/trace 能排障跨进程写入。
package/doc/ROADMAP.md ADDED
@@ -0,0 +1,114 @@
1
+ # @chendpoc/pi-memory Roadmap
2
+
3
+ <p align="center">
4
+ <a href="ROADMAP.md">English</a> |
5
+ <a href="ROADMAP-zh.md">简体中文</a>
6
+ </p>
7
+
8
+ This is the public product roadmap for `@chendpoc/pi-memory`. It focuses on user-visible outcomes and intentionally avoids linking to internal `dev-doc/` design notes that are not shipped in the npm package.
9
+
10
+ ## Version Map
11
+
12
+ | Version | Theme | User-facing outcome |
13
+ | --- | --- | --- |
14
+ | **0.3.x** | Trust and safety | Memory writes are safer, bounded, and easier to diagnose. |
15
+ | **0.4.x** | Recall quality | Pi retrieves the right memory more often under the Preflight budget. |
16
+ | **0.5.x** | Memory lifecycle | Users can review, age out, and correct long-lived memory with less manual cleanup. |
17
+ | **0.6.x** | Observability + controls | Users can inspect, debug, edit, review, and locally move memory between Pi installs. |
18
+ | **0.7.x** | Optional sync | Local-first memory can coordinate across agents or devices without making cloud sync mandatory. |
19
+
20
+ Before **0.7**, three things must be real: debug/trace, memory edit/review, and local import/export. Cloud or multi-agent sync should remain optional and local-first by default.
21
+
22
+ ## Product Principles
23
+
24
+ - `MEMORY.md` remains the editable Ground Truth.
25
+ - Derived indexes, sidecars, traces, and future sync state must be rebuildable from local memory artifacts.
26
+ - Recall should improve ordinary agent behavior without adding multi-second thinking to every turn.
27
+ - Safety features should fail closed for memory writes and fail open for agent turns.
28
+ - `pi-memory` should not become a full transcript search product; that belongs in a dedicated session-search package.
29
+
30
+ ## Current Foundation
31
+
32
+ - `MEMORY.md` Ground Truth with overflow.
33
+ - `/remember` and `/memory-status`.
34
+ - Sidecar over UDS JSONL.
35
+ - `memory.vec.sqlite` vector index.
36
+ - QueryIntent with raw-query fallback.
37
+ - 800ms shared Preflight budget with AbortSignal-aware sidecar query.
38
+ - Warm sidecar, intent cache, query cache.
39
+ - Dual-purpose compaction summary.
40
+ - Shutdown Queue + `maintenance`.
41
+ - Consolidate + reindex.
42
+ - Subagent Memory Cap + Compact Delta.
43
+ - Secret redaction before Ground Truth writes.
44
+ - `MemoryRuntime` extension lifecycle and refactored store/sidecar modules.
45
+
46
+ ## P0: Trust And Safety
47
+
48
+ **Target: 0.3.x** · [GitHub milestone](https://github.com/chendpoc/pi-memory/milestone/1)
49
+
50
+ User-facing goal: memory should be safe enough to keep enabled by default.
51
+
52
+ - ✅ Secret and token redaction before durable memory writes — **shipped in 0.3.0**.
53
+ - ✅ Smaller, clearer runtime modules for store, ingest, status, lifecycle, and sidecar behavior — **shipped in 0.3.0**.
54
+ - Prompt-injection guardrails for LLM-generated Memory Export.
55
+ - Correction detector for explicit user corrections, scoped first to the `/remember` path.
56
+ - Lightweight reason codes for skipped writes and fallback decisions; full trace UX is planned for **0.6**.
57
+
58
+ ## P1: Recall Quality
59
+
60
+ **Target: 0.4.x** · [GitHub milestone](https://github.com/chendpoc/pi-memory/milestone/2)
61
+
62
+ User-facing goal: Pi should recall the right stable facts more often, while staying fast enough for interactive turns.
63
+
64
+ - Hybrid lexical + vector recall for `MEMORY.md` entries: SQLite FTS5 plus existing vector chunks, RRF merge, then MMR.
65
+ - Recall eval fixtures for common coding-agent questions.
66
+ - Debug metrics split by intent, embed, scan, MMR, render, fallback, and total Preflight time.
67
+ - Embedding provider improvements beyond Ollama, including free/open-source embedding APIs where practical.
68
+ - Sidecar retrieval optimizations: incremental reindex, batch embed, and clearer reindex/query isolation.
69
+ - Optional reranker after MMR only when it fits the latency budget.
70
+
71
+ ## P2: Memory Lifecycle
72
+
73
+ **Target: 0.5.x** · [GitHub milestone](https://github.com/chendpoc/pi-memory/milestone/3)
74
+
75
+ User-facing goal: long-lived memory should stay useful instead of becoming a growing pile of stale facts.
76
+
77
+ - Failure and tool-quirk categories.
78
+ - Human-reviewable memory draft or diary before promotion.
79
+ - Usage-weighted promotion and pruning.
80
+ - Safer consolidate preview before rewrite.
81
+ - Explicit stale/superseded fact handling instead of simple TODO pruning.
82
+ - Lifecycle events feed the shared debug/trace event schema; the user-facing trace surfaces ship in **0.6**.
83
+
84
+ ## P3: Observability + Controls
85
+
86
+ **Target: 0.6.x** · [GitHub milestone](https://github.com/chendpoc/pi-memory/milestone/4)
87
+
88
+ User-facing goal: when memory behaves unexpectedly, users can see why and fix it without reading raw internals.
89
+
90
+ Required exit criteria:
91
+
92
+ - Local trace ring buffer, for example `logs/trace.jsonl`, with stable event names and reason codes.
93
+ - `pi-memory status --verbose` and `/memory-status` surfaces that summarize recent skip, fallback, write, reindex, and recall events.
94
+ - Memory edit/review commands paired with stale/supersede semantics from **0.5**.
95
+ - Local import/export between Pi installations, with a dry-run mode before any future sync work.
96
+
97
+ Optional backlog for 0.6:
98
+
99
+ - Better TUI status panel.
100
+ - Documentation recipes for common Pi setups.
101
+ - Remaining sidecar tuning such as parallel raw+intent recall, MMR lambda tuning, and post-consolidate recall spot checks, driven by p99 latency and eval data.
102
+
103
+ ## P4: Optional Sync
104
+
105
+ **Target: 0.7.x**
106
+
107
+ User-facing goal: users who work across multiple Pi agents or devices can coordinate memory without giving up local control.
108
+
109
+ - Multi-agent cross-session memory coordination.
110
+ - Optional cloud Pi agent <-> local Pi agent session-memory sync.
111
+ - `MEMORY.md` remains the source of truth; vector indexes are rebuilt per device.
112
+ - No automatic upload by default.
113
+ - Sync design must define conflict handling, trust boundaries, redaction guarantees, and rollback before implementation.
114
+ - Prerequisites: injection + redaction closed loop, stale/edit semantics, local import/export, and debug/trace for cross-process write troubleshooting.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chendpoc/pi-memory",
3
- "version": "0.2.4",
3
+ "version": "0.3.2",
4
4
  "description": "Cross-session episodic memory for Pi agent — MEMORY.md ground truth, JSONL sidecar retrieval, and Preflight injection",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -38,7 +38,15 @@
38
38
  },
39
39
  "files": [
40
40
  "dist",
41
+ "doc/README-zh.md",
42
+ "doc/ROADMAP.md",
43
+ "doc/ROADMAP-zh.md",
44
+ "doc/LAUNCH-KIT.md",
41
45
  "templates/MEMORY.md.example",
46
+ "templates/com.pi.memory.consolidate.plist.example",
47
+ "templates/consolidate.cmd.example",
48
+ "templates/crontab.example",
49
+ "templates/schtasks.example.txt",
42
50
  "scripts/path-utils.mjs",
43
51
  "scripts/init-memory-workspace.mjs",
44
52
  "scripts/platform-fs.mjs",
@@ -55,6 +63,11 @@
55
63
  "pi-extension",
56
64
  "pi-agent",
57
65
  "episodic-memory",
66
+ "agent-memory",
67
+ "local-memory",
68
+ "markdown-memory",
69
+ "coding-agent",
70
+ "ai-memory",
58
71
  "recent-memory",
59
72
  "memory-recall"
60
73
  ],
@@ -69,7 +82,7 @@
69
82
  "extensions": [
70
83
  "./dist/pi-extension.js"
71
84
  ],
72
- "image": "https://raw.githubusercontent.com/chendpoc/pi-memory/v0.2.4/assets/gallery/pi-memory-gallery.png"
85
+ "image": "https://raw.githubusercontent.com/chendpoc/pi-memory/v0.3.1/assets/gallery/pi-memory-gallery.png"
73
86
  },
74
87
  "peerDependencies": {
75
88
  "@earendil-works/pi-agent-core": "*",
@@ -89,7 +102,6 @@
89
102
  "@earendil-works/pi-coding-agent": "*",
90
103
  "@earendil-works/pi-tui": "*",
91
104
  "@types/better-sqlite3": "^7.6.0",
92
- "@types/lodash": "^4.17.24",
93
105
  "@types/node": "^24.0.0",
94
106
  "typebox": "^1.3.3",
95
107
  "typescript": "^5.7.2",
@@ -102,8 +114,8 @@
102
114
  "chalk": "^5.6.2",
103
115
  "dayjs": "^1.11.21",
104
116
  "dotenv": "^17.4.2",
117
+ "es-toolkit": "^1.49.0",
105
118
  "execa": "^9.6.1",
106
- "lodash": "^4.18.1",
107
119
  "lru-cache": "^11.5.1",
108
120
  "proper-lockfile": "^4.1.2"
109
121
  }
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
3
  * Prefer compiled `pi-memory init` when dist exists; otherwise pre-build JS fallback.
4
+ * Scheduler sync is best-effort: failures must not fail npm install.
4
5
  */
5
6
  import { existsSync } from "node:fs";
6
7
  import { spawnSync } from "node:child_process";
@@ -10,8 +11,17 @@ import { fileURLToPath } from "node:url";
10
11
  const packageRoot = join(dirname(fileURLToPath(import.meta.url)), "..");
11
12
  const cli = join(packageRoot, "dist", "cli.js");
12
13
 
14
+ function runBestEffort(args) {
15
+ try {
16
+ spawnSync(process.execPath, args, { cwd: packageRoot, stdio: "ignore" });
17
+ } catch {
18
+ // ignore — workspace init / launchd sync must not block install
19
+ }
20
+ }
21
+
13
22
  if (existsSync(cli)) {
14
- spawnSync(process.execPath, [cli, "init"], { cwd: packageRoot, stdio: "ignore" });
23
+ runBestEffort([cli, "init"]);
24
+ runBestEffort([cli, "scheduler", "sync"]);
15
25
  } else {
16
26
  await import("./init-memory-workspace.mjs");
17
27
  }
@@ -0,0 +1,41 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
3
+ "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
4
+ <!--
5
+ Managed automatically by pi-memory (`scheduler sync` on postinstall, init, session_start).
6
+ Reference copy — normally do not install by hand.
7
+
8
+ Manual test after sync:
9
+ launchctl start com.pi.memory.maintenance
10
+
11
+ Logs: __HOME__/.pi/pi-memory-data/logs/maintenance.{log,err.log}
12
+ -->
13
+ <plist version="1.0">
14
+ <dict>
15
+ <key>Label</key>
16
+ <string>com.pi.memory.maintenance</string>
17
+
18
+ <key>ProgramArguments</key>
19
+ <array>
20
+ <string>/bin/sh</string>
21
+ <string>-c</string>
22
+ <string>mkdir -p '__HOME__/.pi/pi-memory-data/logs' &amp;&amp; exec '__NODE__' '__CLI__' maintenance --cron --verbose >> '__HOME__/.pi/pi-memory-data/logs/maintenance.log' 2>> '__HOME__/.pi/pi-memory-data/logs/maintenance.err.log'</string>
23
+ </array>
24
+
25
+ <key>StartCalendarInterval</key>
26
+ <dict>
27
+ <key>Hour</key>
28
+ <integer>3</integer>
29
+ <key>Minute</key>
30
+ <integer>0</integer>
31
+ </dict>
32
+
33
+ <key>EnvironmentVariables</key>
34
+ <dict>
35
+ <key>PI_MEMORY_ENV_FILE</key>
36
+ <string>__HOME__/.pi/agent/pi-memory.env</string>
37
+ <key>PI_MEMORY_AGENT_DIR</key>
38
+ <string>__HOME__/.pi/pi-memory-data</string>
39
+ </dict>
40
+ </dict>
41
+ </plist>
@@ -0,0 +1,15 @@
1
+ @echo off
2
+ REM Windows wrapper for daily maintenance (Task Scheduler).
3
+ REM Replace __NODE__ and __CLI__ before use.
4
+ REM
5
+ REM Install (elevated cmd):
6
+ REM schtasks /Create /TN "PiMemoryMaintenance" /TR "\"%CD%\consolidate.cmd\"" /SC DAILY /ST 03:00 /F
7
+ REM
8
+ REM Or point /TR directly at this script after editing paths below.
9
+
10
+ set PI_MEMORY_ENV_FILE=%USERPROFILE%\.pi\agent\pi-memory.env
11
+ set PI_MEMORY_AGENT_DIR=%USERPROFILE%\.pi\pi-memory-data
12
+
13
+ if not exist "%USERPROFILE%\.pi\pi-memory-data\logs" mkdir "%USERPROFILE%\.pi\pi-memory-data\logs"
14
+
15
+ "__NODE__" "__CLI__" maintenance --cron --verbose >> "%USERPROFILE%\.pi\pi-memory-data\logs\maintenance.log" 2>> "%USERPROFILE%\.pi\pi-memory-data\logs\maintenance.err.log"
@@ -0,0 +1,14 @@
1
+ # Daily 03:00 maintenance via OS cron (Linux/macOS crontab)
2
+ #
3
+ # Runs in one window:
4
+ # 1. consolidate — dedupe / merge MEMORY.md
5
+ # 2. drain-shutdown-queue — ingest facts from sessions that never compacted
6
+ #
7
+ # Install:
8
+ # 1. Replace paths below, then: crontab -e
9
+ # 2. `logs/` is created by Pi session start or `pi-memory init`; the mkdir below covers cron-only installs.
10
+ #
11
+ # __NODE__ = which node
12
+ # __CLI__ = path to pi-memory/dist/cli.js (after pnpm build)
13
+ #
14
+ 0 3 * * * mkdir -p $HOME/.pi/pi-memory-data/logs && PI_MEMORY_ENV_FILE=$HOME/.pi/agent/pi-memory.env PI_MEMORY_AGENT_DIR=$HOME/.pi/pi-memory-data __NODE__ __CLI__ maintenance --cron --verbose >> $HOME/.pi/pi-memory-data/logs/maintenance.log 2>&1
@@ -0,0 +1,34 @@
1
+ # Windows Task Scheduler — daily 03:00 maintenance
2
+ #
3
+ # Runs consolidate, then drain-shutdown-queue in one invocation.
4
+ #
5
+ # Prerequisites:
6
+ # 1. pnpm build
7
+ # 2. Edit templates/consolidate.cmd.example (__NODE__, __CLI__)
8
+ # 3. `logs/` is created by Pi session start or `pi-memory init`; consolidate.cmd also mkdirs before redirect.
9
+ #
10
+ # Option A — schtasks with wrapper script (recommended):
11
+ #
12
+ # schtasks /Create ^
13
+ # /TN "PiMemoryMaintenance" ^
14
+ # /TR "C:\path\to\pi-memory\templates\consolidate.cmd" ^
15
+ # /SC DAILY /ST 03:00 /F
16
+ #
17
+ # Option B — schtasks inline (replace paths):
18
+ #
19
+ # schtasks /Create ^
20
+ # /TN "PiMemoryMaintenance" ^
21
+ # /TR "\"C:\Program Files\nodejs\node.exe\" \"C:\path\to\pi-memory\dist\cli.js\" maintenance --cron --verbose" ^
22
+ # /SC DAILY /ST 03:00 /F
23
+ #
24
+ # Set env vars for the task (Task Scheduler → Properties → Environment):
25
+ # PI_MEMORY_ENV_FILE = %USERPROFILE%\.pi\agent\pi-memory.env
26
+ # PI_MEMORY_AGENT_DIR = %USERPROFILE%\.pi\pi-memory-data
27
+ #
28
+ # Manual test:
29
+ # schtasks /Run /TN "PiMemoryMaintenance"
30
+ #
31
+ # Remove:
32
+ # schtasks /Delete /TN "PiMemoryMaintenance" /F
33
+ #
34
+ # Logs: %USERPROFILE%\.pi\pi-memory-data\logs\maintenance.log
@@ -1,5 +0,0 @@
1
- /** Stable dedupe key for memory entries (section + trimmed content). */
2
- export declare function entryDedupeKey(entry: {
3
- section: string;
4
- content: string;
5
- }): string;
@@ -1,4 +0,0 @@
1
- /** Stable dedupe key for memory entries (section + trimmed content). */
2
- export function entryDedupeKey(entry) {
3
- return `${entry.section}\0${entry.content.trim()}`;
4
- }
File without changes