In this section
On this page

capdag shows three things in a terminal beyond its plain output:

  • the live view of a run, drawn under the command while it runs;
  • pickers, wherever a command needs a choice;
  • the graph of a machine, full screen, to look at (capdag view) or edit (capdag edit).

Each is used only when a person is at a terminal. In a pipe, in CI, with --json, with --no-input or on a terminal that cannot move its cursor (TERM=dumb), the same command shows none of them and asks for nothing: a run prints plain lines, and a choice is given by a flag (When a capdag command fails §A choice that was not made). The flags, outputs and exit status of a command are the same either way (CLI reference).

When it is used

  Used when
Live view --progress is auto (the default) and a picker could be shown; or --progress live, and stderr is a terminal that is not dumb
Pickers stdin and stderr are terminals, neither --json nor --no-input is given, CI is not set, and TERM is not dumb
view, edit stdin and stdout are terminals

stdout may go anywhere: the live view and the pickers are drawn on stderr, so capdag model pull $(capdag model search qwen --pick) still lets a person choose, and capdag run … > list.txt still shows the run.

Colour follows --color auto|always|never: auto colours a terminal that is not dumb and nothing else, and NO_COLOR turns it off. Lines and marks are drawn with Unicode box drawing in a UTF-8 locale and with ASCII otherwise.

The live view

While a run goes, a block under the command shows it, as many rows tall as it has lines. It is drawn in the normal scrollback, not over the screen. What the run writes for stdout, when stdout is the same terminal, and each run’s summary are printed above the block as they come, as ordinary lines: a path wider than the terminal wraps as the terminal wraps it and copies whole. When the runs end the block is cleared and the command goes on from the row it began on: the scrollback keeps what happened, with no blank rows where the block was.

pages.machine · report.pdf                         3.2 s
 ✓ disbind           done
 ◐ save-as-txt       3/5 page
 Ctrl-C stop · Ctrl-C twice abort · l log · ↑↓ step
  • A row per step, in the order the steps run, named by its cap’s alias. A map — a step run once per item of a sequence — is one row, counting its items as they end (3/5 page, with failed ones counted apart).
  • A step’s mark: · waiting, ◐ running (with its progress bar), ✓ done, ↷ skipped, ⚠ failed and tolerated by its policy, ✗ failed, – never started, and a yellow ✗ cancelled when the run was aborted.
  • The selected step’s last line: what its cartridge said last. l shows the run’s last few log lines instead.
  • A run once per input: the block shows the run going now (run 3/8), and each run’s summary goes into the scrollback above it as the run ends.
  • The summary says how the run ended and how long it took, and lists the files it wrote (→ path) when stdout does not already list them — that is, when stdout is not the terminal.
Keys Action
Ctrl-C Stop: nothing new starts; what started finishes and is written
Ctrl-C again Abort: everything running is cancelled, and the cartridges are given 5 s to end
Ctrl-C a third time End the run now, without waiting out the 5 s
l The run’s last log lines, or the selected step’s last line
↑ ↓ Select a step
Ctrl-Z Suspend capdag, giving the terminal back to the shell; fg draws the block again

What each Ctrl-C does is decided by the model of a run (Execution §Runs stop). A stopped or aborted run exits 130.

Without a terminal, or with --progress plain, the same run prints a line when a step starts, ends or fails, and its progress at most once a second:

[1/2] disbind  done
[2/2] save-as-txt  3/5 page

--progress none prints only the summary, and --json prints every change as a record (step, log, run_finished, …) on stdout.

Pickers

Where a command needs a choice — what to make of a file, which machine, which capability, which model, what to do with a planned machine — it shows the options by their aliases in a list under the command:

Choose what to make: tx        2/31
› txt        UTF-8, Plain Text · each · 2 steps
  txt-page   Document Page · each · 1 step
type to filter · ↑↓ move · Enter choose · Esc cancel
Keys Action
typing Keep the options whose name, description or URN has every word typed
↑ ↓ Move
Enter Choose
Esc, Ctrl-C Give up: the command ends with a usage error (exit 2)
Ctrl-Z Suspend capdag, giving the terminal back to the shell; fg shows the list again

