Skip to content

Commit 3726dac

Browse files
committed
Add Docker distribution, auto-reindex on model change, update all docs
- Dockerfile (node:24-alpine multi-stage) + GitHub Actions workflow for ghcr.io - Graph persistence now stores embedding model name; auto-reindex on model change - Comprehensive docs update: ARCHITECTURE.md, SPEC.md, CLAUDE.md, README.md (57 tools, 6 graphs, skills, prompts page, Docker quick start) - Help articles: add SkillGraph to graph-structure, cross-graph, knowledge/task tools - Remove orphaned files (PromptMascot, old roles/scenarios) - Fix repo URL in package.json
1 parent 5a46dd4 commit 3726dac

25 files changed

Lines changed: 663 additions & 289 deletions

.dockerignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
node_modules
2+
ui/node_modules
3+
dist
4+
ui/dist
5+
.graph-memory
6+
.cache
7+
models/
8+
data
9+
.env
10+
graph-memory.yaml
11+
demo-project/.graph-memory
12+
demo-project/.notes
13+
demo-project/.tasks
14+
demo-project/.skills
15+
.git
16+
*.md
17+
!README.md

.github/workflows/docker.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ['v*']
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
build-and-push:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Log in to Container Registry
23+
uses: docker/login-action@v3
24+
with:
25+
registry: ${{ env.REGISTRY }}
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Extract metadata
30+
id: meta
31+
uses: docker/metadata-action@v5
32+
with:
33+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
34+
tags: |
35+
type=raw,value=latest,enable={{is_default_branch}}
36+
type=sha,prefix=
37+
type=semver,pattern={{version}}
38+
type=semver,pattern={{major}}.{{minor}}
39+
40+
- name: Build and push
41+
uses: docker/build-push-action@v6
42+
with:
43+
context: .
44+
push: true
45+
tags: ${{ steps.meta.outputs.tags }}
46+
labels: ${{ steps.meta.outputs.labels }}

ARCHITECTURE.md

Lines changed: 99 additions & 37 deletions
Large diffs are not rendered by default.

