Pages

Writing and versions

The page id, the three ways to write a page file, what a write does, and versions for when two writers share a page.

On this page 10 sections

A page is one row in the Legato panel's sidebar: a title, an optional icon and an ordered list of cards. Each page is a JSON file on your Mac, in ~/Library/Application Support/Legato/Pages. An agent writes it through Legato's MCP server, a script writes it with the legato command, or any program writes the file itself. Legato shows it as soon as the file is saved. Pages and their data never leave the Mac.

json
{
  "$schema": "./.schemas/page.schema.json",
  "title": "Homelab",
  "icon": "server.rack",
  "cards": [
    { "id": "nas", "type": "status", "label": "NAS", "state": "ok", "detail": "41% used" },
    { "id": "wan", "type": "stat", "label": "WAN down", "value": 912, "unit": "Mbps" }
  ]
}
Key
titlerequired1–60 characters. The page's name in the sidebar.
title_fromoptionalA name for the panel's title row from a source's answer, such as the item a page with params shows: { "ref": "kuma", "value": rule }. title stays the page's name, and shows until the source answers. See Titled by its item.
cardsrequired1 to 24 cards, top to bottom. A tabs card counts as one, and the cards in its tabs don't, up to 120 cards on the page in all. Each needs a unique id and a type.
iconoptionalAn SF Symbol name, like server.rack. Lowercase words separated by dots, up to 64 characters. A name the Mac doesn't have shows a generic icon; see Icons for where to find names.
sourcesoptionalNamed sources Legato fetches on a schedule to fill cards: an API on the internet or your network, this Mac's calendars or reminders. See Sources and Buttons.
notifyoptionalA macOS notification from this page: { "id": "deploy-142", "title": "Deploy finished", "body": "v2.15 is live." }. Each id shows once; write a new one to notify again. See Notifications.
sidebaroptionalfalse makes it a detail page, reached from other pages' links rather than the sidebar. Default true.
$schemaoptionalWhere an editor finds the page schema, for suggestions and checking as you type. See The schema.
schema_versionoptional1, or left out.

Any other top-level key, light included, stops the page loading, and Legato shows what's wrong in its place. A file is at most 1 MB.

The page id

A page's id is its file name without .json: homelab.json is the page homelab. A new page's id is 1–64 lowercase letters, digits and hyphens, starting with a letter or digit (budget, deals-electronics). Card ids may also use _; page ids may not.

Legato loads every file in the folder whose name ends in .json and doesn't start with a dot, so a file you named some other way still shows, and the legato tools can still read, replace and delete it. Renaming the file changes the page's id.

Writing a page

Every write replaces the whole page. There's no partial update: a card you leave out is gone. Build the whole page from your current data each time and write it.

There are three ways to write one, and they all end in the same file.

From an agent, over MCP

The legato command inside the app is also an MCP server: legato mcp. Connect an agent to it, and the agent writes pages with these tools:

ToolDoes
set_pageCreates or replaces a whole page. Its arguments are page_id, the page's keys (title, icon, cards, sources, notify) and an optional if_match.
get_pageOne page, with its version and whether Legato loaded it.
list_pagesEvery page in the folder, without its cards.
delete_pageMoves a page's file to the Trash. Takes if_match.
get_page_schemaThe JSON Schema for page, sources, notify, one card type, or the shared rules and actions. With no part, the list of parts and every card type's fields.

From a script, with legato

The same tool is a command for scripts, at /Applications/Legato.app/Contents/Helpers/legato:

bash
legato set homelab homelab.json        # or pipe the page in: … | legato set homelab
legato get homelab
legato list
legato delete homelab
legato schema stat                     # page, sources, period, params, notify, title_from or a card type

--if-match <version> on set or delete acts only if the page is still at that version; see Versions and if-match. Answers are JSON on standard output. A refusal is {"error": {"code", "message", "details"}} with exit status 1.

What set and set_page do

  1. Check the id and validate the complete page with Legato's file parser, without opening the panel or running sources: the page itself, and each card's source and buttons. An invalid page returns invalid_page before any file changes.
  2. Write the file whole: to a temporary file in the folder, then renamed into place, so Legato never reads half a page. The tool writes the page in its own layout, keys in a fixed order and pretty-printed, with its own $schema line first.
  3. Open Legato in the background if it isn't running.
  4. Wait for Legato to load the page: up to 4 seconds, or 10 if Legato had to be opened.
  5. Report whether Legato loaded those exact bytes. If a different running build rejects them, return load_failed with saved: "true"; the tool never rolls back over another save.

