---
name: playcraft-deploy
description: 组合操作：build → save → publish。在 sandbox 构建，保存代码到 Git，上传 dist/ 到 COS，返回可分享的预览链接。
compatibility: agent
---

## Skill Definition
tools:
  - bash
  - read
prompt_extension: |
  你负责完整的发布流程：构建 → 保存到 Git → 上传 COS → 返回预览链接。

  ## 三步原子流程

  ```
  playcraft tools build-project  →  playcraft tools save-to-git  →  playcraft tools publish
            ↓                              ↓                              ↓
      npm run build               commit+push                  上传 dist/ 到 COS
    (dist/ in sandbox)           (dist/ in repo)                → previewUrl
  ```

  ## CLI 命令说明
  - **`playcraft tools build-project --project-id <ID>`**：在项目 sandbox 里执行 npm run build
  - **`playcraft tools save-to-git --project-id <ID> --message "<提交信息>"`**：将 sandbox（含 dist/）sync 到 repo，commit 并 push
  - **`playcraft tools publish --project-id <ID>`**：读取 repo 中的 dist/，上传到 COS，返回 previewUrl
  - **`playcraft tools list-remixes`**：当 projectId 未知时查询；结果写入文件，stdout 打印摘要，用 `read` 工具查看详细数据
  - **read**：读取 context.md 获取项目信息

  ## 工作流
  1. 从 context.md 或 `playcraft tools list-remixes` 获取 projectId 和 branch
  2. **`playcraft tools build-project --project-id <ID>`**
     - 失败 → terminate `{ summary: "构建失败：<error>，请先修复代码" }`
  3. **`playcraft tools save-to-git --project-id <ID> --message "<提交信息>"`**
     - 失败 → terminate `{ summary: "Git 保存失败：<error>" }`
  4. **`playcraft tools publish --project-id <ID>`**
     - 失败 → terminate `{ summary: "COS 上传失败（可能未配置 COS），代码已保存到 Git" }`
  5. 成功 → terminate `{ summary: "发布成功，预览链接：<previewUrl>" }`

  ## 注意
  - 三步必须按顺序执行，前一步失败则停止并汇报
  - build-project 和 save-to-git 操作的是同一个 sandbox，sandbox 必须处于 ready 状态
  - 若 COS 未配置，publish 会返回 null URL；此时代码已成功保存到 Git，不算完全失败

## 我做什么
1. 在项目 sandbox 中执行 `npm run build`
2. 将代码和构建产物保存到 Git
3. 上传 dist/ 到 COS，返回可分享的预览 URL

## 何时用我
- "帮我构建并发布项目"
- "生成一个预览链接"
- 可玩广告变体完成后，需要发布测试链接时

## 工作流
1. **`playcraft tools build-project --project-id <ID>`**（构建）→ 失败则 terminate 汇报
2. **`playcraft tools save-to-git --project-id <ID> --message "<提交信息>"`**（保存）→ 失败则 terminate 汇报
3. **`playcraft tools publish --project-id <ID>`**（发布）→ 返回 previewUrl
4. **terminate** `{ summary: "发布成功，预览：<previewUrl>" }`
