stitch-sdk-pipeline
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStitch SDK Pipeline
Stitch SDK生成流水线
This skill orchestrates the full SDK generation pipeline — from capturing MCP tool schemas to publishing a tested, validated package. Use this when:
- The Stitch MCP server adds or changes tools
- You need to regenerate the SDK from scratch
- You want to verify the pipeline is healthy
[!IMPORTANT] Stage 2 is the only step requiring agent intelligence. All other stages are deterministic scripts. For Stage 2, use theskill.stitch-sdk-domain-design
该Skill编排完整的SDK生成流水线——从捕获MCP工具schema到发布经过测试和验证的包。在以下场景使用:
- Stitch MCP服务器新增或修改工具
- 需要从头重新生成SDK
- 想要验证流水线是否正常运行
[!IMPORTANT] 第2阶段是唯一需要Agent智能的步骤。 所有其他阶段都是确定性脚本。第2阶段请使用Skill。stitch-sdk-domain-design
Prerequisites
前置条件
- environment variable set
STITCH_API_KEY - installed
bun - Working directory: project root ()
stitch-sdk/
- 已设置环境变量
STITCH_API_KEY - 已安装
bun - 工作目录:项目根目录()
stitch-sdk/
Pipeline Stages
流水线阶段
Stage 1: Capture Tool Schemas 🤖
阶段1:捕获工具Schema 🤖
bash
// turbo
npm run captureConnects to the Stitch MCP server, calls , and writes the raw schemas to . Updates the manifest section of .
tools/listpackages/sdk/generated/tools-manifest.jsonstitch-sdk.lockOutput: (includes + for every tool)
packages/sdk/generated/tools-manifest.jsoninputSchemaoutputSchemaWhen to skip: If is already up to date and no server-side changes occurred.
tools-manifest.jsonbash
// turbo
npm run capture连接到Stitch MCP服务器,调用接口,并将原始schema写入。更新中的manifest部分。
tools/listpackages/sdk/generated/tools-manifest.jsonstitch-sdk.lock输出:(包含每个工具的和)
packages/sdk/generated/tools-manifest.jsoninputSchemaoutputSchema可跳过场景:如果已经是最新版本,且服务器端没有发生变更。
tools-manifest.jsonStage 2: Domain Design 🧠 (Agent)
阶段2:领域设计 🧠(Agent)
Use the skill for this stage.
stitch-sdk-domain-designRead and edit to map tools → classes → methods.
tools-manifest.jsonpackages/sdk/generated/domain-map.jsonKey decisions at this stage:
- Which class owns each tool?
- What are the arg routing rules (self, param, computed, selfArray)?
- What is the response projection path?
- Should the method cache data from the construction response?
Input: + (the canonical IR contract)
Output:
tools-manifest.jsonscripts/ir-schema.tspackages/sdk/generated/domain-map.jsonWhen to skip: If already has the correct bindings and you only changed or .
domain-map.jsonir-schema.tsgenerate-sdk.ts本阶段请使用 Skill。
stitch-sdk-domain-design读取并编辑,完成工具→类→方法的映射。
tools-manifest.jsonpackages/sdk/generated/domain-map.json本阶段的关键决策:
- 每个工具归属哪个类?
- 参数路由规则是什么(self、param、computed、selfArray)?
- 响应投影路径是什么?
- 方法是否应该缓存构造响应中的数据?
输入: + (标准IR契约)
输出:
tools-manifest.jsonscripts/ir-schema.tspackages/sdk/generated/domain-map.json可跳过场景:如果已经有正确的绑定关系,且仅修改了或。
domain-map.jsonir-schema.tsgenerate-sdk.tsStage 3: Generate TypeScript 🤖
阶段3:生成TypeScript代码 🤖
bash
// turbo
npm run generateValidates the IR (Zod schema) and every projection (against ), then emits TypeScript files via ts-morph into .
outputSchemapackages/sdk/generated/src/Output: + updated
packages/sdk/generated/src/*.tsstitch-sdk.lockIf this fails with a projection error, go back to Stage 2 and fix .
domain-map.jsonbash
// turbo
npm run generate验证IR(Zod schema)和每个投影(与对比),然后通过ts-morph将TypeScript文件输出到。
outputSchemapackages/sdk/generated/src/输出: + 更新后的
packages/sdk/generated/src/*.tsstitch-sdk.lock如果因投影错误失败,请回到阶段2修复。
domain-map.jsonStage 4: Build 🤖
阶段4:构建 🤖
bash
// turbo
npm run buildTypeScript compilation: → .
packages/sdk/packages/sdk/dist/bash
// turbo
npm run buildTypeScript编译: → 。
packages/sdk/packages/sdk/dist/Stage 5: Unit Tests 🤖
阶段5:单元测试 🤖
bash
// turbo
npm run testRuns core unit tests (vitest) — mocked , verifying generated method signatures, caching, and error handling.
callToolbash
// turbo
npm run test运行核心单元测试(vitest)——模拟,验证生成的方法签名、缓存和错误处理。
callToolStage 6: Script Tests 🤖
阶段6:脚本测试 🤖
bash
// turbo
npm run test:scriptsRuns contract tests (IR schema acceptance/rejection) and logic tests (expression builders) using .
bun:testbash
// turbo
npm run test:scripts使用运行契约测试(IR schema的接受/拒绝)和逻辑测试(表达式构建器)。
bun:testStage 7: E2E Tests 🤖
阶段7:端到端测试 🤖
bash
npm run test:e2eLive API tests against the built package. Requires (and for AI SDK tests). Two test suites:
STITCH_API_KEYGEMINI_API_KEY- — Direct SDK calls: create projects, generate screens, verify responses.
live.test.ts - — AI SDK integration via
ai-sdk-e2e.test.ts: Gemini autonomously calls Stitch tools, generates designs, extracts HTML + Tailwind config, produces modular React components, validates via SWC, and scaffolds a Vite preview app atstitchTools()..stitch/preview/
bash
npm run test:e2e针对构建后的包运行实时API测试。需要(AI SDK测试还需要)。包含两个测试套件:
STITCH_API_KEYGEMINI_API_KEY- — 直接调用SDK:创建项目、生成界面、验证响应。
live.test.ts - — 通过
ai-sdk-e2e.test.ts集成AI SDK:Gemini自动调用Stitch工具、生成设计、提取HTML + Tailwind配置、生成模块化React组件、通过SWC验证,并在stitchTools()搭建Vite预览应用。.stitch/preview/
Stage 8: Lock Validation 🤖
阶段8:锁文件验证 🤖
bash
// turbo
npm run validate:generatedVerifies that hashes match the actual generated files. Catches drift (someone edited generated files manually or forgot to regenerate).
stitch-sdk.lock[!IMPORTANT] Always run after Stage 3 (Generate). If you run Capture (Stage 1) then Validate without re-generating, the hashes will mismatch because the manifest hash changed.
bash
// turbo
npm run validate:generated验证中的哈希值与实际生成的文件是否匹配。捕获漂移问题(例如有人手动编辑了生成的文件或忘记重新生成)。
stitch-sdk.lock[!IMPORTANT] 请始终在阶段3(生成)之后运行此步骤。如果运行了捕获(阶段1)但未重新生成就直接验证,由于manifest哈希已更改,哈希值会不匹配。
Stage 9: Skill Audit 🧠 (Agent)
阶段9:Skill审计 🧠(Agent)
After the pipeline passes, audit agent skills for freshness. Read the current source of truth and update any skills that reference stale methods, args, or examples.
Inputs:
- (public surface)
packages/sdk/src/index.ts - Generated class files in
packages/sdk/generated/src/ - (error codes)
packages/sdk/src/spec/errors.ts - (config schema)
packages/sdk/src/spec/client.ts
Skills to audit (in priority order):
- — highest churn, references specific methods and constructor signatures
stitch-sdk-usage - — must document
stitch-sdk-readme,stitchTools(), and AI SDK integration examplestoolDefinitions - — check cache examples match current domain-map patterns
stitch-sdk-development - — check code examples in the cache section
stitch-sdk-domain-design
Skills to skip: (self-referential), (generic methodology).
stitch-sdk-pipelinered-green-yellowWhat to check:
- Every method name in a code example exists on its class
- Every import in an example matches an export in
index.ts - Constructor signatures match the actual constructors
- Config fields match
StitchConfigSchema - Error codes match
StitchErrorCode
When to skip: If only infrastructure code changed (, ) and no public API surface changed.
packages/sdk/src/client.tspackages/sdk/src/proxy/流水线通过后,审计Agent Skill的新鲜度。读取当前的事实来源,并更新所有引用过时方法、参数或示例的Skill。
输入:
- (公共接口)
packages/sdk/src/index.ts - 中的生成类文件
packages/sdk/generated/src/ - (错误码)
packages/sdk/src/spec/errors.ts - (配置schema)
packages/sdk/src/spec/client.ts
需要审计的Skill(按优先级排序):
- — 变更频率最高,引用了特定方法和构造函数签名
stitch-sdk-usage - — 必须记录
stitch-sdk-readme、stitchTools()和AI SDK集成示例toolDefinitions - — 检查缓存示例是否匹配当前domain-map模式
stitch-sdk-development - — 检查缓存部分的代码示例
stitch-sdk-domain-design
可跳过的Skill:(自引用)、(通用方法论)。
stitch-sdk-pipelinered-green-yellow检查内容:
- 代码示例中的每个方法名都存在于对应的类中
- 示例中的每个导入都与中的导出匹配
index.ts - 构造函数签名与实际构造函数一致
- 配置字段与匹配
StitchConfigSchema - 错误码与匹配
StitchErrorCode
可跳过场景:如果仅修改了基础设施代码(、),且公共API接口未发生变化。
packages/sdk/src/client.tspackages/sdk/src/proxy/Quick Reference
快速参考
Full pipeline (script stages only)
完整流水线(仅脚本阶段)
bash
npm run pipelineRuns Stage 1 → 3 → 4 → 5 in sequence. Does not include Stage 2 (agent), Stage 7 (e2e), or Stage 9 (skill audit).
bash
npm run pipeline按顺序运行阶段1→3→4→5。不包含阶段2(Agent)、阶段7(端到端测试)或阶段9(Skill审计)。
Starting from a specific stage
从指定阶段开始
| Scenario | Start from |
|---|---|
| New tool added to MCP server | Stage 1 |
| Need to change how a tool maps to a method | Stage 2 |
Changed | Stage 3 |
Changed code in | Stage 4 |
| Just want to verify everything works | Stage 5 |
| Changed AI SDK tools adapter or tool definitions | Stage 5 |
| Public API surface changed | Stage 9 |
| 场景 | 从哪个阶段开始 |
|---|---|
| MCP服务器新增工具 | 阶段1 |
| 需要修改工具到方法的映射方式 | 阶段2 |
修改了 | 阶段3 |
修改了 | 阶段4 |
| 仅需验证所有功能是否正常 | 阶段5 |
| 修改了AI SDK工具适配器或工具定义 | 阶段5 |
| 公共API接口发生变化 | 阶段9 |
Key files
关键文件
| File | Location | Role |
|---|---|---|
| | Raw MCP tool schemas (Stage 1 output) |
| | IR: tool → class → method mappings (Stage 2 output) |
| | Generated JSON Schema tool definitions for AI SDK |
| | |
| | Zod schema defining valid IR structure |
| | TypeScript types for JSON Schema |
| | ts-morph codegen (Stage 3) |
| | Integrity hashes for drift detection |
| | Stitch HTML parser (Tailwind config + font extraction) |
| | SWC AST validator for generated React components |
| 文件 | 位置 | 作用 |
|---|---|---|
| | MCP工具原始schema(阶段1输出) |
| | IR:工具→类→方法的映射关系(阶段2输出) |
| | 为AI SDK生成的JSON Schema工具定义 |
| | |
| | 定义有效IR结构的Zod schema |
| | JSON Schema对应的TypeScript类型 |
| | ts-morph代码生成器(阶段3) |
| | 用于漂移检测的完整性哈希 |
| | Stitch HTML解析器(提取Tailwind配置和字体) |
| | 用于生成的React组件的SWC AST验证器 |