@playcraft/cli 0.0.39 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -3
- package/dist/atom-plan/validate-atom-plan.js +298 -0
- package/dist/cli-root-help.js +1 -1
- package/dist/commands/3d.js +363 -0
- package/dist/commands/create.js +337 -0
- package/dist/commands/fix-ids.js +17 -3
- package/dist/commands/fix-ids.test.js +264 -0
- package/dist/commands/image.js +1337 -43
- package/dist/commands/login.js +60 -2
- package/dist/commands/recommend.js +1 -1
- package/dist/commands/remix.js +213 -0
- package/dist/commands/skills.js +1379 -0
- package/dist/commands/tools-3d.js +473 -0
- package/dist/commands/tools-generation.js +454 -0
- package/dist/commands/tools-project.js +400 -0
- package/dist/commands/tools-research.js +37 -0
- package/dist/commands/tools-research.test.js +216 -0
- package/dist/commands/tools-utils.js +164 -0
- package/dist/commands/tools.js +7 -616
- package/dist/config.js +2 -0
- package/dist/index.js +20 -2
- package/dist/utils/agent-api-client.js +52 -16
- package/package.json +9 -3
- package/project-template/.claude/agents/designer.md +116 -0
- package/project-template/.claude/agents/developer.md +133 -0
- package/project-template/.claude/agents/pm.md +164 -0
- package/project-template/.claude/agents/refs/README.md +67 -0
- package/project-template/.claude/agents/refs/designer-art-style-catalog.md +533 -0
- package/project-template/.claude/agents/refs/designer-color-audio-recipes.md +153 -0
- package/project-template/.claude/agents/refs/designer-deliverable-spec.md +167 -0
- package/project-template/.claude/agents/refs/designer-dimension-axis.md +27 -0
- package/project-template/.claude/agents/refs/designer-handoff-v2-checklist.md +68 -0
- package/project-template/.claude/agents/refs/designer-master-composite-recipes.md +216 -0
- package/project-template/.claude/agents/refs/designer-style-exploration-flow.md +37 -0
- package/project-template/.claude/agents/refs/developer-dev-handoff.md +109 -0
- package/project-template/.claude/agents/refs/developer-impl-cookbook.md +134 -0
- package/project-template/.claude/agents/refs/developer-phase1-flow.md +211 -0
- package/project-template/.claude/agents/refs/pm-workflow-detail.md +545 -0
- package/project-template/.claude/agents/refs/reviewer-six-dimension-eval.md +286 -0
- package/project-template/.claude/agents/refs/ta-3d-flip-recipe.md +85 -0
- package/project-template/.claude/agents/refs/ta-atlas-deliverable-standard.md +46 -0
- package/project-template/.claude/agents/refs/ta-batch-pipeline-recipes.md +120 -0
- package/project-template/.claude/agents/refs/ta-image-generation-detail.md +356 -0
- package/project-template/.claude/agents/refs/ta-image-ops-reference.md +495 -0
- package/project-template/.claude/agents/refs/ta-pipeline-cookbook.md +699 -0
- package/project-template/.claude/agents/refs/ta-tools-reference.md +111 -0
- package/project-template/.claude/agents/refs/ta-vfx-preset-catalog.md +365 -0
- package/project-template/.claude/agents/reviewer.md +103 -0
- package/project-template/.claude/agents/technical-artist.md +111 -0
- package/project-template/.claude/hooks/README.md +36 -0
- package/project-template/.claude/hooks/validate-atom-plan.mjs +224 -0
- package/project-template/.claude/hooks/validate-workflow-stop.mjs +258 -0
- package/project-template/.claude/settings.json +32 -0
- package/project-template/.claude/settings.local.json +4 -0
- package/project-template/.claude/skills/playcraft-ad-psychology/SKILL.md +182 -0
- package/project-template/.claude/skills/playcraft-art-style-guide/SKILL.md +123 -0
- package/project-template/.claude/skills/playcraft-asset-state-sheet/SKILL.md +141 -0
- package/project-template/.claude/skills/playcraft-audio-generation/SKILL.md +280 -0
- package/project-template/.claude/skills/playcraft-batch-pipeline/SKILL.md +184 -0
- package/project-template/.claude/skills/playcraft-build-optimizer/SKILL.md +306 -0
- package/project-template/.claude/skills/playcraft-image-generation/SKILL.md +229 -0
- package/project-template/.claude/skills/playcraft-image-generation/reference/build-sprite-sheet.template.mjs +123 -0
- package/project-template/.claude/skills/playcraft-image-generation/reference/compare-style.template.mjs +254 -0
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch-sprite.template.mjs +235 -0
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-batch.template.mjs +97 -0
- package/project-template/.claude/skills/playcraft-image-generation/reference/gen-edit-variants.template.mjs +118 -0
- package/project-template/.claude/skills/playcraft-image-generation/reference/process-batch.template.mjs +137 -0
- package/project-template/.claude/skills/playcraft-image-generation/reference/prompt-cookbook.md +397 -0
- package/project-template/.claude/skills/playcraft-image-generation/reference/validate-sprite-sheet.template.mjs +296 -0
- package/project-template/.claude/skills/playcraft-image-ops/SKILL.md +122 -0
- package/project-template/.claude/skills/playcraft-masking/SKILL.md +373 -0
- package/project-template/.claude/skills/playcraft-research/SKILL.md +212 -0
- package/project-template/.claude/skills/playcraft-sprite-generation/SKILL.md +423 -0
- package/project-template/.claude/skills/playcraft-storyboard/SKILL.md +148 -0
- package/project-template/.claude/skills/playcraft-style-qa/SKILL.md +270 -0
- package/project-template/.claude/skills/playcraft-text-rendering/SKILL.md +236 -0
- package/project-template/.claude/skills/playcraft-vfx-animation/SKILL.md +130 -0
- package/project-template/.claude/skills/playcraft-workflow/SKILL.md +396 -0
- package/project-template/.cursor/hooks.json +17 -0
- package/project-template/.cursor/rules/playcraft-orchestrator.mdc +87 -0
- package/project-template/.cursor/rules/playcraft-subagent-boundary.mdc +18 -0
- package/project-template/CLAUDE.md +240 -0
- package/project-template/assets/audio/bgm/.gitkeep +0 -0
- package/project-template/assets/audio/sfx/.gitkeep +0 -0
- package/project-template/assets/bundles/.gitkeep +0 -0
- package/project-template/assets/images/bg/.gitkeep +0 -0
- package/project-template/assets/images/reference/.gitkeep +0 -0
- package/project-template/assets/images/storyboard/.gitkeep +0 -0
- package/project-template/assets/images/tiles/.gitkeep +0 -0
- package/project-template/assets/images/ui/.gitkeep +0 -0
- package/project-template/assets/images/vfx/.gitkeep +0 -0
- package/project-template/assets/models/.gitkeep +0 -0
- package/project-template/docs/team/agent-conduct.md +105 -0
- package/project-template/docs/team/agent-runtime-matrix.md +62 -0
- package/project-template/docs/team/atom-plan-format.md +74 -0
- package/project-template/docs/team/collaboration.md +288 -0
- package/project-template/docs/team/core-model.md +50 -0
- package/project-template/docs/team/platform-capabilities.md +15 -0
- package/project-template/docs/team/workflow-changelog.md +51 -0
- package/project-template/docs/team/workflow-consistency-checklist.md +128 -0
- package/project-template/game/config/.gitkeep +0 -0
- package/project-template/game/gameplay/.gitkeep +0 -0
- package/project-template/game/scenes/.gitkeep +0 -0
- package/project-template/logs/.gitkeep +0 -0
- package/project-template/ta-workspace/logs/.gitkeep +0 -0
- package/project-template/ta-workspace/scripts/.gitkeep +0 -0
- package/project-template/ta-workspace/tmp/.gitkeep +0 -0
- package/project-template/templates/atom-plan.template.json +26 -0
- package/project-template/templates/atom-plan.template.md +76 -0
- package/project-template/templates/design-brief.template.md +195 -0
- package/project-template/templates/design-lens-checklist.reference.md +117 -0
- package/project-template/templates/design-methodology.md +99 -0
- package/project-template/templates/designer-log.template.md +98 -0
- package/project-template/templates/developer-log.template.md +140 -0
- package/project-template/templates/five-axis-framework.md +186 -0
- package/project-template/templates/intent-clarifications.template.md +58 -0
- package/project-template/templates/layout-spec.template.md +132 -0
- package/project-template/templates/project-state.template.md +219 -0
- package/project-template/templates/review-report.template.md +166 -0
- package/project-template/templates/style-exploration.template.md +93 -0
- package/project-template/templates/ta-log.template.md +205 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playcraft-audio-generation
|
|
3
|
+
description: PlayCraft AI 音频生成完整指南。涵盖 SFX 音效生成、BGM 背景音乐生成(prompt 套路、时长、风格参数)、本地音频后处理(compress/fade/loop/normalize/mix),以及完整的音频管线。Designer 和 TA 在生成音频资产前必读。
|
|
4
|
+
triggers: 生成音效,生成bgm,生成背景音乐,generate sfx,generate bgm,generate audio,音频,音效,背景音乐,sfx,bgm,loop音频,音频压缩,音频处理,audio,compress audio,fade,normalize,音频后处理,音频管线
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PlayCraft AI 音频生成指南
|
|
8
|
+
|
|
9
|
+
## 0. 开始前必读
|
|
10
|
+
|
|
11
|
+
音频资产分两类,使用不同工具:
|
|
12
|
+
|
|
13
|
+
| 类型 | 工具 | 是否需要后端 |
|
|
14
|
+
| ------------------ | ------------------------------ | ------------ |
|
|
15
|
+
| AI 生成音效(SFX) | `playcraft tools generate-sfx` | 是 |
|
|
16
|
+
| AI 生成 BGM | `playcraft tools generate-bgm` | 是 |
|
|
17
|
+
| 本地音频处理 | `playcraft audio <子命令>` | 否 |
|
|
18
|
+
|
|
19
|
+
> ⚠️ **重要**:`generate-sfx` 的 `--prompt` **只支持英文**。BGM 的 prompt 可以用中文描述风格,但英文效果更稳定。
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 1. SFX 音效生成
|
|
24
|
+
|
|
25
|
+
### 基本用法
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
playcraft tools generate-sfx \
|
|
29
|
+
--prompt "short coin collect chime, game UI, bright and crisp" \
|
|
30
|
+
--output assets/audio/sfx/coin.mp3 \
|
|
31
|
+
--duration 1.0
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 常用参数
|
|
35
|
+
|
|
36
|
+
| 参数 | 说明 | 建议值 |
|
|
37
|
+
| ------------ | --------------------------- | -------------------------- |
|
|
38
|
+
| `--prompt` | 音效描述(**必须英文**) | 见下方 prompt 套路 |
|
|
39
|
+
| `--output` | 保存路径(`.mp3` / `.wav`) | — |
|
|
40
|
+
| `--duration` | 时长(秒) | SFX:0.3–3.0;环境音:3–10 |
|
|
41
|
+
| `--loop` | 是否循环友好 | 环境音、引擎声用 `--loop` |
|
|
42
|
+
|
|
43
|
+
### SFX Prompt 套路
|
|
44
|
+
|
|
45
|
+
**结构**:`[音效描述], [场景/用途], [音色特征], [可选:情绪/风格]`
|
|
46
|
+
|
|
47
|
+
| 用途 | Prompt 示例 |
|
|
48
|
+
| -------------- | -------------------------------------------------------------------------- |
|
|
49
|
+
| UI 点击 | `"button click, game UI, soft and satisfying, short"` |
|
|
50
|
+
| 金币收集 | `"coin collect chime, arcade game, bright metallic, 0.5 seconds"` |
|
|
51
|
+
| 爆炸 | `"explosion impact, action game, deep bass rumble with debris scatter"` |
|
|
52
|
+
| 卡牌翻转 | `"card flip whoosh, card game, crisp paper sound"` |
|
|
53
|
+
| 胜利提示 | `"victory fanfare, casual mobile game, cheerful and upbeat, short jingle"` |
|
|
54
|
+
| 失败提示 | `"fail sound, game over, descending tone, simple"` |
|
|
55
|
+
| 跳跃 | `"jump sound, platform game, light spring bounce"` |
|
|
56
|
+
| 魔法施放 | `"magic spell cast, fantasy game, sparkling shimmer with whoosh"` |
|
|
57
|
+
| 麻将碰牌 | `"mahjong tile click, ceramic tap sound, sharp and clear"` |
|
|
58
|
+
| 环境音(循环) | `"forest ambient, birds chirping, peaceful, seamless loop"` |
|
|
59
|
+
|
|
60
|
+
**质量修饰词**(加在末尾):
|
|
61
|
+
|
|
62
|
+
- 追求干净:`"clean, no reverb, game-ready"`
|
|
63
|
+
- 追求丰富:`"rich, layered, cinematic"`
|
|
64
|
+
- 追求复古:`"8-bit, chiptune, retro game"`
|
|
65
|
+
|
|
66
|
+
### 批量 SFX 生成脚本
|
|
67
|
+
|
|
68
|
+
```javascript
|
|
69
|
+
// ta-workspace/scripts/gen-sfx.mjs
|
|
70
|
+
import { execSync } from "child_process";
|
|
71
|
+
import { existsSync } from "fs";
|
|
72
|
+
|
|
73
|
+
const OUTPUT_DIR = "assets/audio/sfx";
|
|
74
|
+
const SFX_LIST = [
|
|
75
|
+
{
|
|
76
|
+
name: "coin",
|
|
77
|
+
prompt: "coin collect chime, arcade game, bright metallic, 0.5 seconds",
|
|
78
|
+
duration: 0.5,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: "click",
|
|
82
|
+
prompt: "button click, game UI, soft satisfying, short",
|
|
83
|
+
duration: 0.3,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "win",
|
|
87
|
+
prompt: "victory fanfare, casual mobile game, cheerful upbeat jingle",
|
|
88
|
+
duration: 2.0,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "fail",
|
|
92
|
+
prompt: "fail sound, game over, descending tone, simple",
|
|
93
|
+
duration: 1.5,
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
name: "jump",
|
|
97
|
+
prompt: "jump sound, platform game, light spring bounce",
|
|
98
|
+
duration: 0.4,
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
for (const sfx of SFX_LIST) {
|
|
103
|
+
const output = `${OUTPUT_DIR}/${sfx.name}.mp3`;
|
|
104
|
+
if (existsSync(output)) {
|
|
105
|
+
console.log(`[SKIP] ${sfx.name}`);
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
console.log(`[GEN] ${sfx.name}...`);
|
|
109
|
+
execSync(
|
|
110
|
+
`playcraft tools generate-sfx --prompt "${sfx.prompt}" --output "${output}" --duration ${sfx.duration}`,
|
|
111
|
+
{ stdio: "inherit" },
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## 2. BGM 背景音乐生成
|
|
119
|
+
|
|
120
|
+
### 基本用法
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
playcraft tools generate-bgm \
|
|
124
|
+
--prompt "upbeat casual mobile game, playful and energetic, suitable for a card matching game" \
|
|
125
|
+
--output assets/audio/bgm/main_theme.mp3 \
|
|
126
|
+
--bpm 120
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 常用参数
|
|
130
|
+
|
|
131
|
+
| 参数 | 说明 | 建议值 |
|
|
132
|
+
| ---------- | ------------ | ---------------------------------------------- |
|
|
133
|
+
| `--prompt` | 音乐风格描述 | 见下方 prompt 套路 |
|
|
134
|
+
| `--output` | 保存路径 | — |
|
|
135
|
+
| `--bpm` | 节拍速度 | 轻松:90–110;激烈:130–160 |
|
|
136
|
+
| `--style` | 附加风格标签 | `"electronic"` / `"orchestral"` / `"chiptune"` |
|
|
137
|
+
|
|
138
|
+
### BGM Prompt 套路
|
|
139
|
+
|
|
140
|
+
**结构**:`[游戏类型], [情绪基调], [乐器风格], [可选:特定场景]`
|
|
141
|
+
|
|
142
|
+
| 场景 | Prompt 示例 | BPM |
|
|
143
|
+
| ------------ | ------------------------------------------------------------------- | --- |
|
|
144
|
+
| 休闲手游主题 | `"casual mobile game, cheerful and bouncy, ukulele and marimba"` | 110 |
|
|
145
|
+
| 扑克牌游戏 | `"card game background, smooth jazz lounge, elegant and relaxed"` | 95 |
|
|
146
|
+
| 麻将游戏 | `"mahjong game, traditional Chinese instruments, calm and focused"` | 85 |
|
|
147
|
+
| 动作游戏 | `"action arcade game, intense and driving, electronic synth drums"` | 145 |
|
|
148
|
+
| 像素风冒险 | `"8-bit adventure game, chiptune style, heroic and nostalgic"` | 130 |
|
|
149
|
+
| 益智解谜 | `"puzzle game, gentle and thoughtful, soft piano and ambient pad"` | 90 |
|
|
150
|
+
| 胜利画面 | `"victory celebration, triumphant fanfare, short and energetic"` | 140 |
|
|
151
|
+
| 菜单/大厅 | `"game lobby menu, welcoming and pleasant, light and airy"` | 100 |
|
|
152
|
+
|
|
153
|
+
### BGM 循环处理(必做!)
|
|
154
|
+
|
|
155
|
+
AI 生成的 BGM 首尾通常不能无缝循环,需要后处理:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# 生成后检查时长
|
|
159
|
+
playcraft audio info --input assets/audio/bgm/main_theme.mp3
|
|
160
|
+
|
|
161
|
+
# 无缝循环处理(交叉淡化 1 秒)
|
|
162
|
+
playcraft audio loop \
|
|
163
|
+
--input assets/audio/bgm/main_theme.mp3 \
|
|
164
|
+
--output assets/audio/bgm/main_theme_loop.mp3 \
|
|
165
|
+
--crossfade 1.0
|
|
166
|
+
|
|
167
|
+
# 验证循环点
|
|
168
|
+
playcraft audio info --input assets/audio/bgm/main_theme_loop.mp3
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 3. 本地音频后处理
|
|
174
|
+
|
|
175
|
+
所有 `playcraft audio` 子命令**完全本地运行**,无需网络。
|
|
176
|
+
|
|
177
|
+
### 3.1 常用处理命令
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# 查看音频信息(时长、体积、比特率、采样率)
|
|
181
|
+
playcraft audio info --input audio.mp3
|
|
182
|
+
|
|
183
|
+
# 压缩(减小文件体积)
|
|
184
|
+
playcraft audio compress \
|
|
185
|
+
--input audio.mp3 \
|
|
186
|
+
--output audio_small.mp3 \
|
|
187
|
+
--target-size 50KB # 或指定比特率 --bitrate 64k
|
|
188
|
+
|
|
189
|
+
# 裁剪(取片段)
|
|
190
|
+
playcraft audio trim \
|
|
191
|
+
--input audio.mp3 \
|
|
192
|
+
--output trimmed.mp3 \
|
|
193
|
+
--start 0 --end 5.0 # 取前 5 秒
|
|
194
|
+
|
|
195
|
+
# 淡入淡出
|
|
196
|
+
playcraft audio fade \
|
|
197
|
+
--input audio.mp3 \
|
|
198
|
+
--output audio_fade.mp3 \
|
|
199
|
+
--fade-in 0.3 \
|
|
200
|
+
--fade-out 0.5
|
|
201
|
+
|
|
202
|
+
# 无缝循环
|
|
203
|
+
playcraft audio loop \
|
|
204
|
+
--input audio.mp3 \
|
|
205
|
+
--output audio_loop.mp3 \
|
|
206
|
+
--crossfade 1.0
|
|
207
|
+
|
|
208
|
+
# 响度标准化(游戏音频建议 -16 LUFS)
|
|
209
|
+
playcraft audio normalize \
|
|
210
|
+
--input audio.mp3 \
|
|
211
|
+
--output audio_norm.mp3 \
|
|
212
|
+
--target-loudness -16
|
|
213
|
+
|
|
214
|
+
# 格式转换(WAV → MP3,或 MP3 → OGG)
|
|
215
|
+
playcraft audio convert \
|
|
216
|
+
--input audio.wav \
|
|
217
|
+
--output audio.mp3
|
|
218
|
+
|
|
219
|
+
# 多轨混音
|
|
220
|
+
playcraft audio mix \
|
|
221
|
+
--inputs bgm.mp3,sfx.mp3 \
|
|
222
|
+
--output mixed.mp3 \
|
|
223
|
+
--volumes 0.7,1.0 # BGM 70%,SFX 100%
|
|
224
|
+
--offsets 0,2.5 # SFX 在 2.5 秒处开始
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### 3.2 标准音频处理管线
|
|
228
|
+
|
|
229
|
+
AI 生成后的**必做处理步骤**:
|
|
230
|
+
|
|
231
|
+
```
|
|
232
|
+
SFX 管线:
|
|
233
|
+
generate-sfx → normalize (-16 LUFS) → compress (目标 <100KB) → convert (.mp3)
|
|
234
|
+
|
|
235
|
+
BGM 管线:
|
|
236
|
+
generate-bgm → normalize (-16 LUFS) → loop (--crossfade 1.0) → compress (目标 <500KB) → convert (.mp3)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
---
|
|
240
|
+
|
|
241
|
+
## 4. 错误恢复策略
|
|
242
|
+
|
|
243
|
+
| 错误现象 | 原因 | 行动 |
|
|
244
|
+
| ------------------------------ | ----------------- | -------------------------------------------- |
|
|
245
|
+
| `generate-sfx` prompt 返回错误 | Prompt 包含中文 | **改为英文** |
|
|
246
|
+
| SFX 时长不准 | AI 生成时长近似值 | 用 `audio trim` 裁剪到精确时长 |
|
|
247
|
+
| BGM 首尾断裂 | AI 未做循环 | **必须跑 `audio loop --crossfade 1.0`** |
|
|
248
|
+
| 音量太小/太大 | 生成音量随机 | `audio normalize --target-loudness -16` |
|
|
249
|
+
| 文件体积太大(>1MB) | 无压缩 | `audio compress --target-size 200KB` |
|
|
250
|
+
| 格式不对 | 项目要求特定格式 | `audio convert --input x.wav --output x.mp3` |
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## 5. 常用命令速查
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# AI 生成 SFX(prompt 必须英文)
|
|
258
|
+
playcraft tools generate-sfx \
|
|
259
|
+
--prompt "coin collect, bright chime, 0.5 seconds" \
|
|
260
|
+
--output sfx/coin.mp3 \
|
|
261
|
+
--duration 0.5
|
|
262
|
+
|
|
263
|
+
# AI 生成 BGM
|
|
264
|
+
playcraft tools generate-bgm \
|
|
265
|
+
--prompt "casual card game, upbeat jazz, relaxed" \
|
|
266
|
+
--output bgm/theme.mp3 \
|
|
267
|
+
--bpm 110
|
|
268
|
+
|
|
269
|
+
# 无缝循环处理(BGM 必做)
|
|
270
|
+
playcraft audio loop --input bgm/theme.mp3 --output bgm/theme_loop.mp3 --crossfade 1.0
|
|
271
|
+
|
|
272
|
+
# 响度标准化(SFX/BGM 推荐)
|
|
273
|
+
playcraft audio normalize --input audio.mp3 --output audio_norm.mp3 --target-loudness -16
|
|
274
|
+
|
|
275
|
+
# 压缩减体积
|
|
276
|
+
playcraft audio compress --input audio.mp3 --output audio_small.mp3 --target-size 100KB
|
|
277
|
+
|
|
278
|
+
# 查看音频信息
|
|
279
|
+
playcraft audio info --input audio.mp3
|
|
280
|
+
```
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: playcraft-batch-pipeline
|
|
3
|
+
description: PlayCraft 批处理管线选型与语法指南。涵盖三种批处理方式的选型决策树(Node.js 脚本 / CLI batch / CLI pipeline)、playcraft image batch 的 steps 语法与已知限制、playcraft image pipeline 的 YAML 配置结构与 assemble 精灵图组装。实用配方见 refs 文件。
|
|
4
|
+
triggers: 批处理,batch,pipeline,批量操作,多文件处理,声明式管线,YAML配置,批量resize,批量转换,批量去背,assemble,精灵图组装,image batch,image pipeline,批量处理,parallel,skip-existing,断点续传
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# PlayCraft 批处理管线指南
|
|
8
|
+
|
|
9
|
+
## 0. 三种批处理方式选型
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
需要批量处理多张图片?
|
|
13
|
+
│
|
|
14
|
+
├─ 涉及 AI 生成(generate-image)或复杂分支逻辑?
|
|
15
|
+
│ └─ → Node.js .mjs 脚本(ta-workspace/scripts/)
|
|
16
|
+
│ 参考:playcraft-image-generation Skill 的 reference/ 模板
|
|
17
|
+
│
|
|
18
|
+
├─ 纯本地图像处理(resize/convert/tint 等),需要并发加速?
|
|
19
|
+
│ └─ → playcraft image batch(本节 §1)
|
|
20
|
+
│
|
|
21
|
+
└─ 需要最终自动打包成精灵图,或用配置文件管理管线?
|
|
22
|
+
└─ → playcraft image pipeline(本节 §2)
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**三种方式对比**:
|
|
26
|
+
|
|
27
|
+
| 特性 | Node.js 脚本 | image batch | image pipeline |
|
|
28
|
+
| -------------- | ------------ | ----------------- | ----------------------- |
|
|
29
|
+
| AI 生成 | 支持 | 不支持 | 不支持 |
|
|
30
|
+
| 并发控制 | 自定义 | `--parallel N` | 顺序 |
|
|
31
|
+
| 断点续传 | 自实现 | `--skip-existing` | 不支持 |
|
|
32
|
+
| 配置复用 | JS 文件 | 命令行 | YAML/JSON 文件 |
|
|
33
|
+
| 自动组装精灵图 | 自实现 | 不支持 | `assemble.sprite-sheet` |
|
|
34
|
+
| 学习成本 | 中 | 低 | 低 |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 1. playcraft image batch — 声明式多步批处理
|
|
39
|
+
|
|
40
|
+
对一个目录(或多个文件)中的所有图片,按顺序执行多个处理步骤。
|
|
41
|
+
|
|
42
|
+
### 基础用法
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
playcraft image batch \
|
|
46
|
+
--input-dir assets/images/raw/ \
|
|
47
|
+
--output-dir assets/images/processed/ \
|
|
48
|
+
--steps "resize --width 256 --height 256, tint --color #FFD700" \
|
|
49
|
+
--parallel 4 --skip-existing
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
| 参数 | 类型 | 说明 |
|
|
53
|
+
| -------------------- | ------ | ---------------------------------------------- |
|
|
54
|
+
| `--input-dir <dir>` | string | 输入目录(与 `--inputs` 二选一) |
|
|
55
|
+
| `--inputs <paths>` | string | 逗号分隔的文件列表(与 `--input-dir` 二选一) |
|
|
56
|
+
| `--glob <pattern>` | string | 文件匹配模式,默认 `*.png,*.jpg,*.jpeg,*.webp` |
|
|
57
|
+
| `--output-dir <dir>` | string | 输出目录(必填)**输出统一为 .png** |
|
|
58
|
+
| `--steps <pipeline>` | string | 处理步骤(必填,见下方语法) |
|
|
59
|
+
| `--parallel <N>` | number | 并发数,默认 4 |
|
|
60
|
+
| `--skip-existing` | flag | 跳过输出目录中已存在的文件(断点续传) |
|
|
61
|
+
|
|
62
|
+
### Steps 语法
|
|
63
|
+
|
|
64
|
+
`--steps` 接受逗号分隔的步骤列表,每步格式为 `子命令名 [参数...]`:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
--steps "resize --width 128 --height 128, grayscale, tint --color #4488FF"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 支持的步骤命令
|
|
71
|
+
|
|
72
|
+
| 可用命令 | 示例 |
|
|
73
|
+
| ------------------- | --------------------------------------------------------- |
|
|
74
|
+
| `resize` | `resize --width 128 --height 128` 或 `resize --scale 0.5` |
|
|
75
|
+
| `convert` | `convert --format webp --quality 85` |
|
|
76
|
+
| `grayscale` | `grayscale` |
|
|
77
|
+
| `blur` | `blur --sigma 5` |
|
|
78
|
+
| `tint` | `tint --color #FFD700` |
|
|
79
|
+
| `trim` | `trim --threshold 20` |
|
|
80
|
+
| `negate` | `negate` |
|
|
81
|
+
| `rotate` | `rotate --angle 90` |
|
|
82
|
+
| `flip` | `flip --direction horizontal` |
|
|
83
|
+
| `pad` | `pad --all 8` |
|
|
84
|
+
| `pixelate` | `pixelate --pixel-size 8` |
|
|
85
|
+
| `remove-background` | `remove-background --method floodfill --tolerance 40` |
|
|
86
|
+
|
|
87
|
+
> **已知限制**:`crop`、`overlay`、`sprite-split`、`sprite-sheet`、`animate`、`use-vfx`、`segment`、`decompose-layers` 不能在 `--steps` 中使用(`segment` / `decompose-layers` 走后端 API)。需要 `crop` 或分层的批量操作请用 for 循环或 Node.js 脚本。
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## 2. playcraft image pipeline — YAML/JSON 声明式管线
|
|
92
|
+
|
|
93
|
+
比 `batch` 更强大:支持配置文件复用、可选自动组装精灵图。
|
|
94
|
+
|
|
95
|
+
### YAML 配置结构
|
|
96
|
+
|
|
97
|
+
```yaml
|
|
98
|
+
# ta-workspace/pipeline_config.yaml
|
|
99
|
+
input:
|
|
100
|
+
dir: assets/images/raw_tiles/
|
|
101
|
+
glob: "*.png"
|
|
102
|
+
|
|
103
|
+
steps:
|
|
104
|
+
- command: resize
|
|
105
|
+
width: 128
|
|
106
|
+
height: 128
|
|
107
|
+
- command: trim
|
|
108
|
+
threshold: 15
|
|
109
|
+
|
|
110
|
+
output:
|
|
111
|
+
dir: assets/images/tiles/
|
|
112
|
+
|
|
113
|
+
assemble: # 可选:处理完后自动组装精灵图
|
|
114
|
+
sprite-sheet:
|
|
115
|
+
output: assets/images/tiles_sprite.png
|
|
116
|
+
columns: 4
|
|
117
|
+
padding: 2
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
执行:`playcraft image pipeline --config ta-workspace/pipeline_config.yaml`(加 `--dry-run` 可预览步骤)
|
|
121
|
+
|
|
122
|
+
### assemble.sprite-sheet 说明
|
|
123
|
+
|
|
124
|
+
配置 `assemble.sprite-sheet` 后,pipeline 完成所有文件处理后,会自动将 `output.dir` 下的所有 `*.png` 合并为一张精灵图(同时生成 `.json` 元数据):
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
assemble:
|
|
128
|
+
sprite-sheet:
|
|
129
|
+
output: assets/images/sprite_atlas.png
|
|
130
|
+
columns: 4 # 每行帧数
|
|
131
|
+
padding: 2 # 帧间距(像素)
|
|
132
|
+
sort: name # 排序方式:name(默认)/ modified / none
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## 3. 何时用哪种方式(完整决策树)
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
需要批量处理?
|
|
141
|
+
│
|
|
142
|
+
├─ 需要 AI 生成(generate-image/generate-3d)?
|
|
143
|
+
│ └─ 用 Node.js 脚本(ta-workspace/scripts/*.mjs)
|
|
144
|
+
│ 参考:playcraft-image-generation SKILL 的 reference/gen-batch.template.mjs
|
|
145
|
+
│
|
|
146
|
+
├─ 只需要本地图像变换(resize/tint/trim/convert/去背等)?
|
|
147
|
+
│ │
|
|
148
|
+
│ ├─ 需要最终合并成精灵图?
|
|
149
|
+
│ │ └─ 用 pipeline(YAML/JSON 配置 + assemble)
|
|
150
|
+
│ │
|
|
151
|
+
│ ├─ 需要并发加速?
|
|
152
|
+
│ │ └─ 用 batch(--parallel N)
|
|
153
|
+
│ │
|
|
154
|
+
│ ├─ 需要断点续传?
|
|
155
|
+
│ │ └─ 用 batch(--skip-existing)
|
|
156
|
+
│ │
|
|
157
|
+
│ └─ 配置需要复用/版本管理?
|
|
158
|
+
│ └─ 用 pipeline(YAML 文件)
|
|
159
|
+
│
|
|
160
|
+
└─ 需要 crop 作为批处理步骤?
|
|
161
|
+
└─ 用 for 循环(batch 不支持 crop):
|
|
162
|
+
for f in dir/*.png; do
|
|
163
|
+
playcraft image crop --input "$f" --output "out/$(basename $f)" \
|
|
164
|
+
--x 0 --y 0 --width 128 --height 128
|
|
165
|
+
done
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## 4. 已知限制汇总
|
|
171
|
+
|
|
172
|
+
| 限制 | 影响 | 绕过方法 |
|
|
173
|
+
| -------------------------------------------------- | ---------------------------------------------------------- | --------------------------------------------- |
|
|
174
|
+
| `batch` 的 `--steps` 不支持 `crop` | 无法在批处理管线中裁切 | 改用 for 循环或 Node.js 脚本 |
|
|
175
|
+
| `batch` 不支持 `overlay`(需要两个输入) | 无法批量合成 | 改用 Node.js 脚本 |
|
|
176
|
+
| `pipeline` 不支持并发(顺序处理) | 大批量时较慢 | 改用 `batch --parallel` |
|
|
177
|
+
| `batch` 输出统一为 `.png`(忽略 convert 步骤后缀) | 即使 steps 中有 `convert --format webp`,文件名仍是 `.png` | pipeline 中用 convert 步骤 + 修改 output 路径 |
|
|
178
|
+
| `remove-background --method ai` 在 batch 中不支持 | 批量 AI 去背报错 | 改用 floodfill,或用 Node.js 脚本 |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 5. 配方参考
|
|
183
|
+
|
|
184
|
+
完整的 batch/pipeline 实用配方(批量 resize、批量去背、主题色变体、精灵图组装管线等)见 `refs/ta-batch-pipeline-recipes.md`。
|