@playcraft/cli 0.0.41 → 0.0.42

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 (49) hide show
  1. package/dist/commands/tools-generation.js +2 -4
  2. package/dist/commands/tools-utils.js +19 -0
  3. package/dist/utils/version-checker.js +8 -11
  4. package/package.json +3 -3
  5. package/project-template/.claude/agents/designer.md +12 -8
  6. package/project-template/.claude/agents/developer.md +53 -62
  7. package/project-template/.claude/agents/refs/README.md +21 -15
  8. package/project-template/.claude/agents/refs/designer-deliverable-spec.md +24 -0
  9. package/project-template/.claude/agents/refs/designer-master-composite-recipes.md +20 -28
  10. package/project-template/.claude/agents/refs/developer-phase1-flow.md +81 -156
  11. package/project-template/.claude/agents/refs/pm-workflow-detail.md +6 -0
  12. package/project-template/.claude/agents/refs/reviewer-convergence-eval.md +130 -0
  13. package/project-template/.claude/agents/refs/reviewer-six-dimension-eval.md +4 -284
  14. package/project-template/.claude/agents/refs/ta-atlas-deliverable-standard.md +27 -6
  15. package/project-template/.claude/agents/refs/ta-pipeline-cookbook.md +433 -24
  16. package/project-template/.claude/agents/reviewer.md +62 -38
  17. package/project-template/.claude/agents/technical-artist.md +36 -25
  18. package/project-template/.claude/hooks/README.md +9 -1
  19. package/project-template/.claude/hooks/validate-workflow-stop.mjs +86 -1
  20. package/project-template/.claude/settings.json +4 -0
  21. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +65 -15
  22. package/project-template/.claude/skills/playcraft-storyboard/SKILL.md +26 -7
  23. package/project-template/.claude/skills/playcraft-workflow/SKILL.md +104 -15
  24. package/project-template/.claude/skills/playwright-cli/SKILL.md +390 -0
  25. package/project-template/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  26. package/project-template/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  27. package/project-template/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  28. package/project-template/.claude/skills/playwright-cli/references/running-code.md +240 -0
  29. package/project-template/.claude/skills/playwright-cli/references/session-management.md +226 -0
  30. package/project-template/.claude/skills/playwright-cli/references/spec-driven-testing.md +312 -0
  31. package/project-template/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  32. package/project-template/.claude/skills/playwright-cli/references/test-generation.md +138 -0
  33. package/project-template/.claude/skills/playwright-cli/references/tracing.md +142 -0
  34. package/project-template/.claude/skills/playwright-cli/references/video-recording.md +157 -0
  35. package/project-template/.cursor/rules/playcraft-orchestrator.mdc +74 -24
  36. package/project-template/.cursor/rules/playcraft-subagent-boundary.mdc +1 -1
  37. package/project-template/CLAUDE.md +99 -59
  38. package/project-template/docs/team/agent-conduct.md +42 -26
  39. package/project-template/docs/team/atom-plan-format.md +33 -2
  40. package/project-template/docs/team/collaboration.md +57 -48
  41. package/project-template/docs/team/workflow-changelog.md +28 -14
  42. package/project-template/docs/team/workflow-consistency-checklist.md +12 -0
  43. package/project-template/templates/atom-plan.template.md +35 -3
  44. package/project-template/templates/designer-log.template.md +16 -0
  45. package/project-template/templates/developer-log.template.md +95 -101
  46. package/project-template/templates/layout-spec.template.md +14 -0
  47. package/project-template/templates/project-state.template.md +51 -33
  48. package/project-template/templates/review-report.template.md +76 -151
  49. package/project-template/templates/ta-log.template.md +138 -0
@@ -34,6 +34,48 @@ ls assets/audio/ # Designer Ph.2 raw audio (if present)
34
34
 
35
35
  ---
36
36
 
37
+ ## Step 0 Pre: mediaGroups Asset Reuse (mandatory, before any generation)
38
+
39
+ > **Purpose:** `atom-plan.json` → `skillsMatch.mediaGroups` contains pre-matched reusable assets from the skills library. These assets have already been validated by PM's `playcraft skills match`. **TA MUST check and link available media assets before generating anything from scratch.**
40
+
41
+ ```bash
42
+ # 1. Read mediaGroups from atom-plan.json
43
+ cat docs/atom-plan.json | jq '.skillsMatch.mediaGroups'
44
+ ```
45
+
46
+ For each mediaGroup entry:
47
+
48
+ 1. **Check if the mediaGroup matches a TA-assigned atom** — compare `atomId` / description with atoms in your production list
49
+ 2. **If matched → link the asset directly**:
50
+
51
+ ```bash
52
+ # Link the pre-matched asset to the contract path
53
+ playcraft skills link --atom <atomId> --output <assetMapping_path>
54
+ # OR manually copy from skills library:
55
+ cp $(playcraft skills read <mediaGroup_atomId> --path) <assetMapping_path>
56
+ ```
57
+
58
+ 3. **Post-process the linked asset** (resize, convert, transparency) — linked assets still need format compliance
59
+ 4. **Update atom status** immediately:
60
+
61
+ ```json
62
+ { "atomId": "<id>", "status": "done", "actualOutput": "<assetMapping_path>" }
63
+ ```
64
+
65
+ 5. **If NOT matched or quality insufficient** — proceed to Step 0 Skill Discovery + Step 1 generation as normal; document reason in `dagRevisions`:
66
+
67
+ ```markdown
68
+ ### mediaGroup Skip — {{atomId}}
69
+
70
+ - **mediaGroup atomId**: {{mg_atomId}}
71
+ - **reason**: {{quality issue / style mismatch / wrong dimensions}}
72
+ - **action**: generate from scratch using Step 1 pipeline
73
+ ```
74
+
75
+ **STOP gate**: `ta-log.md` must contain a "mediaGroups Reuse" section listing each mediaGroup's disposition (linked / skipped + reason) before proceeding to generation.
76
+
77
+ ---
78
+
37
79
  ## Step 0 (Skill Discovery) → Enrich TA Skill Context
38
80
 
39
81
  Before executing any atom, run two rounds of Skill Discovery:
@@ -113,6 +155,47 @@ If `skillRef` is `—` or empty for an atom, skip Part B for that atom and rely
113
155
 
114
156
  ---
115
157
 
158
+ ### Part C — Mandatory Skill Preflight(管线 Skill 读取)
159
+
160
+ > **Purpose:** TA 在生产前必须阅读相关的 playcraft 管线 Skill,确保使用平台既定最佳实践而非"凭经验自由发挥"。
161
+
162
+ **必读 Skills(按产出类型):**
163
+
164
+ | 产出类型 | 必读 Skill | 不读的后果 |
165
+ | --------------- | ------------------------------------------------------------------------ | ---------------------------- |
166
+ | 任何图片生成 | `playcraft-image-generation`(§3 背景决策树、模型选择、reference-image) | 所有透明度问题 |
167
+ | 需要透明的素材 | `playcraft-masking`(remove-background / segment / decompose-layers) | 白底、黑块、色残留 |
168
+ | 精灵图 / Atlas | `playcraft-sprite-generation`(单帧生成→合并,非 AI 直出网格) | 帧尺寸不均、无 alpha、帧出血 |
169
+ | VFX 动画帧 | `playcraft-vfx-animation` | 发光效果黑块 |
170
+ | 批量 (>5 元素) | `playcraft-batch-pipeline` | 风格不一致、参数丢失 |
171
+ | 文字 / 数字渲染 | `playcraft-text-rendering`(绿幕策略 + 描边保护) | 文字白底、数字变绿 |
172
+ | 风格一致性验证 | `playcraft-style-qa` | 风格偏离 MC / ASR |
173
+
174
+ **执行方式:**
175
+
176
+ ```bash
177
+ # Read each relevant skill before production
178
+ cat .claude/skills/playcraft-image-generation/SKILL.md
179
+ cat .claude/skills/playcraft-masking/SKILL.md
180
+ cat .claude/skills/playcraft-sprite-generation/SKILL.md
181
+ # ... additional skills per atom type
182
+ ```
183
+
184
+ **STOP 门槛**:`logs/ta-log.md` 的 **§ Skill Preflight** 必须列出每个已读 Skill + 关键决策摘要(一行)。未填则不得执行 Step 1 批量生成。
185
+
186
+ ```markdown
187
+ ## Skill Preflight
188
+
189
+ | Skill | 已读 | 关键决策摘要 |
190
+ | --------------------------- | ---- | ----------------------------------------------------- |
191
+ | playcraft-image-generation | ✅ | 使用 gpt-image-2;所有透明素材 chroma key + ref-image |
192
+ | playcraft-masking | ✅ | floodfill 优先 (tolerance=25);复杂形状用 segment |
193
+ | playcraft-sprite-generation | ✅ | 单帧生成→去背→resize→合并;禁止 AI 直出网格 |
194
+ | playcraft-text-rendering | ✅ | 文字必须蓝幕;描边保护 + tolerance 降到 20 |
195
+ ```
196
+
197
+ ---
198
+
116
199
  ## Step 1 (Asset Completion)
117
200
 
118
201
  > **生图前请先阅读 `playcraft-image-generation` Skill**(包含模型选择决策树、reference-image 工作流和错误恢复策略)。
@@ -259,32 +342,134 @@ node ta-workspace/scripts/gen-<name>-variants.mjs
259
342
 
260
343
  ### Step 4: Process Assets(去背景 + resize + 验证)
261
344
 
