@shahmilsaari/memory-core 0.1.0 → 0.1.2

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.
Files changed (3) hide show
  1. package/README.md +234 -307
  2. package/dist/cli.js +37 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,19 +1,34 @@
1
- # @archmind/memory-core
1
+ # @shahmilsaari/memory-core
2
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.
3
+ Universal AI memory for any project. Install once, and every AI coding agent — Copilot, Cursor, Claude Code, Windsurf, Cline, and 13 more — automatically follows your architecture rules, past decisions, and best practices. Backed by PostgreSQL + pgvector and fully local AI via Ollama. No OpenAI key required.
4
+
5
+ ```bash
6
+ npx @shahmilsaari/memory-core init
7
+ ```
4
8
 
5
9
  ---
6
10
 
7
11
  ## How it works
8
12
 
9
13
  ```
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
14
+ memory-core init
15
+
16
+ ├── You pick: Backend / Frontend / Fullstack
17
+ ├── You pick: Architecture (Clean, MVC, React, Vue, …)
18
+
19
+
20
+ PostgreSQL + pgvector
21
+ 192 predefined rules — each with a WHY
22
+ + your own saved decisions
23
+
24
+
25
+ 18 AI agent config files generated
26
+
27
+
28
+ Every agent reads its file → follows your rules
29
+
30
+ git commit → pre-commit hook → Ollama checks diff
31
+ → violations blocked with Rule + Why + Fix
17
32
  ```
18
33
 
19
34
  ---
@@ -21,10 +36,10 @@ Your central PostgreSQL database (memories + rules)
21
36
  ## Supported agents
22
37
 
23
38
  | Agent | File generated |
24
- |-------|---------------|
39
+ |---|---|
40
+ | Claude Code | `CLAUDE.md` |
25
41
  | GitHub Copilot | `.github/copilot-instructions.md` |
26
42
  | Cursor | `.cursorrules` + `.cursor/rules/memory-core.mdc` |
27
- | Claude Code | `CLAUDE.md` |
28
43
  | Windsurf | `.windsurfrules` |
29
44
  | Cline | `.clinerules` |
30
45
  | Roo Code | `.roo/rules/memory-core.md` |
@@ -35,195 +50,155 @@ Your central PostgreSQL database (memories + rules)
35
50
  | Gemini Code Assist | `.gemini/styleguide.md` |
36
51
  | Zed AI | `.zed/settings.json` |
37
52
  | JetBrains AI | `.idea/ai-instructions.md` |
53
+ | OpenHands / AGENTS | `AGENTS.md` |
38
54
 
39
- Plus: `AGENTS.md`, `AI_RULES.md`, `ARCHITECTURE.md`, `PROJECT_MEMORY.md`
55
+ Plus: `AI_RULES.md`, `ARCHITECTURE.md`, `PROJECT_MEMORY.md`
40
56
 
41
57
  ---
42
58
 
43
59
  ## Prerequisites
44
60
 
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)
61
+ | Requirement | Purpose |
62
+ |---|---|
63
+ | PostgreSQL 14+ | Memory storage |
64
+ | pgvector | Semantic similarity search |
65
+ | Ollama + `nomic-embed-text` | Free local embeddings (no API key) |
66
+ | Ollama + `llama3.2` | Pre-commit rule checking |
50
67
 
51
68
  ---
52
69
 
53
- ## 1. PostgreSQL setup
70
+ ## Setup
54
71
 
55
- ### macOS (Homebrew)
72
+ ### 1. PostgreSQL
56
73
 
74
+ **macOS**
57
75
  ```bash
58
76
  brew install postgresql@16
59
77
  brew services start postgresql@16
60
78
  ```
61
79
 
62
- Verify it is running:
63
-
64
- ```bash
65
- psql -U $(whoami) -l
66
- ```
67
-
68
- ### Linux (Ubuntu/Debian)
69
-
80
+ **Linux**
70
81
  ```bash
71
82
  sudo apt install postgresql postgresql-contrib
72
83
  sudo systemctl start postgresql
73
84
  ```
