Skip to content

Commit ed62d30

Browse files
committed
v1.0.11: docs overhaul, CPU optimization, unified SETUP.md
- Merge other-clients.md into unified docs/SETUP.md - Add client setup for OpenCode, Cursor, Windsurf with MCP config examples - Fix tool count in CONTRIBUTING.md and ARCHITECTURE.md (10 → 12) - Fix REST endpoints in SETUP.md (/api/entries → /api/knowledge) - Fix dashboard tabs (Recall → Embeddings) - Add 11 missing env vars to SETUP.md (embedding config, API keys) - Add session-start hook script - Add descriptions to README doc links for consistency
1 parent 133080d commit ed62d30

14 files changed

Lines changed: 354 additions & 47 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export KNOWLEDGE_PORT=3423
5656
agent-knowledge/
5757
src/
5858
index.ts Entry point (MCP stdio + dashboard auto-start)
59-
server.ts MCP server, 10 tool definitions, request routing
59+
server.ts MCP server, 12 tool definitions, request routing
6060
dashboard.ts HTTP + WebSocket server, REST API, file watcher
6161
types.ts KnowledgeConfig, getConfig()
6262
knowledge/

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ npm run lint # Type-check (tsc --noEmit)
182182

183183
## Documentation
184184

185-
- [Setup Guide](docs/SETUP.md)
186-
- [Architecture](docs/ARCHITECTURE.md)
187-
- [Dashboard](docs/DASHBOARD.md)
185+
- [Setup Guide](docs/SETUP.md) — installation, client setup (Claude Code, OpenCode, Cursor, Windsurf), hooks
186+
- [Architecture](docs/ARCHITECTURE.md) — source structure, design principles, database schema
187+
- [Dashboard](docs/DASHBOARD.md) — web UI views and features
188188
- [Changelog](CHANGELOG.md)
189189

190190
## License

docs/ARCHITECTURE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ graph TB
3535
```
3636
src/
3737
index.ts Entry point — MCP stdio + dashboard auto-start
38-
server.ts 10 tool definitions, request routing, error handling
38+
server.ts 12 tool definitions, request routing, error handling
3939
dashboard.ts HTTP + WebSocket server, REST API, file watcher
4040
types.ts KnowledgeConfig interface, getConfig()
4141
knowledge/

docs/SETUP.md

Lines changed: 246 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
# Setup Guide
22

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+
328
## Prerequisites
429

530
- **Node.js 20+** (ES modules and TypeScript features)
@@ -10,6 +35,8 @@ node --version # v20.0.0 or later
1035
git --version
1136
```
1237

38+
---
39+
1340
## Installation
1441

1542
```bash
@@ -25,17 +52,23 @@ For development with auto-rebuild:
2552
npm run dev
2653
```
2754

28-
## Configuration in Claude Code
55+
---
56+
57+
## Client Setup
58+
59+
agent-knowledge works with any MCP client (stdio) or HTTP client (REST API). Pick your client below.
2960

30-
### Register the MCP server
61+
### Claude Code
62+
63+
#### Register the MCP server
3164

3265
```bash
3366
claude mcp add agent-knowledge -s user \
3467
-e KNOWLEDGE_MEMORY_DIR="$HOME/claude-memory" \
3568
-- node /path/to/agent-knowledge/dist/index.js
3669
```
3770

38-
### Permissions
71+
#### Permissions
3972

4073
Add to `~/.claude/settings.json`:
4174

@@ -47,34 +80,173 @@ Add to `~/.claude/settings.json`:
4780
}
4881
```
4982

50-
### Verify
83+
#### Verify
5184

5285
```bash
5386
claude mcp list
5487
# Should show: agent-knowledge ... Connected
5588
```
5689

57-
## Environment Variables
90+
### OpenCode
5891

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 |
92+
`opencode.json` (project root) or `~/.config/opencode/opencode.json` (global):
6593

66-
Set in your shell profile or pass via MCP config:
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:
67151

68152
```bash
69-
export KNOWLEDGE_MEMORY_DIR="$HOME/claude-memory"
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."}'
70166
```
71167

72-
On Windows (PowerShell):
168+
---
73169

74-
```powershell
75-
$env:KNOWLEDGE_MEMORY_DIR = "$env:USERPROFILE\claude-memory"
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+
}
76198
```
77199

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+
78250
## Knowledge Base Setup
79251

80252
The knowledge base is a git repository with categorized markdown files.
@@ -118,14 +290,51 @@ updated: 2026-03-25
118290
Architecture notes, deployment info, etc.
119291
```
120292

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+
121328
## Dashboard
122329

123330
Auto-starts with the MCP server at **http://localhost:3423**.
124331

125-
4 tabs: Knowledge, Search, Sessions, Recall. Supports light/dark theme.
332+
4 tabs: Knowledge, Search, Sessions, Embeddings. Supports light/dark theme.
126333

127334
Live reload: edit files in `src/ui/` and the browser refreshes automatically.
128335

336+
---
337+
129338
## Multi-Machine Sync
130339

131340
| Operation | Git Action | When |
@@ -140,6 +349,16 @@ Ensure git credentials are configured (SSH key or credential helper):
140349
cd ~/claude-memory && git pull && git push # Should work without prompts
141350
```
142351

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+
143362
## Troubleshooting
144363

145364
### Port already in use
@@ -176,3 +395,13 @@ Verify session transcripts exist:
176395
```bash
177396
ls ~/.claude/projects/ # Should contain project directories with .jsonl files
178397
```
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-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "agent-knowledge",
3-
"version": "1.0.10",
3+
"version": "1.0.11",
44
"description": "Cross-session memory and recall for AI agents — git-synced knowledge base, hybrid semantic+TF-IDF search, auto-distillation with secrets scrubbing",
55
"type": "module",
66
"main": "dist/index.js",

0 commit comments

Comments
 (0)