@ google/ stitch (英语)
在 Google Stitch 创建 UI 屏幕, 从一个提示, 将您运行的应用程序的页面拉到 Stitch 画布上, 然后从您的终端或编码代理上标出 .
npx @google/stitch generate screen \
--new-project "Mobile Onboarding Flow" \
--prompt "Sign-up step with email and phone verification" \
--device MOBILE
这创建了Stitch项目,在其中生成一个移动屏幕,并打印工程和屏幕ID.
把已有的页面带入史地奇并重新设计它
从您的本地 Dev 服务器中抓取一条路径作为自定义的 HTML 文件, 上传为屏幕, 然后快速编辑 :
stitch capture http://localhost:3000/checkout # saves .stitch/captures/checkout.html
stitch upload screen .stitch/captures/checkout.html --route /checkout --title Checkout
stitch edit screen <screen-id> --project <project-id> --prompt "Use a two-column layout"
探索屏幕的变体
stitch generate variants \
--project <project-id> \
--screen <screen-id> \
--prompt "Try warmer colors and a denser layout" \
--count 3 \
--creative-range EXPLORE \
--aspects LAYOUT,COLOR_SCHEME
本地预览工程屏幕
stitch serve -p <project-id> --port 3000
使用编码代理
每个命令都接受 --json 用于结构化产出, --json '{...}' 用于原始输入有效载荷,以及 --schema 打印它所接受的JSON Schema。 代理可以在不读取文件的情况下发现 API :
stitch generate --schema # which resources can be generated
stitch generate screen --schema # payload schema for one resource
stitch find projects --limit 10 --json
或者用您的编辑器注册捆绑的 MCP 服务器 :
stitch mcp install
安装
npm install -g @google/stitch
要求节点.js 20或更晚. 安装两个二进制 : stitch 财务报告和审定财务报表 stitch-mcp (与 stitch mcp start) (中文(简体) ).
认证
stitch login # Google OAuth in the browser; tokens are stored locally and refreshed automatically
stitch status # shows which credentials are active
stitch logout # removes stored OAuth credentials and saved API keys
Canvas命令(项目,屏幕,设计系统)除了OAuth之外,可能还需要一个API密钥. 如果命令失败 MISSING_CANVAS_CREDENTIALS,设置一个:
export STITCH_API_KEY=your-api-key
| 证书 | 旗帜 | 环境变量 |
|---|---|---|
| API 密钥 | --api-key | STITCH_API_KEY |
| OAuth 访问符 | --access-token | STITCH_ACCESS_TOKEN |
stitch login 选项: --port (左起回调端口,默认值) 8085, (中文(简体) ), --json。 。 。 .
stitch status 选项: --flow design|loop, (中文(简体) ), --token (打印出有效的无记名标志), --json。 。 。 .
配置
存储器默认值 .stitch.json数字 :
stitch config set project 1234567890
stitch config get project
stitch config list # resolved values from flags, env, and config files
stitch config unset project
| 设置 | 旗帜 | 环境变量 |
|---|---|---|
| 项目 | -p, --project | STITCH_PROJECT_ID |
| 工作空间 | -w, --workspace | STITCH_WORKSPACE |
| API 基础 URL | --base-url | STITCH_BASE_URL |
全球旗帜
| 旗帜 | 说明 |
|---|---|
--format json|ndjson|table|markdown | 输出格式。 默认为 table 在终端. |
--json [payload] | 以JSON格式输出. 双模式命令( O)create, (中文(简体) ), edit, (中文(简体) ), get, (中文(简体) ), find, (中文(简体) ), api),也接受JSON原始输入有效载荷. |
--schema | 打印JSON Schema(草案2020-12)用于命令或资源. |
--dry-run | 在突变命令上,验证和预览时不拨打后端. |
图标
generate
以双子座生成屏幕或变体.
stitch generate screen --project <project-id> --prompt "Analytics dashboard with revenue chart" --device DESKTOP
| 选项 | 说明 |
|---|---|
-p, --project | 目标项目 ID |
--new-project [title] | 创建新工程 |
--prompt | 艺术指导提示 |
-d, --device | DESKTOP 或者说 MOBILE |
--model | GEMINI_3_8_FLASH 或者说 GEMINI_3_5_FLASH_LITE |
--title | 屏幕标题、最佳工作(项目名称: --new-project(中文(简体) ) |
--screen | 源屏幕( 变量) |
--count | 变种数量, 1–5 |
--creative-range | REFINE, (中文(简体) ), EXPLORE,或 REIMAGINE |
--aspects | 逗号分隔 : LAYOUT, (中文(简体) ), COLOR_SCHEME, (中文(简体) ), IMAGES, (中文(简体) ), TEXT_FONT, (中文(简体) ), TEXT_CONTENT |
--dry-run | 不生成预览 |
edit
更改已有资源 。 对于屏幕,这个以快取再生.
stitch edit screen <screen-id> --project <project-id> --prompt "Add a dark mode toggle to the header"
| 选项 | 说明 |
|---|---|
--prompt | 艺术指导提示 |
--device | DESKTOP 或者说 MOBILE |
--model | 生成模式 |
--design-system | 应用的设计系统ID |
--json '{...}' | 原始补丁有效载荷(例如: design-system(中文(简体) ) |
--dry-run | 预览不更改任何内容 |
资源: screen, (中文(简体) ), design-system。 。 。 .
capture
将页面保存为单个自成一体的 HTML 文件,准备上传为屏幕.
stitch capture http://localhost:3000/library
| 选项 | 说明 |
|---|---|
-o, --output | 输出路径 。 默认 .stitch/captures/<route>.html· ; - 用于 stdout 的 |
--tab [id] | 抓取打开的 Chrome DevTools 标签为- is, 不重新装入 |
--auth | 剧作家 storageState JSON 注册路线 |
--origin | 当抓取本地文件时, 源头为其根相干资产服务 |
--allow-redirect | 即使页面重定向到不同的路由, 也要保存 |
子命令 : routes (在代码库中找到的路由列表),以及 browser, (中文(简体) ), port, (中文(简体) ), file 用于明确的捕获模式.
upload
上传屏幕或设计文件到工程中.
stitch upload screen .stitch/checkout.html --route /checkout --title Checkout
stitch upload design DESIGN.md --project <project-id>
子命令 : screen (HTML或图像), design (DESIGN.md) (英语).
serve
为项目屏幕运行本地预览服务器 .
stitch serve -p <project-id>
| 选项 | 说明 |
|---|---|
-p, --project | 要预览的工程 |
--port | 默认端口 3000 |
--dry-run | 检查配置和退出 |
find
列表资源.
stitch find projects --limit 10
| 选项 | 说明 |
|---|---|
--limit | 最大结果 |
--page-size, (中文(简体) ), --page-token | 倾斜 |
--filter | 过滤表达式 |
资源: project, (中文(简体) ), screen, (中文(简体) ), design-system。 。 。 .
get
通过 ID 获取一个资源 .
stitch get project <project-id> --json
stitch get screen <screen-id> --project <project-id> --json
create
从旗帜或JSON有效载荷创建资源.
stitch create project --title "Customer Dashboard Redesign"
stitch create project --json '{"title":"Customer Dashboard Redesign"}'
选项 : --title, (中文(简体) ), --json, (中文(简体) ), --dry-run。 。 。 .
delete
删除资源 .
stitch delete project --id <project-id> --dry-run
选项 : --id, (中文(简体) ), --dry-run, (中文(简体) ), -y, --yes (skip确认).
open 财务报告和审定财务报表 url
在 Stitch 画布上打开工程或屏幕, 或打印其 URL .
stitch open project <project-id>
stitch url screen <screen-id> --project <project-id>
open --url 打印而不是启动浏览器( 也尊重) STITCH_NO_BROWSER) (中文(简体) ).
mcp
把史迪奇作为MCP服务器运行在stdio上.
stitch mcp install # register with your AI editor
stitch mcp start # start the server (what the editor runs)
agent-skills
安装 a SKILL.md 它教编码代理 如何使用这个CLI.
stitch agent-skills add # writes to .agents/skills
stitch agent-skills list
stitch agent-skills update # resync after upgrading the CLI
api
直接调用 Stitch REST 端点 .
stitch api workspaces
stitch api workspaces/<id>/priorities --schema
选项 : -X, --method (默认) GET, (中文(简体) ), --json, (中文(简体) ), --schema, (中文(简体) ), -y, --yes。 。 。 .
privacy
显示或接受 Stitch 隐私通知和服务条件 : stitch privacy status | show | accept。 。 。 .
实验:循环工作空间
循环对齐带有 Stitch 的 GitHub 仓库 工作空间。你给工作空间 优先事项,这些是诸如"减少离职摩擦"之类的长期目标. Stitch对照每个优先级读取代码库和报告 见解:与路线挂钩的具体机会. 对于每一个见解,它可以提出 解决方案,这是具体的改变.
循环默认关闭 。 命令和API在发布之间可能会有变化.
工作流程
# 1. Turn Loop on and sign in to Google and GitHub
stitch enable loop
stitch login
stitch github login
stitch github configure # grant the Stitch GitHub App access to your repositories
stitch github repos # list repositories you can attach to a workspace
# 2. Create a workspace for a repository and make it this directory's default
stitch create workspace --name Storefront --json '{"repositories":["https://github.com/org/storefront"]}'
stitch find workspaces
stitch config set workspace <workspace-id>
# 3. Add a priority, either from a starter template or written from scratch
stitch create priority --templates
stitch create priority --objective "Reduce checkout friction"
# 4. Generate insights and wait for the run to finish
stitch generate insights --priority <priority-id> --watch --notify
# 5. Review the insights, then generate solutions or dismiss them
stitch find insights --priority <priority-id>
stitch generate solutions --insight <insight-id>
stitch find solutions --priority <priority-id>
stitch dismiss insights <insight-id>
stitch status --flow loop 报告你在登机阶梯 下一步要跑什么.
概念
| 资源 | 这是什么 |
|---|---|
workspace | 和斯迪奇对齐的仓库 它具有优先事项、见解和背景. |
priority | 史迪奇一直反对的目标. |
insight | 从密码库的开采中 找到一个有路可走的机会. |
solution | 提议的改动回应了一个见解. |
context | 外部材料,如docs或specs,附后,因此斯地奇可以超越代码进行推理. |
file | 上传到工作区的文件 . |
skill | 指示如何塑造 Stitch 代理阅读工作空间。 这些是分开的 stitch agent-skills。 。 。 . |
webhook | HTTP在工作空间事件上发射回调. |
connection | 与GitHub或Slack等外部工具的集成. |
所有这些工作都与 find, (中文(简体) ), get, (中文(简体) ), create, (中文(简体) ), edit,以及 delete。并非所有资源都支持每个动词;运行 stitch <verb> --schema 看看他们会做什么.
循环命令
generate insights: 将密码库与一个或多个优先事项相抗衡.
| 选项 | 说明 |
|---|---|
--priority | 优先ID,或逗号分隔的ID |
--watch | 挡住直到跑道结束 退出代码 0 表示已完成, 1 失败, 124 超时 |
--notify | 与 --watch,在运行结束时发送桌面通知 |
--interval | 投票间隔( 默认) ms 2000(中文(简体) ) |
--timeout | 等待秒( 默认值) 3600(中文(简体) ) |
--delay | 延迟透视生成执行 |
generate solutions:提出修改意见以了解情况。 选项 : --insight (ID或逗号分隔的ID),, --replace-existing (替换未指定的解决方案).
create priority: 选项 --objective, (中文(简体) ), --description, (中文(简体) ), --templates (列表启动模板), -t, --template <id|title|index>, (中文(简体) ), -i, --interactive。 。 。 .
dismiss insights <id>:从建议中隐藏见解。 选项 : --concurrency (默认) 5, (中文(简体) ), --dry-run。 。 。 .
edit workspace <id>: 选项 --add-repo, (中文(简体) ), --remove-repo (乌拉圭, owner/repo或身份证).
upload code [dir] 上传编码库归档(a) .zip 工作空间. upload file <path> 上传一个文件.
connect [tool]:通过提供者的OAuth流量连接一个集成.
stitch connect --list
stitch connect slack --no-browser --timeout 180
选项 : -l, --list, (中文(简体) ), -s, --search, (中文(简体) ), --connected, (中文(简体) ), --all, (中文(简体) ), --no-browser, (中文(简体) ), --timeout (默认) 120) (中文(简体) ).
github: 管理 GitHub 连接. 子命令 : login, (中文(简体) ), configure, (中文(简体) ), repos, (中文(简体) ), status。 。 。 .
api <path>: 直接调用工作空间终点, 例如 stitch api workspaces/<id>/priorities。 。 。 .
关闭循环 stitch disable loop。 。 。 .
图书馆
软件包导出一个配置代码库摄取的模块:
import { defineIngest } from '@google/stitch/ingest';
已知的限制
- 一些帆布操作需要
STITCH_API_KEY甚至在和OAuth签约的时候. - 循环是实验性的。 它的资源和旗帜可能会变化而不会出现大的版本起伏.
许可证
阿帕奇 - 2.0