okfsmith logo okfsmith Docs Website EN Open okfsmith
On this page

User guide

Visualizing the knowledge graph

See the graph

okfsmith graph ./kb

Real output for a fresh --no-llm bundle (two short documents, eight sections):

8 concepts, 12 links, 0 dead links.

Orphans (0):
  (none)

Dead links (0):
  (none)

What each number means:

  • concepts — nodes in the graph (one per concept file).
  • links — edges: a concept's body links to another concept in the bundle.
  • dead links — link targets that resolve to nothing in the bundle (matches W001 from Validation).

A freshly ingested --no-llm bundle already has links: deterministic sectioning links every section to its neighbours in the same document, and to any section its text mentions by title (the ## See also block at the end of each concept). LLM extraction adds richer, claim-based links on top.

  • Orphans — concepts nothing links to. They're valid but isolated: readers can only reach them via list or search.
  • Dead links — links pointing at targets that don't exist in the bundle (typos in hand-written links, renamed concept files).

Links are resolved the way they were written: a link inside a per-section concept (id doc/section) is relative to the source document, so a link naming a whole document (e.g. other.md) lands on that document's primary section concept — the section whose slug matches the file stem, else the earliest-generated section, else the first alphabetically. This is the same rule the dashboard's Explore graph uses, and validate (W001) agrees with it: interlinked documents no longer show up as dead links.

To fix them:

  1. Run okfsmith graph ./kb to list the offenders.
  2. For dead links: open the source concept and correct the link target (or create the missing concept).
  3. For orphans: link to them from related concepts, or add them to an index.md entry — note that index.md-reachability is what validation rule W002 checks.

Temporal status

Graph nodes carry the same temporal status the search / list / read surfaces (and the dashboard graph API) show, evaluated at now: current, superseded, expired, or not_yet_valid (see Temporality for what each means and which frontmatter drives it).

  • Text — when any node is non-current, the report gains a section listing it, e.g. Non-current concepts (1): followed by - old-policy (superseded by new-policy). A bundle where every concept is current prints no such section.
  • JSON — every node carries temporal_status and superseded_by (null unless superseded), so scripts can filter history from live knowledge without a second call.
  • Mermaid — non-current nodes get the status in their label, e.g. old-policy — Old Policy (superseded by new-policy); current nodes keep their plain label.

Output formats

graph renders four ways:

--formatOutput
text (default)The summary above, printed to stdout
jsonMachine-readable: nodes (with temporal_status / superseded_by), edges, orphans, dead links
mermaidflowchart LR — one node per concept, e.g. big_first_bundle["big/first-bundle — First Bundle"]. Paste it into any Mermaid renderer.
htmlAn interactive visualization written to <bundle>/viz.html
# write a Mermaid diagram to a file
okfsmith graph ./kb --format mermaid --output graph.mmd

# render the interactive viewer (offline: colorblind-safe palette, backlinks, search)
okfsmith graph ./kb --format html

The HTML viewer needs no server — open kb/viz.html in a browser. It shows the graph with a colorblind-safe palette, per-concept backlinks, a search box, and keyboard access. Non-current concepts (superseded, expired, or not yet valid) are struck through on the canvas and carry a temporal badge in the detail panel, so stale knowledge never reads as live. (Chat's /graph runs the same command inside the REPL.)

--as-of <date|datetime> replays the whole graph at a past/future instant: node temporal status is evaluated then, not now, in every format — and the HTML viewer labels the replay ("as of …") in its header stats, so a replayed viewer never reads as the present.

Advanced - `--output ` writes to a file instead of stdout for any `--format` — combine with `--format html` to place the viewer somewhere specific: `okfsmith graph ./kb --format html --output ./site/viz.html`. - JSON shape is `{"nodes": [...], "adjacency": {"": ["", ...]}, "dead_links": [...]}` — stable for scripting and CI checks. - The default HTML output is always `/viz.html`; pass `--output` to change it. - Link analysis also runs inside `validate` (E001–E004/W001–W015), but `graph` is the tool for *exploring* the graph, not only conformance-checking it.

Next: Agent skill pack → — teach agents the init → ingest → validate → serve workflow.