@pi-unipi/memory 0.1.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.
@@ -0,0 +1,151 @@
1
+ ---
2
+ name: memory
3
+ description: >
4
+ Persistent cross-session memory management. Store and retrieve user preferences,
5
+ project decisions, code patterns, and conversation summaries across sessions.
6
+ Use when you need to remember something important or recall past context.
7
+ allowed-tools:
8
+ - memory_store
9
+ - memory_search
10
+ - memory_delete
11
+ - memory_list
12
+ - global_memory_store
13
+ - global_memory_search
14
+ - global_memory_list
15
+ - read
16
+ ---
17
+
18
+ # Memory
19
+
20
+ Persistent cross-session memory for Pi coding agent. Memories survive session restarts, compaction, and context resets.
21
+
22
+ ## When to Store Memory
23
+
24
+ Store memory when you encounter:
25
+
26
+ | Type | Examples | Title Format |
27
+ |------|----------|--------------|
28
+ | **Preference** | User likes tabs, prefers functional style | `style_typescript_prefer_tabs` |
29
+ | **Decision** | Chose PostgreSQL over MySQL, JWT over sessions | `db_postgres_chosen_over_mysql` |
30
+ | **Pattern** | How auth is structured, API naming conventions | `api_rest_versioning_v2` |
31
+ | **Summary** | Key findings from debugging, research results | `perf_slow_query_root_cause` |
32
+
33
+ ## Naming Convention
34
+
35
+ **Format:** `<most_important>_<less_important>_<lesser>`
36
+
37
+ **Rules:**
38
+ - Use underscores, not hyphens
39
+ - Start with category (style, db, auth, api, arch, etc.)
40
+ - Be specific: `auth_jwt_prefer_refresh_tokens` not `auth_tokens`
41
+ - Keep under 60 characters
42
+
43
+ **Good titles:**
44
+ - `style_typescript_strict_mode_always`
45
+ - `db_postgres_use_connection_pooling`
46
+ - `arch_api_versioning_v2_breaking`
47
+ - `perf_cache_redis_for_sessions`
48
+
49
+ **Bad titles:**
50
+ - `auth` (too vague)
51
+ - `User prefers tabs` (not snake_case)
52
+ - `auth-jwt-refresh` (hyphens, not underscores)
53
+
54
+ ## When to Search Memory
55
+
56
+ Search memory when:
57
+
58
+ 1. **User references past work:** "Remember when we fixed the auth bug?"
59
+ 2. **Making similar decisions:** "What did we decide about database choice?"
60
+ 3. **Setting up new features:** "What's the user's coding style?"
61
+ 4. **Debugging recurring issues:** "Have we seen this error before?"
62
+
63
+ ## How to Use Tools
64
+
65
+ ### Store a memory:
66
+ ```
67
+ memory_store(
68
+ title: "auth_jwt_prefer_refresh_tokens",
69
+ content: "User prefers short-lived access tokens (15min) with long-lived refresh tokens (30d). Always implement token rotation on refresh.",
70
+ tags: ["auth", "jwt", "preferences"],
71
+ type: "preference"
72
+ )
73
+ ```
74
+
75
+ ### Search memories:
76
+ ```
77
+ memory_search(query: "auth tokens")
78
+ ```
79
+
80
+ ### List all project memories:
81
+ ```
82
+ memory_list()
83
+ ```
84
+
85
+ ### Delete a memory:
86
+ ```
87
+ memory_delete(title: "auth_jwt_prefer_refresh_tokens")
88
+ ```
89
+
90
+ ## Project vs Cross-Project Search
91
+
92
+ | Action | Scope | Tools |
93
+ |--------|-------|-------|
94
+ | **Store** | Always project-scoped | `memory_store` |
95
+ | **Search this project** | Current project only | `memory_search` |
96
+ | **Search all projects** | Cross-project | `global_memory_search` |
97
+ | **List all** | Cross-project | `global_memory_list` |
98
+
99
+ **All memories are project-scoped.** When you store a memory, it belongs to the current project. Use `global_memory_search` to search across ALL projects when looking for past work or user preferences.
100
+
101
+ ## Update-First Principle
102
+
103
+ **Always check before creating.** Before storing a new memory:
104
+
105
+ 1. Search for similar memories
106
+ 2. If found and relevant → UPDATE the existing memory
107
+ 3. If not found → CREATE new memory
108
+
109
+ This prevents memory duplication and keeps memory clean.
110
+
111
+ ## Consolidation
112
+
113
+ When the user runs `/unipi:memory-consolidate` or during compaction:
114
+
115
+ 1. Review the session for memory-worthy items
116
+ 2. For each item:
117
+ - Search for existing similar memory
118
+ - Update if found, create if not
119
+ 3. Report what was stored/updated
120
+
121
+ ## Reading Memory Files
122
+
123
+ Memory files are stored in `~/.unipi/memory/` as markdown with YAML frontmatter:
124
+
125
+ ```markdown
126
+ ---
127
+ title: auth_jwt_prefer_refresh_tokens
128
+ tags: [auth, jwt, preferences]
129
+ project: my-app
130
+ created: 2026-04-26T10:00:00Z
131
+ updated: 2026-04-26T15:30:00Z
132
+ type: preference
133
+ ---
134
+
135
+ # Auth: Prefer Refresh Tokens
136
+
137
+ User prefers short-lived access tokens (15min) with long-lived refresh tokens (30d).
138
+ Always implement token rotation on refresh.
139
+ ```
140
+
141
+ You can read these files directly with the `read` tool for full context.
142
+
143
+ ## Anti-Patterns
144
+
145
+ | Don't | Do Instead |
146
+ |-------|------------|
147
+ | Store everything | Only store decisions, preferences, patterns, summaries |
148
+ | Create duplicate memories | Search first, update existing |
149
+ | Use vague titles | Use specific `<category>_<detail>` format |
150
+ | Store in wrong scope | Project-specific = project scope, universal = global |
151
+ | Forget to update | When context changes, update the memory |