Skip to main content

Crate piw

Crate piw 

Source
Expand description

piw: terminal viewer and live replay server for pi-workflows run bundles. The library form exists for integration tests; main.rs is the CLI.

Modules§

bundle
canvas
Port of src/render/canvas.ts: a sparse character grid where box-drawing characters merge by connectivity (│ crossing ─ becomes ┼).
client
Reconnecting WebSocket client for remote mode (piw --connect ws://…). The background task treats subscriptions and artifact requests as desired state, so reconnects cannot replay stale commands.
format
Port of src/render/format.ts and src/workflows/text.ts, including JavaScript-compatible rounding so durations format identically.
layout
Faithful port of src/render/graph.ts: expand switch edges, classify back edges via DFS, longest-path layering with terminal tail pull-down, virtual pass-through cells, and barycenter ordering. Behavior is pinned against the golden fixtures in fixtures/layout/ — any divergence is a bug in this port, not a stylistic choice.
protocol
Wire types for the live replay protocol (pi-workflows.replay.v1), plus the JSON Patch subset (with the append extension op) used for view synchronization. See docs/live-replay-protocol.md.
render
Port of src/render/graph-render.ts: renders the workflow DAG onto a CharCanvas. Statuses derive from the steps visible up to the selected step, taken transitions highlight, switch branches carry case labels, and loop edges route through a right-hand gutter. Output is pinned to the TypeScript renderer through the golden fixtures.
server
piw serve: a WebSocket server exposing run views over the live replay protocol. The server is a bundle reader like any other — it never writes bundles — and binds to localhost by default because bundles contain private data.
session
Deterministic reducer for session/events.ndjson.
source
The run source: reads bundles from a runs directory and maintains one semantic run view per run (see docs/live-replay-protocol.md), producing JSON patches as bundles grow. Both the in-process TUI and the WebSocket server consume this; the protocol is just its network form.
theme
ui
The interactive TUI (see docs/tui-viewer.md): a runs sidebar, the graph pane, an inspector with steps/trace/conversation/info tabs, and a replay transport. Works against a local runs directory, a single bundle, or a piw serve WebSocket server; all three feed the same view model.