machina-explorer
machina-explorer is an experimental browser-based UI on top of machina-inspect. Paste a config object, click Analyze, and the app runs structural checks and renders a mermaid state diagram — no build step, no backend.
What it does
Section titled “What it does”- Paste and analyze: Drop a raw FSM config object into the editor and click Analyze. The app evaluates it via
new Function(), builds the state graph withbuildStateGraph(), and runs all structural checks withinspectGraph(). - Inspect findings: Findings are grouped by type — unreachable states,
_onEnterloops, missing handlers. A clean config shows a confirmation instead. - State diagram: Generates a
stateDiagram-v2mermaid diagram from theStateGraphIR. Possible transitions (conditional returns) are labeled with(?). Child FSMs appear as nested subgraphs. - Handler notes toggle: Optionally overlay the list of handler keys (including
_onEnterand_onExit) on each state node in the diagram. - Export: Copy the raw mermaid source to clipboard, or download the rendered diagram as a PNG.
Architecture
Section titled “Architecture”Vanilla TypeScript, no framework. Two panels: CodeMirror 6 editor on the left, findings + diagram on the right.
The core new piece is mermaid-generator.ts — a pure function that converts a StateGraph + config object into a mermaid stateDiagram-v2 string. It has no DOM dependencies and could be extracted to a CLI or server-side tool.
Key pattern: eval → inspect → diagram
Section titled “Key pattern: eval → inspect → diagram”The graph is built once and stored. The handler notes toggle only re-runs generateMermaid() and renderDiagram() — eval and inspect don’t run again.