@playcraft/cli 0.0.41 → 0.0.43

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 (69) hide show
  1. package/dist/atom-plan/validate-asr-coverage.js +317 -0
  2. package/dist/commands/prad.js +61 -0
  3. package/dist/commands/remix.js +4 -2
  4. package/dist/commands/skills.js +24 -0
  5. package/dist/commands/tools-generation.js +2 -4
  6. package/dist/commands/tools-utils.js +19 -0
  7. package/dist/prad/atom-ref.js +23 -0
  8. package/dist/prad/check.js +377 -0
  9. package/dist/prad/check.test.js +27 -0
  10. package/dist/prad/explain.js +109 -0
  11. package/dist/prad/load-spec.js +23 -0
  12. package/dist/prad/paths.js +83 -0
  13. package/dist/prad/skills-index.js +60 -0
  14. package/dist/utils/version-checker.js +8 -11
  15. package/package.json +3 -3
  16. package/project-template/.claude/agents/designer.md +34 -26
  17. package/project-template/.claude/agents/developer.md +55 -62
  18. package/project-template/.claude/agents/pm.md +3 -1
  19. package/project-template/.claude/agents/refs/README.md +21 -15
  20. package/project-template/.claude/agents/refs/designer-deliverable-spec.md +70 -7
  21. package/project-template/.claude/agents/refs/designer-handoff-v2-checklist.md +21 -13
  22. package/project-template/.claude/agents/refs/designer-master-composite-recipes.md +20 -28
  23. package/project-template/.claude/agents/refs/designer-style-exploration-flow.md +39 -9
  24. package/project-template/.claude/agents/refs/developer-dev-handoff.md +1 -1
  25. package/project-template/.claude/agents/refs/developer-phase1-flow.md +81 -156
  26. package/project-template/.claude/agents/refs/pm-workflow-detail.md +24 -2
  27. package/project-template/.claude/agents/refs/reviewer-convergence-eval.md +142 -0
  28. package/project-template/.claude/agents/refs/reviewer-six-dimension-eval.md +4 -284
  29. package/project-template/.claude/agents/refs/ta-atlas-deliverable-standard.md +27 -6
  30. package/project-template/.claude/agents/refs/ta-pipeline-cookbook.md +474 -29
  31. package/project-template/.claude/agents/reviewer.md +65 -38
  32. package/project-template/.claude/agents/technical-artist.md +38 -25
  33. package/project-template/.claude/hooks/README.md +40 -4
  34. package/project-template/.claude/hooks/asr-coverage-validate.mjs +381 -0
  35. package/project-template/.claude/hooks/validate-workflow-stop.mjs +196 -5
  36. package/project-template/.claude/settings.json +4 -0
  37. package/project-template/.claude/skills/playcraft-asset-state-sheet/SKILL.md +76 -22
  38. package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +84 -15
  39. package/project-template/.claude/skills/playcraft-storyboard/SKILL.md +26 -7
  40. package/project-template/.claude/skills/playcraft-workflow/SKILL.md +104 -15
  41. package/project-template/.claude/skills/playwright-cli/SKILL.md +390 -0
  42. package/project-template/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
  43. package/project-template/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
  44. package/project-template/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
  45. package/project-template/.claude/skills/playwright-cli/references/running-code.md +240 -0
  46. package/project-template/.claude/skills/playwright-cli/references/session-management.md +226 -0
  47. package/project-template/.claude/skills/playwright-cli/references/spec-driven-testing.md +312 -0
  48. package/project-template/.claude/skills/playwright-cli/references/storage-state.md +275 -0
  49. package/project-template/.claude/skills/playwright-cli/references/test-generation.md +138 -0
  50. package/project-template/.claude/skills/playwright-cli/references/tracing.md +142 -0
  51. package/project-template/.claude/skills/playwright-cli/references/video-recording.md +157 -0
  52. package/project-template/.cursor/rules/playcraft-orchestrator.mdc +74 -24
  53. package/project-template/.cursor/rules/playcraft-subagent-boundary.mdc +1 -1
  54. package/project-template/CLAUDE.md +99 -59
  55. package/project-template/docs/team/agent-conduct.md +42 -26
  56. package/project-template/docs/team/agent-runtime-matrix.md +71 -39
  57. package/project-template/docs/team/atom-plan-format.md +101 -2
  58. package/project-template/docs/team/collaboration.md +57 -48
  59. package/project-template/docs/team/core-model.md +20 -19
  60. package/project-template/docs/team/workflow-changelog.md +28 -14
  61. package/project-template/docs/team/workflow-consistency-checklist.md +64 -0
  62. package/project-template/templates/atom-plan.template.json +18 -0
  63. package/project-template/templates/atom-plan.template.md +35 -3
  64. package/project-template/templates/designer-log.template.md +94 -5
  65. package/project-template/templates/developer-log.template.md +95 -101
  66. package/project-template/templates/layout-spec.template.md +62 -8
  67. package/project-template/templates/project-state.template.md +51 -33
  68. package/project-template/templates/review-report.template.md +76 -151
  69. package/project-template/templates/ta-log.template.md +180 -14
