Skip to content

Repository files navigation

Wiki — the map of any codebase

Drop in a GitHub URL, get a navigable wiki you can talk to. Local-first (zero cloud touch by default), or route to Anthropic + OpenAI for higher-quality output on hard repos.

Stack: Next.js 16 (App Router) · TypeScript strict · better-sqlite3 · tree-sitter · LM Studio / Ollama (local) or Anthropic + OpenAI (cloud)

npm install
npm run dev            # dev server on :3000
npm run ingest -- sindresorhus/yocto-queue   # index a repo
npm test               # vitest
npm run typecheck      # tsc --noEmit

Modes

WIKI_MODE Generation Embeddings
local (default) On-device model (LM Studio/Ollama) On-device nomic-embed (768d)
cloud Anthropic (ANTHROPIC_API_KEY) OpenAI if key present, else local (1536d vs 768d)

Switching embedder requires a full re-ingest (dimension mismatch is caught at query time with a clear error).

Deploy as a Castle template

Wiki ships as a Castle template: each tenant gets their own isolated Vercel project and SQLite database (data/atlas.db). No shared infrastructure between tenants.

Tenant env contract

Set these on the Vercel project for each tenant deployment:

# Branding
WIKI_TENANT_SLUG=acme              # DNS-safe slug; activates tenant mode
WIKI_TENANT_DISPLAY_NAME=Acme Docs # shown in header + <title>
WIKI_TENANT_PUBLIC_URL=https://acme.wiki.42nights.dev
WIKI_LOGO_URL=https://cdn.acme.com/logo.svg   # browser favicon
WIKI_PRIMARY_COLOR=#0f62fe         # overrides --tenant-primary CSS var

# Castle backlink (required in tenant mode)
CASTLE_API_URL=https://api.castle.42nights.dev
CASTLE_DEPLOYMENT_ID=dep_xxxxxxxxxxxx
CASTLE_WEBHOOK_SECRET=whsec_xxxx

# Generation
WIKI_MODE=cloud
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...   # enables 1536d cloud embeddings

When WIKI_TENANT_SLUG is set, requireTenantEnv() (called at server start) will throw listing any missing required vars — fail-fast before the deployment handles traffic.

Pattern A — per-tenant Vercel project + data/atlas.db

Each tenant is a separate Vercel deployment (separate project, separate env, separate data/atlas.db volume). This is the v0 model: simple, isolated, no cross-tenant blast radius. The SQLite file lives on a persistent volume mounted at /data.

Repo connect (v0): PAT-based

Users paste a GitHub URL into the index box. For private repos, include a PAT:

https://<GITHUB_PAT>@github.com/owner/repo

PAT needs Contents: read + Metadata: read. The token is used only for the one-time clone and is never stored.

Repo connect (v1): GitHub App

Install the GitHub App on a user's org to enable one-click indexing and auto-reindex on push. Configure:

GITHUB_APP_ID=12345
GITHUB_APP_PRIVATE_KEY_PATH=/secrets/app.pem
GITHUB_WEBHOOK_SECRET=whsec_...

Webhook endpoint: POST /api/github/webhook

Mode-lock caveat

Local (768d) and cloud/OpenAI (1536d) embeddings cannot be mixed in one database. If you provision a tenant on local embeddings and later switch to cloud, delete data/atlas.db and trigger a full re-ingest. The dimension guard in lib/vector.ts will catch this with a clear error before serving bad results.

MCP server

The MCP server (npm run mcp) exposes index_repo and ask_wiki tools over stdio. It is reachable by Hermes and other MCP-compatible agents. In Castle deployments the server runs as a sidecar process alongside the Next.js app.

For full env var documentation, failure modes, and a first-call checklist, see docs/template-handoff.md.

About

Local-only DeepWiki clone for the 42nights team — tree-sitter code indexing, hybrid retrieval, grounded wiki + chat with verbatim citations, MCP server. Fully local (LM Studio + local embeddings), zero cloud touch.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages