@aitytech/agentkits-memory 1.0.0 → 2.0.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/LICENSE +21 -0
- package/README.md +267 -149
- package/assets/agentkits-memory-add-memory.png +0 -0
- package/assets/agentkits-memory-memory-detail.png +0 -0
- package/assets/agentkits-memory-memory-list.png +0 -0
- package/assets/logo.svg +24 -0
- package/dist/better-sqlite3-backend.d.ts +192 -0
- package/dist/better-sqlite3-backend.d.ts.map +1 -0
- package/dist/better-sqlite3-backend.js +801 -0
- package/dist/better-sqlite3-backend.js.map +1 -0
- package/dist/cli/save.js +0 -0
- package/dist/cli/setup.d.ts +6 -2
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +289 -42
- package/dist/cli/setup.js.map +1 -1
- package/dist/cli/viewer.js +25 -56
- package/dist/cli/viewer.js.map +1 -1
- package/dist/cli/web-viewer.d.ts +14 -0
- package/dist/cli/web-viewer.d.ts.map +1 -0
- package/dist/cli/web-viewer.js +1769 -0
- package/dist/cli/web-viewer.js.map +1 -0
- package/dist/embeddings/embedding-cache.d.ts +131 -0
- package/dist/embeddings/embedding-cache.d.ts.map +1 -0
- package/dist/embeddings/embedding-cache.js +217 -0
- package/dist/embeddings/embedding-cache.js.map +1 -0
- package/dist/embeddings/index.d.ts +11 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +11 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/local-embeddings.d.ts +140 -0
- package/dist/embeddings/local-embeddings.d.ts.map +1 -0
- package/dist/embeddings/local-embeddings.js +293 -0
- package/dist/embeddings/local-embeddings.js.map +1 -0
- package/dist/hooks/context.d.ts +6 -1
- package/dist/hooks/context.d.ts.map +1 -1
- package/dist/hooks/context.js +12 -2
- package/dist/hooks/context.js.map +1 -1
- package/dist/hooks/observation.d.ts +6 -1
- package/dist/hooks/observation.d.ts.map +1 -1
- package/dist/hooks/observation.js +12 -2
- package/dist/hooks/observation.js.map +1 -1
- package/dist/hooks/service.d.ts +1 -6
- package/dist/hooks/service.d.ts.map +1 -1
- package/dist/hooks/service.js +33 -85
- package/dist/hooks/service.js.map +1 -1
- package/dist/hooks/session-init.d.ts +6 -1
- package/dist/hooks/session-init.d.ts.map +1 -1
- package/dist/hooks/session-init.js +12 -2
- package/dist/hooks/session-init.js.map +1 -1
- package/dist/hooks/summarize.d.ts +6 -1
- package/dist/hooks/summarize.d.ts.map +1 -1
- package/dist/hooks/summarize.js +12 -2
- package/dist/hooks/summarize.js.map +1 -1
- package/dist/index.d.ts +10 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +172 -94
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.js +17 -3
- package/dist/mcp/server.js.map +1 -1
- package/dist/migration.js +3 -3
- package/dist/migration.js.map +1 -1
- package/dist/search/hybrid-search.d.ts +262 -0
- package/dist/search/hybrid-search.d.ts.map +1 -0
- package/dist/search/hybrid-search.js +688 -0
- package/dist/search/hybrid-search.js.map +1 -0
- package/dist/search/index.d.ts +13 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +13 -0
- package/dist/search/index.js.map +1 -0
- package/dist/search/token-economics.d.ts +161 -0
- package/dist/search/token-economics.d.ts.map +1 -0
- package/dist/search/token-economics.js +239 -0
- package/dist/search/token-economics.js.map +1 -0
- package/dist/types.d.ts +0 -68
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +23 -8
- package/src/__tests__/better-sqlite3-backend.test.ts +1466 -0
- package/src/__tests__/cache-manager.test.ts +499 -0
- package/src/__tests__/embedding-integration.test.ts +481 -0
- package/src/__tests__/hnsw-index.test.ts +727 -0
- package/src/__tests__/index.test.ts +432 -0
- package/src/better-sqlite3-backend.ts +1000 -0
- package/src/cli/setup.ts +358 -47
- package/src/cli/viewer.ts +28 -63
- package/src/cli/web-viewer.ts +1956 -0
- package/src/embeddings/__tests__/embedding-cache.test.ts +269 -0
- package/src/embeddings/__tests__/local-embeddings.test.ts +495 -0
- package/src/embeddings/embedding-cache.ts +318 -0
- package/src/embeddings/index.ts +20 -0
- package/src/embeddings/local-embeddings.ts +419 -0
- package/src/hooks/__tests__/handlers.test.ts +58 -17
- package/src/hooks/__tests__/integration.test.ts +77 -26
- package/src/hooks/context.ts +13 -2
- package/src/hooks/observation.ts +13 -2
- package/src/hooks/service.ts +39 -100
- package/src/hooks/session-init.ts +13 -2
- package/src/hooks/summarize.ts +13 -2
- package/src/index.ts +210 -116
- package/src/mcp/server.ts +20 -3
- package/src/search/__tests__/hybrid-search.test.ts +669 -0
- package/src/search/__tests__/token-economics.test.ts +276 -0
- package/src/search/hybrid-search.ts +968 -0
- package/src/search/index.ts +29 -0
- package/src/search/token-economics.ts +367 -0
- package/src/types.ts +0 -96
- package/src/__tests__/sqljs-backend.test.ts +0 -410
- package/src/migration.ts +0 -574
- package/src/sql.js.d.ts +0 -70
- package/src/sqljs-backend.ts +0 -789
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AityTech
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,34 +1,161 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/aitytech/agentkits-memory/main/assets/logo.svg" alt="AgentKits Logo" width="80" height="80">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">AgentKits Memory</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<em>by <strong>AityTech</strong></em>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/package/@aitytech/agentkits-memory"><img src="https://img.shields.io/npm/v/@aitytech/agentkits-memory.svg" alt="npm"></a>
|
|
13
|
+
<img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License">
|
|
14
|
+
<img src="https://img.shields.io/badge/Claude_Code-Compatible-blueviolet" alt="Claude Code">
|
|
15
|
+
<img src="https://img.shields.io/badge/Cursor-Compatible-blue" alt="Cursor">
|
|
16
|
+
<img src="https://img.shields.io/badge/Copilot-Compatible-green" alt="Copilot">
|
|
17
|
+
<img src="https://img.shields.io/badge/Windsurf-Compatible-cyan" alt="Windsurf">
|
|
18
|
+
<img src="https://img.shields.io/badge/Cline-Compatible-orange" alt="Cline">
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
<p align="center">
|
|
22
|
+
<strong>Persistent Memory System for AI Coding Assistants via MCP</strong>
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
<p align="center">
|
|
26
|
+
<em>Fast. Local. Zero external dependencies.</em>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
Store decisions, patterns, errors, and context that persists across sessions.<br>
|
|
31
|
+
No cloud. No API keys. No setup. Just works.
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<a href="#quick-start">Quick Start</a> •
|
|
36
|
+
<a href="#web-viewer">Web Viewer</a> •
|
|
37
|
+
<a href="#features">Features</a> •
|
|
38
|
+
<a href="#agentkits-ecosystem">Ecosystem</a> •
|
|
39
|
+
<a href="https://agentkits.net">agentkits.net</a>
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
---
|
|
4
43
|
|
|
5
44
|
## Features
|
|
6
45
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
46
|
+
| Feature | Benefit |
|
|
47
|
+
|---------|---------|
|
|
48
|
+
| **100% Local** | All data stays on your machine. No cloud, no API keys, no accounts |
|
|
49
|
+
| **Blazing Fast** | Native SQLite (better-sqlite3) = instant queries, zero latency |
|
|
50
|
+
| **Zero Config** | Works out of the box. No database setup required |
|
|
51
|
+
| **Cross-Platform** | Windows, macOS, Linux - same code, same speed |
|
|
52
|
+
| **MCP Server** | `memory_save`, `memory_search`, `memory_recall`, `memory_list`, `memory_status` |
|
|
53
|
+
| **Web Viewer** | Browser UI to view, add, edit, delete memories |
|
|
54
|
+
| **Vector Search** | Optional HNSW semantic similarity (no external service) |
|
|
55
|
+
| **Auto-Capture** | Hooks for session context, tool usage, summaries |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Web Viewer
|
|
13
60
|
|
|
14
|
-
|
|
61
|
+
View and manage your memories through a modern web interface.
|
|
15
62
|
|
|
16
63
|
```bash
|
|
17
|
-
|
|
18
|
-
# or
|
|
19
|
-
pnpm add @agentkits/memory
|
|
64
|
+
npx agentkits-memory-web
|
|
20
65
|
```
|
|
21
66
|
|
|
67
|
+
Then open **http://localhost:1905** in your browser.
|
|
68
|
+
|
|
69
|
+
### Memory List
|
|
70
|
+
|
|
71
|
+
Browse all stored memories with search and namespace filtering.
|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
### Add Memory
|
|
76
|
+
|
|
77
|
+
Create new memories with key, namespace, type, content, and tags.
|
|
78
|
+
|
|
79
|
+

