ID:WORK-155Status:done
Build refrakt reference CLI commands
Priority:highComplexity:moderateSource:SPEC-041
4c6e7a54b9df5aThe user-facing surface of SPEC-041: three subcommands under refrakt reference that emit rune syntax docs derived from the now-shared infrastructure (WORK-149), the content-model renderer (WORK-150), and the attribute preset registry (WORK-151).
refrakt reference <name> — print one rune's syntax referencerefrakt reference list — enumerate available runesrefrakt reference dump — write the full reference to a file (default AGENTS.md)packages/cli/src/commands/reference.ts exists, exporting the three subcommand handlersinspect, contracts, validaterefrakt reference <name> prints markdown by default; --format json emits the structured RuneInfo shape with attributes.own, attributes.base, attributes.universal, contentModel, authoringHints, examplerefrakt reference <name> exits 1 with a clear message when the rune isn't recognised in the merged config; exits 2 on invalid args / missing configrefrakt reference list groups runes by source package; supports --package <name> filter; supports --format jsonrefrakt reference dump writes a complete reference document to --output (default AGENTS.md); supports --format markdown (default) and --format jsonrefrakt reference dump --check exits 1 if the output file is out of date relative to the current config (CI gate)--section-named block in an existing file rather than clobbering it (so users can interleave human notes)--config <path> to locate refrakt.config.json; defaults to cwdpackages/cli/src/commands/reference.ts with three exported handlers.refrakt.config.json, run mergePackages() to get the full rune set, then call describeRune() (markdown) or build the JSON shape directly.lookupAttributePreset() from WORK-151 to identify presets per rune.--check mode runs the same render in-memory and compares to the file contents (string equality); exit 1 with a diff hint on mismatch.packages/cli/src/index.ts (or wherever subcommand registration lives).packages/cli/test/commands/reference.test.ts.authoringHints)--format json)Completed: 2026-04-19
Branch: claude/scaffold-landing-docs-cli-DB31i
packages/runes/src/reference.ts — promoted the full reference-rendering pipeline into @refrakt-md/runes so both the CLI and create-refrakt can share it. Added:ReferenceContext interface (runes + fixtures + per-rune source map)hydrateRuneInfo / hydrateAllRuneInfos / hydrateRuneByName — resolve RuneLike objects into full RuneInfo with content model + base presetSerializedAttribute / SerializedRune / serializeRune — JSON shape used by both reference <name> --format json and reference dump --format jsonReferenceGroup / groupReferenceInfos — core-first then alphabetical package groupingRenderReferenceOptions / renderReferenceMarkdown — full dump renderer with TOC, Universal Attributes, Attribute Presets, per-package rune blocksdescribeRune are now wrapped in ```markdoc fences so raw # headings inside examples don't pollute the document heading structurepackages/runes/src/index.ts — exports all the new reference symbolspackages/cli/src/commands/reference.ts — three thin handlers (referenceNameCommand, referenceListCommand, referenceDumpCommand) that delegate to the runes package. Keeps only CLI-specific concerns: file IO, --check comparison, --section replacement. A fence-aware findNextHeading ensures section replacement doesn't get confused by # headings inside fenced example blocks.packages/cli/src/bin.ts — reference dispatcher, unified parseReferenceArgs, and buildReferenceContext that loads refrakt.config.json, merges packages, assembles theme config (so attribute presets register), applies aliases, and loads local runes. Exit codes: 0 success, 1 unknown rune / check failure, 2 invalid args.packages/cli/test/reference.test.ts — 20 tests covering markdown + JSON output for all three subcommands, alias resolution, universal-attribute categorization, child-rune exclusion, --check behavior across up-to-date/stale/missing file cases, section preservation, determinism, and custom preambles.@refrakt-md/runes (not @refrakt-md/cli) so the upcoming create-refrakt integration (WORK-156) can render AGENTS.md without shelling out or depending on the CLI package.describeRune example blocks are now fenced as ```markdoc — a semantic improvement that also fixes an edge case where raw H1/H2 text in an example (e.g. the form rune's # Contact Us) would leak into the document's heading structure and break --section replacement.findNextHeading walks lines with a fence-state toggle so it won't match headings inside code fences — belt-and-suspenders on top of the fencing change above.