@askjo/pi-mem 1.0.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/README.md +78 -0
- package/index.ts +680 -0
- package/lib.ts +304 -0
- package/logo-dark.png +0 -0
- package/logo.png +0 -0
- package/package.json +47 -0
- package/tests/config.test.ts +71 -0
- package/tests/date-helpers.test.ts +72 -0
- package/tests/file-helpers.test.ts +65 -0
- package/tests/helpers.ts +31 -0
- package/tests/memory-context.test.ts +150 -0
- package/tests/scratchpad.test.ts +191 -0
- package/tests/search.test.ts +126 -0
- package/tests/session-scanner.test.ts +206 -0
package/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="logo-dark.png" />
|
|
4
|
+
<source media="(prefers-color-scheme: light)" srcset="logo.png" />
|
|
5
|
+
<img src="logo.png" alt="pi-mem" width="300" />
|
|
6
|
+
</picture>
|
|
7
|
+
</p>
|
|
8
|
+
<h1 align="center">pi-mem</h1>
|
|
9
|
+
<p align="center"><em>surprisingly useful daily memory for the <a href="https://pi.dev/">pi</a> coding agent</em></p>
|
|
10
|
+
<p align="center"><sub><a href="https://pradeep.md/2026/02/11/pi-mem.html">Read the blog post</a></sub></p>
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<p align="center"><sub>Inspired by <a href="https://openclaw.ai">OpenClaw</a>'s approach to agent memory.</sub></p>
|
|
15
|
+
|
|
16
|
+
## Layout
|
|
17
|
+
|
|
18
|
+
Memory files live under `~/.pi/agent/memory/` (override with `PI_MEMORY_DIR`):
|
|
19
|
+
|
|
20
|
+
| Path | Purpose |
|
|
21
|
+
|------|---------|
|
|
22
|
+
| `MEMORY.md` | Curated long-term memory (decisions, preferences, durable facts) |
|
|
23
|
+
| `SCRATCHPAD.md` | Checklist of things to keep in mind / fix later |
|
|
24
|
+
| `daily/YYYY-MM-DD.md` | Daily append-only log (today + yesterday loaded at session start) |
|
|
25
|
+
| `notes/*.md` | LLM-created files (lessons, self-review, reference material, etc.) |
|
|
26
|
+
|
|
27
|
+
Identity and behavioral files (e.g. `SOUL.md`, `AGENTS.md`, `HEARTBEAT.md`) can also live in the memory directory and be injected into context via `PI_CONTEXT_FILES`.
|
|
28
|
+
|
|
29
|
+
## Tools
|
|
30
|
+
|
|
31
|
+
| Tool | Description |
|
|
32
|
+
|------|-------------|
|
|
33
|
+
| `memory_write` | Write to `long_term` (MEMORY.md), `daily` (today's log), or `note` (notes/filename). Supports `append` and `overwrite` modes. |
|
|
34
|
+
| `memory_read` | Read MEMORY.md (`long_term`), SCRATCHPAD.md (`scratchpad`), daily logs (`daily`), notes (`note`), any root file (`file`), or list everything (`list`). |
|
|
35
|
+
| `memory_search` | Search across all files — filenames and content. Case-insensitive keyword search across root, notes/, and daily/. |
|
|
36
|
+
| `scratchpad` | Manage a checklist: `add`, `done`, `undo`, `clear_done`, `list`. |
|
|
37
|
+
|
|
38
|
+
## Context Injection
|
|
39
|
+
|
|
40
|
+
The following are automatically injected into the system prompt before every agent turn:
|
|
41
|
+
|
|
42
|
+
- Files listed in `PI_CONTEXT_FILES` (e.g. `SOUL.md,AGENTS.md,HEARTBEAT.md`)
|
|
43
|
+
- `MEMORY.md`
|
|
44
|
+
- `SCRATCHPAD.md` (open items only)
|
|
45
|
+
- Today's and yesterday's daily logs
|
|
46
|
+
|
|
47
|
+
Files in `notes/` and older daily logs are **not** injected — they're accessible on-demand via `memory_search` and `memory_read`.
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
|
|
51
|
+
| Env Var | Default | Description |
|
|
52
|
+
|---------|---------|-------------|
|
|
53
|
+
| `PI_MEMORY_DIR` | `~/.pi/agent/memory/` | Root directory for all memory files |
|
|
54
|
+
| `PI_DAILY_DIR` | `$PI_MEMORY_DIR/daily/` | Directory for daily logs |
|
|
55
|
+
| `PI_CONTEXT_FILES` | *(empty)* | Comma-separated list of extra files to inject into context (e.g. `SOUL.md,AGENTS.md,HEARTBEAT.md`) |
|
|
56
|
+
| `PI_AUTOCOMMIT` | `false` | When `1` or `true`, auto-commit to git after every write |
|
|
57
|
+
|
|
58
|
+
## Dashboard Widget
|
|
59
|
+
|
|
60
|
+
An auto-generated "Last 24h" summary is shown on session start and switch:
|
|
61
|
+
- Scans recent session files for titles, costs, and sub-agent counts
|
|
62
|
+
- Groups by topic using an LLM call (falls back to flat list)
|
|
63
|
+
- Rebuilt every 15 minutes in the background
|
|
64
|
+
- Also shows open scratchpad items
|
|
65
|
+
|
|
66
|
+
## Related
|
|
67
|
+
|
|
68
|
+
- **[pi-reflect](https://github.com/jo-inc/pi-reflect)** — Self-improving reflection engine for pi. Analyzes recent conversations and iterates on memory, behavioral rules, and identity files. Pairs naturally with pi-mem.
|
|
69
|
+
|
|
70
|
+
## Installation
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pi install git:github.com/jo-inc/pi-mem
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## License
|
|
77
|
+
|
|
78
|
+
MIT
|