# Spokegrid Canvas Studio: guide for AI agents

Editor: `/canvas`. Describe a document as JSON; the studio lays it out as editable
pages. Nothing is uploaded: documents stay in the browser that opens them.

## Fastest: fill a template with data

`/canvas/templates.json` lists every template (`proposal`, `effort`, `agreement`,
`nda`, `sow`, `quote`, `report`) with the JSON Schema of its data and a fictional
example. You supply facts; layout, totals, numbering and page breaks are done for
you. Omitted fields become `[placeholders]` or their section is dropped.

```js
await SpokegridCanvas.fill("quote", {
  studio: "Studio name", client: "Client", currency: "USD",
  items: [{ name: "Website build", quantity: 1, rate: 2400 }],
  taxPercent: 10, validDays: 15
});                        // { id, title, pages, missing: [...] }
SpokegridCanvas.schema("quote");   SpokegridCanvas.sample("quote");
```

Without scripting, either paste `{"template":"quote","data":{...}}` into
*Templates → Fill with your AI*, or open `/canvas#json=<that object,
percent-encoded>`. Report `missing` to the person so they can supply it.

## Existing studios

The Proposal studio (`/resources/proposals`) has a scripting object too:
`SpokegridProposals.sample()` returns a complete draft showing the shape,
`SpokegridProposals.current()` returns the open draft, and
`await SpokegridProposals.open(draft)` opens a validated copy as a new local
draft. It never overwrites saved drafts. *Design in Canvas* in the Proposal
studio and Agreement creator copies a document into Canvas Studio.

## Invoices, quotes, tax invoices and agreements

On `/resources/invoices`, `/resources/quotes`, `/resources/gst-invoices`,
`/resources/tax-invoices/<country>` and `/resources/agreements`:

```js
SpokegridDocuments.schema();            // what this tool accepts
SpokegridDocuments.fill({ sender: { name: "Studio" }, client: { name: "Client" },
  lines: [{ description: "Design", quantity: 2, rate: 500 }] });
SpokegridDocuments.current();           // the open draft
```

People can do the same with the *Fill with AI* button. The tool asks before
replacing a draft that has content. Signatures cannot be set by a script.

## Brand, favicon, stamp and signature tools

Each page publishes `schema()`, `current()` and `set(data)`:

| Page | Global | Output |
|---|---|---|
| `/resources/brand` | `SpokegridBrand` | `palette()`, `svg({lockup, surface})`, `download()` |
| `/resources/favicon` | `SpokegridFavicon` | `png(size)`, `code("html")`, `download()` |
| `/resources/stamps` | `SpokegridStamps` | `svg()`, `download("png")` |
| `/resources/signatures` | `SpokegridSignatures` | `png()` |

```js
SpokegridBrand.set({ name: "Northwind Studio", tagline: "Design and code", color: "#2447a8", mark: "orbit" });
await SpokegridBrand.download();
```

## Timeline, catalogue and colour tools

| Page | Global | Calls |
|---|---|---|
| `/resources/timeline` | `SpokegridTimeline` | `schema()`, `current()`, `set(data)`, `svg()`, `csv()` |
| `/resources/catalogue` | `SpokegridCatalogue` | `schema()`, `current()`, `fill(data)`, `html()` |
| `/resources/colors/...` | `SpokegridColors` | `schema()`, `current()`, `set(data)`, `ramp()`, `harmony(type)`, `contrast(a, b)` |

```js
SpokegridTimeline.set({ title: "Website", start: "2026-03-02",
  tasks: [{ label: "Design", days: 10 }, { label: "Build", days: 15 }, { label: "Launch", milestone: true }] });
SpokegridCatalogue.fill({ items: [{ name: "Audit", price: 500, currency: "USD" }] });
SpokegridColors.set({ palette: ["#146f62", "#d9e6d5", "#192622"] });
```

The timeline and catalogue ask the person before replacing existing work.

A signature may only be made for the person asking, with their name. Attaching it
to an agreement is left to that person.

## Three ways to create a free-form document

