Converts a call tree into a JSON-ready plain-data structure.
The tree from CodeStory.narrate/2 is a list of
%{module, function, args, return, children} node maps (folded nodes may also
carry count:/varies:). encode/2 turns that into a list of plain maps whose
values are only strings / numbers / booleans / nil / lists / maps — so
JSON.encode!/1 (Elixir 1.18+) or Jason.encode!/1 works without any change.
Compaction is opt-in — the default is a faithful, complete encode:
:fold_repeats(defaultfalse) — collapse repeated sibling runs viaCodeStory.Fold; folded nodes surfacecount/variesfields.:depth(default:infinity) — cap nesting. At the cap a node encodeschildren: []andtruncated: <levels hidden>(the data-native mirror of the formatter's… (N more levels)marker).:detail(default:novel) — value verbosity.:novelkeeps full values; any other value (:short_story,:outline) uses the compact inspect opts.