Skip to content

Commit 735dd09

Browse files
committed
Merge branch 'main' into fix-remote-embedding-result-metadata
2 parents 1b45e33 + ad15eda commit 735dd09

32 files changed

Lines changed: 4368 additions & 6 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ test/unittest.dSYM/Contents/Info.plist
5757
test/unittest.dSYM/Contents/Resources/DWARF/unittest
5858
test/unittest.dSYM/Contents/Resources/Relocations/aarch64/unittest.yml
5959
/build
60+
cli/.sqlmem.json
61+
cli/sqlmem

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,22 @@ WHERE query = 'how do databases store information efficiently';
116116
-- └──────────────┴─────────────────────────────────────┴─────────┘
117117
```
118118

119+
### Command Line: sqlmem
120+
121+
[`sqlmem`](cli/README.md) is the Go CLI for managing SQLite Memory projects from the terminal. It creates `.sqlmem.json`, manages the SQLite database, downloads and loads the SQLite extensions, configures embedding models, indexes Markdown sources, runs hybrid searches, watches files for changes, and exposes the memory tools over MCP.
122+
123+
Use it when you want a project-level workflow around sqlite-memory without writing SQL directly:
124+
125+
```bash
126+
cd cli
127+
make build
128+
./sqlmem init --model /path/to/embedding-model.gguf
129+
./sqlmem add ../docs
130+
./sqlmem search -q "how do I configure memory?"
131+
```
132+
133+
See the [`sqlmem` README](cli/README.md) for installation, configuration, extension cache paths, PDF support, MCP, and command examples.
134+
119135
### Example: Building an AI Agent with Memory
120136

121137
```python

cli/EXAMPLES.md

