Skip to main content

Swamp Diagrams

@taylor/swamp-diagramsv2026.11.07.1· AGPL-3.0-or-later· 18d agoBEHAVIORSACCEPTED WARNINGS
01README

Diagrams of swamp workflows and of behaviors' state machines, drawn as a light and dark SVG pair (or as Mermaid). workflow draws workflows as flowcharts: a box per job, a node per step, and dependsOn arrows labelled with their condition. stateMachine draws a behavior's phases and the methods that move between them, from the transition lines in a published extension's description (such as @swamp/issue-lifecycle), a file or passed in, with the main path down the middle, failure and detour phases beside it, loops, retries and human-only gates marked, and notes alongside. Diagrams are written next to Markdown docs and embedded in marked blocks with a that follows GitHub's light and dark modes; with format=mermaid they can be rendered to SVG or PNG with the mermaid-cli container.

02Behaviors1
@taylor/swamp-diagrams/diagramv2026.11.07.1swamp_diagram.ts

Global Arguments

ArgumentTypeDescription
format?enumsvg: a light and dark SVG pair drawn with a fixed, hand-drawn-style layout, shown with a <picture> element; mermaid: Mermaid source that GitHub draws itself
theme?enumColours: auto (reads on light and dark pages; GitHub draws it in the reader's mode), dark (teal on black), light, both (auto source, images rendered as a -dark and -light pair), or none (Mermaid's default theme, no colours)
direction?enumLayout: TD (top-down) or LR (left-to-right)
render?enumformat mermaid only: also render an image with the mermaid-cli container (needs Docker)
outputDir?stringFolder, relative to the repository, to also copy the diagram files into (empty = keep them in swamp data only)
embedIn?stringMarkdown file or folder, relative to the repository, whose <!-- swamp-diagram: <name> --> … <!-- /swamp-diagram --> blocks get the diagram: a <picture> of the SVG pair (saved in a diagrams/ folder beside the Markdown file) or a mermaid code block (empty = none)
copyFiles?arrayWhich files to copy into outputDir
registryUrl?stringswamp extension registry that stateMachine reads descriptions from
dockerPath?stringDocker CLI binary
mermaidImage?stringmermaid-cli container image used to render SVG or PNG
fn workflow(name?: string, dir?: string, path?: string, title?: string)
Draw swamp workflows as flowcharts: each job a box of its steps, each dependsOn an arrow labelled with its condition. Draws every workflow in workflows/ unless name or path picks one
ArgumentTypeDescription
name?stringWorkflow name, ID or file name (empty = every workflow found)
dir?stringFolder to look for workflows in, relative to the repository: it and every workflows/ folder beneath it (e.g. .. to draw every extension's workflows in a monorepo)
path?stringA workflow YAML file to draw instead, relative to the repository or absolute
title?stringDiagram title (defaults to the workflow name)
fn stateMachine(extension?: string, transitions?: string, path?: string, backEdges?: enum, title?: string, subtitle?: string, hideStates?: array, collapseStates?: array, omitMethods?: array, humanGates?: array, highlightStates?: array, failureStates?: array, notes?: record, showComments?: boolean)
Draw a behavior's phases and the methods that move between them, from transition lines ('from ──[method]──> to') in a published extension's description or passed in
ArgumentTypeDescription
extension?stringPublished extension whose description holds the transitions, e.g. @swamp/issue-lifecycle
transitions?stringTransition lines to draw instead, one per line: 'from ──[method]──> to'
path?stringA file to read the transition lines from instead, relative to the repository (other lines are ignored, so it can be the docs page itself)
backEdges?enumA step back to an earlier phase: retry (red, labelled '(retry)') or normal (routine, like start after stop)
title?stringDiagram title (defaults to the extension name)
subtitle?stringA line shown under the title
hideStates?arrayPhases to leave out; their transitions become entry or exit arrows (e.g. created)
collapseStates?arrayPhases to skip over: each way in is joined to each way out (e.g. verifying)
omitMethods?arrayMethods whose transitions are left out, to keep the diagram to the main path
humanGates?arrayMethods only a person may run, drawn as thick green arrows (e.g. approve)
highlightStates?arrayPhases to emphasise, besides the final ones (which always are)
failureStates?arrayPhases to draw as failures, besides any whose name contains 'fail'
notes?recordA short note to show under a phase, keyed by phase
showComments?booleanAdd each transition's parenthetical comment to its arrow

Resources

diagram(infinite)— A diagram's Mermaid source, what it was drawn from, and where it was copied

Files

mermaid(text/plain)— Mermaid source (.mmd)
markdown(text/markdown)— Markdown file with the diagram in a mermaid code block
image(image/svg+xml)— The diagram rendered to SVG or PNG (when render is set)
03Previous Versions3
2026.11.06.3AGPL-3.0-or-later
2026.11.06.2AGPL-3.0-or-later
2026.11.06.1AGPL-3.0-or-later
04Stats
A
100 / 100
Downloads
17
Archive size
72.0 KB
  • Has README or module doc2/2earned
  • README has a code example1/1earned
  • README is substantive1/1earned
  • Most symbols documented1/1earned
  • No slow types (deprecated)1/1earned
  • Dependencies pass trust audit2/2earned
  • Docs keep secrets in a vault1/1earned
  • Has description1/1earned
  • Platform support declared (or universal)2/2earned
  • License2/2earned
  • Verified public repository2/2earned

06Platforms
07Labels