Skip to content

Build a feature wiki from merged pull requests

Codebase wiki keeps a living, feature-organized wiki of a repository. The GitHub channel acknowledges every closed pull request instantly, fetches a compact digest on the host, and spends a model turn only on merged PRs. The turn maps the change onto feature pages; a daily schedule writes a digest of what changed and rebuilds the index. Chat sessions answer codebase questions from the wiki with page citations.

Use this project when documentation should accumulate from merges instead of being regenerated from scratch. Use Knowledge base when people should curate organizational context through conversation.

Browse the codebase wiki source.

Treat PRs as evidence and features as pages

The wiki refuses to become a merge log:

  • The page tree is rigid: index, features/<slug>, and digests/<yyyy-mm-dd>. The store rejects anything else, so the wiki can't sprawl.
  • The feature-mapping skill requires a wiki_search before every write. A PR updates the page that owns its feature; a new page needs a genuinely new feature; chores change nothing.
  • Every touched page gets a dated changelog entry citing the PR number, so each fact traces back to a merge.

The wiki itself is markdown on the serve host, in .agent-serve/wiki/ by default with a CODEBASE_WIKI_DIR override. Sessions are disposable; the wiki is the durable state.

Follow a merged PR

  1. GitHub delivers pull_request with action closed. The channel returns a task acknowledgement immediately.
  2. The task fetches the digest with the host gh CLI: title, body, labels, changed files, and a bounded diff excerpt. No checkout.
  3. The webhook payload can't say whether the PR merged, so the host checks mergedAt and skips abandoned PRs without a model turn.
  4. For merged PRs, the task starts the turn with pr/DIGEST.md seeded through workspaceFiles and a pr:<owner/repo#N> continuation token, so redeliveries resume instead of double-ingesting.
  5. The model follows feature-mapping: search, update or create feature pages, add changelog entries, and refresh index when pages were added.

In chat, "ingest PR #123" runs the same flow through the ingest_pr tool, which writes the digest into the active session workspace.

Map the wiki files

FilePurpose
agent/agent.tsSelects the cloud runtime and model.
agent/instructions.mdSplits the job into merge ingestion and wiki-cited Q&A.
agent/lib/wiki-store.tsEnforces the rigid page tree and owns reads, writes, and search.
agent/lib/pr-digest.tsFetches PR metadata and diff, and formats pr/DIGEST.md.
agent/tools/ingest_pr.tsExposes host digest preparation for chat-driven backfills.
agent/tools/wiki_read.ts, wiki_search.ts, wiki_write.tsRead, search, and rewrite wiki pages.
agent/skills/feature-mapping.mdMaps changes onto features and fixes the page and changelog shape.
agent/schedules/daily-digest.mdWrites digests/<date>, rebuilds the index, and flags stale pages.
agent/channels/github.tsAcknowledges closed PRs and starts merged-only ingest turns.
agent/storage.tsPersists sessions and events with cursorHostedStorage.
evals/evals.config.tsCaps eval run concurrency.
evals/ingest.eval.tsGates ingest decisions against the wiki filesystem.

There is no MCP connection, subagent, hook, A/B experiment, or custom storage.

Prepare credentials and services

You need:

  • Node 22.13 or newer.
  • An agent-runtime credential for model turns.
  • gh on PATH with read access to the PRs you ingest.

The channel verifies webhook signatures when GITHUB_WEBHOOK_SECRET is set and narrows repositories with CODEBASE_WIKI_REPOS=owner/repo,owner/other. The agent never writes to GitHub. Its only side effects are wiki files on the serve host.

Validate the surface

bash
agent-sdk validate --dir examples/codebase-wiki
agent-sdk info --dir examples/codebase-wiki --json

The manifest should report four server tools, one skill, one schedule, and the authored GitHub channel.

Ingest without webhook plumbing

Replay a real merged PR as a closed delivery:

bash
agent-sdk dev examples/codebase-wiki

agent-sdk github replay https://github.com/owner/repo/pull/123 \
  --dir examples/codebase-wiki --action closed

The reply is a 202 acknowledgement; the ingest continues in the task. Watch the session in the playground, then read the result on disk:

bash
ls examples/codebase-wiki/.agent-serve/wiki/features/

Each ingested feature page carries an overview, a "How it works" section, and a changelog line citing the PR. Deterministic digest preparation works without a model turn:

bash
agent-sdk call ingest_pr \
  --dir examples/codebase-wiki \
  --input '{"pr":"https://github.com/owner/repo/pull/123"}'

A PR closed without merging returns merged: false and a note telling the model to change nothing.

Run the daily digest

The schedule fires at 07:00 UTC. Under agent-sdk dev, trigger it by hand:

bash
curl -s -X POST http://127.0.0.1:3000/codebase-wiki/v1/dev/schedules/daily-digest

The turn reads every feature changelog, writes digests/<today> grouped by feature with PR citations, rebuilds index, and reports one line per page it wrote. Entries dated today always count; a digest only claims a quiet day when no entry qualifies.

Run the evals

bash
agent-sdk eval --dir examples/codebase-wiki --list
agent-sdk eval --dir examples/codebase-wiki ingest/update-existing

The cases seed a temp wiki through CODEBASE_WIKI_DIR and build digests with the same formatter the channel uses, so they run without GitHub or network access. The gates check the filesystem, not prose: a new feature page lands on a new slug, a related PR updates the existing page instead of duplicating it, an unmerged PR changes nothing, and the daily pass writes a digest naming both seeded features.

Reuse the merge-ingestion pattern

Copy this shape when events should accumulate into curated state:

  • Acknowledge webhooks with a task and decide host-side whether a model turn is worth spending.
  • Seed evidence through workspaceFiles so the model never fetches.
  • Constrain the durable store's shape in code and its content in a skill.
  • Add a consolidation schedule so incremental writes stay coherent.

Where to go next