Lines changed: 332 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,332 @@
1+
# sqlmem Examples
2+
3+
Practical examples for common `sqlmem` workflows.
4+
5+
## Initialize A Project
6+
7+
Create `.sqlmem.json`, create the SQLite database, install required extensions, and configure the embedding model.
8+
9+
```sh
10+
sqlmem init --model /models/nomic-embed-text-v1.5.Q8_0.gguf
11+
```
12+
13+
Use a custom extension cache directory:
14+
15+
```sh
16+
sqlmem init \
17+
--extensions-dir ~/.cache/sqlmem/extensions \
18+
--model /models/nomic-embed-text-v1.5.Q8_0.gguf
19+
```
20+
21+
## Use Remote Embeddings
22+
23+
When an API key is present, `sqlmem` configures sqlite-memory for remote embeddings.
24+
25+
```sh
26+
sqlmem init \
27+
--api-key "$sqlmem_API_KEY" \
28+
--model text-embedding-3-small
29+
```
30+
31+
You can also set the API key through the environment:
32+
33+
```sh
34+
export sqlmem_API_KEY="..."
35+
sqlmem init --model text-embedding-3-small
36+
```
37+
38+
Precedence is:
39+
40+
1. `--api-key`
41+
2. `sqlmem_API_KEY`
42+
3. `.sqlmem.json`
43+
44+
## Add Sources
45+
46+
Add a directory:
47+
48+
```sh
49+
sqlmem add ./docs
50+
```
51+
52+
Add one Markdown file:
53+
54+
```sh
55+
sqlmem add ./README.md
56+
```
57+
58+
Add multiple sources in one command:
59+
60+
```sh
61+
sqlmem add ./docs ./notes/project.md
62+
```
63+
64+
Use repeated `--source` flags:
65+
66+
```sh
67+
sqlmem add -s ./docs -s ./notes/project.md
68+
```
69+
70+
Attach a context label to added content:
71+
72+
```sh
73+
sqlmem add ./docs --context product-docs
74+
```
75+
76+
## Add PDFs
77+
78+
PDF indexing is disabled by default because it requires a separate conversion/OCR step. Enable it explicitly first:
79+
80+
```sh
81+
sqlmem config set pdf.enabled true
82+
```
83+
84+
PDF files are then converted to Markdown before indexing.
85+
86+
```sh
87+
sqlmem add ./papers/sqlite-memory-overview.pdf
88+
```
89+
90+
Use a custom PDF cache directory:
91+
92+
```sh
93+
sqlmem --pdf-cache-dir ~/.cache/sqlmem/pdf add ./papers/report.pdf
94+
```
95+
96+
Disable PDF support again:
97+
98+
```sh
99+
sqlmem config set pdf.enabled false
100+
```
101+
102+
## Search
103+
104+
Search with a positional query:
105+
106+
```sh
107+
sqlmem search "hybrid search with sqlite"
108+
```
109+
110+
Search with flags:
111+
112+
```sh
113+
sqlmem search -q "embedding cache behavior" --limit 5
114+
```
115+
116+
Return JSON for scripts:
117+
118+
```sh
119+
sqlmem search -q "vector extension load order" --limit 10 --json
120+
```
121+
122+
Pipe JSON to `jq`:
123+
124+
```sh
125+
sqlmem search -q "pdf cache" --json | jq '.[].path'
126+
```
127+
128+
## Watch Sources
129+
130+
Watch sources already stored in `.sqlmem.json`:
131+
132+
```sh
133+
sqlmem watch
134+
```
135+
136+
Watch explicit paths for the current session:
137+
138+
```sh
139+
sqlmem watch ./docs ./notes/project.md
140+
```
141+
142+
Use a shorter debounce window:
143+
144+
```sh
145+
sqlmem watch --debounce 200ms
146+
```
147+
148+
## Inspect Status
149+
150+
Show database path, source count, embedding selection, PDF cache, and indexed counts:
151+
152+
```sh
153+
sqlmem status
154+
```
155+
156+
Show the full configuration:
157+
158+
```sh
159+
sqlmem config
160+
```
161+
162+
## Edit Configuration
163+
164+
Set the default search limit:
165+
166+
```sh
167+
sqlmem config set options.max_results 10
168+
```
169+
170+
Lower the minimum score:
171+
172+
```sh
173+
sqlmem config set options.min_score 0.65
174+
```
175+
176+
Disable embedding cache:
177+
178+
```sh
179+
sqlmem config set options.embedding_cache false
180+
```
181+
182+
Set supported indexed file extensions:
183+
184+
```sh
185+
sqlmem config set options.extensions "md,mdx,txt"
186+
```
187+
188+
Opt into reStructuredText explicitly:
189+
190+
```sh
191+
sqlmem config set options.extensions "md,mdx,txt,rst"
192+
```
193+
194+
## Manage Extensions
195+
196+
Print the global extension cache path:
197+
198+
```sh
199+
sqlmem extensions path
200+
```
201+
202+
Install required extensions:
203+
204+
```sh
205+
sqlmem extensions install
206+
```
207+
208+
Install only sqlite-sync:
209+
210+
```sh
211+
sqlmem extensions install sync
212+
```
213+
214+
List installed extension files:
215+
216+
```sh
217+
sqlmem extensions list
218+
```
219+
220+
Update cached extensions:
221+
222+
```sh
223+
sqlmem extensions update
224+
```
225+
226+
Use a GitHub token for higher release API limits:
227+
228+
```sh
229+
export GITHUB_TOKEN="..."
230+
sqlmem extensions update
231+
```
232+
233+
## MCP Server
234+
235+
Start the MCP server over stdio:
236+
237+
```sh
238+
sqlmem mcp --transport stdio
239+
```
240+
241+
Start the MCP server over HTTP:
242+
243+
```sh
244+
sqlmem mcp --transport http --addr 127.0.0.1:8765
245+
```
246+
247+
Available MCP tools:
248+
249+
```text
250+
memory_search
251+
memory_add_file
252+
memory_add_directory
253+
memory_add_text
254+
memory_clear
255+
memory_delete
256+
memory_delete_context
257+
memory_reindex
258+
memory_status
259+
```
260+
261+
## Remove Sources
262+
263+
Remove a configured source from `.sqlmem.json`:
264+
265+
```sh
266+
sqlmem remove ./docs
267+
```
268+
269+
## Reindex Or Clear
270+
271+
Reindex all stored memory:
272+
273+
```sh
274+
sqlmem reindex
275+
```
276+
277+
Clear all memory content:
278+
279+
```sh
280+
sqlmem clear
281+
```
282+
283+
Reset the project by deleting the configured database and `.sqlmem.json`:
284+
285+
```sh
286+
sqlmem reset
287+
```
288+
289+
## Interactive Mode
290+
291+
Run without a subcommand to open the interactive prompt:
292+
293+
```sh
294+
sqlmem
295+
```
296+
297+
Inside the prompt:
298+
299+
```text
300+
sqlmem> status
301+
sqlmem> search "release notes"
302+
sqlmem> add ./notes
303+
sqlmem> quit
304+
```
305+
306+
Command history is available with the up and down arrow keys.
307+
308+
## Script Examples
309+
310+
Fail if no results are returned:
311+
312+
```sh
313+
results="$(sqlmem search -q "database migration" --json)"
314+
count="$(printf '%s' "$results" | jq 'length')"
315+
test "$count" -gt 0
316+
```
317+
318+
Index all Markdown files changed in the current Git branch:
319+
320+
```sh
321+
git diff --name-only main...HEAD -- '*.md' '*.mdx' |
322+
while IFS= read -r file; do
323+
[ -f "$file" ] && sqlmem add "$file"
324+
done
325+
```
326+
327+
Create a project-local database name:
328+
329+
```sh
330+
sqlmem init --model /models/nomic-embed-text-v1.5.Q8_0.gguf
331+
sqlmem config set database ".cache/project-memory.sqlite"
332+
```

cli/Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
BINARY := sqlmem
2+
3+
.PHONY: build test clean
4+
5+
build:
6+
go build -o $(BINARY) ./cmd/sqlmem
7+
8+
test:
9+
go test ./...
10+
11+
clean:
12+
rm -f $(BINARY)

0 commit comments

Comments
 (0)