Skip to content

Commit 575a9fb

Browse files
authored
feat: support Design.md workflow for design system creation (#359)
Stitch recently added the ability to create design systems from markdown files (DESIGN.md). This is a two-step workflow: 1. Upload a markdown file describing the design language to a project 2. Create a design system from that uploaded file, which Stitch interprets and converts into actionable design tokens SDK (domain classes): const instance = await project.uploadDesignMd(btoa(markdown)); const ds = await project.createDesignSystemFromDesignMd(instance, 'DESKTOP'); Agent (callTool / tool definitions): Both tools are also registered in the tool definitions, so agents using callTool or the ADK/AI SDK adapters can discover and invoke them directly. This brings the SDK to full MCP tool coverage (14/14) across both modalities.
1 parent 389480d commit 575a9fb

13 files changed

Lines changed: 5504 additions & 215 deletions

packages/sdk/generated/domain-map.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,43 @@
423423
],
424424
"array": true
425425
}
426+
},
427+
{
428+
"tool": "upload_design_md",
429+
"class": "Project",
430+
"method": "uploadDesignMd",
431+
"args": {
432+
"projectId": {
433+
"from": "self"
434+
},
435+
"designMdBase64": {
436+
"from": "param"
437+
}
438+
},
439+
"returns": {
440+
"projection": []
441+
}
442+
},
443+
{
444+
"tool": "create_design_system_from_design_md",
445+
"class": "Project",
446+
"method": "createDesignSystemFromDesignMd",
447+
"args": {
448+
"projectId": {
449+
"from": "self"
450+
},
451+
"selectedScreenInstance": {
452+
"from": "param"
453+
},
454+
"deviceType": {
455+
"from": "param",
456+
"optional": true
457+
}
458+
},
459+
"returns": {
460+
"class": "DesignSystem",
461+
"projection": []
462+
}
426463
}
427464
]
428465
}