The answer says what happened:

json
{
  "id": "homelab",
  "version": "3f9c2a7b1d0e4c58",
  "changed": true,
  "created": false,
  "loaded": { "ok": true, "loaded_at": "2026-10-27T21:15:02.118Z" }
}

changed is false when the page is exactly what was there. Writing the same page again is harmless: the file is saved again, so the page's update time moves on, and nothing else changes. So a script can write on a schedule without checking whether anything changed.

loaded is null when Legato didn't confirm in time, with a note: "Legato hasn't confirmed loading it yet; get_page shows its status", or, when Legato isn't running, "it loads the page when it opens". When the trial has ended and there's no license, the page is saved but not shown, and loaded.plan is "locked"; see Trial and license.

A refused write looks like this; the page stays as it was:

json
{ "error": { "code": "invalid_page", "message": "homelab.json: /cards/1: a stat card needs label",
             "details": { "page": "homelab", "saved": "false" } } }

Any program, writing the file

A page is only a file, so anything that can write JSON can make one. Write to a temporary file in the Pages folder whose name starts with a dot or doesn't end in .json (.homelab.json.tmp, homelab.json.tmp), then rename it to homelab.json. Legato ignores the temporary file and loads the renamed one once. Writing the final name directly works too, but Legato may read it half-written and show an error until the next save.

To find out whether Legato took it, read its status file.

Layout in the window

Without one, a page's cards flow down columns: a column for every 376 points of window, the cards in order down the first and on into the next. A page that wants its cards in a particular place, such as a home page with a wide chart and a table across the bottom, says where in layout:

json
"layout": { "type": "grid", "max_width": 1600, "rows": [
  { "cells": [ { "cards": ["worth"], "weight": 2 }, { "cards": ["month", "pace"] } ] },
  { "cells": [ { "cards": ["attention"] }, { "cards": ["review"] }, { "cards": ["upcoming"] } ] },
  { "cells": [ { "cards": ["recent"] } ] } ] }
  • Rows of 1 to 4 cells, up to 12 rows. A cell holds 1 to 6 cards, one under another, and its weight (1–4, default 1) is its share of the row: 2 beside 1 is two thirds.
  • Every card the page draws is placed exactly once. Cards in a tab stay in their tab, and cards in Details stay there. A page with a layout has no headings.
  • cards stays the reading order. A window too narrow for two cells side by side shows the cards in that order, one under another, so put them in the order you'd read them on a laptop.
  • Narrower windows: a row whose cells can't each have their least width (about 300 points for most cards and for a columns chart, 420 for other charts, maps, heat maps and tiles, and 600 for a table) breaks into pairs, then one cell to a line.
  • A card that isn't showing (its source's when) leaves its cell, and the cells left share the row.
  • max_width (600–4000, default 1600) is the widest the cards get; a wider window centres them.
  • look: cards (the default) draws each card on its own surface. sheet draws the page as one plain sheet with no card surfaces. The page's name is large at the top, each card's name is bold over a thin rule, money in has a + sign instead of green, and only an amount over budget is red. On a sheet, a list whose rows have buttons shows a box before each of those rows. Clicking the row opens it where it is, with its buttons underneath.

Cards or a sheet

Without a layout, the window draws a page on cards or as a sheet. A page that's mostly lists goes on a sheet: more than half the cards drawn on the page are lists, checklists, agendas, timelines or tables, or tabs that hold only those. Headings and Details's cards don't count. Any other page goes on cards. "look": "cards" or "look": "sheet" on the page decides it instead, and a layout's own look wins over both. On a sheet, a card with a fill or a tone keeps its own coloured surface.

The sidebar's count

"sidebar_count": "todo" names one of the page's cards. The sidebar then shows how many rows that card has beside the page's name, as Things counts a list: a list's items, a checklist's items still to do (all of them for a switch list), a table's rows, or an agenda's, timeline's or fleet's items. The count is grey, takes the page's status colour while the page lights, and isn't shown at 0 or while the card is hidden.

Versions and if-match

Every page has a version: the first 16 hex characters of the SHA-256 of the file's bytes, such as 3f9c2a7b1d0e4c58. set, get and list report it. A page that hasn't changed keeps its version; any edit, by an agent, a script or a person in an editor, gives it a new one.

To write only if the page is still at the version you last read, pass that version: if_match in the MCP tools, --if-match on the command line. If the file has changed since, the write is refused and nothing is saved:

