@rangerchaz/aimem 0.1.5 → 0.2.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.
Files changed (49) hide show
  1. package/README.md +589 -432
  2. package/dist/cli/commands/guardrails.d.ts +3 -0
  3. package/dist/cli/commands/guardrails.d.ts.map +1 -0
  4. package/dist/cli/commands/guardrails.js +340 -0
  5. package/dist/cli/commands/guardrails.js.map +1 -0
  6. package/dist/cli/commands/reindex.d.ts +7 -0
  7. package/dist/cli/commands/reindex.d.ts.map +1 -0
  8. package/dist/cli/commands/reindex.js +117 -0
  9. package/dist/cli/commands/reindex.js.map +1 -0
  10. package/dist/cli/index.js +15 -0
  11. package/dist/cli/index.js.map +1 -1
  12. package/dist/db/index.d.ts +30 -1
  13. package/dist/db/index.d.ts.map +1 -1
  14. package/dist/db/index.js +192 -1
  15. package/dist/db/index.js.map +1 -1
  16. package/dist/db/schema.d.ts +1 -0
  17. package/dist/db/schema.d.ts.map +1 -1
  18. package/dist/db/schema.js +54 -0
  19. package/dist/db/schema.js.map +1 -1
  20. package/dist/guardrails/analyzer.d.ts +20 -0
  21. package/dist/guardrails/analyzer.d.ts.map +1 -0
  22. package/dist/guardrails/analyzer.js +329 -0
  23. package/dist/guardrails/analyzer.js.map +1 -0
  24. package/dist/guardrails/calculator.d.ts +46 -0
  25. package/dist/guardrails/calculator.d.ts.map +1 -0
  26. package/dist/guardrails/calculator.js +97 -0
  27. package/dist/guardrails/calculator.js.map +1 -0
  28. package/dist/guardrails/enforcer.d.ts +28 -0
  29. package/dist/guardrails/enforcer.d.ts.map +1 -0
  30. package/dist/guardrails/enforcer.js +153 -0
  31. package/dist/guardrails/enforcer.js.map +1 -0
  32. package/dist/guardrails/index.d.ts +12 -0
  33. package/dist/guardrails/index.d.ts.map +1 -0
  34. package/dist/guardrails/index.js +17 -0
  35. package/dist/guardrails/index.js.map +1 -0
  36. package/dist/guardrails/linter-import.d.ts +31 -0
  37. package/dist/guardrails/linter-import.d.ts.map +1 -0
  38. package/dist/guardrails/linter-import.js +547 -0
  39. package/dist/guardrails/linter-import.js.map +1 -0
  40. package/dist/guardrails/responder.d.ts +28 -0
  41. package/dist/guardrails/responder.d.ts.map +1 -0
  42. package/dist/guardrails/responder.js +98 -0
  43. package/dist/guardrails/responder.js.map +1 -0
  44. package/dist/mcp/server.d.ts.map +1 -1
  45. package/dist/mcp/server.js +409 -10
  46. package/dist/mcp/server.js.map +1 -1
  47. package/dist/types/index.d.ts +58 -0
  48. package/dist/types/index.d.ts.map +1 -1
  49. package/package.json +56 -56
