By bencode
Knowledge graph over a markdown vault — files-as-truth extraction, SQLite index, local viewer, agent-side QA
Knowledge graph over a markdown vault. Files are the truth — the graph
lives in plain JSON under <vault>/meta/kg/ (a hash↔path registry, an L1
concept table, and per-document L2 metadata with verbatim source anchors).
The SQLite index and the local viewer are rebuildable layers on top.
<vault>/meta/kg/registry.jsonl # {hash, path, title, mtime, size} per doc
<vault>/meta/kg/concepts.json # L1 concept table (controlled vocabulary)
<vault>/meta/kg/metadata/<hash>.json # L2 mentions/relations, named by content hash
~/.cache/kg/<sha1(vault)>.db # derived SQLite index — delete freely
Key properties:
kg pending / kg gc) so each doc version is extracted once.anchor.quote validated as a literal substring of the source on import.deterministic edges (md links, arXiv ids) vs llm
edges (extracted, with confidence).Three ways, easiest first:
pnpm install && pnpm -C packages/kg compile # → dist-bin/kg (~60MB)
./dist-bin/kg db stats <vault>
Ship that one file to users — sqlite, jieba dict, and the viewer UI are all
embedded.bun packages/kg/src/cli.ts <command> ...
--experimental-sqlite):
pnpm install && pnpm build # tsc → packages/kg/dist
node packages/kg/dist/cli.js <command> ...
The sqlite layer auto-selects bun:sqlite or node:sqlite at runtime; index
files are interchangeable between the two.
Dev: pnpm test (vitest, node path) and pnpm -C packages/kg test:bun
(bun path) run the same suite. After editing packages/kg/viewer/, run
pnpm -C packages/kg embed to refresh the binary-embedded copies.
KG="bun packages/kg/src/cli.ts" # or node packages/kg/dist/cli.js, or dist-bin/kg
# Phase 1 — pure files
$KG scan <vault> [--scope knowledge] # hash ledger: new/changed/deleted
# default scope: meta/kg/config.json, else all
$KG pending <vault> # docs awaiting extraction
$KG concept import <vault> <json|-> # merge L1 concepts (alias-dedup)
$KG metadata import <vault> <json|-> # validate anchors + write L2
$KG extract-structural <vault> <path> --write # deterministic links/[[wiki-links]]/arXiv
$KG extract-structural <vault> --pending --write # batch over all pending docs
# Phase 2 — SQLite graph index (rebuildable)
$KG db build <vault>
$KG search "<query>" <vault> # jieba-tokenized FTS5
$KG entity <name> <vault> # edges + anchors + source docs
$KG neighbors <name> <vault> --depth 2
$KG paths <a> <b> <vault>
$KG export <vault> --method deterministic
# Agent QA (no server needed)
$KG qa "<question>" <vault> # entities + shortest path + FTS hits
$KG locate <hash> "<quote>" <vault> # quote → line number
$KG doc-info <hash> <vault> # hash → path + metadata + editor url
# Phase 3 — local viewer (127.0.0.1 only)
$KG serve <vault> --port 8765
All commands print JSON. Exit codes: 0 ok · 1 usage/IO · 2 validation · 3 index missing · 4 index stale.
kg serve is one process serving both the static UI and the JSON API
(same-origin fetch, no CORS). Pages: home / entity hub / document reading view
with ?cite= quote highlighting / graph (ego focus + skeleton overview).
North star: every claim links back to its verbatim source line.
A future React viewer will live in web/ and build into packages/kg/viewer/
— the server contract doesn't change.
This repo doubles as a Claude Code plugin (.claude-plugin/plugin.json +
skills/kg/SKILL.md). The skill teaches the agent the extraction contract:
the LLM reads documents and emits metadata JSON; the CLI only does
deterministic file IO and anchor validation.
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
npx claudepluginhub bencode/kgInstallable small skills grown from everyday work and study (en: learn English on the fly; skill-dsl: how to write a skill; and more)
Comprehensive skill pack with 66 specialized skills for full-stack developers: 12 language experts (Python, TypeScript, Go, Rust, C++, Swift, Kotlin, C#, PHP, Java, SQL, JavaScript), 10 backend frameworks, 6 frontend/mobile, plus infrastructure, DevOps, security, and testing. Features progressive disclosure architecture for 50% faster loading.
A growing collection of Claude-compatible academic workflow bundles. Covers scientific figures, manuscript writing and polishing, reviewer assessment, citation retrieval, data availability, paper reading, literature search, response letters, paper-to-PPTX conversion, and evidence-grounded Chinese invention patent drafting. Rules are organized as reusable skill folders with explicit workflows and quality checks.
Complete creative writing suite with 10 specialized agents covering the full writing process: research gathering, character development, story architecture, world-building, dialogue coaching, editing/review, outlining, content strategy, believability auditing, and prose style/voice analysis. Includes genre-specific guides, templates, and quality checklists.
Tools to maintain and improve CLAUDE.md files - audit quality, capture session learnings, and keep project memory current.
Develop, test, build, and deploy Godot 4.x games with Claude Code. Includes GdUnit4 testing, web/desktop exports, CI/CD pipelines, and deployment to Vercel/GitHub Pages/itch.io.
Intelligent draw.io diagramming plugin with AI-powered diagram generation, multi-platform embedding (GitHub, Confluence, Azure DevOps, Notion, Teams, Harness), conditional formatting, live data binding, and MCP server integration for programmatic diagram creation and management.