agent-knowledge 1.0.10 → 1.0.12

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/docs/SETUP.md CHANGED
@@ -1,178 +1,407 @@
1
- # Setup Guide
2
-
3
- ## Prerequisites
4
-
5
- - **Node.js 20+** (ES modules and TypeScript features)
6
- - **Git** (for knowledge base sync)
7
-
8
- ```bash
9
- node --version # v20.0.0 or later
10
- git --version
11
- ```
12
-
13
- ## Installation
14
-
15
- ```bash
16
- git clone https://github.com/keshrath/agent-knowledge.git
17
- cd agent-knowledge
18
- npm install
19
- npm run build
20
- ```
21
-
22
- For development with auto-rebuild:
23
-
24
- ```bash
25
- npm run dev
26
- ```
27
-
28
- ## Configuration in Claude Code
29
-
30
- ### Register the MCP server
31
-
32
- ```bash
33
- claude mcp add agent-knowledge -s user \
34
- -e KNOWLEDGE_MEMORY_DIR="$HOME/claude-memory" \
35
- -- node /path/to/agent-knowledge/dist/index.js
36
- ```
37
-
38
- ### Permissions
39
-
40
- Add to `~/.claude/settings.json`:
41
-
42
- ```json
43
- {
44
- "permissions": {
45
- "allow": ["mcp__agent-knowledge__*"]
46
- }
47
- }
48
- ```
49
-
50
- ### Verify
51
-
52
- ```bash
53
- claude mcp list
54
- # Should show: agent-knowledge ... Connected
55
- ```
56
-
57
- ## Environment Variables
58
-
59
- | Variable | Default | Description |
60
- | ---------------------- | ----------------- | --------------------------------- |
61
- | `KNOWLEDGE_MEMORY_DIR` | `~/claude-memory` | Path to git-synced knowledge base |
62
- | `CLAUDE_MEMORY_DIR` | `~/claude-memory` | Alias (backwards compat) |
63
- | `CLAUDE_DIR` | `~/.claude` | Claude Code data directory |
64
- | `KNOWLEDGE_PORT` | `3423` | Dashboard HTTP/WebSocket port |
65
-
66
- Set in your shell profile or pass via MCP config:
67
-
68
- ```bash
69
- export KNOWLEDGE_MEMORY_DIR="$HOME/claude-memory"
70
- ```
71
-
72
- On Windows (PowerShell):
73
-
74
- ```powershell
75
- $env:KNOWLEDGE_MEMORY_DIR = "$env:USERPROFILE\claude-memory"
76
- ```
77
-
78
- ## Knowledge Base Setup
79
-
80
- The knowledge base is a git repository with categorized markdown files.
81
-
82
- ### Clone existing or create new
83
-
84
- ```bash
85
- # Clone existing
86
- git clone https://your-git-host/claude-memory.git ~/claude-memory
87
-
88
- # Or create new
89
- mkdir -p ~/claude-memory && cd ~/claude-memory && git init
90
- mkdir projects people decisions workflows notes
91
- git add . && git commit -m "Initialize knowledge base"
92
- git remote add origin <your-remote-url>
93
- git push -u origin main
94
- ```
95
-
96
- ### Directory structure
97
-
98
- ```
99
- ~/claude-memory/
100
- projects/ # Project context, architecture, tech stacks
101
- people/ # Team members, contacts, preferences
102
- decisions/ # Architecture decisions, trade-offs, rationale
103
- workflows/ # Processes, deployment steps, runbooks
104
- notes/ # General notes, research, references
105
- ```
106
-
107
- ### Entry format
108
-
109
- ```markdown
110
- ---
111
- title: My Project
112
- tags: [typescript, react, postgres]
113
- updated: 2026-03-25
114
- ---
115
-
116
- # My Project
117
-
118
- Architecture notes, deployment info, etc.
119
- ```
120
-
121
- ## Dashboard
122
-
123
- Auto-starts with the MCP server at **http://localhost:3423**.
124
-
125
- 4 tabs: Knowledge, Search, Sessions, Recall. Supports light/dark theme.
126
-
127
- Live reload: edit files in `src/ui/` and the browser refreshes automatically.
128
-
129
- ## Multi-Machine Sync
130
-
131
- | Operation | Git Action | When |
132
- | ------------------------------------- | ------------------------------ | -------------- |
133
- | `knowledge_read`, `knowledge_list` | `git pull --rebase` | Before reading |
134
- | `knowledge_write`, `knowledge_delete` | `git add -A && commit && push` | After writing |
135
- | `knowledge_sync` | `git pull` then `git push` | Manual trigger |
136
-
137
- Ensure git credentials are configured (SSH key or credential helper):
138
-
139
- ```bash
140
- cd ~/claude-memory && git pull && git push # Should work without prompts
141
- ```
142
-
143
- ## Troubleshooting
144
-
145
- ### Port already in use
146
-
147
- ```bash
148
- # Find the process
149
- netstat -ano | findstr :3423 # Windows
150
- lsof -i :3423 # Linux/macOS
151
-
152
- # Use a different port
153
- export KNOWLEDGE_PORT=3424
154
- ```
155
-
156
- ### Git authentication failures
157
-
158
- Verify credentials work manually:
159
-
160
- ```bash
161
- cd ~/claude-memory && git push
162
- ```
163
-
164
- Set up SSH keys or a credential helper if prompted.
165
-
166
- ### MCP server not connecting
167
-
168
- 1. Check path points to `dist/index.js` (not `src/index.ts`)
169
- 2. Verify Node.js 20+ is on your PATH
170
- 3. Try running manually: `node /path/to/agent-knowledge/dist/index.js`
171
-
172
- ### No session results
173
-
174
- Verify session transcripts exist:
175
-
176
- ```bash
177
- ls ~/.claude/projects/ # Should contain project directories with .jsonl files
178
- ```
1
+ # Setup Guide
2
+
3
+ Detailed instructions for installing, configuring, and integrating agent-knowledge with any MCP client.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Prerequisites](#prerequisites)
8
+ - [Installation](#installation)
9
+ - [Client Setup](#client-setup)
10
+ - [Claude Code](#claude-code)
11
+ - [OpenCode](#opencode)
12
+ - [Cursor](#cursor)
13
+ - [Windsurf](#windsurf)
14
+ - [REST API](#rest-api)
15
+ - [Hooks](#hooks)
16
+ - [Claude Code Hooks](#claude-code-hooks)
17
+ - [OpenCode Plugins](#opencode-plugins)
18
+ - [Cursor and Windsurf](#cursor-and-windsurf)
19
+ - [Knowledge Base Setup](#knowledge-base-setup)
20
+ - [Environment Variables](#environment-variables)
21
+ - [Dashboard](#dashboard)
22
+ - [Multi-Machine Sync](#multi-machine-sync)
23
+ - [Session Auto-Distillation](#session-auto-distillation)
24
+ - [Troubleshooting](#troubleshooting)
25
+
26
+ ---
27
+
28
+ ## Prerequisites
29
+
30
+ - **Node.js 20+** (ES modules and TypeScript features)
31
+ - **Git** (for knowledge base sync)
32
+
33
+ ```bash
34
+ node --version # v20.0.0 or later
35
+ git --version
36
+ ```
37
+
38
+ ---
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ git clone https://github.com/keshrath/agent-knowledge.git
44
+ cd agent-knowledge
45
+ npm install
46
+ npm run build
47
+ ```
48
+
49
+ For development with auto-rebuild:
50
+
51
+ ```bash
52
+ npm run dev
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Client Setup
58
+
59
+ agent-knowledge works with any MCP client (stdio) or HTTP client (REST API). Pick your client below.
60
+
61
+ ### Claude Code
62
+
63
+ #### Register the MCP server
64
+
65
+ ```bash
66
+ claude mcp add agent-knowledge -s user \
67
+ -e KNOWLEDGE_MEMORY_DIR="$HOME/claude-memory" \
68
+ -- node /path/to/agent-knowledge/dist/index.js
69
+ ```
70
+
71
+ #### Permissions
72
+
73
+ Add to `~/.claude/settings.json`:
74
+
75
+ ```json
76
+ {
77
+ "permissions": {
78
+ "allow": ["mcp__agent-knowledge__*"]
79
+ }
80
+ }
81
+ ```
82
+
83
+ #### Verify
84
+
85
+ ```bash
86
+ claude mcp list
87
+ # Should show: agent-knowledge ... Connected
88
+ ```
89
+
90
+ ### OpenCode
91
+
92
+ `opencode.json` (project root) or `~/.config/opencode/opencode.json` (global):
93
+
94
+ ```json
95
+ {
96
+ "$schema": "https://opencode.ai/config.json",
97
+ "mcp": {
98
+ "agent-knowledge": {
99
+ "type": "local",
100
+ "command": ["node", "/absolute/path/to/agent-knowledge/dist/index.js"],
101
+ "environment": {
102
+ "KNOWLEDGE_MEMORY_DIR": "/home/you/claude-memory",
103
+ "KNOWLEDGE_PORT": "3423"
104
+ }
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### Cursor
111
+
112
+ `.cursor/mcp.json` in your project root:
113
+
114
+ ```json
115
+ {
116
+ "mcpServers": {
117
+ "agent-knowledge": {
118
+ "command": "node",
119
+ "args": ["/absolute/path/to/agent-knowledge/dist/index.js"],
120
+ "env": {
121
+ "KNOWLEDGE_MEMORY_DIR": "/home/you/claude-memory",
122
+ "KNOWLEDGE_PORT": "3423"
123
+ }
124
+ }
125
+ }
126
+ }
127
+ ```
128
+
129
+ ### Windsurf
130
+
131
+ `~/.codeium/windsurf/mcp_config.json`:
132
+
133
+ ```json
134
+ {
135
+ "mcpServers": {
136
+ "agent-knowledge": {
137
+ "command": "node",
138
+ "args": ["/absolute/path/to/agent-knowledge/dist/index.js"],
139
+ "env": {
140
+ "KNOWLEDGE_MEMORY_DIR": "/home/you/claude-memory",
141
+ "KNOWLEDGE_PORT": "3423"
142
+ }
143
+ }
144
+ }
145
+ }
146
+ ```
147
+
148
+ ### REST API
149
+
150
+ If your tool doesn't support MCP, use the REST API:
151
+
152
+ ```bash
153
+ # List entries
154
+ curl http://localhost:3423/api/knowledge
155
+
156
+ # Search
157
+ curl 'http://localhost:3423/api/knowledge/search?q=deployment+pipeline'
158
+
159
+ # Read an entry
160
+ curl http://localhost:3423/api/knowledge/projects/my-project
161
+
162
+ # Write an entry
163
+ curl -X PUT http://localhost:3423/api/knowledge/notes/my-note \
164
+ -H 'Content-Type: application/json' \
165
+ -d '{"content": "---\ntitle: My Note\ntags: [example]\n---\n\nContent here."}'
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Hooks
171
+
172
+ Hooks announce the dashboard URL on session start. Support varies by client.
173
+
174
+ ### Claude Code Hooks
175
+
176
+ #### SessionStart (`scripts/hooks/session-start.js`)
177
+
178
+ Announces the knowledge dashboard URL on session start.
179
+
180
+ Add to `~/.claude/settings.json`:
181
+
182
+ ```json
183
+ {
184
+ "hooks": {
185
+ "SessionStart": [
186
+ {
187
+ "hooks": [
188
+ {
189
+ "type": "command",
190
+ "command": "node \"/path/to/agent-knowledge/scripts/hooks/session-start.js\"",
191
+ "timeout": 5
192
+ }
193
+ ]
194
+ }
195
+ ]
196
+ }
197
+ }
198
+ ```
199
+
200
+ ### OpenCode Plugins
201
+
202
+ OpenCode supports lifecycle hooks via JavaScript/TypeScript plugins. Create a plugin in `.opencode/plugins/` or `~/.config/opencode/plugins/`:
203
+
204
+ ```typescript
205
+ // .opencode/plugins/agent-knowledge.ts
206
+ import type { Plugin } from '@opencode-ai/plugin';
207
+
208
+ export const AgentKnowledgePlugin: Plugin = async ({ client }) => {
209
+ return {
210
+ event: async (event) => {
211
+ if (event.type === 'session.created') {
212
+ // Knowledge base instructions provided via AGENTS.md
213
+ }
214
+ },
215
+ };
216
+ };
217
+ ```
218
+
219
+ Available events: `session.created`, `session.idle`, `tool.execute.before`, `tool.execute.after`, `message.updated`, `file.edited`.
220
+
221
+ Combine with `AGENTS.md` instructions (see below).
222
+
223
+ ### Cursor and Windsurf
224
+
225
+ Cursor and Windsurf don't support lifecycle hooks. Use the client's system prompt / instructions file:
226
+
227
+ | Client | Instructions file |
228
+ | -------- | ----------------- |
229
+ | Cursor | `.cursorrules` |
230
+ | Windsurf | `.windsurfrules` |
231
+
232
+ Add these instructions:
233
+
234
+ ```
235
+ You have access to agent-knowledge MCP tools — a shared knowledge base synced via git.
236
+
237
+ Available tools: knowledge_list, knowledge_read, knowledge_write, knowledge_search,
238
+ knowledge_recall, knowledge_sessions, knowledge_config, knowledge_sync
239
+
240
+ Categories: projects, people, decisions, workflows, notes
241
+
242
+ Use knowledge_search for semantic + keyword search across all entries.
243
+ Use knowledge_recall for scoped search (errors, plans, configs, tools, files, decisions).
244
+
245
+ Dashboard: http://localhost:3423
246
+ ```
247
+
248
+ ---
249
+
250
+ ## Knowledge Base Setup
251
+
252
+ The knowledge base is a git repository with categorized markdown files.
253
+
254
+ ### Clone existing or create new
255
+
256
+ ```bash
257
+ # Clone existing
258
+ git clone https://your-git-host/claude-memory.git ~/claude-memory
259
+
260
+ # Or create new
261
+ mkdir -p ~/claude-memory && cd ~/claude-memory && git init
262
+ mkdir projects people decisions workflows notes
263
+ git add . && git commit -m "Initialize knowledge base"
264
+ git remote add origin <your-remote-url>
265
+ git push -u origin main
266
+ ```
267
+
268
+ ### Directory structure
269
+
270
+ ```
271
+ ~/claude-memory/
272
+ projects/ # Project context, architecture, tech stacks
273
+ people/ # Team members, contacts, preferences
274
+ decisions/ # Architecture decisions, trade-offs, rationale
275
+ workflows/ # Processes, deployment steps, runbooks
276
+ notes/ # General notes, research, references
277
+ ```
278
+
279
+ ### Entry format
280
+
281
+ ```markdown
282
+ ---
283
+ title: My Project
284
+ tags: [typescript, react, postgres]
285
+ updated: 2026-03-25
286
+ ---
287
+
288
+ # My Project
289
+
290
+ Architecture notes, deployment info, etc.
291
+ ```
292
+
293
+ ---
294
+
295
+ ## Environment Variables
296
+
297
+ | Variable | Default | Description |
298
+ | ------------------------------------------------ | ----------------- | -------------------------------------------------- |
299
+ | `KNOWLEDGE_MEMORY_DIR` | `~/claude-memory` | Path to git-synced knowledge base |
300
+ | `CLAUDE_MEMORY_DIR` | `~/claude-memory` | Alias (backwards compat) |
301
+ | `CLAUDE_DIR` | `~/.claude` | Claude Code data directory |
302
+ | `KNOWLEDGE_PORT` | `3423` | Dashboard HTTP/WebSocket port |
303
+ | `KNOWLEDGE_EMBEDDING_PROVIDER` | `local` | Embedding provider (local, openai, claude, gemini) |
304
+ | `KNOWLEDGE_EMBEDDING_ALPHA` | `0.5` | Blend weight for semantic vs TF-IDF search (0-1) |
305
+ | `KNOWLEDGE_EMBEDDING_IDLE_TIMEOUT` | — | Idle timeout for embedding worker (ms) |
306
+ | `KNOWLEDGE_EMBEDDING_THREADS` | — | Number of ONNX threads for local embeddings |
307
+ | `KNOWLEDGE_EMBEDDING_MODEL` | — | Model name for embedding provider |
308
+ | `KNOWLEDGE_GIT_URL` | — | Remote git URL for knowledge base sync |
309
+ | `KNOWLEDGE_AUTO_DISTILL` | — | Enable auto-distillation of sessions (true/false) |
310
+ | `KNOWLEDGE_OPENAI_API_KEY` / `OPENAI_API_KEY` | — | API key for OpenAI embeddings |
311
+ | `KNOWLEDGE_CLAUDE_API_KEY` / `ANTHROPIC_API_KEY` | — | API key for Claude/Voyage embeddings |
312
+ | `KNOWLEDGE_GEMINI_API_KEY` / `GEMINI_API_KEY` | — | API key for Gemini embeddings |
313
+
314
+ Set in your shell profile or pass via MCP config:
315
+
316
+ ```bash
317
+ export KNOWLEDGE_MEMORY_DIR="$HOME/claude-memory"
318
+ ```
319
+
320
+ On Windows (PowerShell):
321
+
322
+ ```powershell
323
+ $env:KNOWLEDGE_MEMORY_DIR = "$env:USERPROFILE\claude-memory"
324
+ ```
325
+
326
+ ---
327
+
328
+ ## Dashboard
329
+
330
+ Auto-starts with the MCP server at **http://localhost:3423**.
331
+
332
+ 4 tabs: Knowledge, Search, Sessions, Embeddings. Supports light/dark theme.
333
+
334
+ Live reload: edit files in `src/ui/` and the browser refreshes automatically.
335
+
336
+ ---
337
+
338
+ ## Multi-Machine Sync
339
+
340
+ | Operation | Git Action | When |
341
+ | ------------------------------------- | ------------------------------ | -------------- |
342
+ | `knowledge_read`, `knowledge_list` | `git pull --rebase` | Before reading |
343
+ | `knowledge_write`, `knowledge_delete` | `git add -A && commit && push` | After writing |
344
+ | `knowledge_sync` | `git pull` then `git push` | Manual trigger |
345
+
346
+ Ensure git credentials are configured (SSH key or credential helper):
347
+
348
+ ```bash
349
+ cd ~/claude-memory && git pull && git push # Should work without prompts
350
+ ```
351
+
352
+ ---
353
+
354
+ ## Session Auto-Distillation
355
+
356
+ agent-knowledge can auto-distill session transcripts into knowledge entries. This currently reads Claude Code session files from `~/.claude/projects/`. Other clients store transcripts differently — auto-distillation only works with Claude Code sessions for now.
357
+
358
+ To manually save knowledge from any client, use `knowledge_write`.
359
+
360
+ ---
361
+
362
+ ## Troubleshooting
363
+
364
+ ### Port already in use
365
+
366
+ ```bash
367
+ # Find the process
368
+ netstat -ano | findstr :3423 # Windows
369
+ lsof -i :3423 # Linux/macOS
370
+
371
+ # Use a different port
372
+ export KNOWLEDGE_PORT=3424
373
+ ```
374
+
375
+ ### Git authentication failures
376
+
377
+ Verify credentials work manually:
378
+
379
+ ```bash
380
+ cd ~/claude-memory && git push
381
+ ```
382
+
383
+ Set up SSH keys or a credential helper if prompted.
384
+
385
+ ### MCP server not connecting
386
+
387
+ 1. Check path points to `dist/index.js` (not `src/index.ts`)
388
+ 2. Verify Node.js 20+ is on your PATH
389
+ 3. Try running manually: `node /path/to/agent-knowledge/dist/index.js`
390
+
391
+ ### No session results
392
+
393
+ Verify session transcripts exist:
394
+
395
+ ```bash
396
+ ls ~/.claude/projects/ # Should contain project directories with .jsonl files
397
+ ```
398
+
399
+ ## Client Comparison
400
+
401
+ | Feature | Claude Code | OpenCode | Cursor | Windsurf |
402
+ | -------------------- | ----------- | ------------- | ------------ | -------------- |
403
+ | MCP stdio transport | Yes | Yes | Yes | Yes |
404
+ | Lifecycle hooks | Yes (JSON) | Yes (plugins) | No | No |
405
+ | Session auto-distill | Yes | No | No | No |
406
+ | System prompt file | CLAUDE.md | AGENTS.md | .cursorrules | .windsurfrules |
407
+ | REST API fallback | Yes | Yes | Yes | Yes |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-knowledge",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "Cross-session memory and recall for AI agents — git-synced knowledge base, hybrid semantic+TF-IDF search, auto-distillation with secrets scrubbing",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
- import { cpSync } from 'fs';
2
- import { fileURLToPath } from 'url';
3
- import { dirname, join } from 'path';
4
-
5
- const root = join(dirname(fileURLToPath(import.meta.url)), '..');
6
- cpSync(join(root, 'src', 'ui'), join(root, 'dist', 'ui'), { recursive: true });
1
+ import { cpSync } from 'fs';
2
+ import { fileURLToPath } from 'url';
3
+ import { dirname, join } from 'path';
4
+
5
+ const root = join(dirname(fileURLToPath(import.meta.url)), '..');
6
+ cpSync(join(root, 'src', 'ui'), join(root, 'dist', 'ui'), { recursive: true });
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+
3
+ // =============================================================================
4
+ // agent-knowledge SessionStart hook
5
+ //
6
+ // Announces the knowledge dashboard URL.
7
+ // =============================================================================
8
+
9
+ const knowledgePort = process.env.AGENT_KNOWLEDGE_PORT || '3423';
10
+
11
+ const msg = {
12
+ systemMessage: `agent-knowledge: http://localhost:${knowledgePort}`,
13
+ hookSpecificOutput: {
14
+ hookEventName: 'SessionStart',
15
+ additionalContext: `Knowledge: http://localhost:${knowledgePort}`,
16
+ },
17
+ };
18
+
19
+ console.log(JSON.stringify(msg));