CLAUDE.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ src/
156156
ui/ # React web UI (Feature-Sliced Design)
157157
src/
158158
app/ # App.tsx (routes), theme.ts, styles.css
159-
pages/ # dashboard, knowledge, tasks, skills, docs, files, search, graph, tools, help
159+
pages/ # dashboard, knowledge, tasks, skills, docs, files, prompts, search, graph, tools, help
160160
widgets/ # layout (sidebar + project selector + theme toggle)
161161
features/ # note-crud, task-crud, skill-crud
162162
entities/ # project, note, task, skill, file, doc, code, graph
163163
shared/ # api/client.ts, lib/useWebSocket.ts, lib/ThemeModeContext.tsx
164-
content/ # help articles (markdown) bundled into the UI
164+
content/ # help articles + prompt templates (markdown) bundled into the UI
165165
demo-project/ # Demo "TaskFlow" project for testing and demonstration
166166
src/ # 18 TypeScript files (models, services, controllers, middleware, utils)
167167
docs/ # 11 markdown docs (architecture, API, guides, changelog)
@@ -251,8 +251,11 @@ demo-project/ # Demo "TaskFlow" project for testing and demonstration
251251
and by the indexer when files are removed (`cleanupProxies`)
252252
- **Cross-graph tools**: `cross_references` is the only tool that requires both `docGraph` and
253253
`codeGraph`; registered only when both are available; bridges definitions (code) ↔ examples (docs)
254-
- **Graph persistence**: graphology `export()`/`import()` serialized as JSON;
255-
filenames: `docs.json`, `code.json`, `knowledge.json`, `file-index.json`, `tasks.json`, and `skills.json` in `graphMemory` directory
254+
- **Graph persistence**: graphology `export()`/`import()` serialized as JSON with embedding
255+
model metadata; filenames: `docs.json`, `code.json`, `knowledge.json`, `file-index.json`,
256+
`tasks.json`, and `skills.json` in `graphMemory` directory. Each JSON file wraps the
257+
graphology export with `{ embeddingModel: "...", graph: {...} }`. On load, if the configured
258+
model differs from the stored model, the graph is automatically discarded and re-indexed
256259
- **File mirror (write)**: `KnowledgeGraphManager`, `TaskGraphManager`, and `SkillGraphManager` write markdown files to
257260
`{projectDir}/.notes/{id}/note.md`, `{projectDir}/.tasks/{id}/task.md`, and `{projectDir}/.skills/{id}/skill.md` on every mutation.
258261
Files use YAML frontmatter (id, tags, timestamps, relations) + markdown body (`# Title\n\nContent`).
@@ -301,8 +304,8 @@ demo-project/ # Demo "TaskFlow" project for testing and demonstration
301304
Each project has its own 6 graphs, embedFns, indexer, watcher, and mutation queue.
302305
YAML config hot-reload (add/remove/change projects without restart). Auto-save every 30s.
303306
`PromiseQueue` serializes mutation tool handlers per project to prevent race conditions
304-
- **REST API**: Express app on the same HTTP server (`/api/*`). CRUD endpoints for knowledge
305-
and tasks, search endpoints for docs/code/files, graph export for visualization, tools
307+
- **REST API**: Express app on the same HTTP server (`/api/*`). CRUD endpoints for knowledge,
308+
tasks, and skills; search endpoints for docs/code/files; graph export for visualization; tools
306309
explorer (list/get/call MCP tools via HTTP). Zod validation on all request bodies and
307310
query params. Response format: `{ results: [...] }` for lists, direct object for singles,
308311
204 for DELETEs
@@ -316,14 +319,21 @@ demo-project/ # Demo "TaskFlow" project for testing and demonstration
316319
with configurable column visibility, drag-drop with drop-zone highlights, inline creation,
317320
filter bar, due date/estimate badges, quick actions on hover, scrollable columns),
318321
Skills (skill/recipe management with triggers and usage tracking),
319-
Docs (browse indexed documentation), Files (browser), Search (cross-graph),
322+
Docs (browse indexed documentation), Files (browser),
323+
Prompts (AI prompt generator with scenarios, roles, styles, live preview, export as skill),
324+
Search (cross-graph),
320325
Graph (cytoscape.js visualization), Tools (MCP tools explorer with live execution),
321326
Help (built-in searchable documentation). Light/dark theme toggle. Built output served as
322327
static files from HTTP server with SPA fallback. Dev server: Vite on :5173, proxies `/api` to :3000
323328
- **`--reindex` flag**: all three CLI commands (`index`, `mcp`, `serve`) support `--reindex`
324329
to discard persisted graphs and re-create them from scratch. When set, `load*()` functions
325330
return fresh empty graphs (skip disk read), and the indexer re-indexes all files since
326331
no mtime data exists in the fresh graphs
332+
- **Docker**: multi-stage Dockerfile (node:24-alpine). Build stage: `npm run build` (server + UI).
333+
Runtime stage: production deps + dist/ + ui/dist/. Entry: `node dist/cli/index.js serve`.
334+
Three volume mounts: `/data/config/graph-memory.yaml` (config), `/data/projects/` (project dirs),
335+
`/data/models/` (embedding model cache). GitHub Actions workflow builds and pushes to
336+
`ghcr.io/prih/mcp-graph-memory` on push to `main` or version tags
327337

328338
## Configuration
329339

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM node:24-alpine AS build
2+
3+
WORKDIR /app
4+
5+
# Install dependencies (server)
6+
COPY package.json package-lock.json ./
7+
RUN npm ci
8+
9+
# Install dependencies (UI)
10+
COPY ui/package.json ui/package-lock.json ./ui/
11+
RUN cd ui && npm ci
12+
13+
# Copy source
14+
COPY tsconfig.json tsconfig.build.json ./
15+
COPY src/ ./src/
16+
COPY ui/ ./ui/
17+
18+
# Build server + UI
19+
RUN npm run build
20+
21+
# --- Runtime ---
22+
FROM node:24-alpine
23+
24+
WORKDIR /app
25+
26+
COPY package.json package-lock.json ./
27+
RUN npm ci --omit=dev
28+
29+
COPY --from=build /app/dist ./dist
30+
COPY --from=build /app/ui/dist ./ui/dist
31+
32+
ENV NODE_ENV=production
33+
34+
EXPOSE 3000
35+
36+
ENTRYPOINT ["node", "dist/cli/index.js"]
37+
CMD ["serve", "--config", "/data/config/graph-memory.yaml"]

README.md

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,88 @@ An MCP server that builds a **semantic graph memory** from a project directory.
44
It indexes markdown documentation and TypeScript/JavaScript source code into graph structures,
55
then exposes them as MCP tools that any AI assistant can use to navigate and search the project.
66

