# Diagrams

The 4 tools for diagrams. Before an agent first makes one, it reads guide topic diagrams.

## create_diagram

Make a diagram in a space: nodes and the edges between them — flowcharts, processes, system architecture, data flows, org charts, user journeys — with groups drawn around related nodes. Artifacts lays it out top to bottom or left to right so nothing overlaps; people drag, rename, connect and comment on nodes. Give the nodes (id, label, shape), then the edges (from, to, label). Read guide topic "diagrams" first; check it with render_diagram.

Parameters:
- `space_id` (string, required)
- `title` (string, required)
- `subtitle` (string): One line: what it shows.
- `direction` (string): TB top to bottom (default: processes, hierarchies), LR left to right (pipelines, architectures).
- `nodes` (object[], required)
- `edges` (object[], required)
- `groups` (object[])

## read_diagram

A diagram as it is now, people's edits included: direction, groups, nodes (with x and y where people placed them) and edges with their ids (what update_diagram takes).

Parameters:
- `item_id` (string, required)

## update_diagram

Change a diagram. Any of: title, subtitle, direction; add_groups, remove_groups (their nodes stay, outside any group); add_nodes; change_nodes (by id: the fields you give replace those fields, "" clears one — description, color, group; shape back to rounded); remove_nodes (with their edges); add_edges; change_edges (by id); remove_edges (ids); tidy (true: drop where people placed nodes and lay it all out again). Applied in that order, all or nothing; read_diagram first for the ids — people may have changed it.

Parameters:
- `item_id` (string, required)
- `title` (string)
- `subtitle` (string)
- `direction` (string)
- `add_groups` (object[])
- `remove_groups` (string[])
- `add_nodes` (object[])
- `change_nodes` (object[])
- `remove_nodes` (string[])
- `add_edges` (object[])
- `change_edges` (object[])
- `remove_edges` (string[])
- `tidy` (boolean)

## render_diagram

See a diagram as people do: a screenshot of the whole diagram fitted to the view, plus checks — nodes not connected, decisions without labelled answers, long or repeated labels, empty groups — and errors the page hit.

Parameters:
- `item_id` (string, required)
- `wide` (boolean): A wider view (1920 px) for large left-to-right diagrams.
