@playcraft/cli 0.0.57 → 0.0.59
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 +34 -16
- package/dist/cli-root-help.js +1 -0
- package/dist/commands/build-all.js +10 -9
- package/dist/commands/build.js +13 -12
- package/dist/commands/create.js +26 -33
- package/dist/commands/platform-skills.generated.js +19 -0
- package/dist/commands/skills.js +2 -0
- package/dist/commands/tools-generation.js +1 -1
- package/dist/commands/workspace-runtime.js +54 -0
- package/dist/index.js +3 -1
- package/dist/project-skills/commands.js +72 -0
- package/dist/project-skills/lifecycle.js +28 -0
- package/dist/project-skills/local-run.js +112 -0
- package/dist/project-skills/local-store.js +149 -0
- package/dist/project-skills/messages.js +72 -0
- package/dist/project-skills/reconcile.js +62 -0
- package/dist/project-skills/remote-cache.js +51 -0
- package/dist/project-skills/validation.js +19 -0
- package/dist/remix/clone.js +2 -0
- package/dist/remix/init-template.js +2 -0
- package/dist/remix/pull.js +2 -0
- package/dist/remix/push.js +21 -1
- package/dist/utils/agent-api-client.js +54 -17
- package/dist/utils/tool-operation-journal.js +54 -0
- package/dist/workspace-runtime/codex/app-server.js +395 -0
- package/dist/workspace-runtime/codex/config-toml.js +25 -0
- package/dist/workspace-runtime/codex/jsonrpc-stdio.js +106 -0
- package/dist/workspace-runtime/codex/loopback.js +59 -0
- package/dist/workspace-runtime/codex/native-adapter.js +3 -0
- package/dist/workspace-runtime/main.js +10 -0
- package/dist/workspace-runtime/persistence/journal.js +350 -0
- package/dist/workspace-runtime/processes/managed-writes.js +69 -0
- package/dist/workspace-runtime/serve.js +111 -0
- package/dist/workspace-runtime/server/auth.js +21 -0
- package/dist/workspace-runtime/server/dispatch.js +861 -0
- package/dist/workspace-runtime/server/execution-group.js +88 -0
- package/dist/workspace-runtime/server/http.js +561 -0
- package/dist/workspace-runtime/server/lock.js +53 -0
- package/dist/workspace-runtime/server/types.js +1 -0
- package/dist/workspace-runtime/workspaces/context-error.js +2 -0
- package/dist/workspace-runtime/workspaces/file-snapshot.js +213 -0
- package/dist/workspace-runtime/workspaces/files.js +143 -0
- package/dist/workspace-runtime/workspaces/git.js +242 -0
- package/dist/workspace-runtime/workspaces/json5-edit.js +170 -0
- package/dist/workspace-runtime/workspaces/parameters.js +272 -0
- package/dist/workspace-runtime/workspaces/prepare.js +364 -0
- package/dist/workspace-runtime/workspaces/registry.js +107 -0
- package/dist/workspace-runtime/workspaces/revisions.js +31 -0
- package/package.json +6 -3
- package/project-template-v2/.claude/agents/artist.md +82 -0
- package/project-template-v2/.claude/agents/developer.md +153 -0
- package/project-template-v2/.claude/agents/game-designer.md +264 -0
- package/project-template-v2/.claude/agents/refs/artist-art-style-catalog.md +533 -0
- package/project-template-v2/.claude/agents/refs/artist-color-audio-recipes.md +153 -0
- package/project-template-v2/.claude/agents/refs/artist-dimension-axis.md +27 -0
- package/project-template-v2/.claude/agents/refs/artist-master-composite-recipes.md +208 -0
- package/project-template-v2/.claude/agents/refs/atom-skill-library.md +81 -0
- package/project-template-v2/.claude/agents/refs/developer-impl-cookbook.md +432 -0
- package/project-template-v2/.claude/agents/refs/framework-5-component-filter.md +252 -0
- package/project-template-v2/.claude/agents/refs/framework-game-feel-juice.md +266 -0
- package/project-template-v2/.claude/agents/refs/framework-mda.md +147 -0
- package/project-template-v2/.claude/agents/refs/game-designer-gameplay-sufficiency.md +123 -0
- package/project-template-v2/.claude/agents/refs/ta-3d-flip-recipe.md +88 -0
- package/project-template-v2/.claude/agents/refs/ta-atlas-deliverable-standard.md +67 -0
- package/project-template-v2/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
- package/project-template-v2/.claude/agents/refs/ta-image-generation-detail.md +300 -0
- package/project-template-v2/.claude/agents/refs/ta-image-ops-reference.md +495 -0
- package/project-template-v2/.claude/agents/refs/ta-pipeline-cookbook.md +1141 -0
- package/project-template-v2/.claude/agents/refs/ta-tools-reference.md +111 -0
- package/project-template-v2/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
- package/project-template-v2/.claude/agents/refs/threejs-cannon-pitfalls.md +412 -0
- package/project-template-v2/.claude/agents/reviewer.md +75 -0
- package/project-template-v2/.claude/agents/technical-artist.md +86 -0
- package/project-template-v2/.claude/hooks/snapshot-milestone.mjs +243 -0
- package/project-template-v2/.claude/hooks/user-prompt.mjs +133 -0
- package/project-template-v2/.claude/settings.json +33 -0
- package/project-template-v2/.claude/skills/brainstorming/SKILL.md +161 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/frame-template.html +270 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/helper.js +177 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/server.cjs +354 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/start-server.sh +148 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/stop-server.sh +56 -0
- package/project-template-v2/.claude/skills/brainstorming/scripts/wait-for-selection.sh +62 -0
- package/project-template-v2/.claude/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/project-template-v2/.claude/skills/brainstorming/visual-companion.md +309 -0
- package/project-template-v2/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
- package/project-template-v2/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
- package/project-template-v2/.claude/skills/playcraft-asset-state-sheet/SKILL.md +205 -0
- package/project-template-v2/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
- package/project-template-v2/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
- package/project-template-v2/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/SKILL.md +298 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +324 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +137 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
- package/project-template-v2/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
- package/project-template-v2/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
- package/project-template-v2/.claude/skills/playcraft-image-processing/SKILL.md +219 -0
- package/project-template-v2/.claude/skills/playcraft-masking/SKILL.md +373 -0
- package/project-template-v2/.claude/skills/playcraft-playable-optimization/SKILL.md +161 -0
- package/project-template-v2/.claude/skills/playcraft-research/SKILL.md +215 -0
- package/project-template-v2/.claude/skills/playcraft-skill-recommender/SKILL.md +382 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-remix/SKILL.md +158 -0
- package/project-template-v2/.claude/skills/playcraft-sprite-sheet/SKILL.md +100 -0
- package/project-template-v2/.claude/skills/playcraft-storyboard/SKILL.md +167 -0
- package/project-template-v2/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
- package/project-template-v2/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
- package/project-template-v2/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
- package/project-template-v2/.claude/skills/playwright-cli/SKILL.md +390 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/element-attributes.md +23 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/request-mocking.md +87 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/running-code.md +240 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/session-management.md +226 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/spec-driven-testing.md +308 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/storage-state.md +275 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/test-generation.md +134 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/tracing.md +142 -0
- package/project-template-v2/.claude/skills/playwright-cli/references/video-recording.md +153 -0
- package/project-template-v2/.claude/skills/session-analyzer/SKILL.md +386 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/execution-breakdown.mjs +182 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/find-turns.mjs +72 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/heavy-output.mjs +121 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/resolve-session.mjs +102 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-stats.mjs +127 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/subagent-tool-timeline.mjs +106 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/time-gaps.mjs +128 -0
- package/project-template-v2/.claude/skills/session-analyzer/scripts/turn-timeline.mjs +67 -0
- package/project-template-v2/.claude/snapshot.mjs +263 -0
- package/project-template-v2/.playcraft/skills.lock.json +152 -0
- package/project-template-v2/CLAUDE.md +146 -0
- package/project-template-v2/assets/audio/bgm/.gitkeep +0 -0
- package/project-template-v2/assets/audio/sfx/.gitkeep +0 -0
- package/project-template-v2/assets/bundles/.gitkeep +0 -0
- package/project-template-v2/assets/images/bg/.gitkeep +0 -0
- package/project-template-v2/assets/images/reference/.gitkeep +0 -0
- package/project-template-v2/assets/images/storyboard/.gitkeep +0 -0
- package/project-template-v2/assets/images/tiles/.gitkeep +0 -0
- package/project-template-v2/assets/images/ui/.gitkeep +0 -0
- package/project-template-v2/assets/images/vfx/.gitkeep +0 -0
- package/project-template-v2/assets/models/.gitkeep +0 -0
- package/project-template-v2/docs/harness/iteration-1/context-flow.md +254 -0
- package/project-template-v2/docs/harness/iteration-1/generate-flow.md +91 -0
- package/project-template-v2/docs/harness/iteration-1/ideate-flow.md +214 -0
- package/project-template-v2/docs/harness/iteration-1/optimize-flow.md +75 -0
- package/project-template-v2/docs/harness/iteration-1/wrapup-flow.md +63 -0
- package/project-template-v2/docs/harness/iteration-2/context-flow.md +223 -0
- package/project-template-v2/docs/harness/iteration-2/generate-flow.md +129 -0
- package/project-template-v2/docs/harness/iteration-2/ideate-flow.md +267 -0
- package/project-template-v2/docs/harness/iteration-2/optimize-flow.md +164 -0
- package/project-template-v2/docs/harness/iteration-2/wrapup-flow.md +115 -0
- package/project-template-v2/docs/harness/orchestrator-flow.md +364 -0
- package/project-template-v2/docs/project-state.json +60 -0
- package/project-template-v2/docs/project-state.md +72 -0
- package/project-template-v2/docs/standards/README.md +225 -0
- package/project-template-v2/docs/standards/agent-behavior-standards.md +174 -0
- package/project-template-v2/docs/standards/artifacts/design-brief.md +19 -0
- package/project-template-v2/docs/standards/artifacts/design.md +22 -0
- package/project-template-v2/docs/standards/artifacts/game-code.md +41 -0
- package/project-template-v2/docs/standards/artifacts/todo-list.md +41 -0
- package/project-template-v2/docs/standards/iter1-agent-behavior-standards.md +343 -0
- package/project-template-v2/game/index.ts +18 -0
- package/project-template-v2/globals.d.ts +51 -0
- package/project-template-v2/index.css +34 -0
- package/project-template-v2/index.html +18 -0
- package/project-template-v2/main.ts +9 -0
- package/project-template-v2/package.json +46 -0
- package/project-template-v2/skills/_shared/scripts/dispatch-clear.mjs +31 -0
- package/project-template-v2/skills/_shared/scripts/dispatch-set.mjs +86 -0
- package/project-template-v2/skills/_shared/scripts/dod-check.mjs +153 -0
- package/project-template-v2/skills/_shared/scripts/handoff-append.mjs +70 -0
- package/project-template-v2/skills/_shared/scripts/lib/validator-artifacts.mjs +91 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/dod-config.mjs +131 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/index.mjs +80 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-1-core.mjs +90 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-2-wrap.mjs +93 -0
- package/project-template-v2/skills/_shared/scripts/pipeline/iteration-3-visual.mjs +23 -0
- package/project-template-v2/skills/_shared/scripts/render-project-state.mjs +230 -0
- package/project-template-v2/skills/_shared/scripts/state-advance-stage.mjs +58 -0
- package/project-template-v2/skills/_shared/scripts/state-get.mjs +339 -0
- package/project-template-v2/skills/_shared/scripts/state-handoff.mjs +39 -0
- package/project-template-v2/skills/_shared/scripts/state-set.mjs +94 -0
- package/project-template-v2/skills/_shared/scripts/state-store.mjs +783 -0
- package/project-template-v2/skills/_shared/scripts/todo-add.mjs +88 -0
- package/project-template-v2/skills/_shared/scripts/todo-get.mjs +130 -0
- package/project-template-v2/skills/_shared/scripts/todo-remove.mjs +33 -0
- package/project-template-v2/skills/_shared/scripts/todo-set.mjs +47 -0
- package/project-template-v2/skills/_shared/scripts/verify-asset-code-sync.mjs +268 -0
- package/project-template-v2/skills/_shared/scripts/verify-env.mjs +285 -0
- package/project-template-v2/skills/_shared/scripts/verify-placeholders.mjs +161 -0
- package/project-template-v2/skills/playable-autoplay/SKILL.md +176 -0
- package/project-template-v2/skills/playable-autoplay/agents/openai.yaml +4 -0
- package/project-template-v2/skills/playable-debug/SKILL.md +116 -0
- package/project-template-v2/skills/playable-debug/agents/openai.yaml +4 -0
- package/project-template-v2/skills/playable-debug/references/debug-config.md +40 -0
- package/project-template-v2/skills/playable-record/SKILL.md +140 -0
- package/project-template-v2/skills/playable-record/scripts/lib/dev-server.mjs +104 -0
- package/project-template-v2/skills/playable-record/scripts/lib/record-audio-bridge.js +141 -0
- package/project-template-v2/skills/playable-record/scripts/record-playable.mjs +425 -0
- package/project-template-v2/skills/playable-record/scripts/verify-contract.mjs +261 -0
- package/project-template-v2/skills/playable-record/scripts/verify-firstwin.mjs +398 -0
- package/project-template-v2/skills/playable-record/scripts/verify-fusion.mjs +322 -0
- package/project-template-v2/skills/playable-record/scripts/verify-lifecycle.mjs +105 -0
- package/project-template-v2/skills/playable-record/scripts/verify-vlm-video.mjs +230 -0
- package/project-template-v2/skills/playable-validate/SKILL.md +61 -0
- package/project-template-v2/skills/playable-validate/validation-rules.md +14 -0
- package/project-template-v2/skills/playable-verify-ui/SKILL.md +63 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/__init__.py +1 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/config_expr.js +218 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/node_utils.js +51 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/profile_loader.py +59 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/report.py +106 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/lib/runtime_contract.js +116 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_fetch_antipatterns.py +59 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_hardcoded_layout.js +64 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_runtime_contract.js +58 -0
- package/project-template-v2/skills/playable-verify-ui/scripts/verify_text_overlap.py +333 -0
- package/project-template-v2/ta-workspace/scripts/.gitkeep +0 -0
- package/project-template-v2/tsconfig.json +20 -0
- package/project-template-v2/vite.config.ts +27 -0
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playcraft-build-optimizer
|
|
3
|
+
description: 可玩广告构建优化与平台合规验证完整指南。涵盖 playcraft build 全部优化参数(图片压缩/WebP转换/模型压缩/JS混淆)、正确的优化执行顺序(避免多次有损压缩)、各平台合规验证清单(文件大小/外部请求/CTA API/音频自动播放)、Base64 膨胀系数计算。供未来 Optimizer Agent 使用。
|
|
4
|
+
triggers: 构建优化,build optimizer,压缩,compress,WebP,pngquant,文件大小,file size,合规验证,compliance,CTA API,FbPlayableAd,ExitApi,外部请求,external request,体积,5MB限制,build参数,optimize,minify
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# 可玩广告构建优化与合规验证指南
|
|
8
|
+
|
|
9
|
+
> **使用时机**:在 Developer Phase 2(集成构建)完成、产出 index.html 之后执行。优化是最后一步,不在生产阶段执行。
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 0. 关键数字速查
|
|
14
|
+
|
|
15
|
+
| 约束项 | 数值 | 说明 |
|
|
16
|
+
| ---------------- | --------------------------- | ---------------------------------------- |
|
|
17
|
+
| 最终文件大小上限 | 5 MB | Meta/Google/AppLovin/IronSource 统一标准 |
|
|
18
|
+
| 原始资产建议上限 | 3.75 MB | Base64 编码后膨胀 ×1.33,需提前预留空间 |
|
|
19
|
+
| 触控目标最小尺寸 | 48×48 px | 防止误触,符合 WCAG 可访问性标准 |
|
|
20
|
+
| CTA 对比度下限 | 4.5:1 | WCAG AA 标准(CTA 按钮与背景) |
|
|
21
|
+
| Meta CTA API | `FbPlayableAd.onCTAClick()` | 必须实现,否则审核拒绝 |
|
|
22
|
+
| Google CTA API | `ExitApi.exit()` | 必须实现,否则审核拒绝 |
|
|
23
|
+
| 音频自动播放 | 禁止 | 必须等用户交互后才能播放 |
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 1. 合规验证清单(构建后必须执行)
|
|
28
|
+
|
|
29
|
+
### 1.1 文件大小验证
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# 检查最终输出文件大小
|
|
33
|
+
playcraft image info --input dist/index.html --json # 不适用,用 shell
|
|
34
|
+
|
|
35
|
+
# Shell 方法:检查文件大小(字节)
|
|
36
|
+
du -sh dist/index.html
|
|
37
|
+
ls -lh dist/index.html
|
|
38
|
+
|
|
39
|
+
# 计算:若当前原始资产总大小为 X MB
|
|
40
|
+
# 预计最终 HTML 大小 ≈ X × 1.33(Base64 膨胀)
|
|
41
|
+
# 若预计超过 5 MB,需要压缩
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Base64 膨胀系数说明**:`playcraft build` 会将所有资产(图片、音频、模型)内嵌到单个 HTML 文件中,编码为 Base64。Base64 编码会使数据体积增加约 33%。
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
原始资产总大小 × 1.33 ≈ 最终 HTML 文件大小
|
|
48
|
+
→ 要保证最终 < 5 MB,原始资产须 < 3.75 MB
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 1.2 外部请求检查
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# 在项目代码中搜索外部请求(构建前检查)
|
|
55
|
+
grep -r "fetch(" game/ --include="*.js" --include="*.ts"
|
|
56
|
+
grep -r "XMLHttpRequest" game/ --include="*.js" --include="*.ts"
|
|
57
|
+
grep -r "https://" game/ --include="*.js" --include="*.ts"
|
|
58
|
+
grep -r "http://" game/ --include="*.js" --include="*.ts"
|
|
59
|
+
grep -r "<script src=" game/ --include="*.html"
|
|
60
|
+
grep -r "<link href=" game/ --include="*.html"
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**零外部请求要求**:最终 HTML 不得包含任何外部 URL(CDN、API、图片链接等)。所有资源必须内嵌。
|
|
64
|
+
|
|
65
|
+
### 1.3 CTA API 实现验证
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# 检查 Meta CTA API 实现
|
|
69
|
+
grep -r "FbPlayableAd.onCTAClick" game/ --include="*.js" --include="*.ts"
|
|
70
|
+
# 若无匹配 → CTA 功能不完整,需要 Developer 补充
|
|
71
|
+
|
|
72
|
+
# 检查 Google CTA API 实现
|
|
73
|
+
grep -r "ExitApi.exit" game/ --include="*.js" --include="*.ts"
|
|
74
|
+
# 若无匹配 → Google Ads 版本缺少 CTA,需要 Developer 补充
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**CTA API 标准实现**(供 Developer 参考):
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
// 多平台兼容 CTA 处理
|
|
81
|
+
function handleCTAClick() {
|
|
82
|
+
// Meta / Facebook
|
|
83
|
+
if (typeof FbPlayableAd !== 'undefined') {
|
|
84
|
+
FbPlayableAd.onCTAClick();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// Google Ads / AdMob
|
|
88
|
+
if (typeof ExitApi !== 'undefined') {
|
|
89
|
+
ExitApi.exit();
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
// AppLovin / IronSource / 其他
|
|
93
|
+
if (typeof mraid !== 'undefined') {
|
|
94
|
+
mraid.open(STORE_URL);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// Fallback
|
|
98
|
+
window.open(STORE_URL, '_blank');
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### 1.4 音频自动播放检查
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# 检查是否有自动播放的音频
|
|
106
|
+
grep -r "autoplay" game/ --include="*.js" --include="*.ts" --include="*.html"
|
|
107
|
+
grep -r "\.play()" game/ --include="*.js" --include="*.ts"
|
|
108
|
+
# 所有 .play() 调用必须在用户交互事件(click/touchstart)的回调内
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 2. playcraft build 优化参数
|
|
114
|
+
|
|
115
|
+
### 完整优化构建命令
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# 标准优化构建(Meta 平台)
|
|
119
|
+
playcraft build . \
|
|
120
|
+
--platform facebook \
|
|
121
|
+
--compress-images \
|
|
122
|
+
--image-quality 85 \
|
|
123
|
+
--convert-webp \
|
|
124
|
+
--js-minify \
|
|
125
|
+
--css-minify \
|
|
126
|
+
--output dist/
|
|
127
|
+
|
|
128
|
+
# 带 3D 模型压缩的构建
|
|
129
|
+
playcraft build . \
|
|
130
|
+
--platform facebook \
|
|
131
|
+
--compress-images \
|
|
132
|
+
--image-quality 80 \
|
|
133
|
+
--convert-webp \
|
|
134
|
+
--compress-models \
|
|
135
|
+
--model-compression draco \
|
|
136
|
+
--js-minify \
|
|
137
|
+
--output dist/
|
|
138
|
+
|
|
139
|
+
# 分析体积占用(不构建,只分析)
|
|
140
|
+
playcraft build . \
|
|
141
|
+
--platform facebook \
|
|
142
|
+
--analyze
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 图片优化参数
|
|
146
|
+
|
|
147
|
+
| 参数 | 说明 | 默认 |
|
|
148
|
+
| ------------------------- | ------------------------- | ---------- |
|
|
149
|
+
| `--compress-images` | 启用图片压缩(pngquant) | 需显式开启 |
|
|
150
|
+
| `--image-quality <0-100>` | 压缩质量(底层 pngquant) | 85 |
|
|
151
|
+
| `--convert-webp` | 将 PNG/JPG 转换为 WebP | 默认开启 |
|
|
152
|
+
| `--no-convert-webp` | 禁用 WebP 转换 | — |
|
|
153
|
+
|
|
154
|
+
**pngquant 说明**:`--compress-images` 使用 `imagemin-pngquant` 进行 PNG 调色板量化,可减少 30-50% 体积,无明显视觉损失(对像素艺术效果更好)。
|
|
155
|
+
|
|
156
|
+
**WebP 说明**:`--convert-webp` 将图片转换为 WebP 格式,比 PNG 减少 60-75%,比 JPG 减少 25-34%,且支持透明通道。现代移动端浏览器均支持。
|
|
157
|
+
|
|
158
|
+
### 模型优化参数
|
|
159
|
+
|
|
160
|
+
| 参数 | 说明 |
|
|
161
|
+
| ----------------------------- | ------------------------------------- |
|
|
162
|
+
| `--compress-models` | 启用 3D 模型压缩 |
|
|
163
|
+
| `--model-compression draco` | 使用 Draco 几何压缩(通用,广泛支持) |
|
|
164
|
+
| `--model-compression meshopt` | 使用 MeshOptimizer(更高压缩比) |
|
|
165
|
+
|
|
166
|
+
### JS/CSS 优化参数
|
|
167
|
+
|
|
168
|
+
| 参数 | 说明 |
|
|
169
|
+
| -------------- | ----------------------------- |
|
|
170
|
+
| `--js-minify` | 启用 JS 压缩(Terser + 混淆) |
|
|
171
|
+
| `--css-minify` | 启用 CSS 压缩 |
|
|
172
|
+
|
|
173
|
+
### 多平台批量构建
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# 同时构建多个平台版本
|
|
177
|
+
playcraft build-all . \
|
|
178
|
+
--platforms facebook,google,applovin \
|
|
179
|
+
--compress-images \
|
|
180
|
+
--image-quality 85 \
|
|
181
|
+
--convert-webp \
|
|
182
|
+
--js-minify \
|
|
183
|
+
--output dist/
|
|
184
|
+
|
|
185
|
+
# 或按平台组
|
|
186
|
+
playcraft build-all . \
|
|
187
|
+
--group mainstream \ # 主流平台
|
|
188
|
+
--compress-images \
|
|
189
|
+
--convert-webp
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## 3. 正确的优化执行顺序
|
|
195
|
+
|
|
196
|
+
**关键原则**:避免对同一文件多次执行有损压缩(每次有损压缩都会叠加质量损失)。
|
|
197
|
+
|
|
198
|
+
```
|
|
199
|
+
正确顺序:
|
|
200
|
+
1. 检查原始资产总大小
|
|
201
|
+
↓
|
|
202
|
+
2. 3D 模型压缩(draco/meshopt)— 无损几何优化
|
|
203
|
+
↓
|
|
204
|
+
3. playcraft build --convert-webp — PNG→WebP(一次有损转换)
|
|
205
|
+
↓
|
|
206
|
+
4. playcraft build --compress-images --image-quality 85 — pngquant(针对非 WebP 的 PNG)
|
|
207
|
+
↓
|
|
208
|
+
5. playcraft build --js-minify --css-minify — 代码压缩
|
|
209
|
+
↓
|
|
210
|
+
6. 检查最终文件大小(必须 < 5 MB)
|
|
211
|
+
↓
|
|
212
|
+
7. 合规验证清单(§1)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**禁止行为**:
|
|
216
|
+
|
|
217
|
+
- 不要先用 `playcraft image convert --format webp` 手动转换,再用 `--convert-webp` 构建(双重转换)
|
|
218
|
+
- 不要对同一图片多次运行 `--compress-images`(每次都会损失质量)
|
|
219
|
+
- 生产阶段(Artist/TA)产出应保持 PNG 格式,优化阶段统一转换
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## 4. 单文件优化(构建后问题文件处理)
|
|
224
|
+
|
|
225
|
+
当某个文件体积异常大时,可单独优化:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# 查看问题文件大小
|
|
229
|
+
playcraft image info --input assets/images/bg/background.png --json
|
|
230
|
+
|
|
231
|
+
# 单文件转 WebP(有损,质量 85)
|
|
232
|
+
playcraft image convert \
|
|
233
|
+
--input assets/images/bg/background.png \
|
|
234
|
+
--output assets/images/bg/background.webp \
|
|
235
|
+
--format webp \
|
|
236
|
+
--quality 85
|
|
237
|
+
|
|
238
|
+
# 单文件转 WebP(无损,适合 UI 元素和像素艺术)
|
|
239
|
+
playcraft image convert \
|
|
240
|
+
--input assets/images/ui/button.png \
|
|
241
|
+
--output assets/images/ui/button.webp \
|
|
242
|
+
--format webp \
|
|
243
|
+
--lossless
|
|
244
|
+
|
|
245
|
+
# 音频压缩(降低比特率)
|
|
246
|
+
playcraft audio compress \
|
|
247
|
+
--input assets/audio/bgm/main_theme.mp3 \
|
|
248
|
+
--output assets/audio/bgm/main_theme_compressed.mp3 \
|
|
249
|
+
--bitrate 96k \
|
|
250
|
+
--mono
|
|
251
|
+
|
|
252
|
+
# 3D 模型优化
|
|
253
|
+
playcraft 3d optimize \
|
|
254
|
+
--input assets/models/character.glb \
|
|
255
|
+
--output assets/models/character_optimized.glb \
|
|
256
|
+
--texture-size 512
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 5. 优化报告格式
|
|
262
|
+
|
|
263
|
+
完成优化后,写入 `logs/optimizer-log.md`:
|
|
264
|
+
|
|
265
|
+
```markdown
|
|
266
|
+
# Optimizer Log
|
|
267
|
+
|
|
268
|
+
## 构建信息
|
|
269
|
+
|
|
270
|
+
- 平台:{{platform}}
|
|
271
|
+
- 构建时间:{{timestamp}}
|
|
272
|
+
- 最终文件大小:{{size_mb}} MB(限制:5 MB)
|
|
273
|
+
- 构建状态:{{pass/fail}}
|
|
274
|
+
|
|
275
|
+
## 资产优化摘要
|
|
276
|
+
|
|
277
|
+
| 资产类型 | 优化前总大小 | 优化后总大小 | 压缩率 |
|
|
278
|
+
| ------------------ | ------------- | ------------ | ---------- |
|
|
279
|
+
| 图片(PNG → WebP) | {{before}} MB | {{after}} MB | {{ratio}}% |
|
|
280
|
+
| 3D 模型 | {{before}} MB | {{after}} MB | {{ratio}}% |
|
|
281
|
+
| 音频 | {{before}} MB | {{after}} MB | {{ratio}}% |
|
|
282
|
+
| JS/CSS | {{before}} KB | {{after}} KB | {{ratio}}% |
|
|
283
|
+
|
|
284
|
+
## 合规验证结果
|
|
285
|
+
|
|
286
|
+
- [ ] 文件大小 ≤ 5 MB
|
|
287
|
+
- [ ] 零外部请求
|
|
288
|
+
- [ ] Meta CTA API 实现(FbPlayableAd.onCTAClick)
|
|
289
|
+
- [ ] Google CTA API 实现(ExitApi.exit)
|
|
290
|
+
- [ ] 音频无自动播放
|
|
291
|
+
|
|
292
|
+
## 问题与建议
|
|
293
|
+
|
|
294
|
+
{{如有超限或合规问题,在此列出并给出修复建议}}
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## 6. 常见审核被拒原因速查
|
|
300
|
+
|
|
301
|
+
| 被拒原因 | 占比 | 检查方法 | 修复方法 |
|
|
302
|
+
| ----------------- | ---- | ------------------------ | ------------------------------------------------------- |
|
|
303
|
+
| 文件大小超过 5 MB | 45% | `ls -lh dist/index.html` | `--compress-images --convert-webp` 或降低 image-quality |
|
|
304
|
+
| 包含外部请求 | 30% | `grep -r "https://"` | Developer 将外部资源内嵌 |
|
|
305
|
+
| CTA 未实现 | 15% | `grep "FbPlayableAd"` | Developer 添加平台 CTA API |
|
|
306
|
+
| 音频自动播放 | 10% | `grep "autoplay"` | Developer 改为用户交互触发 |
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playcraft-image-generation
|
|
3
|
+
description: PlayCraft AI 图片生成核心决策指南。涵盖模型选择决策树、核心命令模板、背景处理决策树(绿幕策略)、脚本决策规则。精灵图直出/Edit 模型/错误恢复/批量实践等进阶内容见 refs/ta-image-generation-detail.md。
|
|
4
|
+
triggers: 生成图片,generate image,选模型,model selection,reference image,参考图,风格一致,图生图,文生图,AI生图,图片质量,模型选择,500错误,模型失败,generate-image,list-image-models,ta-workspace,batch,批量,脚本,nodejs,edit模型,变体,绿幕,去背景,透明PNG,prompt,提示词,prompt套路,提示词技巧
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PlayCraft AI 图片生成指南
|
|
8
|
+
|
|
9
|
+
## 0. 开始前必读
|
|
10
|
+
|
|
11
|
+
生图前**必须先运行模型发现命令**:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
playcraft tools list-image-models
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
输出示例:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
MODEL CAPABILITY ALPHA PROVIDERS
|
|
21
|
+
gpt-image-2 text+image no 3 (iegg-litellm, mulerouter, 302)
|
|
22
|
+
gemini-3.1-flash-image-preview text+image no 2 (google, iegg-litellm)
|
|
23
|
+
hy-image-v3.0 text+image no 1 (tencent-cloud)
|
|
24
|
+
flux-kontext-pro text+image no 1 (302)
|
|
25
|
+
qwen-image-edit-max image→image no 1 (mulerouter)
|
|
26
|
+
...
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**列说明**:
|
|
30
|
+
|
|
31
|
+
- `CAPABILITY`:`text→image` 仅文生图 / `image→image` 仅图生图 / `text+image` 两者均支持
|
|
32
|
+
- `ALPHA`:`yes` = 原生透明 PNG;`no` = 需使用绿幕策略(见第 3 节)
|
|
33
|
+
- `PROVIDERS`:支持该模型的 provider 数量,多个 provider 时后端按优先级自动 fallback(顺序尝试,首个成功即返回)
|
|
34
|
+
|
|
35
|
+
**Prompt 套路速查**:[reference/prompt-cookbook.md](reference/prompt-cookbook.md)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 1. 模型选择决策树
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
需要生图?
|
|
43
|
+
├─ 追求最高质量(概念图、精品单图)?
|
|
44
|
+
│ └─ gpt-image-2(3 个 provider 自动 fallback:iegg-litellm → mulerouter → 302)
|
|
45
|
+
│
|
|
46
|
+
├─ 需要 --reference-image(风格一致性批量生产)?
|
|
47
|
+
│ └─ 必须选 CAPABILITY = text+image 或 image→image 的模型
|
|
48
|
+
│
|
|
49
|
+
├─ 同类元素批量生成(<=16 个)?
|
|
50
|
+
│ └─ 精灵图直出策略(见进阶参考)
|
|
51
|
+
│
|
|
52
|
+
├─ 结构相似的变体集(换花色/换数字/换颜色)?
|
|
53
|
+
│ └─ Edit 模型工作流(见进阶参考)
|
|
54
|
+
│
|
|
55
|
+
└─ 不确定?
|
|
56
|
+
└─ 先试 gpt-image-2,失败换 gemini-3.1-flash-image-preview
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 主要模型特性
|
|
60
|
+
|
|
61
|
+
| 模型 | 特点与优势 | 最佳场景 | 速度 | 注意事项 |
|
|
62
|
+
| ---------------------------------- | ------------------------------------------------------------------------------------------- | ----------------------------------------------- | ------------------------------- | --------------------------------------------------------------- |
|
|
63
|
+
| **gpt-image-2** | 细节最丰富、光影最真实、网格/布局理解力最强、中文字符准确率最高、3 provider fallback 容错高 | 概念图、精灵图直出、含文字素材、写实/半写实风格 | 慢(7-8min/张),**不设 timeout** | 慢是正常的;只有 `API 500` / `fetch failed` 才切换下一 provider |
|
|
64
|
+
| **gemini-3.1-flash-image-preview** | 速度快、色彩鲜艳、构图清晰、最稳定不易报错、reference-image 理解好 | 快速迭代、扁平卡通、明亮休闲风、超时回退 | 快(<30s) | 精细细节和文字不如 gpt-image-2 |
|
|
65
|
+
| **hy-image-v3.0** | 亚洲审美偏向、角色设计好、Q版/IP风格擅长 | 中国风、Q版角色、IP 形象 | 中等 | 西方写实风格表现一般 |
|
|
66
|
+
| **flux-kontext-pro** | 艺术感强、风格独特、手绘质感好 | 艺术插画、手绘风、独特画风探索 | 中等 | 网格理解弱,不适合精灵图 |
|
|
67
|
+
| **nano-banana-2** | 最快、适合简单图形探索 | 简洁图标、平面设计、快速草稿 | 极快 | 中文字符不可靠、细节少 |
|
|
68
|
+
| **qwen-image-edit-max** | 图生图编辑能力强、局部修改精确 | 换花色/换数字/换颜色等结构相似变体 | 中等 | CAPABILITY=image→image,必须传 reference-image |
|
|
69
|
+
| **wan2.6-image** | 风格迁移能力好 | 将参考图风格应用到新内容 | 中等 | CAPABILITY=image→image,必须传 reference-image |
|
|
70
|
+
|
|
71
|
+
### 选型口诀
|
|
72
|
+
|
|
73
|
+
- 追求质量 / 含文字 / 网格图 → `gpt-image-2`
|
|
74
|
+
- 快速迭代 / 扁平风格 / 回退备选 → `gemini-3.1-flash-image-preview`
|
|
75
|
+
- 中国风 / Q版 / 亚洲审美 → `hy-image-v3.0`
|
|
76
|
+
- 艺术/手绘探索 → `flux-kontext-pro`
|
|
77
|
+
- 纯 edit 变体 → `qwen-image-edit-max`
|
|
78
|
+
- 一切都失败 → `gemini-3.1-flash-image-preview`(最稳定)
|
|
79
|
+
|
|
80
|
+
### 为什么精灵图直出是首选批量策略?
|
|
81
|
+
|
|
82
|
+
精灵图直出(一次 API 调用生成一张包含 N 个元素的网格图,再 sprite-split 切分)优于逐个生成,原因有三:
|
|
83
|
+
|
|
84
|
+
1. **成本**:一次 API 调用可包含 4-16 个元素,而逐个生成 N 个元素需要 N 次调用,成本和耗时线性增长。
|
|
85
|
+
2. **风格一致性**:同一张图中的所有元素共享相同的生成上下文,天然保证色调、线条、阴影风格统一,避免逐个生成时每张图风格漂移的问题。
|
|
86
|
+
3. **无逐元素偏差**:逐个生成时即使用相同 prompt,模型每次采样结果都不同,元素之间会出现肉眼可见的不一致;精灵图在一次推理中完成,消除了这种 per-element drift。
|
|
87
|
+
|
|
88
|
+
详细策略与代码示例见进阶参考。
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## 2. 核心命令
|
|
93
|
+
|
|
94
|
+
### 文生图(text-to-image)
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
playcraft tools generate-image \
|
|
98
|
+
--prompt "A golden sword icon, flat 2D vector style, centered composition" \
|
|
99
|
+
--output assets/images/sword.png \
|
|
100
|
+
--aspect-ratio 1:1 \
|
|
101
|
+
--image-size 4K \
|
|
102
|
+
--image-model gpt-image-2
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 图生图(image-to-image / reference-image)
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
playcraft tools generate-image \
|
|
109
|
+
--prompt "A similar style silver shield icon, same art direction" \
|
|
110
|
+
--output assets/images/shield.png \
|
|
111
|
+
--reference-image assets/images/sword.png \
|
|
112
|
+
--aspect-ratio 1:1 \
|
|
113
|
+
--image-size 4K \
|
|
114
|
+
--image-model gpt-image-2
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 参数说明
|
|
118
|
+
|
|
119
|
+
| 参数 | 值 | 说明 |
|
|
120
|
+
| ---------------------- | ----------------------------------------- | ------------------------------------------------------- |
|
|
121
|
+
| `--aspect-ratio` | `1:1` / **`45:16`** / `16:9` / `9:16` / … | **Master Composite(5×9:16 横排)用 `45:16`** |
|
|
122
|
+
| `--width` / `--height` | 像素整数(成对) | MC 推荐 **`3600×1280`** 或 **`4096×1455`** |
|
|
123
|
+
| `--image-size` | `1K` / `2K` / `4K` | 控制分辨率级别。实际像素取决于模型+比例的组合(见下表) |
|
|
124
|
+
|
|
125
|
+
**`--image-size` 对 gpt-image-2 的落盘尺寸**(MuleRouter 请求 `size=auto`,由后端 letterbox 到目标像素):
|
|
126
|
+
|
|
127
|
+
| aspectRatio | 1K | 2K | 4K |
|
|
128
|
+
| ----------------------------- | --------- | ------------- | ------------- |
|
|
129
|
+
| 1:1 | 1024x1024 | 2048x2048 | 2048x2048 |
|
|
130
|
+
| **45:16** (5×9:16 故事板横排) | 2048x728 | **3600x1280** | **4096x1455** |
|
|
131
|
+
| 16:9 | 2048x1152 | 2048x1152 | 3840x2160 |
|
|
132
|
+
| 9:16 | 2160x3840 | 2160x3840 | 2160x3840 |
|
|
133
|
+
| 3:2 / 4:3 | 1536x1024 | 1536x1024 | 1536x1024 |
|
|
134
|
+
| 21:9 | 2048x1152 | 3840x2160 | 3840x2160 |
|
|
135
|
+
|
|
136
|
+
> **IEGG LiteLLM** 在 fallback 链中排第一,但 Azure gpt-image 最大约 1536px 宽 — 达不到 5×9:16 横排。故事板请用 **`mulerouter/gpt-image-2`**(跳过 litellm)+ `--width 3600 --height 1280`(或 4096×1455)。
|
|
137
|
+
|
|
138
|
+
### Master Composite(MC)模型白名单
|
|
139
|
+
|
|
140
|
+
Artist 生成 MC 时**不得**套用上方通用决策树里的 gemini / flux / hy-image 等——MC 只允许:
|
|
141
|
+
|
|
142
|
+
| 允许 | 禁止(MC) |
|
|
143
|
+
| -------------------------- | --------------------------------------------------- |
|
|
144
|
+
| `mulerouter/gpt-image-2` | `gemini-*`、`flux-*`、`hy-image-*`、`wan*`、`qwen*` |
|
|
145
|
+
| `mulerouter/nano-banana-2` | 裸 `gpt-image-2`(会走 iegg-litellm 压扁五格) |
|
|
146
|
+
|
|
147
|
+
完整 prompt / 尺寸规范见 **`playcraft-storyboard`** skill。ASR 双板 `--image-model` 须与已选 MC **完全一致**。
|
|
148
|
+
|
|
149
|
+
**Phase 1(概念图)**:纯文生图,`--image-size 4K` + MC 白名单内模型。
|
|
150
|
+
**Phase 2(批量生产)**:必须带 `--reference-image` 指向 Phase 1 确认的概念图,同一批次使用**相同模型 + 相同 reference image + 相同 image-size**。
|
|
151
|
+
|
|
152
|
+
### --reference-image 路径支持
|
|
153
|
+
|
|
154
|
+
- 本地绝对路径:`/path/to/ref.png`
|
|
155
|
+
- 相对路径(相对 CWD):`assets/images/ref.png`
|
|
156
|
+
- HTTP(S) URL(CLI 自动下载):`"https://images.unsplash.com/photo-xxx"`
|
|
157
|
+
- 多张参考图(重复选项,最多 8 张)
|
|
158
|
+
- 混合本地文件 + URL
|
|
159
|
+
- `search-image` 返回的 `downloadUrl` 可直接使用
|
|
160
|
+
|
|
161
|
+
### 常用辅助命令
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
# 去背景(绿幕建议 tolerance=25;默认白背景可用 15)
|
|
165
|
+
playcraft image remove-background --input in.png --output out.png --tolerance 25
|
|
166
|
+
|
|
167
|
+
# 缩放
|
|
168
|
+
playcraft image resize --input in.png --output out.png --width 128 --height 128
|
|
169
|
+
|
|
170
|
+
# 精灵图切分
|
|
171
|
+
playcraft image sprite-split \
|
|
172
|
+
--input sheet.png --output-dir frames/ \
|
|
173
|
+
--rows 2 --columns 4 \
|
|
174
|
+
--frame-width <总宽/4> --frame-height <总高/2>
|
|
175
|
+
|
|
176
|
+
# 合并精灵图
|
|
177
|
+
playcraft image sprite-sheet \
|
|
178
|
+
--input-dir processed/ --output bundle \
|
|
179
|
+
--columns 8 --background white
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 3. 背景处理决策树
|
|
185
|
+
|
|
186
|
+
> **核心原则**:先确定素材类型,再决定是否需要去背景,再按素材主色调选择色幕颜色,最后做去背景 + 深色背景验证。
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
生成的素材需要做什么?
|
|
190
|
+
│
|
|
191
|
+
├─ 需要透明背景的独立元素(角色、道具、图标、文字图片、HUD、VFX)?
|
|
192
|
+
│ ├─ 检查模型 ALPHA 列(playcraft tools list-image-models)
|
|
193
|
+
│ ├─ ALPHA = yes → prompt 加 "transparent background, PNG with alpha"
|
|
194
|
+
│ └─ ALPHA = no → 色幕策略(按素材主色调选择):
|
|
195
|
+
│ ├─ 素材为金色/黄色/橙色/绿色 → 蓝幕 #0000FF
|
|
196
|
+
│ │ ├─ prompt 末尾加 "on solid bright blue #0000FF background, isolated, centered"
|
|
197
|
+
│ │ └─ 后处理:remove-background(tolerance 25)→ 深色背景验证
|
|
198
|
+
│ ├─ 素材为蓝色/紫色/靛蓝 → 绿幕 #00FF00
|
|
199
|
+
│ │ ├─ prompt 末尾加 "on solid bright green #00FF00 background, isolated, centered"
|
|
200
|
+
│ │ └─ 后处理:remove-background(tolerance 25)→ 深色背景验证
|
|
201
|
+
│ └─ 其他颜色 → 绿幕 #00FF00(默认)
|
|
202
|
+
│ ├─ prompt 末尾加 "on solid bright green #00FF00 background, isolated, centered"
|
|
203
|
+
│ └─ 后处理:remove-background(tolerance 25)→ 深色背景验证
|
|
204
|
+
│
|
|
205
|
+
├─ 卡牌/棋盘格子/UI 面板(本身就是矩形有边框)?
|
|
206
|
+
│ ├─ 不要去背景!白色牌面就是牌的一部分
|
|
207
|
+
│ ├─ prompt 加 "flat 2D, no drop shadow, no 3D effect, clean edges"
|
|
208
|
+
│ └─ 后处理:直接 resize(skipRemoveBg = true)
|
|
209
|
+
│
|
|
210
|
+
└─ 场景背景(天空、地面、全屏图)?
|
|
211
|
+
├─ 不做背景处理,直接 resize
|
|
212
|
+
└─ ⚠️ prompt 必须加 "full bleed, edge to edge, no vignette, no fade"
|
|
213
|
+
→ 后处理验证:四角四边颜色一致,无褪色/白色
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### 为什么需要色幕策略?
|
|
217
|
+
|
|
218
|
+
**当前所有已接入模型均不支持原生透明 PNG(ALPHA = no)**。白色背景 + 白色物体 = floodfill 无法区分边界。纯色背景 + 非撞色游戏素材 = 抠图几乎完美。与影视 chroma-key 原理相同。
|
|
219
|
+
|
|
220
|
+
### 色幕选型矩阵(Color Conflict Avoidance)
|
|
221
|
+
|
|
222
|
+
> ⚠️ **不要默认全用绿幕!** 金色素材 + 绿幕 = 绿色与金色色相接近,floodfill 会在边缘残留绿色,或误删金色像素。
|
|
223
|
+
|
|
224
|
+
| 素材主色调 | ❌ 禁用 | ✅ 推荐 | 原因 |
|
|
225
|
+
| --------------------- | ------- | ---------------- | ------------------------------------------ |
|
|
226
|
+
| 金色/黄色/橙色/琥珀色 | 绿幕 | **蓝幕 #0000FF** | 金色与绿色色相接近(黄绿区),边缘残留绿色 |
|
|
227
|
+
| 绿色/翠绿/青色 | 绿幕 | **蓝幕 #0000FF** | 同色系,无法区分边界 |
|
|
228
|
+
| 蓝色/靛蓝/紫色 | 蓝幕 | **绿幕 #00FF00** | 同色系冲突 |
|
|
229
|
+
| 红色/粉色/白色/黑色 | — | 绿幕或蓝幕均可 | 与两者色相距离都大 |
|
|
230
|
+
| 多色/彩虹 | — | **品红 #FF00FF** | 品红在自然素材中最少出现(最后手段) |
|
|
231
|
+
|
|
232
|
+
### Prompt 后缀速查表
|
|
233
|
+
|
|
234
|
+
| 素材类型 | prompt 建议后缀 | 后处理 | skipRemoveBg |
|
|
235
|
+
| -------------------------- | ------------------------------------------------------------------- | ------------------------------------------- | ------------ |
|
|
236
|
+
| 独立元素(需透明,非金色) | `"on solid bright green #00FF00 background, isolated, centered"` | remove-background (tolerance 25) → 深色验证 | `false` |
|
|
237
|
+
| 独立元素(金/黄/橙/绿色) | `"on solid bright blue #0000FF background, isolated, centered"` | remove-background (tolerance 25) → 深色验证 | `false` |
|
|
238
|
+
| 独立元素(多色/彩虹) | `"on solid bright magenta #FF00FF background, isolated, centered"` | remove-background (tolerance 20) → 深色验证 | `false` |
|
|
239
|
+
| VFX 特效(发光/粒子) | `"on solid bright blue #0000FF background, isolated, centered"` | remove-background (tolerance 25) → 逐帧验证 | `false` |
|
|
240
|
+
| 卡牌/棋子(矩形本体) | `"flat 2D, no shadow, no 3D effect, clean edges, white background"` | 只做 resize | `true` |
|
|
241
|
+
| UI 按钮/面板 | `"flat UI element, no shadow, clean edges"` | trim + resize | `true` |
|
|
242
|
+
| 场景背景 | `"full scene, full bleed, edge to edge, no vignette, no fade"` | resize → 四角全覆盖检查 | `true` |
|
|
243
|
+
|
|
244
|
+
### 去背景后必做:深色背景渲证
|
|
245
|
+
|
|
246
|
+
> 每个需要透明的资产,去背景后**必须**在深色背景上叠合验证。这一步是防止白底/色幕残留/黑块的最后防线。
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
playcraft image overlay \
|
|
250
|
+
--base ta-workspace/tmp/dark_verify_bg.png \
|
|
251
|
+
--overlay <processed>.png \
|
|
252
|
+
--output ta-workspace/tmp/verify_<name>.png \
|
|
253
|
+
--gravity center
|
|
254
|
+
# 目视检查:无白边、无色幕残留色、无黑色不透明块、边缘干净
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**不通过时的修复**:见 `ta-pipeline-cookbook.md` Step 0e §3 及 Compliance Gate 失败修复表。
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## 3.1 ASR 专用分支(Artist · ring 3 build)
|
|
262
|
+
|
|
263
|
+
> **Read `playcraft-asset-state-sheet` Skill first.** ASR 是制作期参考板,不是 runtime 透明资产。
|
|
264
|
+
|
|
265
|
+
| 阶段 | Artist | TA |
|
|
266
|
+
| ----------------- | ------------------------------------- | ----------------------------- |
|
|
267
|
+
| ASR 整图 | **opaque**(灰底或统一色幕)— 正常 | — |
|
|
268
|
+
| ASR 格内元素 | **isolated** + 按色幕矩阵选 cell 背景 | `crop` 后 `remove-background` |
|
|
269
|
+
| remove-background | **禁止** — Artist 不做 | production Wave 2 |
|
|
270
|
+
|
|
271
|
+
**Artist ASR prompt 要点**:
|
|
272
|
+
|
|
273
|
+
1. Sheet canvas:`solid flat #808080` 或整板统一绿幕(非渐变)
|
|
274
|
+
2. 每格:`ONE isolated element, centered, NO white box, NO scene, NO ground shadow`
|
|
275
|
+
3. 金/橙/黄/绿元素格 → cell 背景 `#0000FF`;蓝/紫 → `#00FF00`
|
|
276
|
+
4. 生成后**目视**格内可抠性 — 不要求 `channels=4`(那是 TA 后处理产物)
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## 4. 脚本决策
|
|
281
|
+
|
|
282
|
+
- **<=5 个文件** → 直接使用 CLI 命令
|
|
283
|
+
- **>5 个文件** → 编写 Node.js 脚本放入 `ta-workspace/scripts/`。脚本模板见 `reference/` 目录。
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 5. 进阶参考
|
|
288
|
+
|
|
289
|
+
需要以下进阶内容时,查阅 [`refs/ta-image-generation-detail.md`](../../agents/refs/ta-image-generation-detail.md):
|
|
290
|
+
|
|
291
|
+
| 主题 | 说明 |
|
|
292
|
+
| --------------------- | ------------------------------------------------------------------- |
|
|
293
|
+
| 精灵图直出策略 | gpt-image-2 网格图生成 + sprite-split 切分,白底/绿幕示例,分批策略 |
|
|
294
|
+
| Edit 模型工作流 | 基图 → edit 变体(换花色/换数字/换颜色),prompt 写法 |
|
|
295
|
+
| 错误恢复表 | 各类错误现象、原因、立即行动;模型回退顺序 |
|
|
296
|
+
| Provider 回退链 | gpt-image-2 三 provider 互为回退 + 非 gpt-image-2 稳定回退 |
|
|
297
|
+
| 批量生成最佳实践 | 单张验证、Node.js 脚本推荐、脚本模板使用 |
|
|
298
|
+
| ta-workspace 脚本驱动 | 为什么用 Node.js、目录约定、脚本模板一览表 |
|