With -v each option shows its URN too. The list takes the rows its options need, twelve at most, and is cleared once a choice is made: what the command prints next starts on the row where the list began.

The live view and the pickers give the terminal back as they found it — out of raw mode, its cursor shown — however the command ends, an error or a crash included.

The graph: capdag view and capdag edit

capdag view <file.machine> shows a machine as a graph, the whole terminal given to it; capdag edit <file.machine> shows the same graph and changes the machine. Without a terminal, view prints the picture as capdag graph does, and edit says to edit the file and capdag check it. The terminal must be at least 60 columns by 18 rows.

Reading the graph

A machine is drawn left to right, each node in the column its longest path from an input puts it in.

Node Drawn as
Input A blue card: its media
Step A rounded card: its cap’s title, and its alias with its retry and failure policy
Value A card for a value a step makes and another step reads
Map A card for the sequence split into items, each run on its own; the edges out of it say For each item
Gather Where the results of a map’s items are collected
Output A green card: what the machine gives

Level of detail takes the place of zoom. Each node shows its whole card, a small card, one line, or one cell. Unless a level is chosen with + and -, the view shows the most detail at which the whole machine fits, and f returns to that. w wraps a wide machine into bands that fit the width. m shows a minimap of the whole machine with the visible part marked.

Keys Action
←↑↓→, hjkl Focus the nearest node in that direction
HJKL, Shift-arrows, drag Move the view
Tab, Shift-Tab Focus the next or the previous node
], [ Follow the focused node’s outgoing or incoming edge
+, - More or less detail
f Fit the whole machine
w Wrap into bands, or not
m The minimap
:, Ctrl-K Every action by name
? The keys
x Run the machine on the inputs given on the command line (capdag view m.machine report.pdf)
q Close

Editing

capdag edit shows the inspector beside the graph, describing the focused node or step; e shows the notation in its place, with the text of the focused node or step marked. Moving the cursor in the notation focuses what it is in.

A change is applied only when the machine it makes is valid. Until it has been checked the top bar says checking…; a change that is not valid is not applied, and the reason is shown. A file whose machine is not valid opens with the reason, so it can be put right. A file that does not exist yet is made when it is saved.

Keys Action
a A step reading the focused node: the palette offers the caps whose input takes what the node holds
A A step of its own
r Replace the focused step’s cap
d Delete the step, connecting what it read to what read it
D Disconnect the step
., , Select the step’s next or previous source
I Give the step a new input
N Have the step read another node
X Remove the selected source
i A step before the selected source
s Read the selected source from another node
o Write the step’s output into another node
u, Ctrl-Z Undo
U, Ctrl-Y Redo
Ctrl-S Save; in the notation, apply it
x Save, and run the machine on the inputs given on the command line
e Show the notation and edit it; again to hide it
q Close; with unsaved changes it asks first

The palette lists caps by title and alias, and typing filters them. A cap chosen there is written by its alias, as every machine the command line writes is; a cap with no alias gets a header naming its URN. A step whose name is neither a header nor a fabric alias is marked ✗, in red, and the inspector says so.

A node name is typed with completion (Tab). Saving writes the whole file at once: the file holds the old machine or the new one, never part of either. A run started with x is shown as any run is, in the live view, once the editor has closed.

Where it is made

Everything on this page, with the command’s plain lines, --json records and errors, is one crate, capdag-tuikit: every command and flag of capdag, and what each says in every mode. It asks the engine for what only the engine can do — open the fabric, find, install and start cartridges, run machines — through one interface, Host, and words every answer itself. The capdag binary is that command line on the engine’s host, built by the capdag-cli crate; the capdag library holds no terminal code.

The same command line also runs on worlds: a snapshot of a published fabric, cartridges, files, and a script of what the engine says during each run. The capdag-tuikit binary plays every command on a world, and journeys — one thing a person does, in each mode it is done in — are played and checked against what they should show, so a change to a screen is seen and tested without the engine. How to do that is in Work on the terminal interface with worlds and journeys; the crates, Host and the formats are in the reference.