Developers / 09
CLI Report Generator
taraflow-report — a headless entry point that generates the exact same documentation as the Documentation tab, from a saved .tara.json file, with no UI and no Electron. Built for CI/CD pipelines and containers where launching the desktop app isn't practical.
01
Entry-point separation, not a runtime switch
- Two independent entry points share only the pure generation core:
main.tsx(Electron/browser renderer) andtaraflow-reporter/taraflow-report.ts(plain Node) — there is no branch inmain.tsx/app.tsxthat decides "am I headless?" - The purity boundary (invariant): no module in the generation path (
features/documentation/{models,utils}/**) may import a feature barrel (features/*/index.ts),react,react-dom,@mui/*, draw.io, or any module with a top-levelwindow/documentreference.import typeedges are exempt — they're erased at build time and carry no runtime weight - The boundary is enforced with a
dependency-cruiserrule (utils/depcruise-doc.cjs), run as a CI-failing step - The renderer's own PDF path (
pdf-generator-renderer.ts, window/IPC-based) and the UI'sdoc-generator.tsfactory are never touched — the CLI gets its own factory (cli-generators.ts) that imports the four pure generators directly, never through the barrel that would drag in the renderer's PDF module
02
What changes vs. what's additive
- Exactly one category of change touches existing files: swapping barrel imports for deep-path imports in the generation path (e.g. DFD formatters, risk mitigation helpers, threat catalog resolvers, shared tag utilities) — runtime-identical, the renderer resolves the same functions as before
- Everything else is additive: new files under
taraflow-reporter/: the entry with argument parsing (--format,--lang de|en,--out,--chapters) andcli/(Node DOM parser, Node-side i18n init, project loader, chapter resolution,Project → DocProjectDatamapper) - The i18n singleton is reused as-is in Node once initialized with a filesystem resource backend instead of the browser's — namespaces actually used by templates/mappers must all be registered, or raw i18n keys leak into the report instead of labels
03
Loading a project outside the app
- No
storage-servicedependency (that's Electron/browser-coupled) — a plainfs.readFile+JSON.parse, followed by the same schema migrations the app runs on load (risk data, asset configuration, factor ratings) - The project's
computedmaps (e.g.impactLabels) must be present as emptyMaps, neverundefined— the base generator accesses them with a nullish-coalescing fallback on the value, not on the map itself attackTree(singular, inDocProjectData) maps fromproject.attackTrees(plural) — a naming mismatch worth knowing about before it causes a silent empty section- The on-disk DFD thumbnail is already a base64 SVG — reports embed it directly, no headless draw.io instance needed; leveled DFDs store one thumbnail per page
- The DFD XML is parsed with
@xmldom/xmldomin Node, so the CLI runs the same leveled analysis (effective model, table groups, parent-level flows) as the app
04
Build & packaging
- Its own
tsconfig.cli.json(extends the base config) keeps the renderer's build untouched; path aliases (features/*,shared,i18n) are resolved viatsx+tsconfig-paths, or bundled withesbuild --platform=node --format=esmand--aliasflags mirroring the sametsconfigpaths;pdfmakeand@resvg/resvg-jsstay external and are installed intodist-cli/node_modules - Distributed as a standalone
.debpackage (depends only onnodejs; the two runtime modules ship inside), decoupled from the Electron desktop installer — installstaraflow-reportstraight to/usr/bin - PDF without a headless browser:
pdf-generator-node.tsbuilds the document withpdfmake0.3 and rasterizes the DFD SVG with@resvg/resvg-js— no Puppeteer, no Electron
05
CI guardrail
- The
dependency-cruiserrule runs as a hard CI failure: any reintroduced barrel/react/draw.io import in the generation path breaks the build immediately, not just a lint warning - A smoke test generates a report from a fixture project and asserts the output is non-empty and contains the expected chapter titles
- The CLI binary itself runs against that fixture as a CI job, not just its library code in isolation
06
Sibling: taraflow-verify
- A second headless binary in
taraflow-verifier/runs the Audit Verification Engine against a git repository:taraflow-verify <repo> (--anchor <hash> | --policy <file.json>) [--ref --strict --four-eyes --protected b1,b2 --json] - Exit codes for CI: 0 pass · 1 findings · 2 usage · 3 engine error (git missing, not a repository, unresolvable ref)
- Same engine core as the app (
features/audit/services/verify), git through one exec adapter; packaged as its own.debdepending onnodejsandgit