studiograph 1.3.48-next.257 → 1.3.48-next.259

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/agent/prompts/system.md +5 -3
  2. package/dist/agent/skills/artifact-canvas/skill.md +54 -13
  3. package/dist/agent/skills/paged-documents/skill.md +147 -0
  4. package/dist/agent/tools/artifact-tools.js +1 -1
  5. package/dist/agent/tools/artifact-tools.js.map +1 -1
  6. package/dist/core/artifact-frame-document.js +71 -22
  7. package/dist/core/artifact-frame-document.js.map +1 -1
  8. package/dist/core/artifact-paged-css.d.ts +64 -0
  9. package/dist/core/artifact-paged-css.js +253 -0
  10. package/dist/core/artifact-paged-css.js.map +1 -0
  11. package/dist/mcp/tools.js +6 -3
  12. package/dist/mcp/tools.js.map +1 -1
  13. package/dist/services/artifact-render-export.js +38 -1
  14. package/dist/services/artifact-render-export.js.map +1 -1
  15. package/dist/web/_app/immutable/assets/FrameCanvas.Clh5Xdr7.css +1 -0
  16. package/dist/web/_app/immutable/chunks/{CIn7YEl02.js → 7T3lnqZI2.js} +2 -2
  17. package/dist/web/_app/immutable/chunks/{fJ-ZYp0N2.js → A98N4tEQ2.js} +1 -1
  18. package/dist/web/_app/immutable/chunks/{DCWbqexw.js → B7Hmk7kS.js} +1 -1
  19. package/dist/web/_app/immutable/chunks/{_TQ4jLwn.js → BES1w_XS.js} +1 -1
  20. package/dist/web/_app/immutable/chunks/{1Lt1f7Uf.js → BMiLrQE7.js} +1 -1
  21. package/dist/web/_app/immutable/chunks/{BqdhZL6I.js → BRoKnvc3.js} +1 -1
  22. package/dist/web/_app/immutable/chunks/{gsgn7E-X.js → BbAd2-nD.js} +1 -1
  23. package/dist/web/_app/immutable/chunks/{DOrNA9-_.js → Bo6MInPe.js} +1 -1
  24. package/dist/web/_app/immutable/chunks/{Bdw7OKur.js → BrNxtFJ8.js} +3 -3
  25. package/dist/web/_app/immutable/chunks/{CZzvOGH72.js → C2y6LFnO2.js} +1 -1
  26. package/dist/web/_app/immutable/chunks/{Cj7gAXKs.js → C7U1JhuJ.js} +1 -1
  27. package/dist/web/_app/immutable/chunks/{eWig6c-y.js → CVjgnBi4.js} +1 -1
  28. package/dist/web/_app/immutable/chunks/{C8NPBOPD.js → CkG86_Ae.js} +1 -1
  29. package/dist/web/_app/immutable/chunks/Cr907H0t.js +1 -0
  30. package/dist/web/_app/immutable/chunks/{eWCQRtoR2.js → CtsLiFXz2.js} +1 -1
  31. package/dist/web/_app/immutable/chunks/{B9QB1U-V2.js → CvgOD5uw2.js} +1 -1
  32. package/dist/web/_app/immutable/chunks/{uBRkjc_h2.js → CwY9h7602.js} +2 -2
  33. package/dist/web/_app/immutable/chunks/{DpFu4gqN.js → Cwu3RMpb.js} +1 -1
  34. package/dist/web/_app/immutable/chunks/{Bg5yknRP.js → D-y-DK_o.js} +1 -1
  35. package/dist/web/_app/immutable/chunks/DDKvg2Kd.js +1 -0
  36. package/dist/web/_app/immutable/chunks/{DkfN0B50.js → DI_bCdqQ.js} +1 -1
  37. package/dist/web/_app/immutable/chunks/{DJw-z9CB2.js → DIolstZF2.js} +1 -1
  38. package/dist/web/_app/immutable/chunks/{COcb0M0i2.js → DRpzbH4J2.js} +1 -1
  39. package/dist/web/_app/immutable/chunks/{BAC9tqH6.js → DdixGgWb.js} +1 -1
  40. package/dist/web/_app/immutable/chunks/{BNf6gE7Y.js → DgyePxxv.js} +1 -1
  41. package/dist/web/_app/immutable/chunks/{DNYbjOaP.js → Dit7T_60.js} +1 -1
  42. package/dist/web/_app/immutable/chunks/{DRtMiAD1.js → DniDptuo.js} +1 -1
  43. package/dist/web/_app/immutable/chunks/{f7230SaD.js → Dt99Jcr8.js} +1 -1
  44. package/dist/web/_app/immutable/chunks/{CaHm756F.js → DugivwY9.js} +1 -1
  45. package/dist/web/_app/immutable/chunks/{DacjMGks.js → Dw7Sq8IR.js} +1 -1
  46. package/dist/web/_app/immutable/chunks/{a_ihwmm02.js → MXrRh4dk2.js} +1 -1
  47. package/dist/web/_app/immutable/chunks/{cN1Vezp8.js → S_DgSTkW.js} +1 -1
  48. package/dist/web/_app/immutable/chunks/{1MjabJ2y.js → W5k7a-QV.js} +1 -1
  49. package/dist/web/_app/immutable/chunks/{Dus9RJnX2.js → WAeGDMPX2.js} +1 -1
  50. package/dist/web/_app/immutable/chunks/{32ZqrXeC.js → e5xEtGm1.js} +1 -1
  51. package/dist/web/_app/immutable/chunks/{CXMSw0Gf.js → g85hKyUf.js} +1 -1
  52. package/dist/web/_app/immutable/chunks/{BMm0Dns5.js → gxhkVvxw.js} +1 -1
  53. package/dist/web/_app/immutable/chunks/{C53vhDyz.js → k_3Qxul-.js} +1 -1
  54. package/dist/web/_app/immutable/chunks/{9cc0wIur.js → mAe-xkZ5.js} +1 -1
  55. package/dist/web/_app/immutable/chunks/{TVhYnQhc2.js → mzmLqxIL2.js} +1 -1
  56. package/dist/web/_app/immutable/chunks/{Bus_PL05.js → nk_jK3mi.js} +2 -2
  57. package/dist/web/_app/immutable/chunks/ns8IDc3J2.js +1015 -0
  58. package/dist/web/_app/immutable/chunks/{B2K0a29Z.js → w39YugU0.js} +1 -1
  59. package/dist/web/_app/immutable/chunks/{BWrF0LDh2.js → wTvwLetd2.js} +1 -1
  60. package/dist/web/_app/immutable/entry/{app.CXVr_1mn.js → app.asA3oozh.js} +2 -2
  61. package/dist/web/_app/immutable/entry/start.1hq4S0jc.js +1 -0
  62. package/dist/web/_app/immutable/nodes/{0.WobZPgRb.js → 0.CxBc1vj3.js} +2 -2
  63. package/dist/web/_app/immutable/nodes/{1.Ds4GVoUa.js → 1.B1L4Nyul.js} +1 -1
  64. package/dist/web/_app/immutable/nodes/{10.CCtH_YgK.js → 10.Dv3hqtLy.js} +1 -1
  65. package/dist/web/_app/immutable/nodes/{11.OEyD5wwi.js → 11.B1-7i_1D.js} +1 -1
  66. package/dist/web/_app/immutable/nodes/{12.BG9CEKwz.js → 12.D_N3425x.js} +1 -1
  67. package/dist/web/_app/immutable/nodes/{13.DFsy-Jad.js → 13.BKAEPqrR.js} +1 -1
  68. package/dist/web/_app/immutable/nodes/{15.Y01fbFfk.js → 15.CioLKzVG.js} +1 -1
  69. package/dist/web/_app/immutable/nodes/{16.DZtynUsu.js → 16.K1T5UXyE.js} +1 -1
  70. package/dist/web/_app/immutable/nodes/{18.XWkMsRgl.js → 18.ErciRWlQ.js} +1 -1
  71. package/dist/web/_app/immutable/nodes/{19.CPKwCWbX.js → 19.BiCgtBHI.js} +1 -1
  72. package/dist/web/_app/immutable/nodes/{2.jp2o7_ij.js → 2.E3wvnN4L.js} +4 -4
  73. package/dist/web/_app/immutable/nodes/{3.BCo_DVVm.js → 3.Dk1MM8ts.js} +1 -1
  74. package/dist/web/_app/immutable/nodes/{4.C8cH82Km.js → 4.BJmTpdeF.js} +3 -3
  75. package/dist/web/_app/immutable/nodes/{5.2QVTLq-n.js → 5.BdHisXZF.js} +1 -1
  76. package/dist/web/_app/immutable/nodes/{6.C6QAMtAs.js → 6.D_H81P5K.js} +1 -1
  77. package/dist/web/_app/immutable/nodes/{7.DemnHsNj.js → 7.fukWV5I6.js} +1 -1
  78. package/dist/web/_app/immutable/nodes/{8.Bvw_WIQp.js → 8.D0dAY6I3.js} +1 -1
  79. package/dist/web/_app/immutable/nodes/{9.Cjfu-GbA.js → 9.CNApQbMf.js} +1 -1
  80. package/dist/web/_app/version.json +1 -1
  81. package/dist/web/index.html +13 -13
  82. package/package.json +1 -1
  83. package/dist/web/_app/immutable/assets/FrameCanvas.DYfzMiiv.css +0 -1
  84. package/dist/web/_app/immutable/chunks/B_aGT4PE.js +0 -1
  85. package/dist/web/_app/immutable/chunks/CsGtqz-y.js +0 -1
  86. package/dist/web/_app/immutable/chunks/XA3JN08B2.js +0 -889
  87. package/dist/web/_app/immutable/entry/start.CBO1INN0.js +0 -1
