Skip to content

Commit 95dd4a2

Browse files
committed
v1.0.0: initial release
MCP server that gives AI agents persistent memory across sessions. Git-synced knowledge base with semantic search over session history. Auto-distills session insights and scrubs secrets before pushing to git.
0 parents  commit 95dd4a2

68 files changed

Lines changed: 17631 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ['v*']
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
check:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 10
14+
strategy:
15+
matrix:
16+
node-version: [20, 22]
17+
steps:
18+
- uses: actions/checkout@v4
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: ${{ matrix.node-version }}
22+
cache: npm
23+
- run: npm ci
24+
- run: npm run build
25+
- run: npm run typecheck
26+
- run: npm run lint
27+
- run: npm run format:check
28+
- run: npm test
29+
30+
publish:
31+
needs: check
32+
if: startsWith(github.ref, 'refs/tags/v')
33+
runs-on: ubuntu-latest
34+
timeout-minutes: 10
35+
permissions:
36+
contents: read
37+
id-token: write
38+
steps:
39+
- uses: actions/checkout@v4
40+
- uses: actions/setup-node@v4
41+
with:
42+
node-version: 22
43+
registry-url: https://registry.npmjs.org
44+
cache: npm
45+
- run: npm ci
46+
- run: npm run build
47+
- run: npm publish --provenance --access public
48+
env:
49+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
node_modules/
2+
dist/
3+
*.db
4+
*.db-wal
5+
*.db-shm
6+
.env
7+
.env.local
8+
coverage/
9+
*.tgz
10+
*.tsbuildinfo
11+
.DS_Store
12+
Thumbs.db
13+
.worktrees/
14+
.claude/worktrees/

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npx lint-staged

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.npmjs.org/

CHANGELOG.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Changelog
2+
3+
## 1.0.0 (2026-03-26)
4+
5+
Initial release.
6+
7+
### MCP Tools (12)
8+
9+
**Knowledge (5):** `knowledge_list`, `knowledge_read`, `knowledge_write`, `knowledge_delete`, `knowledge_sync`
10+
11+
**Sessions (5):** `knowledge_sessions`, `knowledge_search`, `knowledge_get`, `knowledge_summary`, `knowledge_recall`
12+
13+
**Admin (2):** `knowledge_index_status`, `knowledge_config`
14+
15+
### Search Engine
16+
17+
- Hybrid semantic + TF-IDF search with configurable alpha blending
18+
- Recency decay weighting (newer sessions rank higher)
19+
- Fuzzy matching via Levenshtein distance
20+
- 6 recall scopes: errors, plans, configs, tools, files, decisions
21+
- Role-based filtering (all, user, assistant)
22+
- Regex mode for pattern-based searches
23+
24+
### Embeddings & Vector Store
25+
26+
- SQLite vector store with sqlite-vec for cosine similarity
27+
- 4 embedding providers: local (Hugging Face), OpenAI, Claude/Voyage, Gemini
28+
- Background indexer runs on server startup
29+
- Automatic provider switching with dimension migration
30+
31+
### Knowledge Base
32+
33+
- Git-synced markdown vault at `~/claude-memory/`
34+
- 5 categories: projects, people, decisions, workflows, notes
35+
- YAML frontmatter for metadata (title, tags, updated)
36+
- Auto git commit + push on writes, pull on reads
37+
- Configurable git URL via `knowledge_config` tool or `KNOWLEDGE_GIT_URL` env var
38+
- New repos auto-scaffolded with README, .gitignore, and category dirs
39+
40+
### Auto-Distillation
41+
42+
- Automatic extraction of session insights into knowledge base
43+
- Project name normalization (worktrees, swarms merged into parent)
44+
- Secrets scrubbing: API keys, tokens, passwords, JWTs, private keys redacted
45+
- System noise stripped (XML tags, task notifications)
46+
- Absolute paths normalized to `~/`
47+
- Defense-in-depth audit blocks writes with surviving sensitive content
48+
49+
### Persistent Configuration
50+
51+
- `knowledge_config` tool for runtime setup (no restart needed)
52+
- Config stored at XDG/AppData location (tool-agnostic)
53+
- Priority: env vars > persisted config > defaults
54+
55+
### Web Dashboard
56+
57+
- http://localhost:3423, auto-starts with MCP server
58+
- 5 tabs: Knowledge, Search, Sessions, Recall, Embeddings
59+
- MD3 design language matching agent-comm and agent-tasks
60+
- Light/dark theme with localStorage persistence
61+
- Side panel (560px, resizable) with markdown rendering
62+
- Live reload via file watcher + WebSocket
63+
- Semantic search toggle with score breakdown
64+
65+
### Performance
66+
67+
- Session file mtime cache (re-parses only changed files)
68+
- Global TF-IDF index cache with 60s TTL
69+
- Background embedding indexer (non-blocking)
70+
71+
### Infrastructure
72+
73+
- REST API: 10 endpoints (knowledge, sessions, search, recall, index-status, health)
74+
- WebSocket server for real-time dashboard updates
75+
- 280 tests passing (vitest)
76+
- TypeScript strict mode, ES modules
77+
- GitHub Actions CI (Node 20/22 matrix, npm publish on tags)

