Draft cited pages

docsbot draft writes a first draft of a page from material you already have, cites every statement, and gives reviewers a checklist of facts to confirm. It is for writers starting a new page, not a way to skip review: every draft starts as status: draft with review: required, and check fails a page marked ready while its claims are unverified.

Write a draft

From the root of a repository:

docsbot draft write "Upgrading lumen safely"

docsbot uses the repository as its sources:

  • Docs: every page under the content root, cut into passages it can cite. Pages that are themselves drafts (status: draft) are not used.
  • Knowledge graph: each claim lists the pages that define the commands, flags and settings it names.
  • Code and configuration: code, config files, schemas and reference tables, used to check the numbers, defaults, flags, fields and versions in each claim.

Add more sources with --kb (folders or files of Markdown, AsciiDoc, reST or text) and --transcript (WebVTT, SRT or plain text interview transcripts):

docsbot draft write "Upgrading lumen safely" --transcript calls/upgrade.vtt --kb ../support-notes

Use --no-repo to draft only from --kb and --transcript.

What you get

The draft goes to drafts/<topic> (or --out; never inside the sources):

File Contents
draft.md the page, with a footnote citation on every statement. Statements without a valid citation are marked [uncited].
claims.json the verification ledger: every statement, its citations, and each number, version, flag, command, parameter, field and default in it, marked as found or not found in the cited passage, and as confirmed by or conflicting with the repository
review.md the reviewer’s checklist, with facts missing from their sources listed first

A conflict is a real finding: for example, a default in the docs that differs from the default in the config schema.

Extractive or written by a model

Without a model, the draft is extractive: sentences come from the sources as written, for a writer to rework. Nothing leaves your machine.

With a model, the prose is written from the same passages with a versioned prompt, and the ledger checks the result the same way. Configure one in docsbot.yml:

draft:
  provider: ollama          # none | ollama | openai | anthropic
  model: llama3.1
  # endpoint: http://localhost:11434
Provider Notes
ollama local; endpoint defaults to http://localhost:11434; model is required
openai any OpenAI-compatible server, such as llama.cpp or LM Studio; endpoint and model are required
anthropic Anthropic’s API; needs allow_remote: true; reads the key from api_key_env or ANTHROPIC_API_KEY

docsbot refuses to send passages to an endpoint off your machine unless you set allow_remote: true (or pass --allow-remote).

Use your own template

The built-in template has five sections: Summary, Before you start, Recommended practices, Common mistakes, and Check that it works. Write your own as Markdown: each ## heading is a section, and an HTML comment under it says what belongs there and, after query:, extra words to search the sources for.

## Before you start
<!-- Prerequisites, versions, access. query: prerequisites requirements install version -->

## Steps
<!-- The procedure, in order. query: run command step passages: code -->

passages: code or passages: prose limits a section to one kind of source.

docsbot draft write "Logging" --template templates/practice.md --out drafts/logging

Review the draft

Record decisions claim by claim. Claim IDs (C1, C2 …) are in review.md:

docsbot draft verify drafts/logging --claim C1,C2 --status verified --by "A Reviewer"
docsbot draft verify drafts/logging --claim C5 --status needs-change --note "the default is info"
docsbot draft status drafts/logging

Statuses are verified, rejected, needs-change and unverified. A claim without a citation can only be verified with a --note that says where it was checked.

Edit draft.md freely. The next verify or status matches the ledger to the file: edited or new statements become unverified, and claims whose text is gone are marked removed.

When the page moves into your docs, docsbot check fails it (rule draft-unverified-claims) while it is marked ready and any claim is still unverified.