Skip to content

feat: openkb visualize — interactive knowledge graph (3D · mind-map · radial) - #103

Merged
KylinMountain merged 6 commits into
mainfrom
feat/visualize
Jun 22, 2026
Merged

feat: openkb visualize — interactive knowledge graph (3D · mind-map · radial)#103
KylinMountain merged 6 commits into
mainfrom
feat/visualize

Conversation

@KylinMountain

@KylinMountain KylinMountain commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

New read-only openkb visualize command that renders the wiki's [[wikilink]] graph as a self-contained, offline, interactive HTML page — pure data + a templated render, no LLM, deterministic.

It ships three views of the same knowledge base, switchable from a tab bar (no network, no CDN, works offline):

  • 3D (default) — a force-directed "nebula": nodes coloured by type, sized by connectivity, soft glow, ambient flow particles, gentle idle auto-rotation; drag to orbit, scroll to zoom, drag a node to pull it out & pin.
  • mind-map — an OpenKB-rooted horizontal tree (OpenKB → documents → the concepts each produced), curved connectors coloured by type, collapsible branches (+/−), centred in the viewport.
  • radial — the same OpenKB-centred hierarchy fanned out in a circle, with faint wikilink cross-references that light up on hover.

Shared across all views: a glass inspector panel (type, description, sources, in/out links — each clickable to jump), search, a legend type-filter, a spacing slider, reset, and a smooth auto-fit that frames the graph to the viewport. Opens in the browser by default (--no-open for headless); writes output/visualize/graph.html each run (a shareable snapshot).

Why a tree/hierarchy, not just the force graph

A dense wiki (here 71 nodes / 800 edges, avg degree ~22) is a hairball as a raw force graph — intrinsic to the data, not the layout. The mind-map and radial views use the provenance hierarchy that already lives in the frontmatter (each summary's origin document via full_text; each concept/entity's source summaries via sources), which is a genuinely readable tree.

Architecture

  • openkb/visualize.pybuild_graph(wiki_dir) collects nodes/edges/types (reuses lint._extract_wikilinks / _normalize_target, frontmatter.parse, schema.PAGE_CONTENT_DIRS); render_html(graph) injects the JSON into the template (escaped so it can't break out of <script>).
  • openkb/templates/graph.html — the self-contained canvas + DOM template (ships via hatchling's default packaging).
  • openkb/cli.py — thin visualize command (mirrors the other read commands' decorators/lock).

Also folds in a one-line fix to a deck-skill test that was already red on main (unrelated to visualize — #101 changed the default deck skill without updating the test).

Test plan

  • pytest — 810 passed
  • ruff clean on new files
  • Verified in-browser on a real KB (71 nodes / 800 edges): all three views render, tab switching, inspector/search/legend-filter/spacing/reset, auto-fit, no console errors
  • Two /code-review passes (incl. an xhigh-effort run after the view churn); findings fixed

@KylinMountain KylinMountain changed the title feat: openkb visualize — interactive 3D knowledge graph feat: openkb visualize — interactive knowledge graph (3D · mind-map · radial) Jun 22, 2026
@KylinMountain

Copy link
Copy Markdown
Collaborator Author
image

…enkb-deck-neon

#101 made openkb-deck-neon the default deck skill (creator.py
DEFAULT_DECK_SKILL) but left this test asserting the old
openkb-deck-editorial, so it was red on main. Unrelated to visualize.
… HTML

build_graph(wiki_dir) walks summaries/concepts/entities, collects nodes
(id/label/type/description/sources + in/out degree), resolves [[wikilinks]]
to edges (reusing lint._extract_wikilinks/_normalize_target and
frontmatter.parse; dirs from schema.PAGE_CONTENT_DIRS), and drops
broken/self/duplicate links. render_html injects the graph as JSON into
the template (escaping </ so it can't break out of <script>).
Thin read-only command mirroring the other commands' decorators + KB lock:
resolve KB -> build_graph -> render_html -> write output/visualize/graph.html.
Opens in the browser by default (--no-open for headless), resolve()s the
path for a valid file URI, and degrades with a hint if no browser launches.
…-map / radial)

One offline HTML page (canvas + DOM, no CDN/network) with three switchable
views of the same KB: a 3D force 'nebula' (default; glow, degree-sized
nodes, flow particles, idle auto-rotation), an OpenKB-rooted horizontal
mind-map (collapsible provenance tree), and a radial OpenKB-centred circle
with faint cross-references. Shared: glass inspector panel, search, legend
type-filter, spacing slider, reset, smooth auto-fit. Neon-on-dark aurora.
build_graph (nodes/edges/types, broken-link drop, orphan, degree, provenance
sources incl. summary full_text); render_html self-contained (canvas, JSON
embedded, no http(s), unicode round-trip); CLI writes output/visualize/
graph.html, opens by default, --no-open suppresses, empty wiki writes nothing.
@KylinMountain
KylinMountain force-pushed the feat/visualize branch 3 times, most recently from c1ae1e7 to 6fdf257 Compare June 22, 2026 10:43
Add it to the Layer 2 generators table and a '(iii) Visualize' subsection
matching the existing (i)/(ii) generator sections: a self-contained
interactive knowledge graph (3D / mind-map / radial) written to
output/visualize/graph.html.
@KylinMountain
KylinMountain merged commit 46c13f7 into main Jun 22, 2026
1 check passed
@woutervanranst

Copy link
Copy Markdown

@KylinMountain can you trigger a new release? 🙏

@KylinMountain

Copy link
Copy Markdown
Collaborator Author

@woutervanranst Thanks for the nudge! It’s actually already out. You can grab it via: pip install openkb==0.4.2rc1 --prerelease=allow .

Full changelog: https://github.com/VectifyAI/OpenKB/releases/tag/v0.4.2-rc1

@KylinMountain
KylinMountain deleted the feat/visualize branch June 25, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants