@playcraft/cli 0.0.39 → 0.0.41

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.
Files changed (121) hide show
  1. package/README.md +66 -3
  2. package/dist/atom-plan/validate-atom-plan.js +298 -0
  3. package/dist/cli-root-help.js +1 -1
  4. package/dist/commands/3d.js +363 -0
  5. package/dist/commands/create.js +337 -0
  6. package/dist/commands/fix-ids.js +17 -3
  7. package/dist/commands/fix-ids.test.js +264 -0
  8. package/dist/commands/image.js +1337 -43
  9. package/dist/commands/login.js +60 -2
  10. package/dist/commands/recommend.js +1 -1
  11. package/dist/commands/remix.js +213 -0
  12. package/dist/commands/skills.js +1379 -0
  13. package/dist/commands/tools-3d.js +473 -0
  14. package/dist/commands/tools-generation.js +454 -0
  15. package/dist/commands/tools-project.js +400 -0
  16. package/dist/commands/tools-research.js +37 -0
  17. package/dist/commands/tools-research.test.js +216 -0
  18. package/dist/commands/tools-utils.js +164 -0
  19. package/dist/commands/tools.js +7 -616
  20. package/dist/config.js +2 -0
  21. package/dist/index.js +20 -2
  22. package/dist/utils/agent-api-client.js +52 -16
  23. package/package.json +9 -3
  24. package/project-template/.claude/agents/designer.md +116 -0
  25. package/project-template/.claude/agents/developer.md +133 -0
  26. package/project-template/.claude/agents/pm.md +164 -0
  27. package/project-template/.claude/agents/refs/README.md +67 -0
  28. package/project-template/.claude/agents/refs/designer-art-style-catalog.md +533 -0
  29. package/project-template/.claude/agents/refs/designer-color-audio-recipes.md +153 -0
  30. package/project-template/.claude/agents/refs/designer-deliverable-spec.md +167 -0
  31. package/project-template/.claude/agents/refs/designer-dimension-axis.md +27 -0
  32. package/project-template/.claude/agents/refs/designer-handoff-v2-checklist.md +68 -0
  33. package/project-template/.claude/agents/refs/designer-master-composite-recipes.md +216 -0
  34. package/project-template/.claude/agents/refs/designer-style-exploration-flow.md +37 -0
  35. package/project-template/.claude/agents/refs/developer-dev-handoff.md +109 -0
  36. package/project-template/.claude/agents/refs/developer-impl-cookbook.md +134 -0
  37. package/project-template/.claude/agents/refs/developer-phase1-flow.md +211 -0
  38. package/project-template/.claude/agents/refs/pm-workflow-detail.md +545 -0
  39. package/project-template/.claude/agents/refs/reviewer-six-dimension-eval.md +286 -0
  40. package/project-template/.claude/agents/refs/ta-3d-flip-recipe.md +85 -0
  41. package/project-template/.claude/agents/refs/ta-atlas-deliverable-standard.md +46 -0
  42. package/project-template/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
  43. package/project-template/.claude/agents/refs/ta-image-generation-detail.md +356 -0
  44. package/project-template/.claude/agents/refs/ta-image-ops-reference.md +495 -0
  45. package/project-template/.claude/agents/refs/ta-pipeline-cookbook.md +699 -0
  46. package/project-template/.claude/agents/refs/ta-tools-reference.md +111 -0
  47. package/project-template/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
  48. package/project-template/.claude/agents/reviewer.md +103 -0
  49. package/project-template/.claude/agents/technical-artist.md +111 -0
  50. package/project-template/.claude/hooks/README.md +36 -0
  51. package/project-template/.claude/hooks/validate-atom-plan.mjs +224 -0
  52. package/project-template/.claude/hooks/validate-workflow-stop.mjs +258 -0
  53. package/project-template/.claude/settings.json +32 -0
  54. package/project-template/.claude/settings.local.json +4 -0
  55. package/project-template/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
  56. package/project-template/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
  57. package/project-template/.claude/skills/playcraft-asset-state-sheet/SKILL.md +141 -0
  58. package/project-template/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
  59. package/project-template/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
  60. package/project-template/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
  61. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +229 -0
  62. package/project-template/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
  63. package/project-template/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
  64. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +235 -0
  65. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -0
  66. package/project-template/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
  67. package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +137 -0
  68. package/project-template/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
  69. package/project-template/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
  70. package/project-template/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
  71. package/project-template/.claude/skills/playcraft-masking/SKILL.md +373 -0
  72. package/project-template/.claude/skills/playcraft-research/SKILL.md +212 -0
  73. package/project-template/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
  74. package/project-template/.claude/skills/playcraft-storyboard/SKILL.md +148 -0
  75. package/project-template/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
  76. package/project-template/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
  77. package/project-template/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
  78. package/project-template/.claude/skills/playcraft-workflow/SKILL.md +396 -0
  79. package/project-template/.cursor/hooks.json +17 -0
  80. package/project-template/.cursor/rules/playcraft-orchestrator.mdc +87 -0
  81. package/project-template/.cursor/rules/playcraft-subagent-boundary.mdc +18 -0
  82. package/project-template/CLAUDE.md +240 -0
  83. package/project-template/assets/audio/bgm/.gitkeep +0 -0
  84. package/project-template/assets/audio/sfx/.gitkeep +0 -0
  85. package/project-template/assets/bundles/.gitkeep +0 -0
  86. package/project-template/assets/images/bg/.gitkeep +0 -0
  87. package/project-template/assets/images/reference/.gitkeep +0 -0
  88. package/project-template/assets/images/storyboard/.gitkeep +0 -0
  89. package/project-template/assets/images/tiles/.gitkeep +0 -0
  90. package/project-template/assets/images/ui/.gitkeep +0 -0
  91. package/project-template/assets/images/vfx/.gitkeep +0 -0
  92. package/project-template/assets/models/.gitkeep +0 -0
  93. package/project-template/docs/team/agent-conduct.md +105 -0
  94. package/project-template/docs/team/agent-runtime-matrix.md +62 -0
  95. package/project-template/docs/team/atom-plan-format.md +74 -0
  96. package/project-template/docs/team/collaboration.md +288 -0
  97. package/project-template/docs/team/core-model.md +50 -0
  98. package/project-template/docs/team/platform-capabilities.md +15 -0
  99. package/project-template/docs/team/workflow-changelog.md +51 -0
  100. package/project-template/docs/team/workflow-consistency-checklist.md +128 -0
  101. package/project-template/game/config/.gitkeep +0 -0
  102. package/project-template/game/gameplay/.gitkeep +0 -0
  103. package/project-template/game/scenes/.gitkeep +0 -0
  104. package/project-template/logs/.gitkeep +0 -0
  105. package/project-template/ta-workspace/logs/.gitkeep +0 -0
  106. package/project-template/ta-workspace/scripts/.gitkeep +0 -0
  107. package/project-template/ta-workspace/tmp/.gitkeep +0 -0
  108. package/project-template/templates/atom-plan.template.json +26 -0
  109. package/project-template/templates/atom-plan.template.md +76 -0
  110. package/project-template/templates/design-brief.template.md +195 -0
  111. package/project-template/templates/design-lens-checklist.reference.md +117 -0
  112. package/project-template/templates/design-methodology.md +99 -0
  113. package/project-template/templates/designer-log.template.md +98 -0
  114. package/project-template/templates/developer-log.template.md +140 -0
  115. package/project-template/templates/five-axis-framework.md +186 -0
  116. package/project-template/templates/intent-clarifications.template.md +58 -0
  117. package/project-template/templates/layout-spec.template.md +132 -0
  118. package/project-template/templates/project-state.template.md +219 -0
  119. package/project-template/templates/review-report.template.md +166 -0
  120. package/project-template/templates/style-exploration.template.md +93 -0
  121. package/project-template/templates/ta-log.template.md +205 -0
@@ -0,0 +1,373 @@
1
+ ---
2
+ name: playcraft-masking
3
+ description: PlayCraft 蒙版与智能抠图完整指南。涵盖 decompose-layers(302 Qwen 整图分层)、segment(SAM3 语义分割)的文本/框选模式、mask+rgba 输出、remove-background 选型、蒙版合成与轮廓描边。TA 在处理抠图、蒙版或背景替换任务前必读。
4
+ triggers: 蒙版,mask,抠图,去背景,remove-background,语义分割,segment,SAM,SAM3,decompose-layers,图层分层,layered,背景替换,透明背景,RGBA,floodfill,ai抠图,轮廓描边,背景分离,foreground,主体提取
5
+ ---
6
+
7
+ # PlayCraft 蒙版与智能抠图完整指南
8
+
9
+ ## 0. 工具速查
10
+
11
+ | 工具 | 适用场景 | 速度 | 质量 |
12
+ | -------------------------------------- | ------------------------------------------------- | ---------------------- | -------------------- |
13
+ | `remove-background --method floodfill` | 纯色背景(绿幕、白底、渐变色) | 快(本地) | 中等,边缘较硬 |
14
+ | `remove-background --method ai` | 任意复杂背景 | 慢(调后端) | 高,支持半透明/毛发 |
15
+ | `decompose-layers` | **整图**拆成 N 个语义 RGBA 层(Master Composite) | 慢(302,约 1–2 分钟) | 高,全尺寸分层 PNG |
16
+ | `segment` | 按 prompt **指定对象**抠图/蒙版 | 慢(SAM3) | 最高,产出 mask+rgba |
17
+
18
+ **决策逻辑**:
19
+
20
+ ```
21
+ 要从整张合成稿一次性拆出背景/角色/UI 等多层?
22
+ ├─ 是 → decompose-layers(需 Admin 配置 302 API Key;本地图需公网 URL 或 --input HTTPS)
23
+ └─ 否 → 背景是纯色/绿幕?
24
+ ├─ 是 → remove-background --method floodfill
25
+ └─ 否 → 需要 mask 文件供后续合成?
26
+ ├─ 是 → segment(或已知位置用 crop)
27
+ └─ 否 → remove-background --method ai
28
+ ```
29
+
30
+ **decompose-layers vs segment**:
31
+
32
+ - **decompose-layers**:无 per-object prompt,自动分层;适合 Master Composite 拆解;**不能**指定「只要第 3 格 tile」。ASR 优先用 `crop`。
33
+ - **segment**:开放词汇或框选单个对象;适合精确蒙版;密集网格上**禁止**纯 text prompt(见下文 §2)。
34
+
35
+ ---
36
+
37
+ ## 1. decompose-layers — 302 Qwen 整图语义分层
38
+
39
+ 将整张图拆成 `num_layers` 张带透明通道的 PNG(默认 4 层),用于 Master Composite 元素提取(ASR 优先 crop,不用本命令)。
40
+
41
+ ```bash
42
+ playcraft image decompose-layers \
43
+ --input assets/images/storyboard/master_composite.png \
44
+ --output-dir ta-workspace/tmp/layers \
45
+ --num-layers 4 \
46
+ --prompt ""
47
+
48
+ # 输入已是公网 URL 时(推荐本地 dev)
49
+ playcraft image decompose-layers \
50
+ --input "https://example.com/composite.png" \
51
+ --output-dir ./layers-out
52
+ ```
53
+
54
+ **配置**:Admin → 系统 → AI → `provider=302`、`modelKind=image` + API Key(与 302 生图共用,**不必**单独添加 qwen-image-layered 模型项)。
55
+
56
+ **输出**:`layer_00.png` … `layer_{N-1}.png` + `decompose-layers-meta.json`。
57
+
58
+ ---
59
+
60
+ ## 2. remove-background — 去背景
61
+
62
+ ### Floodfill 模式(纯色背景)
63
+
64
+ ```bash
65
+ # 基础用法(默认 floodfill,去除纯色背景)
66
+ playcraft image remove-background \
67
+ --input assets/images/tiles/tile_greenscreen.png \
68
+ --output assets/images/tiles/tile_transparent.png
69
+
70
+ # 调整容差(--tolerance,默认 30)
71
+ # 值越高,容错越大(适合渐变背景或有噪点的纯色背景)
72
+ playcraft image remove-background \
73
+ --input assets/images/character/character_white_bg.png \
74
+ --output assets/images/character/character_transparent.png \
75
+ --method floodfill \
76
+ --tolerance 50
77
+
78
+ # 边缘平滑度(--edge-smooth,默认 2,最大有效 4)
79
+ # 值越高,边缘越柔和(减少锯齿)
80
+ playcraft image remove-background \
81
+ --input assets/images/tiles/tile_white.png \
82
+ --output assets/images/tiles/tile_clean.png \
83
+ --tolerance 30 \
84
+ --edge-smooth 3
85
+ ```
86
+
87
+ **Floodfill 参数说明**:
88
+
89
+ | 参数 | 默认值 | 说明 |
90
+ | --------------- | ------ | -------------------------------------------------- |
91
+ | `--tolerance` | 30 | 颜色容差(0-255):背景色在此范围内的像素都被去掉 |
92
+ | `--edge-smooth` | 2 | 边缘平滑(0-4):对边缘 alpha 做高斯平滑,减少锯齿 |
93
+
94
+ **什么时候调大 tolerance**:
95
+
96
+ - 白色背景但图中有浅色元素 → tolerance 太大会误删内容,建议 20-30
97
+ - 绿幕背景有轻微渐变 → 可试 40-60
98
+ - 背景有明显噪点 → 50+
99
+
100
+ ### AI 模式(复杂背景)
101
+
102
+ ```bash
103
+ playcraft image remove-background \
104
+ --input assets/images/character/character_scene.png \
105
+ --output assets/images/character/character_cutout.png \
106
+ --method ai \
107
+ --model small # small(快)或 medium(精细)
108
+
109
+ # 跳过 alpha 精化(更快,边缘稍粗)
110
+ playcraft image remove-background \
111
+ --input source.png \
112
+ --output output.png \
113
+ --method ai \
114
+ --no-refine
115
+ ```
116
+
117
+ **AI 模式 vs Floodfill 选型表**:
118
+
119
+ | 特征 | 选 floodfill | 选 ai |
120
+ | -------------------------------- | ------------ | ----- |
121
+ | 背景是纯色(绿、白、蓝) | 是 | — |
122
+ | 背景有复杂纹理/渐变/场景 | — | 是 |
123
+ | 角色有半透明部分(衣物、头发丝) | — | 是 |
124
+ | 需要快速批量处理 | 是 | — |
125
+ | 追求最高精度 | — | 是 |
126
+
127
+ ---
128
+
129
+ ## 3. segment — SAM3 语义分割
130
+
131
+ `segment` 调用后端 SAM3 模型,对图片中的对象进行精确语义分割,产出**蒙版文件**(mask)和**透明抠图**(rgba)。
132
+
133
+ **适用场景**:
134
+
135
+ - 需要精确 mask 文件供后续合成操作使用
136
+ - 从游戏截图中精确分离多个游戏元素
137
+ - 需要不规则形状的蒙版(圆形徽章、异形 UI 元素)
138
+
139
+ ### ⚠️ 模式选择决策(必读)
140
+
141
+ > **对网格/已知布局图(如 ASR state sheets、authoring sprite sheets),严禁使用纯 text prompt!**
142
+ >
143
+ > text prompt 在多元素密集图上歧义极大——SAM3 无法准确区分"整个 tile 方块"和"方块内的水果 icon"。
144
+
145
+ ```
146
+ 提取目标的位置已知或可计算?
147
+ ├─ 是(网格布局、规则排列)
148
+ │ → 优先 playcraft image crop(最可靠,零 AI 歧义)
149
+ │ → 次选 segment --boxes(需要精确蒙版时)
150
+
151
+ ├─ 位置大致可估、需要精确蒙版
152
+ │ → segment --boxes(用近似 bbox 框选)
153
+
154
+ └─ 位置完全未知、元素形状不规则
155
+ → segment --text(最后手段)
156
+ → prompt 必须极其具体,包含位置/颜色/上下文描述
157
+ ```
158
+
159
+ **常见错误示例**:
160
+
161
+ - ❌ `--text "apple tile icon"` → 可能只切出苹果水果,丢失 tile 方块底板
162
+ - ❌ `--text "panda character"` → 图上有 panda face tile + panda 角色,返回多个 instance
163
+ - ✅ `--boxes '[[50,50,450,450]]'` → 框选已知位置的完整元素
164
+ - ✅ `playcraft image crop --x 50 --y 50 --width 400 --height 400` → 零歧义直切
165
+
166
+ ### 文本提示模式(仅用于位置未知、元素分布不规则场景)
167
+
168
+ ```bash
169
+ # 用文字描述要提取的对象(仅适用于元素位置无法提前计算的场景)
170
+ playcraft image segment \
171
+ --input assets/images/screenshot.png \
172
+ --text "the main character" \
173
+ --output-dir assets/images/segment_output/
174
+
175
+ # 提取特定游戏元素
176
+ playcraft image segment \
177
+ --input assets/images/game_scene.png \
178
+ --text "the treasure chest" \
179
+ --output-dir /tmp/segment/
180
+ ```
181
+
182
+ **text prompt 最佳实践**:
183
+
184
+ - 描述要尽可能具体:加颜色、位置、完整性描述
185
+ - ✅ `"the complete rounded square tile with green apple in top-left area"`
186
+ - ❌ `"apple tile icon"`(歧义:是苹果本身?还是整个 tile 方块?)
187
+ - 返回多个 instance 时,不要盲目取 score 最高的——检查 bbox 尺寸是否合理
188
+
189
+ ### 框选模式(多对象精确分割)
190
+
191
+ ```bash
192
+ # --boxes 接受 JSON 数组,每个元素为 [x1, y1, x2, y2](左上角和右下角坐标)
193
+ playcraft image segment \
194
+ --input assets/images/game_scene.png \
195
+ --boxes '[[50, 100, 200, 300], [350, 150, 500, 400]]' \
196
+ --box-labels '["player", "enemy"]' \
197
+ --output-dir /tmp/segment/
198
+
199
+ # 单个框(无需 box-labels 时)
200
+ playcraft image segment \
201
+ --input assets/images/tile_sheet.png \
202
+ --boxes '[[0, 0, 128, 128]]' \
203
+ --output-dir /tmp/segment/
204
+ ```
205
+
206
+ ### 输出结构
207
+
208
+ `segment` 在 `--output-dir` 下生成:
209
+
210
+ ```
211
+ segment_output/
212
+ ├── 00_mask.png # 二值蒙版(白=前景,黑=背景)
213
+ ├── 00_rgba.png # 透明背景抠图(直接可用)
214
+ ├── 01_mask.png # 第二个对象的蒙版(若多框)
215
+ ├── 01_rgba.png # 第二个对象的透明抠图
216
+ └── segment-meta.json # 分割元数据(坐标、置信度等)
217
+ ```
218
+
219
+ ### 阈值调节(边缘精细度)
220
+
221
+ ```bash
222
+ # --threshold(默认 0.3):越低保留越多细节,但可能包含噪点
223
+ # 越高边缘越干净,但可能丢失细节(毛发、透明边缘)
224
+ playcraft image segment \
225
+ --input game_scene.png \
226
+ --text "the hero character" \
227
+ --threshold 0.2 \ # 较低:保留更多边缘细节
228
+ --output-dir /tmp/segment/
229
+
230
+ # --mask-threshold:后端蒙版生成阈值(高级参数)
231
+ playcraft image segment \
232
+ --input source.png \
233
+ --text "the dragon" \
234
+ --threshold 0.3 \
235
+ --mask-threshold 0.5 \
236
+ --output-dir /tmp/segment/
237
+ ```
238
+
239
+ ### 仅生成蒙版(不要 rgba)
240
+
241
+ ```bash
242
+ # --no-rgba:跳过 rgba 生成,只输出 mask(更快)
243
+ playcraft image segment \
244
+ --input source.png \
245
+ --text "the background elements" \
246
+ --no-rgba \
247
+ --output-dir /tmp/masks/
248
+ ```
249
+
250
+ ---
251
+
252
+ ## 4. 蒙版合成工作流
253
+
254
+ ### 工作流 A:换背景(最常用)
255
+
256
+ ```bash
257
+ # 1. 用 segment 提取角色(带透明背景)
258
+ playcraft image segment \
259
+ --input assets/images/character_with_bg.png \
260
+ --text "the game character" \
261
+ --output-dir /tmp/char_segment/
262
+ # → 产出 /tmp/char_segment/00_rgba.png
263
+
264
+ # 2. 用 overlay 把角色合成到新背景上
265
+ playcraft image overlay \
266
+ --base assets/images/bg/new_background.png \
267
+ --overlay /tmp/char_segment/00_rgba.png \
268
+ --output assets/images/character_on_new_bg.png \
269
+ --gravity center
270
+ ```
271
+
272
+ ### 工作流 B:多层合成(背景 + 角色 + UI)
273
+
274
+ ```bash
275
+ # 层1:基础背景
276
+ cp assets/images/bg/background.png /tmp/composite.png
277
+
278
+ # 层2:叠加角色(居中偏下)
279
+ playcraft image overlay \
280
+ --base /tmp/composite.png \
281
+ --overlay assets/images/character/character_transparent.png \
282
+ --output /tmp/composite.png \
283
+ --gravity south
284
+
285
+ # 层3:叠加 UI 层(顶部)
286
+ playcraft image overlay \
287
+ --base /tmp/composite.png \
288
+ --overlay assets/images/ui/hud_overlay.png \
289
+ --output assets/images/final_scene.png \
290
+ --gravity north
291
+ ```
292
+
293
+ ### 工作流 C:轮廓描边效果
294
+
295
+ 用蒙版制作发光轮廓描边:
296
+
297
+ ```bash
298
+ # 1. 提取蒙版
299
+ playcraft image segment \
300
+ --input assets/images/character.png \
301
+ --text "character" \
302
+ --output-dir /tmp/seg/
303
+
304
+ # 2. 把蒙版 tint 为描边颜色(金色)
305
+ playcraft image tint \
306
+ --input /tmp/seg/00_mask.png \
307
+ --output /tmp/outline_colored.png \
308
+ --color "#FFD700"
309
+
310
+ # 3. 扩大描边层(pad 向外扩 4px)
311
+ playcraft image pad \
312
+ --input /tmp/outline_colored.png \
313
+ --output /tmp/outline_padded.png \
314
+ --all 4
315
+
316
+ # 4. 叠回:描边层在底,原图在上
317
+ playcraft image overlay \
318
+ --base /tmp/outline_padded.png \
319
+ --overlay /tmp/seg/00_rgba.png \
320
+ --output assets/images/character_outlined.png \
321
+ --gravity center
322
+ ```
323
+
324
+ ### 工作流 D:批量替换素材背景
325
+
326
+ ```bash
327
+ # 对多张带绿幕背景的素材批量去背
328
+ for f in assets/images/raw/tile_*_greenscreen.png; do
329
+ name=$(basename "$f" _greenscreen.png)
330
+ playcraft image remove-background \
331
+ --input "$f" \
332
+ --output "assets/images/tiles/${name}.png" \
333
+ --method floodfill \
334
+ --tolerance 40
335
+ done
336
+ ```
337
+
338
+ ---
339
+
340
+ ## 5. 常见问题排查
341
+
342
+ ### 边缘有绿色/白色残留(floodfill)
343
+
344
+ ```bash
345
+ # 原因:tolerance 太低,部分背景像素未被删除
346
+ # 修复:适当提高 tolerance(每次 +10 尝试)
347
+ playcraft image remove-background \
348
+ --input source.png --output output.png \
349
+ --tolerance 50 # 从 30 提升到 50
350
+ ```
351
+
352
+ ### segment 分割到了错误的对象
353
+
354
+ ```bash
355
+ # 原因:文本提示不够精确
356
+ # 修复方案 1:更具体的描述
357
+ --text "the blue warrior character in the center" # 加颜色/位置描述
358
+
359
+ # 修复方案 2:改用框选模式,精确框出目标区域
360
+ --boxes '[[x1, y1, x2, y2]]' # 先用 playcraft image info 确认图片尺寸
361
+ ```
362
+
363
+ ### rgba 输出有半透明噪点
364
+
365
+ ```bash
366
+ # 原因:threshold 太低
367
+ # 修复:提高 threshold(从 0.3 到 0.5)
368
+ playcraft image segment \
369
+ --input source.png \
370
+ --text "target object" \
371
+ --threshold 0.5 \
372
+ --output-dir /tmp/seg/
373
+ ```
@@ -0,0 +1,212 @@
1
+ ---
2
+ name: playcraft-research
3
+ description: PlayCraft 网络研究协议。当本地 Skill 库不足以覆盖需求时触发——包括遇到陌生玩法机制、不熟悉的美术风格、特定音频类型、算法实现参考、需要图片参考等场景。使用 playcraft tools research / fetch-url / search-image 命令(统一鉴权,无需配置额外 key)直接搜索网络,将研究成果融入活 DAG。
4
+ triggers: 本地skill不够,没有现成skill,找不到参考,不了解这个风格,不熟悉这个玩法,陌生机制,需要调研,搜索参考,互联网搜索,研究,需要图片参考,找参考图,视觉参考
5
+ ---
6
+
7
+ # PlayCraft 网络研究协议
8
+
9
+ ## 可用工具(统一鉴权,无需额外配置)
10
+
11
+ 使用 PlayCraft CLI 提供的三个搜索工具:
12
+
13
+ ```bash
14
+ # 文本研究 — Gemini + Google Search grounding,返回综合答案 + 引用来源
15
+ playcraft tools research --query "<问题>" [--focus <领域>] [--json]
16
+
17
+ # 读取 URL — Gemini 理解指定页面内容,返回结构化摘要
18
+ playcraft tools fetch-url --url "<URL>" [--query "<具体问题>"] [--json]
19
+
20
+ # 图片搜索 — Unsplash / Pexels 高质量图库,返回可直接用于 --reference-image 的 URL
21
+ playcraft tools search-image --query "<关键词(建议英文)>" [--source unsplash|pexels|auto] [--count 6] [--orientation landscape|portrait|square] [--json]
22
+ ```
23
+
24
+ `--focus` 参数(research 命令):`gameplay` | `visual` | `audio` | `code` | `compliance`
25
+
26
+ ---
27
+
28
+ ## 何时使用网络研究
29
+
30
+ **先本地,再网络**。网络研究是本地 Skill 发现的补充,不是替代。
31
+
32
+ | 场景 | 应做什么 |
33
+ |---|---|
34
+ | `playcraft skills match` 完整匹配 | 直接用,无需研究 |
35
+ | 部分匹配,缺少细节 | 用本地 Skill,补充网络研究缺失部分 |
36
+ | 完全无匹配 | **触发 `research` 文本研究** |
37
+ | 遇到陌生专业名词 | **触发 `research` 文本研究** |
38
+ | 需要最新数据(2024+ 最佳实践) | **触发 `research` 文本研究** |
39
+ | 需要视觉参考图(Phase 1 概念图 / 风格探索) | **触发 `search-image` 图片搜索** |
40
+ | 生成后不满意,想用参考图引导风格 | **触发 `search-image` → 结果 URL 直接传 `--reference-image`** |
41
+
42
+ ---
43
+
44
+ ## 各角色研究标准流程
45
+
46
+ ### PM — 玩法机制调研
47
+
48
+ ```bash
49
+ # 理解陌生的玩法类型
50
+ playcraft tools research \
51
+ --query "match-3 mobile game level design best practices difficulty curve" \
52
+ --focus gameplay --json
53
+
54
+ # 了解可玩广告设计原则
55
+ playcraft tools research \
56
+ --query "playable ad game mechanics player retention 15 seconds hook" \
57
+ --focus gameplay --json
58
+
59
+ # 读取具体设计文章
60
+ playcraft tools fetch-url \
61
+ --url "https://www.gamedeveloper.com/design/..." \
62
+ --query "what are the key level design parameters"
63
+ ```
64
+
65
+ ### Designer — 视觉/音频风格调研
66
+
67
+ ```bash
68
+ # 搜索艺术风格生成参数
69
+ playcraft tools research \
70
+ --query "pixel art 8-bit game sprite limited color palette generation prompt keywords" \
71
+ --focus visual --json
72
+
73
+ # 读取调色板数据库
74
+ playcraft tools fetch-url \
75
+ --url "https://lospec.com/palette-list/..." \
76
+ --query "what are the exact hex colors and style characteristics"
77
+
78
+ # 搜索音频风格
79
+ playcraft tools research \
80
+ --query "chiptune BGM game music BPM range instruments characteristics" \
81
+ --focus audio --json
82
+
83
+ # ── 图片搜索(新增)─────────────────────────────────────────────────────────
84
+
85
+ # 搜索视觉参考图(用于 Phase 1 风格探索)
86
+ playcraft tools search-image \
87
+ --query "pixel art 8-bit forest game background" \
88
+ --source pexels --orientation portrait --json
89
+
90
+ # 搜索元素参考图(用于指导具体 asset 生成)
91
+ playcraft tools search-image \
92
+ --query "cute cartoon fruit character icon game UI" \
93
+ --count 4 --json
94
+
95
+ # 将搜索结果 URL 直接用作参考图(无需先下载)
96
+ playcraft tools generate-image \
97
+ --prompt "pixel art forest background, 8-bit style, limited color palette" \
98
+ --reference-image "https://images.unsplash.com/photo-xxxxx" \
99
+ --output assets/images/bg/background.png \
100
+ --aspect-ratio 9:16
101
+ ```
102
+
103
+ > **关键提示**:`search-image` 返回的 `downloadUrl` 字段可直接传给 `--reference-image`,CLI 会自动下载,无需手动保存。`--json` 模式返回结构化列表,方便批量选用。
104
+
105
+ ### Developer — 算法/技术实现调研
106
+
107
+ ```bash
108
+ # 搜索具体实现
109
+ playcraft tools research \
110
+ --query "A* pathfinding javascript tile map Phaser 3 implementation performance" \
111
+ --focus code --json
112
+
113
+ # 读取官方文档
114
+ playcraft tools fetch-url \
115
+ --url "https://phaser.io/docs/3.60.0/Phaser.Physics.html" \
116
+ --query "how does StaticGroup work with tilemap collision"
117
+
118
+ # 搜索性能优化
119
+ playcraft tools research \
120
+ --query "Phaser 3 60fps mobile performance sprite batch rendering optimization" \
121
+ --focus code --json
122
+ ```
123
+
124
+ ### Reviewer — 质量标准调研
125
+
126
+ ```bash
127
+ # 平台合规要求
128
+ playcraft tools research \
129
+ --query "Google Ads playable ad HTML5 policy requirements file size 2026" \
130
+ --focus compliance --json
131
+
132
+ # 读取最新政策文档
133
+ playcraft tools fetch-url \
134
+ --url "https://support.google.com/google-ads/answer/..." \
135
+ --query "what are the technical requirements for playable ads"
136
+
137
+ # 性能基准
138
+ playcraft tools research \
139
+ --query "web game 60fps performance budget mobile device HTML5 2025" \
140
+ --focus compliance --json
141
+ ```
142
+
143
+ ---
144
+
145
+ ## 研究结果融入活 DAG
146
+
147
+ 研究结果**必须写入 `atom-plan.md`**,否则其他 Agent 无法从中受益。
148
+
149
+ ### 写入格式
150
+
151
+ ```markdown
152
+ <!-- 在对应 atom 的 Asset/Impl Skill Context 下 -->
153
+
154
+ ### {{atom_id}} — {{slot_name}}
155
+ - **本地 Skill**:无匹配(playcraft skills match 返回 0 结果)
156
+ - **文本研究结论**(若执行了 research / fetch-url):
157
+ - 命令:`playcraft tools research --query "..." --focus visual --json`
158
+ - 核心发现:{{1-3 句话,具体且可操作}}
159
+ - 关键参数:{{数值、关键词、具体配置}}
160
+ - 引用来源:{{URL}}
161
+ - **图片参考**(若执行了 search-image):
162
+ - 命令:`playcraft tools search-image --query "..." --json`
163
+ - 选用图片:{{description}} — {{downloadUrl}}
164
+ - 使用方式:作为 `--reference-image` 传入生成命令
165
+ - **实现/生成决策**:{{基于研究的具体方案}}
166
+ - **候选新 Skill**:`{{建议名称}}.{{bundleType}}` — {{为什么值得沉淀}}
167
+ ```
168
+
169
+ ### 示例:Designer 研究波普艺术 + 搜图参考
170
+
171
+ ```markdown
172
+ ### bg_atom — 背景图层
173
+ - 本地 Skill:无匹配
174
+ - 文本研究结论:
175
+ - 命令:`playcraft tools research --query "pop art game sprite color palette" --focus visual --json`
176
+ - 核心发现:波普艺术使用 4-6 色高饱和调色板,粗黑轮廓线,网点图案填充
177
+ - 关键参数:饱和度 >80%,互补色对比,轮廓线 3-5px
178
+ - 引用来源:lospec.com/palette-list/pop-art
179
+ - 图片参考:
180
+ - 命令:`playcraft tools search-image --query "pop art colorful bold graphic background" --source unsplash --json`
181
+ - 选用图片:Bold geometric pop art composition — https://images.unsplash.com/photo-xxxxx
182
+ - 使用方式:`--reference-image "https://images.unsplash.com/photo-xxxxx"`
183
+ - 生成决策:
184
+ - prompt: "pop art style, bold black outlines, halftone dots, vivid colors, {{element}}"
185
+ - style: "vibrant, graphic, flat colors, 1960s comic style"
186
+ - reference: 上方 Unsplash URL(CLI 自动下载)
187
+ - 候选新 Skill:`pop_art_sprite.aiimage`
188
+ ```
189
+
190
+ ---
191
+
192
+ ## "候选新 Skill" 贡献循环
193
+
194
+ 每次网络研究形成可复用方案,在 `atom-plan.md` 的 **DAG Revisions** 标注:
195
+
196
+ ```markdown
197
+ ### Revision N — {{Agent}} (propose-skill)
198
+ - **atomId**: {{atom_id}}
199
+ - **reason**: 本地无 Skill,通过网络研究形成可复用方案
200
+ - **change**: 建议创建:`{{skill_name}}.{{bundleType}}` — {{描述}},来源:{{URL}}
201
+ ```
202
+
203
+ ---
204
+
205
+ ## 研究质量检查
206
+
207
+ | 检查项 | 要求 |
208
+ |---|---|
209
+ | **来源可信度** | 优先官方文档、行业权威;引用来源来自 `--json` 输出的 `citations` 字段 |
210
+ | **信息时效** | 优先 2024-2026 年内容(在 query 中加年份可提高准确性) |
211
+ | **可操作性** | 结论必须直接用于生成参数或代码,不能泛泛而谈 |
212
+ | **与 StyleDirection 一致** | 视觉研究须与 design-brief 的 StyleDirection 对齐 |