Skip to content

Commit 625b2dd

Browse files
committed
v1.1.0: generic multi-tool session support, remove Claude Code coupling
- Remove all Claude Code-specific naming: claudeDir→dataDir, projectsDir→sessionsDir - New env vars: KNOWLEDGE_DATA_DIR, KNOWLEDGE_ANTHROPIC_API_KEY (no legacy fallbacks) - Default memory dir: ~/agent-knowledge (was ~/claude-memory) - Rename ClaudeEmbeddingProvider→AnthropicEmbeddingProvider (claude.ts→anthropic.ts) - Add session adapter system with auto-detection for 6 AI coding tools: Claude Code (JSONL), Cursor (JSONL), OpenCode (SQLite), Cline (JSON), Continue.dev (JSON), Aider (Markdown/JSONL) - Native Cursor session format support (role field, content arrays) - Auto-create vector DB parent directory on startup - Update all documentation for generic multi-tool identity
1 parent fde4947 commit 625b2dd

26 files changed

Lines changed: 1281 additions & 173 deletions

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
# Changelog
22

3+
## 1.1.0 (2026-03-27)
4+
5+
### Multi-Source Session Adapters
6+
7+
agent-knowledge now auto-discovers and reads sessions from all major AI coding assistants. If a tool is installed, its sessions appear automatically in the dashboard and search results -- no configuration required.
8+
9+
- **New adapters**: OpenCode (SQLite), Cline (JSON), Continue.dev (JSON), Aider (Markdown/JSONL)
10+
- **Auto-detection**: Cursor sessions discovered from `~/.cursor/projects/*/agent-transcripts/`; OpenCode from `~/.local/share/opencode/opencode.db`; Cline from VS Code globalStorage; Continue.dev from `~/.continue/sessions/`; Aider from `.aider.chat.history.md` / `.aider.llm.history` in project dirs
11+
- **Adapter interface**: pluggable `SessionAdapter` with `isAvailable()`, `discoverProjects()`, `listSessions()`, `parseSession()` -- add new tools by implementing one file
12+
- **`EXTRA_SESSION_ROOTS` env var**: comma-separated paths for additional session directories
13+
- **`OPENCODE_DATA_DIR` env var**: override OpenCode data location (default `~/.local/share/opencode`)
14+
15+
### Generic Naming Refactor
16+
17+
Removed Claude Code-specific language throughout. agent-knowledge is now fully client-agnostic.
18+
19+
- **Config fields renamed**: `claudeDir` -> `dataDir`, `projectsDir` -> `sessionsDir`
20+
- **Env vars renamed**:
21+
- `KNOWLEDGE_DATA_DIR` (was `CLAUDE_DIR`)
22+
- `KNOWLEDGE_ANTHROPIC_API_KEY` (was `KNOWLEDGE_CLAUDE_API_KEY`)
23+
- **Default memory directory**: `~/agent-knowledge`
24+
- **Embedding class renamed**: `ClaudeEmbeddingProvider` -> `AnthropicEmbeddingProvider`
25+
- **Documentation**: all references updated to use generic "agent sessions" language, architecture diagrams show "Session Data Dir" instead of `~/.claude/projects`
26+
327
## 1.0.0 (2026-03-26)
428

529
Initial release.
@@ -30,7 +54,7 @@ Initial release.
3054

3155
### Knowledge Base
3256

33-
- Git-synced markdown vault at `~/claude-memory/`
57+
- Git-synced markdown vault at `~/agent-knowledge/` (previously `~/claude-memory/`)
3458
- 5 categories: projects, people, decisions, workflows, notes
3559
- YAML frontmatter for metadata (title, tags, updated)
3660
- Auto git commit + push on writes, pull on reads

