Build Index Workflow
Regenerate the wiki graph surfaces after source markdown changes: catalog, backlinks, README stats, and index freshness state.
npx tsx scripts/build-index.ts
Source: AGENTS.md Indexing and Logging, 2026-05-31
Side effects
- Walks all
wiki/**/*.md(except_prefixed) - Parses frontmatter, wikilinks, and typed
related:relationships - Updates
_backlinks.jsonwith mention and relationship types - Refreshes README Repository stats between
<!-- repo-stats:auto:start/end -->markers (never edit that table by hand) - Updates
state.jsontimestamps viaupdateState
This workflow is a generated-surface refresh. The source of truth is the handwritten page graph, not _index.md or _backlinks.json. If a generated row is wrong, fix the source page or generator, then rerun the command. Source: Generated Surface Contract, 2026-07-01
What counts as success
A successful run leaves these files consistent with disk:
wiki/_index.mdincludes every page that should be findable.wiki/_backlinks.jsonreflects current wikilinks and typed relationships.- Root
README.mdstats match the current repository. state.jsonrecords the index refresh.- No manual
## Backlinkssections were added to pages.
The index is a compiled artifact, not prose. Edit source pages, not generated index sections.
When to run
After any ingest, new category expansion, page move, merge, delete, or bulk page creation. Always follow with QMD Embed Workflow so search matches disk.
Also run after:
- renaming or moving wiki pages
- changing frontmatter fields used by the UI
- adding or removing wikilinks
- editing directory READMEs or resolver pages
- deleting pages during deduplication
Failure handling
If build-index fails, do not continue to qmd embed. Fix the structural issue first. Common causes are malformed frontmatter, invalid relationship shapes, duplicate generated markers in README, or a page path the script cannot parse. After fixing, rerun build-index, then doctor, then qmd.
If the command succeeds but produces unexpected generated diffs, inspect the source pages and generator before hand-editing output. Generated files are allowed to change during broad wiki maintenance; mystery diffs are a prompt to verify ownership, not to delete the evidence.
Run Contract
This workflow follows Workflow Run Contract: name the sources, write output or no-op proof, promote only durable facts, update state only when the run really completed, refresh generated surfaces when durable pages or skills change, and log user-visible work.
Timeline
- 2026-07-01 | Aligned the workflow with Generated Surface Contract so
_index.md, backlinks, README stats, and state are treated as generated projections of source markdown. Source: User request, 2026-07-01 - 2026-06-18 | Added success criteria, expanded run triggers, and failure handling so agents treat build-index as a required compiled-artifact refresh. Source: User request, 2026-06-18
- 2026-05-31 | Workflow page created from build-index script contract. Source: scripts/build-index.ts, 2026-05-31