7+
## Quick start with Docker
8+
9+
### 1. Create a config file
10+
11+
Create `graph-memory.yaml` — paths must be relative to the container filesystem:
12+
13+
```yaml
14+
server:
15+
host: "0.0.0.0"
16+
port: 3000
17+
modelsDir: "/data/models"
18+
19+
projects:
20+
my-app:
21+
projectDir: "/data/projects/my-app"
22+
docsPattern: "docs/**/*.md"
23+
codePattern: "src/**/*.{ts,tsx}"
24+
excludePattern: "node_modules/**,dist/**"
25+
```
26+
27+
### 2. Run with Docker
28+
29+
```bash
30+
docker run -d \
31+
--name graph-memory \
32+
-p 3000:3000 \
33+
-v $(pwd)/graph-memory.yaml:/data/config/graph-memory.yaml:ro \
34+
-v /path/to/my-app:/data/projects/my-app:ro \
35+
-v graph-memory-models:/data/models \
36+
ghcr.io/prih/mcp-graph-memory
37+
```
38+
39+
Three mounts:
40+
| Mount | Container path | Description |
41+
|-------|---------------|-------------|
42+
| **Config** | `/data/config/graph-memory.yaml` | Your config file (read-only) |
43+
| **Projects** | `/data/projects/` | Project directories to index (read-only, unless you use knowledge/tasks/skills — then remove `:ro`) |
44+
| **Models** | `/data/models/` | Embedding model cache — use a named volume so models persist across container restarts |
45+
46+
The embedding model (`Xenova/all-MiniLM-L6-v2`, ~90MB) is downloaded on first startup. Subsequent starts use the cached model from the volume.
47+
48+
### 3. Run with Docker Compose
49+
50+
```yaml
51+
# docker-compose.yaml
52+
services:
53+
graph-memory:
54+
image: ghcr.io/prih/mcp-graph-memory
55+
ports:
56+
- "3000:3000"
57+
volumes:
58+
- ./graph-memory.yaml:/data/config/graph-memory.yaml:ro
59+
- /path/to/my-app:/data/projects/my-app
60+
- models:/data/models
61+
restart: unless-stopped
62+
63+
volumes:
64+
models:
65+
```
66+
67+
```bash
68+
docker compose up -d
69+
```
70+
71+
### 4. Connect
72+
73+
- **Web UI**: `http://localhost:3000`
74+
- **MCP (Streamable HTTP)**: `http://localhost:3000/mcp/my-app`
75+
- **REST API**: `http://localhost:3000/api/projects`
76+
77+
To force re-index all projects from scratch:
78+
79+
```bash
80+
docker run --rm \
81+
-v $(pwd)/graph-memory.yaml:/data/config/graph-memory.yaml:ro \
82+
-v /path/to/my-app:/data/projects/my-app \
83+
-v graph-memory-models:/data/models \
84+
ghcr.io/prih/mcp-graph-memory serve --config /data/config/graph-memory.yaml --reindex
85+
```
86+
87+
> **Multiple projects**: mount each project directory separately and add entries to `graph-memory.yaml`. The config file is watched for changes — add or remove projects without restarting the container.
88+
789
## What it does
890

991
- Parses **markdown files** into heading-based chunks, links related files via graph edges
@@ -117,7 +199,7 @@ then exposes them as MCP tools that any AI assistant can use to navigate and sea
117199
| `recall_skills` | Recall relevant skills for a task context (lower minScore for higher recall) |
118200
| `bump_skill_usage` | Increment skill usage counter + set lastUsedAt |
119201

120-
## Installation
202+
## Installation (from source)
121203

122204
```bash
123205
npm install
@@ -281,12 +363,13 @@ Pass these IDs to `get_node`, `get_symbol`, or `get_note` to fetch full content.
281363

282364
The `serve` command starts a web UI at `http://localhost:3000` with:
283365

284-
- **Dashboard** — project stats (notes, tasks, docs, code, files) + recent activity
366+
- **Dashboard** — project stats (notes, tasks, skills, docs, code, files) + recent activity
285367
- **Knowledge** — notes CRUD, semantic search, relations, cross-graph links
286368
- **Tasks** — kanban board with configurable columns, drag-drop with drop-zone highlights, inline task creation, filter bar (search/priority/tags), due date and estimate badges, quick actions on hover, scrollable columns
369+
- **Skills** — skill/recipe management with triggers, steps, and usage tracking
287370
- **Docs** — browse and search indexed markdown documentation
288371
- **Files** — file browser with directory navigation, metadata, search
289-
- **Skills** — skill/recipe management with triggers, steps, and usage tracking
372+
- **Prompts** — AI prompt generator with scenario presets, role/style/graph selection, live preview, copy & export as skill
290373
- **Search** — unified semantic search across all 6 graphs
291374
- **Graph** — interactive force-directed graph visualization (Cytoscape.js)
292375
- **Tools** — MCP tools explorer with live execution from the browser

0 commit comments

Comments
 (0)