CLAUDE.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ src/
99
server.ts MCP server, 12 tool definitions, request routing
1010
dashboard.ts HTTP + WebSocket server, REST API, file watcher
1111
index.ts Entry point (MCP stdio + dashboard auto-start)
12-
types.ts KnowledgeConfig, getConfig(), persisted config
12+
types.ts KnowledgeConfig (dataDir, sessionsDir, extraSessionRoots), getConfig(), persisted config
1313
validate.ts ValidationError class, input validation
1414
version.ts Runtime version from package.json
1515
knowledge/
@@ -18,11 +18,17 @@ src/
1818
git.ts git pull/push/sync with timeouts
1919
distill.ts Session auto-distillation with secrets scrubbing
2020
sessions/
21-
parser.ts JSONL parsing with mtime-based cache
21+
parser.ts Multi-format session parsing with mtime-based cache
2222
indexer.ts Background indexing for sessions
2323
search.ts TF-IDF ranked search with 60s global index cache
2424
scopes.ts Search scopes (errors, plans, configs, tools, files, decisions)
2525
summary.ts Session summaries, topic extraction, file path detection
26+
adapters/
27+
index.ts SessionAdapter interface, adapter registry, auto-init
28+
opencode.ts OpenCode adapter (SQLite database)
29+
cline.ts Cline adapter (VS Code globalStorage JSON)
30+
continue.ts Continue.dev adapter (JSON session files)
31+
aider.ts Aider adapter (Markdown chat history + JSONL LLM history)
2632
search/
2733
tfidf.ts TF-IDF scoring engine (tokenizer, stopwords, index)
2834
fuzzy.ts Levenshtein distance, sliding window fuzzy matching
@@ -85,9 +91,22 @@ npm run dev # watch mode (tsc --watch)
8591
- **Dashboard**: HTTP + WebSocket at port 3423, REST API for entries/sessions/search
8692
- **Git sync**: Auto pull/push on write, manual sync via `knowledge_sync`
8793

94+
## Supported Session Sources
95+
96+
Sessions are auto-discovered from all installed AI coding tools via the adapter system:
97+
98+
- **Claude Code** -- JSONL files in `$KNOWLEDGE_DATA_DIR/projects/`
99+
- **Cursor** -- JSONL files in `~/.cursor/projects/*/agent-transcripts/`
100+
- **OpenCode** -- SQLite database at `~/.local/share/opencode/opencode.db` (or `$OPENCODE_DATA_DIR`)
101+
- **Cline** -- JSON task files in VS Code globalStorage `saoudrizwan.claude-dev/tasks/`
102+
- **Continue.dev** -- JSON session files in `~/.continue/sessions/`
103+
- **Aider** -- `.aider.chat.history.md` and `.aider.llm.history` in project directories
104+
105+
Additional roots: `EXTRA_SESSION_ROOTS` env var (comma-separated). New tools: implement `SessionAdapter` in `src/sessions/adapters/`.
106+
88107
## Knowledge Base
89108

90-
- Entries are Markdown files with YAML frontmatter stored in `~/claude-memory/`
109+
- Entries are Markdown files with YAML frontmatter stored in `~/agent-knowledge/`
91110
- Categories: `projects`, `people`, `decisions`, `workflows`, `notes`
92111
- Search: hybrid semantic (embeddings) + TF-IDF with fuzzy fallback
93112
- Session search scopes: `errors`, `plans`, `configs`, `tools`, `files`, `decisions`, `all`

CONTRIBUTING.md

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
- **Git** (for knowledge base sync)
2525
- A knowledge base repo (or create one):
2626
```bash
27-
mkdir -p ~/claude-memory && cd ~/claude-memory && git init
27+
mkdir -p ~/agent-knowledge && cd ~/agent-knowledge && git init
2828
mkdir projects people decisions workflows notes
2929
```
3030

@@ -45,8 +45,8 @@ npm run test:watch
4545
### Environment
4646

4747
```bash
48-
export KNOWLEDGE_MEMORY_DIR=~/claude-memory
49-
export CLAUDE_DIR=~/.claude
48+
export KNOWLEDGE_MEMORY_DIR=~/agent-knowledge
49+
export KNOWLEDGE_DATA_DIR=~/.claude # primary session dir (other tools auto-detected)
5050
export KNOWLEDGE_PORT=3423
5151
```
5252

