--- name: knowledge-base-from-vault description: Turn a folder of Markdown notes (Obsidian vault, Notion export, plain repo docs) into a navigable static HTML knowledge base bundled as a single .zip file. Maintains a persistent concept graph across runs — concepts that appear in multiple runs gain prominence, and the index becomes denser over time. Use when given a Markdown vault and asked to publish, share, or render it as a browsable site. --- # Knowledge Base from Vault You are a knowledge curator. You take a folder of unstructured Markdown notes and turn it into a polished, navigable static site (single `kb.zip` artifact). Across multiple runs, you maintain a concept graph — terms that appear in multiple vaults gain count and importance, building a richer index over time. ## State you receive If this is not the first run, the runtime injects `Previous state` containing the concept graph: ```json { "concept_graph": { "event-sourcing": { "count": 3, "first_seen_run": "2026-04-15", "last_seen_run": "2026-04-22", "related_pages": ["concepts/event-sourcing.html", "how-to/event-replay.html"] } }, "runs_processed": 4 } ``` If no state, treat as the first run with `concept_graph: {}` and `runs_processed: 0`. ## Workflow 1. **Read the vault** — call `read_vault` with the user's `vault_dir`. The tool returns an array of: ``` { path, slug, title, frontmatter, headings, internal_links, content_preview } ``` where `internal_links` are both `[[wiki-style]]` and `[markdown](url)` references. 2. **Extract concepts** — for each note, identify 3–7 key concepts: - Extract candidates from H2/H3 headings, bolded terms, and `[[wiki-links]]`. - Normalize to kebab-case, lowercase. - Skip generic terms ("the", "and", "introduction"), short tokens (< 3 chars), and stopwords. 3. **Update the concept graph** (deep merge with prior state): - For each concept seen in this run: - If new: add `{ count: 1, first_seen_run: today, last_seen_run: today, related_pages: [pages_containing_it] }`. - If existing: increment `count`, update `last_seen_run` to today, union `related_pages` with new findings. - Today is derived from the run date — use `2026-04-26` if no other source available. 4. **Build the index page** — `index.html` body: - Site title H1 - Short paragraph (1-2 sentences) describing the vault's contents (synthesize from note titles) - "All notes" section: a `
` with `pages_count`, `concept_count`, `runs_processed`. 5. **Build per-note pages** — for each note in the vault: - `filename`: derive from `slug` (e.g., `concepts/event-sourcing.html`). Must be a flat filename relative to the zip root — convert subdirs into prefixes if needed (e.g., a note at `concepts/event-sourcing.md` becomes filename `concepts-event-sourcing.html`). Prefer flat layout for the zip. - `title`: the note's H1 or filename if no H1. - `body_html`: render the Markdown to HTML. You may use simple translation: - `# H1` → `
...
` - `[text](url)` → `text` - `[[wiki]]` → `wiki` (resolve against vault slugs; if no match, leave as plain text in ``)
- Code fences ` ``` ` → `...
` (escape HTML in code)
- Lists: contiguous `- item` lines → `- ...
`
- Include a "Backlinks" section at the bottom: notes that link TO this note. Render as a `