kiro-memory 1.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 +661 -0
- package/README.md +290 -0
- package/package.json +117 -0
- package/plugin/dist/cli/contextkit.js +1259 -0
- package/plugin/dist/hooks/agentSpawn.js +1187 -0
- package/plugin/dist/hooks/kiro-hooks.js +1184 -0
- package/plugin/dist/hooks/postToolUse.js +1219 -0
- package/plugin/dist/hooks/stop.js +1163 -0
- package/plugin/dist/hooks/userPromptSubmit.js +1152 -0
- package/plugin/dist/index.js +2103 -0
- package/plugin/dist/sdk/index.js +1083 -0
- package/plugin/dist/servers/mcp-server.js +266 -0
- package/plugin/dist/services/search/ChromaManager.js +357 -0
- package/plugin/dist/services/search/HybridSearch.js +502 -0
- package/plugin/dist/services/search/index.js +511 -0
- package/plugin/dist/services/sqlite/Database.js +625 -0
- package/plugin/dist/services/sqlite/Observations.js +46 -0
- package/plugin/dist/services/sqlite/Prompts.js +39 -0
- package/plugin/dist/services/sqlite/Search.js +143 -0
- package/plugin/dist/services/sqlite/Sessions.js +60 -0
- package/plugin/dist/services/sqlite/Summaries.js +44 -0
- package/plugin/dist/services/sqlite/index.js +951 -0
- package/plugin/dist/shared/paths.js +315 -0
- package/plugin/dist/types/worker-types.js +0 -0
- package/plugin/dist/utils/logger.js +222 -0
- package/plugin/dist/viewer.html +252 -0
- package/plugin/dist/viewer.js +23965 -0
- package/plugin/dist/worker-service.js +1782 -0
package/README.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# ContextKit
|
|
2
|
+
|
|
3
|
+
**Persistent cross-session memory for [Kiro CLI](https://kiro.dev/).**
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
ContextKit gives your Kiro agent memory that persists across sessions. It automatically captures what happened -- files changed, tools used, decisions made -- and feeds relevant context back at the start of the next session. No manual bookkeeping. Your agent picks up exactly where it left off.
|
|
13
|
+
|
|
14
|
+
## What Your Agent Sees
|
|
15
|
+
|
|
16
|
+
When a new session starts, ContextKit automatically injects previous session context:
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
# ContextKit: Previous Session Context
|
|
20
|
+
|
|
21
|
+
## Previous Sessions
|
|
22
|
+
|
|
23
|
+
- **Learned**: JWT tokens need refresh logic with 5-minute buffer
|
|
24
|
+
- **Completed**: Implemented OAuth2 login flow with Google provider
|
|
25
|
+
- **Next steps**: Files modified: src/auth/oauth.ts, src/middleware/auth.ts
|
|
26
|
+
|
|
27
|
+
## Recent Observations
|
|
28
|
+
|
|
29
|
+
- **[file-write] Written: src/auth/oauth.ts**: Implemented Google OAuth2 provider
|
|
30
|
+
- **[command] Executed: npm test -- --coverage**: All 47 tests passing
|
|
31
|
+
- **[research] Searched: JWT refresh token best practices**: Found rotating refresh pattern
|
|
32
|
+
|
|
33
|
+
> Project: my-app | Observations: 23 | Summaries: 5
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Features
|
|
37
|
+
|
|
38
|
+
- **Automatic Context Injection** -- Previous session knowledge injected at agent start via `agentSpawn` hook
|
|
39
|
+
- **Prompt Tracking** -- Every user prompt recorded for continuity (`userPromptSubmit` hook)
|
|
40
|
+
- **Tool & File Monitoring** -- File writes, command executions, and tool usage captured in real time (`postToolUse` hook)
|
|
41
|
+
- **Session Summaries** -- Structured summaries generated when sessions end (`stop` hook)
|
|
42
|
+
- **MCP Server** -- 4 tools (`search`, `timeline`, `get_observations`, `get_context`) exposed via Model Context Protocol
|
|
43
|
+
- **Full-Text Search** -- SQLite FTS5 for fast, typo-tolerant search across all stored context
|
|
44
|
+
- **TypeScript SDK** -- Programmatic access to the entire memory system
|
|
45
|
+
- **CLI** -- Query and manage context directly from the terminal
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Install globally
|
|
51
|
+
npm install -g contextkit
|
|
52
|
+
|
|
53
|
+
# Install into Kiro CLI (hooks + MCP server + agent config)
|
|
54
|
+
contextkit install
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or from source:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
git clone https://github.com/auriti-web-design/contextkit.git
|
|
61
|
+
cd contextkit
|
|
62
|
+
npm install && npm run build
|
|
63
|
+
npm run install:kiro
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Start the worker, then use Kiro as usual -- ContextKit runs in the background:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm run worker:start
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Kiro Integration
|
|
73
|
+
|
|
74
|
+
ContextKit registers **4 hooks** and an **MCP server** with Kiro CLI. The agent configuration is installed to `~/.kiro/agents/contextkit.json`:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"name": "contextkit-memory",
|
|
79
|
+
"tools": ["read", "write", "shell", "glob", "grep", "@contextkit"],
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"contextkit": {
|
|
82
|
+
"command": "node",
|
|
83
|
+
"args": ["/path/to/dist/servers/mcp-server.js"]
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"hooks": {
|
|
87
|
+
"agentSpawn": [{ "command": "node /path/to/dist/hooks/agentSpawn.js" }],
|
|
88
|
+
"userPromptSubmit": [{ "command": "node /path/to/dist/hooks/userPromptSubmit.js" }],
|
|
89
|
+
"postToolUse": [{ "command": "node /path/to/dist/hooks/postToolUse.js", "matcher": "*" }],
|
|
90
|
+
"stop": [{ "command": "node /path/to/dist/hooks/stop.js" }]
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The hooks are fully automatic. No changes to your workflow required.
|
|
96
|
+
|
|
97
|
+
## Architecture
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
Kiro CLI
|
|
101
|
+
|
|
|
102
|
+
+-------------+-------------+
|
|
103
|
+
| | |
|
|
104
|
+
agentSpawn postToolUse stop
|
|
105
|
+
(inject ctx) (track tools) (summarize)
|
|
106
|
+
| | |
|
|
107
|
+
+------+------+------+------+
|
|
108
|
+
| |
|
|
109
|
+
Worker HTTP MCP Server
|
|
110
|
+
(port 3001) (stdio)
|
|
111
|
+
| |
|
|
112
|
+
+------+------+
|
|
113
|
+
|
|
|
114
|
+
SQLite + FTS5
|
|
115
|
+
(~/.contextkit/contextkit.db)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Hooks
|
|
119
|
+
|
|
120
|
+
| Hook | Trigger | Purpose |
|
|
121
|
+
|------|---------|---------|
|
|
122
|
+
| `agentSpawn` | Session starts | Injects relevant context from previous sessions |
|
|
123
|
+
| `userPromptSubmit` | User sends prompt | Records the prompt for session continuity |
|
|
124
|
+
| `postToolUse` | Any tool completes | Captures file writes, commands, research actions |
|
|
125
|
+
| `stop` | Session ends | Generates and stores a structured session summary |
|
|
126
|
+
|
|
127
|
+
### MCP Tools
|
|
128
|
+
|
|
129
|
+
| Tool | Description |
|
|
130
|
+
|------|-------------|
|
|
131
|
+
| `search` | Full-text search across observations and summaries. Supports project and type filters. |
|
|
132
|
+
| `timeline` | Chronological context around a specific observation. Shows what happened before and after. |
|
|
133
|
+
| `get_observations` | Retrieve full details of specific observations by ID. Use after `search` to drill down. |
|
|
134
|
+
| `get_context` | Get recent observations, summaries, and prompts for a project. |
|
|
135
|
+
|
|
136
|
+
### Storage
|
|
137
|
+
|
|
138
|
+
| Component | Location |
|
|
139
|
+
|-----------|----------|
|
|
140
|
+
| Database | `~/.contextkit/contextkit.db` |
|
|
141
|
+
| Logs | `~/.contextkit/logs/` |
|
|
142
|
+
| Archives | `~/.contextkit/archives/` |
|
|
143
|
+
| Backups | `~/.contextkit/backups/` |
|
|
144
|
+
|
|
145
|
+
## SDK
|
|
146
|
+
|
|
147
|
+
The TypeScript SDK provides full programmatic access to the memory system.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
import { createContextKit } from 'contextkit';
|
|
151
|
+
|
|
152
|
+
const ctx = createContextKit({ project: 'my-project' });
|
|
153
|
+
|
|
154
|
+
// Retrieve context for the current project
|
|
155
|
+
const context = await ctx.getContext();
|
|
156
|
+
console.log(context.relevantObservations);
|
|
157
|
+
console.log(context.relevantSummaries);
|
|
158
|
+
|
|
159
|
+
// Store an observation
|
|
160
|
+
await ctx.storeObservation({
|
|
161
|
+
type: 'note',
|
|
162
|
+
title: 'Auth fix',
|
|
163
|
+
content: 'Fixed OAuth flow -- tokens now refresh with 5-min buffer'
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Full-text search with filters
|
|
167
|
+
const results = await ctx.searchAdvanced('authentication', {
|
|
168
|
+
type: 'file-write',
|
|
169
|
+
limit: 10
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Get chronological timeline around an observation
|
|
173
|
+
const timeline = await ctx.getTimeline(42, 5, 5);
|
|
174
|
+
|
|
175
|
+
// Store a session summary
|
|
176
|
+
await ctx.storeSummary({
|
|
177
|
+
request: 'Implement OAuth2 login',
|
|
178
|
+
learned: 'Google OAuth requires PKCE for SPAs',
|
|
179
|
+
completed: 'Login flow with Google provider',
|
|
180
|
+
nextSteps: 'Add refresh token rotation'
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Always close when done
|
|
184
|
+
ctx.close();
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### SDK API Reference
|
|
188
|
+
|
|
189
|
+
| Method | Returns | Description |
|
|
190
|
+
|--------|---------|-------------|
|
|
191
|
+
| `getContext()` | `ContextContext` | Recent observations, summaries, and prompts for the project |
|
|
192
|
+
| `storeObservation(data)` | `number` | Store an observation, returns its ID |
|
|
193
|
+
| `storeSummary(data)` | `number` | Store a session summary, returns its ID |
|
|
194
|
+
| `search(query)` | `{ observations, summaries }` | Basic full-text search |
|
|
195
|
+
| `searchAdvanced(query, filters)` | `{ observations, summaries }` | FTS5 search with project/type/date/limit filters |
|
|
196
|
+
| `getTimeline(anchorId, before, after)` | `TimelineEntry[]` | Chronological context around an observation |
|
|
197
|
+
| `getRecentObservations(limit)` | `Observation[]` | Most recent observations |
|
|
198
|
+
| `getRecentSummaries(limit)` | `Summary[]` | Most recent summaries |
|
|
199
|
+
| `getOrCreateSession(id)` | `DBSession` | Get or initialize a session |
|
|
200
|
+
| `storePrompt(sessionId, num, text)` | `number` | Store a user prompt |
|
|
201
|
+
| `close()` | `void` | Close the database connection |
|
|
202
|
+
|
|
203
|
+
## CLI Reference
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
contextkit <command> [options]
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
| Command | Alias | Description |
|
|
210
|
+
|---------|-------|-------------|
|
|
211
|
+
| `contextkit context` | `ctx` | Display current project context |
|
|
212
|
+
| `contextkit search <query>` | -- | Search across all stored context |
|
|
213
|
+
| `contextkit observations [limit]` | `obs` | Show recent observations (default: 10) |
|
|
214
|
+
| `contextkit summaries [limit]` | `sum` | Show recent summaries (default: 5) |
|
|
215
|
+
| `contextkit add-observation <title> <content>` | `add-obs` | Manually add an observation |
|
|
216
|
+
| `contextkit add-summary <content>` | `add-sum` | Manually add a summary |
|
|
217
|
+
|
|
218
|
+
### Examples
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# View what ContextKit knows about your project
|
|
222
|
+
contextkit context
|
|
223
|
+
|
|
224
|
+
# Search for past work on authentication
|
|
225
|
+
contextkit search "OAuth token refresh"
|
|
226
|
+
|
|
227
|
+
# Show the last 20 observations
|
|
228
|
+
contextkit observations 20
|
|
229
|
+
|
|
230
|
+
# Manually record a decision
|
|
231
|
+
contextkit add-observation "Architecture Decision" "Chose PostgreSQL over MongoDB for ACID compliance"
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## Configuration
|
|
235
|
+
|
|
236
|
+
### Environment Variables
|
|
237
|
+
|
|
238
|
+
| Variable | Default | Description |
|
|
239
|
+
|----------|---------|-------------|
|
|
240
|
+
| `CONTEXTKIT_DATA_DIR` | `~/.contextkit` | Base directory for all ContextKit data |
|
|
241
|
+
| `CONTEXTKIT_WORKER_HOST` | `127.0.0.1` | Worker service bind address |
|
|
242
|
+
| `CONTEXTKIT_WORKER_PORT` | `3001` | Worker service port |
|
|
243
|
+
| `CONTEXTKIT_LOG_LEVEL` | `INFO` | Log verbosity: `DEBUG`, `INFO`, `WARN`, `ERROR` |
|
|
244
|
+
| `KIRO_CONFIG_DIR` | `~/.kiro` | Kiro CLI configuration directory |
|
|
245
|
+
|
|
246
|
+
### Worker Management
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
npm run worker:start # Start the background worker
|
|
250
|
+
npm run worker:stop # Stop the worker
|
|
251
|
+
npm run worker:restart # Restart after code changes
|
|
252
|
+
npm run worker:status # Check if worker is running
|
|
253
|
+
npm run worker:logs # View recent logs
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
## Requirements
|
|
257
|
+
|
|
258
|
+
- **Node.js** >= 18
|
|
259
|
+
- **Kiro CLI** -- [kiro.dev](https://kiro.dev/)
|
|
260
|
+
|
|
261
|
+
## Development
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Install dependencies
|
|
265
|
+
npm install
|
|
266
|
+
|
|
267
|
+
# Build and sync to Kiro
|
|
268
|
+
npm run dev
|
|
269
|
+
|
|
270
|
+
# Run tests
|
|
271
|
+
npm test
|
|
272
|
+
|
|
273
|
+
# Run specific test suites
|
|
274
|
+
npm run test:sqlite
|
|
275
|
+
npm run test:search
|
|
276
|
+
npm run test:context
|
|
277
|
+
npm run test:server
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Contributing
|
|
281
|
+
|
|
282
|
+
Contributions are welcome. Please open an issue to discuss proposed changes before submitting a pull request. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
283
|
+
|
|
284
|
+
## License
|
|
285
|
+
|
|
286
|
+
[AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.html)
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
Built by [auriti-web-design](https://github.com/auriti-web-design)
|
package/package.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kiro-memory",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Persistent cross-session memory for Kiro CLI. Automatically tracks context, observations, and summaries across coding sessions.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"kiro",
|
|
7
|
+
"kiro-cli",
|
|
8
|
+
"context",
|
|
9
|
+
"memory",
|
|
10
|
+
"persistence",
|
|
11
|
+
"mcp",
|
|
12
|
+
"hooks",
|
|
13
|
+
"sqlite",
|
|
14
|
+
"typescript",
|
|
15
|
+
"agent",
|
|
16
|
+
"ai-tools"
|
|
17
|
+
],
|
|
18
|
+
"author": "auriti-web-design",
|
|
19
|
+
"license": "AGPL-3.0",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/auriti-web-design/contextkit.git"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/auriti-web-design/contextkit#readme",
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/auriti-web-design/contextkit/issues"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./sdk": {
|
|
35
|
+
"types": "./dist/sdk/index.d.ts",
|
|
36
|
+
"import": "./dist/sdk/index.js"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"plugin"
|
|
42
|
+
],
|
|
43
|
+
"bin": {
|
|
44
|
+
"contextkit": "./dist/cli/contextkit.js"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18.0.0",
|
|
48
|
+
"bun": ">=1.0.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"dev": "npm run build-and-sync",
|
|
52
|
+
"build": "node scripts/build-plugin.js",
|
|
53
|
+
"build-and-sync": "npm run build && npm run sync-kiro && npm run worker:restart",
|
|
54
|
+
"sync-kiro": "node scripts/sync-kiro.cjs",
|
|
55
|
+
"sync-kiro:force": "node scripts/sync-kiro.cjs --force",
|
|
56
|
+
"worker:start": "bun plugin/scripts/worker-service.cjs start",
|
|
57
|
+
"worker:stop": "bun plugin/scripts/worker-service.cjs stop",
|
|
58
|
+
"worker:restart": "bun plugin/scripts/worker-service.cjs restart",
|
|
59
|
+
"worker:status": "bun plugin/scripts/worker-service.cjs status",
|
|
60
|
+
"worker:logs": "tail -n 50 ~/.contextkit/logs/worker-$(date +%Y-%m-%d).log",
|
|
61
|
+
"worker:tail": "tail -f 50 ~/.contextkit/logs/worker-$(date +%Y-%m-%d).log",
|
|
62
|
+
"queue": "bun scripts/check-pending-queue.ts",
|
|
63
|
+
"queue:process": "bun scripts/check-pending-queue.ts --process",
|
|
64
|
+
"queue:clear": "bun scripts/clear-failed-queue.ts --all --force",
|
|
65
|
+
"context:regenerate": "bun scripts/regenerate-context.ts",
|
|
66
|
+
"context:dry-run": "bun scripts/regenerate-context.ts --dry-run",
|
|
67
|
+
"test": "bun test",
|
|
68
|
+
"test:sqlite": "bun test tests/sqlite/",
|
|
69
|
+
"test:agents": "bun test tests/worker/agents/",
|
|
70
|
+
"test:search": "bun test tests/worker/search/",
|
|
71
|
+
"test:context": "bun test tests/context/",
|
|
72
|
+
"test:infra": "bun test tests/infrastructure/",
|
|
73
|
+
"test:server": "bun test tests/server/",
|
|
74
|
+
"install:kiro": "bash scripts/install-kiro.sh",
|
|
75
|
+
"prepublishOnly": "npm run build",
|
|
76
|
+
"release": "np",
|
|
77
|
+
"release:patch": "np patch --no-cleanup",
|
|
78
|
+
"release:minor": "np minor --no-cleanup",
|
|
79
|
+
"release:major": "np major --no-cleanup"
|
|
80
|
+
},
|
|
81
|
+
"np": {
|
|
82
|
+
"yarn": false,
|
|
83
|
+
"contents": ".",
|
|
84
|
+
"testScript": "test",
|
|
85
|
+
"2fa": false
|
|
86
|
+
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"@chroma-core/default-embed": "^0.1.9",
|
|
89
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
90
|
+
"ansi-to-html": "^0.7.2",
|
|
91
|
+
"better-sqlite3": "^12.6.2",
|
|
92
|
+
"chromadb": "^3.2.2",
|
|
93
|
+
"cors": "^2.8.5",
|
|
94
|
+
"dompurify": "^3.3.1",
|
|
95
|
+
"express": "^4.18.2",
|
|
96
|
+
"glob": "^11.0.3",
|
|
97
|
+
"handlebars": "^4.7.8",
|
|
98
|
+
"react": "^18.3.1",
|
|
99
|
+
"react-dom": "^18.3.1",
|
|
100
|
+
"yaml": "^2.8.2",
|
|
101
|
+
"zod": "^3.23.8"
|
|
102
|
+
},
|
|
103
|
+
"devDependencies": {
|
|
104
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
105
|
+
"@types/cors": "^2.8.19",
|
|
106
|
+
"@types/dompurify": "^3.0.5",
|
|
107
|
+
"@types/express": "^4.17.21",
|
|
108
|
+
"@types/node": "^20.0.0",
|
|
109
|
+
"@types/react": "^18.3.5",
|
|
110
|
+
"@types/react-dom": "^18.3.0",
|
|
111
|
+
"bun-types": "^1.0.0",
|
|
112
|
+
"esbuild": "^0.27.2",
|
|
113
|
+
"np": "^11.0.2",
|
|
114
|
+
"tsx": "^4.20.6",
|
|
115
|
+
"typescript": "^5.3.0"
|
|
116
|
+
}
|
|
117
|
+
}
|