@playcraft/cli 0.0.49 → 0.0.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -44
- package/REMIX.md +760 -0
- package/dist/commands/login.js +82 -32
- package/dist/commands/remix.js +1210 -176
- package/dist/utils/playcraft-http-client.js +172 -0
- package/dist/utils/remix-image-attachments.js +125 -0
- package/package.json +8 -3
- package/dist/agent/cloud-connection.test.js +0 -67
- package/dist/agent/local-backend.test.js +0 -52
- package/dist/commands/fix-ids.test.js +0 -264
- package/dist/commands/tools-research.test.js +0 -216
- package/dist/prad/check.test.js +0 -49
- package/dist/sync/sync-manager.test.js +0 -80
package/REMIX.md
ADDED
|
@@ -0,0 +1,760 @@
|
|
|
1
|
+
# PlayCraft CLI Remix 完整命令参考
|
|
2
|
+
|
|
3
|
+
本文档覆盖 `playcraft remix` 模块当前实际提供的全部命令、参数、交互行为、自动化输出、图片传输和常见工作流。
|
|
4
|
+
|
|
5
|
+
CLI (Command-Line Interface, 命令行界面) 的 Remix 工作流用于:
|
|
6
|
+
|
|
7
|
+
- 查询当前用户的团队和可见项目模板。
|
|
8
|
+
- 从模板项目创建真实 Remix 分支。
|
|
9
|
+
- 启动或复用 Remix 沙箱。
|
|
10
|
+
- 打开 Remix Editor。
|
|
11
|
+
- 向当前沙箱的 Agent 会话发送文本需求和参考图片。
|
|
12
|
+
- 在交互式终端或自动化脚本中完成端到端创建流程。
|
|
13
|
+
- 在本地项目中应用 Phaser 或 Three.js 引擎脚手架。
|
|
14
|
+
|
|
15
|
+
## 1. 命令总览
|
|
16
|
+
|
|
17
|
+
```text
|
|
18
|
+
playcraft remix init-template
|
|
19
|
+
playcraft remix teams
|
|
20
|
+
playcraft remix templates
|
|
21
|
+
playcraft remix create
|
|
22
|
+
playcraft remix start
|
|
23
|
+
playcraft remix prompt
|
|
24
|
+
playcraft remix run
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| 想完成的操作 | 推荐命令 |
|
|
28
|
+
| ---------------------------- | --------------------------------------------------------------------- |
|
|
29
|
+
| 查看当前账号所属团队 | `playcraft remix teams` |
|
|
30
|
+
| 查看团队内可作为模板的项目 | `playcraft remix templates --team-id <team-id>` |
|
|
31
|
+
| 只创建 Remix,不启动沙箱 | `playcraft remix create` 或交互式 `playcraft remix run` 后留空 Prompt |
|
|
32
|
+
| 启动已有 Remix 并打开 Editor | `playcraft remix start --project-id <id> --branch <branch> --open` |
|
|
33
|
+
| 向已有 Remix 发送需求 | `playcraft remix prompt` |
|
|
34
|
+
| 创建 Remix 并立即运行 Agent | `playcraft remix run` |
|
|
35
|
+
| 查询已有 Remix 列表 | `playcraft tools list-remixes`;当前没有 `playcraft remix list` |
|
|
36
|
+
| 给本地项目应用引擎模板 | `playcraft remix init-template` |
|
|
37
|
+
|
|
38
|
+
查看当前版本的帮助:
|
|
39
|
+
|
|
40
|
+
```powershell
|
|
41
|
+
playcraft remix --help
|
|
42
|
+
playcraft remix help start
|
|
43
|
+
playcraft remix prompt --help
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 2. 使用前准备
|
|
47
|
+
|
|
48
|
+
### 2.1 登录
|
|
49
|
+
|
|
50
|
+
普通用户推荐先登录:
|
|
51
|
+
|
|
52
|
+
```powershell
|
|
53
|
+
playcraft login --url https://test-playcraft.aix.intlgame.com
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
登录后,PAT (Personal Access Token, 个人访问令牌) 保存在:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
~/.playcraft/config.json
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
同一环境中的现有 Token 有效时,CLI 会直接使用它。Token 已过期、失效或切换到其他环境时,浏览器重新授权会创建新 Token,并替换本地旧 Token。
|
|
63
|
+
|
|
64
|
+
### 2.2 服务地址优先级
|
|
65
|
+
|
|
66
|
+
Remix 云端命令按以下顺序选择服务地址:
|
|
67
|
+
|
|
68
|
+
1. 当前命令的 `--url <url>`。
|
|
69
|
+
2. `PLAYCRAFT_API_URL` 环境变量。
|
|
70
|
+
3. `PLAYCRAFT_URL` 环境变量。
|
|
71
|
+
4. `~/.playcraft/config.json` 中的 `backendUrl`。
|
|
72
|
+
5. `~/.playcraft/config.json` 中的 `url`。
|
|
73
|
+
6. 默认 PlayCraft 云端地址。
|
|
74
|
+
|
|
75
|
+
PowerShell 示例:
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
$env:PLAYCRAFT_URL = "https://test-playcraft.aix.intlgame.com"
|
|
79
|
+
playcraft remix teams
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### 2.3 Token 优先级
|
|
83
|
+
|
|
84
|
+
Remix 云端命令按以下顺序选择 Token:
|
|
85
|
+
|
|
86
|
+
1. 当前命令的 `--token <token>`。
|
|
87
|
+
2. `PLAYCRAFT_TOKEN` 环境变量。
|
|
88
|
+
3. `~/.playcraft/config.json` 中登录保存的 Token。
|
|
89
|
+
|
|
90
|
+
自动化环境推荐使用环境变量,避免 Token 出现在进程列表或 Shell 历史中:
|
|
91
|
+
|
|
92
|
+
```powershell
|
|
93
|
+
$env:PLAYCRAFT_TOKEN = "playcraft_pat_replace_with_secret"
|
|
94
|
+
playcraft remix teams --json
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### 2.4 项目 ID 与分支
|
|
98
|
+
|
|
99
|
+
- `--project-id` 是 PlayCraft 对外项目 ID (Identifier, 标识符)。
|
|
100
|
+
- `--branch` 必须使用真实 Remix 分支名,例如 `remix/Arrows-cli-test-0723`。
|
|
101
|
+
- URL (Uniform Resource Locator, 统一资源定位符) 中的分支可能显示为 `remix%2FArrows-cli-test-0723`,传给命令时应恢复为 `remix/Arrows-cli-test-0723`。
|
|
102
|
+
- 不要把 Remix 展示名称直接当成分支名;以 `create` 或 `run` 返回的 `branch` 为准。
|
|
103
|
+
|
|
104
|
+
## 3. 通用参数与输出
|
|
105
|
+
|
|
106
|
+
以下参数适用于 `teams`、`templates`、`create`、`start`、`prompt` 和 `run`:
|
|
107
|
+
|
|
108
|
+
| 参数 | 说明 |
|
|
109
|
+
| ----------------- | -------------------------------------------------------------------------------------------------- |
|
|
110
|
+
| `--url <url>` | 指定 PlayCraft 服务地址 |
|
|
111
|
+
| `--token <token>` | 显式指定 PAT |
|
|
112
|
+
| `--json` | 标准输出只返回一个 JSON (JavaScript Object Notation, JavaScript 对象表示法) 结果;进度写入标准错误 |
|
|
113
|
+
|
|
114
|
+
成功 JSON 采用统一外层结构:
|
|
115
|
+
|
|
116
|
+
```json
|
|
117
|
+
{
|
|
118
|
+
"schemaVersion": "1.0",
|
|
119
|
+
"ok": true,
|
|
120
|
+
"command": "remix.start",
|
|
121
|
+
"requestId": "request-id",
|
|
122
|
+
"data": {}
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
失败 JSON 采用统一错误结构:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"schemaVersion": "1.0",
|
|
131
|
+
"ok": false,
|
|
132
|
+
"command": "remix.prompt",
|
|
133
|
+
"requestId": "request-id",
|
|
134
|
+
"error": {
|
|
135
|
+
"code": "AGENT_REQUEST_FAILED",
|
|
136
|
+
"message": "错误说明",
|
|
137
|
+
"retryable": false
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
退出码:
|
|
143
|
+
|
|
144
|
+
| 退出码 | 含义 |
|
|
145
|
+
| ------ | -------------------------------- |
|
|
146
|
+
| `0` | 成功 |
|
|
147
|
+
| `2` | 参数、附件或沙箱容量错误 |
|
|
148
|
+
| `3` | 未登录或登录过期 |
|
|
149
|
+
| `4` | 团队、模板、资源或权限错误 |
|
|
150
|
+
| `5` | Agent 超时、不可用或远端请求失败 |
|
|
151
|
+
|
|
152
|
+
## 4. `remix teams`
|
|
153
|
+
|
|
154
|
+
列出当前登录账号可访问的团队。
|
|
155
|
+
|
|
156
|
+
### 用法
|
|
157
|
+
|
|
158
|
+
```powershell
|
|
159
|
+
playcraft remix teams [--url <url>] [--token <token>] [--json]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### 示例
|
|
163
|
+
|
|
164
|
+
```powershell
|
|
165
|
+
playcraft remix teams
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
人类可读输出:
|
|
169
|
+
|
|
170
|
+
```text
|
|
171
|
+
team-id UA (Tencent IEGG)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
自动化输出:
|
|
175
|
+
|
|
176
|
+
```powershell
|
|
177
|
+
playcraft remix teams --json
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
`data.items` 包含团队记录,`data.total` 表示返回数量。
|
|
181
|
+
|
|
182
|
+
## 5. `remix templates`
|
|
183
|
+
|
|
184
|
+
列出指定团队中当前用户可见的项目模板。
|
|
185
|
+
|
|
186
|
+
### 用法
|
|
187
|
+
|
|
188
|
+
```powershell
|
|
189
|
+
playcraft remix templates `
|
|
190
|
+
--team-id <team-id> `
|
|
191
|
+
[--tag <filter>] `
|
|
192
|
+
[--url <url>] `
|
|
193
|
+
[--token <token>] `
|
|
194
|
+
[--json]
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### 参数
|
|
198
|
+
|
|
199
|
+
| 参数 | 必填 | 说明 |
|
|
200
|
+
| ---------------- | ---- | -------------------------------------- |
|
|
201
|
+
| `--team-id <id>` | 是 | 团队 ID |
|
|
202
|
+
| `--tag <filter>` | 否 | 在模板标签中执行不区分大小写的包含匹配 |
|
|
203
|
+
|
|
204
|
+
### 示例
|
|
205
|
+
|
|
206
|
+
```powershell
|
|
207
|
+
playcraft remix templates `
|
|
208
|
+
--team-id team-id
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
按标签筛选:
|
|
212
|
+
|
|
213
|
+
```powershell
|
|
214
|
+
playcraft remix templates `
|
|
215
|
+
--team-id team-id `
|
|
216
|
+
--tag arrows `
|
|
217
|
+
--json
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
输出中的模板 `id` 可用于 `remix create --project-id` 或 `remix run --template-id`。
|
|
221
|
+
|
|
222
|
+
## 6. `remix create`
|
|
223
|
+
|
|
224
|
+
从指定项目和源分支创建真实 Remix 分支。该命令只创建分支,不启动沙箱、不启动 Agent,也不自动打开 Editor。
|
|
225
|
+
|
|
226
|
+
### 用法
|
|
227
|
+
|
|
228
|
+
```powershell
|
|
229
|
+
playcraft remix create `
|
|
230
|
+
--project-id <project-id> `
|
|
231
|
+
--name <remix-name> `
|
|
232
|
+
[--team-id <team-id>] `
|
|
233
|
+
[--source-branch <branch>] `
|
|
234
|
+
[--url <url>] `
|
|
235
|
+
[--token <token>] `
|
|
236
|
+
[--json]
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### 参数
|
|
240
|
+
|
|
241
|
+
| 参数 | 必填 | 默认值 | 说明 |
|
|
242
|
+
| -------------------------- | ---- | ------ | -------------------------------------- |
|
|
243
|
+
| `--project-id <id>` | 是 | 无 | 源模板项目 ID |
|
|
244
|
+
| `--name <name>` | 是 | 无 | Remix 展示名称;服务端会返回最终分支名 |
|
|
245
|
+
| `--team-id <id>` | 否 | 无 | 团队权限上下文 |
|
|
246
|
+
| `--source-branch <branch>` | 否 | `main` | 创建 Remix 时使用的源分支 |
|
|
247
|
+
|
|
248
|
+
### 示例
|
|
249
|
+
|
|
250
|
+
```powershell
|
|
251
|
+
playcraft remix create `
|
|
252
|
+
--project-id 10000086 `
|
|
253
|
+
--name "Arrows-cli-test-0723" `
|
|
254
|
+
--source-branch main `
|
|
255
|
+
--json
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
保存结果中的以下字段:
|
|
259
|
+
|
|
260
|
+
- `data.projectId`
|
|
261
|
+
- `data.branch`
|
|
262
|
+
- `data.editorUrl`
|
|
263
|
+
|
|
264
|
+
后续进入 Editor:
|
|
265
|
+
|
|
266
|
+
```powershell
|
|
267
|
+
playcraft remix start `
|
|
268
|
+
--project-id 10000086 `
|
|
269
|
+
--branch "remix/Arrows-cli-test-0723" `
|
|
270
|
+
--open
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## 7. `remix start`
|
|
274
|
+
|
|
275
|
+
启动或复用指定 Remix 的沙箱。沙箱就绪后返回 Editor URL;有预览服务时同时返回 Preview URL。该命令不会向 Agent 发送需求。
|
|
276
|
+
|
|
277
|
+
### 用法
|
|
278
|
+
|
|
279
|
+
```powershell
|
|
280
|
+
playcraft remix start `
|
|
281
|
+
--project-id <project-id> `
|
|
282
|
+
--branch <remix-branch> `
|
|
283
|
+
[--source-branch <branch>] `
|
|
284
|
+
[--evict-slot-id <slot-id>] `
|
|
285
|
+
[--evict-confirmed] `
|
|
286
|
+
[--open] `
|
|
287
|
+
[--url <url>] `
|
|
288
|
+
[--token <token>] `
|
|
289
|
+
[--json]
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### 参数
|
|
293
|
+
|
|
294
|
+
| 参数 | 必填 | 说明 |
|
|
295
|
+
| -------------------------- | ---- | ----------------------------------------------------------------------- |
|
|
296
|
+
| `--project-id <id>` | 是 | Remix 所属项目 ID |
|
|
297
|
+
| `--branch <name>` | 是 | Remix 分支,禁止省略后隐式使用 `main` |
|
|
298
|
+
| `--source-branch <branch>` | 否 | 目标分支不存在时使用的源分支 |
|
|
299
|
+
| `--evict-slot-id <id>` | 否 | 沙箱容量满时指定要释放的槽位 |
|
|
300
|
+
| `--evict-confirmed` | 否 | 确认释放 `--evict-slot-id` 指定的槽位;自动化场景应与前一个参数一起使用 |
|
|
301
|
+
| `--open` | 否 | 沙箱就绪后打开 Remix Editor |
|
|
302
|
+
|
|
303
|
+
### 示例:进入已经创建的 Remix
|
|
304
|
+
|
|
305
|
+
```powershell
|
|
306
|
+
playcraft remix start `
|
|
307
|
+
--project-id 10000086 `
|
|
308
|
+
--branch "remix/Arrows-cli-test-0723" `
|
|
309
|
+
--open `
|
|
310
|
+
--url https://test-playcraft.aix.intlgame.com
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
只取得结构化地址,不打开浏览器:
|
|
314
|
+
|
|
315
|
+
```powershell
|
|
316
|
+
playcraft remix start `
|
|
317
|
+
--project-id 10000086 `
|
|
318
|
+
--branch "remix/Arrows-cli-test-0723" `
|
|
319
|
+
--json
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
成功结果的重要字段:
|
|
323
|
+
|
|
324
|
+
| 字段 | 说明 |
|
|
325
|
+
| ---------------------- | ------------------------------------------ |
|
|
326
|
+
| `data.urls.editor` | Remix Editor 地址 |
|
|
327
|
+
| `data.urls.preview` | 沙箱预览地址;只有服务就绪并提供预览时存在 |
|
|
328
|
+
| `data.sandbox.id` | 沙箱 ID |
|
|
329
|
+
| `data.sandbox.slotId` | 沙箱槽位 ID |
|
|
330
|
+
| `data.agent.slug` | 当前 Code Agent 类型 |
|
|
331
|
+
| `data.agent.sessionId` | 当前 Agent 会话 ID |
|
|
332
|
+
|
|
333
|
+
### 沙箱容量满
|
|
334
|
+
|
|
335
|
+
交互式终端会显示可释放槽位并要求确认。非交互或 `--json` 模式不会显示选择菜单,应根据错误详情重新运行:
|
|
336
|
+
|
|
337
|
+
```powershell
|
|
338
|
+
playcraft remix start `
|
|
339
|
+
--project-id 10000086 `
|
|
340
|
+
--branch "remix/Arrows-cli-test-0723" `
|
|
341
|
+
--evict-slot-id <slot-id> `
|
|
342
|
+
--evict-confirmed `
|
|
343
|
+
--json
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## 8. `remix prompt`
|
|
347
|
+
|
|
348
|
+
向指定 Remix 沙箱的当前 Agent 会话发送文本需求和可选参考图片。命令会自动启动或复用沙箱,并使用当前会话;不需要先单独运行 `remix start`。
|
|
349
|
+
|
|
350
|
+
### 用法
|
|
351
|
+
|
|
352
|
+
```powershell
|
|
353
|
+
playcraft remix prompt `
|
|
354
|
+
--project-id <project-id> `
|
|
355
|
+
--branch <remix-branch> `
|
|
356
|
+
(--prompt <text> | --prompt-file <path>) `
|
|
357
|
+
[--image <path-1> <path-2>] `
|
|
358
|
+
[--wait | --no-wait] `
|
|
359
|
+
[--timeout <seconds>] `
|
|
360
|
+
[--evict-slot-id <slot-id>] `
|
|
361
|
+
[--evict-confirmed] `
|
|
362
|
+
[--open] `
|
|
363
|
+
[--url <url>] `
|
|
364
|
+
[--token <token>] `
|
|
365
|
+
[--json]
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### 参数
|
|
369
|
+
|
|
370
|
+
| 参数 | 必填 | 默认值 | 说明 |
|
|
371
|
+
| ---------------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------- |
|
|
372
|
+
| `--project-id <id>` | 是 | 无 | Remix 所属项目 ID |
|
|
373
|
+
| `--branch <name>` | 是 | 无 | Remix 分支 |
|
|
374
|
+
| `--prompt <text>` | 二选一 | 无 | 直接传入需求;不能与 `--prompt-file` 同时使用 |
|
|
375
|
+
| `--prompt-file <path>` | 二选一 | 无 | 读取 UTF-8 (Unicode Transformation Format 8-bit, Unicode 八位转换格式) 文本文件;不能与 `--prompt` 同时使用 |
|
|
376
|
+
| `--image <path...>` | 否 | 无 | 一个或多个本地参考图片路径 |
|
|
377
|
+
| `--wait` | 否 | 默认行为 | 等待当前 Agent 回合结束并读取最后一条助手消息 |
|
|
378
|
+
| `--no-wait` | 否 | 关闭等待 | Agent 接收需求后立即返回,结果中的状态为 `running` |
|
|
379
|
+
| `--timeout <seconds>` | 否 | `1800` | 最少 1 秒;只限制 CLI 等待时间,不代表自动中止远端任务 |
|
|
380
|
+
| `--evict-slot-id <id>` | 否 | 无 | 容量满时指定释放槽位 |
|
|
381
|
+
| `--evict-confirmed` | 否 | `false` | 确认释放指定槽位 |
|
|
382
|
+
| `--open` | 否 | `false` | 执行完成或需求被接收后打开 Editor |
|
|
383
|
+
|
|
384
|
+
Prompt 最大为 256 KiB (Kibibyte, 千二进制字节)。空内容会失败。
|
|
385
|
+
|
|
386
|
+
### 文本示例
|
|
387
|
+
|
|
388
|
+
```powershell
|
|
389
|
+
playcraft remix prompt `
|
|
390
|
+
--project-id 10000086 `
|
|
391
|
+
--branch "remix/Arrows-cli-test-0723" `
|
|
392
|
+
--prompt "继续完善箭头关卡,并检查移动端交互" `
|
|
393
|
+
--wait
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### 从文件读取需求
|
|
397
|
+
|
|
398
|
+
```powershell
|
|
399
|
+
playcraft remix prompt `
|
|
400
|
+
--project-id 10000086 `
|
|
401
|
+
--branch "remix/Arrows-cli-test-0723" `
|
|
402
|
+
--prompt-file .\request.md `
|
|
403
|
+
--json
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### 携带参考图片
|
|
407
|
+
|
|
408
|
+
图片规则:
|
|
409
|
+
|
|
410
|
+
- 最多 4 张。
|
|
411
|
+
- 每张不超过 5 MB (Megabyte, 兆字节)。
|
|
412
|
+
- 支持 JPEG (Joint Photographic Experts Group, 联合图像专家组)、PNG (Portable Network Graphics, 便携式网络图形)、WebP 和 GIF (Graphics Interchange Format, 图形交换格式)。
|
|
413
|
+
- CLI 先校验本地文件,再启动或复用沙箱。
|
|
414
|
+
- 后端会把图片转换为 PNG 并写入 `tmp/opencode-images/`。
|
|
415
|
+
- Agent 收到的是文本 Prompt 和沙箱图片路径,不是非文本图片消息 part。
|
|
416
|
+
- 任意图片校验或上传失败都会终止发送,不会静默降级为纯文本。
|
|
417
|
+
- CLI 不预判当前模型是否具备视觉输入能力。
|
|
418
|
+
|
|
419
|
+
示例:
|
|
420
|
+
|
|
421
|
+
```powershell
|
|
422
|
+
playcraft remix prompt `
|
|
423
|
+
--project-id 10000086 `
|
|
424
|
+
--branch "remix/Arrows-cli-test-0723" `
|
|
425
|
+
--prompt "参考这些图片调整关卡视觉和配色" `
|
|
426
|
+
--image .\ref-a.png .\ref-b.webp `
|
|
427
|
+
--wait
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### 当前会话存在待回答问题
|
|
431
|
+
|
|
432
|
+
如果当前 Agent 会话已有待回答问题,CLI 会先处理这些问题,不会重复发送原需求;本次指定的图片也不会上传。自动化调用应检查结构化输出中的附件状态。
|
|
433
|
+
|
|
434
|
+
## 9. `remix run`
|
|
435
|
+
|
|
436
|
+
`run` 是高层编排命令,支持以下两种模式:
|
|
437
|
+
|
|
438
|
+
1. 选择团队和模板,创建新 Remix,可选立即发送 Agent 需求。
|
|
439
|
+
2. 对已有 `projectId + branch` 发送 Agent 需求。
|
|
440
|
+
|
|
441
|
+
### 用法
|
|
442
|
+
|
|
443
|
+
```powershell
|
|
444
|
+
playcraft remix run `
|
|
445
|
+
[--team-id <team-id>] `
|
|
446
|
+
[--template-id <template-id>] `
|
|
447
|
+
[--project-id <project-id>] `
|
|
448
|
+
[--branch <remix-branch>] `
|
|
449
|
+
[--name <remix-name>] `
|
|
450
|
+
[--source-branch <branch>] `
|
|
451
|
+
[--prompt <text> | --prompt-file <path>] `
|
|
452
|
+
[--image <path-1> <path-2>] `
|
|
453
|
+
[--wait | --no-wait] `
|
|
454
|
+
[--timeout <seconds>] `
|
|
455
|
+
[--open] `
|
|
456
|
+
[--url <url>] `
|
|
457
|
+
[--token <token>] `
|
|
458
|
+
[--json]
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
### 参数
|
|
462
|
+
|
|
463
|
+
| 参数 | 创建模式 | 已有 Remix 模式 | 说明 |
|
|
464
|
+
| -------------------------- | ---------------- | ---------------- | ----------------------------------------------- |
|
|
465
|
+
| `--team-id <id>` | 非交互时必填 | 禁止 | 所选团队 ID |
|
|
466
|
+
| `--template-id <id>` | 非交互时必填 | 禁止 | 源模板项目 ID |
|
|
467
|
+
| `--project-id <id>` | 禁止 | 必填 | 已有 Remix 项目 ID |
|
|
468
|
+
| `--branch <name>` | 自动生成 | 必填 | 已有 Remix 分支 |
|
|
469
|
+
| `--name <name>` | 非交互时必填 | 禁止 | 新 Remix 展示名称 |
|
|
470
|
+
| `--source-branch <branch>` | 可选 | 不使用 | 模板没有配置默认分支时的回退源分支,默认 `main` |
|
|
471
|
+
| `--prompt <text>` | 可选 | 非交互时必填 | 内联需求 |
|
|
472
|
+
| `--prompt-file <path>` | 可选 | 非交互时必填 | 文件需求;与 `--prompt` 二选一 |
|
|
473
|
+
| `--image <path...>` | 有 Prompt 时可选 | 有 Prompt 时可选 | 图片规则与 `remix prompt` 相同 |
|
|
474
|
+
| `--wait` / `--no-wait` | 可选 | 可选 | 默认等待 Agent 完成 |
|
|
475
|
+
| `--timeout <seconds>` | 可选 | 可选 | 默认 1800 秒 |
|
|
476
|
+
| `--open` | 可选 | 可选 | Agent 流程启动后打开 Editor |
|
|
477
|
+
|
|
478
|
+
`--project-id + --branch` 不能与 `--team-id`、`--template-id` 或 `--name` 混用。
|
|
479
|
+
|
|
480
|
+
### 交互式完整流程
|
|
481
|
+
|
|
482
|
+
```powershell
|
|
483
|
+
playcraft remix run
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
交互顺序:
|
|
487
|
+
|
|
488
|
+
1. 选择团队。
|
|
489
|
+
2. 加载模板来源:有模板页权限时显示团队模板和当前团队的系统推荐;无权限时只显示当前团队的系统推荐。系统推荐与 Remix 画廊一致,由推荐 Prompt 模板和推荐 Remix 两部分组成。
|
|
490
|
+
3. 选择模板;输入 `back` 可返回团队列表。
|
|
491
|
+
4. 选择团队模板后加载它的分支,可选择 `main` 或已有 Remix;选择系统推荐时直接使用该推荐配置的基础模板和分支。输入 `back` 可返回模板列表。
|
|
492
|
+
5. CLI 按平台规则自动生成 Remix 名称并创建真实 Remix 分支。
|
|
493
|
+
6. 输入需求描述。
|
|
494
|
+
7. 有需求时启动沙箱并运行 Agent;直接回车或输入 `exit` 时只创建 Remix。
|
|
495
|
+
|
|
496
|
+
模板权限与网页 `/projects` 保持一致,仅系统管理员可以读取团队模板项目。CLI 只在服务端明确返回 `403 Forbidden` 时降级为仅系统推荐;网络错误或服务端异常会原样报错,不会误判成权限不足。
|
|
497
|
+
|
|
498
|
+
创建后留空 Prompt 的输出:
|
|
499
|
+
|
|
500
|
+
```text
|
|
501
|
+
✓ Remix 创建完成:Arrows-cli-test-0723
|
|
502
|
+
Remix 详情地址:https://test-playcraft.aix.intlgame.com/projects/10000086/remixes/remix%2FArrows-cli-test-0723
|
|
503
|
+
已结束:Remix 已创建,未启动 Agent。
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
此时继续进入 Editor:
|
|
507
|
+
|
|
508
|
+
```powershell
|
|
509
|
+
playcraft remix start `
|
|
510
|
+
--project-id 10000086 `
|
|
511
|
+
--branch "remix/Arrows-cli-test-0723" `
|
|
512
|
+
--open
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### 非交互创建并运行 Agent
|
|
516
|
+
|
|
517
|
+
```powershell
|
|
518
|
+
playcraft remix run `
|
|
519
|
+
--team-id team-id `
|
|
520
|
+
--template-id 10000086 `
|
|
521
|
+
--name "Arrows-cli-generated" `
|
|
522
|
+
--prompt "创建三个递进难度的箭头关卡" `
|
|
523
|
+
--wait `
|
|
524
|
+
--json
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### 非交互只创建 Remix
|
|
528
|
+
|
|
529
|
+
```powershell
|
|
530
|
+
playcraft remix run `
|
|
531
|
+
--team-id team-id `
|
|
532
|
+
--template-id 10000086 `
|
|
533
|
+
--name "Arrows-cli-created-only" `
|
|
534
|
+
--json
|
|
535
|
+
```
|
|
536
|
+
|
|
537
|
+
该模式不会启动沙箱。之后使用 `remix start` 或 `remix prompt`。
|
|
538
|
+
|
|
539
|
+
### 对已有 Remix 继续运行 Agent
|
|
540
|
+
|
|
541
|
+
```powershell
|
|
542
|
+
playcraft remix run `
|
|
543
|
+
--project-id 10000086 `
|
|
544
|
+
--branch "remix/Arrows-cli-test-0723" `
|
|
545
|
+
--prompt "继续完成上次未完成的关卡调整" `
|
|
546
|
+
--wait
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
`remix run` 的已有 Remix 模式与 `remix prompt` 接近;需要更直接、可预测的调用时推荐使用 `remix prompt`。
|
|
550
|
+
|
|
551
|
+
## 10. `remix init-template`
|
|
552
|
+
|
|
553
|
+
该命令是本地脚手架能力,与云端 Remix 分支、沙箱和 Agent 会话无关。
|
|
554
|
+
|
|
555
|
+
### 用法
|
|
556
|
+
|
|
557
|
+
```powershell
|
|
558
|
+
playcraft remix init-template `
|
|
559
|
+
[--engine phaser|threejs] `
|
|
560
|
+
[--from-atom-tree] `
|
|
561
|
+
[--project-dir <path>] `
|
|
562
|
+
[--force] `
|
|
563
|
+
[--bake] `
|
|
564
|
+
[--all-engines]
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
### 参数
|
|
568
|
+
|
|
569
|
+
| 参数 | 说明 |
|
|
570
|
+
| ---------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
571
|
+
| `--engine <name>` | 选择 `phaser` 或 `threejs` |
|
|
572
|
+
| `--from-atom-tree` | 从项目 `docs/atom-tree.json` 的 `meta.engineDecision.adapter` 读取引擎,并自动链接选择的 Atom Skills |
|
|
573
|
+
| `--project-dir <path>` | 项目根目录,默认当前工作目录 |
|
|
574
|
+
| `--force` | 当前 `.playcraft-engine` 与目标引擎不一致时仍替换 `game/`;使用前应确认现有内容可恢复 |
|
|
575
|
+
| `--bake` | 烘焙 CLI 包维护的完整项目模板 |
|
|
576
|
+
| `--all-engines` | 与 `--bake` 一起使用,烘焙全部已知引擎模板 |
|
|
577
|
+
|
|
578
|
+
必须提供 `--engine` 或 `--from-atom-tree`;唯一例外是同时使用 `--bake --all-engines`。
|
|
579
|
+
|
|
580
|
+
应用 Phaser 模板:
|
|
581
|
+
|
|
582
|
+
```powershell
|
|
583
|
+
playcraft remix init-template `
|
|
584
|
+
--engine phaser `
|
|
585
|
+
--project-dir D:\projects\my-playable
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
从 Atom Tree 读取引擎:
|
|
589
|
+
|
|
590
|
+
```powershell
|
|
591
|
+
playcraft remix init-template `
|
|
592
|
+
--from-atom-tree `
|
|
593
|
+
--project-dir D:\projects\my-playable
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
烘焙全部引擎模板:
|
|
597
|
+
|
|
598
|
+
```powershell
|
|
599
|
+
playcraft remix init-template --bake --all-engines
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
## 11. 查询已有 Remix
|
|
603
|
+
|
|
604
|
+
当前 `playcraft remix` 模块没有 `list` 子命令。使用现有工具命令:
|
|
605
|
+
|
|
606
|
+
```powershell
|
|
607
|
+
playcraft tools list-remixes `
|
|
608
|
+
--scope my `
|
|
609
|
+
--page 1 `
|
|
610
|
+
--limit 20
|
|
611
|
+
```
|
|
612
|
+
|
|
613
|
+
搜索:
|
|
614
|
+
|
|
615
|
+
```powershell
|
|
616
|
+
playcraft tools list-remixes `
|
|
617
|
+
--scope my `
|
|
618
|
+
--search "Arrows-cli"
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
参数:
|
|
622
|
+
|
|
623
|
+
| 参数 | 默认值 | 说明 |
|
|
624
|
+
| -------------------- | ------ | ----------------------------------------------- |
|
|
625
|
+
| `--scope <scope>` | `my` | `my` 查询自己可访问的 Remix;`gallery` 查询画廊 |
|
|
626
|
+
| `--search <keyword>` | 无 | 按关键字搜索 |
|
|
627
|
+
| `--limit <n>` | `20` | 每页最大数量 |
|
|
628
|
+
| `--page <n>` | `1` | 页码 |
|
|
629
|
+
|
|
630
|
+
该工具命令会把完整结果写入结果文件,并在终端打印数量和文件位置。
|
|
631
|
+
|
|
632
|
+
## 12. 推荐工作流
|
|
633
|
+
|
|
634
|
+
### 12.1 第一次使用
|
|
635
|
+
|
|
636
|
+
```powershell
|
|
637
|
+
playcraft login --url https://test-playcraft.aix.intlgame.com
|
|
638
|
+
playcraft remix teams
|
|
639
|
+
playcraft remix templates --team-id <team-id>
|
|
640
|
+
playcraft remix run
|
|
641
|
+
```
|
|
642
|
+
|
|
643
|
+
### 12.2 创建、稍后打开 Editor
|
|
644
|
+
|
|
645
|
+
```powershell
|
|
646
|
+
playcraft remix run
|
|
647
|
+
|
|
648
|
+
playcraft remix start `
|
|
649
|
+
--project-id <project-id> `
|
|
650
|
+
--branch <remix-branch> `
|
|
651
|
+
--open
|
|
652
|
+
```
|
|
653
|
+
|
|
654
|
+
### 12.3 创建后立即让 Agent 工作
|
|
655
|
+
|
|
656
|
+
```powershell
|
|
657
|
+
playcraft remix run `
|
|
658
|
+
--team-id <team-id> `
|
|
659
|
+
--template-id <template-id> `
|
|
660
|
+
--name <remix-name> `
|
|
661
|
+
--prompt-file .\request.md `
|
|
662
|
+
--wait `
|
|
663
|
+
--open
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
### 12.4 已有 Remix 继续迭代
|
|
667
|
+
|
|
668
|
+
```powershell
|
|
669
|
+
playcraft remix prompt `
|
|
670
|
+
--project-id <project-id> `
|
|
671
|
+
--branch <remix-branch> `
|
|
672
|
+
--prompt "继续优化视觉、交互和加载性能" `
|
|
673
|
+
--image .\visual-reference.png `
|
|
674
|
+
--wait
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
### 12.5 CI 自动化
|
|
678
|
+
|
|
679
|
+
CI (Continuous Integration, 持续集成) 中应显式提供所有必需参数,并使用环境变量传 Token:
|
|
680
|
+
|
|
681
|
+
```powershell
|
|
682
|
+
$env:PLAYCRAFT_URL = "https://test-playcraft.aix.intlgame.com"
|
|
683
|
+
$env:PLAYCRAFT_TOKEN = "playcraft_pat_replace_with_secret"
|
|
684
|
+
|
|
685
|
+
playcraft remix run `
|
|
686
|
+
--team-id <team-id> `
|
|
687
|
+
--template-id <template-id> `
|
|
688
|
+
--name <remix-name> `
|
|
689
|
+
--prompt-file .\request.md `
|
|
690
|
+
--no-wait `
|
|
691
|
+
--json
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
## 13. URL 类型说明
|
|
695
|
+
|
|
696
|
+
Remix 流程可能返回三种不同地址:
|
|
697
|
+
|
|
698
|
+
| 地址 | 用途 |
|
|
699
|
+
| -------------- | ----------------------------------------------------------------------------- |
|
|
700
|
+
| Remix 详情地址 | 项目页面中的 Remix 详情,例如 `/projects/{projectId}/remixes/{encodedBranch}` |
|
|
701
|
+
| Editor 地址 | Remix 编辑器,例如 `/editor/remix/{projectId}?branch={encodedBranch}` |
|
|
702
|
+
| Preview 地址 | 沙箱中的运行预览;只有沙箱就绪时存在 |
|
|
703
|
+
|
|
704
|
+
`remix run` 创建后留空 Prompt 时显示的是 Remix 详情地址,因为沙箱尚未启动。要进入 Editor,运行 `remix start --open`。
|
|
705
|
+
|
|
706
|
+
## 14. 常见问题
|
|
707
|
+
|
|
708
|
+
### 14.1 `run` 显示“未启动 Agent”是不是创建失败?
|
|
709
|
+
|
|
710
|
+
不是。交互式 `run` 在 Prompt 留空或输入 `exit` 时只创建 Remix。之后可以运行:
|
|
711
|
+
|
|
712
|
+
```powershell
|
|
713
|
+
playcraft remix start --project-id <project-id> --branch <remix-branch> --open
|
|
714
|
+
```
|
|
715
|
+
|
|
716
|
+
### 14.2 能否不先运行 `start`,直接发送 Prompt?
|
|
717
|
+
|
|
718
|
+
可以。`remix prompt` 会自动启动或复用沙箱。
|
|
719
|
+
|
|
720
|
+
### 14.3 为什么 `prompt` 必须同时提供项目 ID 和分支?
|
|
721
|
+
|
|
722
|
+
项目中可能存在多个 Remix 分支。显式指定二者可以避免需求落到 `main` 或其他 Remix。
|
|
723
|
+
|
|
724
|
+
### 14.4 `--open` 与 URL 输出有什么区别?
|
|
725
|
+
|
|
726
|
+
`--open` 会调用系统浏览器。没有 `--open` 时命令仍会返回或打印 Editor URL,适合远程终端和自动化环境。
|
|
727
|
+
|
|
728
|
+
### 14.5 图片上传失败后是否仍会发送纯文本?
|
|
729
|
+
|
|
730
|
+
不会。附件校验或上传失败时,整个 Prompt 请求失败,避免 Agent 在缺少参考图的情况下继续执行。
|
|
731
|
+
|
|
732
|
+
### 14.6 `--no-wait` 是否会取消 Agent?
|
|
733
|
+
|
|
734
|
+
不会。它只让 CLI 在 Agent 接收请求后立即返回,远端任务继续运行。
|
|
735
|
+
|
|
736
|
+
### 14.7 超时后 Agent 是否会停止?
|
|
737
|
+
|
|
738
|
+
不保证。`--timeout` 限制 CLI 等待时间;当前命令不会因为本地等待超时而自动中止远端 Agent。
|
|
739
|
+
|
|
740
|
+
### 14.8 如何避免测试环境和生产环境 Token 混用?
|
|
741
|
+
|
|
742
|
+
登录时显式传入环境地址:
|
|
743
|
+
|
|
744
|
+
```powershell
|
|
745
|
+
playcraft login --url https://test-playcraft.aix.intlgame.com
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
CLI 只会在保存 Token 的环境与目标环境一致时复用它;浏览器重新授权会创建新 Token 并替换旧值。
|
|
749
|
+
|
|
750
|
+
## 15. 版本与帮助
|
|
751
|
+
|
|
752
|
+
本文档描述当前源码中的命令。安装版本可能落后于仓库源码,排查参数差异时先检查:
|
|
753
|
+
|
|
754
|
+
```powershell
|
|
755
|
+
playcraft --version
|
|
756
|
+
playcraft remix --help
|
|
757
|
+
playcraft remix <command> --help
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
如果全局安装版本未包含最新命令,需要发布或重新安装 `@playcraft/cli` 后再使用。
|