@pinkpixel/memi 0.0.0-stage → 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/LICENSE +202 -0
- package/README.md +298 -2
- package/dist/cli/commands/config.js +38 -0
- package/dist/cli/commands/doctor.js +53 -0
- package/dist/cli/commands/memories.js +146 -0
- package/dist/cli/commands/reindex.js +34 -0
- package/dist/cli/commands/serve.js +9 -0
- package/dist/cli/commands/ui.js +26 -0
- package/dist/cli/index.js +20 -0
- package/dist/cli/util.js +46 -0
- package/dist/core/config.js +89 -0
- package/dist/core/db.js +21 -0
- package/dist/core/format.js +16 -0
- package/dist/core/memories.js +192 -0
- package/dist/core/project.js +53 -0
- package/dist/core/rows.js +38 -0
- package/dist/core/runtime.js +10 -0
- package/dist/core/schema.js +60 -0
- package/dist/core/search.js +86 -0
- package/dist/core/types.js +12 -0
- package/dist/core/vectors.js +102 -0
- package/dist/embed/http.js +20 -0
- package/dist/embed/index.js +9 -0
- package/dist/embed/ollama.js +24 -0
- package/dist/embed/openai.js +22 -0
- package/dist/embed/types.js +2 -0
- package/dist/lib/app-info.js +5 -0
- package/dist/mcp/server.js +24 -0
- package/dist/mcp/tools.js +152 -0
- package/dist/ui/assets.js +38 -0
- package/dist/ui/routes.js +91 -0
- package/dist/ui/security.js +47 -0
- package/dist/ui/server.js +33 -0
- package/package.json +63 -4
- package/skills/memi-curate/SKILL.md +89 -0
- package/skills/memi-memory/SKILL.md +141 -0
- package/skills/memi-memory/references/examples.md +50 -0
- package/skills/memi-memory/references/rubrics.md +44 -0
- package/skills/memi-setup/SKILL.md +159 -0
- package/ui/css/controls.css +274 -0
- package/ui/css/dialogs.css +145 -0
- package/ui/css/layout.css +237 -0
- package/ui/css/memories.css +168 -0
- package/ui/css/tokens.css +125 -0
- package/ui/favicon.svg +1 -0
- package/ui/fonts/OFL.txt +192 -0
- package/ui/fonts/geist-latin-wght-normal.woff2 +0 -0
- package/ui/fonts/geist-mono-latin-wght-normal.woff2 +0 -0
- package/ui/index.html +75 -0
- package/ui/js/api.js +30 -0
- package/ui/js/confirm.js +29 -0
- package/ui/js/dom.js +49 -0
- package/ui/js/editor.js +133 -0
- package/ui/js/icons.js +29 -0
- package/ui/js/list.js +66 -0
- package/ui/js/main.js +244 -0
- package/ui/js/sidebar.js +85 -0
- package/ui/js/state.js +61 -0
- package/ui/js/toast.js +10 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,299 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/pinkpixel-dev/memi/HEAD/memi.png" alt="memi, a small smiling pastel blob with a sparkle" width="140">
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
# memi
|
|
6
|
+
|
|
7
|
+
Local-first memory for AI agents. Memories live in one SQLite file on your machine, and agents reach them through an MCP server.
|
|
8
|
+
|
|
9
|
+
AI agents forget everything when a session ends. memi gives them somewhere to keep the things worth remembering: decisions and why they were made, how you like things done, mistakes not to repeat. The next session can search that instead of asking you the same questions again.
|
|
10
|
+
|
|
11
|
+
## What it does
|
|
12
|
+
|
|
13
|
+
- Stores memories in a single SQLite file, with no server to run and no account to make
|
|
14
|
+
- Finds them by meaning and by keyword, using local embeddings from Ollama or OpenAI
|
|
15
|
+
- Keeps **global** memories (about you, across every project) apart from **project** memories (about one codebase)
|
|
16
|
+
- Lets you mark memories as important, pin the ones that must always be loaded, and sort them into categories
|
|
17
|
+
- Runs as an MCP server, so any client that speaks MCP can use it
|
|
18
|
+
- Comes with a CLI, a small local web UI for browsing and editing, and agent skills that teach an agent when to save and recall
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
You need:
|
|
23
|
+
|
|
24
|
+
- Node.js 22 or newer
|
|
25
|
+
- One embedder: [Ollama](https://ollama.com) (runs locally) or an OpenAI API key
|
|
26
|
+
|
|
27
|
+
Install it globally to get a `memi` command:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install -g @pinkpixel/memi
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Or skip the install and let `npx` fetch it when it's needed. That's what the MCP setup below does:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npx -y @pinkpixel/memi doctor
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The examples below say `memi`. If you didn't install globally, use `npx -y @pinkpixel/memi` in its place. To build it from source instead, see [Development](#development).
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
The default embedder is Ollama with `nomic-embed-text`, so pull that first:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
ollama pull nomic-embed-text
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Check that everything is wired up:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
memi doctor
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Save a few things, then search for them in different words:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
memi add "I prefer tabs over spaces" --global --category preference
|
|
59
|
+
memi add "Deploys go through GitHub Actions to Cloudflare" --category fact
|
|
60
|
+
memi add "Keep answers short, with no summary at the end" --global --category preference
|
|
61
|
+
|
|
62
|
+
memi search "indentation style"
|
|
63
|
+
memi search "how do we ship releases"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Neither search shares a word with the memory it finds. That's the embeddings at work. (The second memory has no `--global`, so it belongs to whichever project you ran the command in.)
|
|
67
|
+
|
|
68
|
+
If you'd rather use OpenAI:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
export OPENAI_API_KEY=sk-...
|
|
72
|
+
memi config set embedder.provider openai
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Keep in mind that memory text gets sent to OpenAI to be embedded when you do this.
|
|
76
|
+
|
|
77
|
+
## Connect it to your agent
|
|
78
|
+
|
|
79
|
+
### Claude Code
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
claude mcp add memi -s user -e MEMI_AGENT=claude -- npx -y @pinkpixel/memi serve
|
|
83
|
+
claude mcp list
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`-s user` makes memi available in every project, which is usually what you want for a memory. `MEMI_AGENT` is optional (more on that below).
|
|
87
|
+
|
|
88
|
+
The first start downloads the package, which takes a few seconds. After that npx reuses its cache, so starts are quick, and that cache can hold on to an older version. Use `@pinkpixel/memi@latest` in the command to always get the newest one. If you installed globally, you can use `memi serve` as the command instead, which starts fastest.
|
|
89
|
+
|
|
90
|
+
### Other clients
|
|
91
|
+
|
|
92
|
+
Anything that can launch a stdio MCP server needs a command, its arguments, and optionally some environment variables. In the common `mcpServers` format:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"mcpServers": {
|
|
97
|
+
"memi": {
|
|
98
|
+
"command": "npx",
|
|
99
|
+
"args": ["-y", "@pinkpixel/memi", "serve"],
|
|
100
|
+
"env": { "MEMI_AGENT": "my-agent" }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Restart the client after editing its config. I've only tested this with Claude Code so far, but other clients should work the same way.
|
|
107
|
+
|
|
108
|
+
### What the agent gets
|
|
109
|
+
|
|
110
|
+
| Tool | What it does |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `get_context` | Loads the pinned and high-importance memories at the start of a session |
|
|
113
|
+
| `recall` | Searches by meaning and keyword |
|
|
114
|
+
| `remember` | Saves a memory, and points out similar ones that already exist |
|
|
115
|
+
| `update_memory` | Changes a memory, or moves it between global and a project |
|
|
116
|
+
| `forget` | Deletes a memory |
|
|
117
|
+
| `list_memories` | Browses without a search query |
|
|
118
|
+
| `list_categories` | Lists categories with counts |
|
|
119
|
+
|
|
120
|
+
## Install the skills
|
|
121
|
+
|
|
122
|
+
The tools alone don't tell an agent when to use them, so there are three skills in `skills/`:
|
|
123
|
+
|
|
124
|
+
| Skill | What it covers |
|
|
125
|
+
|---|---|
|
|
126
|
+
| `memi-memory` | The everyday habit: load context first, recall before deciding, save what's worth keeping, and never save secrets |
|
|
127
|
+
| `memi-curate` | Cleaning up a messy store. It proposes changes and waits for your approval before deleting anything |
|
|
128
|
+
| `memi-setup` | Installing, connecting, switching embedders, and reading `memi doctor` |
|
|
129
|
+
|
|
130
|
+
They ship inside the package. Copy or symlink the folders into your client's skills directory. For Claude Code that's `~/.claude/skills/`, and with a global install it looks like this:
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
ln -s "$(npm root -g)/@pinkpixel/memi/skills/"* ~/.claude/skills/
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Without a global install, grab the `skills` folder from the repo instead.
|
|
137
|
+
|
|
138
|
+
## The CLI
|
|
139
|
+
|
|
140
|
+
| Command | What it does |
|
|
141
|
+
|---|---|
|
|
142
|
+
| `memi add <content...>` | Save a memory. Options: `-c` category, `-i` importance 1 to 5, `-t` tags, `--pin`, `--global`, `-p` project |
|
|
143
|
+
| `memi search <query...>` | Search. Options: `--mode hybrid\|semantic\|text`, `--scope both\|project\|global\|all`, `-c`, `--min-importance`, `-n`, `--json` |
|
|
144
|
+
| `memi list` | Browse and filter. Same filters as search, plus `--pinned` and `--order recent\|oldest\|importance` |
|
|
145
|
+
| `memi update <id>` | Change a memory: `--content`, `-c`, `-i`, `-t`, `--pin`, `--unpin`, `--global`, `-p` |
|
|
146
|
+
| `memi forget <id>` | Delete one. Asks first, or pass `--yes` |
|
|
147
|
+
| `memi categories` | List categories with counts |
|
|
148
|
+
| `memi config` | Show settings. `memi config set <key> <value>` changes one |
|
|
149
|
+
| `memi reindex` | Rebuild the vector index. Asks first, or pass `--yes` |
|
|
150
|
+
| `memi doctor` | Check the database, the embedder, the index, and project detection |
|
|
151
|
+
| `memi ui` | Start the local web UI |
|
|
152
|
+
| `memi serve` | Run the MCP server |
|
|
153
|
+
|
|
154
|
+
Known errors print one line starting with `memi:` and exit with code 1. Commands that need a confirmation won't guess when there's no terminal to ask in. Pass `--yes` in scripts.
|
|
155
|
+
|
|
156
|
+
## The local UI
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
memi ui --open
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
This serves a small memory manager at `http://localhost:4747`. You can search, filter by scope, category, and importance, add and edit memories, pin them, and delete them. Deleting always asks first.
|
|
163
|
+
|
|
164
|
+
A few keys help: `/` jumps to search, `n` starts a new memory, `Esc` closes whatever is open, and `Ctrl+Enter` saves. It works on a phone-sized screen too.
|
|
165
|
+
|
|
166
|
+
It only listens on your own machine, and it ignores requests that don't come from `localhost`, since it can delete things. Pick another port with `--port`, or `memi config set ui.port <n>`.
|
|
167
|
+
|
|
168
|
+
## Projects, scopes, and the agent name
|
|
169
|
+
|
|
170
|
+
Every memory is either **global** or belongs to one **project**. memi works out the project in this order:
|
|
171
|
+
|
|
172
|
+
1. A name you pass (`--project`, or the `project` argument of a tool)
|
|
173
|
+
2. The `MEMI_PROJECT` environment variable
|
|
174
|
+
3. The folder name of the git repo you're in
|
|
175
|
+
4. The agent name, stored as `agent:<name>`
|
|
176
|
+
|
|
177
|
+
That fourth one is for folders with no git repo. Set it with `memi config set agent <name>` or `MEMI_AGENT`. The agent name is also recorded on each memory, so you can see who wrote what.
|
|
178
|
+
|
|
179
|
+
With none of those, project memories can't be saved, and the error says what to set. Global memories always work.
|
|
180
|
+
|
|
181
|
+
One thing to know: the git check uses the folder name only. Two repos with the same folder name share a project. Pass an explicit project name if that bites you.
|
|
182
|
+
|
|
183
|
+
## Embeddings
|
|
184
|
+
|
|
185
|
+
| Provider | Default model | What you need |
|
|
186
|
+
|---|---|---|
|
|
187
|
+
| `ollama` | `nomic-embed-text` | Ollama running, with the model pulled |
|
|
188
|
+
| `openai` | `text-embedding-3-small` | `OPENAI_API_KEY` in the environment that runs memi |
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
memi config # what's in effect right now
|
|
192
|
+
memi config set embedder.provider openai
|
|
193
|
+
memi config set embedder.model text-embedding-3-small
|
|
194
|
+
memi config set embedder.baseUrl http://localhost:11434
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The API key is only ever read from the environment. memi never writes it to a file.
|
|
198
|
+
|
|
199
|
+
### Switching embedders
|
|
200
|
+
|
|
201
|
+
Different models make vectors of different sizes, so the vectors you already have can't be reused. When you change the embedder, memi notices and turns semantic search off, with a warning. Keyword search keeps working, and nothing is deleted.
|
|
202
|
+
|
|
203
|
+
To finish the switch:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
memi reindex
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
That drops the vector table, rebuilds it for the new model, and re-embeds every saved memory. **Your memories are kept.** It asks before it starts. The embedding happens before anything is dropped, so if the new embedder isn't reachable, nothing changes. If you switch back to the original model, you don't need to reindex at all.
|
|
210
|
+
|
|
211
|
+
If a memory was saved while the embedder was down, it's still saved. It just has no vector yet. `memi reindex --missing` fills those in without dropping anything.
|
|
212
|
+
|
|
213
|
+
## Configuration
|
|
214
|
+
|
|
215
|
+
Settings come from `~/.memi/config.json`, and environment variables override them.
|
|
216
|
+
|
|
217
|
+
| Setting | Config key | Environment variable |
|
|
218
|
+
|---|---|---|
|
|
219
|
+
| Embedder | `embedder.provider` | `MEMI_EMBED_PROVIDER` |
|
|
220
|
+
| Model | `embedder.model` | `MEMI_EMBED_MODEL` |
|
|
221
|
+
| Embedder URL | `embedder.baseUrl` | `MEMI_OLLAMA_URL` (Ollama), `OPENAI_BASE_URL` (OpenAI) |
|
|
222
|
+
| Agent name | `agent` | `MEMI_AGENT` |
|
|
223
|
+
| UI port | `ui.port` | none |
|
|
224
|
+
| Force a project | none | `MEMI_PROJECT` |
|
|
225
|
+
| Data folder | none | `MEMI_HOME` |
|
|
226
|
+
| OpenAI key | none | `OPENAI_API_KEY` |
|
|
227
|
+
|
|
228
|
+
Setting `embedder.provider` clears the saved model and URL, so the new provider starts from its own defaults.
|
|
229
|
+
|
|
230
|
+
## Where your data lives
|
|
231
|
+
|
|
232
|
+
- Database: `~/.memi/memi.db`
|
|
233
|
+
- Config: `~/.memi/config.json`
|
|
234
|
+
|
|
235
|
+
Set `MEMI_HOME` to move both. SQLite runs in WAL mode, so you'll see `memi.db-wal` and `memi.db-shm` next to the database while memi is running. To back up, copy all three files while nothing is using the database, or run `sqlite3 ~/.memi/memi.db ".backup backup.db"`.
|
|
236
|
+
|
|
237
|
+
## How search works
|
|
238
|
+
|
|
239
|
+
Searches run two ways and merge the results: a keyword search (SQLite FTS5, with stemming) and a vector search (`sqlite-vec`, cosine distance). The two ranked lists are combined with reciprocal rank fusion. Importance and recency then give a small nudge, small enough that relevance still wins.
|
|
240
|
+
|
|
241
|
+
If vectors aren't usable, search falls back to keywords and tells you.
|
|
242
|
+
|
|
243
|
+
## Limitations
|
|
244
|
+
|
|
245
|
+
- Only tested on Linux so far
|
|
246
|
+
- Only tested with Claude Code as the MCP client
|
|
247
|
+
- Semantic search always returns its nearest matches, even when none of them are really relevant. There's no relevance cutoff yet
|
|
248
|
+
- Search quality depends on the embedding model. `nomic-embed-text` scores are fairly bunched together, so vague queries can rank oddly
|
|
249
|
+
- Two git repos with the same folder name share a project
|
|
250
|
+
- The UI can't run `memi reindex` yet. It shows the command to copy instead
|
|
251
|
+
|
|
252
|
+
## Development
|
|
253
|
+
|
|
254
|
+
To build from source:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
git clone https://github.com/pinkpixel-dev/memi.git
|
|
258
|
+
cd memi
|
|
259
|
+
npm install
|
|
260
|
+
npm run build
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Run it with `node dist/cli/index.js`, or point an MCP client at it with an absolute path:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
claude mcp add memi -s user -- node /absolute/path/to/memi/dist/cli/index.js serve
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Checks:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
npm run typecheck
|
|
273
|
+
npm test
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
The tests are real ones. The end-to-end tests start the actual CLI and MCP server as child processes, and the UI tests run the real frontend modules against the real API. There are no mocks.
|
|
277
|
+
|
|
278
|
+
The semantic tests need Ollama running with `nomic-embed-text` pulled, and skip themselves if it isn't. One test, the embedder switch from 768 to 1024 dimensions, also needs a second model. It defaults to `qwen3-embedding:0.6b`, and you can use another with `MEMI_TEST_ALT_MODEL`. Without it, that one test is skipped.
|
|
279
|
+
|
|
280
|
+
The code is split up like this:
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
src/core/ storage, search, project detection, embeddings plumbing
|
|
284
|
+
src/embed/ Ollama and OpenAI providers
|
|
285
|
+
src/mcp/ the MCP server and its tools
|
|
286
|
+
src/cli/ the command line
|
|
287
|
+
src/ui/ the web UI's server
|
|
288
|
+
ui/ the web UI's files (plain HTML, CSS, and JavaScript, no build step)
|
|
289
|
+
skills/ the agent skills
|
|
290
|
+
tests/
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
## License
|
|
294
|
+
|
|
295
|
+
Apache 2.0. See [LICENSE](LICENSE).
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
Made with 💖 by [Pink Pixel](https://pinkpixel.dev)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { CONFIG_KEYS, configPath, loadConfig, resolveAgent, resolveEmbedder, saveConfig, setConfigValue } from "../../core/config.js";
|
|
2
|
+
import { openRuntime } from "../../core/runtime.js";
|
|
3
|
+
import { MemiError } from "../../core/types.js";
|
|
4
|
+
import { action } from "../util.js";
|
|
5
|
+
export const registerConfig = (program) => {
|
|
6
|
+
const config = program.command("config").description("Show or change settings");
|
|
7
|
+
config.action(action(() => {
|
|
8
|
+
const c = loadConfig();
|
|
9
|
+
const e = resolveEmbedder(c);
|
|
10
|
+
console.log(`Config file: ${configPath()}\n`);
|
|
11
|
+
console.log(`embedder.provider ${e.provider}`);
|
|
12
|
+
console.log(`embedder.model ${e.model}`);
|
|
13
|
+
console.log(`embedder.baseUrl ${e.baseUrl}`);
|
|
14
|
+
if (e.provider === "openai")
|
|
15
|
+
console.log(`OPENAI_API_KEY ${e.apiKey ? "set" : "not set"}`);
|
|
16
|
+
console.log(`agent ${resolveAgent(c) ?? "(none)"}`);
|
|
17
|
+
console.log(`ui.port ${c.ui.port}`);
|
|
18
|
+
}));
|
|
19
|
+
config
|
|
20
|
+
.command("set <key> <value>")
|
|
21
|
+
.description(`Set one of: ${CONFIG_KEYS.join(", ")}`)
|
|
22
|
+
.action(action((key, value) => {
|
|
23
|
+
let next;
|
|
24
|
+
try {
|
|
25
|
+
next = setConfigValue(loadConfig(), key, value);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
throw new MemiError(err.message);
|
|
29
|
+
}
|
|
30
|
+
saveConfig(next);
|
|
31
|
+
console.log(`Set ${key} = ${value}`);
|
|
32
|
+
if (!key.startsWith("embedder."))
|
|
33
|
+
return;
|
|
34
|
+
const { warning } = openRuntime().store.status();
|
|
35
|
+
if (warning)
|
|
36
|
+
console.error(`\nWarning: ${warning}`);
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { configPath, dbPath, loadConfig, memiHome, resolveAgent, resolveEmbedder } from "../../core/config.js";
|
|
3
|
+
import { resolveProject } from "../../core/project.js";
|
|
4
|
+
import { openRuntime } from "../../core/runtime.js";
|
|
5
|
+
import { action } from "../util.js";
|
|
6
|
+
export const registerDoctor = (program) => {
|
|
7
|
+
program
|
|
8
|
+
.command("doctor")
|
|
9
|
+
.description("Check the database, the embedder, and project detection")
|
|
10
|
+
.action(action(async () => {
|
|
11
|
+
let failed = false;
|
|
12
|
+
const line = (level, msg) => {
|
|
13
|
+
if (level === "fail")
|
|
14
|
+
failed = true;
|
|
15
|
+
console.log(`${level.padEnd(4)} ${msg}`);
|
|
16
|
+
};
|
|
17
|
+
const config = loadConfig();
|
|
18
|
+
const resolved = resolveEmbedder(config);
|
|
19
|
+
console.log(`Home: ${memiHome()} (config ${existsSync(configPath()) ? "found" : "not created yet, using defaults"})\n`);
|
|
20
|
+
const { store } = openRuntime();
|
|
21
|
+
const status = store.status();
|
|
22
|
+
line("ok", `Database at ${dbPath()}: ${status.total} memories`);
|
|
23
|
+
if (resolved.provider === "openai" && !resolved.apiKey)
|
|
24
|
+
line("fail", "OPENAI_API_KEY is not set");
|
|
25
|
+
else {
|
|
26
|
+
const start = Date.now();
|
|
27
|
+
try {
|
|
28
|
+
const [vec] = await store.embedder.embed(["memi doctor check"], "query");
|
|
29
|
+
line("ok", `Embedder ${resolved.provider}/${resolved.model} replied in ${Date.now() - start}ms (${vec?.length} dimensions)`);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
line("fail", err.message);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const { state } = status;
|
|
36
|
+
if (state.status === "uninitialized")
|
|
37
|
+
line("ok", "No vectors yet. The index is created when you save your first memory.");
|
|
38
|
+
else if (state.status === "mismatch")
|
|
39
|
+
line("fail", status.warning ?? "The embedder changed. Run `memi reindex`.");
|
|
40
|
+
else {
|
|
41
|
+
line("ok", `Vector index matches (${state.stored.provider}/${state.stored.model}, ${state.stored.dimensions} dimensions)`);
|
|
42
|
+
const missing = status.total - status.vectors;
|
|
43
|
+
if (missing > 0)
|
|
44
|
+
line("warn", `${missing} memories have no vector. Run \`memi reindex --missing\`.`);
|
|
45
|
+
}
|
|
46
|
+
const agent = resolveAgent(config);
|
|
47
|
+
const project = resolveProject({ agent });
|
|
48
|
+
line(project ? "ok" : "warn", project ? `Project here: ${project.project} (from ${project.source})` : "No project detected here. Set MEMI_AGENT or run inside a git repo.");
|
|
49
|
+
console.log(` Agent name: ${agent ?? "(none)"}`);
|
|
50
|
+
if (failed)
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}));
|
|
53
|
+
};
|