Skip to main content

@siglo/cli Developer Tools & CLI Guide

@siglo/cli provides developer tooling, code scaffolding, static analysis, command-line inspection, architecture export, and regression testing utilities for Siglo workflows. It allows engineering teams to scaffold typed steps/workflows, visualize execution graphs, export to Mermaid/Graphviz/JSON, detect cyclic dependencies, inspect serialized checkpoints, and replay golden test fixtures in CI/CD pipelines.

1. Overview

@siglo/cli operates both as an executable terminal tool (Siglo) and as a programmatic TypeScript library:

2. Installation

Install @siglo/cli locally in your project or globally:

3. Command Line Interface (CLI)

The CLI executable is siglo.

General Usage

Global Options:

  • --format=mermaid|text|dot|json: Diagram representation or export format (default: mermaid).
  • --direction=TD|LR|TB: Graph layout direction for Mermaid or DOT diagrams (default: TD).
  • --out=<file>: Write output directly to a file instead of stdout.
  • --redact=key1,key2: Comma-delimited list of sensitive context keys or node names to mask with [REDACTED].
  • --port=<port>: Port number for the live monitor server (default: 4000).
  • --host=<host>: Host interface binding for the live monitor server (default: 0.0.0.0).
  • --namespace=<ns>: Filter telemetry events to a specific tenant namespace.
  • --help, -h: Show CLI usage guide.
  • --version, -v: Display CLI version.

Command 1: siglo init [dir]

Scaffolds a clean starter project preconfigured with Siglo, tsx, modern TypeScript config, and a runnable workflow test.

Generated Files:

  1. package.json: Contains scripts (npm test, npm start) and required dependencies.
  2. src/workflow.ts: Example order processing pipeline with validation and payment steps.
  3. src/workflow.test.ts: Automated test executing the workflow with assertions.

Command 2: siglo generate workflow <name>

Scaffolds a brand new typed workflow file and companion unit test powered by @siglo/testing.

Generated Files:

  1. src/workflows/order-processing.workflow.ts: Strongly-typed input/output interfaces, steps, and default workflow export.
  2. src/workflows/order-processing.workflow.test.ts: Test harness setup verifying end-to-end execution and step invocations.

Command 3: siglo generate step <name>

Scaffolds an isolated, strongly-typed Step module and companion unit test.

Generated Files:

  1. src/steps/send-notification.step.ts: Typed step module with input/output interfaces.
  2. src/steps/send-notification.step.test.ts: Direct step execution test.

Command 4: siglo visualize <workflow-file> [options]

Renders the workflow graph AST as either a Mermaid flowchart or an indented ASCII text hierarchy.

Mermaid Diagram (Default):

Output:

Text Diagram (--format=text):

Output:

Command 5: siglo export <workflow-file> [options]

Exports the workflow topology graph directly to standard formats for architectural documentation, diagrams, or web visualization:
  • --format=mermaid: Mermaid flowchart with policy badges (retries, timeouts, fallback).
  • --format=dot: Graphviz DOT format compatible with Graphviz tools and PlantUML.
  • --format=json: Comprehensive AST node/edge graph JSON.
  • --direction=TD|LR|TB: Graph layout orientation (top-down, left-to-right).
  • --out=<file>: Save result directly to a specified destination file.

Command 6: siglo validate <workflow-file>

Performs static analysis on the workflow graph AST without executing any step business logic:
  • Detects cyclic dependencies.
  • Identifies unreachable nodes or disconnected subgraphs.
  • Verifies combinator structures (parallel, branch, map).
Success Output:
Failure Output (Exit Code 1):

Command 7: siglo inspect <workflow-file> [options]

Returns a detailed JSON telemetry summary of the workflow topology, node classifications, edge connections, and total complexity metrics.
Output:

Command 8: siglo checkpoint <file> [options]

Parses and validates a serialized checkpoint state JSON file (e.g., dumped from Redis or PostgreSQL during debugging), summarizing step chains and execution context while masking sensitive credentials.
Output:

Command 9: siglo replay <fixture> [workflow-file]

Replays an end-to-end workflow execution using recorded inputs and validates that output values match golden expectations.
Success Output:
Regression Output (Exit Code 1):

Command 10: siglo monitor [workflow-file]

Launches the real-time DevTools live monitoring HTTP server and web dashboard:
Output:
Workflows in other processes or terminals can attach immediately via:


Command 11: siglo reconcile [workflow-file] [options]

Scans persistent storage for abandoned workflow execution stacks stuck in RUNNING state past a stale threshold, and safely reconciles them:

Reconcile Options:

  • --stale-threshold=<duration>: Duration threshold past which a running stack is considered abandoned (e.g. 10m, 1h, 30000ms; default: 10m).
  • --action=inspect|compensate|fail: Reconciliation action (default: compensate).
    • inspect: Read-only audit report detailing abandoned stacks without mutating state.
    • compensate: Executes LIFO saga compensation handlers on pending steps.
    • fail: Transitions abandoned stack states to FAILED and releases locks.
  • --mode=strict|best-effort: Compensation error tolerance (default: best-effort).
  • --namespace=<ns>: Scopes reconciliation query to a specific tenant partition.

4. Programmatic API Reference

Import programmatic utilities directly in your tests, scripts, and build pipelines:

startMonitor(options?: MonitorOptions)

Starts the live workflow monitoring dev server and React DevTools web dashboard programmatically:

generateWorkflow(name, targetDir?)

Generates typed workflow and test templates:

generateStep(name, targetDir?)

Generates typed step and test templates:

exportWorkflow(workflow, options?)

Exports a workflow to Mermaid, Graphviz DOT, or JSON format:

visualizeWorkflow(workflow)

Generates both Mermaid and ASCII text representations of a workflow:

validateWorkflow(workflow)

Runs cycle detection and connectivity validation on the compiled graph:

inspectWorkflow(workflow, options?)

Analyzes graph structure and optionally redacts sensitive node names:

inspectCheckpoint(checkpoint, options?)

Inspects a checkpoint object or JSON string, redacting specified context fields across all steps:

replayFixture(workflow, fixture)

Replays an end-to-end workflow against a recorded golden test fixture. Ideal for CI regression testing, schema evolution validation, and deterministic output verification.

TypeScript Interface:


5. Golden Fixture Testing in CI

Use replayFixture in your test suite to ensure that workflow refactoring preserves identical behavior and contract outputs:

Step 1: Define Fixture File (test/fixtures/pricing-fixture.json)

Step 2: Implement Test Runner (test/pricing.test.ts)


6. Workflow File Loading Mechanics

When Siglo loads a workflow file specified on the command line (e.g. siglo visualize src/workflow.ts or siglo export src/workflow.ts):
  1. The file is dynamically imported using Node.js ES modules.
  2. The loader checks exports in the following order:
    • export default flowInstance
    • export const workflow = flowInstance
    • export const pipeline = flowInstance
    • Any named export satisfying isFlow or containing a run() function.
    • If the candidate is a zero-argument factory function (e.g., export default () => flow(...)), it is invoked automatically to construct the graph.