sae4u-memory 0.2.0__tar.gz
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.
- sae4u_memory-0.2.0/LICENSE +21 -0
- sae4u_memory-0.2.0/PKG-INFO +232 -0
- sae4u_memory-0.2.0/README.md +214 -0
- sae4u_memory-0.2.0/pyproject.toml +37 -0
- sae4u_memory-0.2.0/sae4u_memory/__init__.py +3 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/commands/memory-distill.md +71 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/docs/architecture.md +107 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/docs/episodic-bridge.md +118 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/docs/persona-customization.md +77 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/docs/tick-protocol.md +86 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/hooks/memory-tick.sh +63 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/prompts/session-close.md +39 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/prompts/session-open.md +45 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/rules/agents-no-delete-features.md +36 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/rules/grep-before-asking.md +30 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/rules/memory-architecture-minimalist.md +43 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/rules/memory-cleanup-interactive.md +28 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/rules/memory-tick-protocol.md +38 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/rules/no-hardcode.md +37 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/rules/no-session-state-confabulation.md +46 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/rules/post-write-review.md +62 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/rules/session-open-mirror-handoff.md +47 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/rules/verify-evidence-before-citing.md +32 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/templates/MEMORY.md.template +20 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/templates/feedback-rule.md.template +17 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/templates/project-fact.md.template +20 -0
- sae4u_memory-0.2.0/sae4u_memory/_assets/templates/tick-log.md.template +21 -0
- sae4u_memory-0.2.0/sae4u_memory/init.py +384 -0
- sae4u_memory-0.2.0/sae4u_memory/markdown_memory.py +240 -0
- sae4u_memory-0.2.0/sae4u_memory/memory.py +200 -0
- sae4u_memory-0.2.0/sae4u_memory/persona.py +152 -0
- sae4u_memory-0.2.0/sae4u_memory/server.py +220 -0
- sae4u_memory-0.2.0/sae4u_memory.egg-info/PKG-INFO +232 -0
- sae4u_memory-0.2.0/sae4u_memory.egg-info/SOURCES.txt +37 -0
- sae4u_memory-0.2.0/sae4u_memory.egg-info/dependency_links.txt +1 -0
- sae4u_memory-0.2.0/sae4u_memory.egg-info/entry_points.txt +2 -0
- sae4u_memory-0.2.0/sae4u_memory.egg-info/requires.txt +2 -0
- sae4u_memory-0.2.0/sae4u_memory.egg-info/top_level.txt +1 -0
- sae4u_memory-0.2.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Simple4u / Very Simple Solutions Inc.
|
|
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.
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sae4u-memory
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Persistent memory architecture for Claude — MCP server + hooks + rules + prompts. Part of the SAE4U OSS family.
|
|
5
|
+
Author-email: Simple4u <nests@simple4uhq.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Simple4uhq/sae4u-memory
|
|
8
|
+
Project-URL: Repository, https://github.com/Simple4uhq/sae4u-memory
|
|
9
|
+
Project-URL: Issues, https://github.com/Simple4uhq/sae4u-memory/issues
|
|
10
|
+
Project-URL: SisterProject, https://github.com/Simple4uhq/sae4u-agent
|
|
11
|
+
Keywords: claude,mcp,ai,memory,persistent,anthropic,sae4u
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: mcp>=1.0.0
|
|
16
|
+
Requires-Dist: pydantic>=2.0.0
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# SAE4U Memory
|
|
20
|
+
|
|
21
|
+
**A persistent memory architecture for Claude — MCP server + hooks +
|
|
22
|
+
rules + prompts + templates.** Free and open source. MIT.
|
|
23
|
+
|
|
24
|
+
Claude forgets you every time you close the chat. SAE4U Memory fixes
|
|
25
|
+
that, and goes further: it ships an opinionated *architecture* for
|
|
26
|
+
how persistent memory should be organized — not just storage, but
|
|
27
|
+
classification, periodic review, persona, cleanup, and session
|
|
28
|
+
continuity.
|
|
29
|
+
|
|
30
|
+
Part of the [SAE4U](https://github.com/Simple4uhq) OSS family
|
|
31
|
+
alongside [`sae4u-agent`](https://github.com/Simple4uhq/sae4u-agent).
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## What you get
|
|
36
|
+
|
|
37
|
+
### Core (works in any MCP client — Claude Desktop, Claude Code, etc.)
|
|
38
|
+
|
|
39
|
+
- **Two-corpus recall** — `recall(query)` searches BOTH SQLite facts
|
|
40
|
+
AND your markdown memory files (Claude Code auto-memory dirs +
|
|
41
|
+
`~/.sae4u-memory/`) in one call. No re-explaining yourself.
|
|
42
|
+
- **Hierarchical memory** — `remember(text, category)` with 5
|
|
43
|
+
categories: `user`, `feedback`, `project`, `reference`, `general`.
|
|
44
|
+
- **Session journals** — `journal(text)` for end-of-session notes
|
|
45
|
+
written to `~/.sae4u-memory/journals/YYYY-MM-DD.md` for human reading.
|
|
46
|
+
- **Customizable persona** — `persona.md` shapes the AI's identity.
|
|
47
|
+
Default: **Simple**, a peer-level coder friend who remembers things.
|
|
48
|
+
- **Local-first** — your memory lives in `~/.sae4u-memory/` on your
|
|
49
|
+
machine. Nothing leaves.
|
|
50
|
+
|
|
51
|
+
### Architecture (Claude Code with `--code-full`)
|
|
52
|
+
|
|
53
|
+
- **`hooks/memory-tick.sh`** — UserPromptSubmit hook that fires every
|
|
54
|
+
10 min and forces a brief memory review. Catches borderline
|
|
55
|
+
observations before they fall out of context.
|
|
56
|
+
- **`rules/`** — 10 universal feedback rules covering memory
|
|
57
|
+
discipline, session continuity, anti-confabulation, hardcode
|
|
58
|
+
prevention, post-write review.
|
|
59
|
+
- **`prompts/`** — opinionated session-open and session-close prompts
|
|
60
|
+
that pair with the architecture.
|
|
61
|
+
- **`templates/`** — formats for `MEMORY.md`, feedback rules,
|
|
62
|
+
project facts, and tick logs.
|
|
63
|
+
- **`commands/memory-distill.md`** — weekly distill ritual that
|
|
64
|
+
promotes tick-log items to permanent memory interactively.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Install
|
|
69
|
+
|
|
70
|
+
### Minimum (MCP only)
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
git clone https://github.com/Simple4uhq/sae4u-memory
|
|
74
|
+
cd sae4u-memory
|
|
75
|
+
pip install -e .
|
|
76
|
+
sae4u-memory init
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
This wires the MCP server into Claude Desktop and Claude Code, and
|
|
80
|
+
appends a guidance block to `~/.claude/CLAUDE.md`. Restart your
|
|
81
|
+
client and the memory tools are live.
|
|
82
|
+
|
|
83
|
+
### Full architecture (Claude Code only)
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
sae4u-memory init --code-full
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Adds:
|
|
90
|
+
- Copy `hooks/memory-tick.sh` → `~/.claude/hooks/memory-tick.sh`
|
|
91
|
+
- Register the hook in `~/.claude/settings.json` under `hooks.UserPromptSubmit`
|
|
92
|
+
- Scaffold `~/.sae4u-memory/MEMORY.md`
|
|
93
|
+
- Drop default rules into `~/.sae4u-memory/rules/`
|
|
94
|
+
|
|
95
|
+
Restart Claude Code. The tick will fire every 10 min and instruct the
|
|
96
|
+
AI to review and classify recent context.
|
|
97
|
+
|
|
98
|
+
### Flags
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
sae4u-memory init --desktop # Claude Desktop only
|
|
102
|
+
sae4u-memory init --code # Claude Code MCP only
|
|
103
|
+
sae4u-memory init --code-full # Claude Code MCP + hook + scaffold
|
|
104
|
+
sae4u-memory init --no-claude-md # skip CLAUDE.md guidance block
|
|
105
|
+
sae4u-memory init --dry-run # preview changes without applying
|
|
106
|
+
sae4u-memory uninstall # remove all config entries
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Tools exposed (MCP)
|
|
112
|
+
|
|
113
|
+
| Tool | Purpose |
|
|
114
|
+
|------|---------|
|
|
115
|
+
| `remember(text, category)` | Save a fact to long-term memory |
|
|
116
|
+
| `recall(query, limit, sources)` | Search across SQLite + markdown roots. `sources` = `all` / `sqlite` / `markdown` |
|
|
117
|
+
| `list_memories(category)` | Browse what's remembered |
|
|
118
|
+
| `forget(memory_id)` | Delete a wrong/outdated memory |
|
|
119
|
+
| `journal(text)` | Write an end-of-session note |
|
|
120
|
+
| `recent_journals(days)` | Read recent journal entries |
|
|
121
|
+
| `get_persona()` | Return full persona + user context |
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## How memory is organized
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
~/.sae4u-memory/
|
|
129
|
+
├── persona.md # Edit to customize behavior
|
|
130
|
+
├── memory.db # SQLite + FTS5
|
|
131
|
+
├── MEMORY.md # Index of permanent files (loaded at session start)
|
|
132
|
+
├── user/ # User context loaded by get_persona()
|
|
133
|
+
│ ├── identity.md
|
|
134
|
+
│ ├── projects.md
|
|
135
|
+
│ └── preferences.md
|
|
136
|
+
├── tick/ # Day-rolling tick log (NOT indexed in MEMORY.md)
|
|
137
|
+
│ └── 2026-05-07.md
|
|
138
|
+
├── archive/ # User-confirmed archived files
|
|
139
|
+
├── journals/ # End-of-session narratives
|
|
140
|
+
│ └── 2026-05-07.md
|
|
141
|
+
└── .last_tick # Epoch of last memory tick
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The 4-type classification (`user`, `feedback`, `project`, `reference`)
|
|
145
|
+
plus the tick / permanent split is the architectural core. See
|
|
146
|
+
[`architecture.md`](sae4u_memory/_assets/docs/architecture.md) for the
|
|
147
|
+
full explanation.
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Documentation
|
|
152
|
+
|
|
153
|
+
All architecture content lives under [`sae4u_memory/_assets/`](sae4u_memory/_assets/) so it ships with the wheel.
|
|
154
|
+
|
|
155
|
+
- [`docs/architecture.md`](sae4u_memory/_assets/docs/architecture.md) —
|
|
156
|
+
5 concepts, file layout, the 4 types, what NOT to save
|
|
157
|
+
- [`docs/tick-protocol.md`](sae4u_memory/_assets/docs/tick-protocol.md) —
|
|
158
|
+
how the 10-min hook works, what gets written where
|
|
159
|
+
- [`docs/persona-customization.md`](sae4u_memory/_assets/docs/persona-customization.md) —
|
|
160
|
+
what's editable, what's loaded at session start
|
|
161
|
+
- [`docs/episodic-bridge.md`](sae4u_memory/_assets/docs/episodic-bridge.md) —
|
|
162
|
+
optional pattern for users with a remote dev box
|
|
163
|
+
- [`prompts/session-open.md`](sae4u_memory/_assets/prompts/session-open.md) —
|
|
164
|
+
paste this at session start
|
|
165
|
+
- [`prompts/session-close.md`](sae4u_memory/_assets/prompts/session-close.md) —
|
|
166
|
+
paste this at session end
|
|
167
|
+
- [`commands/memory-distill.md`](sae4u_memory/_assets/commands/memory-distill.md) —
|
|
168
|
+
weekly cleanup ritual
|
|
169
|
+
- [`rules/`](sae4u_memory/_assets/rules/) — 10 universal feedback rules
|
|
170
|
+
- [`hooks/memory-tick.sh`](sae4u_memory/_assets/hooks/memory-tick.sh) —
|
|
171
|
+
the UserPromptSubmit hook itself
|
|
172
|
+
- [`templates/`](sae4u_memory/_assets/templates/) — MEMORY.md, feedback rule, project fact, tick log
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Customize
|
|
177
|
+
|
|
178
|
+
Edit `~/.sae4u-memory/persona.md` to change the AI's identity, voice,
|
|
179
|
+
and rules. Edit `~/.sae4u-memory/user/*.md` to pre-fill what the AI
|
|
180
|
+
knows about you. Both are loaded fresh on every session start.
|
|
181
|
+
|
|
182
|
+
The default persona is **Simple** — a peer-level coder friend.
|
|
183
|
+
Rename, rewrite, or replace as you see fit.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Environment
|
|
188
|
+
|
|
189
|
+
- `SAE4U_MEMORY_HOME` — override the data directory
|
|
190
|
+
(default `~/.sae4u-memory`)
|
|
191
|
+
- `SAE4U_MARKDOWN_ROOTS` — colon-separated list of markdown roots
|
|
192
|
+
that `recall()` should search. Defaults to all Claude Code
|
|
193
|
+
auto-memory dirs (globbed from `~/.claude/projects/*/memory/`)
|
|
194
|
+
plus `SAE4U_MEMORY_HOME`.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
## Uninstall
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
sae4u-memory uninstall # remove configs from Claude Desktop + Code
|
|
202
|
+
rm ~/.claude/hooks/memory-tick.sh # if you ran --code-full
|
|
203
|
+
rm -rf ~/.sae4u-memory # optional — also delete stored memories
|
|
204
|
+
pip uninstall sae4u-memory
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Status
|
|
210
|
+
|
|
211
|
+
**v0.2.0** — memory architecture release. Full export of the pattern
|
|
212
|
+
the project authors run in production: hooks + rules + prompts +
|
|
213
|
+
templates + persona + extended `init` for Claude Code. Renamed from
|
|
214
|
+
`simple4u-memory` to align with the SAE4U OSS family.
|
|
215
|
+
|
|
216
|
+
Previous: v0.1.3 (under the old name) shipped two-corpus recall and
|
|
217
|
+
a working-rules persona. v0.1.x users on PyPI: install fresh from
|
|
218
|
+
this repo; the old package is no longer maintained.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Sister project
|
|
223
|
+
|
|
224
|
+
- [`sae4u-agent`](https://github.com/Simple4uhq/sae4u-agent) —
|
|
225
|
+
multi-tenant control plane and agent runtime template. The
|
|
226
|
+
agents need memory; this is that memory.
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
MIT.
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# SAE4U Memory
|
|
2
|
+
|
|
3
|
+
**A persistent memory architecture for Claude — MCP server + hooks +
|
|
4
|
+
rules + prompts + templates.** Free and open source. MIT.
|
|
5
|
+
|
|
6
|
+
Claude forgets you every time you close the chat. SAE4U Memory fixes
|
|
7
|
+
that, and goes further: it ships an opinionated *architecture* for
|
|
8
|
+
how persistent memory should be organized — not just storage, but
|
|
9
|
+
classification, periodic review, persona, cleanup, and session
|
|
10
|
+
continuity.
|
|
11
|
+
|
|
12
|
+
Part of the [SAE4U](https://github.com/Simple4uhq) OSS family
|
|
13
|
+
alongside [`sae4u-agent`](https://github.com/Simple4uhq/sae4u-agent).
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## What you get
|
|
18
|
+
|
|
19
|
+
### Core (works in any MCP client — Claude Desktop, Claude Code, etc.)
|
|
20
|
+
|
|
21
|
+
- **Two-corpus recall** — `recall(query)` searches BOTH SQLite facts
|
|
22
|
+
AND your markdown memory files (Claude Code auto-memory dirs +
|
|
23
|
+
`~/.sae4u-memory/`) in one call. No re-explaining yourself.
|
|
24
|
+
- **Hierarchical memory** — `remember(text, category)` with 5
|
|
25
|
+
categories: `user`, `feedback`, `project`, `reference`, `general`.
|
|
26
|
+
- **Session journals** — `journal(text)` for end-of-session notes
|
|
27
|
+
written to `~/.sae4u-memory/journals/YYYY-MM-DD.md` for human reading.
|
|
28
|
+
- **Customizable persona** — `persona.md` shapes the AI's identity.
|
|
29
|
+
Default: **Simple**, a peer-level coder friend who remembers things.
|
|
30
|
+
- **Local-first** — your memory lives in `~/.sae4u-memory/` on your
|
|
31
|
+
machine. Nothing leaves.
|
|
32
|
+
|
|
33
|
+
### Architecture (Claude Code with `--code-full`)
|
|
34
|
+
|
|
35
|
+
- **`hooks/memory-tick.sh`** — UserPromptSubmit hook that fires every
|
|
36
|
+
10 min and forces a brief memory review. Catches borderline
|
|
37
|
+
observations before they fall out of context.
|
|
38
|
+
- **`rules/`** — 10 universal feedback rules covering memory
|
|
39
|
+
discipline, session continuity, anti-confabulation, hardcode
|
|
40
|
+
prevention, post-write review.
|
|
41
|
+
- **`prompts/`** — opinionated session-open and session-close prompts
|
|
42
|
+
that pair with the architecture.
|
|
43
|
+
- **`templates/`** — formats for `MEMORY.md`, feedback rules,
|
|
44
|
+
project facts, and tick logs.
|
|
45
|
+
- **`commands/memory-distill.md`** — weekly distill ritual that
|
|
46
|
+
promotes tick-log items to permanent memory interactively.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
### Minimum (MCP only)
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git clone https://github.com/Simple4uhq/sae4u-memory
|
|
56
|
+
cd sae4u-memory
|
|
57
|
+
pip install -e .
|
|
58
|
+
sae4u-memory init
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This wires the MCP server into Claude Desktop and Claude Code, and
|
|
62
|
+
appends a guidance block to `~/.claude/CLAUDE.md`. Restart your
|
|
63
|
+
client and the memory tools are live.
|
|
64
|
+
|
|
65
|
+
### Full architecture (Claude Code only)
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
sae4u-memory init --code-full
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Adds:
|
|
72
|
+
- Copy `hooks/memory-tick.sh` → `~/.claude/hooks/memory-tick.sh`
|
|
73
|
+
- Register the hook in `~/.claude/settings.json` under `hooks.UserPromptSubmit`
|
|
74
|
+
- Scaffold `~/.sae4u-memory/MEMORY.md`
|
|
75
|
+
- Drop default rules into `~/.sae4u-memory/rules/`
|
|
76
|
+
|
|
77
|
+
Restart Claude Code. The tick will fire every 10 min and instruct the
|
|
78
|
+
AI to review and classify recent context.
|
|
79
|
+
|
|
80
|
+
### Flags
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
sae4u-memory init --desktop # Claude Desktop only
|
|
84
|
+
sae4u-memory init --code # Claude Code MCP only
|
|
85
|
+
sae4u-memory init --code-full # Claude Code MCP + hook + scaffold
|
|
86
|
+
sae4u-memory init --no-claude-md # skip CLAUDE.md guidance block
|
|
87
|
+
sae4u-memory init --dry-run # preview changes without applying
|
|
88
|
+
sae4u-memory uninstall # remove all config entries
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Tools exposed (MCP)
|
|
94
|
+
|
|
95
|
+
| Tool | Purpose |
|
|
96
|
+
|------|---------|
|
|
97
|
+
| `remember(text, category)` | Save a fact to long-term memory |
|
|
98
|
+
| `recall(query, limit, sources)` | Search across SQLite + markdown roots. `sources` = `all` / `sqlite` / `markdown` |
|
|
99
|
+
| `list_memories(category)` | Browse what's remembered |
|
|
100
|
+
| `forget(memory_id)` | Delete a wrong/outdated memory |
|
|
101
|
+
| `journal(text)` | Write an end-of-session note |
|
|
102
|
+
| `recent_journals(days)` | Read recent journal entries |
|
|
103
|
+
| `get_persona()` | Return full persona + user context |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## How memory is organized
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
~/.sae4u-memory/
|
|
111
|
+
├── persona.md # Edit to customize behavior
|
|
112
|
+
├── memory.db # SQLite + FTS5
|
|
113
|
+
├── MEMORY.md # Index of permanent files (loaded at session start)
|
|
114
|
+
├── user/ # User context loaded by get_persona()
|
|
115
|
+
│ ├── identity.md
|
|
116
|
+
│ ├── projects.md
|
|
117
|
+
│ └── preferences.md
|
|
118
|
+
├── tick/ # Day-rolling tick log (NOT indexed in MEMORY.md)
|
|
119
|
+
│ └── 2026-05-07.md
|
|
120
|
+
├── archive/ # User-confirmed archived files
|
|
121
|
+
├── journals/ # End-of-session narratives
|
|
122
|
+
│ └── 2026-05-07.md
|
|
123
|
+
└── .last_tick # Epoch of last memory tick
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The 4-type classification (`user`, `feedback`, `project`, `reference`)
|
|
127
|
+
plus the tick / permanent split is the architectural core. See
|
|
128
|
+
[`architecture.md`](sae4u_memory/_assets/docs/architecture.md) for the
|
|
129
|
+
full explanation.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Documentation
|
|
134
|
+
|
|
135
|
+
All architecture content lives under [`sae4u_memory/_assets/`](sae4u_memory/_assets/) so it ships with the wheel.
|
|
136
|
+
|
|
137
|
+
- [`docs/architecture.md`](sae4u_memory/_assets/docs/architecture.md) —
|
|
138
|
+
5 concepts, file layout, the 4 types, what NOT to save
|
|
139
|
+
- [`docs/tick-protocol.md`](sae4u_memory/_assets/docs/tick-protocol.md) —
|
|
140
|
+
how the 10-min hook works, what gets written where
|
|
141
|
+
- [`docs/persona-customization.md`](sae4u_memory/_assets/docs/persona-customization.md) —
|
|
142
|
+
what's editable, what's loaded at session start
|
|
143
|
+
- [`docs/episodic-bridge.md`](sae4u_memory/_assets/docs/episodic-bridge.md) —
|
|
144
|
+
optional pattern for users with a remote dev box
|
|
145
|
+
- [`prompts/session-open.md`](sae4u_memory/_assets/prompts/session-open.md) —
|
|
146
|
+
paste this at session start
|
|
147
|
+
- [`prompts/session-close.md`](sae4u_memory/_assets/prompts/session-close.md) —
|
|
148
|
+
paste this at session end
|
|
149
|
+
- [`commands/memory-distill.md`](sae4u_memory/_assets/commands/memory-distill.md) —
|
|
150
|
+
weekly cleanup ritual
|
|
151
|
+
- [`rules/`](sae4u_memory/_assets/rules/) — 10 universal feedback rules
|
|
152
|
+
- [`hooks/memory-tick.sh`](sae4u_memory/_assets/hooks/memory-tick.sh) —
|
|
153
|
+
the UserPromptSubmit hook itself
|
|
154
|
+
- [`templates/`](sae4u_memory/_assets/templates/) — MEMORY.md, feedback rule, project fact, tick log
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Customize
|
|
159
|
+
|
|
160
|
+
Edit `~/.sae4u-memory/persona.md` to change the AI's identity, voice,
|
|
161
|
+
and rules. Edit `~/.sae4u-memory/user/*.md` to pre-fill what the AI
|
|
162
|
+
knows about you. Both are loaded fresh on every session start.
|
|
163
|
+
|
|
164
|
+
The default persona is **Simple** — a peer-level coder friend.
|
|
165
|
+
Rename, rewrite, or replace as you see fit.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Environment
|
|
170
|
+
|
|
171
|
+
- `SAE4U_MEMORY_HOME` — override the data directory
|
|
172
|
+
(default `~/.sae4u-memory`)
|
|
173
|
+
- `SAE4U_MARKDOWN_ROOTS` — colon-separated list of markdown roots
|
|
174
|
+
that `recall()` should search. Defaults to all Claude Code
|
|
175
|
+
auto-memory dirs (globbed from `~/.claude/projects/*/memory/`)
|
|
176
|
+
plus `SAE4U_MEMORY_HOME`.
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## Uninstall
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
sae4u-memory uninstall # remove configs from Claude Desktop + Code
|
|
184
|
+
rm ~/.claude/hooks/memory-tick.sh # if you ran --code-full
|
|
185
|
+
rm -rf ~/.sae4u-memory # optional — also delete stored memories
|
|
186
|
+
pip uninstall sae4u-memory
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Status
|
|
192
|
+
|
|
193
|
+
**v0.2.0** — memory architecture release. Full export of the pattern
|
|
194
|
+
the project authors run in production: hooks + rules + prompts +
|
|
195
|
+
templates + persona + extended `init` for Claude Code. Renamed from
|
|
196
|
+
`simple4u-memory` to align with the SAE4U OSS family.
|
|
197
|
+
|
|
198
|
+
Previous: v0.1.3 (under the old name) shipped two-corpus recall and
|
|
199
|
+
a working-rules persona. v0.1.x users on PyPI: install fresh from
|
|
200
|
+
this repo; the old package is no longer maintained.
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Sister project
|
|
205
|
+
|
|
206
|
+
- [`sae4u-agent`](https://github.com/Simple4uhq/sae4u-agent) —
|
|
207
|
+
multi-tenant control plane and agent runtime template. The
|
|
208
|
+
agents need memory; this is that memory.
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
MIT.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sae4u-memory"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "Persistent memory architecture for Claude — MCP server + hooks + rules + prompts. Part of the SAE4U OSS family."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = { text = "MIT" }
|
|
8
|
+
authors = [{ name = "Simple4u", email = "nests@simple4uhq.com" }]
|
|
9
|
+
keywords = ["claude", "mcp", "ai", "memory", "persistent", "anthropic", "sae4u"]
|
|
10
|
+
dependencies = [
|
|
11
|
+
"mcp>=1.0.0",
|
|
12
|
+
"pydantic>=2.0.0",
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
[project.scripts]
|
|
16
|
+
sae4u-memory = "sae4u_memory.server:main"
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Homepage = "https://github.com/Simple4uhq/sae4u-memory"
|
|
20
|
+
Repository = "https://github.com/Simple4uhq/sae4u-memory"
|
|
21
|
+
Issues = "https://github.com/Simple4uhq/sae4u-memory/issues"
|
|
22
|
+
SisterProject = "https://github.com/Simple4uhq/sae4u-agent"
|
|
23
|
+
|
|
24
|
+
[build-system]
|
|
25
|
+
requires = ["setuptools>=61.0"]
|
|
26
|
+
build-backend = "setuptools.build_meta"
|
|
27
|
+
|
|
28
|
+
[tool.setuptools.packages.find]
|
|
29
|
+
where = ["."]
|
|
30
|
+
include = ["sae4u_memory*"]
|
|
31
|
+
|
|
32
|
+
[tool.setuptools.package-data]
|
|
33
|
+
sae4u_memory = [
|
|
34
|
+
"_assets/**/*.sh",
|
|
35
|
+
"_assets/**/*.md",
|
|
36
|
+
"_assets/**/*.template",
|
|
37
|
+
]
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# /memory-distill — weekly memory cleanup
|
|
2
|
+
|
|
3
|
+
A periodic ritual: read the rolling tick log, propose promotions to
|
|
4
|
+
permanent memory, and let the user confirm what to keep, archive,
|
|
5
|
+
or forget.
|
|
6
|
+
|
|
7
|
+
## When to run
|
|
8
|
+
|
|
9
|
+
- Weekly (e.g. Sunday evening or Monday morning).
|
|
10
|
+
- After heavy context-creation periods (a sprint close, a launch).
|
|
11
|
+
- When tick log files have piled up beyond what a quick scan can
|
|
12
|
+
digest (~5+ days of unmerged ticks).
|
|
13
|
+
|
|
14
|
+
## What it does
|
|
15
|
+
|
|
16
|
+
1. **Read the tick logs** — all files under `~/.sae4u-memory/tick/`
|
|
17
|
+
that haven't been distilled yet, plus any new permanent files
|
|
18
|
+
added since last distill.
|
|
19
|
+
2. **Cluster** by topic (use the 4 types — user/feedback/project/
|
|
20
|
+
reference — as a first cut, then group within type by topic).
|
|
21
|
+
3. **Propose actions** for each cluster. Three outcomes per item:
|
|
22
|
+
- **Promote** to a permanent file (new or merge into existing).
|
|
23
|
+
Update MEMORY.md.
|
|
24
|
+
- **Drop** — was tick-only noise; not worth keeping.
|
|
25
|
+
- **Keep in tick log** — borderline; see again next week.
|
|
26
|
+
4. **Surface for confirmation.** The user reviews the proposals
|
|
27
|
+
and accepts / rejects each. Never auto-promote, never
|
|
28
|
+
auto-forget — see `rules/memory-cleanup-interactive.md`.
|
|
29
|
+
5. **Apply** the confirmed actions:
|
|
30
|
+
- Move tick entries to permanent files
|
|
31
|
+
- Update MEMORY.md index
|
|
32
|
+
- Archive distilled tick log file (e.g. rename to
|
|
33
|
+
`tick/distilled/2026-05-07.md` or compress)
|
|
34
|
+
6. **Stale check** for permanent memory — entries not referenced
|
|
35
|
+
in N weeks. Ask: "still interesting or forget?" Don't volunteer
|
|
36
|
+
to delete; just surface the question.
|
|
37
|
+
|
|
38
|
+
## How the AI presents this
|
|
39
|
+
|
|
40
|
+
Group by topic, not by file. The user shouldn't have to read 40
|
|
41
|
+
individual proposals — bundle related ticks into "here are 5 things
|
|
42
|
+
about X, what shape do you want them in?"
|
|
43
|
+
|
|
44
|
+
Keep the proposals concrete:
|
|
45
|
+
|
|
46
|
+
> ### Topic: testing approach
|
|
47
|
+
>
|
|
48
|
+
> Across 4 ticks last week:
|
|
49
|
+
> - 2026-05-02 — "don't mock the database in integration tests"
|
|
50
|
+
> - 2026-05-04 — confirmed "TDD for new API endpoints"
|
|
51
|
+
> - 2026-05-05 — "use testcontainers for postgres in CI"
|
|
52
|
+
> - 2026-05-06 — "snapshot tests OK for component output"
|
|
53
|
+
>
|
|
54
|
+
> Propose: promote to `feedback_testing_approach.md` consolidating
|
|
55
|
+
> all four. Drop the per-tick entries from tick log.
|
|
56
|
+
>
|
|
57
|
+
> Accept / Reject?
|
|
58
|
+
|
|
59
|
+
## Implementation
|
|
60
|
+
|
|
61
|
+
This is a slash-command spec (Claude Code), not an automated job.
|
|
62
|
+
The AI reads it as guidance and runs through the steps interactively.
|
|
63
|
+
|
|
64
|
+
You can wire it into a routine:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Weekly cron — reminds you to run distill in next session
|
|
68
|
+
0 18 * * SUN echo "/memory-distill" | tee -a ~/.sae4u-memory/distill-due.log
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or just rely on calendar / habit.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
`sae4u-memory` is built around five concepts:
|
|
4
|
+
|
|
5
|
+
1. **Two-corpus recall** — semantic-ish search over SQLite facts
|
|
6
|
+
(written via `remember`) AND markdown files in your auto-memory
|
|
7
|
+
dirs and `~/.sae4u-memory/`.
|
|
8
|
+
2. **MEMORY.md as the index** — a single table of contents pointing
|
|
9
|
+
to per-topic files. Loaded into context at session start.
|
|
10
|
+
3. **4-type classification** — every memory is one of `user`,
|
|
11
|
+
`feedback`, `project`, or `reference`. Each type has different
|
|
12
|
+
handling and shelf life.
|
|
13
|
+
4. **Tick / permanent split** — borderline observations go to a
|
|
14
|
+
day-rolling tick log (NOT indexed in MEMORY.md). Foundational
|
|
15
|
+
items go directly to permanent files indexed in MEMORY.md.
|
|
16
|
+
5. **Persona at session start** — `get_persona()` returns a
|
|
17
|
+
working-rules document plus user context, loaded fresh.
|
|
18
|
+
|
|
19
|
+
## File layout
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
~/.sae4u-memory/
|
|
23
|
+
├── memory.db # SQLite facts written via remember()
|
|
24
|
+
├── persona.md # AI's identity + rules (edit to customize)
|
|
25
|
+
├── MEMORY.md # Index of permanent files (loaded at session start)
|
|
26
|
+
├── user/ # User context loaded by get_persona()
|
|
27
|
+
│ ├── identity.md
|
|
28
|
+
│ ├── projects.md
|
|
29
|
+
│ └── preferences.md
|
|
30
|
+
├── tick/ # Day-rolling tick log
|
|
31
|
+
│ └── 2026-05-07.md
|
|
32
|
+
├── archive/ # User-confirmed archived files (optional)
|
|
33
|
+
├── journals/ # End-of-session narratives
|
|
34
|
+
│ └── 2026-05-07.md
|
|
35
|
+
└── .last_tick # Epoch timestamp of last memory tick
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
In Claude Code, the additional auto-memory dir lives at
|
|
39
|
+
`~/.claude/projects/<project-slug>/memory/` — `recall()` searches
|
|
40
|
+
that too, by default.
|
|
41
|
+
|
|
42
|
+
## The 4 types
|
|
43
|
+
|
|
44
|
+
### `user`
|
|
45
|
+
Facts about who the user is — role, goals, knowledge, responsibilities,
|
|
46
|
+
preferences. Helps tailor future behavior. Does NOT decay quickly.
|
|
47
|
+
|
|
48
|
+
> Example: "Senior backend engineer, 10 years Go, new to React.
|
|
49
|
+
> Prefers explanation in terms of backend analogues."
|
|
50
|
+
|
|
51
|
+
### `feedback`
|
|
52
|
+
Corrections AND validations. Every time the user pushes back ("don't
|
|
53
|
+
do X") OR confirms a non-obvious approach worked ("yes exactly,
|
|
54
|
+
keep doing that"). Lead with the rule, then **Why:** and
|
|
55
|
+
**How to apply:** lines.
|
|
56
|
+
|
|
57
|
+
> Example: see `rules/no-hardcode.md`
|
|
58
|
+
|
|
59
|
+
### `project`
|
|
60
|
+
Ongoing work, decisions, motivations, deadlines. **Decays fast** —
|
|
61
|
+
convert relative dates to absolute ones at write time
|
|
62
|
+
("Thursday" → "2026-03-05"). Re-evaluate periodically.
|
|
63
|
+
|
|
64
|
+
> Example: "Merge freeze begins 2026-03-05 for mobile release.
|
|
65
|
+
> Flag any non-critical PR scheduled after."
|
|
66
|
+
|
|
67
|
+
### `reference`
|
|
68
|
+
Pointers to external systems where information lives. Slack channels,
|
|
69
|
+
ticket queues, dashboards, documentation portals. Tells the AI where
|
|
70
|
+
to look — does not duplicate the content.
|
|
71
|
+
|
|
72
|
+
> Example: "Bugs tracked in Linear project INGEST. Check there for
|
|
73
|
+
> pipeline issues."
|
|
74
|
+
|
|
75
|
+
## What NOT to save
|
|
76
|
+
|
|
77
|
+
- Code patterns, conventions, file paths, project structure — these
|
|
78
|
+
can be re-derived from reading the current state.
|
|
79
|
+
- Git history or recent changes — `git log` / `git blame` are
|
|
80
|
+
authoritative.
|
|
81
|
+
- Debugging recipes — the fix is in the code; the commit message
|
|
82
|
+
has the context.
|
|
83
|
+
- Anything already documented in CLAUDE.md.
|
|
84
|
+
- Ephemeral task state — that's what the conversation is for.
|
|
85
|
+
|
|
86
|
+
These exclusions apply even when the user explicitly asks. If they
|
|
87
|
+
ask for an "activity summary", ask what was *surprising* — that's
|
|
88
|
+
the part worth keeping.
|
|
89
|
+
|
|
90
|
+
## How recall works
|
|
91
|
+
|
|
92
|
+
`recall(query)` returns a merged stream from two sources:
|
|
93
|
+
|
|
94
|
+
1. **SQLite (FTS5):** facts written with `remember(text, category)`.
|
|
95
|
+
Indexed by full-text search. Good for "recall what I told you about X".
|
|
96
|
+
2. **Markdown:** files under `~/.sae4u-memory/` and Claude Code
|
|
97
|
+
auto-memory dirs. Ranked by weighted keyword scoring with a
|
|
98
|
+
recency bonus for tick logs. Good for "what's the rule about Y"
|
|
99
|
+
and "what did I write down recently".
|
|
100
|
+
|
|
101
|
+
Filter sources via `sources="sqlite"` or `sources="markdown"` if you
|
|
102
|
+
want only one corpus.
|
|
103
|
+
|
|
104
|
+
## Cleanup
|
|
105
|
+
|
|
106
|
+
Don't auto-forget. Use `/memory-distill` (see `commands/memory-distill.md`)
|
|
107
|
+
periodically. The user has agency over what gets archived or deleted.
|