@@ -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
+ ```
274
410
 
275
- 生图时 prompt 末尾加 `"on solid bright green #00FF00 background, isolated, centered"`(当前所有模型 ALPHA = no,无原生透明输出),然后:
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 重新生成:
276
427
 
277
428
  ```bash
278
- # 绿幕抠图(tolerance=25 对绿色效果最好)
279
- playcraft image remove-background --input in.png --output out.png --tolerance 25
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
280
454
  ```
281
455
 
282
- **批量处理 ta-workspace 脚本模板**:
456
+ #### bgStrategy = full-coverage(全屏背景)
457
+
458
+ ```bash
459
+ playcraft image info --input <bg_asset>.png --json
460
+ # 验证:尺寸精确匹配 layout-spec 要求
461
+ # 目视检查:四角四边颜色一致,无褪色/渐变/白色边缘/暗角
462
+ ```
463
+
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
 
@@ -557,21 +742,55 @@ Designer's **ASR sheets** (UI + element state reference) contain **representativ
557
742
 
558
743
  1. From **ASR** (preferred): `crop` each state slot → `resize` to spec → these become your `--reference-image` for Stage A batch generation
559
744
  2. From **Master Composite** (fallback): extract elements not covered in ASR
560
- 3. Check `designer-log.md` **ASR State Inventory** — note which states are covered vs which need expansion
745
+ 3. Check `designer-log.md` § **ASR Coverage Matrix** — note which states are covered vs which need expansion; Sheet grid metadata table at the top has `rows × cols + cell W×H + padding` for pixel-coordinate computation
561
746
  4. Background: generate clean bg using composite as `--reference-image`
562
747
  5. Text assets: → **invoke `playcraft-text-rendering` skill**
563
748
  6. Representative quality insufficient → ICP request to Designer for supplementary samples
564
749
 
750
+ **若 ASR crop 后不可抠**(白边/色幕残留/元素截断/格内场景底)→ **`routeTo: designer`** 重生成 ASR 对应格;**不要** TA 自行用 AI 重画整张 ASR。
751
+
565
752
  **ASR 提取方法(按优先级)**:
566
753
 
567
754
  > ⚠️ **严禁对 ASR 网格布局图使用纯 text prompt 的 segment!** 使用 `designer-log` 中的槽位坐标 + `crop`。
568
755
 
756
+ **优先路径:直接读 `atom-plan.json` → `atoms[].asrSlot`(最高优先级)**
757
+
758
+ Designer 在 Phase 1 完成 ASR 后会把每个 VisualAtom 的网格坐标写到 `atom-plan.json` → `atoms[i].asrSlot: { sheet, row, col }`(详见 [`docs/team/atom-plan-format.md` § `asrSlot`](../../../docs/team/atom-plan-format.md#asrslot-字段可选--visualatom-基线绑定))。TA 直接用这个字段 + `designer-log` § Sheet grid metadata,省去手翻 Coverage Matrix 的步骤:
759
+
760
+ ```bash
761
+ # 1) 从 atom-plan.json 读取所有有 asrSlot 的 VisualAtom
762
+ cat docs/atom-plan.json | jq -r '
763
+ .atoms[]
764
+ | select(.asrSlot != null)
765
+ | "\(.atomId)\t\(.asrSlot.sheet)\t\(.asrSlot.row)\t\(.asrSlot.col)"
766
+ '
767
+ # 输出格式: <atomId>\t<sheet>\t<row>\t<col>
768
+
769
+ # 2) 从 designer-log.md § ASR Coverage Matrix § Sheet grid metadata 读 cellW / cellH / padding
770
+ # (单独读一次,缓存到 ta-log 备查)
771
+
772
+ # 3) 计算像素坐标并 crop(脚本化 — ta-workspace/scripts/asr-extract.mjs)
773
+ # x = (col - 1) * (cellW + padding) + padding
774
+ # y = (row - 1) * (cellH + padding) + padding
775
+ # sheetPath 映射:
776
+ # ui → assets/images/reference/ui_state_sheet_<selectedMcOption>.png
777
+ # element → assets/images/reference/element_state_sheet_<selectedMcOption>.png
778
+ # element_2 → assets/images/reference/element_state_sheet_<selectedMcOption>_2.png
779
+ # contractPath 从 layout-spec assetMapping 中按 atom slot 反查
780
+ #
781
+ # playcraft image crop --input <sheetPath> --x <x> --y <y> --width <cellW> --height <cellH> --output <contractPath>
569
782
  ```
570
- ASR 是已知网格布局?(ui_state_sheet / element_state_sheet,行列分明)
571
- ├─ 是 → 方法 1: crop 直切(最可靠,零歧义)
783
+
784
+ ```
785
+ ASR 是已知网格布局?(ui_state_sheet / element_state_sheet / element_state_sheet_*_2,行列分明)
786
+ ├─ atom-plan.json 有 asrSlot 字段 → 方法 0(推荐): 上面脚本化批量 crop
787
+
788
+ ├─ 是但 asrSlot 缺失 → 方法 1: crop 直切(手动查 Coverage Matrix R#C#)
572
789
  │ 1. playcraft image info --input assets/images/reference/ui_state_sheet_<X>.png → 获取尺寸
573
- │ 2. 从 designer-log ASR State Inventory 读取行列与 bbox
574
- 3. playcraft image crop --input <asr_sheet> --x <x> --y <y> --width <w> --height <h> --output <out>
790
+ │ 2. 从 designer-log § ASR Coverage Matrix 读取 Sheet grid 元数据 + 目标行列 (R#C#)
791
+ pixel coords: x = (C-1) × (cellW + padding) + padding
792
+ │ y = (R-1) × (cellH + padding) + padding
793
+ │ 3. playcraft image crop --input <asr_sheet> --x <x> --y <y> --width <cellW> --height <cellH> --output <out>
575
794
  │ 4. 对有背景底色的元素:crop 后再 remove-background --method floodfill
576
795
 
577
796
  ├─ 元素位置不规则但 bbox 已知 → 方法 2: segment --boxes(精确框选)
@@ -580,6 +799,8 @@ ASR 是已知网格布局?(ui_state_sheet / element_state_sheet,行列分
580
799
  └─ 仅 MC 有该类型 → 方法 3: decompose-layers 或 segment --text(最后手段,见 playcraft-masking)
581
800
  ```
582
801
 
802
+ > **若 Designer 没有填 `asrSlot`** — 不需要重新 invoke Designer,TA 可以手动从 `designer-log § ASR Coverage Matrix § Coverage` 反查 R#C# 并继续。在 ICP 中提示 PM/Designer 下次预填可加速。
803
+
583
804
  **常见踩坑**:
584
805
 
585
806
  - ❌ `segment --text "apple tile icon"` → SAM3 可能只切出苹果图案,丢失 tile 方块底板
@@ -593,31 +814,239 @@ ASR 是已知网格布局?(ui_state_sheet / element_state_sheet,行列分
593
814
 
594
815
  Read designer-log Style Intent Notes → write interpretation table to `ta-log.md` → confidence low = blocked, medium = proceed with caution, high = proceed.
595
816
 
817
+ ### Step 0d: Production Plan (mandatory, before any generation)
818
+
819
+ > **Purpose:** Converge on full asset coverage and pipeline order before bulk production.
820
+
821
+ Write `logs/ta-log.md` § **Production Plan** with:
822
+
823
+ 1. **Coverage Plan** — one row per `layout-spec` `assetMapping` entry (contract path, pipeline type, reference source, priority)
824
+ 2. **Atlas Assembly Plan** — one row per atlas group from layout-spec grouping table (output `.webp` + `.json`, frameIds, grid layout)
825
+ 3. **Pipeline Order** — numbered steps (Extract → Complete → Process → Assemble → Verify)
826
+ 4. **Risk Checklist** — all items checked `[x]`
827
+
828
+ **Rules:**
829
+
830
+ - Coverage Plan row count must equal `assetMapping` entry count (no gaps)
831
+ - Atlas groups must match layout-spec § atlas grouping table
832
+ - **MUST NOT** start Step 1 bulk generation until Risk Checklist is fully checked
833
+ - `validate-workflow-stop.mjs` blocks STOP if Plan is incomplete
834
+
835
+ ---
836
+
837
+ ### Step 0e: Asset Transparency Classification (mandatory, before any generation)
838
+
839
+ > **Purpose:** 根据 `layout-spec.md` 的 `assetMapping` 路径约定 + 元素色彩分析,自动推导每个资产的透明度需求和色幕策略,确定完整的处理管线。**此步骤在 Production Plan 完成后、Step 1 批量生成前执行。**
840
+
841
+ **根因认知**:当前所有 AI 模型均不支持原生透明 PNG(`ALPHA = no`)。不做透明度处理 → 所有素材"生成就完事" → UI 叠加元素白底、VFX 黑块、HUD 数字白底、图标白底等系统性问题。**PlayCraft CLI 提供了完整的透明度工具链(`remove-background` / `segment` / `decompose-layers`),TA 必须显式使用。**
842
+
843
+ #### 1. 从路径约定推导 needsAlpha
844
+
845
+ 遍历 `layout-spec.md` 的 `assetMapping`,根据**路径目录**自动判断每个资产是否需要透明背景:
846
+
847
+ ```
848
+ assetMapping 路径所在目录?
849
+
850
+ ├─ assets/images/bg/ → needsAlpha = false(全屏背景,不透明)
851
+ ├─ assets/images/ui/ → needsAlpha = true (UI 叠加层,必须透明)
852
+ ├─ assets/images/txt/ → needsAlpha = true (文字图片,必须透明)
853
+ ├─ assets/images/vfx/ → needsAlpha = true (特效精灵图,必须透明)
854
+ ├─ assets/images/tiles/ → needsAlpha = true (默认;除非是卡牌/棋子矩形实体)
855
+ ├─ assets/audio/ → N/A(非图片)
856
+ └─ 其他路径 → 按素材用途判断:叠加在其他图层上 = true,独立全屏 = false
857
+ ```
858
+
859
+ **卡牌/棋子等矩形实体例外**:虽然路径在 `tiles/`,但白色牌面是资产本体的一部分,不需要透明。TA 根据 `design-brief` 的 Style Direction + `designer-log` 的样本判断。
860
+
861
+ #### 2. 从元素色彩推导 bgStrategy(色幕选型)
862
+
863
+ 对每个 `needsAlpha = true` 的资产,根据元素主色调选择色幕颜色。色调信息来源:
864
+
865
+ - `layout-spec.md` 的 Color Palette(elementId → hex color)
866
+ - `design-brief.md` 的 Style Direction(整体色温描述)
867
+ - `designer-log.md` 的样本(实际视觉参考)
868
+
869
+ **色幕选型矩阵**:
870
+
871
+ | 元素主色调 | ❌ 禁用色幕 | ✅ 推荐色幕 | 原因 |
872
+ | --------------------- | ------------ | ---------------- | ---------------------------------------------------- |
873
+ | 金色/黄色/橙色/琥珀色 | 绿幕 #00FF00 | **蓝幕 #0000FF** | 金色与绿色色相接近(黄绿区),floodfill 残留绿色边缘 |
874
+ | 绿色/翠绿/青色 | 绿幕 #00FF00 | **蓝幕 #0000FF** | 同色系,floodfill 无法区分边界 |
875
+ | 蓝色/靛蓝/紫色 | 蓝幕 #0000FF | **绿幕 #00FF00** | 同色系冲突 |
876
+ | 红色/粉色/白色/黑色 | — | 绿幕或蓝幕均可 | 与两者色相距离都大 |
877
+ | 多色/彩虹 | — | **品红 #FF00FF** | 品红在自然素材中最少出现(最后手段) |
878
+
879
+ **特殊规则**(不按元素色彩,按资产类型固定):
880
+
881
+ | 资产类型 | 固定色幕 | 原因 |
882
+ | ---------------------- | ---------------- | ---------------------------------------------------- |
883
+ | VFX 发光/粒子/选中高亮 | **蓝幕 #0000FF** | VFX 普遍含暖色调(金色火焰、橙色爆炸),绿幕必出残留 |
884
+ | 文字/数字图片 | **蓝幕 #0000FF** | 文字常为金色/白色/浅色,绿幕边缘污染 |
885
+ | 全屏背景 | N/A(不去背景) | prompt 加 `"full bleed, edge to edge, no vignette"` |
886
+ | 矩形实体(卡牌/棋子) | N/A(不去背景) | 白底是资产本身,skipRemoveBg = true |
887
+
888
+ #### 3. 填写 Transparency Classification 表
889
+
890
+ ```markdown
891
+ ## Transparency Classification
892
+
893
+ | assetMapping path | needsAlpha | bgStrategy | 去背工具(第一选择) | 回退工具 | 验证方法 | 验证结果 |
894
+ | ----------------------------- | ---------- | ------------- | ------------------------------------- | ------------------------------------------- | -------------------- | -------- |
895
+ | assets/images/bg/bg_main.webp | false | full-coverage | N/A | N/A | 边缘全覆盖检查 | ❓ |
896
+ | assets/images/ui/btn_cta.webp | true | greenscreen | `remove-background --floodfill -t 25` | `segment --boxes` / `remove-bg --method ai` | 深色背景 overlay | ❓ |
897
+ | assets/images/txt/digits.webp | true | bluescreen | `remove-background --floodfill -t 25` | `segment --boxes` / `remove-bg --method ai` | 深色背景 overlay | ❓ |
898
+ | assets/images/vfx/glow.webp | true | bluescreen | `remove-background --floodfill -t 25` | `segment --boxes` | 逐帧深色背景 overlay | ❓ |
899
+ | assets/images/tiles/tile.webp | true | greenscreen | `remove-background --floodfill -t 25` | `segment --boxes` / `remove-bg --method ai` | 深色背景 overlay | ❓ |
900
+ | assets/images/txt/title.webp | true | bluescreen | `remove-background --floodfill -t 25` | `remove-bg --method ai` | 深色背景 overlay | ❓ |
901
+ ```
902
+
903
+ #### 4. 去背工具链(按 bgStrategy 执行)
904
+
905
+ > **PlayCraft CLI 提供了完整的透明度处理工具链,TA 必须按决策树显式使用,不能跳过去背景步骤。**
906
+
907
+ | bgStrategy | 生成 prompt 后缀 | 第一选择去背工具 | 回退工具(第一选择效果不好时) |
908
+ | ------------- | ------------------------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- |
909
+ | greenscreen | `"on solid bright green #00FF00 background, isolated, centered"` | `playcraft image remove-background --tolerance 25` | `playcraft image segment --boxes` 或 `--method ai` |
910
+ | bluescreen | `"on solid bright blue #0000FF background, isolated, centered"` | `playcraft image remove-background --tolerance 25` | `playcraft image segment --boxes` 或 `--method ai` |
911
+ | magenta | `"on solid bright magenta #FF00FF background, isolated, centered"` | `playcraft image remove-background --tolerance 20` | `playcraft image remove-background --method ai` |
912
+ | extract | 无特殊后缀(从 MC/ASR 提取) | `playcraft image crop` 或 `segment --boxes` | `playcraft image decompose-layers`(整图分层) |
913
+ | full-coverage | `"full scene, full bleed, edge to edge, no vignette, no fade"` | N/A(不去背景) | N/A |
914
+ | opaque | `"flat 2D, no shadow, no 3D effect, clean edges, white background"` | N/A(不去背景) | N/A |
915
+
916
+ **工具选型决策树**(TA 必须按此执行,不可跳步):
917
+
918
+ ```
919
+ needsAlpha = true?
920
+ ├─ 是 → 按色幕选型矩阵确定色幕颜色
921
+ │ → Step A: 生成时 prompt 加色幕后缀
922
+ │ → Step B: playcraft image remove-background --method floodfill --tolerance 25
923
+ │ → Step C: playcraft image info --json → channels == 4?
924
+ │ ├─ channels=4 → Step D: 深色背景 overlay 验证
925
+ │ │ ├─ 通过 → ✅ 记录结果
926
+ │ │ └─ 边缘有残留 → 回退工具链:
927
+ │ │ ├─ 纯色残留少量 → 调高 tolerance (25→40→60) 重试
928
+ │ │ ├─ 复杂边缘/不规则形状 → playcraft image segment --boxes (SAM3)
929
+ │ │ ├─ 毛发/半透明/复杂背景 → playcraft image remove-background --method ai
930
+ │ │ └─ 仍然不行 → playcraft image segment --text (最后手段)
931
+ │ └─ channels=3 → 输出可能是 JPEG,确保 --output 为 .png 后缀
932
+
933
+ ├─ needsAlpha = true 且从 MC/ASR 提取(非 AI 生成)?
934
+ │ → 优先: playcraft image crop (已知网格布局/坐标)
935
+ │ → 次选: playcraft image segment --boxes (已知大致位置,需精确蒙版)
936
+ │ → 回退: playcraft image segment --text (位置未知,描述要极其具体)
937
+ │ → 整图分层: playcraft image decompose-layers (需拆出多层时)
938
+ │ → Step D: 深色背景 overlay 验证
939
+
940
+ ├─ needsAlpha = false(full-coverage 全屏背景)?
941
+ │ → 不做去背景
942
+ │ → 验证:playcraft image info 确认尺寸 → 四角四边颜色一致,无褪色/白色/渐变
943
+
944
+ └─ needsAlpha = false(opaque 矩形实体)?
945
+ → 不做去背景,直接 resize(skipRemoveBg = true)
946
+ ```
947
+
948
+ #### 4. 验证清单(生成后必做)
949
+
950
+ **每个 `needsAlpha=true` 的资产,去背景后必须做以下验证:**
951
+
952
+ ```bash
953
+ # A. Alpha 通道检查 — channels 必须 = 4
954
+ playcraft image info --input <asset>.png --json
955
+ # 验证: channels == 4 (若 channels == 3,说明没有 alpha 通道)
956
+
957
+ # B. 深色背景渲染验证 — 在 #1A1A2E 深色底上叠合查看
958
+ playcraft image overlay \
959
+ --base ta-workspace/tmp/dark_verify_bg.png \
960
+ --overlay <asset>.png \
961
+ --output ta-workspace/tmp/verify_<name>.png \
962
+ --gravity center
963
+ # 目视检查:无白边、无色幕残留、无黑块、边缘干净
964
+
965
+ # C. 背景图全覆盖检查(仅 bgStrategy=full-coverage)
966
+ playcraft image info --input <bg_asset>.png --json
967
+ # 验证:尺寸精确匹配 layout-spec 要求
968
+ # 目视检查:四角四边颜色一致,无褪色/渐变/白色边缘
969
+ ```
970
+
971
+ **验证用深色底图生成(一次即可,全项目复用)**:
972
+
973
+ ```bash
974
+ # 生成 512x512 深色验证底图
975
+ node -e "
976
+ const sharp = require('sharp');
977
+ sharp({ create: { width: 512, height: 512, channels: 4, background: { r: 26, g: 26, b: 46, alpha: 1 } } })
978
+ .png().toFile('ta-workspace/tmp/dark_verify_bg.png');
979
+ "
980
+ ```
981
+
982
+ **批量验证脚本(>5 个透明资产时推荐)**:
983
+
984
+ ```bash
985
+ # 为每个需要透明的资产批量叠合验证
986
+ for f in assets/images/ui/*.png assets/images/vfx/*.png assets/images/txt/*.png; do
987
+ name=$(basename "$f" .png)
988
+ playcraft image overlay \
989
+ --base ta-workspace/tmp/dark_verify_bg.png \
990
+ --overlay "$f" \
991
+ --output "ta-workspace/tmp/verify_${name}.png" \
992
+ --gravity center
993
+ echo "[VERIFY] $name → ta-workspace/tmp/verify_${name}.png"
994
+ done
995
+ # 逐张目视检查输出,发现问题立即记录到 ta-log
996
+ ```
997
+
998
+ #### 5. 写入 ta-log.md
999
+
1000
+ 在 `logs/ta-log.md` § Transparency Classification 表中填写验证结果:
1001
+
1002
+ ```markdown
1003
+ ## Transparency Classification
1004
+
1005
+ | # | Contract Path | needsAlpha | bgStrategy | 去背工具 | 验证结果 |
1006
+ | --- | ----------------------------- | ---------- | ------------- | -------------------------------- | --------------------------- |
1007
+ | 1 | assets/images/ui/btn_cta.webp | true | greenscreen | remove-background floodfill t=25 | ✅ channels=4, 深色验证通过 |
1008
+ | 2 | assets/images/txt/title.webp | true | bluescreen | remove-background floodfill t=25 | ✅ channels=4, 深色验证通过 |
1009
+ | 3 | assets/images/ui/icons.webp | true | segment | segment --boxes + crop | ✅ channels=4, 深色验证通过 |
1010
+ | 4 | assets/images/bg/bg_main.webp | false | full-coverage | N/A | ✅ 全覆盖检查通过 |
1011
+ ```
1012
+
1013
+ **MUST NOT** 进入 Step 1 批量生成,除非 Transparency Classification 表完成且无 `❓` 未决项。
1014
+
1015
+ ---
1016
+
596
1017
  ### Step 1: Skill Discovery
597
1018
 
598
1019
  - Part A: `playcraft skills list/match` → find pipeline Skills → write to atom-plan `## TA Skill Context`
599
1020
  - Part B: `playcraft skills scaffold <skillRef> --dry-run` for each atom → extract prompt/model params
600
1021
  (See **Step 0** above for bash examples.)
601
1022
 
602
- ### Pipeline model (E → A → B → C → D)
1023
+ ### Pipeline model (E → T → A → B → C → D)
603
1024
 
604
1025
  ```
605
1026
  Gate #2 → TA starts
606
1027
 
607
- ├─ E: Extract (Step 0b) — decompose-layers or segment references from composites
1028
+ ├─ 0a: Upstream Intake
1029
+ ├─ 0b: Extract (E) — decompose-layers or segment references from composites
1030
+ ├─ 0c: Style Interpretation Check
1031
+ ├─ 0d: Production Plan
1032
+ ├─ 0e: Transparency Classification ← NEW (classify all assets, select chroma key per color matrix)
1033
+
1034
+ ├─ T: Transparency-aware generation (Step 1 with correct chroma key per 0e table)
608
1035
  │ │
609
1036
  │ ├─ C₁: generate-3d (if referenceSource="designer-sample")
610
1037
  │ │
611
- │ ├─ A: Batch Element Generation (sprite sheet per type)
1038
+ │ ├─ A: Batch Element Generation (sprite sheet per type, chroma key per 0e)
612
1039
  │ │ │
613
- │ │ ├──→ B: animate / sprite-sheet / use-vfx
1040
+ │ │ ├──→ B: animate / sprite-sheet / use-vfx (VFX always blue screen)
614
1041
  │ │ └──→ C₂: apply-texture (if referenceSource="ta-completion")
615
1042
  │ │
616
1043
  │ └─ (extraction insufficient → ICP → Designer supplementary)
617
1044
 
1045
+ ├─ Step 4: Process (remove-bg per chroma → dark-bg verify each asset)
1046
+
618
1047
  ├─ D: Audio post-processing (independent, waits for Designer Ph.2 audio)
619
1048
 
620
- └─ All done → Compliance Gate
1049
+ └─ All done → Compliance Gate (incl. Transparency checks)
621
1050
  ```
622
1051
 
623
1052
  ### Pipeline selection (quick)
@@ -666,19 +1095,35 @@ Independent track, waits only for Designer Ph.2 audio delivery:
666
1095
 
667
1096
  ### Compliance Gate (full checklist)
668
1097
 
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 |
1098
+ | Check | Criteria |
1099
+ | --------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
1100
+ | All assetMapping files exist | Zero missing |
1101
+ | Image dimensions match assetSpec | Exact match |
1102
+ | Image format | **WebP** for runtime deliverables per `ta-atlas-deliverable-standard`; PNG/JPG only if layout-spec explicitly requires |
1103
+ | Sprite / atlas grid params | In ta-log.md (cols/frameW/frameH/frameCount); `.json` beside each atlas |
1104
+ | **Transparency Classification** | ta-log.md has Transparency Classification table; all rows have 验证结果 (no `❓`) |
1105
+ | **Alpha channel (transparent)** | All assets marked 需要透明=✅ have `channels=4` (`playcraft image info --json`) |
1106
+ | **Dark-bg render verify (transparent)** | All transparent assets verified on #1A1A2E dark background — no white edge, no chroma residue, no black blocks |
1107
+ | **Background full-coverage** | All full-screen backgrounds: edges extend to all four sides, no fade/vignette/white corners |
1108
+ | **Atlas per-frame verify** | Each frame in atlas verified individually on dark background (especially VFX glow/particle frames) |
1109
+ | Audio format | MP3 after TA post-process |
1110
+ | No external dependencies | Standalone files |
1111
+ | Style Interpretation completed | ta-log.md has interpretation table |
1112
+ | No open TA questions | intent-clarifications.md clear |
679
1113
 
680
1114
  > **TA 阶段不管体积。** 品质和规格合规是唯一目标。体积优化在 Developer build 阶段。
681
1115
 
1116
+ **Transparency compliance 不通过的常见原因及修复**:
1117
+
1118
+ | 失败现象 | 根因 | 修复 |
1119
+ | ----------------------- | ------------------------------------ | ------------------------------------------------- |
1120
+ | channels=3(无 alpha) | 去背景步骤遗漏,或输出为 JPEG | 对原图执行 remove-background,确保输出 PNG |
1121
+ | 深色验证见白边 | 生成时未用色幕,白底未完全去除 | 用正确色幕重新生成 + remove-background |
1122
+ | 深色验证见绿色/蓝色残留 | 色幕选型错误(素材色与色幕撞色) | 按色幕选型矩阵换用另一种色幕重新生成 |
1123
+ | VFX 帧出现黑色不透明块 | 发光/粒子生成时未加色幕 | 用蓝幕重新生成每一帧 |
1124
+ | 背景图四角有白色/褪色 | prompt 未约束 edge-to-edge | prompt 加 "full bleed, edge to edge, no vignette" |
1125
+ | 文字/数字图底色未去除 | 未分类为"需要透明",直接 resize 交付 | 回查 Transparency Classification → 补做去背景流程 |
1126
+
682
1127
  **After compliance**: Write `logs/ta-log.md` manifest → mark atoms `✅ done` → update project-state.md.
683
1128
 
684
1129
  ### Reference image rules