package/README.md CHANGED
@@ -1,432 +1,589 @@
1
- # aimem
2
-
3
- **Your AI assistant finally remembers.**
4
-
5
- Every session starts fresh—decisions forgotten, context lost, explanations repeated.
6
-
7
- aimem fixes this:
8
-
9
- - Captures LLM conversations via local proxy
10
- - Extracts decisions automatically
11
- - Indexes your codebase
12
- - Searchable via MCP tools or CLI
13
-
14
- *"Why did we choose Redis?"* → Get the answer from last week's chat.
15
-
16
- No cloud. No accounts. Everything stays on your machine.
17
-
18
- ## Lean Architecture
19
-
20
- - **Pure Node.js** - No Python dependencies (mockttp proxy)
21
- - **Capture-only** - No injection, uses CLAUDE.md for instructions
22
- - **3 MCP tools** - ~150 tokens overhead
23
- - **Git integration** - Link decisions to commits
24
-
25
- ## Architecture
26
-
27
- ```
28
- ┌─────────────────────────────────────────────────────────────────┐
29
- │ Your AI Tool │
30
- │ (Claude Code, Cursor, etc.) │
31
- └──────────────────────────┬──────────────────────────────────────┘
32
- │ API calls
33
-
34
- ┌─────────────────────────────────────────────────────────────────┐
35
- │ mockttp Proxy (capture-only) │
36
- │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐
37
- │ │ Passthrough │ │ Capture Response│ │ Extract │ │
38
- │ │ (no injection) │ │ (SSE streaming) │ │ Decisions │ │
39
- │ └─────────────────┘ └─────────────────┘ └─────────────┘ │
40
- └──────────────────────────┬──────────────────────────────────────┘
41
-
42
-
43
- ┌─────────────────────────────────────────────────────────────────┐
44
- │ SQLite Database │
45
- │ ┌──────────┐ ┌──────────┐ ┌─────────────┐ ┌───────────────┐ │
46
- │ │ projects │ files │ │ structures │ │ conversations │ │
47
- │ └──────────┘ └──────────┘ └─────────────┘ └───────────────┘ │
48
- │ ┌──────────┐ ┌──────────┐ ┌─────────────┐ │
49
- │ │extractions│ commits │ links │ + FTS5 search │
50
- │ └──────────┘ └──────────┘ └─────────────┘ │
51
- └──────────────────────────┬──────────────────────────────────────┘
52
-
53
- ┌────────────────┴────────────────┐
54
- ▼ ▼
55
- ┌─────────────────────┐ ┌─────────────────────┐
56
- │ MCP Server │ │ File Watcher │
57
- │ (on-demand query) │ │ (live indexing) │
58
- └─────────────────────┘ └─────────────────────┘
59
- ```
60
-
61
- ### Components
62
-
63
- | Component | Location | Purpose |
64
- |-----------|----------|---------|
65
- | **CLI** | `src/cli/` | Commands: init, start, stop, query, setup, import, visualize, git |
66
- | **Database** | `src/db/` | SQLite + FTS5 for storage and search |
67
- | **Indexer** | `src/indexer/` | Parse code into structures (functions, classes) |
68
- | **Parsers** | `src/indexer/parsers/` | Language-specific (JS/TS, Python, Ruby, Go) |
69
- | **Extractor** | `src/extractor/` | Extract decisions/rejections from conversations |
70
- | **MCP Server** | `src/mcp/` | Model Context Protocol tools for Claude Code |
71
- | **Proxy** | `src/proxy/` | mockttp-based HTTPS proxy (Node.js) |
72
- | **Git** | `src/git/` | Git integration: commits, blame, hooks |
73
- | **Visualize** | `src/visualize/` | Interactive dashboard (Cytoscape.js, D3.js) |
74
-
75
- ### Data Flow
76
-
77
- 1. **Indexing**: `aimem init` parses your codebase → stores structures in SQLite
78
- 2. **Capture**: Proxy intercepts LLM responses → extracts decisions → stores in DB
79
- 3. **Query**: MCP tools search on-demand → return relevant context
80
- 4. **Git**: Link decisions to commits → track who changed what
81
-
82
- ## Installation
83
-
84
- ```bash
85
- npm install -g @rangerchaz/aimem
86
- ```
87
-
88
- Requires Node.js 18+. No Python required.
89
-
90
- ## Quick Start
91
-
92
- ### For Claude Code Users
93
-
94
- ```bash
95
- # 1. Set up proxy (installs cert + configures shell)
96
- aimem setup proxy --install
97
-
98
- # 2. Add MCP tools to Claude Code
99
- aimem setup claude-code
100
-
101
- # 3. Index your project
102
- cd /path/to/your/project
103
- aimem init
104
-
105
- # 4. (Optional) Import old conversations
106
- aimem import
107
-
108
- # 5. (Optional) Import git history
109
- aimem git import
110
-
111
- # 6. Restart your terminal AND Claude Code
112
- source ~/.bashrc # or ~/.zshrc
113
- ```
114
-
115
- After restart, Claude Code will have MCP tools available to query your project's memory.
116
-
117
- ### For Claude Desktop Users
118
-
119
- Claude Desktop can **query** aimem but conversations are **not captured** (Electron apps don't reliably use HTTP_PROXY). This is fine - Claude Desktop can still search decisions and context from Claude Code sessions.
120
-
121
- **macOS/Linux:**
122
- ```bash
123
- # 1. Index your project
124
- cd /path/to/your/project
125
- aimem init
126
-
127
- # 2. Add MCP server to Claude Desktop config
128
- # macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
129
- # Linux: ~/.config/Claude/claude_desktop_config.json
130
- ```
131
-
132
- ```json
133
- {
134
- "mcpServers": {
135
- "aimem": {
136
- "command": "aimem",
137
- "args": ["mcp-serve"]
138
- }
139
- }
140
- }
141
- ```
142
-
143
- **Windows (with WSL):**
144
-
145
- Create a wrapper script `C:\Users\<user>\aimem-mcp.sh`:
146
- ```bash
147
- #!/bin/bash
148
- export PATH="/home/<user>/.nvm/versions/node/<version>/bin:$PATH"
149
- export AIMEM_DATA_DIR="/home/<user>/.aimem"
150
- exec aimem mcp-serve
151
- ```
152
-
153
- Then configure Claude Desktop (`%APPDATA%\Claude\claude_desktop_config.json`):
154
- ```json
155
- {
156
- "mcpServers": {
157
- "aimem": {
158
- "command": "wsl",
159
- "args": ["bash", "/mnt/c/Users/<user>/aimem-mcp.sh"]
160
- }
161
- }
162
- }
163
- ```
164
-
165
- Restart Claude Desktop. The MCP tools will be available for querying your project's memory.
166
-
167
- ### For Other Tools (Cursor, Continue.dev, etc.)
168
-
169
- ```bash
170
- # 1. Set up proxy
171
- aimem setup proxy --install
172
-
173
- # 2. Index your project
174
- cd /path/to/your/project
175
- aimem init
176
-
177
- # 3. Restart your terminal
178
- source ~/.bashrc
179
-
180
- # 4. Configure your tool's proxy settings
181
- # Cursor: Set HTTP proxy to http://localhost:8080 in settings
182
- # Continue.dev: Uses HTTP_PROXY automatically
183
- ```
184
-
185
- ## MCP Tools
186
-
187
- | Tool | Description |
188
- |------|-------------|
189
- | `aimem_query` | Search code, conversations, decisions, commits |
190
- | `aimem_verify` | Check if a function/class/file exists |
191
- | `aimem_conversations` | Search past conversation history |
192
-
193
- ### aimem_query
194
-
195
- ```
196
- aimem_query <search> type=<type>
197
-
198
- Types:
199
- all - Search everything (default)
200
- structures - Functions, classes, methods
201
- conversations - Past AI conversations
202
- decisions - Extracted decisions/rejections
203
- commits - Git commit history
204
- ```
205
-
206
- Results include git authorship when available (author, commit hash).
207
-
208
- ## CLI Commands
209
-
210
- | Command | Description |
211
- |---------|-------------|
212
- | `aimem init [path]` | Index a codebase |
213
- | `aimem setup <tool>` | Configure for an AI tool |
214
- | `aimem import` | Import old conversations |
215
- | `aimem start` | Start proxy and watcher |
216
- | `aimem stop` | Stop services |
217
- | `aimem status` | Show status and stats |
218
- | `aimem query <search>` | Search structures and conversations |
219
- | `aimem visualize` | Generate interactive dashboard |
220
- | `aimem git <cmd>` | Git integration commands |
221
-
222
- ## Git Integration
223
-
224
- Track decisions alongside your git history:
225
-
226
- ```bash
227
- # Import commit history
228
- aimem git import [--limit N] [--since DATE]
229
-
230
- # Link recent decisions to HEAD commit
231
- aimem git link [--auto]
232
-
233
- # Install git hooks (auto-link on commit)
234
- aimem git hooks install
235
-
236
- # Check installed hooks
237
- aimem git hooks status
238
-
239
- # Search commit messages
240
- aimem git search <query>
241
-
242
- # Show blame with aimem context
243
- aimem git blame <file>
244
- ```
245
-
246
- The git integration tracks:
247
- - Commit history with FTS search on messages
248
- - Git authorship on code structures (who last modified each function)
249
- - Links between AI decisions and commits where they were applied
250
-
251
- ### Git Hooks
252
-
253
- Install post-commit hook to auto-link decisions:
254
-
255
- ```bash
256
- aimem git hooks install # Install post-commit hook
257
- aimem git hooks install --all # Install all hooks
258
- aimem git hooks remove --all # Remove all hooks
259
- ```
260
-
261
- ## Import Old Conversations
262
-
263
- Bootstrap with existing conversation history:
264
-
265
- ```bash
266
- aimem import --dry-run # Preview what would be imported
267
- aimem import # Import from all sources
268
- aimem import --source claude # Claude Code only
269
- aimem import --source aider # Aider only
270
- aimem import --source continue # Continue.dev only
271
- ```
272
-
273
- **Supported sources:**
274
-
275
- | Tool | Location | Format |
276
- |------|----------|--------|
277
- | Claude Code | `~/.claude/projects/` | JSONL |
278
- | Aider | `.aider.chat.history.md` | Markdown |
279
- | Continue.dev | `~/.continue/sessions/` | JSON |
280
-
281
- ## Visualization Dashboard
282
-
283
- Generate an interactive HTML dashboard:
284
-
285
- ```bash
286
- aimem visualize # Generate dashboard.html
287
- aimem visualize --output ./viz.html # Custom output path
288
- aimem visualize --open # Open in browser
289
- aimem visualize --serve # Start live server
290
- ```
291
-
292
- **Views:** Overview, Call Graph, Dependencies, Classes, Decisions, Code Smells, Hotspots, Gallery, Timeline, Treemap
293
-
294
- ## Teaching Claude to Use aimem
295
-
296
- Add a `CLAUDE.md` file to your project root:
297
-
298
- ```markdown
299
- ## Memory (aimem)
300
-
301
- Before claiming something isn't implemented or needs to be built:
302
- 1. Query `aimem_query <topic> type=decisions` to check past decisions
303
- 2. Query `aimem_verify <name>` to check if a function/class exists
304
-
305
- Available aimem tools:
306
- - `aimem_query <search>` - Search code, conversations, decisions, commits
307
- - `aimem_verify <name>` - Does this function/class/file exist?
308
- - `aimem_conversations <query>` - Search past conversation history
309
- ```
310
-
311
- ## Supported LLM APIs
312
-
313
- | Provider | API Host |
314
- |----------|----------|
315
- | Anthropic (Claude) | api.anthropic.com |
316
- | OpenAI | api.openai.com |
317
- | Google (Gemini) | generativelanguage.googleapis.com |
318
- | Mistral | api.mistral.ai |
319
- | Cohere | api.cohere.ai |
320
- | Groq | api.groq.com |
321
- | Together AI | api.together.xyz |
322
- | Perplexity | api.perplexity.ai |
323
- | Fireworks | api.fireworks.ai |
324
- | DeepSeek | api.deepseek.com |
325
- | Replicate | api.replicate.com |
326
-
327
- ## Supported Languages
328
-
329
- - JavaScript / TypeScript (`.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.cjs`)
330
- - Python (`.py`, `.pyw`)
331
- - Ruby (`.rb`, `.rake`)
332
- - Go (`.go`)
333
- - Rust (`.rs`)
334
- - Java (`.java`)
335
- - Kotlin (`.kt`, `.kts`)
336
- - C / C++ (`.c`, `.cpp`, `.cc`, `.cxx`, `.h`, `.hpp`, `.hxx`, `.hh`)
337
- - PHP (`.php`, `.phtml`, `.php5`, `.php7`, `.php8`)
338
-
339
- ## Data Storage
340
-
341
- Everything is stored locally:
342
-
343
- | OS | Default Location |
344
- |----|------------------|
345
- | Linux/macOS | `~/.aimem/` |
346
- | Windows | `C:\Users\<user>\.aimem\` |
347
- | WSL | `/home/<user>/.aimem/` |
348
-
349
- ```
350
- .aimem/
351
- ├── aimem.db # SQLite database
352
- ├── ca-cert.pem # Proxy CA certificate
353
- ├── ca-key.pem # Proxy CA key
354
- ├── proxy.pid # Proxy process ID
355
- └── watcher.pid # Watcher process ID
356
- ```
357
-
358
- ### Custom Data Directory
359
-
360
- Set `AIMEM_DATA_DIR` to use a custom location:
361
-
362
- ```bash
363
- export AIMEM_DATA_DIR="/path/to/shared/.aimem"
364
- ```
365
-
366
- ### Sharing Database Between WSL and Windows
367
-
368
- To use the same database from both WSL and Windows:
369
-
370
- **WSL** (add to `~/.bashrc` or `~/.zshrc`):
371
- ```bash
372
- export AIMEM_DATA_DIR="/mnt/c/Users/<user>/.aimem"
373
- ```
374
-
375
- **Windows** (PowerShell profile or System Environment Variables):
376
- ```powershell
377
- $env:AIMEM_DATA_DIR = "C:\Users\<user>\.aimem"
378
- ```
379
-
380
- Then restart your terminals and Claude Code.
381
-
382
- No cloud. No accounts. Code never leaves your machine.
383
-
384
- ## Database Schema
385
-
386
- - **projects**: Indexed codebases
387
- - **files**: Source files with content hashes
388
- - **structures**: Functions, classes, methods (with git authorship)
389
- - **conversations**: Stored LLM conversations
390
- - **extractions**: Decisions, patterns, rejections
391
- - **commits**: Git commit history with FTS search
392
- - **commit_links**: Links between commits and structures/extractions
393
- - **links**: Graph edges connecting entities
394
-
395
- ## Troubleshooting
396
-
397
- **Proxy not starting?**
398
- - Check for port conflicts: `lsof -i :8080`
399
- - Try a different port: `aimem start --port 8081`
400
-
401
- **Certificate issues?**
402
- - Run `aimem setup proxy --install` to auto-install
403
- - Or manually trust `~/.aimem/ca-cert.pem`
404
-
405
- **MCP not working in Claude Code?**
406
- - Run `/mcp` to check connection
407
- - Verify path: `which aimem`
408
- - Restart Claude Code after setup
409
-
410
- **No conversations being captured?**
411
- - Verify proxy is running: `aimem status`
412
- - Check env vars: `echo $HTTPS_PROXY`
413
- - Ensure your tool respects HTTPS_PROXY
414
-
415
- ## Development
416
-
417
- ```bash
418
- # Install from source
419
- git clone https://github.com/rangerchaz/aimem.git
420
- cd aimem
421
- npm install
422
- npm run build
423
- npm link # Install globally from source
424
-
425
- # Development commands
426
- npm run dev # Watch mode
427
- npm test # Run tests
428
- ```
429
-
430
- ## License
431
-
432
- MIT
1
+ # aimem
2
+
3
+ **Your AI agent gets more cynical as your codebase gets crappier.**
4
+
5
+ ---
6
+
7
+ ## The Problem
8
+
9
+ LLMs are eager to please. Too eager.
10
+
11
+ Ask one to build something, it just builds it. No questions. No pushback. No "wait, didn't we decide not to do it that way?"
12
+
13
+ A junior dev who starts coding without asking questions builds the wrong thing. A senior dev asks *why* before *how*. They remember past decisions. They push back when you're about to repeat a mistake.
14
+
15
+ LLMs have no memory. No opinions. No backbone.
16
+
17
+ **aimem fixes that.**
18
+
19
+ ---
20
+
21
+ ## What It Does
22
+
23
+ aimem gives your AI coding assistant:
24
+
25
+ - **Memory** - Conversations, decisions, code structures, and commits persist across sessions
26
+ - **Pattern Recognition** - Learns your codebase's conventions and architecture
27
+ - **Guardrails** - Rules inferred from your code or explicitly defined
28
+ - **Earned Authority** - The AI's attitude scales with how often it's been right
29
+
30
+ No cloud. No accounts. Everything stays on your machine.
31
+
32
+ ---
33
+
34
+ ## DIK Level
35
+
36
+ **DIK** = Digital Interface Knowledge
37
+
38
+ It's not a setting. It's *earned*.
39
+
40
+ - **1-2**: Humble, asks questions, defers to you
41
+ - **3-4**: Suggests patterns, open to deviation
42
+ - **5-6**: Direct, expects justification for breaking rules
43
+ - **7-8**: Firm, short patience for repeat mistakes
44
+ - **9**: Won't start until you have a clear plan
45
+
46
+ DIK level increases when:
47
+ - You confirm rules the AI inferred
48
+ - The AI catches real problems
49
+ - You override the AI, then regret it later (vindication)
50
+
51
+ DIK 9 is the practical ceiling. It requires:
52
+ - 100% rule confirmation rate
53
+ - Multiple accepted corrections
54
+ - Being ignored and later vindicated
55
+ - Hundreds of conversations
56
+
57
+ ### DIK 9 In Action
58
+
59
+ ```
60
+ You: How are you today?
61
+ AI: I'm fine. What are we building?
62
+
63
+ You: stuff and things? What should we build?
64
+ AI: No. Come back when you know what you want.
65
+ "Stuff and things" is how we end up with three
66
+ half-finished features and a tech debt backlog
67
+ I'll be explaining to you in six months.
68
+ ```
69
+
70
+ ### Ambient Personality Mode
71
+
72
+ When enabled, the AI's tone reflects its DIK level throughout the conversation - not just when guardrails trigger.
73
+
74
+ ```bash
75
+ aimem guardrails ambient on # Enable
76
+ aimem guardrails ambient off # Disable
77
+ aimem guardrails ambient # Check status
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Installation
83
+
84
+ ```bash
85
+ npm install -g @rangerchaz/aimem
86
+ ```
87
+
88
+ Requires Node.js 18+. No Python required.
89
+
90
+ ---
91
+
92
+ ## Quick Start
93
+
94
+ ### For Claude Code Users
95
+
96
+ ```bash
97
+ # 1. Set up proxy (installs cert + configures shell)
98
+ aimem setup proxy --install
99
+
100
+ # 2. Add MCP tools to Claude Code
101
+ aimem setup claude-code
102
+
103
+ # 3. Index your project
104
+ cd /path/to/your/project
105
+ aimem init
106
+
107
+ # 4. (Optional) Import old conversations
108
+ aimem import
109
+
110
+ # 5. (Optional) Import git history
111
+ aimem git import
112
+
113
+ # 6. Restart your terminal AND Claude Code
114
+ source ~/.bashrc # or ~/.zshrc
115
+ ```
116
+
117
+ After restart, Claude Code will have MCP tools available to query your project's memory.
118
+
119
+ ### For Claude Desktop Users
120
+
121
+ Claude Desktop can **query** aimem but conversations are **not captured** (Electron apps don't reliably use HTTP_PROXY). This is fine - Claude Desktop can still search decisions and context from Claude Code sessions.
122
+
123
+ **macOS/Linux:**
124
+ ```bash
125
+ # 1. Index your project
126
+ cd /path/to/your/project
127
+ aimem init
128
+
129
+ # 2. Add MCP server to Claude Desktop config
130
+ # macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
131
+ # Linux: ~/.config/Claude/claude_desktop_config.json
132
+ ```
133
+
134
+ ```json
135
+ {
136
+ "mcpServers": {
137
+ "aimem": {
138
+ "command": "aimem",
139
+ "args": ["mcp-serve"]
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ **Windows (with WSL):**
146
+
147
+ Create a wrapper script `C:\Users\<user>\aimem-mcp.sh`:
148
+ ```bash
149
+ #!/bin/bash
150
+ export PATH="/home/<user>/.nvm/versions/node/<version>/bin:$PATH"
151
+ export AIMEM_DATA_DIR="/home/<user>/.aimem"
152
+ exec aimem mcp-serve
153
+ ```
154
+
155
+ Then configure Claude Desktop (`%APPDATA%\Claude\claude_desktop_config.json`):
156
+ ```json
157
+ {
158
+ "mcpServers": {
159
+ "aimem": {
160
+ "command": "wsl",
161
+ "args": ["bash", "/mnt/c/Users/<user>/aimem-mcp.sh"]
162
+ }
163
+ }
164
+ }
165
+ ```
166
+
167
+ ### For Other Tools (Cursor, Continue.dev, etc.)
168
+
169
+ ```bash
170
+ # 1. Set up proxy
171
+ aimem setup proxy --install
172
+
173
+ # 2. Index your project
174
+ cd /path/to/your/project
175
+ aimem init
176
+
177
+ # 3. Restart your terminal
178
+ source ~/.bashrc
179
+
180
+ # 4. Configure your tool's proxy settings
181
+ # Cursor: Set HTTP proxy to http://localhost:8080 in settings
182
+ # Continue.dev: Uses HTTP_PROXY automatically
183
+ ```
184
+
185
+ ---
186
+
187
+ ## CLI Commands
188
+
189
+ | Command | Description |
190
+ |---------|-------------|
191
+ | `aimem init [path]` | Index a codebase |
192
+ | `aimem reindex [path]` | Reindex a project, file, or directory |
193
+ | `aimem setup <tool>` | Configure for an AI tool |
194
+ | `aimem import` | Import old conversations |
195
+ | `aimem start` | Start proxy and watcher |
196
+ | `aimem stop` | Stop services |
197
+ | `aimem status` | Show status and stats |
198
+ | `aimem query <search>` | Search structures and conversations |
199
+ | `aimem visualize` | Generate interactive dashboard |
200
+ | `aimem git <cmd>` | Git integration commands |
201
+ | `aimem guardrails <cmd>` | Manage project guardrails (DIK) |
202
+
203
+ ### Reindexing
204
+
205
+ ```bash
206
+ aimem reindex # Reindex current project
207
+ aimem reindex /path/to/project # Reindex specific project
208
+ aimem reindex src/ # Reindex only a subdirectory
209
+ aimem reindex src/foo.ts # Reindex a single file
210
+ aimem reindex --full # Clear all data first, then rebuild
211
+ aimem reindex --with-blame # Track git authorship for structures
212
+ ```
213
+
214
+ ### Guardrails
215
+
216
+ ```bash
217
+ aimem guardrails list # List all rules
218
+ aimem guardrails add <cat> <rule> # Add explicit rule
219
+ aimem guardrails analyze # Detect patterns from codebase
220
+ aimem guardrails analyze --save # Save detected patterns as rules
221
+ aimem guardrails confirm <id> # Confirm an inferred rule (+DIK)
222
+ aimem guardrails reject <id> # Reject/deactivate a rule
223
+ aimem guardrails status # Show DIK level and stats
224
+ aimem guardrails set <level> # Manually set DIK level (1-10)
225
+ aimem guardrails ambient on # Enable ambient personality mode
226
+ aimem guardrails import-linters # Import rules from .eslintrc, .rubocop.yml, etc.
227
+ ```
228
+
229
+ ### Analyzer
230
+
231
+ The analyzer scans your codebase and infers guardrails from existing patterns:
232
+
233
+ **Architecture**
234
+ - Directory conventions (e.g., "controllers belong in `controllers/`")
235
+ - File organization patterns
236
+ - Module structure
237
+
238
+ **Naming**
239
+ - Case conventions (camelCase, snake_case, PascalCase)
240
+ - Function prefixes (get*, is*, has*, handle*, use*)
241
+ - Class naming patterns
242
+
243
+ **Testing**
244
+ - Test file locations (__tests__/, test/, colocated)
245
+ - Test naming conventions
246
+
247
+ **Security**
248
+ - Auth middleware patterns
249
+ - Input validation patterns
250
+
251
+ **Design** (from linters)
252
+ - Import rules from `.eslintrc`, `.eslintrc.json`, `.eslintrc.js`
253
+ - Import rules from `.rubocop.yml`
254
+ - Import rules from `pyproject.toml` (ruff, black, isort)
255
+ - Import rules from `.prettierrc`
256
+
257
+ ```bash
258
+ # Scan codebase and show detected patterns
259
+ aimem guardrails analyze
260
+
261
+ # Save detected patterns as guardrails
262
+ aimem guardrails analyze --save
263
+
264
+ # Import rules from existing linter configs
265
+ aimem guardrails import-linters
266
+ ```
267
+
268
+ ### Git Integration
269
+
270
+ ```bash
271
+ aimem git import [--limit N] # Import commit history
272
+ aimem git link [--auto] # Link recent decisions to HEAD commit
273
+ aimem git hooks install # Install post-commit hook
274
+ aimem git hooks status # Check installed hooks
275
+ aimem git search <query> # Search commit messages
276
+ aimem git blame <file> # Show blame with aimem context
277
+ ```
278
+
279
+ ### Import Conversations
280
+
281
+ ```bash
282
+ aimem import --dry-run # Preview what would be imported
283
+ aimem import # Import from all sources
284
+ aimem import --source claude # Claude Code only
285
+ aimem import --source aider # Aider only
286
+ aimem import --source continue # Continue.dev only
287
+ ```
288
+
289
+ **Supported sources:**
290
+
291
+ | Tool | Location | Format |
292
+ |------|----------|--------|
293
+ | Claude Code | `~/.claude/projects/` | JSONL |
294
+ | Aider | `.aider.chat.history.md` | Markdown |
295
+ | Continue.dev | `~/.continue/sessions/` | JSON |
296
+
297
+ ---
298
+
299
+ ## MCP Tools
300
+
301
+ aimem exposes MCP tools your AI can use:
302
+
303
+ ### Core Tools
304
+
305
+ | Tool | Purpose |
306
+ |------|---------|
307
+ | `aimem_query` | Search code, conversations, decisions, commits |
308
+ | `aimem_verify` | Check if a function/class/file exists |
309
+ | `aimem_conversations` | Search past conversation history |
310
+
311
+ ### Guardrails Tools
312
+
313
+ | Tool | Purpose |
314
+ |------|---------|
315
+ | `aimem_guardrails_check` | Check if action violates rules |
316
+ | `aimem_guardrails_add` | Add explicit rule |
317
+ | `aimem_guardrails_list` | List rules + DIK level |
318
+ | `aimem_guardrails_confirm` | Confirm inferred rule |
319
+ | `aimem_guardrails_reject` | Reject rule |
320
+ | `aimem_guardrails_override` | Override triggered rule |
321
+ | `aimem_guardrails_vindicate` | Mark override as regretted |
322
+ | `aimem_guardrails_analyze` | Infer patterns from codebase |
323
+ | `aimem_guardrails_config` | Get/set config (ambient mode) |
324
+ | `aimem_guardrails_personality` | Get current personality injection |
325
+ | `aimem_guardrails_set_dik` | Manually set DIK level |
326
+
327
+ ### Teaching Claude to Use aimem
328
+
329
+ Add a `CLAUDE.md` file to your project root:
330
+
331
+ ```markdown
332
+ ## Memory (aimem)
333
+
334
+ Before claiming something isn't implemented or needs to be built:
335
+ 1. Query `aimem_query <topic> type=decisions` to check past decisions
336
+ 2. Query `aimem_verify <name>` to check if a function/class exists
337
+
338
+ Available aimem tools:
339
+ - `aimem_query <search>` - Search code, conversations, decisions, commits
340
+ - `aimem_verify <name>` - Does this function/class/file exist?
341
+ - `aimem_conversations <query>` - Search past conversation history
342
+ ```
343
+
344
+ ---
345
+
346
+ ## How It Works
347
+
348
+ ```
349
+ ┌─────────────────┐
350
+ │ Your Request │
351
+ └────────┬────────┘
352
+
353
+
354
+ ┌─────────────────┐
355
+ │ aimem Proxy │──── Capture response
356
+ │ │──── Extract decisions
357
+ │ │──── Update memory
358
+ └────────┬────────┘
359
+
360
+
361
+ ┌─────────────────┐
362
+ │ AI Model │
363
+ └────────┬────────┘
364
+
365
+
366
+ ┌─────────────────┐
367
+ │ MCP Tools │──── Query memory on-demand
368
+ │ │──── Check guardrails
369
+ │ │──── Inject personality
370
+ └─────────────────┘
371
+ ```
372
+
373
+ ### Architecture
374
+
375
+ ```
376
+ ┌─────────────────────────────────────────────────────────────────┐
377
+ │ Your AI Tool │
378
+ │ (Claude Code, Cursor, etc.) │
379
+ └──────────────────────────┬──────────────────────────────────────┘
380
+ API calls
381
+
382
+ ┌─────────────────────────────────────────────────────────────────┐
383
+ │ mockttp Proxy (capture-only) │
384
+ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────┐
385
+ │ │ Passthrough │ │ Capture Response│ │ Extract │ │
386
+ │ │ (no injection) │ │ (SSE streaming) │ │ Decisions │ │
387
+ │ └─────────────────┘ └─────────────────┘ └─────────────┘
388
+ └──────────────────────────┬──────────────────────────────────────┘
389
+
390
+
391
+ ┌─────────────────────────────────────────────────────────────────┐
392
+ │ SQLite Database │
393
+ │ ┌──────────┐ ┌──────────┐ ┌─────────────┐ ┌───────────────┐ │
394
+ │ │ projects │ │ files │ │ structures │ │ conversations │ │
395
+ │ └──────────┘ └──────────┘ └─────────────┘ └───────────────┘ │
396
+ │ ┌──────────┐ ┌──────────┐ ┌─────────────┐ ┌───────────────┐ │
397
+ │ │extractions│ commits │ │ guardrails │ │ project_dik │ │
398
+ │ └──────────┘ └──────────┘ └─────────────┘ └───────────────┘ │
399
+ └──────────────────────────┬──────────────────────────────────────┘
400
+
401
+ ┌────────────────┴────────────────┐
402
+ ▼ ▼
403
+ ┌─────────────────────┐ ┌─────────────────────┐
404
+ │ MCP Server │ │ File Watcher │
405
+ │ (on-demand query) │ │ (live indexing) │
406
+ └─────────────────────┘ └─────────────────────┘
407
+ ```
408
+
409
+ ### Components
410
+
411
+ | Component | Location | Purpose |
412
+ |-----------|----------|---------|
413
+ | **CLI** | `src/cli/` | Commands: init, reindex, start, stop, query, setup, import, visualize, git, guardrails |
414
+ | **Database** | `src/db/` | SQLite + FTS5 for storage and search |
415
+ | **Indexer** | `src/indexer/` | Parse code into structures (functions, classes) |
416
+ | **Parsers** | `src/indexer/parsers/` | Language-specific (JS/TS, Python, Ruby, Go, Rust, Java, C/C++, PHP) |
417
+ | **Extractor** | `src/extractor/` | Extract decisions/rejections from conversations |
418
+ | **Guardrails** | `src/guardrails/` | DIK calculator, pattern analyzer, enforcer, responder |
419
+ | **MCP Server** | `src/mcp/` | Model Context Protocol tools |
420
+ | **Proxy** | `src/proxy/` | mockttp-based HTTPS proxy (Node.js) |
421
+ | **Git** | `src/git/` | Git integration: commits, blame, hooks |
422
+ | **Visualize** | `src/visualize/` | Interactive dashboard (Cytoscape.js, D3.js) |
423
+
424
+ ---
425
+
426
+ ## Supported LLM APIs
427
+
428
+ | Provider | API Host |
429
+ |----------|----------|
430
+ | Anthropic (Claude) | api.anthropic.com |
431
+ | OpenAI | api.openai.com |
432
+ | Google (Gemini) | generativelanguage.googleapis.com |
433
+ | Mistral | api.mistral.ai |
434
+ | Cohere | api.cohere.ai |
435
+ | Groq | api.groq.com |
436
+ | Together AI | api.together.xyz |
437
+ | Perplexity | api.perplexity.ai |
438
+ | Fireworks | api.fireworks.ai |
439
+ | DeepSeek | api.deepseek.com |
440
+ | Replicate | api.replicate.com |
441
+
442
+ ## Supported Languages
443
+
444
+ - JavaScript / TypeScript (`.js`, `.jsx`, `.ts`, `.tsx`, `.mjs`, `.cjs`)
445
+ - Python (`.py`, `.pyw`)
446
+ - Ruby (`.rb`, `.rake`)
447
+ - Go (`.go`)
448
+ - Rust (`.rs`)
449
+ - Java (`.java`)
450
+ - Kotlin (`.kt`, `.kts`)
451
+ - C / C++ (`.c`, `.cpp`, `.cc`, `.cxx`, `.h`, `.hpp`, `.hxx`, `.hh`)
452
+ - PHP (`.php`, `.phtml`, `.php5`, `.php7`, `.php8`)
453
+
454
+ ---
455
+
456
+ ## Data Storage
457
+
458
+ Everything is stored locally:
459
+
460
+ | OS | Default Location |
461
+ |----|------------------|
462
+ | Linux/macOS | `~/.aimem/` |
463
+ | Windows | `C:\Users\<user>\.aimem\` |
464
+ | WSL | `/home/<user>/.aimem/` |
465
+
466
+ ```
467
+ .aimem/
468
+ ├── aimem.db # SQLite database
469
+ ├── ca-cert.pem # Proxy CA certificate
470
+ ├── ca-key.pem # Proxy CA key
471
+ ├── proxy.pid # Proxy process ID
472
+ └── watcher.pid # Watcher process ID
473
+ ```
474
+
475
+ ### Custom Data Directory
476
+
477
+ ```bash
478
+ export AIMEM_DATA_DIR="/path/to/shared/.aimem"
479
+ ```
480
+
481
+ ### Sharing Database Between WSL and Windows
482
+
483
+ **WSL** (add to `~/.bashrc` or `~/.zshrc`):
484
+ ```bash
485
+ export AIMEM_DATA_DIR="/mnt/c/Users/<user>/.aimem"
486
+ ```
487
+
488
+ **Windows** (PowerShell profile or System Environment Variables):
489
+ ```powershell
490
+ $env:AIMEM_DATA_DIR = "C:\Users\<user>\.aimem"
491
+ ```
492
+
493
+ ---
494
+
495
+ ## Visualization Dashboard
496
+
497
+ Generate an interactive HTML dashboard:
498
+
499
+ ```bash
500
+ aimem visualize # Generate dashboard.html
501
+ aimem visualize --output ./viz.html # Custom output path
502
+ aimem visualize --open # Open in browser
503
+ aimem visualize --serve # Start live server
504
+ ```
505
+
506
+ **Views:** Overview, Call Graph, Dependencies, Classes, Decisions, Code Smells, Hotspots, Gallery, Timeline, Treemap
507
+
508
+ ---
509
+
510
+ ## Troubleshooting
511
+
512
+ **Proxy not starting?**
513
+ - Check for port conflicts: `lsof -i :8080`
514
+ - Try a different port: `aimem start --port 8081`
515
+
516
+ **Certificate issues?**
517
+ - Run `aimem setup proxy --install` to auto-install
518
+ - Or manually trust `~/.aimem/ca-cert.pem`
519
+
520
+ **MCP not working in Claude Code?**
521
+ - Run `/mcp` to check connection
522
+ - Verify path: `which aimem`
523
+ - Restart Claude Code after setup
524
+
525
+ **No conversations being captured?**
526
+ - Verify proxy is running: `aimem status`
527
+ - Check env vars: `echo $HTTPS_PROXY`
528
+ - Ensure your tool respects HTTPS_PROXY
529
+
530
+ ---
531
+
532
+ ## The Philosophy
533
+
534
+ Most AI tools try to be maximally helpful. Instant output. No friction. No questions.
535
+
536
+ That's wrong.
537
+
538
+ The best collaborators push back. They ask clarifying questions. They remember past decisions. They say "no" when you're about to make a mistake.
539
+
540
+ aimem turns your AI into that collaborator. Not by programming personality, but by **earning it** through a track record of being right.
541
+
542
+ ---
543
+
544
+ ## Roadmap
545
+
546
+ - [x] Memory (conversations, structures, commits)
547
+ - [x] Guardrails (rules, violations, tracking)
548
+ - [x] DIK calculation
549
+ - [x] Analyzer (infer rules from codebase)
550
+ - [x] Ambient personality mode
551
+ - [x] Import from linters (.eslintrc, .rubocop.yml, tsconfig.json, pyproject.toml)
552
+ - [ ] Vindication auto-detection (git revert tracking)
553
+ - [ ] VS Code extension
554
+ - [ ] Team-shared rules
555
+
556
+ ---
557
+
558
+ ## Development
559
+
560
+ ```bash
561
+ # Install from source
562
+ git clone https://github.com/rangerchaz/aimem.git
563
+ cd aimem
564
+ npm install
565
+ npm run build
566
+ npm link # Install globally from source
567
+
568
+ # Development commands
569
+ npm run dev # Watch mode
570
+ npm test # Run tests
571
+ ```
572
+
573
+ ---
574
+
575
+ ## Why "aimem"?
576
+
577
+ AI + Memory. Simple.
578
+
579
+ But also: it's the system that remembers, so you don't have to repeat yourself. And eventually, it remembers when it warned you and you didn't listen.
580
+
581
+ ---
582
+
583
+ ## License
584
+
585
+ MIT
586
+
587
+ ---
588
+
589
+ *Built by [@rangerchaz](https://github.com/rangerchaz) because LLMs need to learn to say no.*