pi-session-memory 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 shengxiao04
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,104 @@
1
+ # pi-session-memory
2
+
3
+ [![npm version](https://img.shields.io/npm/v/pi-session-memory?color=cb3837&logo=npm)](https://www.npmjs.com/package/pi-session-memory)
4
+ [![Pi package](https://img.shields.io/badge/Pi-package-6B5BFF)](https://pi.dev/packages)
5
+
6
+ A local-first Pi extension that saves completed conversations to SQLite and gives the agent a `recall_memory` tool for retrieving relevant discussions from previous Pi, Claude Code, and Codex sessions.
7
+
8
+ > **Paper:** An accompanying arXiv paper is planned. [arXiv:XXXX.XXXXX](https://arxiv.org/abs/XXXX.XXXXX) *(placeholder; not published yet)*
9
+
10
+ ## Features
11
+
12
+ - Persists completed Pi conversations in `~/.pi/agent/memory.db`.
13
+ - Imports historical session records from Pi, Claude Code, and Codex with `/memory-backfill`.
14
+ - Exposes `recall_memory`, allowing Pi to retrieve relevant prior discussions when users explicitly refer to earlier work.
15
+ - Uses stable native user-message IDs and `INSERT OR IGNORE`, making live persistence and backfill idempotent.
16
+ - Searches literal substrings with escaped SQLite `LIKE` patterns, including technical terms containing `%`, `_`, or `\\`.
17
+ - Uses only Node.js built-ins and SQLite (`node:sqlite`); no external runtime dependencies.
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pi install npm:pi-session-memory@0.1.1
23
+ ```
24
+
25
+ To try the package without installing it permanently:
26
+
27
+ ```bash
28
+ pi -e npm:pi-session-memory@0.1.1
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ### Import existing history
34
+
35
+ Run this once after installation, and again whenever you want to scan newly available historical session files:
36
+
37
+ ```text
38
+ /memory-backfill
39
+ ```
40
+
41
+ The command imports eligible user/assistant exchanges from:
42
+
43
+ | Source | Session location |
44
+ | --- | --- |
45
+ | Pi | `~/.pi/agent/sessions/**/*.jsonl` |
46
+ | Claude Code | `~/.claude/projects/**/*.jsonl` |
47
+ | Codex | `~/.codex/sessions/**/*.jsonl` |
48
+
49
+ ### Recall prior work
50
+
51
+ The extension instructs Pi to call `recall_memory` when a user explicitly asks about a previous discussion, for example:
52
+
53
+ ```text
54
+ What did we decide about LangGraph last time?
55
+ ```
56
+
57
+ ```text
58
+ 回顾一下我们开发历史中关于 Joule 的内容
59
+ ```
60
+
61
+ The tool searches prior user prompts and assistant responses, ranks matches by entity hits, and returns the five most relevant turns.
62
+
63
+ ## How it works
64
+
65
+ ```text
66
+ completed Pi agent run ───► SQLite memory.db ◄─── /memory-backfill
67
+ ▲ │
68
+ │ ▼
69
+ recall_memory Pi / Claude / Codex
70
+ ```
71
+
72
+ After a Pi agent run settles, the extension captures the latest user message and the subsequent assistant replies/tool names from the active session branch. Historical imports normalize each supported source into the same session/turn schema.
73
+
74
+ The database stays on the local machine at:
75
+
76
+ ```text
77
+ ~/.pi/agent/memory.db
78
+ ```
79
+
80
+ ## Privacy
81
+
82
+ Conversation data is stored and queried locally. This package does not add a remote storage service or transmit conversation history on its own. Review the source and your model provider's configuration before using it with sensitive conversations.
83
+
84
+ ## Development
85
+
86
+ ```bash
87
+ npm test
88
+ ```
89
+
90
+ ## Paper placeholder
91
+
92
+ ```bibtex
93
+ @article{pi-session-memory-2026,
94
+ title = {Persistent Local-First Cross-Session Memory for Coding Agents},
95
+ author = {Anonymous},
96
+ year = {2026},
97
+ eprint = {XXXX.XXXXX},
98
+ archivePrefix = {arXiv},
99
+ primaryClass = {cs.AI},
100
+ note = {Placeholder; preprint forthcoming}
101
+ }
102
+ ```
103
+
104
+ Replace the title, authors, arXiv identifier, and citation metadata after the preprint is submitted.
package/package.json CHANGED
@@ -1,8 +1,19 @@
1
1
  {
2
2
  "name": "pi-session-memory",
3
- "version": "0.1.0",
4
- "description": "Pi extension: persists conversation turns to SQLite and exposes recall_memory tool for cross-session retrieval",
5
- "keywords": ["pi-package"],
3
+ "version": "0.1.2",
4
+ "description": "Persistent, local-first cross-session memory for Pi, with SQLite-backed recall across Pi, Claude Code, and Codex conversations",
5
+ "keywords": [
6
+ "pi-package"
7
+ ],
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/shengxiao20/pi-session-memory.git"
11
+ },
12
+ "homepage": "https://github.com/shengxiao20/pi-session-memory#readme",
13
+ "license": "MIT",
14
+ "bugs": {
15
+ "url": "https://github.com/shengxiao20/pi-session-memory/issues"
16
+ },
6
17
  "type": "module",
7
18
  "scripts": {
8
19
  "test": "tsx tests/core.test.ts"
@@ -11,7 +22,9 @@
11
22
  "tsx": "^4.23.13"
12
23
  },
13
24
  "pi": {
14
- "extensions": ["./extensions"]
25
+ "extensions": [
26
+ "./extensions"
27
+ ]
15
28
  },
16
29
  "peerDependencies": {
17
30
  "@earendil-works/pi-coding-agent": "*"
@@ -1,5 +0,0 @@
1
- # CodeGraph data files — local to each machine, not for committing.
2
- # Ignore everything in .codegraph/ except this file itself, so transient
3
- # files (the database, daemon.pid, sockets, logs) never show up in git.
4
- *
5
- !.gitignore