@shahmilsaari/memory-core 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.
package/README.md ADDED
@@ -0,0 +1,538 @@
1
+ # @archmind/memory-core
2
+
3
+ Universal AI memory core. Install in any Git project and every AI coding agent — Copilot, Cursor, Claude, Windsurf, Cline, and more — will automatically follow your architecture rules and past decisions.
4
+
5
+ ---
6
+
7
+ ## How it works
8
+
9
+ ```
10
+ Your central PostgreSQL database (memories + rules)
11
+
12
+ memory-core init (run once per project)
13
+
14
+ Generates AI config files for every agent
15
+
16
+ Every agent reads its file → follows your rules
17
+ ```
18
+
19
+ ---
20
+
21
+ ## Supported agents
22
+
23
+ | Agent | File generated |
24
+ |-------|---------------|
25
+ | GitHub Copilot | `.github/copilot-instructions.md` |
26
+ | Cursor | `.cursorrules` + `.cursor/rules/memory-core.mdc` |
27
+ | Claude Code | `CLAUDE.md` |
28
+ | Windsurf | `.windsurfrules` |
29
+ | Cline | `.clinerules` |
30
+ | Roo Code | `.roo/rules/memory-core.md` |
31
+ | Aider | `.aider.conf.yml` |
32
+ | Continue.dev | `.continue/config.json` |
33
+ | Devin | `DEVIN.md` |
34
+ | Amazon Q | `.amazonq/dev/guidelines.md` |
35
+ | Gemini Code Assist | `.gemini/styleguide.md` |
36
+ | Zed AI | `.zed/settings.json` |
37
+ | JetBrains AI | `.idea/ai-instructions.md` |
38
+
39
+ Plus: `AGENTS.md`, `AI_RULES.md`, `ARCHITECTURE.md`, `PROJECT_MEMORY.md`
40
+
41
+ ---
42
+
43
+ ## Prerequisites
44
+
45
+ You need three things installed before using this package:
46
+
47
+ 1. **PostgreSQL** (local or remote)
48
+ 2. **pgvector** (PostgreSQL extension for semantic search)
49
+ 3. **Ollama** with `nomic-embed-text` model (free, local embeddings — no API key needed)
50
+
51
+ ---
52
+
53
+ ## 1. PostgreSQL setup
54
+
55
+ ### macOS (Homebrew)
56
+
57
+ ```bash
58
+ brew install postgresql@16
59
+ brew services start postgresql@16
60
+ ```
61
+
62
+ Verify it is running:
63
+
64
+ ```bash
65
+ psql -U $(whoami) -l
66
+ ```
67
+
68
+ ### Linux (Ubuntu/Debian)
69
+
70
+ ```bash
71
+ sudo apt install postgresql postgresql-contrib
72
+ sudo systemctl start postgresql
73
+ ```
74
+
75
+ ### Windows
76
+
77
+ Download and install from [postgresql.org](https://www.postgresql.org/download/windows/).
78
+
79
+ ---
80
+
81
+ ## 2. pgvector setup
82
+
83
+ pgvector adds vector similarity search to PostgreSQL. It must be built for your exact PostgreSQL version.
84
+
85
+ ### macOS with PostgreSQL@16 (Homebrew)
86
+
87
+ The brew pgvector package targets pg17+, so build from source:
88
+
89
+ ```bash
90
+ # Install build tools if needed
91
+ xcode-select --install
92
+
93
+ # Clone and build for PostgreSQL@16
94
+ git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git /tmp/pgvector
95
+ cd /tmp/pgvector
96
+ make PG_CONFIG=/opt/homebrew/opt/postgresql@16/bin/pg_config
97
+ make install PG_CONFIG=/opt/homebrew/opt/postgresql@16/bin/pg_config
98
+ ```
99
+
100
+ ### macOS with PostgreSQL@17+ (Homebrew)
101
+
102
+ ```bash
103
+ brew install pgvector
104
+ ```
105
+
106
+ ### Linux (Ubuntu/Debian)
107
+
108
+ ```bash
109
+ sudo apt install postgresql-16-pgvector
110
+ # Replace 16 with your PostgreSQL version
111
+ ```
112
+
113
+ ### Verify pgvector is installed
114
+
115
+ ```bash
116
+ psql -U $(whoami) -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';"
117
+ ```
118
+
119
+ You should see a row with `name = vector`.
120
+
121
+ ---
122
+
123
+ ## 3. Ollama setup
124
+
125
+ Ollama runs the embedding model locally. No API key or internet connection required after setup.
126
+
127
+ ### macOS
128
+
129
+ ```bash
130
+ brew install ollama
131
+ brew services start ollama
132
+ ```
133
+
134
+ ### Linux
135
+
136
+ ```bash
137
+ curl -fsSL https://ollama.com/install.sh | sh
138
+ ollama serve &
139
+ ```
140
+
141
+ ### Windows
142
+
143
+ Download from [ollama.com](https://ollama.com/download).
144
+
145
+ ### Pull the embedding model
146
+
147
+ ```bash
148
+ ollama pull nomic-embed-text
149
+ ```
150
+
151
+ Verify Ollama is running:
152
+
153
+ ```bash
154
+ curl http://localhost:11434
155
+ # Expected: "Ollama is running"
156
+ ```
157
+
158
+ ---
159
+
160
+ ## 4. Create the database
161
+
162
+ ```bash
163
+ createdb memory_core
164
+ ```
165
+
166
+ Then run the setup SQL to create the table and indexes:
167
+
168
+ ```bash
169
+ psql -U $(whoami) -d memory_core -f setup.sql
170
+ ```
171
+
172
+ Expected output:
173
+
174
+ ```
175
+ CREATE EXTENSION
176
+ CREATE TABLE
177
+ CREATE INDEX
178
+ CREATE INDEX
179
+ CREATE INDEX
180
+ ```
181
+
182
+ ---
183
+
184
+ ## 5. Install the package
185
+
186
+ ### Use without installing (recommended)
187
+
188
+ ```bash
189
+ npx @archmind/memory-core init
190
+ ```
191
+
192
+ ### Or install globally
193
+
194
+ ```bash
195
+ npm install -g @archmind/memory-core
196
+ memory-core init
197
+ ```
198
+
199
+ ### Or clone and run locally (development)
200
+
201
+ ```bash
202
+ git clone https://github.com/your-org/memory-core.git
203
+ cd memory-core
204
+ npm install
205
+ npm run build
206
+ node dist/cli.js init
207
+ ```
208
+
209
+ ---
210
+
211
+ ## 6. Configure environment
212
+
213
+ Create a `.env` file in the project root (or `.memory-core.env` for per-project config):
214
+
215
+ ```env
216
+ DATABASE_URL=postgresql://YOUR_USERNAME@localhost:5432/memory_core
217
+ OLLAMA_URL=http://localhost:11434
218
+ OLLAMA_MODEL=nomic-embed-text
219
+ ```
220
+
221
+ Replace `YOUR_USERNAME` with your system username. On macOS with Homebrew, this is typically your macOS username with no password.
222
+
223
+ To find your username:
224
+
225
+ ```bash
226
+ whoami
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Commands
232
+
233
+ ### `init` — Set up a project
234
+
235
+ Run once inside any Git project:
236
+
237
+ ```bash
238
+ cd /path/to/your-project
239
+ npx @archmind/memory-core init
240
+ ```
241
+
242
+ You will be asked:
243
+
244
+ ```
245
+ Project name? → my-api
246
+ Architecture? → Clean Architecture
247
+ Language/framework? → TypeScript / NestJS
248
+ Pull relevant memories? → yes
249
+ Install caveman? → no
250
+ Generate AI files? → yes
251
+ ```
252
+
253
+ This creates all AI agent config files in the project and saves `.memory-core.json` to remember your choices.
254
+
255
+ ---
256
+
257
+ ### `sync` — Refresh AI files
258
+
259
+ After adding new memories, regenerate all agent files:
260
+
261
+ ```bash
262
+ npx @archmind/memory-core sync
263
+ ```
264
+
265
+ Pulls the latest relevant memories from the database and rewrites all generated files.
266
+
267
+ ---
268
+
269
+ ### `remember` — Save a decision
270
+
271
+ ```bash
272
+ npx @archmind/memory-core remember "Controllers must only validate input and call use cases"
273
+ ```
274
+
275
+ With options:
276
+
277
+ ```bash
278
+ npx @archmind/memory-core remember "Use DTOs for all API responses" \
279
+ --type rule \
280
+ --scope global \
281
+ --tags "api,dto,response"
282
+ ```
283
+
284
+ | Option | Values | Default |
285
+ |--------|--------|---------|
286
+ | `--type` | `decision`, `rule`, `pattern`, `note` | `decision` |
287
+ | `--scope` | `global`, `project` | `project` |
288
+ | `--tags` | comma-separated | none |
289
+
290
+ ---
291
+
292
+ ### `global` — Sync memory to every AI agent globally
293
+
294
+ Injects your memories into the global config of **every AI agent** — so all of them follow your rules in every project, without running `init`.
295
+
296
+ ```bash
297
+ npx @archmind/memory-core global
298
+ ```
299
+
300
+ With architecture filter:
301
+
302
+ ```bash
303
+ npx @archmind/memory-core global --arch clean-architecture
304
+ ```
305
+
306
+ **What gets updated:**
307
+
308
+ | Agent | Global file written |
309
+ |-------|-------------------|
310
+ | Claude Code | `~/.claude/CLAUDE.md` |
311
+ | GitHub Copilot | VS Code `settings.json` → `github.copilot.chat.codeGeneration.instructions` |
312
+ | Cursor | `~/.cursor/rules/memory-core.mdc` |
313
+ | Cline | VS Code `settings.json` → `cline.customInstructions` |
314
+ | Continue.dev | `~/.continue/config.json` → `systemMessage` |
315
+ | Aider | `~/.aider.conf.yml` |
316
+ | Zed AI | `~/.config/zed/settings.json` → `assistant.system_prompt` |
317
+ | Windsurf | `~/.windsurf/rules/memory-core.md` |
318
+
319
+ Run this again after `memory-core remember` to keep all agents in sync.
320
+
321
+ ---
322
+
323
+ ### `search` — Find past decisions
324
+
325
+ ```bash
326
+ npx @archmind/memory-core search "auth architecture"
327
+ ```
328
+
329
+ With limit:
330
+
331
+ ```bash
332
+ npx @archmind/memory-core search "database access" --limit 10
333
+ ```
334
+
335
+ ---
336
+
337
+ ## Architecture profiles
338
+
339
+ Choose from six built-in profiles during `init`:
340
+
341
+ | Profile | Best for |
342
+ |---------|----------|
343
+ | **Clean Architecture** | Domain-driven APIs with strict layer separation |
344
+ | **Modular Monolith** | Feature-based modules that could become microservices |
345
+ | **MVC** | Standard web apps with controllers, models, services |
346
+ | **Hexagonal Architecture** | Port/adapter isolation, highly testable cores |
347
+ | **Next.js App Router** | Next.js 13+ with server components and server actions |
348
+ | **Laravel Service Repository** | Laravel APIs with service and repository pattern |
349
+
350
+ ---
351
+
352
+ ## Caveman token saver (optional)
353
+
354
+ During `init` you can enable [caveman](https://github.com/juliusbrussee/caveman), which compresses AI responses by 65–75% while keeping them accurate.
355
+
356
+ Choose intensity:
357
+
358
+ | Level | Style |
359
+ |-------|-------|
360
+ | `lite` | Professional terseness |
361
+ | `full` | Caveman mode (default) |
362
+ | `ultra` | Telegraphic, minimum words |
363
+
364
+ caveman rules are injected into every generated agent file automatically.
365
+
366
+ ---
367
+
368
+ ## Typical workflow
369
+
370
+ ### New project
371
+
372
+ ```bash
373
+ git clone https://github.com/your-org/new-api.git
374
+ cd new-api
375
+ npx @archmind/memory-core init
376
+ ```
377
+
378
+ Every AI agent in this project now follows your architecture rules.
379
+
380
+ ### Save a new decision mid-project
381
+
382
+ ```bash
383
+ npx @archmind/memory-core remember "Auth tokens must be validated in middleware, never in controllers" \
384
+ --type decision \
385
+ --scope global \
386
+ --tags "auth,middleware"
387
+ ```
388
+
389
+ ### Sync all projects after saving new decisions
390
+
391
+ ```bash
392
+ npx @archmind/memory-core sync
393
+ ```
394
+
395
+ ### Search before making an architectural decision
396
+
397
+ ```bash
398
+ npx @archmind/memory-core search "error handling strategy"
399
+ ```
400
+
401
+ ---
402
+
403
+ ## Project structure
404
+
405
+ ```
406
+ memory-core/
407
+ src/
408
+ cli.ts ← CLI entry point (init, sync, remember, search)
409
+ config.ts ← Environment config loader
410
+ db.ts ← PostgreSQL connection + memory CRUD
411
+ embedding.ts ← Ollama embedding calls
412
+ retriever.ts ← Semantic search via pgvector
413
+ generator.ts ← Profile loader + Handlebars renderer + file writer
414
+ project-detector.ts ← Auto-detect language/framework from project files
415
+
416
+ profiles/ ← Architecture profile YAML files
417
+ clean-architecture.yml
418
+ modular-monolith.yml
419
+ mvc.yml
420
+ hexagonal.yml
421
+ nextjs.yml
422
+ laravel-service-repository.yml
423
+
424
+ templates/ ← Handlebars templates for each AI agent
425
+ CLAUDE.md.hbs
426
+ copilot-instructions.md.hbs
427
+ cursorrules.hbs
428
+ cursor-rule.mdc.hbs
429
+ windsurfrules.hbs
430
+ clinerules.hbs
431
+ roo-rule.md.hbs
432
+ aider.conf.yml.hbs
433
+ continue-config.json.hbs
434
+ DEVIN.md.hbs
435
+ amazonq-guidelines.md.hbs
436
+ gemini-styleguide.md.hbs
437
+ zed-settings.json.hbs
438
+ jetbrains-ai.md.hbs
439
+ AGENTS.md.hbs
440
+ AI_RULES.md.hbs
441
+ ARCHITECTURE.md.hbs
442
+ PROJECT_MEMORY.md.hbs
443
+
444
+ setup.sql ← PostgreSQL schema (run once)
445
+ .env.example ← Environment variable template
446
+ ```
447
+
448
+ ---
449
+
450
+ ## Database schema
451
+
452
+ ```sql
453
+ CREATE TABLE memories (
454
+ id BIGSERIAL PRIMARY KEY,
455
+ type TEXT NOT NULL, -- decision | rule | pattern | note
456
+ scope TEXT NOT NULL, -- global | project
457
+ architecture TEXT, -- clean-architecture | mvc | etc.
458
+ project_name TEXT,
459
+ title TEXT,
460
+ content TEXT NOT NULL,
461
+ tags TEXT[],
462
+ embedding vector(768), -- nomic-embed-text output
463
+ created_at TIMESTAMP DEFAULT now()
464
+ );
465
+ ```
466
+
467
+ ---
468
+
469
+ ## Troubleshooting
470
+
471
+ ### `extension "vector" is not available`
472
+
473
+ pgvector is not installed for your PostgreSQL version. See [pgvector setup](#2-pgvector-setup) above.
474
+
475
+ ### `Cannot reach Ollama at http://localhost:11434`
476
+
477
+ Ollama is not running. Start it:
478
+
479
+ ```bash
480
+ brew services start ollama # macOS
481
+ ollama serve # Linux / manual
482
+ ```
483
+
484
+ ### `DATABASE_URL is not set`
485
+
486
+ Create a `.env` file in the project root with your database URL. See [Configure environment](#6-configure-environment).
487
+
488
+ ### `createdb: error: database creation failed: ERROR: role does not exist`
489
+
490
+ Your PostgreSQL user does not exist. Create it:
491
+
492
+ ```bash
493
+ createuser -s $(whoami)
494
+ ```
495
+
496
+ ### Search returns fewer results than expected
497
+
498
+ This is normal when the database has fewer than 100 memories. The ivfflat index is optimized for large datasets. Results improve as you add more memories.
499
+
500
+ ---
501
+
502
+ ## Development
503
+
504
+ ```bash
505
+ git clone https://github.com/your-org/memory-core.git
506
+ cd memory-core
507
+ npm install
508
+ npm run build # compile TypeScript → dist/
509
+ npm run dev # run with tsx (no build needed)
510
+ ```
511
+
512
+ Run a command locally:
513
+
514
+ ```bash
515
+ node dist/cli.js remember "my decision"
516
+ node dist/cli.js search "query"
517
+ ```
518
+
519
+ ---
520
+
521
+ ## Publishing
522
+
523
+ ```bash
524
+ npm login --scope=@archmind
525
+ npm publish --access public
526
+ ```
527
+
528
+ After publishing, anyone can use:
529
+
530
+ ```bash
531
+ npx @archmind/memory-core init
532
+ ```
533
+
534
+ ---
535
+
536
+ ## License
537
+
538
+ MIT