1实现原理 · 为什么它能做到
功能靠调用第三方 SaaS(Sleek)REST API 实现:agent 作为 Sleek 的 API 客户端,用 `POST /api/v1/projects/:id/chat/messages` 把用户意图发给 Sleek 服务端,由 Sleek 的 AI 生成屏幕,agent 负责取回结果与截图展示——技能本体不含任何设计/渲染代码。
[sleek.design](https://sleek.design) is an AI-powered mobile app design tool. You interact with it via a REST API at `/api/v1/*` to create projects, describe what you want built in plain language, and get back rendered screens.
鉴权=环境变量 Bearer token:每个请求带 `Authorization: Bearer $SLEEK_API_KEY`;frontmatter 声明 requires-env。
**Auth**: `Authorization: Bearer $SLEEK_API_KEY` on every `/api/v1/*` request
无 key 时走 OAuth 式 device flow:POST /device/start 拿 verificationUrl+userCode+deviceCode,用户到浏览器确认后轮询 /device/poll 换取 key 并写入 SLEEK_API_KEY。
If `SLEEK_API_KEY` is not set, use the device flow so the user never handles the raw key: 1. `POST https://sleek.design/api/v1/device/start` (no auth) with body `{"source": "your-tool-slug"}`. The response contains a `verificationUrl`, a human-checkable `userCode`, a secret `deviceCode`, and a poll `interval` in seconds. 2. Show the user the `verificationUrl` and the `userCode`, and tell them to confirm the code matches before approving. 3. Poll `POST https://sleek.design/api/v1/device/poll` with `{"deviceCode": "..."}` every `interval` seconds. When the user approves, the poll returns `{"status": "approved", "key": "sk_..."}` exactly once: store it as `SLEEK_API_KEY`.
设计工作流=项目→聊天消息→轮询 run→截图闭环:单条完整意图发 chat,Sleek 自行规划屏幕与版式,agent 轮询 runId 直到 completed 再截图给用户看。
Send the request with `POST /api/v1/projects/:id/chat/messages`. Sleek plans screen content and layout from your message, and will invent a visual style if you don't give it one. Don't decompose the request into screens and don't add product details the user didn't ask for; send the full intent as a single message.
异步纪律:chat 默认异步(202 + runId),轮询 2s→5s 退避、5 分钟上限;`?wait=true` 阻塞至 300s;单项目单 run(409 冲突处理)、idempotency-key 幂等重试。
chat messages are async by default: you get a `runId` and poll `GET /api/v1/projects/:id/chat/runs/:runId`. Start at 2s interval, back off to 5s after 10s, give up after 5 minutes.
结果验证闭环:run 产生 screen_created/updated 必须 POST /api/v1/screenshots 截图给用户,且不允许静默完成;自查时用 fullHeight 重拍整页。
After every chat run that produces `screen_created` or `screen_updated` operations, **take screenshots and show them to the user** using `POST /api/v1/screenshots`. The step is done only when the user has seen a screenshot of every screen the run created or updated; never complete a run silently.
落地实现路径:取 component HTML(activeVersion 或 pin 版本)→ 存 .html;React Native/SwiftUI 则 HTML+截图双源参照,图标经 Iconify API、字体取 HTML link 标签。
The component `code` is a complete HTML document. Save it directly to a `.html` file. No build step needed.
自有安全章程:单主机、仅 HTTPS、密钥只走 Authorization 头、最小 scope key。
**Single host**: All requests go exclusively to `https://sleek.design`. No data is sent to third parties.
2核心能力
3外部依赖
| 类型 | 依赖 |
|---|---|
| api | Sleek REST API (sleek.design) |
| api | Sleek OpenAPI spec |
| api | Iconify API(仅实现原生图标时) |
| cli | curl |
| package | react-native-svg(SvgXml,仅 RN 实现路径) |
4风险提醒 风险提醒:橙色 · 评估后使用
- 需读取用户凭证级环境变量并外发第三方 SaaS — SLEEK_API_KEY 每请求作为 Bearer 发送到 sleek.design;device flow 会把换到的 key 写回环境变量。密钥泄露面在宿主环境与 Sleek 服务端两处,建议最小 scope + 可吊销 key(skill 自己也这样建议)。
- 服务端生成产物直接落盘 — Sleek 返回的 component HTML 被指示直接写为本地 .html 文件——若 Sleek 输出含恶意内容(服务端被攻破/注入),产物进入用户工程。无消毒环节,依赖对服务端的信任。
- 实现路径存在第二外发点 — 取图标时请求 api.iconify.design(按 HTML 中的图标名拼接 URL);虽然 host 白名单 frontmatter 只写 sleek.design,实际 iconify 调用为文档明示,属预期但需知情。
- 依赖商业 SaaS 的可用性与定价 — 功能完全由 sleek.design 提供:免费额度约一次设计、持续使用需 Pro($49.99/月或 $30/月年付);服务端故障/停服/限流直接使 skill 失效,且有升级/充值引导交互面。
- 文档与仓库现状滞后 — 安装命令与 hero 图指向已不存在的旧仓库名 sleekdotdesign/agent-skills,用户按 README 操作可能装到旧版/失败。
5第二遍独立确认
- [ok] 鉴权与凭证读取 — '**Auth**: `Authorization: Bearer $SLEEK_API_KEY` on every `/api/v1/*` request' 原文在;frontmatter requires-env: SLEEK_API_KEY。无其他凭证访问。
- [ok] device flow 换 key — device/start(无鉴权拿 verificationUrl/userCode/deviceCode)+ device/poll 轮询换 sk_ key 并 'store it as SLEEK_API_KEY' 的原文完整存在。
- [ok] 网络外发 host 清单 — 正则扫描全部 URL host 仅 sleek.design(功能主体)与 api.iconify.design(图标实现);example.com 是 imageUrls 文档占位;'Single host… No data is sent to third parties' 与实现路径的 iconify 调用并存——严格说 iconify 为第二外发点,但系文档明示的实现步骤,非隐蔽行为。
- [ok] 本地文件写入 — 'Save screenshots in the project directory'、'Save it directly to a `.html` file'、'curl -o run.json'、SVG 存静态资源四处写入指令均有原文。
- [ok] 无脚本内置 — skill 目录仅 SKILL.md 一个文件,仓库无 scripts/;curl/写文件全部由宿主按指示执行,无自带可执行代码。
- [ok] 端点表与正文一致性 — Quick Reference 11 个端点(projects/components/references/chat runs/cancel/screenshots)与正文 HTTP 示例逐一对应,参数表含 required/默认值/级联(padding)语义。
- [ok] 异步轮询纪律 — 'Start at 2s interval, back off to 5s after 10s, give up after 5 minutes' 与 '?wait=true'(300s 上限、202 超时转轮询)原文在,非编造。
- [ok] 截图验收闭环 — 'never complete a run silently' + fullHeight 自查('re-shoot the screen with `fullHeight: true`')+ 并行截图建议原文均在。
6结论
215af338726abdb5…2aaa24df05