@rangerchaz/aimem 0.1.4 → 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.
- package/README.md +589 -432
- package/dist/cli/commands/guardrails.d.ts +3 -0
- package/dist/cli/commands/guardrails.d.ts.map +1 -0
- package/dist/cli/commands/guardrails.js +340 -0
- package/dist/cli/commands/guardrails.js.map +1 -0
- package/dist/cli/commands/reindex.d.ts +7 -0
- package/dist/cli/commands/reindex.d.ts.map +1 -0
- package/dist/cli/commands/reindex.js +117 -0
- package/dist/cli/commands/reindex.js.map +1 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/db/index.d.ts +30 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +192 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/schema.d.ts +1 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +54 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/guardrails/analyzer.d.ts +20 -0
- package/dist/guardrails/analyzer.d.ts.map +1 -0
- package/dist/guardrails/analyzer.js +329 -0
- package/dist/guardrails/analyzer.js.map +1 -0
- package/dist/guardrails/calculator.d.ts +46 -0
- package/dist/guardrails/calculator.d.ts.map +1 -0
- package/dist/guardrails/calculator.js +97 -0
- package/dist/guardrails/calculator.js.map +1 -0
- package/dist/guardrails/enforcer.d.ts +28 -0
- package/dist/guardrails/enforcer.d.ts.map +1 -0
- package/dist/guardrails/enforcer.js +153 -0
- package/dist/guardrails/enforcer.js.map +1 -0
- package/dist/guardrails/index.d.ts +12 -0
- package/dist/guardrails/index.d.ts.map +1 -0
- package/dist/guardrails/index.js +17 -0
- package/dist/guardrails/index.js.map +1 -0
- package/dist/guardrails/linter-import.d.ts +31 -0
- package/dist/guardrails/linter-import.d.ts.map +1 -0
- package/dist/guardrails/linter-import.js +547 -0
- package/dist/guardrails/linter-import.js.map +1 -0
- package/dist/guardrails/responder.d.ts +28 -0
- package/dist/guardrails/responder.d.ts.map +1 -0
- package/dist/guardrails/responder.js +98 -0
- package/dist/guardrails/responder.js.map +1 -0
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +409 -10
- package/dist/mcp/server.js.map +1 -1
- package/dist/proxy/interceptor-mockttp.d.ts +4 -0
- package/dist/proxy/interceptor-mockttp.d.ts.map +1 -1
- package/dist/proxy/interceptor-mockttp.js +59 -5
- package/dist/proxy/interceptor-mockttp.js.map +1 -1
- package/dist/types/index.d.ts +58 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +56 -56
package/README.md
CHANGED
|
@@ -1,432 +1,589 @@
|
|
|
1
|
-
# aimem
|
|
2
|
-
|
|
3
|
-
**Your AI
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
#
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
|
190
|
-
|
|
191
|
-
| `
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
-
|
|
249
|
-
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
aimem
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
##
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
|
314
|
-
|
|
315
|
-
|
|
|
316
|
-
|
|
|
317
|
-
|
|
|
318
|
-
|
|
|
319
|
-
|
|
|
320
|
-
|
|
|
321
|
-
|
|
|
322
|
-
|
|
|
323
|
-
|
|
|
324
|
-
|
|
|
325
|
-
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
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.*
|