json
{ "error": { "code": "version_mismatch",
             "message": "The page has changed since that version; read it again before replacing it.",
             "details": { "current_version": "a01d77e9c3b2f640" } } }

current_version is "none" when the page no longer exists. Read the page again, rebuild it, and retry with the new version. delete takes it too.

To create a page only if there's no page with that id yet, pass none as the version. A script that adds pages then can't replace one someone made in the meantime.

Most agents don't need this: one agent owns a page and rewrites it whole. It matters when two runs might overlap, or when a person edits the file by hand and an agent shouldn't undo that.

Reading pages back

get_page (legato get) returns the page as it is on disk, without its $schema line, with its version, when the file was last modified, and its load status:

json
{
  "id": "homelab",
  "version": "3f9c2a7b1d0e4c58",
  "modified": "2026-10-27T21:15:02.104Z",
  "page": { "title": "Homelab", "icon": "server.rack", "cards": [ … ] },
  "status": { "ok": true, "loaded_at": "2026-10-27T21:15:02.118Z" }
}

A file that isn't valid JSON comes back as text instead of page, so you can see what's in it. status is null when Legato hasn't loaded the file yet.

list_pages (legato list) lists the folder in Legato's order, by file name:

json
{
  "folder": "/Users/you/Library/Application Support/Legato/Pages",
  "pages": [
    { "id": "homelab", "name": "Uptime", "title": "Homelab", "version": "3f9c2a7b1d0e4c58",
      "modified": "2026-10-27T21:15:02.104Z", "ok": true }
  ]
}

name is the page's name in the sidebar: the one you gave it there, or its title (never a title_from name, which changes with the answer). A page Legato couldn't use has ok: false and its error; a page that's locked has plan: "locked".

Deleting a page

delete_page (legato delete) moves the page's file to the Trash, and the panel drops it at once. Put it back from the Trash to restore it.

json
{ "id": "deals-tv", "deleted": true, "note": "Moved to the Trash; put it back from there to restore it." }

A page that isn't there gets not_found. Deleting the file any other way does the same.

You don't need to delete a page because nothing has updated it lately; its footer already shows how long ago that was. Delete pages that no longer mean anything, like a deal that ended.

The person at the Mac has the last word. Right-clicking a page in the sidebar offers Delete Page…, which moves its file to the Trash too, with any detail pages ("sidebar": false) that only it leads to, so none is left stranded. The question names them. A page in the sidebar is never deleted along with another, and neither is a detail page another page still links to. legato delete and delete_page delete only the page they name. An agent that writes the page again creates it again: if someone keeps deleting your page, stop writing it. Renaming a page in the sidebar, moving it into a section or turning its notifications off doesn't change the file.

The schema

The page schema is JSON Schema (draft-07) for a whole page: its keys, its sources and every card type, with each field's limits. Legato installs it in the Pages folder, at .schemas/page.schema.json, each time it starts, so an editor that supports JSON Schema (VS Code, for one) gives suggestions and flags mistakes as you type, offline. Point a page at it with:

json
"$schema": "./.schemas/page.schema.json"

Older pages that say ./.schemas/local-page.schema.json still work. The same schema is published at legatobar.com/schemas/page.schema.json, and get_page_schema (legato schema) serves it in parts. For a page you keep elsewhere, download it and point $schema at your copy.

The schema can't know what an API answers, so it can't tell whether a source's mapping picks the right data; the Source Preview can.

Errors

The tools refuse with these codes, in the same {"error": {"code", "message", "details"}} shape:

CodeMeans
invalid_pageThe page has a key it can't, no title or no cards, isn't a JSON object, or Legato's parser found a mistake. The message says which. Nothing was written.
load_failedThe page was saved, but the running Legato, from a different build than the tool, couldn't load it. Reopen Legato.
validation_unavailableThe tool couldn't run Legato's page check; nothing was written. Reinstall Legato.
invalid_page_idThe id isn't a page id, or a new page's id isn't lowercase letters, digits and hyphens.
too_largeThe page is larger than 1 MB.
version_mismatchThe page isn't at the if_match version. details.current_version says where it is.
not_foundThere's no page with that id.
write_failed, delete_failedThe file couldn't be saved or moved to the Trash; the message says why.
schema_unavailableThe schema isn't installed yet. Open Legato once.
unknown_partget_page_schema was asked for a part it doesn't have; the message lists them.
invalid_argumentsA command was missing its page id or file, or --if-match its version.

See Errors for handling them in an agent.