262
- > **先判断素材类型,再决定是否需要去背景**(参见 playcraft-image-generation Skill 4.5 节背景处理决策树)
345
+ > **必须先查阅 Step 0e Transparency Classification 表**,按 `bgStrategy` 列执行。不要凭直觉判断是否需要去背景。
346
+
347
+ #### 处理管线总览
348
+
349
+ ```
350
+ 按 bgStrategy 分流:
351
+
352
+ ├─ opaque → 直接 resize(skipRemoveBg = true)
353
+
354
+ ├─ full-coverage → resize → 全覆盖验证(四角四边)
355
+
356
+ ├─ greenscreen / bluescreen / magenta → 完整去背管线:
357
+ │ 1. playcraft image remove-background --method floodfill --tolerance 25
358
+ │ 2. playcraft image info --json → 确认 channels=4
359
+ │ 3. playcraft image overlay (深色背景验证)
360
+ │ 4. 验证失败? → 回退工具链(见下方)
361
+ │ 5. playcraft image resize → playcraft image convert --format webp
362
+
363
+ └─ segment → 提取管线:
364
+ 1. playcraft image crop (已知坐标) 或 segment --boxes (需精确蒙版)
365
+ 2. 若整图分层 → playcraft image decompose-layers
366
+ 3. playcraft image info --json → 确认 channels=4
367
+ 4. playcraft image overlay (深色背景验证)
368
+ 5. playcraft image resize → playcraft image convert --format webp
369
+ ```
263
370
 
264
- **卡牌 / 棋子 / UI 面板(矩形本体,不需要透明背景)**:
371
+ #### bgStrategy = opaque(卡牌/棋子/矩形实体)
265
372
 
266
373
  ```bash
267
- # 直接 resize,不做去背景(白色牌面就是牌的一部分!)
268
374
  playcraft image resize --input <file>.png --output <file>.png --width <W> --height <H> --fit contain
269
375
  ```
270
376
 
271
377
  批量处理使用 `process-batch.template.mjs` 并设置 `CONFIG.skipRemoveBg = true`。
272
378
 
273
- **独立元素(角色/道具/图标,需要透明背景)→ 绿幕策略**:
379
+ #### bgStrategy = greenscreen / bluescreen / magenta(需要透明的元素)
380
+
381
+ > ⚠️ **不要跳过去背景步骤!** 按 Step 0e 表中的 bgStrategy 选用正确的工具。
382
+
383
+ **Step 4a — 去背景(第一选择:floodfill)**:
384
+
385
+ ```bash
386
+ playcraft image remove-background \
387
+ --input <raw_asset>.png \
388
+ --output <processed_asset>.png \
389
+ --method floodfill \
390
+ --tolerance 25
391
+ ```
392
+
393
+ **Step 4b — 验证 alpha 通道**:
394
+
395
+ ```bash
396
+ playcraft image info --input <processed_asset>.png --json
397
+ # 确认: channels == 4(若 channels == 3,说明输出格式错误,确保 .png 后缀)
398
+ ```
399
+
400
+ **Step 4c — 深色背景渲染验证**:
401
+
402
+ ```bash
403
+ playcraft image overlay \
404
+ --base ta-workspace/tmp/dark_verify_bg.png \
405
+ --overlay <processed_asset>.png \
406
+ --output ta-workspace/tmp/verify_<name>.png \
407
+ --gravity center
408
+ # 目视确认:边缘干净、无色幕残留、无白色/黑色伪影
409
+ ```
410
+
411
+ **Step 4d — 验证失败时的回退工具链**:
412
+
413
+ | 验证失败现象 | 根因 | 回退工具 |
414
+ | -------------------------- | ------------------------------ | -------------------------------------------------------------------------- |
415
+ | 色幕残留少量(边缘毛刺) | tolerance 偏低 | `remove-background --tolerance 40`(+15 递增重试) |
416
+ | 色幕残留明显(大面积色块) | 素材色与色幕撞色 | **spec-gap** → PM 修改 bgStrategy → 用正确色幕重新生成 |
417
+ | 复杂边缘/不规则形状 | floodfill 无法处理复杂轮廓 | `playcraft image segment --boxes '[[x1,y1,x2,y2]]'`(精确框选,SAM3 分割) |
418
+ | 毛发/半透明/渐变边缘 | floodfill 是硬边缘算法 | `playcraft image remove-background --method ai`(AI 语义去背景) |
419
+ | 去背过度(元素被挖掉) | tolerance 过高或素材含近色区域 | 降低 tolerance 到 15-20 → 仍不行则 `segment --boxes` |
420
+ | VFX 帧出现黑色不透明块 | 发光/粒子未用色幕生成 | 用蓝幕重新生成每一帧,然后 `remove-background` |
421
+ | 白底/白边残留 | 未使用色幕策略直接白底生成 | 用正确色幕重新生成(不要试图在白底上去背景) |
422
+ | 背景图四角褪色/白边 | prompt 未加 edge-to-edge | 重新生成,prompt 加 `"full bleed, edge to edge, no vignette"` |
423
+
424
+ #### bgStrategy = segment(从 MC/ASR 提取)
425
+
426
+ 使用 PlayCraft CLI 提供的分割工具链提取,不做 AI 重新生成:
274
427
 