CONTRIBUTING.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Contributing to agent-knowledge
2+
3+
## Getting Started
4+
5+
1. Clone the repository:
6+
```bash
7+
git clone https://github.com/keshrath/agent-knowledge.git
8+
cd agent-knowledge
9+
```
10+
2. Install dependencies:
11+
```bash
12+
npm install
13+
```
14+
3. Build:
15+
```bash
16+
npm run build
17+
```
18+
19+
## Development Setup
20+
21+
### Prerequisites
22+
23+
- **Node.js >= 20** (LTS recommended)
24+
- **Git** (for knowledge base sync)
25+
- A knowledge base repo (or create one):
26+
```bash
27+
mkdir -p ~/claude-memory && cd ~/claude-memory && git init
28+
mkdir projects people decisions workflows notes
29+
```
30+
31+
### Development Mode
32+
33+
```bash
34+
# Watch mode — recompiles on changes
35+
npm run dev
36+
37+
# Start dashboard standalone (port 3423)
38+
KNOWLEDGE_PORT=3423 node dist/dashboard.js
39+
40+
# Run tests
41+
npm test
42+
npm run test:watch
43+
```
44+
45+
### Environment
46+
47+
```bash
48+
export KNOWLEDGE_MEMORY_DIR=~/claude-memory
49+
export CLAUDE_DIR=~/.claude
50+
export KNOWLEDGE_PORT=3423
51+
```
52+
53+
## Project Structure
54+
55+
```
56+
agent-knowledge/
57+
src/
58+
index.ts Entry point (MCP stdio + dashboard auto-start)
59+
server.ts MCP server, 10 tool definitions, request routing
60+
dashboard.ts HTTP + WebSocket server, REST API, file watcher
61+
types.ts KnowledgeConfig, getConfig()
62+
knowledge/
63+
store.ts Markdown CRUD, frontmatter parsing, path traversal protection
64+
search.ts TF-IDF search over knowledge entries with regex fallback
65+
git.ts git pull/push/sync with timeouts
66+
sessions/
67+
parser.ts JSONL parsing with mtime-based cache
68+
search.ts TF-IDF ranked search with 60s global index cache
69+
scopes.ts 6 search scopes (errors, plans, configs, tools, files, decisions)
70+
summary.ts Session summaries, topic extraction, file path detection
71+
search/
72+
tfidf.ts TF-IDF scoring engine (tokenizer, stopwords, index)
73+
fuzzy.ts Levenshtein distance, sliding window fuzzy matching
74+
types.ts SearchResult, SearchOptions interfaces
75+
ui/
76+
index.html Dashboard SPA
77+
styles.css MD3 design tokens (light + dark)
78+
app.js Client-side vanilla JS (WebSocket, tabs, rendering)
79+
tests/
80+
tfidf.test.ts TF-IDF engine tests (8)
81+
fuzzy.test.ts Fuzzy matching tests (7)
82+
docs/
83+
SETUP.md Installation and configuration guide
84+
ARCHITECTURE.md Technical architecture documentation
85+
DASHBOARD.md Dashboard features and usage
86+
assets/ Screenshots
87+
```
88+
89+
## Code Style
90+
91+
- **TypeScript** with strict mode, ES modules
92+
- **Imports**: use `.js` extensions (TypeScript NodeNext convention)
93+
- **Naming**: `camelCase` for functions/variables, `PascalCase` for types/classes, `UPPER_SNAKE` for constants
94+
- **Async**: use `async`/`await` over raw promises
95+
- **Error handling**: throw descriptive errors, catch and return MCP-formatted errors in tool handlers
96+
- **No external formatters** -- match existing code style
97+
98+
## Testing
99+
100+
```bash
101+
npm test # Run all tests
102+
npm run test:watch # Watch mode
103+
npx vitest run tests/tfidf.test.ts # Single file
104+
npm run lint # Type-check (tsc --noEmit)
105+
```
106+
107+
Tests use **vitest** with `fs.mkdtempSync` for temp directories in filesystem tests.
108+
109+
### What to Test
110+
111+
- Knowledge store: CRUD, frontmatter parsing, category validation, path traversal
112+
- TF-IDF: tokenization, stopwords, ranking correctness, edge cases
113+
- Fuzzy: Levenshtein distance, threshold filtering, sliding window
114+
- Sessions: JSONL parsing, malformed line handling, message extraction
115+
116+
## Pull Requests
117+
118+
1. All tests must pass
119+
2. Type-check must be clean (`npm run typecheck`)
120+
3. Lint and format checks must pass (`npm run check`)
121+
4. Update docs if changing tool behavior or adding features
122+
5. Keep commits focused -- one logical change per commit
123+
124+
## License
125+
126+
MIT

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 keshrath
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.

0 commit comments

Comments
 (0)