Writing Taji docs
This page tells you, a person or an agent, how to add or rewrite a page: which type it is, which template and worked page it starts from, how its examples are captured, and which tests hold it. Source of truth: this page; engine/crates/taji/tests/docs.rs holds links, paths, examples, templates, ADRs and plugin pages. docs/README.md indexes every page, and the site's tabs, sidebars, landing and llms.txt come from it.
Add a page
- Pick the page's type below and copy its worked page, or start from its template.
- If the page shows output or a picture, write the page first, its
file=fences empty, and the example's source indocs/<section>/examples/<slug>/(see Examples); a recipe's<slug>is its page's stem. - Add one bullet to
docs/README.md: a link to the page, labelled, then a colon and one sentence. - Run
make docs-capture EXAMPLE=docs/<section>/examples/<slug>to fill the fences, thenmake docs, which also type-checks every example's.ts(itstype-checkstep).
That is three files by hand (the page, the source, the bullet) and two commands. A page that needs a change anywhere else (the harness, a test, a template, docs-site/) gets it in that mechanism, once, never as a special case in the page.
Rules for every page
- One reader and one type per page.
- Plain GitHub Markdown: no frontmatter, no MDX, no HTML. The H1 is the title. A placeholder in angle brackets goes in a code span or a fence, since raw HTML is live on the site.
- The first paragraph says, in one or two sentences, what the reader will have or know. A tutorial or how-to then has a "You need" line.
- Second person, present tense, no hedging, full sentences. Teach: define a term where it first appears and link the glossary; say why after what; an example before the general rule; one idea per paragraph. There is no word cap; cut what carries no information.
- A link to another page is a relative Markdown link; a code path is a code span. Both must resolve. Name only tracked, public paths.
- A page is added to
docs/README.mdin the same change, as one bullet with a one-sentence description. - A page ends with
## Next(tutorial, how-to, recipe: two to four links) or## See also(the rest).
Page types
Each type is one of Diátaxis's four kinds: Tutorial and Quickstart are tutorials; How-to and Recipe are how-to guides; Reference, coverage and the skill's references are reference; Explanation, Comparison, ADR and architecture pages are explanation. A new page starts as a copy of its type's worked page; a type with none starts from its template.
| Type | Worked page |
|---|---|
| Tutorial, Quickstart | docs/guide/first-session.md |
| How-to | docs/guide/agent.md |
| Explanation | docs/guide/what-is-taji.md |
| Comparison | docs/indicators/pine.md |
Templates
Tutorial / Quickstart. The title says what you will have. One path, no branches. Steps are numbered H2s ("## 1. Launch Taji"); each is an action, then what you see (a screenshot or a captured block), then one or two "what changed" bullets. Then ## If something goes wrong (the message as Taji prints it, its cause, its fix) and ## Next.
How-to. The title is the task. Result and needs first; numbered steps with exact commands; ## If it fails only for a known cause: symptom, cause, fix. Explanation beyond two sentences becomes a link. End with ## Next.
Recipe (docs/cookbook/<slug>.md). The title is what it does. One sentence, then a "You need" line, then the example format, then ## Change it (two or three variations, each a diff of a few lines) and ## Next; it also gets one row in docs/cookbook/README.md.
Explanation. The opening paragraph is the claim. Then a diagram of the model; then sections titled by the question they answer ("What happens when a tick arrives?"), not by a fixed scheme; one worked example with real output; refusals and limits where they bite, each with its reason and its ADR. No command tables. End with ## See also.
Comparison. Every statement about the other product cites its current page with the fetch date, as a footnote, and a table sets the two side by side. A page on another product, such as Taji vs TradingView and Pine Script, opens with that table, then what Taji does that the other cannot: what a user sees and cares about, not a feature list.
Reference. The title is the thing. The first line names its source of truth, as a code span, and the test that holds it. One heading per item, in the code's order: a line of purpose, type and default, one snippet. No rationale. A generated page's first line after the title is "Generated by <command>; do not edit."
ADR (docs/decisions/NNNN-<slug>.md, MADR minimal). The title is # NNNN. <the rule as a sentence>; the first line is Accepted <YYYY-MM-DD>.; then ## Context, ## Decision, ## Alternatives (each rejected option, one line why), ## Consequences, ## Held by (the test, gate or review check). An ADR that exists is in force: no status field. Adding, pruning and compacting: docs/decisions/README.md.
Plugin page (plugins/<id>/README.md). Headings in this order, each required only where its condition holds:
# <name>: exactly the manifest'sname, or a pane's window title. Then one to three sentences on what it gives you.## Before you linkand## Link, when the manifest has[[link]]: the account, plan and cost; then everyformas a code span and where to start it (the Connections page ortaji-link <form>).## What it needs, a feature plugin (taji-*) only: its first line the data it reads and which providers serve it, which the docs home shows; then the detail, linkingdocs/reference/coverage/data.md.## What you get, linkingdocs/reference/coverage/<id>.md, when that page exists; otherwise## Use(tasks, as steps).## Reads, panes only: a link to each section ofdocs/reference/coverage/panels.mdwhose panel the pane draws; with no section of its own,panels.md#first-paintand its row.## Behaviour and limitsand## Open, when the coverage page exists: first line, how and when the facts were measured, with the labels its entries carry (Pthe vendor's own page or spec,Dits OpenAPI document,Sa community source,Uinferred,Mmeasured); then each measured section as a###, verbatim; then what is unmeasured.- Optional, last:
## Unlink,## If it fails,## References.
No other ## heading. docs/plugins/README.md's catalog links every page: plugin_pages fails one it does not.
Architecture page (plugins/<id>/ARCHITECTURE.md, a plugin whose manifest has about and a [[sources]] or [[link]]), for whoever changes, debugs or builds on the integration. Depth means facts. Headings in this order, one omitted only where its subject is absent (a keyless source has no auth, a channel no orders):
# <name>: how it works, the manifest'sname; then the vendor, what Taji takes from it, the crate's shape.## The vendor: hosts and environments, auth and token lifetimes, each API family called and its version, accounts and entitlements, stated limits, each linked to its official page with the date fetched; what Taji does not use, and why.## Code map: each file, one line: what it owns; the entry point first.## How it plugs into Taji: the SDK traits,FACTS,VenueFacts,OFFER, the link forms; a table of each Taji surface, the vendor call and the file; one read's and one order's (a channel: one message's) path from the wire to the vendor and back.## Why it is built this way: each choice and its reason (an ADR, a ruling, a measurement).## Constraints and limits: the mechanisms; the numbers stay in the plugin page's measured###sections, linked.## Examples: real exchanges only, each naming its source (a fixture, a live test's or walk's output, the wire fixture), ids masked<ACCT>orpN; none captured, "No capture yet" and what would make one.## Testing: fixtures, offline and live tests, walks: commands, and which need a key, paper or SIM.## References: official links with fetch dates.
No other ## heading. The plugin page links it under ## References.
Examples
Examples are real, and only the capture harness writes their output. Nobody types or pastes output, and nobody edits a picture.
An example is a directory docs/<section>/examples/<slug>/ beside its page. By hand it holds one of:
- One indicator source,
<name>.ts, and nocalls.json.<name>is the indicator's definition name,[a-z][a-z0-9_]*, 64 at most (ema_cross.ts, notema-cross.ts) and no built-in's (prior_day_levelsis taken:GET /read/cataloglists them), and its inputs and plots share one namespace. The harness checks it, writes it to the boot desk, binds it to chart 1, waits for its rows to stop growing, keeps the newest 10 as<name>.jsonand photographs the pane asshot.png. You name no route. Arows.jqbeside it picks other rows: a jq filter over all the rows, oldest first, whose array is<name>.json(rows.jqofema-crosskeeps the 10 ending with the latest cross). It is a source. calls.json, an ordered list of wire requests:{"name", "method", "route", "body"?, "until"?, "meta"?, "shot"?};{"name", "stream", "body"?, "take"}to open the wire's WebSocket at that path (/ws/market) with the token, sendbodyand keep its firsttakeframes; or{"name", "fixture"}to copy a file fromengine/crates/taji/tests/fixtures/wire/instead of calling, for an answer a keyless kernel cannot give (a refusal, since a non-2xx answer fails the example). Each answer is<name>.json, whole: Arrow as records,{"metadata", "rows"}with"meta": true(the schema's metadata, the envelope a reader needs, beside the rows), and a stream's an array of{"header", "rows"?}."until"is a jq filter over the answer: the call repeats a second apart, up to 60 s, until it is true ("length >= 1"for a product whose first row comes later).{desk}in a route or body is the boot desk, and{<name><jq filter>}that filter of an earlier answer ({bind.node | split("/") | last}); in a body, a string that is one ref whole takes the value with its JSON type ("anchor_pane_id": "{layout.chart_pane_id}"is a number), and a ref inside longer text is text;{"$file": "<path>"}in a body is that file's text, the path relative to the example directory (../first-indicator/pulse.ts), andcapture.jsonrecords the file as a source, so editing it without recapturing failsexamples_are_captured;"shot": truephotographs the desk's chart pane after all the calls, and"shot": "<ref>"the pane that ref names ("{pane.pane_ids[0]}"after anadd_pane), shot in Taji's own window, the only page that draws a plugin's pane, sowindow/distmust be built (pnpm --filter @taji/window build).- Either may add
setup.sh, run in the example directory after boot withSTATE,PORTandTOKENset, andTAJI_STATE_DIR,TAJI_STORE_DIR,TAJI_HOMEandTAJI_WIREnaming the capture's kernel, so atajicommand there acts on it;plugins, one repo-relative plugin directory a line (plugins/taji-gex), each staged into the kernel'sTAJI_PLUGINSas a person's holds it, its program taken from wheretaji plugin devfinds it and its window half (aplugin.tsxin itsui/, its layer builders) packed byui/pack.tsinto the staged copy alone (an unbuilt program or a failed pack fails the example, naming the build command or the pack's output; a plugin written for the page lives in the example directory,docs/plugins/examples/<slug>/<id>/, and every file in it is a source); ordev, one plugin directory whosefixtures/the kernel plays: the harness runstaji plugin dev <dir> --headlessinstead of its own kernel and photographs that desk. Not both. Each is a source.
On a page, the example appears in this order:
- The whole source file in one fence, opened with its language (in a recipe, its first fence but a command, diagram or diff),
file="examples/<slug>/<name>"andtitle="<name>", runnable as it stands. Leave it empty: the harness fills it with the file, byte for byte. - The picture,
examples/<slug>/shot.png, as a Markdown image whose alt text says what it shows. - A numbered walk, one item per block of the file, each led by the code it explains in bold.
- Each output in its own fence with
file="examples/<slug>/<name>.json". It is the whole answer: bound the request (a limit, a range), never trim the answer. - A caption line in italics,
*Captured YYYY-MM-DD on <where it ran>.*(a headless kernel and the made-up data it read, or the fixture path as a code span), the date and place read from the example'scapture.json. EveryCaptured <date>on a page is the date of an example the page links.
A shell fence holds commands only, so Copy copies something runnable; what they print goes in a text fence. In a tutorial, how-to or recipe every other fence carries file=.
The capture harness
make docs-capture EXAMPLE=docs/<section>/examples/<slug> runs engine/crates/taji/scripts/docs_capture.sh on one example; with no EXAMPLE, on every one. Per example it boots its own headless kernel with no key on new mktemp -d state, store and home directories (or taji plugin dev's, for dev), makes the calls, and ends the kernel on every exit path. Then it replaces the last capture's outputs, writes capture.json (the market date, the checkout's commit, where it ran, each source's and output's SHA-256) and sets every file= fence in the pages beside examples/, warning when no page links the example.
It builds nothing: build the kernel and the UI bundle first. Its header lists what it needs (the checkout's Python from make setup, jq, bun, each plugins or dev plugin built where taji plugin dev looks: $CARGO_TARGET_DIR, else <dir>/target). It needs no key, no market hours and no network for market data: the kernel's market is made up: the keyless sources (Yahoo, EDGAR, Cboe and SSGA) are off from boot, dev kernels too, the cookbook's csv-source serves a seeded daily series for SPY and QQQ, so recapturing gives the same daily figures, and plugins/samplefeed serves their minute bars, quotes and option chains, which follow the clock. An example that needs another product plays a plugin's own fixtures/ through dev, or cannot be captured. Exit code = examples that failed.
Diagrams, callouts, tabs
Diagrams are Mermaid fences (flowchart LR or sequenceDiagram), nine nodes at most, labels from the glossary, one concept each, followed by a sentence that reads the diagram. GitHub draws them plain; the site draws them hand-sketched. No image of a diagram.
Callouts are GitHub alerts (> [!NOTE], [!TIP], [!IMPORTANT], [!WARNING], [!CAUTION]), two a page at most; the last two are for money and what cannot be undone.
Tabs are adjacent fences whose info string ends tab={"label":"macOS"}, for the same step per OS or package manager only. Each fence opens with a comment naming its variant, so a reader on GitHub can tell them apart.
The site adds a page menu (copy the page, view its Markdown, open it in an assistant) to every page; you write nothing for it, and a page must read correctly as raw Markdown.
The tests that hold them
All in engine/crates/taji/tests/docs.rs; cargo test -p taji --test docs runs them, pnpm --dir docs-site exec node --test test/anchors.test.ts checks every #fragment a page links against the target's headings without a build, and make docs builds the site with every link and anchor checked.
| Test | Fails when |
|---|---|
paths_resolve | a relative link or a code-span path does not exist |
every_page_is_indexed | a page under docs/ is not linked from the index, or a file there is neither Markdown nor part of an example |
llms_txt_indexes_the_docs | the root llms.txt misses a page the index links |
examples_are_captured | an example has no capture.json, holds a file that is neither a source nor a named output, a hash does not match (an output edited by hand, a source changed and not recaptured), a file= fence differs from its file, a page shows an image that is not an example's shot.png, a Captured <date> or *Captured caption is not the date of an example the page links, or no page uses an example |
pages_follow_their_template | a page listed in its TEMPLATED table breaks its type's checks above (numbered steps, the closing heading, a Mermaid fence, a "Where " heading, a source of truth, file= on every fence but sh, diff and mermaid, a recipe's first other fence from its own example) |
decisions | an ADR breaks its template or is not indexed |
plugin_pages, architecture_pages | a plugin page or architecture page breaks its template |
schema_defs_documented, env_vars_documented | a reference page misses a schema type or names a variable the code does not read |
A rewritten page joins TEMPLATED in the same change.
One owner per fact
| Fact | Owner |
|---|---|
| What to read before editing a directory, commands, rules | AGENTS.md |
| A crate's role; every route | the //! atop its lib.rs; the //! header of engine/crates/taji/src/wire/mod.rs |
| How an agent drives Taji; how a script or indicator is written | agent/skills/taji/ (ships in packages: never depends on docs/; docs link into it) |
| How an indicator runs, and why | docs/indicators/ |
| How a person connects and bounds their agent | docs/guide/agent.md |
| A plugin's identity, link forms, steps, risk and refusal words | its taji-plugin.toml; the page retypes no step |
| Measured vendor behaviour, limits, open items | the plugin's page |
| How a vendor integration works, and why | plugins/<id>/ARCHITECTURE.md |
| What a provider serves, cell by cell | docs/reference/coverage/ |
| An example's output, picture and date | its capture.json, written by make docs-capture |
| Why a rule stands | its ADR in docs/decisions/ |
| Which checks a change needs | docs/contribute/testing.md; each command's own words stay in AGENTS.md |