275
- 生图时 prompt 末尾加 `"on solid bright green #00FF00 background, isolated, centered"`(当前所有模型 ALPHA = no,无原生透明输出),然后:
428
+ ```bash
429
+ # 方法 1: crop 直切(ASR 已知网格布局,最可靠)
430
+ playcraft image crop \
431
+ --input assets/images/reference/element_state_sheet_X.png \
432
+ --x <x> --y <y> --width <w> --height <h> \
433
+ --output <extracted>.png
434
+
435
+ # 方法 2: SAM3 语义分割(需精确蒙版时)
436
+ playcraft image segment \
437
+ --input assets/images/storyboard/master_composite.png \
438
+ --boxes '[[x1,y1,x2,y2]]' \
439
+ --output-dir ta-workspace/tmp/seg/
440
+ # → 使用 00_rgba.png(已带透明通道)
441
+
442
+ # 方法 3: 整图分层(需要从 MC 拆出多个层)
443
+ playcraft image decompose-layers \
444
+ --input assets/images/storyboard/master_composite.png \
445
+ --output-dir ta-workspace/tmp/layers \
446
+ --num-layers 4
447
+
448
+ # 提取后仍需深色背景验证
449
+ playcraft image overlay \
450
+ --base ta-workspace/tmp/dark_verify_bg.png \
451
+ --overlay <extracted>.png \
452
+ --output ta-workspace/tmp/verify_<name>.png \
453
+ --gravity center
454
+ ```
455
+
456
+ #### bgStrategy = full-coverage(全屏背景)
276
457
 
277
458
  ```bash
278
- # 绿幕抠图(tolerance=25 对绿色效果最好)
279
- playcraft image remove-background --input in.png --output out.png --tolerance 25
459
+ playcraft image info --input <bg_asset>.png --json
460
+ # 验证:尺寸精确匹配 layout-spec 要求
461
+ # 目视检查:四角四边颜色一致,无褪色/渐变/白色边缘/暗角
280
462
  ```
281
463
 
282
- **批量处理 → ta-workspace 脚本模板**:
464
+ #### 批量处理
283
465
 
284
466
  ```bash
285
467
  cp .claude/skills/playcraft-image-generation/reference/process-batch.template.mjs \
286
468
  ta-workspace/scripts/process-<name>.mjs
287
- # 修改 CONFIG(特别是 skipRemoveBg 和 removeBgTolerance)后运行
469
+ # 修改 CONFIG
470
+ # skipRemoveBg = true (bgStrategy=opaque/full-coverage)
471
+ # skipRemoveBg = false (bgStrategy=greenscreen/bluescreen/magenta)
472
+ # removeBgTolerance = 25
288
473
  node ta-workspace/scripts/process-<name>.mjs
289
474
  ```
290
475
 
