| name | sfsm-uml-diagram-to-json |
| description | Extract an SFSM FA definition JSON file in compact format from a draw.io UML state diagram. Use when asked to convert, export, or reverse-engineer a diagram back into SFSM/StOP JSON. |
| metadata | {"author":"vsirotin","version":"2.0"} |
UML State Diagram (draw.io) → SFSM Compact JSON
This skill wraps the ts/ts-stop/scripts/drawio-to-json.js script to extract or reverse-convert a draw.io diagram into a compact-format SFSM FA definition ready for Sfsm.loadFA().
Usage
Invoke the script directly or use this skill when you need to:
- Convert a draw.io diagram back to SFSM JSON format
- Reverse-engineer a manually drawn state diagram into a machine-readable FA definition
- Extract SFSM data from a diagram produced by the
sfsm-json-to-uml-diagram skill (lossless round-trip)
- Export a collaborator's visual diagram as a JSON file for programmatic use
How it works
The script reads a .drawio file and extracts every state, transition, and SFSM-specific metadata:
- Preferred: Diagrams generated by
json-to-drawio.js include custom metadata (sfsmRole, sfsmFa, sfsmKey, sfsmSignal, sfsmCommand) embedded in cell styles — these are read directly and trusted as ground truth.
- Fallback: Hand-drawn diagrams without metadata are parsed using shape-based heuristics (ellipses → states, swimlanes → sub-FAs, thick-bordered circles → exit states, etc.).
Output is a compact-format JSON object: { "<FaName>": [[from, signal, to], [from, signal, to, command], ...], ... }
Input/Output
- Input: A
.drawio file (ideally generated by json-to-drawio.js)
- Output: A
.json file in compact SFSM format
Command
cd ts/ts-stop
node scripts/drawio-to-json.js <input.drawio> <output.json>
Validation tip
After converting a diagram to JSON, compare the result against the original JSON using the compare-compact-jsons.js script or the sfsm-compare-json-uml-diagram skill to verify the round-trip was lossless:
node scripts/compare-compact-jsons.js <original.json> <output.json>
See 04-tools.md § 7.5.4 for detailed documentation.