74
85
 
75
- ### Windows
76
-
77
- Download and install from [postgresql.org](https://www.postgresql.org/download/windows/).
86
+ **Windows** — download from [postgresql.org](https://www.postgresql.org/download/windows/)
78
87
 
79
88
  ---
80
89
 
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:
90
+ ### 2. pgvector
88
91
 
92
+ **macOS with PostgreSQL@16** (brew pgvector only targets pg17+, build from source):
89
93
  ```bash
90
- # Install build tools if needed
91
94
  xcode-select --install
92
-
93
- # Clone and build for PostgreSQL@16
94
95
  git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git /tmp/pgvector
95
96
  cd /tmp/pgvector
96
97
  make PG_CONFIG=/opt/homebrew/opt/postgresql@16/bin/pg_config
97
98
  make install PG_CONFIG=/opt/homebrew/opt/postgresql@16/bin/pg_config
98
99
  ```
99
100
 
100
- ### macOS with PostgreSQL@17+ (Homebrew)
101
-
101
+ **macOS with PostgreSQL@17+**
102
102
  ```bash
103
103
  brew install pgvector
104
104
  ```
105
105
 
106
- ### Linux (Ubuntu/Debian)
107
-
106
+ **Linux**
108
107
  ```bash
109
- sudo apt install postgresql-16-pgvector
110
- # Replace 16 with your PostgreSQL version
108
+ sudo apt install postgresql-16-pgvector # replace 16 with your version
111
109
  ```
112
110
 
113
- ### Verify pgvector is installed
114
-
111
+ Verify:
115
112
  ```bash
116
113
  psql -U $(whoami) -c "SELECT * FROM pg_available_extensions WHERE name = 'vector';"
117
114
  ```
118
115
 
119
- You should see a row with `name = vector`.
120
-
121
116
  ---
122
117
 
123
- ## 3. Ollama setup
124
-
125
- Ollama runs the embedding model locally. No API key or internet connection required after setup.
126
-
127
- ### macOS
118
+ ### 3. Ollama
128
119
 
120
+ **macOS**
129
121
  ```bash
130
122
  brew install ollama
131
123
  brew services start ollama
132
124
  ```
133
125
 
134
- ### Linux
135
-
126
+ **Linux**
136
127
  ```bash
137
128
  curl -fsSL https://ollama.com/install.sh | sh
138
129
  ollama serve &
139
130
  ```
140
131
 
141
- ### Windows
142
-
143
- Download from [ollama.com](https://ollama.com/download).
144
-
145
- ### Pull the embedding model
132
+ **Windows** — download from [ollama.com](https://ollama.com/download)
146
133
 
134
+ Pull the required models:
147
135
  ```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"
136
+ ollama pull nomic-embed-text # embeddings — used by remember/search/sync
137
+ ollama pull llama3.2 # code analysis — used by pre-commit hook
156
138
  ```
157
139
 
158
140
  ---
159
141
 
160
- ## 4. Create the database
142
+ ### 4. Create the database
161
143
 
162
144
  ```bash
163
145
  createdb memory_core
164
146
  ```
165
147
 
166
- Then run the setup SQL to create the table and indexes:
167
-
148
+ Then run the schema (get `setup.sql` from the repo or copy below):
168
149
  ```bash
169
150
  psql -U $(whoami) -d memory_core -f setup.sql
170
151
  ```
171
152
 
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
153
+ `setup.sql` contents:
154
+ ```sql
155
+ CREATE EXTENSION IF NOT EXISTS vector;
193
156
 
194
- ```bash
195
- npm install -g @archmind/memory-core
196
- memory-core init
197
- ```
157
+ CREATE TABLE IF NOT EXISTS memories (
158
+ id BIGSERIAL PRIMARY KEY,
159
+ type TEXT NOT NULL,
160
+ scope TEXT NOT NULL DEFAULT 'project',
161
+ architecture TEXT,
162
+ project_name TEXT,
163
+ title TEXT,
164
+ content TEXT NOT NULL,
165
+ reason TEXT,
166
+ tags TEXT[] DEFAULT '{}',
167
+ embedding vector(768),
168
+ created_at TIMESTAMP DEFAULT now()
169
+ );
198
170
 
199
- ### Or clone and run locally (development)
171
+ CREATE INDEX IF NOT EXISTS memories_embedding_idx
172
+ ON memories USING ivfflat (embedding vector_cosine_ops)
173
+ WITH (lists = 100);
200
174
 
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
175
+ CREATE INDEX IF NOT EXISTS memories_architecture_idx ON memories (architecture);
176
+ CREATE INDEX IF NOT EXISTS memories_scope_idx ON memories (scope);
207
177
  ```
208
178
 
209
179
  ---
210
180
 
211
- ## 6. Configure environment
181
+ ### 5. Configure environment
212
182
 
213
- Create a `.env` file in the project root (or `.memory-core.env` for per-project config):
183
+ Create `.env` in the project where you run memory-core (or `.memory-core.env` per project):
214
184
 
215
185
  ```env
216
186
  DATABASE_URL=postgresql://YOUR_USERNAME@localhost:5432/memory_core
217
187
  OLLAMA_URL=http://localhost:11434
218
188
  OLLAMA_MODEL=nomic-embed-text
189
+ OLLAMA_CHAT_MODEL=llama3.2
219
190
  ```
220
191
 
221
- Replace `YOUR_USERNAME` with your system username. On macOS with Homebrew, this is typically your macOS username with no password.
192
+ Find your username: `whoami`
193
+
194
+ ---
222
195
 
223
- To find your username:
196
+ ### 6. Seed the database
197
+
198
+ Load 192 predefined best-practice rules (each with a reason explaining why it exists):
224
199
 
225
200
  ```bash
226
- whoami
201
+ npx @shahmilsaari/memory-core seed
227
202
  ```
228
203
 
229
204
  ---
@@ -232,304 +207,256 @@ whoami
232
207
 
233
208
  ### `init` — Set up a project
234
209
 
235
- Run once inside any Git project:
236
-
237
210
  ```bash
238
- cd /path/to/your-project
239
- npx @archmind/memory-core init
211
+ cd your-project
212
+ npx @shahmilsaari/memory-core init
240
213
  ```
241
214
 
242
- You will be asked:
243
-
215
+ Interactive prompts:
244
216
  ```
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
217
+ Project name? → my-api
218
+ Project type? Backend / Frontend / Fullstack
219
+ Backend architecture? Clean Architecture
220
+ Frontend framework? (skipped for backend-only)
221
+ Language? TypeScript
222
+ Install caveman? → no
251
223
  ```
252
224
 
253
- This creates all AI agent config files in the project and saves `.memory-core.json` to remember your choices.
225
+ Generates all 18 agent config files and saves `.memory-core.json`.
254
226
 
255
227
  ---
256
228
 
257
- ### `sync` — Refresh AI files
258
-
259
- After adding new memories, regenerate all agent files:
229
+ ### `sync` — Regenerate all agent files
260
230
 
261
231
  ```bash
262
- npx @archmind/memory-core sync
232
+ npx @shahmilsaari/memory-core sync
263
233
  ```
264
234
 
265
- Pulls the latest relevant memories from the database and rewrites all generated files.
235
+ Re-pulls memories from the DB and rewrites all 18 files. Run after `remember` or `seed`.
266
236
 
267
237
  ---
268
238
 
269
239
  ### `remember` — Save a decision
270
240
 
271
241
  ```bash
272
- npx @archmind/memory-core remember "Controllers must only validate input and call use cases"
242
+ npx @shahmilsaari/memory-core remember "Controllers must never call the database directly"
273
243
  ```
274
244
 
275
- With options:
245
+ Prompts: _"Why does this rule exist?"_ — the reason is stored and shown to agents and developers when a violation is caught.
276
246
 
247
+ With flags:
277
248
  ```bash
278
- npx @archmind/memory-core remember "Use DTOs for all API responses" \
249
+ npx @shahmilsaari/memory-core remember "Use DTOs for all API responses" \
279
250
  --type rule \
280
251
  --scope global \
252
+ --reason "Raw DB entities leak internal schema and expose sensitive fields to clients" \
281
253
  --tags "api,dto,response"
282
254
  ```
283
255
 
284
- | Option | Values | Default |
285
- |--------|--------|---------|
286
- | `--type` | `decision`, `rule`, `pattern`, `note` | `decision` |
287
- | `--scope` | `global`, `project` | `project` |
256
+ | Flag | Values | Default |
257
+ |---|---|---|
258
+ | `--type` | `decision` `rule` `pattern` `note` | `decision` |
259
+ | `--scope` | `global` `project` | `project` |
260
+ | `--reason` | free text | prompted interactively |
288
261
  | `--tags` | comma-separated | none |
289
262
 
290
263
  ---
291
264
 
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`.
265
+ ### `search` — Semantic search
295
266
 
296
267
  ```bash
297
- npx @archmind/memory-core global
268
+ npx @shahmilsaari/memory-core search "error handling"
269
+ npx @shahmilsaari/memory-core search "auth strategy" --limit 10
298
270
  ```
299
271
 
300
- With architecture filter:
272
+ ---
273
+
274
+ ### `seed` — Load predefined rules
301
275
 
302
276
  ```bash
303
- npx @archmind/memory-core global --arch clean-architecture
277
+ npx @shahmilsaari/memory-core seed
278
+ npx @shahmilsaari/memory-core seed --arch clean-architecture # one architecture only
279
+ npx @shahmilsaari/memory-core seed --force # re-seed existing entries
304
280
  ```
305
281
 
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.
282
+ 192 rules across all architectures. Every rule includes a `reason` explaining why it exists.
320
283
 
321
284
  ---
322
285
 
323
- ### `search` — Find past decisions
286
+ ### `hook install` — Pre-commit enforcement
324
287
 
325
288
  ```bash
326
- npx @archmind/memory-core search "auth architecture"
289
+ npx @shahmilsaari/memory-core hook install
327
290
  ```
328
291
 
329
- With limit:
292
+ Installs a git pre-commit hook. Every `git commit` automatically checks staged source files against your architecture rules using Ollama (llama3.2). Violations are blocked with full context:
330
293
 
331
- ```bash
332
- npx @archmind/memory-core search "database access" --limit 10
333
294
  ```
295
+ ✗ 2 rule violations found — commit blocked
334
296
 
335
- ---
297
+ [1] src/controllers/user.ts:32
298
+ Rule: Thin controllers — business logic belongs in services
299
+ Why: Logic in controllers cannot be reused from CLI, queues, or other
300
+ entry points — it gets siloed and duplicated across handlers
301
+ Issue: Password validation logic inside route handler
302
+ Fix: Move to UserService.validateCredentials()
336
303
 
337
- ## Architecture profiles
304
+ [2] src/domain/user.entity.ts:5
305
+ Rule: Domain has zero external imports
306
+ Why: Framework imports in the domain layer tie business logic to
307
+ infrastructure — you can't swap the DB or test without spinning up the stack
308
+ Issue: Imports 'typeorm' directly
309
+ Fix: Define IUserRepository interface in domain, implement in infrastructure/
338
310
 
339
- Choose from six built-in profiles during `init`:
311
+ To bypass (not recommended): git commit --no-verify
312
+ To save as memory: memory-core remember "<lesson>"
313
+ ```
340
314
 
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 |
315
+ ```bash
316
+ npx @shahmilsaari/memory-core hook uninstall # remove the hook
317
+ ```
349
318
 
350
319
  ---
351
320
 
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:
321
+ ### `check` Manual rule check
357
322
 
358
- | Level | Style |
359
- |-------|-------|
360
- | `lite` | Professional terseness |
361
- | `full` | Caveman mode (default) |
362
- | `ultra` | Telegraphic, minimum words |
323
+ ```bash
324
+ npx @shahmilsaari/memory-core check --staged # check staged files
325
+ npx @shahmilsaari/memory-core check --staged --verbose # show model + diff details
326
+ ```
363
327
 
364
- caveman rules are injected into every generated agent file automatically.
328
+ Same as the pre-commit hook useful in CI/CD pipelines.
365
329
 
366
330
  ---
367
331
 
368
- ## Typical workflow
332
+ ### `global` — Sync to all agents globally
369
333
 
370
- ### New project
334
+ Writes your rules to the global config of every installed agent — so they follow your rules in every project without running `init`:
371
335
 
372
336
  ```bash
373
- git clone https://github.com/your-org/new-api.git
374
- cd new-api
375
- npx @archmind/memory-core init
337
+ npx @shahmilsaari/memory-core global
376
338
  ```
377
339
 
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
- ```
340
+ | Agent | Global file |
341
+ |---|---|
342
+ | Claude Code | `~/.claude/CLAUDE.md` |
343
+ | GitHub Copilot | VS Code `settings.json` |
344
+ | Cursor | `~/.cursor/rules/memory-core.mdc` |
345
+ | Cline | VS Code `settings.json` |
346
+ | Continue.dev | `~/.continue/config.json` |
347
+ | Aider | `~/.aider.conf.yml` |
348
+ | Zed AI | `~/.config/zed/settings.json` |
349
+ | Windsurf | `~/.windsurf/rules/memory-core.md` |
388
350
 
389
- ### Sync all projects after saving new decisions
351
+ ---
390
352
 
391
- ```bash
392
- npx @archmind/memory-core sync
393
- ```
353
+ ## Architecture profiles
394
354
 
395
- ### Search before making an architectural decision
355
+ ### Backend
356
+ | Profile | Best for |
357
+ |---|---|
358
+ | **Clean Architecture** | Domain-driven APIs, strict layer separation |
359
+ | **Modular Monolith** | Feature modules that could become microservices |
360
+ | **MVC** | Standard web apps, controllers + services |
361
+ | **Hexagonal** | Port/adapter isolation, highly testable cores |
362
+ | **Next.js** | Next.js 13+ fullstack (server components + actions) |
363
+ | **Laravel** | Laravel APIs with service-repository pattern |
364
+
365
+ ### Frontend
366
+ | Profile | Best for |
367
+ |---|---|
368
+ | **React** | Functional components, hooks, React Query, Zustand |
369
+ | **Vue 3** | Composition API, Pinia, composables |
370
+ | **Angular** | Standalone components, signals, OnPush |
371
+ | **Svelte** | Svelte 5 runes, SvelteKit load functions |
372
+ | **Nuxt 3** | Fullstack Vue with SSR, server routes |
373
+ | **React Native** | Mobile apps, FlatList, secure storage |
396
374
 
397
- ```bash
398
- npx @archmind/memory-core search "error handling strategy"
399
- ```
375
+ Fullstack projects get dual sections — one for backend, one for frontend — in every generated agent file.
400
376
 
401
377
  ---
402
378
 
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
- ---
379
+ ## Caveman token saver (optional)
449
380
 
450
- ## Database schema
381
+ Compresses AI responses 65–75% by stripping filler words. Enabled optionally during `init`. Injected into every agent file automatically.
451
382
 
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
- ```
383
+ | Level | Style |
384
+ |---|---|
385
+ | `lite` | Professional terseness |
386
+ | `full` | Caveman mode |
387
+ | `ultra` | Telegraphic, minimum words |
466
388
 
467
389
  ---
468
390
 
469
- ## Troubleshooting
391
+ ## Typical workflow
470
392
 
471
- ### `extension "vector" is not available`
393
+ ```bash
394
+ # New project
395
+ cd my-api
396
+ npx @shahmilsaari/memory-core init
397
+ npx @shahmilsaari/memory-core hook install
472
398
 
473
- pgvector is not installed for your PostgreSQL version. See [pgvector setup](#2-pgvector-setup) above.
399
+ # Save a decision mid-project
400
+ npx @shahmilsaari/memory-core remember "All auth goes through middleware, never duplicated in controllers" \
401
+ --type decision --scope global
474
402
 
475
- ### `Cannot reach Ollama at http://localhost:11434`
403
+ # Sync agent files after new decisions
404
+ npx @shahmilsaari/memory-core sync
476
405
 
477
- Ollama is not running. Start it:
406
+ # Search before making an architectural decision
407
+ npx @shahmilsaari/memory-core search "caching strategy"
478
408
 
479
- ```bash
480
- brew services start ollama # macOS
481
- ollama serve # Linux / manual
409
+ # Try to commit code that breaks rules → hook blocks it with explanation
410
+ git commit -m "add user endpoint"
482
411
  ```
483
412
 
484
- ### `DATABASE_URL is not set`
413
+ ---
485
414
 
486
- Create a `.env` file in the project root with your database URL. See [Configure environment](#6-configure-environment).
415
+ ## Environment variables
487
416
 
488
- ### `createdb: error: database creation failed: ERROR: role does not exist`
417
+ | Variable | Required | Default | Description |
418
+ |---|---|---|---|
419
+ | `DATABASE_URL` | Yes | — | PostgreSQL connection string |
420
+ | `OLLAMA_URL` | No | `http://localhost:11434` | Ollama server URL |
421
+ | `OLLAMA_MODEL` | No | `nomic-embed-text` | Embedding model |
422
+ | `OLLAMA_CHAT_MODEL` | No | `llama3.2` | Chat model for pre-commit checks |
489
423
 
490
- Your PostgreSQL user does not exist. Create it:
424
+ ---
491
425
 
492
- ```bash
493
- createuser -s $(whoami)
494
- ```
426
+ ## Troubleshooting
495
427
 
496
- ### Search returns fewer results than expected
428
+ **`extension "vector" is not available`**
429
+ pgvector not installed for your PostgreSQL version. See [pgvector setup](#2-pgvector-setup).
497
430
 
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.
431
+ **`Ollama not running skipping rule check`**
432
+ Start Ollama: `brew services start ollama` (macOS) or `ollama serve` (Linux).
499
433
 
500
- ---
434
+ **`Chat model "llama3.2" not found`**
435
+ Pull the model: `ollama pull llama3.2`. Or set `OLLAMA_CHAT_MODEL=mistral` in `.env`.
501
436
 
502
- ## Development
437
+ **`DATABASE_URL is not set`**
438
+ Create `.env` in your project root. See [Configure environment](#5-configure-environment).
503
439
 
440
+ **`createdb: role does not exist`**
504
441
  ```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)
442
+ createuser -s $(whoami)
510
443
  ```
511
444
 
512
- Run a command locally:
513
-
514
- ```bash
515
- node dist/cli.js remember "my decision"
516
- node dist/cli.js search "query"
517
- ```
445
+ **Pre-commit hook flagging config/JSON files**
446
+ The hook only checks source files (`.ts .tsx .js .jsx .py .php .rb .go .java .cs .swift .kt .rs .vue .svelte`). Config and env files are automatically skipped.
518
447
 
519
448
  ---
520
449
 
521
- ## Publishing
522
-
523
- ```bash
524
- npm login --scope=@archmind
525
- npm publish --access public
526
- ```
527
-
528
- After publishing, anyone can use:
450
+ ## Roadmap
529
451
 
530
- ```bash
531
- npx @archmind/memory-core init
532
- ```
452
+ | Feature | Description |
453
+ |---|---|
454
+ | CI/CD check | GitHub Actions workflow — fails PRs that violate rules |
455
+ | Watch mode | `memory-core watch` — checks files on save in real-time |
456
+ | Violation memory | Auto-save caught violations as "never do X, do Y" memories |
457
+ | Rule analytics | Track which rules break most, which files are worst offenders |
458
+ | Team sync | `memory-core push/pull` — shared memory pool across the whole team |
459
+ | Memory review | `memory-core approve` — team sign-off before rules propagate |
533
460
 
534
461
  ---
535
462
 
package/dist/cli.js CHANGED
@@ -5,7 +5,7 @@ import { Command } from "commander";
5
5
  import { input, select, confirm } from "@inquirer/prompts";
6
6
  import chalk2 from "chalk";
7
7
  import ora from "ora";
8
- import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync2 } from "fs";
8
+ import { readFileSync as readFileSync4, writeFileSync as writeFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync2, appendFileSync } from "fs";
9
9
  import { join as join5, dirname as dirname2 } from "path";
10
10
  import { homedir } from "os";
11
11
  import { execSync as execSync2 } from "child_process";
@@ -829,6 +829,42 @@ program.name("memory-core").description("Universal AI memory core \u2014 generat
829
829
  program.command("init").description("Initialize memory-core in the current project").action(async () => {
830
830
  console.log(chalk2.bold.cyan("\n memory-core init\n"));
831
831
  const detected = detectProject();
832
+ const envPath = join5(process.cwd(), ".memory-core.env");
833
+ const hasEnv = existsSync5(envPath) || existsSync5(join5(process.cwd(), ".env")) || !!process.env.DATABASE_URL;
834
+ if (!hasEnv) {
835
+ console.log(chalk2.dim(" No .memory-core.env found \u2014 let's set up your database connection.\n"));
836
+ const dbUser = process.env.USER ?? process.env.USERNAME ?? "postgres";
837
+ const dbUrl = await input({
838
+ message: "PostgreSQL connection URL?",
839
+ default: `postgresql://${dbUser}@localhost:5432/memory_core`
840
+ });
841
+ const ollamaUrl = await input({
842
+ message: "Ollama URL?",
843
+ default: "http://localhost:11434"
844
+ });
845
+ const envContent = [
846
+ `DATABASE_URL=${dbUrl}`,
847
+ `OLLAMA_URL=${ollamaUrl}`,
848
+ `OLLAMA_MODEL=nomic-embed-text`,
849
+ `OLLAMA_CHAT_MODEL=llama3.2`
850
+ ].join("\n") + "\n";
851
+ writeFileSync3(envPath, envContent);
852
+ process.env.DATABASE_URL = dbUrl;
853
+ process.env.OLLAMA_URL = ollamaUrl;
854
+ process.env.OLLAMA_MODEL = "nomic-embed-text";
855
+ process.env.OLLAMA_CHAT_MODEL = "llama3.2";
856
+ const gitignorePath = join5(process.cwd(), ".gitignore");
857
+ if (existsSync5(gitignorePath)) {
858
+ const gi = readFileSync4(gitignorePath, "utf-8");
859
+ if (!gi.includes(".memory-core.env")) {
860
+ appendFileSync(gitignorePath, "\n.memory-core.env\n");
861
+ }
862
+ } else {
863
+ writeFileSync3(gitignorePath, ".memory-core.env\n");
864
+ }
865
+ console.log(chalk2.green("\n \u2713 .memory-core.env created"));
866
+ console.log(chalk2.gray(" Added to .gitignore \u2014 your DB credentials stay local.\n"));
867
+ }
832
868
  const projectName = await input({
833
869
  message: "Project name?",
834
870
  default: process.cwd().split("/").pop() ?? "my-project"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shahmilsaari/memory-core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Universal AI memory core — generate AI context files from architecture profiles with RAG support",
5
5
  "type": "module",
6
6
  "bin": {