# 图文成片工作流问题记录 ## 问题一:manifest 初始化缺少 file 字段 **现象:** ``` [assemble] 成片失败: The "path" argument must be of type string. Received undefined ``` **根因:** `pipeline.js init` 生成的 manifest.json 中,每个 item 只有 `shotDesc`、`script`、`duration` 等字段,**缺少 `file` 字段**。 `capcut_assemble.js` 依赖 `item.file` 来定位本地图片: ```js const filePath = path.join(inputDir, item.file) return fs.existsSync(filePath) ``` 没有 `file` 字段时,`path.join(inputDir, undefined)` → `undefined` → 报错。 **修复:** 手动给每个 item 补上 `file` 字段: ```js m.items.forEach((item, i) => { item.file = 'images/scene_' + String(i+1).padStart(2,'0') + '_' + slug + '.jpeg' }) ``` **建议改进:** `pipeline.js init` 应自动根据 items 索引和 slug 生成 `file` 字段,与后续 assemble 阶段无缝衔接。 --- ## 问题二:并行生图命令的 cwd 问题 **现象:** ```bash # 6 个并行命令,其中 5 个报错 cd .claude/skills/video-from-script/scripts && node gemini-image-generator.js ... # Exit code 1: no such file or directory ``` **根因:** 5 个并行命令在解析时,zsh 把 `.claude/...` 路径中 `.` 视为当前目录的相对路径,而并行任务可能在不同 cwd 下执行,导致路径解析失败。 **修复:** 改用绝对路径: ```bash SCRIPTS="/Users/lc/Desktop/CLAUDE/video-create/.claude/skills/video-from-script/scripts" node "$SCRIPTS/gemini-image-generator.js" generate "..." -o "$OUT" -r 9:16 ``` **建议改进:** CLI 命令始终使用绝对路径,避免相对路径在并行环境下的歧义。 --- ## 问题三:shot 6 在 mv 重命名时被遗漏 **现象:** 6 张图生完后,重命名时只有 5 张被正确命名为 `scene_0X_xxx.jpeg`,缺少 `scene_06_跪着.jpeg`。 **根因:** mv 命令基于修改时间排序,zsh glob `generated_*.jpeg` 只匹配当时存在的文件。6张图的生成时间戳不同,重命名脚本从最旧的文件开始取(tail -1),但脚本顺序与实际时间顺序可能不匹配。 **修复:** 直接对生成的临时文件重命名为固定名称,不依赖时间排序逻辑。 **建议改进:** pipeline.js 的生图阶段应直接输出为 `scene_{NN}_{slug}.jpeg`,而非先生成 `generated_*.jpeg` 再重命名。 --- ## 问题四:pipeline.js assemble 阶段的路径解析 Bug **现象:** `pipeline.js run --phase tts,assemble` 时 tts 正常,但 assemble 阶段找不到文件而报错。直接调用 `capcut_assemble.js --input ` 则正常。 **根因:** pipeline.js 在调用 assemble 时,传递的 input 路径为相对路径,且未正确设置 `item.file` 字段,导致 assemble 内部 `path.join(inputDir, item.file)` 得到 undefined。 **建议改进:** `pipeline.js run --phase assemble` 前应先检查 items 是否都有 `file` 字段,缺失时自动补充。 --- ## 建议的改进方向 1. **`pipeline.js init`** 自动生成 `file` 字段,与图片命名规范一致 2. **CLI 命令** 统一使用绝对路径,避免 cwd 歧义 3. **生图脚本** 直接输出为 `scene_XX_xxx.jpeg`,消除重命名步骤 4. **`pipeline.js validate`** 增加 assemble 阶段的前置检查(items.file + items.audio 完整性)