synabun 2026.3.310 → 2026.3.312
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/hooks/claude-code/post-plan.mjs +2 -1
- package/hooks/claude-code/post-remember.mjs +1 -2
- package/hooks/claude-code/pre-compact.mjs +7 -4
- package/hooks/claude-code/pre-websearch.mjs +4 -2
- package/hooks/claude-code/prompt-submit.mjs +1 -2
- package/hooks/claude-code/session-start.mjs +5 -5
- package/hooks/claude-code/shared.mjs +5 -3
- package/hooks/claude-code/stop.mjs +1 -2
- package/hooks/claude-code/test-user-learning.mjs +3 -1
- package/lib/paths.js +74 -0
- package/mcp-server/dist/tools/loop.js +3 -3
- package/mcp-server/dist/tools/loop.js.map +1 -1
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/tools/loop.ts +3 -3
- package/neural-interface/lib/db.js +1 -1
- package/neural-interface/public/shared/styles.css +1 -1
- package/neural-interface/public/variant/3d/graph.js +1 -0
- package/neural-interface/server.js +122 -99
- package/package.json +2 -2
- package/postinstall.js +9 -19
- package/setup.js +315 -337
- package/CLAUDE.md +0 -150
package/CLAUDE.md
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
# CLAUDE.md
|
|
2
|
-
|
|
3
|
-
====================================END SYNBUN
|
|
4
|
-
|
|
5
|
-
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
6
|
-
|
|
7
|
-
## What is SynaBun
|
|
8
|
-
|
|
9
|
-
Persistent vector memory for AI assistants — SQLite + local Transformers.js embeddings (all-MiniLM-L6-v2, 384 dims). No external services, no API keys, no Docker. Installed via `npm install -g synabun` or cloned from GitHub.
|
|
10
|
-
|
|
11
|
-
## Commands
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
# Start everything (installs deps, builds MCP, launches Neural Interface)
|
|
15
|
-
npm start # runs setup.js
|
|
16
|
-
|
|
17
|
-
# Neural Interface only (Express server on :3344)
|
|
18
|
-
node neural-interface/server.js
|
|
19
|
-
|
|
20
|
-
# Build MCP server (required after any TypeScript change)
|
|
21
|
-
cd mcp-server && npm run build # ALWAYS use npm run build, never npx tsc
|
|
22
|
-
|
|
23
|
-
# Dev mode (auto-rebuild on change)
|
|
24
|
-
cd mcp-server && npm run dev # tsx src/index.ts
|
|
25
|
-
|
|
26
|
-
# Tests
|
|
27
|
-
cd mcp-server && npm test # vitest run
|
|
28
|
-
cd mcp-server && npm run test:watch # vitest watch mode
|
|
29
|
-
|
|
30
|
-
# Register MCP with Claude Code
|
|
31
|
-
claude mcp add SynaBun -s user -- node "/path/to/Synabun/mcp-server/run.mjs"
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
## Architecture
|
|
35
|
-
|
|
36
|
-
Two independently running processes that share one SQLite database:
|
|
37
|
-
|
|
38
|
-
### MCP Server (`mcp-server/`)
|
|
39
|
-
TypeScript, compiles to `dist/`. Entry point: `run.mjs` → `dist/preload.js` → `dist/index.js`. Communicates with AI tools via MCP protocol (stdio or HTTP). 72 tools across 9 groups: Memory (8), Browser (39), Whiteboard (5), Cards (5), Discord (8), Leonardo (4), Git (1), Loop (1), TicTacToe (1).
|
|
40
|
-
|
|
41
|
-
- `src/index.ts` — tool registration, schema refresh, server creation
|
|
42
|
-
- `src/config.ts` — env config, project detection from `claude-code-projects.json`
|
|
43
|
-
- `src/types.ts` — `MemoryPayload` interface
|
|
44
|
-
- `src/http.ts` — HTTP MCP transport (stateless, fresh server per request)
|
|
45
|
-
- `src/services/sqlite.ts` — storage layer, vectors as Float32Array BLOBs, cosine similarity in JS
|
|
46
|
-
- `src/services/local-embeddings.ts` — Transformers.js embedding generation
|
|
47
|
-
- `src/services/categories.ts` — category CRUD, hierarchy, dynamic schema refresh
|
|
48
|
-
- `src/tools/` — one file per tool (or per tool group with a registration function)
|
|
49
|
-
|
|
50
|
-
### Neural Interface (`neural-interface/`)
|
|
51
|
-
Express server (`server.js`, ~15K lines) serving a vanilla JS + Three.js frontend. 55+ REST API endpoints. Runs on port 3344.
|
|
52
|
-
|
|
53
|
-
- `server.js` — monolithic Express server with all API routes, WebSocket, terminal (node-pty), Playwright browser management, session registry, loop orchestration
|
|
54
|
-
- `public/index.html` — 3D force-directed graph (Three.js)
|
|
55
|
-
- `public/index2d.html` — 2D canvas variant
|
|
56
|
-
- `public/onboarding.html` — first-time setup wizard
|
|
57
|
-
- `public/claude-chat.html` — standalone Claude Code chat page
|
|
58
|
-
- `public/shared/` — modular JS/CSS (~50 files): `ui-*.js` modules, `storage.js` (server-synced state), `styles.css`, `utils.js`
|
|
59
|
-
- `lib/db.js` — shared SQLite access (same DB as MCP server)
|
|
60
|
-
- `lib/session-indexer.js` — conversation session indexing
|
|
61
|
-
- `skins/` — theme system (CSS + JSON per skin)
|
|
62
|
-
- `i18n/` — internationalization (en.json)
|
|
63
|
-
- `templates/CLAUDE-template.md` — source of truth for memory rulesets injected into project CLAUDE.md files
|
|
64
|
-
|
|
65
|
-
### Hooks (`hooks/claude-code/`)
|
|
66
|
-
7 ESM (.mjs) lifecycle hooks for Claude Code, registered in `.claude/settings.json`:
|
|
67
|
-
|
|
68
|
-
| Hook | Event | Purpose |
|
|
69
|
-
|------|-------|---------|
|
|
70
|
-
| `session-start.mjs` | SessionStart | Greeting, boot sequence, compaction recovery, loop detection |
|
|
71
|
-
| `prompt-submit.mjs` | UserPromptSubmit | Tiered recall nudges, loop iteration injection |
|
|
72
|
-
| `pre-compact.mjs` | PreCompact | Transcript capture before context compaction |
|
|
73
|
-
| `stop.mjs` | Stop | Combined obligations: compaction, loops, task memory, user learning |
|
|
74
|
-
| `post-remember.mjs` | PostToolUse | Edit tracking, flag clearing, user learning |
|
|
75
|
-
| `pre-websearch.mjs` | PreToolUse | Blocks WebSearch/WebFetch during active browser sessions |
|
|
76
|
-
| `post-plan.mjs` | PostToolUse | Auto-stores plans as memories on ExitPlanMode |
|
|
77
|
-
|
|
78
|
-
`shared.mjs` contains utilities used across hooks.
|
|
79
|
-
|
|
80
|
-
### Skills (`skills/`)
|
|
81
|
-
Claude Code slash commands with `SKILL.md` entry points and `modules/` subdirectories:
|
|
82
|
-
- `synabun/` — `/synabun` command hub (brainstorm, audit, health, search)
|
|
83
|
-
- `leonardo/` — `/leonardo` master media prompter (video, image, model advisor, prompt library)
|
|
84
|
-
|
|
85
|
-
### Data Flow
|
|
86
|
-
```
|
|
87
|
-
AI tool calls remember → MCP server embeds content → SQLite stores vector + payload
|
|
88
|
-
AI tool calls recall → MCP server embeds query → cosine similarity search → re-ranked results
|
|
89
|
-
Neural Interface → reads same SQLite DB → renders 3D graph, REST API, WebSocket
|
|
90
|
-
Hooks → fire on Claude Code events → inject context, enforce memory obligations
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Shared State
|
|
94
|
-
- `data/memory.db` — single SQLite database (memories, session chunks, trash)
|
|
95
|
-
- `data/ui-state.json` — Neural Interface UI state (synced via `storage.js`)
|
|
96
|
-
- `data/pending-compact/` — per-session compaction flags
|
|
97
|
-
- `data/pending-remember/` — per-session edit tracking flags
|
|
98
|
-
- `mcp-server/data/custom-categories-{connId}.json` — per-connection category definitions
|
|
99
|
-
|
|
100
|
-
## Key Patterns
|
|
101
|
-
|
|
102
|
-
- **Category descriptions are routing instructions**: Claude reads all category descriptions from the MCP tool schema to decide where to store memories. Descriptions must be prescriptive rules, not vague labels.
|
|
103
|
-
- **Dynamic schema refresh**: Category changes trigger `refreshCategorySchemas()` → `notifications/tools/list_changed` → Claude re-fetches tool list. No restart needed.
|
|
104
|
-
- **Per-tab session isolation**: Project/model/effort state stored per-tab in sidepanel (`ui-claude-panel.js`) and per-tab via `sessionStorage` in standalone (`claude-chat.js`). Global `ui-state.json` keys are "last used" defaults only.
|
|
105
|
-
- **Browser sessions**: Playwright with persistent Chromium profiles. Multi-session isolation via dedicated browser session per automation. Leonardo tools are 100% browser-based (no API key).
|
|
106
|
-
- **Compaction chain**: PreCompact → flag → SessionStart injects → Claude remembers(conversations) → PostToolUse clears → Stop allows.
|
|
107
|
-
- **MCP calls must be sequential**: Parallel MCP tool calls can cascade failures. Always call memory tools one at a time.
|
|
108
|
-
|
|
109
|
-
## Environment
|
|
110
|
-
|
|
111
|
-
- Node.js 22.5+ required (for built-in `node:sqlite`)
|
|
112
|
-
- `.env` at project root — `SQLITE_DB_PATH`, `NEURAL_PORT` (default 3344), `DISCORD_BOT_TOKEN`, `DISCORD_GUILD_ID`
|
|
113
|
-
- CLAUDE.md is gitignored (user-local)
|
|
114
|
-
|
|
115
|
-
## Persistent Memory
|
|
116
|
-
|
|
117
|
-
You have persistent vector memory via the `SynaBun` MCP server (72 tools).
|
|
118
|
-
Core memory tools: remember, recall, forget, restore, reflect, memories, sync, category.
|
|
119
|
-
|
|
120
|
-
### Auto-Recall
|
|
121
|
-
- Session start: recall current project context
|
|
122
|
-
- Topic mentioned: recall what you know
|
|
123
|
-
- Before architecture decisions: recall past decisions
|
|
124
|
-
- Debugging: recall similar bugs
|
|
125
|
-
|
|
126
|
-
### Auto-Remember (MANDATORY)
|
|
127
|
-
After ANY task (bug fix, feature, refactor, config change, investigation, architecture decision), MUST `remember` BEFORE responding.
|
|
128
|
-
|
|
129
|
-
Steps:
|
|
130
|
-
1. `remember` — what + why + how, appropriate category, set project, related_files, importance (5=routine, 6-7=significant, 8+=critical), and 3-5 tags
|
|
131
|
-
|
|
132
|
-
`remember` returns the full UUID and accepts all fields (tags, importance) directly. No need to recall+reflect afterward.
|
|
133
|
-
|
|
134
|
-
**NOT triggered by:** Simple Q&A, file reads with no findings, trivial typos.
|
|
135
|
-
|
|
136
|
-
**Importance scale:** 1-2=trivial, 3-4=low, 5=normal, 6-7=significant, 8-9=critical, 10=foundational. User says "remember this" → 8+. Architecture decisions → 8+.
|
|
137
|
-
|
|
138
|
-
### Response Ordering
|
|
139
|
-
When finishing a task: call `remember` (and any other memory tools) **FIRST**, then write your completion summary **LAST**. Never summary-then-tools — the stop hook will block you.
|
|
140
|
-
|
|
141
|
-
### Tool Quirks
|
|
142
|
-
- `remember` returns the full UUID and accepts tags + importance directly.
|
|
143
|
-
- `reflect` requires FULL UUID — use the one from `remember`, or `recall` to find existing memories.
|
|
144
|
-
- Sequential MCP calls only — never parallel.
|
|
145
|
-
|
|
146
|
-
### Plan Mode
|
|
147
|
-
When in plan mode and you need clarification:
|
|
148
|
-
- ALWAYS use `AskUserQuestion` to present options — never plain text questions
|
|
149
|
-
- Use `ExitPlanMode` for final plan approval
|
|
150
|
-
- Use `multiSelect: true` in AskUserQuestion when options aren't mutually exclusive
|