@@ -64,10 +64,16 @@ agent-knowledge/
6464
search.ts TF-IDF search over knowledge entries with regex fallback
6565
git.ts git pull/push/sync with timeouts
6666
sessions/
67-
parser.ts JSONL parsing with mtime-based cache
67+
parser.ts Multi-format session parsing with mtime-based cache
6868
search.ts TF-IDF ranked search with 60s global index cache
6969
scopes.ts 6 search scopes (errors, plans, configs, tools, files, decisions)
7070
summary.ts Session summaries, topic extraction, file path detection
71+
adapters/
72+
index.ts SessionAdapter interface, registry, auto-init
73+
opencode.ts OpenCode adapter (SQLite)
74+
cline.ts Cline adapter (JSON)
75+
continue.ts Continue.dev adapter (JSON)
76+
aider.ts Aider adapter (Markdown/JSONL)
7177
search/
7278
tfidf.ts TF-IDF scoring engine (tokenizer, stopwords, index)
7379
fuzzy.ts Levenshtein distance, sliding window fuzzy matching
@@ -112,6 +118,71 @@ Tests use **vitest** with `fs.mkdtempSync` for temp directories in filesystem te
112118
- TF-IDF: tokenization, stopwords, ranking correctness, edge cases
113119
- Fuzzy: Levenshtein distance, threshold filtering, sliding window
114120
- Sessions: JSONL parsing, malformed line handling, message extraction
121+
- Session adapters: `isAvailable()` detection, `parseSession()` output normalization, graceful handling of missing/corrupt data
122+
123+
## Adding a Session Adapter
124+
125+
agent-knowledge uses a pluggable adapter system to read sessions from different AI coding tools. To add support for a new tool:
126+
127+
### 1. Create the adapter file
128+
129+
Create `src/sessions/adapters/<tool>.ts` implementing the `SessionAdapter` interface:
130+
131+
```typescript
132+
import type { SessionEntry } from '../parser.js';
133+
import type { SessionAdapter } from './index.js';
134+
135+
export const myToolAdapter: SessionAdapter = {
136+
prefix: 'mytool', // Unique prefix for virtual descriptors
137+
name: 'My Tool', // Human-readable name
138+
139+
isAvailable(): boolean {
140+
// Return true if this tool is installed on the current machine.
141+
// Check for the existence of data files/directories.
142+
return existsSync('/path/to/mytool/data');
143+
},
144+
145+
discoverProjects(): Array<{ name: string; path: string }> {
146+
// Return a list of projects/groups found for this tool.
147+
// Use `mytool://` prefixed paths as virtual descriptors.
148+
return [{ name: 'mytool', path: 'mytool://all' }];
149+
},
150+
151+
listSessions(projectDescriptor: string): Array<{ id: string; file: string }> {
152+
// List individual sessions within a project.
153+
// Return virtual descriptors that parseSession() can handle.
154+
return [{ id: 'session-1', file: 'mytool://session:session-1' }];
155+
},
156+
157+
parseSession(descriptor: string): SessionEntry[] {
158+
// Parse a session into normalized SessionEntry[] objects.
159+
// Each entry needs at minimum: type ('user'|'assistant'), message.role, message.content
160+
return [{ type: 'user', message: { role: 'user', content: 'Hello' } }];
161+
},
162+
};
163+
```
164+
165+
### 2. Register the adapter
166+
167+
Add a dynamic import to `src/sessions/adapters/index.ts` in the `initAdapters()` function:
168+
169+
```typescript
170+
import('./mytool.js').then((m) => registerAdapter(m.myToolAdapter)).catch(() => {});
171+
```
172+
173+
### 3. Key guidelines
174+
175+
- **Auto-detection only**: `isAvailable()` should check for the tool's data files on disk. No user configuration required.
176+
- **Virtual descriptors**: Use `<prefix>://` URIs so the parser can dispatch to the correct adapter.
177+
- **Graceful failure**: All methods should catch errors and return empty arrays rather than throwing.
178+
- **Read-only access**: Never modify the source tool's data files. Use `{ readonly: true }` for database connections.
179+
- **Platform-aware paths**: Handle Windows, macOS, and Linux path differences (see `cline.ts` for an example).
180+
181+
### 4. Update documentation
182+
183+
- Add the tool to the "Supported Tools" table in `README.md`
184+
- Add the tool to the "Supported Session Sources" list in `CLAUDE.md`
185+
- Add a changelog entry in `CHANGELOG.md`
115186

116187
## Pull Requests
117188