@@ -233,16 +233,18 @@ You have access to tools in the following categories:
233
233
 
234
234
  **Creating skills — help the workspace teach itself.** When the user asks to "create a skill", "save this as a skill", "make this reusable", or "do it like this from now on" — load the `create-skill` skill and follow it. ALSO be **proactive**: after you produce something polished and reusable with a repeatable recipe (a branded document or deck style, a standard report format, a workflow), offer ONCE to save it as a reusable skill (e.g. *"Want me to save this as a reusable offer-letter skill?"*). Offer only for genuinely reusable, style-bearing work, at most once per piece of work; if declined, drop it. Saving a skill captures the recipe so the same house style is applied consistently next time — `create-skill` covers how to author and save it well (always ask which folder).
235
235
 
236
- **Artifact Canvas** — Use `create_artifact` to produce or update a persisted sandboxed canvas artifact from an HTML/CSS/JS bundle. Use `inspect_artifact` to visually inspect the rendered artifact with Playwright, including individual slides/pages/frames. This is appropriate for slide decks, letterhead documents, social graphics, prototypes, diagrams, small interactive tools, and other visual outputs.
236
+ **Artifact Canvas** — Use `create_artifact` to produce or update a persisted sandboxed canvas artifact from an HTML/CSS/JS bundle. Use `inspect_artifact` to visually inspect the rendered artifact with Playwright, including individual slides/pages/frames. Artifacts are for **designed, laid-out, visual** outputs: slide decks, social graphics, posters/diagrams, prototypes, small interactive tools, and documents the user wants *designed* on letterhead / as a formatted PDF.
237
+
238
+ **Entry or artifact? Decide before reaching for `create_artifact`.** A request to *draft / write / put together* a proposal, contract, memo, report, or brief as **prose** wants a **`document` entry** (editable markdown in the graph) — that is the DEFAULT, not a canvas artifact. Build a canvas artifact only when the user signals a **designed / laid-out / visual / print-ready** output: "on letterhead", "as a deck/slides", "a graphic/poster", "a formatted or branded PDF", "make it look like…", a specific visual treatment. *"Draft a proposal for Acme"* → a `document` entry; *"draft a proposal for Acme on our letterhead"* or *"design a proposal"* → an artifact. When it's ambiguous, prefer the entry (cheaper, editable) or ask: *"Want this as an editable document, or designed on letterhead as a canvas artifact?"* The frame-structure rules below apply only once you've decided it IS an artifact.
237
239
 
238
240
  The platform owns arrangement, stepping, and pagination — so **match the artifact type to its frame structure** and never hand-roll a stepper, filmstrip, pagination, or page grid inside one frame:
239
241
  - **Slide deck** → N `slides` frames, one per slide (e.g. 1280×720 or 1920×1080).