packages/sdk/generated/src/designsystem.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
* AUTO-GENERATED by scripts/generate-sdk.ts
33
DO NOT EDIT — changes will be overwritten.
44
5-
Source: tools-manifest.json (sha256:2f1a623ec115...)
6-
domain-map.json (sha256:0ee09d686be6...)
7-
Generated: 2026-06-01T03:47:10.743Z
5+
Source: tools-manifest.json (sha256:d831990b27e9...)
6+
domain-map.json (sha256:715639788724...)
7+
Generated: 2026-06-01T04:11:36.685Z
88
*/
99
import { type StitchToolClient } from "../../src/client.js";
1010
import { StitchError } from "../../src/spec/errors.js";
1111
import {
12+
ComponentTokens,
1213
DesignTheme,
1314
File,
1415
ProjectMetadata,
@@ -29,7 +30,10 @@ import {
2930
PrototypeLinks,
3031
PrototypeState,
3132
PrototypeV2Spec,
33+
Question,
34+
QuestionsAsked,
3235
ScreenMetadata,
36+
SessionEvent,
3337
SessionOutputComponent,
3438
VariantOptions,
3539
SelectedScreenInstance,

packages/sdk/generated/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
* AUTO-GENERATED by scripts/generate-sdk.ts
33
DO NOT EDIT — changes will be overwritten.
44
5-
Source: tools-manifest.json (sha256:2f1a623ec115...)
6-
domain-map.json (sha256:0ee09d686be6...)
7-
Generated: 2026-06-01T03:47:10.743Z
5+
Source: tools-manifest.json (sha256:d831990b27e9...)
6+
domain-map.json (sha256:715639788724...)
7+
Generated: 2026-06-01T04:11:36.685Z
88
*/
99
export { Stitch } from "./stitch.js";
1010
export { Project } from "./project.js";

packages/sdk/generated/src/project.ts

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
* AUTO-GENERATED by scripts/generate-sdk.ts
33
DO NOT EDIT — changes will be overwritten.
44
5-
Source: tools-manifest.json (sha256:2f1a623ec115...)
6-
domain-map.json (sha256:0ee09d686be6...)
7-
Generated: 2026-06-01T03:47:10.743Z
5+
Source: tools-manifest.json (sha256:d831990b27e9...)
6+
domain-map.json (sha256:715639788724...)
7+
Generated: 2026-06-01T04:11:36.685Z
88
*/
99
import { type StitchToolClient } from "../../src/client.js";
1010
import { StitchError } from "../../src/spec/errors.js";
1111
import {
12+
ComponentTokens,
1213
DesignTheme,
1314
File,
1415
ProjectMetadata,
@@ -29,7 +30,10 @@ import {
2930
PrototypeLinks,
3031
PrototypeState,
3132
PrototypeV2Spec,
33+
Question,
34+
QuestionsAsked,
3235
ScreenMetadata,
36+
SessionEvent,
3337
SessionOutputComponent,
3438
VariantOptions,
3539
SelectedScreenInstance,
@@ -40,6 +44,8 @@ import {
4044
GetScreenResponse,
4145
CreateDesignSystemResponse,
4246
ListDesignSystemsResponse,
47+
UploadDesignMdResponse,
48+
CreateDesignSystemFromDesignMdResponse,
4349
} from "./responses.generated.js";
4450
import { Screen } from "./screen.js";
4551
import { DesignSystem } from "./designsystem.js";
@@ -187,6 +193,51 @@ export class Project {
187193
}
188194
}
189195

196+
/**
197+
* Uploads DESIGN.md to a Stitch project. Use this tool when the user wants to create a design system from a DESIGN.md file.
198+
* Tool: upload_design_md
199+
*/
200+
async uploadDesignMd(designMdBase64: string): Promise<any> {
201+
try {
202+
const raw = await this.client.callTool<UploadDesignMdResponse>(
203+
"upload_design_md",
204+
{ projectId: this.projectId, designMdBase64 },
205+
);
206+
return raw || "";
207+
} catch (error) {
208+
throw StitchError.fromUnknown(error);
209+
}
210+
}
211+
212+
/**
213+
* Creates a design system for a project, with user uploaded DESIGN.md file, and displays the design system in the UI.
214+
* Tool: create_design_system_from_design_md
215+
*/
216+
async createDesignSystemFromDesignMd(
217+
selectedScreenInstance: SelectedScreenInstance,
218+
deviceType?:
219+
| "DEVICE_TYPE_UNSPECIFIED"
220+
| "MOBILE"
221+
| "DESKTOP"
222+
| "TABLET"
223+
| "AGNOSTIC",
224+
): Promise<DesignSystem> {
225+
try {
226+
const raw =
227+
await this.client.callTool<CreateDesignSystemFromDesignMdResponse>(
228+
"create_design_system_from_design_md",
229+
{ projectId: this.projectId, selectedScreenInstance, deviceType },
230+
);
231+
return this.client.entities.resolve(
232+
DesignSystem,
233+
["projectId", "assetId"],
234+
{ ...raw, projectId: this.projectId },
235+
);
236+
} catch (error) {
237+
throw StitchError.fromUnknown(error);
238+
}
239+
}
240+
190241
/** Create a DesignSystem handle from an existing ID without an API call. */
191242
designSystem(id: string): DesignSystem {
192243
return this.client.entities.resolve(

packages/sdk/generated/src/responses.generated.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
ComponentTokens,
23
DesignTheme,
34
File,
45
ProjectMetadata,
@@ -19,7 +20,10 @@ import {
1920
PrototypeLinks,
2021
PrototypeState,
2122
PrototypeV2Spec,
23+
Question,
24+
QuestionsAsked,
2225
ScreenMetadata,
26+
SessionEvent,
2327
SessionOutputComponent,
2428
VariantOptions,
2529
SelectedScreenInstance,
@@ -28,9 +32,9 @@ import {
2832
* AUTO-GENERATED by scripts/generate-sdk.ts
2933
DO NOT EDIT — changes will be overwritten.
3034
31-
Source: tools-manifest.json (sha256:2f1a623ec115...)
32-
domain-map.json (sha256:0ee09d686be6...)
33-
Generated: 2026-06-01T03:47:10.743Z
35+
Source: tools-manifest.json (sha256:d831990b27e9...)
36+
domain-map.json (sha256:715639788724...)
37+
Generated: 2026-06-01T04:11:36.685Z
3438
*/
3539

3640
/** Response message for create_project. */
@@ -140,6 +144,31 @@ export interface GenerateVariantsResponse {
140144
sessionId?: string;
141145
}
142146

147+
/** Response message for upload_design_md. */
148+
export interface UploadDesignMdResponse {
149+
groupId?: string;
150+
groupName?: string;
151+
height?: number;
152+
hidden?: boolean;
153+
id?: string;
154+
isFavourite?: boolean;
155+
isResized?: boolean;
156+
label?: string;
157+
sourceAsset?: string;
158+
sourceScreen?: string;
159+
textContent?: string;
160+
type?:
161+
| "SCREEN_INSTANCE_TYPE_UNSPECIFIED"
162+
| "SCREEN_INSTANCE"
163+
| "DESIGN_SYSTEM_INSTANCE"
164+
| "GROUP_INSTANCE"
165+
| "TEXT_INSTANCE";
166+
variantScreenInstance?: ScreenInstance;
167+
width?: number;
168+
x?: number;
169+
y?: number;
170+
}
171+
143172
/** Response message for create_design_system. */
144173
export interface CreateDesignSystemResponse {
145174
copiedFrom?: string;
@@ -148,6 +177,11 @@ export interface CreateDesignSystemResponse {
148177
version?: string;
149178
}
150179

180+
/** Response message for create_design_system_from_design_md. */
181+
export interface CreateDesignSystemFromDesignMdResponse {
182+
assetId?: string;
183+
}
184+
151185
/** Response message for update_design_system. */
152186
export interface UpdateDesignSystemResponse {
153187
copiedFrom?: string;

packages/sdk/generated/src/screen.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
* AUTO-GENERATED by scripts/generate-sdk.ts
33
DO NOT EDIT — changes will be overwritten.
44
5-
Source: tools-manifest.json (sha256:2f1a623ec115...)
6-
domain-map.json (sha256:0ee09d686be6...)
7-
Generated: 2026-06-01T03:47:10.743Z
5+
Source: tools-manifest.json (sha256:d831990b27e9...)
6+
domain-map.json (sha256:715639788724...)
7+
Generated: 2026-06-01T04:11:36.685Z
88
*/
99
import { type StitchToolClient } from "../../src/client.js";
1010
import { StitchError } from "../../src/spec/errors.js";
1111
import {
12+
ComponentTokens,
1213
DesignTheme,
1314
File,
1415
ProjectMetadata,
@@ -29,7 +30,10 @@ import {
2930
PrototypeLinks,
3031
PrototypeState,
3132
PrototypeV2Spec,
33+
Question,
34+
QuestionsAsked,
3235
ScreenMetadata,
36+
SessionEvent,
3337
SessionOutputComponent,
3438
VariantOptions,
3539
SelectedScreenInstance,

packages/sdk/generated/src/stitch.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
* AUTO-GENERATED by scripts/generate-sdk.ts
33
DO NOT EDIT — changes will be overwritten.
44
5-
Source: tools-manifest.json (sha256:2f1a623ec115...)
6-
domain-map.json (sha256:0ee09d686be6...)
7-
Generated: 2026-06-01T03:47:10.743Z
5+
Source: tools-manifest.json (sha256:d831990b27e9...)
6+
domain-map.json (sha256:715639788724...)
7+
Generated: 2026-06-01T04:11:36.685Z
88
*/
99
import { type StitchToolClient } from "../../src/client.js";
1010
import { StitchError } from "../../src/spec/errors.js";
1111
import {
12+
ComponentTokens,
1213
DesignTheme,
1314
File,
1415
ProjectMetadata,
@@ -29,7 +30,10 @@ import {
2930
PrototypeLinks,
3031
PrototypeState,
3132
PrototypeV2Spec,
33+
Question,
34+
QuestionsAsked,
3235
ScreenMetadata,
36+
SessionEvent,
3337
SessionOutputComponent,
3438
VariantOptions,
3539
SelectedScreenInstance,

0 commit comments

Comments
 (0)