@@ -593,31 +778,239 @@ ASR 是已知网格布局?(ui_state_sheet / element_state_sheet,行列分
593
778
 
594
779
  Read designer-log Style Intent Notes → write interpretation table to `ta-log.md` → confidence low = blocked, medium = proceed with caution, high = proceed.
595
780
 
781
+ ### Step 0d: Production Plan (mandatory, before any generation)
782
+
783
+ > **Purpose:** Converge on full asset coverage and pipeline order before bulk production.
784
+
785
+ Write `logs/ta-log.md` § **Production Plan** with:
786
+
787
+ 1. **Coverage Plan** — one row per `layout-spec` `assetMapping` entry (contract path, pipeline type, reference source, priority)
788
+ 2. **Atlas Assembly Plan** — one row per atlas group from layout-spec grouping table (output `.webp` + `.json`, frameIds, grid layout)
789
+ 3. **Pipeline Order** — numbered steps (Extract → Complete → Process → Assemble → Verify)
790
+ 4. **Risk Checklist** — all items checked `[x]`
791
+
792
+ **Rules:**
793
+
794
+ - Coverage Plan row count must equal `assetMapping` entry count (no gaps)
795
+ - Atlas groups must match layout-spec § atlas grouping table
796
+ - **MUST NOT** start Step 1 bulk generation until Risk Checklist is fully checked
797
+ - `validate-workflow-stop.mjs` blocks STOP if Plan is incomplete
798
+
799
+ ---
800
+
801
+ ### Step 0e: Asset Transparency Classification (mandatory, before any generation)
802
+
803
+ > **Purpose:** 根据 `layout-spec.md` 的 `assetMapping` 路径约定 + 元素色彩分析,自动推导每个资产的透明度需求和色幕策略,确定完整的处理管线。**此步骤在 Production Plan 完成后、Step 1 批量生成前执行。**
804
+
805
+ **根因认知**:当前所有 AI 模型均不支持原生透明 PNG(`ALPHA = no`)。不做透明度处理 → 所有素材"生成就完事" → UI 叠加元素白底、VFX 黑块、HUD 数字白底、图标白底等系统性问题。**PlayCraft CLI 提供了完整的透明度工具链(`remove-background` / `segment` / `decompose-layers`),TA 必须显式使用。**
806
+
807
+ #### 1. 从路径约定推导 needsAlpha
808
+
809
+ 遍历 `layout-spec.md` 的 `assetMapping`,根据**路径目录**自动判断每个资产是否需要透明背景:
810
+
811
+ ```
812
+ assetMapping 路径所在目录?
813
+
814
+ ├─ assets/images/bg/ → needsAlpha = false(全屏背景,不透明)
815
+ ├─ assets/images/ui/ → needsAlpha = true (UI 叠加层,必须透明)
816
+ ├─ assets/images/txt/ → needsAlpha = true (文字图片,必须透明)
817
+ ├─ assets/images/vfx/ → needsAlpha = true (特效精灵图,必须透明)
818
+ ├─ assets/images/tiles/ → needsAlpha = true (默认;除非是卡牌/棋子矩形实体)
819
+ ├─ assets/audio/ → N/A(非图片)
820
+ └─ 其他路径 → 按素材用途判断:叠加在其他图层上 = true,独立全屏 = false
821
+ ```
822
+
823
+ **卡牌/棋子等矩形实体例外**:虽然路径在 `tiles/`,但白色牌面是资产本体的一部分,不需要透明。TA 根据 `design-brief` 的 Style Direction + `designer-log` 的样本判断。
824
+
825
+ #### 2. 从元素色彩推导 bgStrategy(色幕选型)
826
+
827
+ 对每个 `needsAlpha = true` 的资产,根据元素主色调选择色幕颜色。色调信息来源:
828
+
829
+ - `layout-spec.md` 的 Color Palette(elementId → hex color)
830
+ - `design-brief.md` 的 Style Direction(整体色温描述)
831
+ - `designer-log.md` 的样本(实际视觉参考)
832
+
833
+ **色幕选型矩阵**:
834
+
835
+ | 元素主色调 | ❌ 禁用色幕 | ✅ 推荐色幕 | 原因 |
836
+ | --------------------- | ------------ | ---------------- | ---------------------------------------------------- |
837
+ | 金色/黄色/橙色/琥珀色 | 绿幕 #00FF00 | **蓝幕 #0000FF** | 金色与绿色色相接近(黄绿区),floodfill 残留绿色边缘 |
838
+ | 绿色/翠绿/青色 | 绿幕 #00FF00 | **蓝幕 #0000FF** | 同色系,floodfill 无法区分边界 |
839
+ | 蓝色/靛蓝/紫色 | 蓝幕 #0000FF | **绿幕 #00FF00** | 同色系冲突 |
840
+ | 红色/粉色/白色/黑色 | — | 绿幕或蓝幕均可 | 与两者色相距离都大 |
841
+ | 多色/彩虹 | — | **品红 #FF00FF** | 品红在自然素材中最少出现(最后手段) |
842
+
843
+ **特殊规则**(不按元素色彩,按资产类型固定):
844
+
845
+ | 资产类型 | 固定色幕 | 原因 |
846
+ | ---------------------- | ---------------- | ---------------------------------------------------- |
847
+ | VFX 发光/粒子/选中高亮 | **蓝幕 #0000FF** | VFX 普遍含暖色调(金色火焰、橙色爆炸),绿幕必出残留 |
848
+ | 文字/数字图片 | **蓝幕 #0000FF** | 文字常为金色/白色/浅色,绿幕边缘污染 |
849
+ | 全屏背景 | N/A(不去背景) | prompt 加 `"full bleed, edge to edge, no vignette"` |
850
+ | 矩形实体(卡牌/棋子) | N/A(不去背景) | 白底是资产本身,skipRemoveBg = true |
851
+
852
+ #### 3. 填写 Transparency Classification 表
853
+
854
+ ```markdown
855
+ ## Transparency Classification
856
+
857
+ | assetMapping path | needsAlpha | bgStrategy | 去背工具(第一选择) | 回退工具 | 验证方法 | 验证结果 |
858
+ | ----------------------------- | ---------- | ------------- | ------------------------------------- | ------------------------------------------- | -------------------- | -------- |
859
+ | assets/images/bg/bg_main.webp | false | full-coverage | N/A | N/A | 边缘全覆盖检查 | ❓ |
860
+ | assets/images/ui/btn_cta.webp | true | greenscreen | `remove-background --floodfill -t 25` | `segment --boxes` / `remove-bg --method ai` | 深色背景 overlay | ❓ |
861
+ | assets/images/ui/digits.webp | true | bluescreen | `remove-background --floodfill -t 25` | `segment --boxes` / `remove-bg --method ai` | 深色背景 overlay | ❓ |
862
+ | assets/images/vfx/glow.webp | true | bluescreen | `remove-background --floodfill -t 25` | `segment --boxes` | 逐帧深色背景 overlay | ❓ |
863
+ | assets/images/tiles/tile.webp | true | greenscreen | `remove-background --floodfill -t 25` | `segment --boxes` / `remove-bg --method ai` | 深色背景 overlay | ❓ |
864
+ | assets/images/txt/title.webp | true | bluescreen | `remove-background --floodfill -t 25` | `remove-bg --method ai` | 深色背景 overlay | ❓ |
865
+ ```
866
+
867
+ #### 4. 去背工具链(按 bgStrategy 执行)
868
+
869
+ > **PlayCraft CLI 提供了完整的透明度处理工具链,TA 必须按决策树显式使用,不能跳过去背景步骤。**
870
+
871
+ | bgStrategy | 生成 prompt 后缀 | 第一选择去背工具 | 回退工具(第一选择效果不好时) |
872
+ | ------------- | ------------------------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- |
873
+ | greenscreen | `"on solid bright green #00FF00 background, isolated, centered"` | `playcraft image remove-background --tolerance 25` | `playcraft image segment --boxes` 或 `--method ai` |
874
+ | bluescreen | `"on solid bright blue #0000FF background, isolated, centered"` | `playcraft image remove-background --tolerance 25` | `playcraft image segment --boxes` 或 `--method ai` |
875
+ | magenta | `"on solid bright magenta #FF00FF background, isolated, centered"` | `playcraft image remove-background --tolerance 20` | `playcraft image remove-background --method ai` |
876
+ | extract | 无特殊后缀(从 MC/ASR 提取) | `playcraft image crop` 或 `segment --boxes` | `playcraft image decompose-layers`(整图分层) |
877
+ | full-coverage | `"full scene, full bleed, edge to edge, no vignette, no fade"` | N/A(不去背景) | N/A |
878
+ | opaque | `"flat 2D, no shadow, no 3D effect, clean edges, white background"` | N/A(不去背景) | N/A |
879
+
880
+ **工具选型决策树**(TA 必须按此执行,不可跳步):
881
+
882
+ ```
883
+ needsAlpha = true?
884
+ ├─ 是 → 按色幕选型矩阵确定色幕颜色
885
+ │ → Step A: 生成时 prompt 加色幕后缀
886
+ │ → Step B: playcraft image remove-background --method floodfill --tolerance 25
887
+ │ → Step C: playcraft image info --json → channels == 4?
888
+ │ ├─ channels=4 → Step D: 深色背景 overlay 验证
889
+ │ │ ├─ 通过 → ✅ 记录结果
890
+ │ │ └─ 边缘有残留 → 回退工具链:
891
+ │ │ ├─ 纯色残留少量 → 调高 tolerance (25→40→60) 重试
892
+ │ │ ├─ 复杂边缘/不规则形状 → playcraft image segment --boxes (SAM3)
893
+ │ │ ├─ 毛发/半透明/复杂背景 → playcraft image remove-background --method ai
894
+ │ │ └─ 仍然不行 → playcraft image segment --text (最后手段)
895
+ │ └─ channels=3 → 输出可能是 JPEG,确保 --output 为 .png 后缀
896
+
897
+ ├─ needsAlpha = true 且从 MC/ASR 提取(非 AI 生成)?
898
+ │ → 优先: playcraft image crop (已知网格布局/坐标)
899
+ │ → 次选: playcraft image segment --boxes (已知大致位置,需精确蒙版)
900
+ │ → 回退: playcraft image segment --text (位置未知,描述要极其具体)
901
+ │ → 整图分层: playcraft image decompose-layers (需拆出多层时)
902
+ │ → Step D: 深色背景 overlay 验证
903
+
904
+ ├─ needsAlpha = false(full-coverage 全屏背景)?
905
+ │ → 不做去背景
906
+ │ → 验证:playcraft image info 确认尺寸 → 四角四边颜色一致,无褪色/白色/渐变
907
+
908
+ └─ needsAlpha = false(opaque 矩形实体)?
909
+ → 不做去背景,直接 resize(skipRemoveBg = true)
910
+ ```
911
+
912
+ #### 4. 验证清单(生成后必做)
913
+
914
+ **每个 `needsAlpha=true` 的资产,去背景后必须做以下验证:**
915
+
916
+ ```bash
917
+ # A. Alpha 通道检查 — channels 必须 = 4
918
+ playcraft image info --input <asset>.png --json
919
+ # 验证: channels == 4 (若 channels == 3,说明没有 alpha 通道)
920
+
921
+ # B. 深色背景渲染验证 — 在 #1A1A2E 深色底上叠合查看
922
+ playcraft image overlay \
923
+ --base ta-workspace/tmp/dark_verify_bg.png \
924
+ --overlay <asset>.png \
925
+ --output ta-workspace/tmp/verify_<name>.png \
926
+ --gravity center
927
+ # 目视检查:无白边、无色幕残留、无黑块、边缘干净
928
+
929
+ # C. 背景图全覆盖检查(仅 bgStrategy=full-coverage)
930
+ playcraft image info --input <bg_asset>.png --json
931
+ # 验证:尺寸精确匹配 layout-spec 要求
932
+ # 目视检查:四角四边颜色一致,无褪色/渐变/白色边缘
933
+ ```
934
+
935
+ **验证用深色底图生成(一次即可,全项目复用)**:
936
+
937
+ ```bash
938
+ # 生成 512x512 深色验证底图
939
+ node -e "
940
+ const sharp = require('sharp');
941
+ sharp({ create: { width: 512, height: 512, channels: 4, background: { r: 26, g: 26, b: 46, alpha: 1 } } })
942
+ .png().toFile('ta-workspace/tmp/dark_verify_bg.png');
943
+ "
944
+ ```
945
+
946
+ **批量验证脚本(>5 个透明资产时推荐)**:
947
+
948
+ ```bash
949
+ # 为每个需要透明的资产批量叠合验证
950
+ for f in assets/images/ui/*.png assets/images/vfx/*.png assets/images/txt/*.png; do
951
+ name=$(basename "$f" .png)
952
+ playcraft image overlay \
953
+ --base ta-workspace/tmp/dark_verify_bg.png \
954
+ --overlay "$f" \
955
+ --output "ta-workspace/tmp/verify_${name}.png" \
956
+ --gravity center
957
+ echo "[VERIFY] $name → ta-workspace/tmp/verify_${name}.png"
958
+ done
959
+ # 逐张目视检查输出,发现问题立即记录到 ta-log
960
+ ```
961
+
962
+ #### 5. 写入 ta-log.md
963
+
964
+ 在 `logs/ta-log.md` § Transparency Classification 表中填写验证结果:
965
+
966
+ ```markdown
967
+ ## Transparency Classification
968
+
969
+ | # | Contract Path | needsAlpha | bgStrategy | 去背工具 | 验证结果 |
970
+ | --- | ----------------------------- | ---------- | ------------- | -------------------------------- | --------------------------- |
971
+ | 1 | assets/images/ui/btn_cta.webp | true | greenscreen | remove-background floodfill t=25 | ✅ channels=4, 深色验证通过 |
972
+ | 2 | assets/images/txt/title.webp | true | bluescreen | remove-background floodfill t=25 | ✅ channels=4, 深色验证通过 |
973
+ | 3 | assets/images/ui/icons.webp | true | segment | segment --boxes + crop | ✅ channels=4, 深色验证通过 |
974
+ | 4 | assets/images/bg/bg_main.webp | false | full-coverage | N/A | ✅ 全覆盖检查通过 |
975
+ ```
976
+
977
+ **MUST NOT** 进入 Step 1 批量生成,除非 Transparency Classification 表完成且无 `❓` 未决项。
978
+
979
+ ---
980
+
596
981
  ### Step 1: Skill Discovery
597
982
 
598
983
  - Part A: `playcraft skills list/match` → find pipeline Skills → write to atom-plan `## TA Skill Context`
599
984
  - Part B: `playcraft skills scaffold <skillRef> --dry-run` for each atom → extract prompt/model params
600
985
  (See **Step 0** above for bash examples.)
601
986
 
602
- ### Pipeline model (E → A → B → C → D)
987
+ ### Pipeline model (E → T → A → B → C → D)
603
988
 
604
989
  ```
605
990
  Gate #2 → TA starts
606
991
 
607
- ├─ E: Extract (Step 0b) — decompose-layers or segment references from composites
992
+ ├─ 0a: Upstream Intake
993
+ ├─ 0b: Extract (E) — decompose-layers or segment references from composites
994
+ ├─ 0c: Style Interpretation Check
995
+ ├─ 0d: Production Plan
996
+ ├─ 0e: Transparency Classification ← NEW (classify all assets, select chroma key per color matrix)
997
+
998
+ ├─ T: Transparency-aware generation (Step 1 with correct chroma key per 0e table)
608
999
  │ │
609
1000
  │ ├─ C₁: generate-3d (if referenceSource="designer-sample")
610
1001
  │ │
611
- │ ├─ A: Batch Element Generation (sprite sheet per type)
1002
+ │ ├─ A: Batch Element Generation (sprite sheet per type, chroma key per 0e)
612
1003
  │ │ │
613
- │ │ ├──→ B: animate / sprite-sheet / use-vfx
1004
+ │ │ ├──→ B: animate / sprite-sheet / use-vfx (VFX always blue screen)
614
1005
  │ │ └──→ C₂: apply-texture (if referenceSource="ta-completion")
615
1006
  │ │
616
1007
  │ └─ (extraction insufficient → ICP → Designer supplementary)
617
1008
 
1009
+ ├─ Step 4: Process (remove-bg per chroma → dark-bg verify each asset)
1010
+
618
1011
  ├─ D: Audio post-processing (independent, waits for Designer Ph.2 audio)
619
1012
 
620
- └─ All done → Compliance Gate
1013
+ └─ All done → Compliance Gate (incl. Transparency checks)
621
1014
  ```
622
1015
 
623
1016
  ### Pipeline selection (quick)
@@ -666,19 +1059,35 @@ Independent track, waits only for Designer Ph.2 audio delivery:
666
1059
 
667
1060
  ### Compliance Gate (full checklist)
668
1061
 
669
- | Check | Criteria |
670
- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
671
- | All assetMapping files exist | Zero missing |
672
- | Image dimensions match assetSpec | Exact match |
673
- | Image format | **WebP** for runtime deliverables per `ta-atlas-deliverable-standard`; PNG/JPG only if layout-spec explicitly requires |
674
- | Sprite / atlas grid params | In ta-log.md (cols/frameW/frameH/frameCount); `.json` beside each atlas |
675
- | Audio format | MP3 after TA post-process |
676
- | No external dependencies | Standalone files |
677
- | Style Interpretation completed | ta-log.md has interpretation table |
678
- | No open TA questions | intent-clarifications.md clear |
1062
+ | Check | Criteria |
1063
+ | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
1064
+ | All assetMapping files exist | Zero missing |
1065
+ | Image dimensions match assetSpec | Exact match |
1066
+ | Image format | **WebP** for runtime deliverables per `ta-atlas-deliverable-standard`; PNG/JPG only if layout-spec explicitly requires |
1067
+ | Sprite / atlas grid params | In ta-log.md (cols/frameW/frameH/frameCount); `.json` beside each atlas |
1068
+ | **Transparency Classification** | ta-log.md has Transparency Classification table; all rows have 验证结果 (no `❓`) |
1069
+ | **Alpha channel (transparent)** | All assets marked 需要透明=✅ have `channels=4` (`playcraft image info --json`) |
1070
+ | **Dark-bg render verify (transparent)** | All transparent assets verified on #1A1A2E dark background — no white edge, no chroma residue, no black blocks |
1071
+ | **Background full-coverage** | All full-screen backgrounds: edges extend to all four sides, no fade/vignette/white corners |
1072
+ | **Atlas per-frame verify** | Each frame in atlas verified individually on dark background (especially VFX glow/particle frames) |
1073
+ | Audio format | MP3 after TA post-process |
1074
+ | No external dependencies | Standalone files |
1075
+ | Style Interpretation completed | ta-log.md has interpretation table |
1076
+ | No open TA questions | intent-clarifications.md clear |
679
1077
 
680
1078
  > **TA 阶段不管体积。** 品质和规格合规是唯一目标。体积优化在 Developer build 阶段。
681
1079
 
1080
+ **Transparency compliance 不通过的常见原因及修复**:
1081
+
1082
+ | 失败现象 | 根因 | 修复 |
1083
+ | ----------------------- | ------------------------------------ | ------------------------------------------------- |
1084
+ | channels=3(无 alpha) | 去背景步骤遗漏,或输出为 JPEG | 对原图执行 remove-background,确保输出 PNG |
1085
+ | 深色验证见白边 | 生成时未用色幕,白底未完全去除 | 用正确色幕重新生成 + remove-background |
1086
+ | 深色验证见绿色/蓝色残留 | 色幕选型错误(素材色与色幕撞色) | 按色幕选型矩阵换用另一种色幕重新生成 |
1087
+ | VFX 帧出现黑色不透明块 | 发光/粒子生成时未加色幕 | 用蓝幕重新生成每一帧 |
1088
+ | 背景图四角有白色/褪色 | prompt 未约束 edge-to-edge | prompt 加 "full bleed, edge to edge, no vignette" |
1089
+ | 文字/数字图底色未去除 | 未分类为"需要透明",直接 resize 交付 | 回查 Transparency Classification → 补做去背景流程 |
1090
+
682
1091
  **After compliance**: Write `logs/ta-log.md` manifest → mark atoms `✅ done` → update project-state.md.
683
1092
 
684
1093
  ### Reference image rules