OKF Visualize
Goal
Produce readable graph views of an OKF bundle. Type styling comes from frontmatter type — this plugin does not special-case AgentNode or other domain nouns.
Output modes
| Mode |
When |
| Mermaid |
Docs, PRs, chat — default |
| JSON |
Downstream tools / further agent steps |
| HTML |
Standalone shareable map (simple self-contained page) |
Process
- Resolve bundle and optional focus concept / filter (type, tag, hops).
- Render the graph:
okf graph <bundle> # if available
# fallback — whole bundle, fenced Mermaid on stdout:
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/okf-graph.py" graph <bundle>
# focused neighborhood:
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/okf-graph.py" graph <bundle> --focus <concept> --hops 2
# other formats:
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/okf-graph.py" graph <bundle> --format json
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/okf-graph.py" graph <bundle> --format html > docs/okf-graph.html
--format json prints JSON; mermaid (default) and html print the artifact
itself, so they pipe straight into a doc or a file. Node IDs come from the
full concept path, so the bundle's many index.md files stay distinct.
- Choose layout:
- Whole bundle — default
- Focus —
--focus + hops for a neighborhood
- By type — filter on frontmatter
type when the user asks
- Emit artifact to the path the user requested (or inline Mermaid in chat).
Mermaid conventions
graph LR
subgraph Catalogs
C[Knowledge catalog]
end
subgraph Knowledge
K[Plugin architecture]
end
C -->|related_to| K
- Use node labels = titles; keep IDs filesystem-safe.
- Edge labels optional (
depends_on, related_to).
- Cap diagrams at ~40 nodes; otherwise filter or multi-diagram by subgraph.
HTML
--format html emits one self-contained page — no CDN, no scripts, no network
fetches, so it opens from disk and survives a locked-down viewer. It carries:
- Title, caption (focus + hops), generated timestamp, node/edge counts
- Mermaid source in
<pre class="mermaid"> — drawn by renderers that
understand it, readable as text everywhere else
- Concept table (title, path, type, verified) and edge table (from, rel, to)
Write it to a file (e.g. docs/okf-graph.html) only when the user wants one;
never re-add a CDN <script> to make it "render properly".
JSON shape
{
"nodes": [{"id": "...", "title": "...", "type": "...", "verified": false}],
"edges": [{"from": "...", "to": "...", "rel": "links_to"}]
}
Rules
- Never invent edges; only render discovered links.
- State hop limits and filters in the diagram title/subtitle.
- For huge bundles, default to 2-hop focus rather than a hairball.
Done when
- User has a Mermaid block and/or file artifact matching the requested mode
- Legend or caption explains filters
1---2name: okf-visualize3description: Visualize OKF bundles as Mermaid, HTML summaries, or JSON graphs. Use when the user wants a diagram of knowledge, an HTML map, or export for docs.4---56# OKF Visualize78## Goal910Produce readable graph views of an OKF bundle. Type styling comes from frontmatter `type` — this plugin does not special-case AgentNode or other domain nouns.1112## Output modes1314| Mode | When |15|------|------|16| **Mermaid** | Docs, PRs, chat — default |17| **JSON** | Downstream tools / further agent steps |18| **HTML** | Standalone shareable map (simple self-contained page) |1920## Process21221. Resolve bundle and optional focus concept / filter (type, tag, hops).232. Render the graph:24 ```bash25 okf graph <bundle> # if available26 # fallback — whole bundle, fenced Mermaid on stdout:27 python3 "${CLAUDE_PLUGIN_ROOT}/scripts/okf-graph.py" graph <bundle>28 # focused neighborhood:29 python3 "${CLAUDE_PLUGIN_ROOT}/scripts/okf-graph.py" graph <bundle> --focus <concept> --hops 230 # other formats:31 python3 "${CLAUDE_PLUGIN_ROOT}/scripts/okf-graph.py" graph <bundle> --format json32 python3 "${CLAUDE_PLUGIN_ROOT}/scripts/okf-graph.py" graph <bundle> --format html > docs/okf-graph.html33 ```34 `--format json` prints JSON; `mermaid` (default) and `html` print the artifact35 itself, so they pipe straight into a doc or a file. Node IDs come from the36 full concept path, so the bundle's many `index.md` files stay distinct.373. Choose layout:38 - **Whole bundle** — default39 - **Focus** — `--focus` + hops for a neighborhood40 - **By type** — filter on frontmatter `type` when the user asks414. Emit artifact to the path the user requested (or inline Mermaid in chat).4243## Mermaid conventions4445```mermaid46graph LR47 subgraph Catalogs48 C[Knowledge catalog]49 end50 subgraph Knowledge51 K[Plugin architecture]52 end53 C -->|related_to| K54```5556- Use node labels = titles; keep IDs filesystem-safe.57- Edge labels optional (`depends_on`, `related_to`).58- Cap diagrams at ~40 nodes; otherwise filter or multi-diagram by subgraph.5960## HTML6162`--format html` emits one self-contained page — no CDN, no scripts, no network63fetches, so it opens from disk and survives a locked-down viewer. It carries:6465- Title, caption (focus + hops), generated timestamp, node/edge counts66- Mermaid source in `<pre class="mermaid">` — drawn by renderers that67 understand it, readable as text everywhere else68- Concept table (title, path, type, verified) and edge table (from, rel, to)6970Write it to a file (e.g. `docs/okf-graph.html`) only when the user wants one;71never re-add a CDN `<script>` to make it "render properly".7273## JSON shape7475```json76{77 "nodes": [{"id": "...", "title": "...", "type": "...", "verified": false}],78 "edges": [{"from": "...", "to": "...", "rel": "links_to"}]79}80```8182## Rules8384- Never invent edges; only render discovered links.85- State hop limits and filters in the diagram title/subtitle.86- For huge bundles, default to 2-hop focus rather than a hairball.8788## Done when8990- User has a Mermaid block and/or file artifact matching the requested mode91- Legend or caption explains filters