1. **Scripting (browser-driving agents).** On `/canvas`, wait for
   `window.SpokegridCanvas`, then:

   ```js
   await SpokegridCanvas.open(spec);   // returns { id, title, pages }
   SpokegridCanvas.link();             // link that opens an editable copy
   SpokegridCanvas.getDocument();      // full canvas JSON
   SpokegridCanvas.html();             // standalone printable HTML
   SpokegridCanvas.templates();        // [{ id, title, detail }]
   SpokegridCanvas.template("proposal"); // a template's spec, to adapt
   ```

2. **Import dialog.** Click *Import*, paste the JSON, choose *Open as new document*.

3. **Link.** `/canvas#spec=<payload>`, where payload is the JSON compressed with
   raw DEFLATE and encoded as base64url without padding. The fragment is not sent
   to the server.

## Spec (free-form documents)

```json
{
  "title": "Website redesign proposal",
  "size": "A4",
  "theme": { "preset": "evergreen", "colors": { "accent": "#7c3aed" } },
  "header": { "left": "Studio name", "right": "PRO-014 · Confidential" },
  "footer": { "left": "example.com", "right": "Page {page} of {pages}" },
  "cover": {
    "brand": "Studio name", "eyebrow": "Proposal", "title": "Website redesign",
    "subtitle": "Scope, plan and price.",
    "meta": [{ "label": "Prepared for", "value": "Client" }]
  },
  "blocks": [
    { "type": "contents" },
    { "type": "h1", "number": "1", "text": "Summary" },
    { "type": "text", "text": "Use **bold**, *italic* and ==accent==.", "tone": "lead" },
    { "type": "stats", "items": [{ "value": "4 wks", "label": "Delivery" }] }
  ]
}
```

Presets: `evergreen`, `midnight`, `ember`, `royal`, `mono`, `noir`.
Colour slots: `ink`, `muted`, `accent`, `accent2`, `surface`, `line`, `paper`, `inverse`.
Fonts (`headingFont`, `bodyFont`): `humanist`, `system`, `geometric`, `grotesk`,
`serif`, `elegant`, `condensed`, `mono`.

## Blocks

| type | fields |
| --- | --- |
| `h1` | `text`, `number?` (listed in contents) |
| `h2`, `h3` | `text` (`h2` is listed in contents) |
| `text` | `text`, `tone?`: `body` `lead` `note` |
| `bullets` | `items[]`, `columns?`: 1 or 2 |
| `callout` | `title?`, `text` |
| `table` | `rows[][]` (first row is the header), `header?`, `widths?`, `align?`, `boldFirst?`, `boldLast?` |
| `stats` | `items[{value,label}]`, `cards?` |
| `chart` | `chart`: `bar` `stacked` `horizontal` `line` `area` `donut` `pie` `progress`; `labels[]`; `series[{name,values[],color?}]`; `title?`, `unit?`, `height?` |
| `gantt` | `count`, `unit?`, `tasks[{label,start,span,note?}]` (`start` counts from 0) |
| `flow` | `columns[{title,nodes[{title,detail?}]}]` (1–3), `link?` |
| `contents` | |
| `effort` | `rate`, `currency`, `areas[{name,tasks[{name,hours}]}]`, `price?`, `deliveryTime?`, `weeks?[{hours,work,label?}]`, `payments?[{name,share}]` |
| `payments` | `total`, `currency`, `milestones[{name,share}]` |
| `signatures` | `parties[{role,name?}]` |
| `image` | `src` (a `data:image/...;base64` URL; remote URLs are rejected), `alt?`, `caption?`, `height?` |
| `spacer` | `height` |
| `pagebreak` | |

Table cells may be `bar:60`, `rating:3/5`, `tag:Built`, `tag(warn):Conditional`
or `tag(muted):Reused`.

Long text and tables continue onto new pages automatically; table headers repeat.
A document holds up to 80 pages. Unknown fields are rejected with the path of the
problem, so fix that field and retry.

## Before you hand it to a person

Do not invent prices, dates, legal terms or client facts. Leave a clear
placeholder instead. Agreement templates are drafting starting points, not legal
advice.
