{"name":"@deckyard/fsm","description":"Finite state machines: define states and transitions, check the definition, fire events with guards and hooks, load from TOML, YAML or JSON, draw as Mermaid or Graphviz","versions":{"0.1.0":{"version":"0.1.0","kind":"git","url":"https://github.com/deckyard/deck-fsm.git","ref":"0.1.0","commit":"2c6276d5991af8fe5fa6c6d4fd45a08eb6280d53","checksum":"","yanked":false,"license":"LGPL-3.0-only","requires":{},"engines":{"jennifer":"\u003e=0.25.0","jennifer-tiny":"\u003e=0.25.0"},"capabilities":[],"keywords":["fsm","state-machine","workflow","states","transitions"],"description":"Finite state machines: define states and transitions, check the definition, fire events with guards and hooks, load from TOML, YAML or JSON, draw as Mermaid or Graphviz","publishedAt":"1793739816","repoId":1444795815,"repoOwnerId":346943577,"repoOwner":"deckyard"}},"readme":"# @deckyard/fsm\n\n[![test](https://github.com/deckyard/deck-fsm/actions/workflows/test.yml/badge.svg)](https://github.com/deckyard/deck-fsm/actions/workflows/test.yml)\n[![Documentation](https://img.shields.io/badge/docs-github%20pages-blue)](https://deckyard.github.io/deck-fsm/)\n[![release](https://img.shields.io/github/v/release/deckyard/deck-fsm)](https://github.com/deckyard/deck-fsm/releases/latest)\n\nFinite state machines for [Jennifer](https://jennifer-lang.dev/): define\nstates and transitions, fire events with guards and enter and leave hooks,\nand keep the current state wherever the program already keeps its data. A\nmisspelt state or a transition that could never be taken fails when the\nmachine is built; `check` finds unreachable states and dead ends. Machines\nload from TOML, YAML or JSON and draw as Mermaid or Graphviz.\n\n**[Documentation](https://deckyard.github.io/deck-fsm/)**\n\n## Install\n\n```sh\njvc add @deckyard/fsm\n```\n\nThis vendors the deck to `vendor/\u003cscope\u003e/fsm/`. Without `jvc`, unpack the\n`src/` subtree of a release archive (`\u003cscope\u003e-fsm-\u003cversion\u003e.tar.gz`) there.\n\n## Usage\n\n```jennifer\nimport \"@deckyard/fsm/\" as fsm;\n\ndef m as fsm.Machine init fsm.machine(\"door\", \"closed\");\n$m = fsm.addStates($m, [\"open\", \"locked\"]);\n$m = fsm.addTransition($m, \"open\", [\"closed\"], \"open\");\n$m = fsm.addTransition($m, \"close\", [\"open\"], \"closed\");\n$m = fsm.addTransition($m, \"lock\", [\"closed\"], \"locked\");\n$m = fsm.addTransition($m, \"unlock\", [\"locked\"], \"closed\");\n\ndef state as string init \"closed\";\n$state = fsm.fire($m, $state, \"lock\", {}).target;\nio.printf(\"%s, can %v\\n\", $state, fsm.events($m, $state, {}));   # locked, can [\"unlock\"]\n```\n\n## Requirements\n\nJennifer 0.25.0 or newer, `jennifer` or `jennifer-tiny`. No capabilities:\nthe deck is pure computation.\n\n## Development\n\n```sh\ntools/check-all.sh                   # the full gate, as CI runs it\njennifer test src/fsm_test.j         # the test overlay\ntools/check-docs.sh                  # docs against the code\ntools/pack.sh dist                   # build the release archive\n```\n\n## Licence\n\nLGPL-3.0-only, see [LICENSE](LICENSE). Copyright (C) 2026 mplx \u0026lt;mplx@jennifer-lang.dev\u0026gt;.\n\n`tools/check-headers.sh` checks every source file's SPDX header against\n`deck.toml`.\n"}