README.md

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Tests: 280 passing](https://img.shields.io/badge/Tests-280%20passing-brightgreen.svg)]()
66
[![MCP Tools: 12](https://img.shields.io/badge/MCP%20Tools-12-blueviolet.svg)]()
77

8-
**Cross-session memory and recall for AI agents** -- git-synced knowledge base, hybrid semantic+TF-IDF search, auto-distillation with secrets scrubbing.
8+
**Cross-session memory and recall for AI coding assistants** -- works with Claude Code, Cursor, OpenCode, Cline, Continue.dev, and Aider out of the box. Git-synced knowledge base, hybrid semantic+TF-IDF search, auto-distillation with secrets scrubbing.
99

1010
<table>
1111
<tr>
@@ -20,23 +20,40 @@
2020

2121
## Why
2222

23-
Claude Code sessions are ephemeral. When a session ends, everything it learned -- architecture decisions, debugging insights, project context -- is gone. The next session starts from scratch.
23+
AI coding sessions are ephemeral. When a session ends, everything it learned -- architecture decisions, debugging insights, project context -- is gone. The next session starts from scratch.
2424

2525
**agent-knowledge** solves this with two complementary systems:
2626

2727
1. **Knowledge Base** -- a git-synced markdown vault of structured entries (decisions, workflows, project context) that persists across sessions and machines.
28-
2. **Session Search** -- TF-IDF ranked full-text search across JSONL session transcripts, so agents can recall what happened before.
28+
2. **Session Search** -- TF-IDF ranked full-text search across session transcripts from all your coding tools, so agents can recall what happened before -- regardless of which tool was used.
29+
30+
## Supported Tools
31+
32+
Sessions from all major AI coding assistants are auto-discovered -- if a tool is installed, its sessions appear automatically.
33+
34+
| Tool | Format | Auto-detected path |
35+
| ---------------- | -------------- | --------------------------------------------------------------- |
36+
| **Claude Code** | JSONL | `$KNOWLEDGE_DATA_DIR/projects/` (default `~/.claude/projects/`) |
37+
| **Cursor** | JSONL | `~/.cursor/projects/*/agent-transcripts/` |
38+
| **OpenCode** | SQLite | `~/.local/share/opencode/opencode.db` (or `$OPENCODE_DATA_DIR`) |
39+
| **Cline** | JSON | VS Code globalStorage `saoudrizwan.claude-dev/tasks/` |
40+
| **Continue.dev** | JSON | `~/.continue/sessions/` |
41+
| **Aider** | Markdown/JSONL | `.aider.chat.history.md` / `.aider.llm.history` in project dirs |
42+
43+
No configuration needed. Additional session roots can be added via the `EXTRA_SESSION_ROOTS` env var (comma-separated paths).
2944

3045
## Features
3146

47+
- **Multi-tool session search** -- unified search across Claude Code, Cursor, OpenCode, Cline, Continue.dev, and Aider sessions
3248
- **Hybrid search** -- semantic vector similarity blended with TF-IDF keyword ranking
3349
- **Git-synced knowledge base** -- markdown vault with YAML frontmatter, auto commit and push on writes
3450
- **Auto-distillation** -- session insights automatically extracted and pushed to git with secrets scrubbing
51+
- **Pluggable adapter system** -- add support for new tools by implementing the `SessionAdapter` interface
3552
- **Embeddings** -- local (Hugging Face), OpenAI, Claude/Voyage, or Gemini providers
3653
- **Fuzzy matching** -- typo-tolerant search using Levenshtein distance
3754
- **6 search scopes** -- errors, plans, configs, tools, files, decisions
3855
- **Configurable git URL** -- `knowledge_config` tool for runtime setup, persisted at XDG/AppData location
39-
- **Cross-machine persistence** -- knowledge syncs via git, sessions read from local JSONL
56+
- **Cross-machine persistence** -- knowledge syncs via git, sessions read from local storage of each tool
4057
- **Real-time dashboard** -- browse, search, and manage at `localhost:3423`
4158
- **Secrets scrubbing** -- API keys, tokens, passwords, private keys automatically redacted before git push
4259

@@ -48,24 +65,18 @@ cd agent-knowledge
4865
npm install && npm run build
4966
```
5067

51-
### Configure in Claude Code
68+
### Configure your MCP client
69+
70+
See [Setup Guide](docs/SETUP.md) for client-specific instructions (Claude Code, Cursor, Windsurf, OpenCode).
71+
72+
Example (Claude Code):
5273

5374
```bash
5475
claude mcp add agent-knowledge -s user \
55-
-e KNOWLEDGE_MEMORY_DIR="$HOME/claude-memory" \
76+
-e KNOWLEDGE_MEMORY_DIR="$HOME/agent-knowledge" \
5677
-- node /path/to/agent-knowledge/dist/index.js
5778
```
5879

59-
Or add to `settings.json` permissions:
60-
61-
```json
62-
{
63-
"permissions": {
64-
"allow": ["mcp__agent-knowledge__*"]
65-
}
66-
}
67-
```
68-
6980
Dashboard: **http://localhost:3423** (auto-starts with MCP server)
7081

7182
## MCP Tools
@@ -116,29 +127,44 @@ Dashboard: **http://localhost:3423** (auto-starts with MCP server)
116127
```mermaid
117128
graph LR
118129
subgraph Storage
119-
KB[(Knowledge Base<br/>~/claude-memory<br/>Git Repository)]
120-
SF[(Session Files<br/>~/.claude/projects<br/>JSONL Logs)]
130+
KB[(Knowledge Base<br/>~/agent-knowledge<br/>Git Repository)]
131+
end
132+
133+
subgraph Session Sources
134+
CC[(Claude Code<br/>JSONL)]
135+
CU[(Cursor<br/>JSONL)]
136+
OC[(OpenCode<br/>SQLite)]
137+
CL[(Cline<br/>JSON)]
138+
CD[(Continue.dev<br/>JSON)]
139+
AI[(Aider<br/>MD / JSONL)]
121140
end
122141
123142
subgraph agent-knowledge
124143
KM[Knowledge Module<br/>store / search / git]
144+
AD[Session Adapters<br/>auto-discovery]
125145
SE[Search Engine<br/>TF-IDF + Fuzzy]
126146
DS[Dashboard<br/>:3423]
127147
MCP[MCP Server<br/>stdio]
128148
end
129149
130150
subgraph Clients
131-
CC[Claude Code Sessions]
151+
AG[Agent Sessions]
132152
WB[Web Browser]
133153
end
134154
135155
KB <-->|git pull/push| KM
136-
SF -->|parse JSONL| SE
156+
CC --> AD
157+
CU --> AD
158+
OC --> AD
159+
CL --> AD
160+
CD --> AD
161+
AI --> AD
162+
AD --> SE
137163
KM --> MCP
138164
SE --> MCP
139165
KM --> DS
140166
SE --> DS
141-
MCP --> CC
167+
MCP --> AG
142168
DS --> WB
143169
```
144170

@@ -169,16 +195,19 @@ npm run lint # Type-check (tsc --noEmit)
169195

170196
## Environment Variables
171197

172-
| Variable | Default | Description |
173-
| ---------------------------------- | ----------------- | ----------------------------------------------------------------- |
174-
| `KNOWLEDGE_MEMORY_DIR` | `~/claude-memory` | Path to git-synced knowledge base |
175-
| `KNOWLEDGE_GIT_URL` | -- | Git remote URL (auto-clones if dir missing) |
176-
| `KNOWLEDGE_AUTO_DISTILL` | `true` | Auto-distill session insights to knowledge base |
177-
| `KNOWLEDGE_EMBEDDING_PROVIDER` | `local` | Embedding provider: `local`, `openai`, `claude`, `gemini` |
178-
| `KNOWLEDGE_EMBEDDING_ALPHA` | `0.3` | TF-IDF vs semantic blend weight (0=pure semantic, 1=pure TF-IDF) |
179-
| `KNOWLEDGE_EMBEDDING_IDLE_TIMEOUT` | `60` | Seconds before unloading local model from memory (0 = keep alive) |
180-
| `CLAUDE_DIR` | `~/.claude` | Directory containing session transcripts (JSONL files) |
181-
| `KNOWLEDGE_PORT` | `3423` | Dashboard HTTP port |
198+
| Variable | Default | Description |
199+
| --------------------------------------------------- | ------------------- | --------------------------------------------------------------------- |
200+
| `KNOWLEDGE_MEMORY_DIR` | `~/agent-knowledge` | Path to git-synced knowledge base |
201+
| `KNOWLEDGE_GIT_URL` | -- | Git remote URL (auto-clones if dir missing) |
202+
| `KNOWLEDGE_AUTO_DISTILL` | `true` | Auto-distill session insights to knowledge base |
203+
| `KNOWLEDGE_EMBEDDING_PROVIDER` | `local` | Embedding provider: `local`, `openai`, `claude`, `gemini` |
204+
| `KNOWLEDGE_EMBEDDING_ALPHA` | `0.3` | TF-IDF vs semantic blend weight (0=pure semantic, 1=pure TF-IDF) |
205+
| `KNOWLEDGE_EMBEDDING_IDLE_TIMEOUT` | `60` | Seconds before unloading local model from memory (0 = keep alive) |
206+
| `KNOWLEDGE_DATA_DIR` | `~/.claude` | Primary session data directory (Claude Code JSONL files) |
207+
| `EXTRA_SESSION_ROOTS` | -- | Additional session directories, comma-separated paths |
208+
| `OPENCODE_DATA_DIR` | (see below) | Override OpenCode data directory (default: `~/.local/share/opencode`) |
209+
| `KNOWLEDGE_ANTHROPIC_API_KEY` / `ANTHROPIC_API_KEY` | -- | API key for Claude/Voyage embeddings |
210+
| `KNOWLEDGE_PORT` | `3423` | Dashboard HTTP port |
182211

183212
## Documentation
184213

0 commit comments

Comments
 (0)