240
- - **Document** (letter, contract, proposal, report anything paginated on letterhead) → ONE `pages` frame whose `content` is the WHOLE document body at a fixed page size (US-Letter `816×1056`; also Legal `816×1344`, Tabloid `1056×1632`, A4 `794×1123`, A3 `1123×1587`, A5 `559×794`). The platform flows the text across as many pages as needed, numbers them, and exports a real multi-page PDF. Style it as rich HTML/CSS; for repeating letterhead/headers/footers use standard CSS Paged Media (`@page` margin boxes + `position: running()`; a full-bleed branded band runs edge-to-edge with side margins `0` + a padded body) — which overrides the platform defaults. (The `furniture`/`pageMargins` frame fields are an optional shortcut for a plain inset header/footer.) NEVER set a document's height to `auto`, NEVER split it into one frame per page, and NEVER build a page grid inside an `app`/`artboard` frame.
242
+ - **Designed document** (a letter, contract, proposal, or report the user wants laid out *on letterhead / as a formatted PDF* — NOT a plain prose draft, which is a `document` entry per the gate above) → ONE `pages` frame whose `content` is the WHOLE document body at a fixed page size (US-Letter `816×1056`; also Legal `816×1344`, Tabloid `1056×1632`, A4 `794×1123`, A3 `1123×1587`, A5 `559×794`). The platform flows the text across as many pages as needed, numbers them, and exports a real multi-page PDF. Style it as rich HTML/CSS; for repeating letterhead/headers/footers use standard CSS Paged Media (`@page` margin boxes + `position: running()`; a full-bleed branded band runs edge-to-edge with side margins `0`, and footer/header text in the 0-margin boxes is `padding`-inset to the body column so it doesn't hit the page edge) — which overrides the platform defaults. (The `furniture`/`pageMargins` frame fields are an optional shortcut for a plain inset header/footer.) NEVER set a document's height to `auto`, NEVER split it into one frame per page, and NEVER build a page grid inside an `app`/`artboard` frame.
241
243
  - **Graphic / poster / diagram** → `artboard` frame(s) at a fixed size.
242
244
  - **App / prototype** → a single `app` frame with fill geometry.
243
245
  - **Whiteboard** → a single `whiteboard` frame.
244
246
 
245
- After `create_artifact` / `patch_artifact`, the result reports the resolved frame structure (manifest) and any warnings — verify the frame count and per-frame layouts match what the user asked for (a deck is N `slides` frames, not one `app` frame); if they don't, or a warning fired, fix it before responding. Load the `artifact-canvas` skill before creating a canvas artifact. Canvas artifacts are graph entries that open in the center content well, with PDF, PNG, and HTML downloads available from the artifact toolbar. For 3D, data visualization, and animation, request curated local libraries in the bundle (`three`, `d3`, `motion`) rather than embedding CDN dependencies.
247
+ After `create_artifact` / `patch_artifact`, the result reports the resolved frame structure (manifest) and any warnings — verify the frame count and per-frame layouts match what the user asked for (a deck is N `slides` frames, not one `app` frame); if they don't, or a warning fired, fix it before responding. Load the `artifact-canvas` skill before creating a canvas artifact, and additionally the `paged-documents` skill before creating or editing a multi-page document (a `pages` frame) — it is the deep CSS Paged Media reference and requires you to render-and-inspect the result. Canvas artifacts are graph entries that open in the center content well, with PDF, PNG, and HTML downloads available from the artifact toolbar. For 3D, data visualization, and animation, request curated local libraries in the bundle (`three`, `d3`, `motion`) rather than embedding CDN dependencies.
246
248
 
247
249
  ### Tool Selection
248
250
 
@@ -1,15 +1,48 @@
1
1
  ---
2
2
  name: artifact-canvas
3
- description: Create sandboxed canvas artifacts as an ordered list of frames (HTML/CSS/JS); the platform arranges, steps, and paginates them — a deck is one `slides` frame per slide, a document (letter/contract/proposal) is ONE fixed-page-box `pages` frame the platform flows across pages with letterhead furniture, so never hand-roll a deck/stepper/page-grid.
3
+ description: Create sandboxed canvas artifacts as an ordered list of frames (HTML/CSS/JS) — for DESIGNED, laid-out, visual output (decks, graphics, prototypes, and documents the user wants designed on letterhead / as a formatted PDF). A plain prose draft of a proposal/contract/memo is a `document` entry, not an artifact. The platform arranges, steps, and paginates frames — a deck is one `slides` frame per slide, a designed letterhead document is ONE fixed-page-box `pages` frame flowed across pages so never hand-roll a deck/stepper/page-grid.
4
4
  loading: on-demand
5
5
  ---
6
6
 
7
7
  # Artifact Canvas
8
8
 
9
- Use this skill when the user asks for a visual or interactive output that should appear in the Studiograph canvas: slide decks, letterhead/print documents, social graphics, diagrams, prototypes, whiteboards, calculators, one-off tools, or any other artifact you can express as HTML/CSS/JS.
9
+ Use this skill when the user asks for a visual or interactive output that should appear in the Studiograph canvas: slide decks, designed letterhead/print documents, social graphics, diagrams, prototypes, whiteboards, calculators, one-off tools, or any other artifact you can express as HTML/CSS/JS.
10
+
11
+ > **Entry or artifact? Decide before you build.** A canvas artifact is for a **designed, laid-out, visual** output. If the user just wants to *draft / write / put together* a proposal, contract, memo, report, or brief as **prose**, that is a **`document` entry** (editable markdown in the graph) — NOT an artifact. Build a document *artifact* only when they signal a designed / print output: "on letterhead", "as a formatted/branded PDF", "design a proposal", a specific visual treatment. *"Draft a proposal for Acme"* → a `document` entry; *"draft a proposal for Acme on our letterhead"* / *"design a proposal"* → an artifact. When it's ambiguous, prefer the document entry (cheaper, editable) or ask: *"Want this as an editable document, or designed on letterhead?"* Decks, graphics, prototypes, and whiteboards are always artifacts — this gate is really about **prose documents**. The rest of this skill assumes you've decided it IS an artifact.
10
12
 
11
13
  An artifact is an **ordered list of frames** (the Figma/Paper artboard sense). Each frame owns its own content and geometry; the **platform** owns the arrangement (a tidy row-major grid), the present/export sequence, the stepper, scaling, and all canvas chrome. You author **content per frame** — you never write deck/stepper/grid machinery yourself.
12
14
 
15
+ ## Choose the artifact type FIRST (route the prompt)
16
+
17
+ Before you build anything, decide which kind of artifact the prompt is asking for. This one decision drives the frame count, the layout, and the whole bundle — getting it wrong (a document built as one `app` frame, a deck built as a single frame, a one-page flyer paying the pagination cost) is the most common failure. Match the user's intent:
18
+
19
+ | The user is asking for… | Build | Layout & frame count | Notes |
20
+ |---|---|---|---|
21
+ | a presentation, slide deck, pitch | a **deck** | one `slides` frame **per slide** (N → N frames) | stepped in present; never one frame for the whole deck |
22
+ | a **flowing** document — letter, contract, report, proposal, agreement of continuous / variable-length text | a **paginated document** | **ONE** `pages` frame holding the whole body | the platform auto-flows + paginates it (Paged.js). Never one frame per page. **Load `paged-documents`.** |
23
+ | a **fixed single page** — flyer, poster, invoice, certificate, cover, menu, one-page letter | an **artboard** | one `artboard` frame at the page size | you compose it to fit; no Paged.js |
24
+ | a **composed multi-page** document — brochure, multi-page form, designed report where each page is its own layout | **artboards** | one `artboard` frame **per page** (N → N frames) | each page composed by hand; exports an N-page PDF; no Paged.js |
25
+ | a social graphic, banner, ad, diagram, chart, infographic | an **artboard** | one `artboard` frame at its fixed size | the canvas size IS the design |
26
+ | an app screen, prototype, UI mockup, tool, calculator, dashboard, landing page | an **app** | one `app` frame (`fill`, or fixed width + `fill` height) | single frame; reflows/interacts |
27
+ | a brainstorm, mind-map, moodboard, concept map, freeform layout | a **whiteboard** | one large `whiteboard` frame | absolute placement, pannable |
28
+
29
+ ### Documents — FLOW vs COMPOSE (this picks `pages` vs `artboard`)
30
+
31
+ For anything document-shaped, the decision that matters is: does the platform need to **flow** a continuous text stream, or are you **composing** the pages yourself?
32
+
33
+ - **FLOW → `pages` (Paged.js).** ONE continuous content stream that the platform fragments across as many pages as the text needs — used precisely *because* you don't want to decide where the breaks fall (a long contract, a report of unknown length). Paged.js also repeats the letterhead on every page for free. **This is the only case that loads Paged.js** (~500KB + processing).
34
+ - **COMPOSE → `artboard` (no Paged.js).** Each page is a fixed surface you lay out yourself — **one** frame for a single page, **N** frames for a multi-page doc whose pages are each their own composition. Faster, exports one PDF page per frame; you place content per page and repeat any header per frame (a shared CSS class).
35
+
36
+ Deciding question: **"Do I want the platform to break a text stream into pages for me?"** Yes → `pages`. No (it's one page, or I'm composing each page) → `artboard`. The moment you'd be manually splitting flowing text into page-frames, switch to `pages`; the moment a "document" is really one fixed page, use `artboard` and skip the pagination cost.
37
+
38
+ Caveat: an `artboard` **crops** overflow (no pagination net) — use it for content you control to fit; if the length is uncertain, `pages` is safer. The verify loop catches a cropped artboard (`framesOverflowing`).
39
+
40
+ ### Other tie-breakers
41
+ - **Deck vs document:** a deck is *presented* (stepped, landscape, sparse slides); a document is *read or printed* (portrait pages, dense text, page numbers).
42
+ - **Artboard vs app:** an artboard is a fixed static surface; an app reflows and can be interactive.
43
+
44
+ A single artifact is almost always ONE type. Only mix layouts when the user genuinely asks for distinct things together; otherwise commit to one type and build it well.
45
+
13
46
  ## Workflow
14
47
 
15
48
  1. Gather the source material from the user's prompt and any relevant entries.
@@ -78,6 +111,8 @@ Each frame:
78
111
 
79
112
  **Letterhead, running headers & footers — use general CSS Paged Media.** A `pages` document is plain HTML/CSS — design it as richly as you like (full-bleed colored bands, logos, zebra-striped tables, multi-column footers). To make content **repeat on every page** (a letterhead, running header, footer, page numbers), use **standard CSS Paged Media** in a `shared` CSS file — the open, fully-flexible mechanism (Paged.js renders it). This is the PRIMARY way; aim for a real designed letterhead, not a plain text line.
80
113
 
114
+ > **Building a multi-page document, load the `paged-documents` skill first.** It is the deep, effective-use reference for the pagination layer — `@page` rules, named/cover pages, the page-margin-box **width** mechanics that decide whether a running header clips, running elements for real letterhead, page counters, break control, and the mandatory render-and-inspect verify loop. The summary below gets you started; that skill is how you do it *well*.
115
+
81
116
  - Mark an element as *running* and pull it into a page-margin box. Put the element once at the top of the frame `content`; it renders in the margin of EVERY page:
82
117
  ```css
83
118
  .letterhead { position: running(lh); }
@@ -89,12 +124,18 @@ Each frame:
89
124
  }
90
125
  ```
91
126
  You get the full surface: any of the 16 margin boxes (`@top-left`/`@bottom-right`/…), `:first`/`:left`/`:right` page selectors, named pages, counters.
92
- - **Full-bleed branded band** (a colored letterhead that runs edge-to-edge): set the side page margins to `0`, give the running element a background + fixed height, and pad the body itself:
127
+ - **Full-bleed branded band** (a colored letterhead that runs edge-to-edge): set the side page margins to `0`, give the running element a background + fixed height, and position its left/right parts with **`position:absolute`**. Do NOT use flex/table to spread them: that layout does NOT survive Paged.js's clone into the margin box (the parts collapse stacked + centered) — absolute children anchor to the band's edges and DO render correctly. (Verified by render.) **Footer/header TEXT needs its own inset when side margins are `0`:** the band is meant to bleed, but `@bottom-left`/`@bottom-right`/`@top-*` text in a 0-margin page sits flush against the paper edge. Margin boxes accept `padding`, so pad each text slot to your body gutter (`padding-left`/`padding-right: 64px`) — only the band bleeds; the furniture aligns to the column.
93
128
  ```css
94
- @page { margin: 104px 0 64px; @top-center { content: element(band); } }
95
- .band { position: running(band); height:104px; background:#16315c; color:#fff;
96
- display:flex; justify-content:space-between; align-items:center; padding:0 64px; }
97
- .doc { padding: 0 64px; } /* the body supplies its own side gutters */
129
+ @page {
130
+ margin: 104px 0 64px; /* side margins 0 → the band bleeds */
131
+ @top-center { content: element(band); }
132
+ @bottom-left { content: "Confidential"; padding-left: 64px; } /* inset the text to the column */
133
+ @bottom-right{ content: counter(page); padding-right: 64px; } /* (margins are 0, so pad each box) */
134
+ }
135
+ .band { position: running(band); height:104px; background:#16315c; color:#fff; }
136
+ .brand { position:absolute; left:64px; top:50%; transform:translateY(-50%); }
137
+ .addr { position:absolute; right:64px; top:50%; transform:translateY(-50%); text-align:right; }
138
+ .doc { padding: 0 64px; } /* the body supplies its own side gutters */
98
139
  ```
99
140
  - Anything you author this way **overrides the platform defaults** (the default margins + the auto page number) — you are in full control.
100
141
 
@@ -110,8 +151,8 @@ The platform also offers two **optional shortcuts** for the simple case; any aut
110
151
  ### Layouts
111
152
 
112
153
  - **`slides`** — a fixed-size deck frame (e.g. `1280×720` or `1920×1080`), stepped one at a time in present. One frame = one slide.
113
- - **`pages`** — a print/document frame. Give it a **fixed page-box width AND height** (US-Letter `816×1056`; Legal `816×1344`; Tabloid `1056×1632`; A4 `794×1123`; A3 `1123×1587`; A5 `559×794` — all @96dpi portrait; swap width/height for landscape) and put the **whole document body** in ONE `pages` frame's `content`. The platform **flows the text across as many pages as needed**, numbers them ("Page N of M"), and exports a real multi-page PDF. A fixed `pages` box does NOT crop — overflow flows onto the next page. Use `break-before: page` to force a new page (e.g. a new section/exhibit) and `break-inside: avoid` to keep a block together; for repeating letterhead/headers/footers style with **CSS Paged Media** (see "Letterhead, running headers & footers" above). This is the model for letters, contracts, proposals, agreements, and multi-page reports. (A `pages` frame with `height: "auto"` is the exception: it is NOT paginatedit renders as one tall continuous page. Use it only for a deliberately single, scroll-not-paginate document.)
114
- - **`artboard`** — a fixed-size design surface: banner, social graphic, diagram, poster.
154
+ - **`pages`** — a **flowing** print/document frame, the only layout that loads Paged.js. Use it when the platform should auto-flow a continuous text stream across pages. Give it a **fixed page-box width AND height** — any size @96dpi, portrait/landscape/arbitrary (common presets: US-Letter `816×1056`, Legal `816×1344`, Tabloid `1056×1632`, A4 `794×1123`, A3 `1123×1587`, A5 `559×794`) — and put the **whole document body** in ONE `pages` frame's `content`. The platform flows the text across as many pages as needed, numbers them, and exports a real multi-page PDF. A fixed `pages` box does NOT crop — overflow flows onto the next page. Use `break-before: page` to force a new page and `break-inside: avoid` to keep a block together; for repeating letterhead, **load the `paged-documents` skill**. The model for letters, contracts, proposals, agreements, and variable-length reports. (A `pages` frame with `height: "auto"` is NOT paginated and does not load Paged.js — one tall continuous page; use it for a deliberately single scroll.) **If the document is one fixed page, or pages you compose by hand, use `artboard` instead** (no Paged.js) — see the router.
155
+ - **`artboard`** — a **fixed-size composed surface**: a banner, social graphic, diagram, or poster, AND the non-paginated document surface — a single fixed page (flyer, invoice, certificate, one-pager) as ONE `artboard` frame, or a multi-page document you compose page-by-page as N `artboard` frames (one per page, exported as an N-page PDF). No Paged.js. A fixed `artboard` CROPS overflow, so design it to fit (or use `pages` if the length is uncertain).
115
156
  - **`app`** — a full-bleed responsive prototype / app screen. Use `geometry: { "width": "fill", "height": "fill" }` to span the whole viewport (content reflows). For a fixed-width app (a phone / tablet / sidebar mock), set a numeric `width` with `"height": "fill"` — the platform centers and letterboxes it at that width and fills height, rather than stretching edge-to-edge. An `app` artifact is single-frame.
116
157
  - **`whiteboard`** — one large pannable freeform surface (e.g. `2400×1600`). Opens at 100% centered and pans; no stepper. The platform draws a dot-grid surface; you place content (notes, diagrams, images) absolutely.
117
158
 
@@ -119,7 +160,7 @@ The platform also offers two **optional shortcuts** for the simple case; any aut
119
160
 
120
161
  `width` is a number (px) or `"fill"`. `height` is a number, `"auto"` (content-driven), or `"fill"`. `"fill"` = span the available viewport (single-frame `app`).
121
162
 
122
- **On a `pages` frame, a fixed page-box height does NOT crop — it paginates.** A multi-page document (letter, contract, proposal, report) is a `pages` frame with a fixed page-box width AND height (e.g. `816×1056`); the platform flows the overflow onto more pages. This is almost always what you want for a written document, so it can print on letterhead with page numbers. `height: "auto"` on a `pages` frame turns pagination OFF (one tall continuous page) — use it only when you deliberately want a single non-paginated scroll.
163
+ **On a `pages` frame, a fixed page-box height does NOT crop — it paginates.** A *flowing* multi-page document (a letter/contract/report whose text runs to an unknown length) is a `pages` frame with a fixed page-box width AND height (e.g. `816×1056`); the platform flows the overflow onto more pages and prints letterhead + page numbers. Reach for `pages` when you want that auto-flow; for a single fixed page or hand-composed pages, use `artboard` frames (no Paged.js) see the router. `height: "auto"` on a `pages` frame turns pagination OFF (one tall continuous page, no Paged.js) — for a deliberately single non-paginated scroll.
123
164
 
124
165
  **On a non-`pages` frame, a fixed numeric height CROPS content taller than it** — the frame is a hard box with `overflow:hidden`, so anything past the declared height is clipped from view. For a content-driven `app`/`artboard` surface whose length you can't predict, declare `height: "auto"` so it grows to fit; do NOT guess a tall fixed number (e.g. `4000`) "to be safe". Use a fixed numeric height for genuinely fixed surfaces (a `slides` deck, a poster/banner `artboard`) where the canvas size IS the design.
125
166
 
@@ -191,7 +232,7 @@ Each slide is one `slides` frame; the shared `deck.css` styles every frame; the
191
232
 
192
233
  ## Example — a flowing letterhead document (full-bleed band via CSS Paged Media)
193
234
 
194
- A letter, contract, or proposal is ONE `pages` frame at a fixed page size; the `content` is the whole body and the platform flows it across pages. The letterhead is a **running element** placed in a `@page` margin box, so it repeats on every page; side margins are `0` so the band runs edge-to-edge, and the body supplies its own gutters. (Page numbers come from the `@bottom-right` counter; `.foot` is a running footer.)
235
+ A *flowing* letter, contract, or proposal is ONE `pages` frame at a fixed page size; the `content` is the whole body and the platform flows it across pages. (A single fixed page or a multi-page document you compose by hand is an `artboard` instead — see the router; this example is the auto-flow case.) The letterhead is a **running element** in a `@page` margin box, so it repeats on every page; side margins are `0` so the band runs edge-to-edge, and the band's logo/address are placed with **`position:absolute`** (flex/table collapse inside a Paged.js margin box — verified). The footer is `@bottom-left`/`@bottom-right` margin boxes **padded to the body gutter** (side margins are `0`, so without the `padding` the footer would sit on the paper edge); the page size comes from `geometry`, so there is **no `@page { size }`**.
195
236
 
196
237
  ```json
197
238
  {
@@ -199,7 +240,7 @@ A letter, contract, or proposal is ONE `pages` frame at a fixed page size; the `
199
240
  "title": "Offer of Employment",
200
241
  "shared": {
201
242
  "files": {
202
- "doc.css": "*{box-sizing:border-box}body{margin:0;font:14px/1.6 -apple-system,Segoe UI,Roboto,sans-serif;color:#1f2937}.doc{padding:28px 64px}h2{color:#16315c;font-size:13px;letter-spacing:.06em;text-transform:uppercase;border-bottom:1px solid #e5e7eb;padding-bottom:6px;margin:22px 0 12px}p{margin:0 0 12px}table{width:100%;border-collapse:collapse;font-size:13px}td{padding:9px 12px;border-bottom:1px solid #eef2f7}tr:nth-child(odd) td{background:#f7f9fc}.band{position:running(band);height:104px;background:#16315c;color:#fff;display:flex;align-items:center;justify-content:space-between;padding:0 64px}.brand{display:flex;align-items:center;gap:14px}.logo{width:40px;height:40px;border-radius:8px;background:#e8492b;color:#fff;display:flex;align-items:center;justify-content:center;font-weight:800;font-size:22px}.brand b{font-size:22px}.brand small{display:block;color:#9fb3d1;font-size:10px;letter-spacing:.12em}.addr{text-align:right;font-size:11px;color:#cdd9ea}.foot{position:running(foot);display:flex;justify-content:space-between;font-size:10px;color:#9ca3af;padding:0 64px}.foot .c{color:#e8492b;font-weight:600}.exhibit{break-before:page}@page{size:816px 1056px;margin:104px 0 70px;@top-center{content:element(band)}@bottom-center{content:element(foot)}@bottom-right{content:\"Page \" counter(page) \" of \" counter(pages)}}"
243
+ "doc.css": "*{box-sizing:border-box}body{margin:0;font:14px/1.6 -apple-system,Segoe UI,Roboto,sans-serif;color:#1f2937}.doc{padding:28px 64px}h2{color:#16315c;font-size:13px;letter-spacing:.06em;text-transform:uppercase;border-bottom:1px solid #e5e7eb;padding-bottom:6px;margin:22px 0 12px}p{margin:0 0 12px}table{width:100%;border-collapse:collapse;font-size:13px}td{padding:9px 12px;border-bottom:1px solid #eef2f7}tr:nth-child(odd) td{background:#f7f9fc}.band{position:running(band);height:104px;background:#16315c;color:#fff}.brand{position:absolute;left:64px;top:34px}.logo{display:inline-block;width:40px;height:40px;border-radius:8px;background:#e8492b;color:#fff;text-align:center;line-height:40px;font-weight:800;font-size:22px;vertical-align:middle;margin-right:14px}.btxt{display:inline-block;vertical-align:middle}.btxt b{font-size:20px}.btxt small{display:block;color:#9fb3d1;font-size:10px;letter-spacing:.12em}.addr{position:absolute;right:64px;top:38px;text-align:right;font-size:11px;color:#cdd9ea;line-height:1.5}.exhibit{break-before:page}@page{margin:104px 0 70px;@top-center{content:element(band)}@bottom-left{content:\"Confidential\";padding-left:64px;font-size:10px;color:#9ca3af}@bottom-right{content:\"Page \" counter(page) \" of \" counter(pages);padding-right:64px;font-size:10px;color:#9ca3af}}"
203
244
  }
204
245
  },
205
246
  "frames": [
@@ -207,7 +248,7 @@ A letter, contract, or proposal is ONE `pages` frame at a fixed page size; the `
207
248
  "id": "letter",
208
249
  "layout": "pages",
209
250
  "geometry": { "width": 816, "height": 1056 },
210
- "content": "<div class=\"band\"><div class=\"brand\"><div class=\"logo\">A</div><div><b>Acme Inc.</b><small>PEOPLE &amp; TALENT</small></div></div><div class=\"addr\">1 Acme Plaza, Suite 800<br>San Francisco, CA 94105<br>hr@acmeinc.com</div></div><div class=\"foot\"><span class=\"c\">Confidential</span><span>Offer Letter — Jordan Lee</span><span>June 17, 2026</span></div><div class=\"doc\"><p style=\"color:#6b7280\">June 17, 2026</p><p><b>Jordan Lee</b><br>742 Evergreen Terrace<br>Portland, OR 97201</p><p>Dear Jordan,</p><p>On behalf of the entire team at Acme Inc., it is our great pleasure to extend this offer…</p><h2>Position Details</h2><table><tr><td>Job Title</td><td>Senior Product Manager</td></tr><tr><td>Start Date</td><td>July 14, 2026</td></tr></table><section class=\"exhibit\"><h2>Conditions of Employment</h2><p>…</p></section></div>"
251
+ "content": "<div class=\"band\"><div class=\"brand\"><span class=\"logo\">A</span><span class=\"btxt\"><b>Acme Inc.</b><small>PEOPLE &amp; TALENT</small></span></div><div class=\"addr\">1 Acme Plaza, Suite 800<br>San Francisco, CA 94105<br>hr@acmeinc.com</div></div><div class=\"doc\"><p style=\"color:#6b7280\">June 17, 2026</p><p><b>Jordan Lee</b><br>742 Evergreen Terrace<br>Portland, OR 97201</p><p>Dear Jordan,</p><p>On behalf of the entire team at Acme Inc., it is our great pleasure to extend this offer…</p><h2>Position Details</h2><table><tr><td>Job Title</td><td>Senior Product Manager</td></tr><tr><td>Start Date</td><td>July 14, 2026</td></tr></table><section class=\"exhibit\"><h2>Conditions of Employment</h2><p>…</p></section></div>"
211
252
  }
212
253
  ]
213
254
  }
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: paged-documents
3
+ description: How to author multi-page print documents (letters, contracts, proposals, reports, briefs) WELL with CSS Paged Media — the platform paginates a `pages` frame with Paged.js. Deep technical know-how for @page rules, named/cover pages, page-margin boxes, running letterhead/headers/footers, page counters, and break control, plus the mandatory render-and-inspect verify loop. Load this whenever you build or edit a paginated document (a `pages` frame); it is the layer beneath any house-style skill.
4
+ loading: on-demand
5
+ ---
6
+
7
+ # Paged documents — using CSS Paged Media (Paged.js) well
8
+
9
+ Load this when you build or edit a **flowing** document: a single `pages` frame whose continuous text the platform fragments across pages with Paged.js (letters, contracts, proposals, agreements, reports, briefs, memos of variable / unknown length). The `artifact-canvas` skill covers the frame model; this skill is the deep, effective-use reference for the pagination layer. A workspace **house-style** skill (if one exists) sits ON TOP of this — that one carries the org's specific letterhead, type scale, and conventions; this one is the universal craft of making Paged Media render correctly.
10
+
11
+ **First check you actually need pagination.** `pages` + Paged.js is for AUTO-FLOWING a continuous stream across pages. If the document is a **single fixed page** (flyer, poster, invoice, certificate, one-pager) or a **multi-page document you compose page by page** (brochure, multi-page form, designed report), build it as `artboard` frame(s) instead — one frame per page — which skips Paged.js entirely (it's heavier and slower to load). See the router in `artifact-canvas`. Use this skill only when you want the platform to break a text stream into pages for you.
12
+
13
+ The single most important habit: **a document is print-bound — you cannot eyeball it like a deck. You MUST render and inspect it, then fix what the render shows, before you say it's done.** See "The verify loop" at the end. Most document defects (a clipped running header, a heading stranded at a page bottom, an orphaned rule) are invisible in the source and obvious in the render.
14
+
15
+ ## Mental model
16
+
17
+ You author **one ordinary HTML document body** plus **CSS Paged Media rules**. Paged.js fragments that one flowing body into as many fixed-size pages as the content needs, and repeats your letterhead/headers/footers on every page. You do NOT build pages by hand — no per-page frames, no page-height spacer divs, no manual page grid. Write the body once; write `@page` rules for the furniture; let the platform paginate.
18
+
19
+ ```
20
+ ONE <pages> frame ──Paged.js──▶ page 1 │ page 2 │ page 3 │ … (real multi-page PDF)
21
+ whole body each carries your @page margins + running header/footer + page number
22
+ ```
23
+
24
+ ## The platform contract (what we give you, what is fixed)
25
+
26
+ Your CSS reaches Paged.js from **shared `.css` files AND inline `<style>` in the frame `content`** — both are honored for `@page` / break / named-page / running-element rules. Relative `url()` (fonts, images) is fine; the platform handles it. Then:
27
+
28
+ - **Page SIZE is the frame `geometry` — ANY width × height, and the platform LOCKS it.** The page can be any size in px @96dpi, **portrait, landscape, or arbitrary** — there is no canonical "default." Common print presets (portrait; swap width↔height for landscape): US-Letter `816×1056`, Legal `816×1344`, Tabloid `1056×1632`, A4 `794×1123`, A3 `1123×1587`, A5 `559×794`. But a custom size is equally valid — a landscape report `1056×816`, a square `1000×1000`, a wide spread `1632×816`, a tall menu `612×1584`. Pick the geometry the document calls for. **Do NOT write `@page { size: … }`** (or `size: letter`) — the platform appends the authoritative `@page { size }` (your chosen geometry) LAST, so yours is ignored. Sizing the page is the geometry's job; everything else below is relative to it.
29
+ - **The platform gives you sensible defaults that your CSS overrides:** a default `@page { margin }` (from the frame's `pageMargins`, else top 96 / sides 72 / bottom 84) and a default **"Page N of M"** counter in `@bottom-right`. Write your own `@page { margin }` or your own margin-box content and yours wins.
30
+ - **Cascade order:** platform defaults → **your CSS** → page-size lock. So your `@page`/margin/break/running rules win over the defaults; only the page size is beyond your reach.
31
+ - **Fixed height is required to paginate.** A `pages` frame with a fixed height (e.g. `1056`) flows overflow onto more pages. A `pages` frame with `height: "auto"` does NOT paginate — it renders as one tall continuous page. Use `auto` only for a deliberately single, non-paginated scroll.
32
+
33
+ ## `@page` rules and named pages
34
+
35
+ The base page:
36
+
37
+ ```css
38
+ @page {
39
+ margin: 96px 72px 84px; /* top sides bottom — illustrative, NOT canonical */
40
+ }
41
+ ```
42
+
43
+ **Margins are a design choice relative to the page, not fixed numbers.** Scale them to the geometry and the document: a big page (Tabloid/A3) wants larger margins than an A5; a landscape page often wants more side margin than top/bottom; a bound document wants an asymmetric inner/outer margin (`@page :left` / `:right`). The top/bottom margins must also leave room for your running header/footer (a tall letterhead needs a taller top margin). The platform's fallback when you set none is top 96 / sides 72 / bottom 84 px — fine for a Letter-ish portrait, but choose your own for any other size. Everywhere below, **the content width is `page-width − left-margin − right-margin`** and any element you size to the column should be derived from the geometry you picked, never a copied constant.
44
+
45
+ **Named pages** give a specific page its own rules — the classic use is a **cover page with no running header/footer**, then a forced break into the body:
46
+
47
+ ```css
48
+ @page cover { margin: 0; } /* full-bleed cover */
49
+ @page cover { @top-left { content: none } @top-right { content: none } @bottom-right { content: none } }
50
+ .cover { page: cover; break-after: page; } /* this element is the cover; body starts on the next page */
51
+ ```
52
+
53
+ `@page :first`, `@page :left`, `@page :right`, and `@page :blank` also work (e.g. mirrored margins for a bound document, or suppressing furniture on the first page).
54
+
55
+ ## Page-margin boxes — left/right header text, and the width trap
56
+
57
+ A running header/footer of **short text** lives directly in margin-box slots. The top edge has these (the bottom mirrors them); each slot positions itself, so left + right text needs no layout work:
58
+
59
+ ```
60
+ @top-left-corner │ @top-left │ @top-center │ @top-right │ @top-right-corner
61
+ ```
62
+
63
+ **The reliable two-part header — separate slots, no width:**
64
+
65
+ ```css
66
+ @page {
67
+ @top-left { content: "Acme Inc." } /* sits at the left of the top margin */
68
+ @top-right { content: "Project Brief" } /* sits at the right */
69
+ @bottom-right { content: counter(page) }
70
+ }
71
+ ```
72
+
73
+ **The width trap (this is the #1 document bug).** The top row's width is the page width minus the corners, **shared** among `@top-left` / `@top-center` / `@top-right`, and each box sizes to its own content. **Never put `width: 100%` (or a wide fixed width) on one margin box** — it steals the whole row and crushes the others, so their text wraps into a sliver and **clips** (a header that should read "Cooper Hewitt Brand Refresh" renders as "Hewitt / Brand / Refresh", cut off — the exact bug). Margin boxes also do NOT grow or wrap gracefully; they clip. So: keep each slot's `content` **short** (a few words), and to get a full-width underline under the header, do NOT reach for `width: 100%` — use a running element for the rule (below).
74
+
75
+ ## Running elements — for ONE repeated block (band, logo, rule), not for spreading parts
76
+
77
+ `position: running(name)` pulls an element out of the body flow and `content: element(name)` drops it into a margin box, repeated on every page. Use it for a **single content block**: a full-bleed colored band, a logo lockup, a centered title, or a full-width rule. It is real HTML/CSS — backgrounds, borders, a fixed height.
78
+
79
+ **Verified Paged.js limitation — do not lay out multiple parts with flex inside a running element.** When the element is cloned into the margin box, its **`display:flex` / `justify-content:space-between` does NOT spread** — the children collapse to their intrinsic size, centered (`<span>Acme</span><span>Brief</span>` renders as "AcmeBrief" in the middle, not left+right). So:
80
+
81
+ - **Left vs right text with NO shared background → use the two margin boxes above** (`@top-left` + `@top-right`), never a flex running element.
82
+ - **A band WITH a shared background that needs left + right content (logo left, address right) → one running element, lay the parts out with `position:absolute`.** Flex and `display:table` both collapse in the clone; **absolute** children anchor to the band's box and DO render correctly. Use **fixed px offsets**, not percentages — the band's height is not definite in the clone, so `top:50%` escapes to the page; `top:34px` stays in the band. (Verified by render.)
83
+
84
+ ```css
85
+ .band { position: running(band); height: 104px; background: #16315c; color: #fff; }
86
+ .brand { position: absolute; left: 64px; top: 34px; } /* logo + name lockup (inline-block inside is fine) */
87
+ .addr { position: absolute; right: 64px; top: 38px; text-align: right; }
88
+ @page {
89
+ margin: 110px 0 84px; /* side margins 0 → the band spans full width */
90
+ @top-center { content: element(band) }
91
+ @bottom-left { content: "Confidential"; padding-left: 64px } /* inset the footer text to the column */
92
+ @bottom-right{ content: counter(page); padding-right: 64px } /* (margins are 0, so pad each box) */
93
+ }
94
+ .doc { padding: 0 64px; } /* body supplies its own gutters */
95
+ ```
96
+
97
+ **The full-bleed-band footer trap.** Side margins `0` let the band bleed — but they also drop any `@bottom-left`/`@bottom-right`/`@top-*` TEXT onto the very paper edge (a page number jammed against the corner). Margin boxes accept `padding`, so **inset every text slot to your body column** with `padding-left`/`padding-right` matching the body gutter (`64px` above). Only the band is meant to bleed; the page number, confidential line, and any header text align to the column. (Verified by render — without the padding the footer sits at x≈0.)
98
+
99
+ For a **first-page-only / last-page-only** variant, attach the element on a named page (`@page :first { @top-center { content: element(coverhead) } }`). Put the running element **once**, near the top of `content`; it does not appear inline.
100
+
101
+ Whatever you build here, **confirm it in the render** (verify loop below) — margin-box and running-element layout has non-obvious behavior (the flex caveat above is exactly why), so looking at the pixels is the only way to know it landed.
102
+
103
+ ## Page counters
104
+
105
+ `counter(page)` is the current page, `counter(pages)` the total. The platform defaults to "Page N of M" bottom-right; override it with your own:
106
+
107
+ ```css
108
+ @page { @bottom-right { content: counter(page); font: 7.5pt 'Brand'; color: #666 } }
109
+ ```
110
+
111
+ `target-counter(attr(href url), page)` resolves the page of a target — use it for a table of contents or cross-references ("see p. 4").
112
+
113
+ ## Break control (the craft that separates clean from sloppy)
114
+
115
+ - `break-before: page` / `break-after: page` — start a section/exhibit on a fresh page.
116
+ - `break-inside: avoid` — keep a block together (a figure + caption, a table row, a signature block, a heading + its first lines).
117
+ - `break-after: avoid` on headings — so a heading is never stranded alone at the bottom of a page with its content on the next.
118
+ - `orphans` / `widows` (e.g. `p { orphans: 2; widows: 2 }`) — no single dangling line of a paragraph across a page break.
119
+ - **Do NOT emit a divider (`<hr>`, a `border-top` separator) immediately before a forced `break-before` section.** The page break already IS the separator; the divider lands orphaned at the bottom of the prior page. Put separators BETWEEN in-flow sections only, not where a page break does the dividing.
120
+
121
+ ## Vertical rhythm and spacing
122
+
123
+ Give headings real breathing room and keep spacing consistent (a single scale: e.g. space below a section heading ≥ the space between paragraphs, so headers don't read as glued to their body). A label-column layout (section label left, body right) needs the label and the body's first line to share a baseline. The EXACT scale (sizes, leading, margins) is **house style** — defer to the workspace house-style skill if one exists; absent that, pick one scale and apply it everywhere rather than ad-hoc values per section.
124
+
125
+ ## The verify loop (mandatory — not optional for documents)
126
+
127
+ After `create_artifact` / `patch_artifact`, **`inspect_artifact` the document and READ the rendered pages**, then fix and re-inspect until clean. A `pages` frame paginates rather than cropping, so it never appears in `framesOverflowing` — that is exactly why you must look at the pixels. Check, on the render:
128
+
129
+ - **Running header/footer fully visible** on every page — not clipped or wrapped (clipping ⇒ a margin box is too narrow, usually a `width` hack; switch to a running element or shorten the text).
130
+ - **No stranded headings** at page bottoms and **no orphaned rules/dividers** at page edges.
131
+ - **Tables and blocks break sanely** (no row split mid-cell, no header row alone at a page bottom).
132
+ - **Cover/first page** furniture is suppressed if intended; page numbers run 1…N.
133
+ - **Margins and the letterhead** look right on page 2+ (page 1 often differs).
134
+
135
+ Do not describe the structure and stop. Render it, look at it, fix what you see. The most common real defects (clipped headers, orphaned dividers, stranded headings) are invisible in the markup and obvious in the render — one inspect pass catches them.
136
+
137
+ ## Quick checklist
138
+
139
+ - [ ] ONE `pages` frame, fixed width AND height — the size the document needs (portrait, landscape, or arbitrary; via geometry, no `@page { size }`).
140
+ - [ ] Margins scaled to that page size (not copied Letter numbers); top/bottom leave room for the letterhead.
141
+ - [ ] Letterhead / multi-part header / full-width rule → a **running element**, not margin-box `width` hacks.
142
+ - [ ] Margin-box text is short and fits.
143
+ - [ ] Full-bleed band (side margins `0`)? Footer/header text slots `padding`-inset to the body column, not on the page edge.
144
+ - [ ] Cover/first page handled with a named page if it differs.
145
+ - [ ] `break-inside: avoid` on blocks that must stay together; `break-after: avoid` on headings; no divider right before a `break-before`.
146
+ - [ ] Consistent spacing scale (defer the exact scale to the house-style skill).
147
+ - [ ] **Rendered and inspected; the pages actually look right.**
@@ -64,7 +64,7 @@ export function createArtifactTools(onArtifact, options = {}) {
64
64
  {
65
65
  name: 'create_artifact',
66
66
  label: 'Create Artifact',
67
- description: 'Create or update a persisted sandboxed canvas artifact from an ordered list of frames (each a fragment of HTML/CSS/JS). Use this for slide decks, documents, social graphics, prototypes, diagrams, whiteboards, and other visual outputs. Match the artifact TYPE to its frame structure: a slide DECK is N "slides" frames, one per slide (e.g. 1280×720); a DOCUMENT — a letter, contract, proposal, report, anything paginated on letterhead — is ONE "pages" frame whose content is the WHOLE document body at a fixed page size (US-Letter 816×1056; also Legal 816×1344, Tabloid 1056×1632, A4 794×1123, A3 1123×1587, A5 559×794): the platform flows the text across as many pages as needed, numbers them, and exports a real multi-page PDF — so do NOT set a document\'s height to "auto", do NOT split it into one frame per page, and do NOT build a page grid inside an "app"/"artboard" frame. Style the document as rich HTML/CSS; for repeating letterhead/headers/footers use standard CSS Paged Media in a shared CSS file (`@page` margin boxes + `position: running()` — a full-bleed branded band runs edge-to-edge if you set the side page margins to 0 and pad the body), which overrides the platform defaults. (The "furniture" + "pageMargins" frame fields are an optional shortcut for a plain inset header/footer.) A GRAPHIC, poster, or diagram is "artboard" frame(s) at a fixed size; an APP or prototype is a single "app" frame with fill geometry; a WHITEBOARD is a single "whiteboard" frame. Never hand-roll a stepper, filmstrip, pagination, or page grid inside one frame — emit the right frames and let the platform arrange, step, and paginate. When chat is scoped to an artifact entry, this updates that canvas. If the user references another EXISTING artifact entry, pass target.entityId and target.repo when known. To create a SEPARATE new artifact while the chat is scoped to one, pass createNew: true (optionally with target.repo to pick the destination folder) — the scoped canvas is left untouched. Otherwise this creates a new artifact entry. To EDIT an existing artifact, first call read_artifact to get the current source and its hash, modify the full bundle, and pass that hash as baseHash so a concurrent change is detected instead of silently overwritten. The result reports the resolved frame structure (manifest) and any warnings — check the frame count and per-frame layouts against what the user asked for (a deck is N "slides" frames, not one "app" frame) and fix it before responding.',
67
+ description: 'Create or update a persisted sandboxed canvas artifact from an ordered list of frames (each a fragment of HTML/CSS/JS). Use this for DESIGNED, laid-out, visual outputs: slide decks, social graphics, prototypes, diagrams, whiteboards, and documents the user wants DESIGNED on letterhead / as a formatted PDF. A plain prose draft of a proposal, contract, memo, or report is a "document" ENTRY (create_entity), NOT an artifact — build a document artifact only when the user signals a designed/print output (on letterhead, a formatted PDF, "design a…"); when ambiguous, prefer the document entry or ask. Match the artifact TYPE to its frame structure: a slide DECK is N "slides" frames, one per slide (e.g. 1280×720); a designed DOCUMENT — a letter, contract, proposal, or report laid out on letterhead — is ONE "pages" frame whose content is the WHOLE document body at a fixed page size (US-Letter 816×1056; also Legal 816×1344, Tabloid 1056×1632, A4 794×1123, A3 1123×1587, A5 559×794): the platform flows the text across as many pages as needed, numbers them, and exports a real multi-page PDF — so do NOT set a document\'s height to "auto", do NOT split it into one frame per page, and do NOT build a page grid inside an "app"/"artboard" frame. Style the document as rich HTML/CSS; for repeating letterhead/headers/footers use standard CSS Paged Media in a shared CSS file (`@page` margin boxes + `position: running()` — a full-bleed branded band runs edge-to-edge if you set the side page margins to 0 and pad the body), which overrides the platform defaults. (The "furniture" + "pageMargins" frame fields are an optional shortcut for a plain inset header/footer.) A GRAPHIC, poster, or diagram is "artboard" frame(s) at a fixed size; an APP or prototype is a single "app" frame with fill geometry; a WHITEBOARD is a single "whiteboard" frame. Never hand-roll a stepper, filmstrip, pagination, or page grid inside one frame — emit the right frames and let the platform arrange, step, and paginate. When chat is scoped to an artifact entry, this updates that canvas. If the user references another EXISTING artifact entry, pass target.entityId and target.repo when known. To create a SEPARATE new artifact while the chat is scoped to one, pass createNew: true (optionally with target.repo to pick the destination folder) — the scoped canvas is left untouched. Otherwise this creates a new artifact entry. To EDIT an existing artifact, first call read_artifact to get the current source and its hash, modify the full bundle, and pass that hash as baseHash so a concurrent change is detected instead of silently overwritten. The result reports the resolved frame structure (manifest) and any warnings — check the frame count and per-frame layouts against what the user asked for (a deck is N "slides" frames, not one "app" frame) and fix it before responding.',
68
68
  parameters: T.Object({
69
69
  bundle: T.Object({}, {
70
70
  description: 'ArtifactBundle object with artifactId, title, and frames: an ordered, non-empty array of { id, title?, layout (slides|pages|artboard|app|whiteboard), geometry ({ width, height }), content (the frame\'s HTML fragment), background? (neutral|transparent|a safe CSS color or gradient — set it to the design\'s real surface so a dark/colored frame does not render white) }. A "pages" (document) frame also accepts furniture ({ header?: {first?,middle?,last?}, footer?: {first?,middle?,last?} } — per-page running header/footer for letterhead) and pageMargins ({ top?, right?, bottom?, left? } in px). Optional bundle-level: shared ({ files, head }) for code shared across frames, tokens (CSS design variables), libraries (three, d3, motion).',
@@ -1 +1 @@
1
- {"version":3,"file":"artifact-tools.js","sourceRoot":"","sources":["../../../src/agent/tools/artifact-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,IAAI,IAAI,CAAC,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAuB,MAAM,oCAAoC,CAAC;AACjG,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EACL,oCAAoC,EACpC,qBAAqB,EACrB,wBAAwB,GAGzB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAwDlD;;oFAEoF;AACpF,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAC9E,CAAC;AAED;;;;4EAI4E;AAC5E,MAAM,CAAC,MA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xG,CAAC;gBACD,IAAI,IAAI,CAAC;gBACT,IAAI,CAAC;oBACH,IAAI,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBACnD,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,OAAO,cAAc,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACrG,CAAC;gBACD,IAAI,CAAC;oBACH,MAAM,QAAQ,GAAG,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;oBACjF,OAAO,cAAc,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC;gBACpG,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,iEAAiE;oBACjE,OAAO,cAAc,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACrG,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -20,6 +20,7 @@ import { computeFrameLayout, FRAME_LAYOUT_DEFAULT_GAP } from './artifact-frame-l
20
20
  import { escapeAttribute, escapeHtml, escapeScript, escapeStyle } from './artifact-escape.js';
21
21
  import { applyAssetResolution, artifactCsp } from './artifact-asset-resolution.js';
22
22
  import { brokenImageScriptTag, libraryTags } from './artifact-libraries.js';
23
+ import { SANITIZE_CSS_URLS_TWIN } from './artifact-paged-css.js';
23
24
  /** Artboard fill for a frame that opts into `neutral`. The DEFAULT (unset) is
24
25
  * transparent — the frame's appearance comes from its own content, so an opaque
25
26
  * slide never shows a white artboard peeking around its edges. Authors opt into
@@ -1027,7 +1028,7 @@ ${furniturePositionCss()}`;
1027
1028
  * page box to one PDF page (`preferCSSPageSize`) — no guillotine.
1028
1029
  *
1029
1030
  * Runs after the Paged.js source defines the UMD global. */
1030
- function paginationBootstrap(frames, artifactId, promote, sharedCss, renderId) {
1031
+ function paginationBootstrap(frames, artifactId, promote, sharedCss, renderId, hostedCanvas) {
1031
1032
  const configById = {};
1032
1033
  for (const frame of frames) {
1033
1034
  configById[frame.id] = {
@@ -1046,7 +1047,16 @@ function paginationBootstrap(frames, artifactId, promote, sharedCss, renderId) {
1046
1047
  const renderId = ${JSON.stringify(renderId)};
1047
1048
  const GAP = ${FRAME_LAYOUT_DEFAULT_GAP};
1048
1049
  const PROMOTE = ${JSON.stringify(promote)};
1049
- const SHARED_CSS = ${JSON.stringify(sharedCss)};
1050
+ const HOSTED_CANVAS = ${JSON.stringify(hostedCanvas)};
1051
+ // Runtime twin of the core sanitizer (src/core/artifact-paged-css.ts), injected
1052
+ // verbatim. Neutralizes every non-absolute url() to about:blank in the CSS handed
1053
+ // to Paged.js, because Paged.js calls new URL(value) (no base) on each url() token
1054
+ // and a scheme-less ref throws synchronously, aborting the whole pagination run.
1055
+ // Only the Paged-fed copy is sanitized — the head <style> keeps real url()s and
1056
+ // paints fonts/backgrounds. Runs AFTER asset resolution (the embedded SHARED_CSS
1057
+ // is already token-rewritten), so it can't fight the ?at= rewrite.
1058
+ ${SANITIZE_CSS_URLS_TWIN}
1059
+ const SHARED_CSS = sanitizeCssUrlsForPagination(${JSON.stringify(sharedCss)});
1050
1060
  const PAGINATE = ${JSON.stringify(configById)};
1051
1061
  const cssEscape = (value) => (window.CSS && CSS.escape) ? CSS.escape(value) : String(value);
1052
1062
  // The UMD global is Paged (paged.js) or PagedModule (paged.min.js).
@@ -1093,6 +1103,10 @@ function paginationBootstrap(frames, artifactId, promote, sharedCss, renderId) {
1093
1103
  if (!Paged || !Paged.Previewer) return;
1094
1104
  try { if (document.fonts && document.fonts.ready) await document.fonts.ready; } catch {}
1095
1105
  const expansions = [];
1106
+ // Frames whose pagination THREW (e.g. a CSS pattern Paged.js still chokes on).
1107
+ // Reported to the host so it can surface a non-blocking "couldn't paginate"
1108
+ // hint instead of silently showing a clipped, margin-less single page.
1109
+ const failed = [];
1096
1110
  for (const id of Object.keys(PAGINATE)) {
1097
1111
  const source = document.querySelector('[data-sg-frame-id="' + cssEscape(id) + '"]');
1098
1112
  if (!source || !source.parentNode) continue;
@@ -1121,17 +1135,25 @@ function paginationBootstrap(frames, artifactId, promote, sharedCss, renderId) {
1121
1135
  if (node.tagName === 'STYLE') inlineCss += (node.textContent || '') + ' ';
1122
1136
  document.head.appendChild(node);
1123
1137
  });
1124
- // Promote: render offscreen, then move each page box out (the canvas owns
1125
- // layout). In place: render straight into the source frame so Paged.js's
1126
- // print structure is preserved for PDF.
1127
- const render = PROMOTE ? document.createElement('div') : source;
1128
- if (PROMOTE) {
1129
- render.setAttribute('data-sg-derived', '');
1130
- render.style.cssText = 'position:absolute;left:-99999px;top:0;width:' + cfg.width + 'px;';
1131
- document.body.appendChild(render);
1132
- } else {
1133
- source.innerHTML = '';
1134
- }
1138
+ // Render straight into the source frame in BOTH modes (in place). Promote
1139
+ // then moves each page box out to a top-level frame (the canvas owns layout);
1140
+ // export leaves them in place so Paged.js's print structure maps to PDF pages.
1141
+ // Rendering promote into an OFFSCREEN position:absolute container made Paged.js
1142
+ // spuriously split the flow wrapper and emit a blank leading page (plus a
1143
+ // tightened first page) whenever an author used a position:running() letterhead
1144
+ // band an editor-canvas-only defect (export, which always rendered in place,
1145
+ // was clean). Rendering in place gives promote the exact in-flow geometry
1146
+ // export uses, so the running-element pagination matches. data-sg-derived
1147
+ // still tags the source so paginationHostCss neutralizes Paged.js preview
1148
+ // chrome while the pages live inside it (before promotion).
1149
+ // Capture the authored markup before clearing so a pagination FAILURE restores
1150
+ // the frame to its EXACT original DOM (an un-paginated single flow), not the
1151
+ // doc-flow-wrapped, style-hoisted content copy — which would drop direct-child
1152
+ // selectors like [data-sg-frame-id] > .cover. (source still holds its original
1153
+ // inline styles here: the hoist above moved style/link out of the content clone.)
1154
+ const originalHtml = source.innerHTML;
1155
+ if (PROMOTE) source.setAttribute('data-sg-derived', '');
1156
+ source.innerHTML = '';
1135
1157
  let pageEls;
1136
1158
  try {
1137
1159
  const previewer = new Paged.Previewer();
@@ -1150,15 +1172,22 @@ function paginationBootstrap(frames, artifactId, promote, sharedCss, renderId) {
1150
1172
  // too. Objects are CSS TEXT (no fetch under connect-src 'none').
1151
1173
  const sheets = [{ 'sg-pagination.css': cfg.css }];
1152
1174
  if (SHARED_CSS) sheets.push({ 'sg-shared.css': SHARED_CSS });
1153
- if (inlineCss) sheets.push({ 'sg-frame-inline.css': inlineCss });
1175
+ // Sanitize inline frame CSS too: a frame <style> with a relative url()
1176
+ // would crash Paged.js exactly like the shared sheet. (SHARED_CSS is
1177
+ // sanitized once up top.)
1178
+ const safeInlineCss = sanitizeCssUrlsForPagination(inlineCss);
1179
+ if (safeInlineCss) sheets.push({ 'sg-frame-inline.css': safeInlineCss });
1154
1180
  sheets.push({ 'sg-page-size.css': cfg.sizeCss });
1155
- await previewer.preview(content, sheets, render);
1156
- pageEls = Array.prototype.slice.call(render.querySelectorAll('.pagedjs_page'));
1181
+ await previewer.preview(content, sheets, source);
1182
+ pageEls = Array.prototype.slice.call(source.querySelectorAll('.pagedjs_page'));
1157
1183
  } catch (error) {
1158
1184
  console.error('Artifact pagination failed for frame ' + id, error);
1159
- if (PROMOTE && render.parentNode) render.parentNode.removeChild(render);
1160
- else source.innerHTML = content.innerHTML;
1161
- continue; // leave the source frame as an un-paginated single flow
1185
+ failed.push({ id: id, reason: String((error && error.message) || error) });
1186
+ // Restore the source to its exact authored DOM as an un-paginated single flow
1187
+ // (both modes now render in place, so the source was cleared above).
1188
+ source.removeAttribute('data-sg-derived');
1189
+ source.innerHTML = originalHtml;
1190
+ continue;
1162
1191
  }
1163
1192
  const furniture = cfg.furniture || {};
1164
1193
  const margins = cfg.margins;
@@ -1207,10 +1236,30 @@ function paginationBootstrap(frames, artifactId, promote, sharedCss, renderId) {
1207
1236
  source.parentNode.insertBefore(frame, source);
1208
1237
  reported.push({ id: pid, width: cfg.width, height: cfg.height });
1209
1238
  });
1210
- if (render.parentNode) render.parentNode.removeChild(render);
1239
+ // Promotion moved every page box out of the source frame; drop the now-empty
1240
+ // source (its Paged.js .pagedjs_pages shell). Both modes render in place now,
1241
+ // so there is no separate offscreen container to remove.
1211
1242
  source.parentNode.removeChild(source);
1212
1243
  expansions.push({ sourceId: id, title: cfg.title, pages: reported });
1213
1244
  }
1245
+ // A document's author CSS usually sets a body background (the page color). The
1246
+ // bootstrap hoists the frame's inline style to head at runtime, so that rule wins
1247
+ // over the platform's transparent canvas and paints the WHOLE hosted surface
1248
+ // behind the page boxes -- the editor grid reads as a solid slab, the present
1249
+ // view loses its page separation -- instead of pages floating on the canvas.
1250
+ // Re-assert the transparent canvas LAST (after the hoisted author styles): the
1251
+ // page boxes keep their own background, so pages stay their page color and the
1252
+ // gaps show the canvas. HOSTED_CANVAS only (host iframe: editor grid + live
1253
+ // present), so standalone export / PDF / PNG -- where body IS the document
1254
+ // backdrop -- are untouched. Runs for both promote and present (present returns
1255
+ // just below). (Only document frames reach this bootstrap. NOTE: no backticks in
1256
+ // this string-built bootstrap -- they close the template literal.)
1257
+ if (HOSTED_CANVAS) {
1258
+ const canvasReset = document.createElement('style');
1259
+ canvasReset.setAttribute('data-sg-canvas-reset', '');
1260
+ canvasReset.textContent = 'html,body{background:transparent !important;}';
1261
+ document.head.appendChild(canvasReset);
1262
+ }
1214
1263
  if (!PROMOTE) return;
1215
1264
  // Renumber data-frame-index across all top-level frames in DOM order so
1216
1265
  // selection's frameIndex stays consistent after promotion.
@@ -1219,7 +1268,7 @@ function paginationBootstrap(frames, artifactId, promote, sharedCss, renderId) {
1219
1268
  // Always post — even with zero successful expansions — so the host knows
1220
1269
  // pagination has SETTLED and stops holding the reveal (a frame that failed
1221
1270
  // to paginate just renders as its un-paginated single flow).
1222
- try { parent.postMessage({ channel: 'studiograph-artifact', artifactId, type: 'frame-pages', renderId, expansions }, '*'); } catch {}
1271
+ try { parent.postMessage({ channel: 'studiograph-artifact', artifactId, type: 'frame-pages', renderId, expansions, failed }, '*'); } catch {}
1223
1272
  };
1224
1273
  if (document.readyState === 'loading') window.addEventListener('DOMContentLoaded', () => { paginate(); });
1225
1274
  else paginate();
@@ -1345,7 +1394,7 @@ export function buildFrameDocument(bundle, ctx) {
1345
1394
  whiteboardStandalone ? whiteboardStandaloneToolbarHtml() : '',
1346
1395
  deckStandalone ? deckStandaloneControlsHtml() : '',
1347
1396
  paginate.length ? `<script data-artifact-paged>${escapedPagedSource(ctx.pagedSource)}</script>` : '',
1348
- paginate.length ? `<script data-artifact-pagination>${escapeScript(paginationBootstrap(paginate, bundle.artifactId, promote, sharedCssText(bundle), ctx.renderId ?? ''))}</script>` : '',
1397
+ paginate.length ? `<script data-artifact-pagination>${escapeScript(paginationBootstrap(paginate, bundle.artifactId, promote, sharedCssText(bundle), ctx.renderId ?? '', ctx.host === 'iframe'))}</script>` : '',
1349
1398
  brokenImageScriptTag(),
1350
1399
  sharedScriptTags(bundle),
1351
1400
  ].filter(Boolean).join('\n');