name: typlore description: Build and maintain a layered wiki that presents a project kept in a git repository, not only its code: what it is for, what goes in and what comes out, examples of it in use, and how its code works. Pages serve four audiences (L0 what, L1 concepts, L2 architecture, L3 code), are written as answer-first explainers, cite lines of files at a pinned commit, and build into a static site with Typst. Use when asked to create, update, check or query a project wiki, to explain a project to readers at different levels, or to document how its parts work together. license: Apache-2.0
typlore 是做什么的?
You write and maintain the wiki. The human chooses the scope, reads, and asks questions. The documented repository is read-only: never edit it, commit to it, or run commands that change it.
Before writing any page, read both references:
references/page-authoring.md: layers, page structure, the Typst API, diagrams.references/evidence.md: what to cite and how.
To put a wiki online beside its repository, read references/publishing.md
(GitHub Pages; the workflow is templates/github-pages.yml).
Where typlore is
typlore's scripts/ and src/ sit beside this skill's folder, in one copy of
typlore. Every scripts/... command below is typlore's: run it with typlore's path.
- In a project set up as typlore's README says, typlore is the git submodule
wiki/typloreand the wiki iswiki/:wiki/typlore/scripts/check.sh wiki. Follow the skill in that submodule,wiki/typlore/skill/SKILL.md: it comes from the same commit as the scripts. Ifrealpathof this skill's folder is notwiki/typlore/skill(a skill installed for every project, newer or older than the project's typlore), read that file and follow it instead. - Anywhere else, typlore is the folder above this skill's real folder: resolve
links first,
realpath <this skill's folder>/...
The wiki directory
<wiki>/
typlore.toml name, repo, typst_root, optional repo_url
wiki.typ entry: settings, index page, one #include per page
pages/<slug>.typ one page each: only the owner puts pages here
candidates/ your drafts, <slug>.typ each, until the owner promotes them;
candidates/preview/ is the drafts' preview site
log.md append-only log of every operation
reviews.json claim review verdicts; written only by scripts/review.sh
dist/ build output; never edit it. Includes source/: every cited
file at its commit, which citation clicks and previews open,
search-index.js, which the search box reads, and
<name>-wiki.pdf, the whole wiki as one PDF
The library is src/typlore.typ in typlore's folder. Pages import it by relative
path, so typst_root must contain both the wiki and typlore: with typlore at
wiki/typlore, that is wiki/ itself.
Layers
| Layer | Reader | A page answers |
|---|---|---|
| L0 What | Anyone | What does this project do, what goes in and what comes out, and why does it exist? |
| L1 Concepts | An engineer new to the domain | What is this idea, and how does this project use it? |
| L2 Architecture | A contributor | How do these parts work together, and why this way? |
| L3 Code | A maintainer | Where is it implemented, and how is it configured? |
Init
Create the wiki directory with these files, then run Check.
typlore.toml:
name = "<project>"
repo = ".." # the documented repo, relative to this file (the wiki is its wiki/)
typst_root = "." # a folder holding both this wiki and typlore (typlore is wiki/typlore)
# repo_url = "https://github.com/<owner>/<repo>" # optional: makes sources clickable
wiki.typ:
#import "typlore/src/typlore.typ": * // typlore's src/, relative to this file
#let cfg = toml("typlore.toml")
#show: wiki.with(name: cfg.name, repo-url: cfg.at("repo_url", default: none))
#index-page(title: cfg.name + " wiki", intro: [<one sentence on what this wiki covers>])
// One #include per page, in layer order:
// #include "pages/<slug>.typ"
log.md: a # <project> wiki log heading.
Build: the first pass
-
Freeze the source. Run
git -C <repo> rev-parse HEADandgit -C <repo> status --short. Use the full SHA as every page'scommit. Modified or untracked paths can't be cited. A topic that exists only in them is deferred: list it in the log and tell the user to commit it. -
Map the project, read-only, at that commit: README, decision records, manifests, entry points, configuration, scripts, tests. List
git ls-tree -r --name-only <sha>. Find what goes in, what comes out, and real examples of the project in use: usage in the README,examples/, test fixtures, sample configs and outputs. Separate what is built from what is planned (roadmaps, "next", status lines). -
Plan the pages. One page per reader question.
- L0: one or two pages: what the project does and why, with an
exampleof it in use (what goes in, what comes out). See "Present the project" inreferences/page-authoring.md. - L1: one page per concept a reader must know before L2 makes sense.
- L2: one page per component, flow or important decision.
- L3: one page per package or module, only once code exists.
For each page give the slug, layer, title (the question), sources and up/down links. Show the plan and wait for approval, unless the user already approved the scope.
- L0: one or two pages: what the project does and why, with an
-
Write the pages as drafts,
candidates/<slug>.typ, L0 first, then each deeper layer. Read every source with line numbers:git -C <repo> show <sha>:<path> | nl -ba. If the SHA is in a shell variable, write"${sha}:<path>"with the braces: zsh reads$sha:pathas a modifier and shows the wrong thing. Follow both references. Setup:on every page below L0 anddown:where deeper pages exist. -
Check the drafts.
scripts/candidates.sh <wiki> checkbuilds the wiki with the drafts in it, runs every check, and writes a preview site tocandidates/preview/. Fix every FAIL. Fix each WARN, or record why it stays. -
Hand them over (section Drafts below). The owner reads them and promotes them; promoting adds each new page's
#includetowiki.typin layer order. -
Check it. Once promoted, run
scripts/check.sh <wiki>with typlore's path (wiki/typlore/scripts/check.sh wiki). -
Review the claims (section Review below), then run Check again.
-
Log it (format below) and report in 3 to 5 lines: pages per layer, deferred topics, the check and review results, and the build command
scripts/build.sh <wiki>.
Update: after the code changes
- Run Check. Its
staleanduncommittedwarnings list the pages to revisit. - For each stale page, run
git -C <repo> diff <page-commit> HEAD -- <paths>. Re-read every cited range at HEAD. Line numbers move, so recopy them. Copy the page tocandidates/<slug>.typand rewrite what changed there. Only then set the draft'scommitto the new SHA. Never move a commit without re-reading the cited lines. - Cascade: search the other pages for the changed terms and slugs
(
grep -rn '<term>' <wiki>/pages) and update every page they affect. - Plan pages for new topics in the diff, and for deferred topics whose sources are now committed. Get approval, then write them.
- Check the drafts and hand them over (section Drafts below). Once they are promoted, run Check. It lists the claims your edits sent back to review as "not reviewed". Review them (section Review below), then log.
Drafts: the owner promotes
You write pages only into candidates/. Nothing there is built or published
until the owner promotes it. A draft is a whole page file: a new page, or the
next version of pages/<slug>.typ, named after its slug.
scripts/candidates.sh <wiki> checkmust PASS before you hand over.- Tell the owner what is ready, and how to read it:
scripts/candidates.sh <wiki> list(new or changed, with titles),diff <slug>(a draft against its page), andcandidates/preview/index.html(the wiki with the drafts in it). - The owner runs
scripts/candidates.sh <wiki> promote [<slug> ...], ordrop <slug>for a draft they reject. Both ask at the owner's terminal and log what they did. Never run them yourself, never write intopages/, and never move a draft by hand.
Query: answer from the wiki
- Search
pages/for the topic, its synonyms and related slugs. - Answer in the conversation from the pages you read. Cite the page file and the repo lines it cites. Prefer the wiki over your own knowledge.
- If the wiki doesn't cover it, say so and offer to add a page. Don't write files unless asked.
Check: keep the wiki healthy
Mechanical: scripts/check.sh <wiki> [--strict]. The wiki must build (every
@slug and up/down link resolves). Every citation must exist at its commit.
Pages whose sources changed are stale. A wiki whose L0 pages show no example
of the project in use gets a warning, and so do diagram labels or boxes that
collide. Once the wiki has been reviewed, a claim
judged unsupported fails, and partial or unreviewed claims warn.
Judgment: report these, and don't fix them silently:
- contradictions between pages;
- terms used without a definition or an L1 page;
- pages that answer more than one question (split them);
- L0 pages that use jargon without plain words;
- pages no other page links to (search for
@<slug>); - planned features written as if they were built.
Review: do the cited lines support each claim?
Check proves that a citation exists. Review judges whether the cited lines say
what the sentence says. Verdicts are kept in <wiki>/reviews.json. A verdict
belongs to one claim and its cited lines: edit the sentence, its paragraph or
the cited code, and that claim returns to pending.
A page's author should not be its only reviewer. If you can start a subagent or a fresh session, give it this section and let it judge. It only reads; you record its verdicts.
-
List.
scripts/review.sh <wiki> pending [--page <slug>]prints every unreviewed claim beside its cited lines. Cited lines start with>; two lines around them, and the line they sit inside, are shown for orientation. Markers that stand side by side after one sentence are one claim: it lists every range, and you judge them together. -
Judge each claim against its
>lines:Verdict When supportedThe cited lines show that the claim is true. partialThe claim is true, but the cited lines show only part of it. unsupportedThe cited lines don't show it, or the claim is wrong. - Read more of the file when you need to (
git -C <repo> show <sha>:<path>), but judge the cited lines. A claim that is true only because of other lines ispartial. - Every number, name, limit and order of events in the claim must be in the cited lines. A constant's name is not its value: "waits 5 s" needs the line that sets the 5.
- Context shows the paragraph or table row around the claim, with the claim
in
[[ ]]. Use it to see what the claim is about (a table cell is about its row), but judge only the claim: other sentences and cells carry their own citations. Step "<title>":at the start of a claim is the step's label on the page.- A claim that is only a table's header cell is about its whole column: judge every cell of that column against the cited lines.
- A default value counts as the value: ignore environment overrides unless the claim is about them.
- A "Diagram box" claim is supported when the cited lines are the code that does what the box names.
- When in doubt, choose
partialand say what is missing. Never guesssupported.
- Read more of the file when you need to (
-
Record. Write the verdicts to a file and apply them.
partialandunsupportedneed a note that says what is missing or wrong.# verdicts.json: {"by": "<who judged>", "verdicts": [{"id": "<id>", "verdict": "partial", "note": "<what is missing>"}]} scripts/review.sh <wiki> apply verdicts.json scripts/review.sh <wiki> set <id> supported --by "<who judged>" # one at a time -
Fix every
partialandunsupportedclaim: correct the sentence, or cite the lines that do support it. The fixed claim is pending again, so review it again. Never change a verdict to make Check pass. -
Check.
scripts/check.sh <wiki>fails on anunsupportedclaim and warns onpartialand unreviewed ones.scripts/review.sh <wiki>alone prints the summary;show <id>prints one claim with its verdict.
Log format
## [YYYY-MM-DD] build | <repo> at <short sha>
- Pages: <slug> (L0); <slug> (L1); ...
- Deferred: <topic>: <why, and what unblocks it>
- Check: PASS (<pages> pages, <citations> citations, <warnings> warnings)
- Review: <n> cited claims: <n> supported, <n> partial, <n> unsupported, <n> pending; by <who judged>
Operations: build, update, check, review; promote and drop are written
by scripts/candidates.sh. Use today's date. Append only.
Credits
Explainer rules adapted from archify (Apache-2.0). The grounding rule and log format follow Astro-Han/karpathy-llm-wiki (MIT). The test for when to draw a diagram follows cathrynlavery/diagram-design (MIT).