|
|
80
|
+
|
|
81
|
+
### Memory Details
|
|
82
|
+
|
|
83
|
+
View full memory details with edit and delete options.
|
|
84
|
+
|
|
85
|
+

|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
22
89
|
## Quick Start
|
|
23
90
|
|
|
91
|
+
### 1. Install
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm install @aitytech/agentkits-memory
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 2. Configure MCP Server
|
|
98
|
+
|
|
99
|
+
Add to your `.mcp.json` (or `.claude/.mcp.json`):
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"mcpServers": {
|
|
104
|
+
"memory": {
|
|
105
|
+
"command": "npx",
|
|
106
|
+
"args": ["agentkits-memory-server"]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 3. Use Memory Tools
|
|
113
|
+
|
|
114
|
+
Once configured, your AI assistant can use these tools:
|
|
115
|
+
|
|
116
|
+
| Tool | Description |
|
|
117
|
+
|------|-------------|
|
|
118
|
+
| `memory_save` | Save decisions, patterns, errors, or context |
|
|
119
|
+
| `memory_search` | Search memories using semantic similarity |
|
|
120
|
+
| `memory_recall` | Recall everything about a specific topic |
|
|
121
|
+
| `memory_list` | List recent memories |
|
|
122
|
+
| `memory_status` | Check memory system status |
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## CLI Commands
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
# Start MCP server
|
|
130
|
+
npx agentkits-memory-server
|
|
131
|
+
|
|
132
|
+
# Start web viewer (port 1905)
|
|
133
|
+
npx agentkits-memory-web
|
|
134
|
+
|
|
135
|
+
# View stored memories (terminal)
|
|
136
|
+
npx agentkits-memory-viewer
|
|
137
|
+
|
|
138
|
+
# Save memory from CLI
|
|
139
|
+
npx agentkits-memory-save "Use JWT with refresh tokens" --category pattern --tags auth,security
|
|
140
|
+
|
|
141
|
+
# Setup hooks for auto-capture
|
|
142
|
+
npx agentkits-memory-setup
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Programmatic Usage
|
|
148
|
+
|
|
24
149
|
```typescript
|
|
25
|
-
import { ProjectMemoryService } from '@agentkits
|
|
150
|
+
import { ProjectMemoryService } from '@aitytech/agentkits-memory';
|
|
26
151
|
|
|
27
|
-
|
|
28
|
-
|
|
152
|
+
const memory = new ProjectMemoryService({
|
|
153
|
+
baseDir: '.claude/memory',
|
|
154
|
+
dbFilename: 'memory.db',
|
|
155
|
+
});
|
|
29
156
|
await memory.initialize();
|
|
30
157
|
|
|
31
|
-
// Store
|
|
158
|
+
// Store a memory
|
|
32
159
|
await memory.storeEntry({
|
|
33
160
|
key: 'auth-pattern',
|
|
34
161
|
content: 'Use JWT with refresh tokens for authentication',
|
|
@@ -36,11 +163,11 @@ await memory.storeEntry({
|
|
|
36
163
|
tags: ['auth', 'security'],
|
|
37
164
|
});
|
|
38
165
|
|
|
39
|
-
// Query
|
|
40
|
-
const
|
|
166
|
+
// Query memories
|
|
167
|
+
const results = await memory.query({
|
|
41
168
|
type: 'hybrid',
|
|
42
169
|
namespace: 'patterns',
|
|
43
|
-
|
|
170
|
+
content: 'authentication',
|
|
44
171
|
limit: 10,
|
|
45
172
|
});
|
|
46
173
|
|
|
@@ -48,84 +175,111 @@ const patterns = await memory.query({
|
|
|
48
175
|
const entry = await memory.getByKey('patterns', 'auth-pattern');
|
|
49
176
|
```
|
|
50
177
|
|
|
51
|
-
|
|
178
|
+
---
|
|
52
179
|
|
|
53
|
-
|
|
54
|
-
// Start a new session
|
|
55
|
-
await memory.startSession();
|
|
180
|
+
## Auto-Capture Hooks
|
|
56
181
|
|
|
57
|
-
|
|
58
|
-
await memory.checkpoint('Completed authentication setup');
|
|
59
|
-
await memory.checkpoint('Added user registration');
|
|
182
|
+
The package includes hooks for automatically capturing AI coding sessions:
|
|
60
183
|
|
|
61
|
-
|
|
62
|
-
|
|
184
|
+
| Hook | Trigger | Action |
|
|
185
|
+
|------|---------|--------|
|
|
186
|
+
| `context` | Session Start | Injects previous session context |
|
|
187
|
+
| `session-init` | First User Prompt | Initializes session record |
|
|
188
|
+
| `observation` | After Tool Use | Captures tool usage |
|
|
189
|
+
| `summarize` | Session End | Generates session summary |
|
|
63
190
|
|
|
64
|
-
|
|
65
|
-
|
|
191
|
+
Setup hooks:
|
|
192
|
+
```bash
|
|
193
|
+
npx agentkits-memory-setup
|
|
66
194
|
```
|
|
67
195
|
|
|
68
|
-
|
|
196
|
+
Or manually copy `hooks.json` to your project:
|
|
197
|
+
```bash
|
|
198
|
+
cp node_modules/@aitytech/agentkits-memory/hooks.json .claude/hooks.json
|
|
199
|
+
```
|
|
69
200
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Memory Categories
|
|
204
|
+
|
|
205
|
+
| Category | Use Case |
|
|
206
|
+
|----------|----------|
|
|
207
|
+
| `decision` | Architecture decisions, ADRs |
|
|
208
|
+
| `pattern` | Reusable code patterns |
|
|
209
|
+
| `error` | Error solutions and fixes |
|
|
210
|
+
| `context` | Project context and facts |
|
|
211
|
+
| `observation` | Session observations |
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Storage
|
|
216
|
+
|
|
217
|
+
Memories are stored in `.claude/memory/memory.db` within your project directory.
|
|
218
|
+
|
|
219
|
+
```
|
|
220
|
+
.claude/memory/
|
|
221
|
+
├── memory.db # SQLite database
|
|
222
|
+
└── memory.db-wal # Write-ahead log (temp)
|
|
75
223
|
```
|
|
76
224
|
|
|
77
|
-
|
|
225
|
+
---
|
|
226
|
+
|
|
227
|
+
## CJK Language Support
|
|
228
|
+
|
|
229
|
+
AgentKits Memory has **automatic CJK support** for Chinese, Japanese, and Korean text search.
|
|
230
|
+
|
|
231
|
+
### Zero Configuration
|
|
232
|
+
|
|
233
|
+
When `better-sqlite3` is installed (default), CJK search works automatically:
|
|
78
234
|
|
|
79
235
|
```typescript
|
|
80
|
-
import {
|
|
81
|
-
|
|
82
|
-
// Create memory with embedding support
|
|
83
|
-
const memory = createEmbeddingMemory(
|
|
84
|
-
'.claude/memory',
|
|
85
|
-
async (text) => {
|
|
86
|
-
// Your embedding function (e.g., OpenAI, local model)
|
|
87
|
-
return await embeddings.embed(text);
|
|
88
|
-
},
|
|
89
|
-
384 // dimensions
|
|
90
|
-
);
|
|
236
|
+
import { ProjectMemoryService } from '@aitytech/agentkits-memory';
|
|
91
237
|
|
|
238
|
+
const memory = new ProjectMemoryService('.claude/memory');
|
|
92
239
|
await memory.initialize();
|
|
93
240
|
|
|
94
|
-
//
|
|
95
|
-
|
|
241
|
+
// Store CJK content
|
|
242
|
+
await memory.storeEntry({
|
|
243
|
+
key: 'auth-pattern',
|
|
244
|
+
content: '認証機能の実装パターン - JWT with refresh tokens',
|
|
245
|
+
namespace: 'patterns',
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
// Search in Japanese, Chinese, or Korean - it just works!
|
|
249
|
+
const results = await memory.query({
|
|
250
|
+
type: 'hybrid',
|
|
251
|
+
content: '認証機能',
|
|
252
|
+
});
|
|
96
253
|
```
|
|
97
254
|
|
|
98
|
-
|
|
255
|
+
### How It Works
|
|
256
|
+
|
|
257
|
+
- **Native SQLite**: Uses `better-sqlite3` for maximum performance
|
|
258
|
+
- **Trigram tokenizer**: FTS5 with trigram creates 3-character sequences for CJK matching
|
|
259
|
+
- **Smart fallback**: Short CJK queries (< 3 chars) automatically use LIKE search
|
|
260
|
+
- **BM25 ranking**: Relevance scoring for search results
|
|
261
|
+
|
|
262
|
+
### Advanced: Japanese Word Segmentation
|
|
263
|
+
|
|
264
|
+
For advanced Japanese with proper word segmentation, optionally use lindera:
|
|
99
265
|
|
|
100
266
|
```typescript
|
|
101
|
-
|
|
102
|
-
await memory.exportToMarkdown('patterns');
|
|
103
|
-
// Creates: .claude/memory/patterns.md
|
|
267
|
+
import { createJapaneseOptimizedBackend } from '@aitytech/agentkits-memory';
|
|
104
268
|
|
|
105
|
-
|
|
106
|
-
|
|
269
|
+
const backend = createJapaneseOptimizedBackend({
|
|
270
|
+
databasePath: '.claude/memory/memory.db',
|
|
271
|
+
linderaPath: './path/to/liblindera_sqlite.dylib',
|
|
272
|
+
});
|
|
107
273
|
```
|
|
108
274
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
The memory system uses these default namespaces (matching existing `.md` file structure):
|
|
275
|
+
Requires [lindera-sqlite](https://github.com/lindera/lindera-sqlite) build.
|
|
112
276
|
|
|
113
|
-
|
|
114
|
-
|-----------|------|---------|
|
|
115
|
-
| `context` | semantic | Project context and facts |
|
|
116
|
-
| `active-context` | episodic | Current work focus |
|
|
117
|
-
| `session-state` | episodic | Session handoff notes |
|
|
118
|
-
| `progress` | episodic | Feature tracking |
|
|
119
|
-
| `patterns` | semantic | Reusable code patterns |
|
|
120
|
-
| `decisions` | procedural | ADRs and decisions |
|
|
121
|
-
| `errors` | procedural | Error solutions |
|
|
277
|
+
---
|
|
122
278
|
|
|
123
279
|
## API Reference
|
|
124
280
|
|
|
125
281
|
### ProjectMemoryService
|
|
126
282
|
|
|
127
|
-
#### Configuration
|
|
128
|
-
|
|
129
283
|
```typescript
|
|
130
284
|
interface ProjectMemoryConfig {
|
|
131
285
|
baseDir: string; // Default: '.claude/memory'
|
|
@@ -136,115 +290,79 @@ interface ProjectMemoryConfig {
|
|
|
136
290
|
cacheEnabled: boolean; // Default: true
|
|
137
291
|
cacheSize: number; // Default: 1000
|
|
138
292
|
cacheTtl: number; // Default: 300000 (5 min)
|
|
139
|
-
autoPersistInterval: number; // Default: 10000 (10 sec)
|
|
140
|
-
maxEntries: number; // Default: 100000
|
|
141
|
-
verbose: boolean; // Default: false
|
|
142
293
|
}
|
|
143
294
|
```
|
|
144
295
|
|
|
145
|
-
|
|
296
|
+
### Methods
|
|
146
297
|
|
|
147
298
|
| Method | Description |
|
|
148
299
|
|--------|-------------|
|
|
149
300
|
| `initialize()` | Initialize the memory service |
|
|
150
301
|
| `shutdown()` | Shutdown and persist changes |
|
|
151
|
-
| `
|
|
152
|
-
| `storeEntry(input)` | Store from simple input |
|
|
302
|
+
| `storeEntry(input)` | Store a memory entry |
|
|
153
303
|
| `get(id)` | Get entry by ID |
|
|
154
304
|
| `getByKey(namespace, key)` | Get entry by namespace and key |
|
|
155
305
|
| `update(id, update)` | Update an entry |
|
|
156
306
|
| `delete(id)` | Delete an entry |
|
|
157
307
|
| `query(query)` | Query entries with filters |
|
|
158
|
-
| `
|
|
159
|
-
| `semanticSearch(content, k)` | Search by content string |
|
|
308
|
+
| `semanticSearch(content, k)` | Semantic similarity search |
|
|
160
309
|
| `count(namespace?)` | Count entries |
|
|
161
310
|
| `listNamespaces()` | List all namespaces |
|
|
162
|
-
| `clearNamespace(namespace)` | Clear a namespace |
|
|
163
|
-
| `startSession()` | Start new session |
|
|
164
|
-
| `checkpoint(description)` | Create checkpoint |
|
|
165
|
-
| `endSession(summary?)` | End current session |
|
|
166
|
-
| `migrateFromMarkdown()` | Migrate from .md files |
|
|
167
|
-
| `exportToMarkdown(namespace)` | Export to markdown |
|
|
168
311
|
| `getStats()` | Get statistics |
|
|
169
|
-
| `healthCheck()` | Health check |
|
|
170
312
|
|
|
171
|
-
|
|
313
|
+
---
|
|
172
314
|
|
|
173
|
-
|
|
174
|
-
.claude/memory/
|
|
175
|
-
├── memory.db # SQLite database (primary storage)
|
|
176
|
-
├── memory.db-wal # Write-ahead log (temp)
|
|
177
|
-
└── exports/ # Optional markdown exports
|
|
178
|
-
├── patterns.md
|
|
179
|
-
├── decisions.md
|
|
180
|
-
└── ...
|
|
181
|
-
```
|
|
315
|
+
## Requirements
|
|
182
316
|
|
|
183
|
-
|
|
317
|
+
- Node.js >= 18.0.0
|
|
318
|
+
- MCP-compatible AI coding assistant
|
|
184
319
|
|
|
185
|
-
|
|
186
|
-
|-----------|------|
|
|
187
|
-
| Store entry | <5ms |
|
|
188
|
-
| Get by ID | <2ms (cached: <0.1ms) |
|
|
189
|
-
| Query (100 results) | <10ms |
|
|
190
|
-
| Vector search (10k entries) | <5ms (with HNSW) |
|
|
191
|
-
| Migration (100 files) | <2s |
|
|
320
|
+
---
|
|
192
321
|
|
|
193
|
-
##
|
|
322
|
+
## AgentKits Ecosystem
|
|
194
323
|
|
|
195
|
-
|
|
324
|
+
**AgentKits Memory** is part of the AgentKits ecosystem by AityTech - tools that make AI coding assistants smarter.
|
|
196
325
|
|
|
197
|
-
|
|
326
|
+
| Product | Description | Link |
|
|
327
|
+
|---------|-------------|------|
|
|
328
|
+
| **AgentKits Engineer** | 28 specialized agents, 100+ skills, enterprise patterns | [GitHub](https://github.com/aitytech/agentkits-engineer) |
|
|
329
|
+
| **AgentKits Marketing** | AI-powered marketing content generation | [GitHub](https://github.com/aitytech/agentkits-marketing) |
|
|
330
|
+
| **AgentKits Memory** | Persistent memory for AI assistants (this package) | [npm](https://www.npmjs.com/package/@aitytech/agentkits-memory) |
|
|
198
331
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
```
|
|
332
|
+
<p align="center">
|
|
333
|
+
<a href="https://agentkits.net">
|
|
334
|
+
<img src="https://img.shields.io/badge/Visit-agentkits.net-blue?style=for-the-badge" alt="agentkits.net">
|
|
335
|
+
</a>
|
|
336
|
+
</p>
|
|
205
337
|
|
|
206
|
-
|
|
207
|
-
```bash
|
|
208
|
-
cp node_modules/@agentkits/memory/hooks.json .claude/hooks.json
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
3. Claude Code will now automatically:
|
|
212
|
-
- Inject previous session context on start
|
|
213
|
-
- Track all tool usage during the session
|
|
214
|
-
- Generate session summaries on exit
|
|
215
|
-
|
|
216
|
-
### Hook Events
|
|
217
|
-
|
|
218
|
-
| Event | Trigger | Action |
|
|
219
|
-
|-------|---------|--------|
|
|
220
|
-
| `context` | SessionStart | Injects memory context |
|
|
221
|
-
| `session-init` | UserPromptSubmit | Initializes session record |
|
|
222
|
-
| `observation` | PostToolUse | Captures tool usage |
|
|
223
|
-
| `summarize` | Stop | Generates session summary |
|
|
338
|
+
---
|
|
224
339
|
|
|
225
|
-
|
|
340
|
+
## Star History
|
|
226
341
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
342
|
+
<a href="https://star-history.com/#aitytech/agentkits-memory&Date">
|
|
343
|
+
<picture>
|
|
344
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=aitytech/agentkits-memory&type=Date&theme=dark" />
|
|
345
|
+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=aitytech/agentkits-memory&type=Date" />
|
|
346
|
+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=aitytech/agentkits-memory&type=Date" />
|
|
347
|
+
</picture>
|
|
348
|
+
</a>
|
|
233
349
|
|
|
234
|
-
|
|
235
|
-
const result = await contextHook.execute(input);
|
|
236
|
-
```
|
|
350
|
+
---
|
|
237
351
|
|
|
238
|
-
|
|
352
|
+
## License
|
|
239
353
|
|
|
240
|
-
|
|
354
|
+
MIT
|
|
241
355
|
|
|
242
|
-
|
|
356
|
+
---
|
|
243
357
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
358
|
+
<p align="center">
|
|
359
|
+
<strong>Give your AI assistant memory that persists.</strong>
|
|
360
|
+
</p>
|
|
247
361
|
|
|
248
|
-
|
|
362
|
+
<p align="center">
|
|
363
|
+
<em>AgentKits Memory by AityTech</em>
|
|
364
|
+
</p>
|
|
249
365
|
|
|
250
|
-
|
|
366
|
+
<p align="center">
|
|
367
|
+
Star this repo if it helps your AI remember.
|
|
368
|
+
</p>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/assets/logo.svg
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="logoGrad" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
4
|
+
<stop offset="0%" style="stop-color:#2563EB"/>
|
|
5
|
+
<stop offset="100%" style="stop-color:#3B82F6"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<!-- Background -->
|
|
9
|
+
<rect width="40" height="40" rx="8" fill="url(#logoGrad)"/>
|
|
10
|
+
<!-- Central hub -->
|
|
11
|
+
<circle cx="20" cy="20" r="5" fill="#fff"/>
|
|
12
|
+
<!-- Nodes -->
|
|
13
|
+
<circle cx="20" cy="9" r="3" fill="#fff"/>
|
|
14
|
+
<circle cx="20" cy="31" r="3" fill="#fff"/>
|
|
15
|
+
<circle cx="9" cy="20" r="3" fill="#fff"/>
|
|
16
|
+
<circle cx="31" cy="20" r="3" fill="#fff"/>
|
|
17
|
+
<!-- Connections -->
|
|
18
|
+
<line x1="20" y1="15" x2="20" y2="12" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/>
|
|
19
|
+
<line x1="20" y1="25" x2="20" y2="28" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/>
|
|
20
|
+
<line x1="15" y1="20" x2="12" y2="20" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/>
|
|
21
|
+
<line x1="25" y1="20" x2="28" y2="20" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/>
|
|
22
|
+
<!-- Center dot -->
|
|
23
|
+
<circle cx="20" cy="20" r="2" fill="#2563EB"/>
|
|
24
|
+
</svg>
|