Kucatoo-Code · Wiki

Wiki update — how it works

This page documents the built-in wiki-update job: what it does, what it picks up, and what it does not. It is the operational companion to wiki-update-prompt.md (which is the procedure the agent follows; this page is the mechanism around it).


1. Overview

The wiki is a set of hand-structured Markdown pages in docs/wiki/ with a small YAML front matter: title, sources: (the code paths a page is responsible for), and verified_at (last time its prose was checked against code).

The wiki-update job is a diff-driven refresh: it diffs the git history since the wiki's last recorded commit, works out which pages are affected, and re-runs a single agent whose goal is the procedure in docs/wiki/wiki-update-prompt.md. After a successful run, a mechanical (not LLM) post-step writes a review diff to docs/wiki/history/ and advances docs/wiki/.wiki-state.json to the current HEAD.

Short answer to "does it pick up code changes and new features":


2. Components

File Role
model_harness/workflow/wiki_job.py Workflow definition + default weekly schedule + the mechanical write_update_diff() post-step.
docs/wiki/wiki-update-prompt.md Source of truth for the procedure (the numbered goal the agent runs).
docs/wiki/.wiki-state.json {last_commit, updated} — the diff base and refresh date.
docs/wiki/*.md The wiki pages (front matter: title, sources, verified_at).
docs/wiki/history/*.diff Per-run review diffs (committed drift + working-tree changes).
scripts/wiki_tables.py Regenerates the AUTO tables in tools.md and web-ui-api.md.
templates/help.html Hand-authored in-app help; updated by the help-sync pass.
templates/wiki.html Reader shell for /wiki and /wiki/<slug>.
model_harness/web/routes_pages.py /wiki routes, rendering, changed-page detection, search.
model_harness/web/routes_scheduler.py Jobs page: schedules, manual runs, diff history, run-cost log.
model_harness/workflow/scheduler.py Engine-side completion hook that calls write_update_diff().

3. Registration and scheduling

register_wiki_update_job(scheduler) runs at harness construction and is idempotent:


4. Triggering a run

Two ways, both via the Jobs/Workflows page (routes_scheduler.py):

The manual-run endpoint also special-cases profile-loop (redirects to the cockpit button) and profile-optimize (proposal/eval post-steps), but wiki-update only needs the diff post-step.


5. The agent procedure (the 6 steps)

From wiki-update-prompt.md (the goal the react agent executes):

  1. Read docs/wiki/.wiki-state.json for last_commit; run git diff --stat <last_commit>..HEAD (fall back to git log -5 --oneline if the file/sha is missing).
  2. For each wiki page, compare the changed paths against the page's sources: front matter. Only edit pages whose sources intersect the diff — never rewrite unaffected pages.
  3. For each affected page: read the current code at the changed paths, update prose to match reality, set verified_at: to today's date. Keep pages under ~250 lines; keep mermaid diagrams valid (≤15 nodes, no double-quoted labels).
  4. If the diff touched model_harness/tools/ or any routes_*.py / app.py, run venv\Scripts\python.exe scripts\wiki_tables.py to regenerate the AUTO tables.
  5. Help-sync pass: review the incoming changes for user-facing behavior or features (new/changed UI tabs, API endpoints, settings, shortcuts, workflows). If any exist, update templates/help.html — it is hand-authored with a <nav class="help-toc">; match its style/structure and only touch the relevant sections (add a TOC entry when adding a section).
  6. Finish with a summary: which pages changed and why, then a "Help impact" heading listing every help.html change — or "Help impact: none".

The agent is explicitly told it does not need to create diff files or touch .wiki-state.json — the harness does that itself.


6. The post-run diff writer (mechanical, not LLM)

write_update_diff(execution_id) runs after a completed wiki-update. It is pure git plumbing and never raises (fail-open: git errors yield empty strings):

  1. Read last_commit from .wiki-state.json.
  2. git diff <last_commit>..HEAD → "Committed since last wiki refresh" (truncated to 50 KB).
  3. git diff HEAD + untracked-file listing (excluding docs/wiki/history/) → "Working-tree changes (uncommitted, incl. this run)".
  4. Then advance .wiki-state.json to the current HEAD — so the next run diffs against this point. (The writer owns this file, not the agent.)
  5. If both sections are empty, skip. Otherwise write docs/wiki/history/<YYYYMMDD-HHMMSS>-wiki-update[-exec_<id>].diff.

The result is a human-reviewable artifact, not an input to the next run. The committed section shows what the agent should have incorporated; the working-tree section shows what the run itself just edited (plus any unrelated uncommitted work in the tree at run time).


7. What the diff scope means in practice


8. Rendering and the reader

routes_pages.py serves the wiki:


9. Gotchas and limitations

  1. Commit before you expect it to reflect. Only committed changes drive edits. To capture work-in-progress, commit it (or run the job again after committing) — the last_commit pointer only advances on a completed run.
  2. Failed runs advance nothing. status != "completed" → no diff, no state advance; the next run re-diffs the same range.
  3. Truncation. Diff sections cap at 50 KB each; a huge change set may be truncated in the artifact (the agent still sees the raw git diff, so this only affects review).
  4. Sources coverage is manual. A new subsystem needs a page (or an updated sources: list) before the job will maintain it.
  5. help.html is hand-authored. The help-sync pass is the only automated touch; it matches existing style and section structure and is scoped to the relevant sections. Large feature additions still benefit from a manual pass.
  6. AUTO tables are the only mechanical text. Everything else (prose, help.html) depends on the agent's judgment of the diff.

verified against code: 2026-09-01