stitch2 0.0.0-stage → 0.7.2

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 (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +208 -2
  3. package/config.schema.json +109 -0
  4. package/dist/assets.d.ts +1 -0
  5. package/dist/assets.js +59 -0
  6. package/dist/audit.d.ts +10 -0
  7. package/dist/audit.js +259 -0
  8. package/dist/build-design.d.ts +39 -0
  9. package/dist/build-design.js +337 -0
  10. package/dist/build-elements.d.ts +1 -0
  11. package/dist/build-elements.js +33 -0
  12. package/dist/canvas.html +689 -0
  13. package/dist/check.d.ts +1 -0
  14. package/dist/check.js +86 -0
  15. package/dist/cli.d.ts +2 -0
  16. package/dist/cli.js +73 -0
  17. package/dist/colours.d.ts +2 -0
  18. package/dist/colours.js +57 -0
  19. package/dist/compare.d.ts +1 -0
  20. package/dist/compare.js +185 -0
  21. package/dist/config.d.ts +53 -0
  22. package/dist/config.js +38 -0
  23. package/dist/consistency.d.ts +40 -0
  24. package/dist/consistency.js +336 -0
  25. package/dist/design-md.d.ts +27 -0
  26. package/dist/design-md.js +49 -0
  27. package/dist/design-page.d.ts +1 -0
  28. package/dist/design-page.js +127 -0
  29. package/dist/elements.d.ts +32 -0
  30. package/dist/elements.js +69 -0
  31. package/dist/exports.d.ts +25 -0
  32. package/dist/exports.js +86 -0
  33. package/dist/extract.d.ts +1 -0
  34. package/dist/extract.js +197 -0
  35. package/dist/init.d.ts +5 -0
  36. package/dist/init.js +83 -0
  37. package/dist/list.d.ts +1 -0
  38. package/dist/list.js +17 -0
  39. package/dist/pick.d.ts +10 -0
  40. package/dist/pick.js +38 -0
  41. package/dist/report.d.ts +1 -0
  42. package/dist/report.js +110 -0
  43. package/dist/sandbox.d.ts +1 -0
  44. package/dist/sandbox.js +183 -0
  45. package/dist/screens.d.ts +34 -0
  46. package/dist/screens.js +85 -0
  47. package/dist/serve.d.ts +4 -0
  48. package/dist/serve.js +181 -0
  49. package/dist/setup.d.ts +1 -0
  50. package/dist/setup.js +214 -0
  51. package/dist/tokens.d.ts +1 -0
  52. package/dist/tokens.js +128 -0
  53. package/dist/type.d.ts +1 -0
  54. package/dist/type.js +60 -0
  55. package/dist/typecheck.d.ts +35 -0
  56. package/dist/typecheck.js +112 -0
  57. package/package.json +53 -4
  58. package/skills/stitch2/SKILL.md +80 -0
  59. package/skills/stitch2/references/components.md +59 -0
  60. package/skills/stitch2/references/guides.md +20 -0
  61. package/skills/stitch2/references/principles.md +80 -0
  62. package/skills/stitch2/references/screens.md +70 -0
  63. package/skills/stitch2/references/typography.md +106 -0
  64. package/skills/stitch2-app-sync/SKILL.md +65 -0
  65. package/skills/stitch2-consistency/SKILL.md +59 -0
  66. package/skills/stitch2-design-md/SKILL.md +64 -0
  67. package/skills/stitch2-import-from-google-stitch/SKILL.md +47 -0
  68. package/skills/stitch2-import-from-google-stitch/references/how-stitch-works.md +36 -0
  69. package/skills/stitch2-variants/SKILL.md +45 -0
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: stitch2-import-from-google-stitch
3
+ description: Optional, only for projects that use Google Stitch (Google's product) — draft screens there through its MCP server and bring them into stitch2 as reviewable versions. Use when the user wants Stitch to generate a screen, design variants, or to push the project's DESIGN.md to a Stitch design system. (stitch2 is inspired by Google Stitch and is not affiliated with Google.)
4
+ ---
5
+
6
+ # Drafting screens in Google Stitch
7
+
8
+ Google Stitch generates screens (HTML and a screenshot) from prompts against a design system. stitch2 treats
9
+ each export as a **draft version**: it lands next to the other versions of its screen on the canvas, gets
10
+ checked, and waits for the user's decision. The project skill names the Stitch project, its design system and
11
+ the data to use in prompts. How Stitch builds its screens: [references/how-stitch-works.md](references/how-stitch-works.md).
12
+
13
+ ## Access
14
+
15
+ - The MCP server is `https://stitch.googleapis.com/mcp` with the header `X-Goog-Api-Key` (configure it in the
16
+ agent's MCP settings; never commit or print the key).
17
+ - Without the MCP tools in the session, call it over HTTP: it is stateless JSON-RPC, one POST per call
18
+ (`{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"…","arguments":{…}}}`, headers
19
+ `content-type: application/json` and `accept: application/json, text/event-stream`).
20
+
21
+ ## Workflow
22
+
23
+ 1. **Design system first.** Systemic changes go into DESIGN.md (Google's DESIGN.md format, which Stitch reads
24
+ directly). Push it with `upload_design_md` (base64 of the file), then `create_design_system_from_design_md`
25
+ with the returned screen instance; `list_design_systems` gives the asset id. Read it back: Stitch's fonts
26
+ come from a fixed list of about 65 Google Fonts and it silently substitutes the others.
27
+ 2. **Prompts carry content and structure**: the screen's sections, controls and realistic data, the shared
28
+ chrome in the same words on every prompt (taken from DESIGN.md's Components), and what must not appear (no
29
+ phone status bar, step labels, tip cards, extra helper text or buttons; Stitch adds them otherwise). Colours,
30
+ fonts and radii come from the design system.
31
+ 3. **One screen at a time**, `generate_screen_from_text` with `designSystem` set. Parallel calls caused
32
+ "service unavailable", screens never placed on the canvas and screens stuck on "Preparing…". Never resend a
33
+ running call. Empty `downloadUrl`s: poll `get_screen` for a few minutes, then generate once more.
34
+ 4. **Known quirks.** `edit_screens` reports success but does not persist through the API; fix a screen by
35
+ generating again with a corrected prompt. There is no API to delete a screen (the user removes it in the
36
+ Stitch UI). `list_screens` lags. A prompt resembling an existing screen makes Stitch edit that one
37
+ (unsaved): start it with "Create a NEW, separate screen (do not edit or replace any existing screen) titled
38
+ '…'". `update_design_system` rewrites the design system's DESIGN.md text. Each reply carries follow-up
39
+ suggestions (`outputComponents[].suggestion`): pass them on to the user.
40
+ 5. **Bring it in as a version**: save the HTML as `<screens>/<screen>/<device>-v<N>.html` with the meta tags
41
+ `<p>-screen`, `<p>-device`, `<p>-source` = `stitch`, `<p>-status` = `review` (see stitch2's screens.md),
42
+ then `stitch2 localize <path>` (Stitch links images to Google URLs that can fail elsewhere or expire),
43
+ `stitch2 check <path> --shots`, and look at it on the canvas.
44
+ 6. **Consistency.** Stitch cannot share components between screens, so its chrome drifts (one project's first
45
+ six screens had six different tab bars). Run the stitch2-consistency skill; the component catalog, not
46
+ Stitch, decides how shared components look. Stitch screens are drafts: the product implements approved
47
+ versions built from the project's components, never pasted Stitch HTML.
@@ -0,0 +1,36 @@
1
+ # How Stitch builds its screens
2
+
3
+ Observed through Stitch's MCP API, the HTML it generated for one project (ten screens, 341 text elements
4
+ measured with `stitch2 type`), and Google's public material: the DESIGN.md format (github.com/google-labs-code/
5
+ design.md, npm `@google/design.md`) and the stitch-skills repository (github.com/google-labs-code/stitch-skills).
6
+
7
+ ## The pipeline
8
+
9
+ 1. **A structured theme.** A Stitch design system is a typed object: headline, body and label fonts from a fixed
10
+ list of about 65 Google Fonts; a seed colour with a Material dynamic-colour variant (TONAL_SPOT, FIDELITY,
11
+ VIBRANT…) and optional overrides; a roundness level (2, 4, 8, 12 px or full); a spacing map; named typography
12
+ levels (family, size, weight, line height, tracking); and a free-text DESIGN.md.
13
+ 2. **DESIGN.md in Google's format.** An uploaded DESIGN.md comes back with YAML front matter: the Material colour
14
+ roles generated from the seed, named type levels, radius and spacing scales, then the prose. Fonts outside its
15
+ list are replaced silently (Geist Mono became Public Sans), and the prose is rewritten to match.
16
+ 3. **A compiled Tailwind config per screen**, with the levels as `text-<level>` sizes bundling line height,
17
+ tracking and weight, plus the colours, spacing and radii. Markup is written against those names, mixed with
18
+ Tailwind's default steps (`text-sm`, `text-xs`), whose sizes carry fixed line heights.
19
+ 4. **Prompts carry content only.** Google's own Stitch skills keep colours, fonts and radii out of prompts; their
20
+ references are vocabulary lists. Stitch's visual judgement lives in its model and hidden prompt.
21
+
22
+ ## What its screens tend to do
23
+
24
+ - About 70% of text at 10–13 px; one or two elements per screen at 20 px or more.
25
+ - Semibold carries hierarchy, including on 11–12 px labels; medium for names and values.
26
+ - Headings tightened (about −0.025em), small labels and capitals opened (+0.025 to +0.05em).
27
+ - A third text grey and opacity steps; the third grey often fails AA contrast.
28
+ - Pressed, hover and focus styles on nearly every control.
29
+ - Labels that make charts readable (axes, legends, figure captions) and distinct icons per item.
30
+
31
+ And what to watch for:
32
+
33
+ - Invented content: captions, statistics and features the prompt did not ask for.
34
+ - The accent on several elements per region; accent text on tinted backgrounds failing contrast.
35
+ - Monospace decimals with wide gaps ("80 . 7").
36
+ - Chrome that differs on every screen (tab bars, headers, icon buttons), because screens share nothing.
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: stitch2-variants
3
+ description: Get fresh-eyes versions of a screen from agents that see no other versions (stitch2 sandbox), so alternatives are not anchored to what exists; or test a change to the skills on output only the rules produced. Use when the user wants alternatives or a new direction, feels stuck with a design, wants several options to choose from, or when a skill or DESIGN.md rule changed and you need evidence it helps.
4
+ ---
5
+
6
+ # Fresh-eyes variants with stitch2 sandboxes
7
+
8
+ An agent that can see a screen's existing versions copies them, even when asked for something new. A sandbox
9
+ is a folder with the project's design system, components, catalog, template and skills, and none of its screens,
10
+ so a fresh agent designs from the brief alone. Its result comes back as the next version of the screen, for
11
+ the user to compare on the canvas.
12
+
13
+ ## Alternatives for a screen
14
+
15
+ 1. **Write the brief** (`<screen>.md`): what the screen is for, its sections and controls, real data. Content
16
+ and structure only: colours, fonts and shapes come from DESIGN.md. Name the file after the screen
17
+ (`history.md` designs `history`). For several directions, write one brief per direction with one sentence
18
+ on what differs (`history.md` in sandbox A: "a calendar first"; in sandbox B: "a list first").
19
+ 2. **Create one sandbox per variant**: `stitch2 sandbox create /tmp/<project>-<screen>-a <brief.md>`.
20
+ `--context home stats` adds the approved versions of other screens, so the variant stays consistent with
21
+ them; `--device desktop` for desktop.
22
+ 3. **Run a fresh agent in each**, with no shared conversation: a sub-agent started without forked history,
23
+ working only in that folder, told to read its AGENTS.md and follow the skills there. Without sub-agents, give
24
+ the user the folder and ask them to open a new agent session in it. Run them in parallel; they do not share
25
+ anything.
26
+ 4. **Import**: `stitch2 sandbox import <dir> --label "calendar first"` for each. Every screen comes back as the
27
+ next version (status review) with a note saying where it came from.
28
+ 5. **Compare** with `stitch2 check` and `stitch2 consistency` (they should pass like any version), then tell the
29
+ user the versions are on the canvas side by side, what each tried, and which you would choose and why. The
30
+ user approves one; the others get archived.
31
+
32
+ ## Testing a change to the skills or DESIGN.md
33
+
34
+ 1. Pick briefs for screens that already have versions made under the old rules.
35
+ 2. Create sandboxes from the project with the changed skills or DESIGN.md, run fresh agents on the same briefs.
36
+ 3. Import them with a label (`--label "rules v2"`) and compare with the old versions: `stitch2 check` (errors,
37
+ warnings), `stitch2 type` (share of text on the type scale, number of sizes), `stitch2 consistency`, and the
38
+ review rubric. Report numbers, not impressions; archive the trial versions afterwards.
39
+
40
+ ## Rules
41
+
42
+ - Never copy files from the project into a sandbox by hand, and never tell the sandbox agent about the existing
43
+ versions: that is the anchoring the sandbox avoids.
44
+ - Briefs say what, not how. A brief that describes another version's layout defeats the purpose.
45
+ - Imported versions are drafts like any other: the user decides.