Files
video-create/.claude/skills/video-from-script/scripts/lib/cmd-create-account.js
sion123 86b9b7948d feat(video-from-script): 重构工作流为子Agent分步执行并新增提示词模板系统
将视频制作工作流拆分为独立子步骤:分镜 → 图片提示词 → 生图 → 视频提示词 → 生视频 → 成片,每步由子Agent独立执行。引入prompts/目录统一管理提示词模板(分镜.md、图片提示词.md、视频提示词.md),通过account.json的storyboardPrompt/imageStylePrompt/videoStylePrompt字段引用。

变更内容:
- 新增confirmed机制和pipeline.js confirm命令,生图后必须人工确认才能继续
- manifest schema改用shotDesc/narration/duration/directorRef替代旧字段
- 文件命名规则从keyword改为slug(从shotDesc/narration派生)
- 删除旧的storyboard-rules.md和prompt-rules.md
- pipeline.js脚本拆分为lib/目录下的独立模块(cmd-init/cmd-confirm/cmd-validate/phase-*)
- 新增cmd-create-account支持一键创建带prompts目录的账号
- capcut_assemble支持narration字段替代text作为字幕源
- 新增.gitclaude/settings.json权限配置
2026-04-30 21:18:31 +08:00

139 lines
4.1 KiB
JavaScript

/**
* Command: create-account — 一键创建账号
*
* 创建目录结构 → 复制参考图 → 上传 OSS → 生成 account.json + 风格骨架
*/
const fs = require('fs')
const path = require('path')
const { ensureDir, log, ACCOUNTS_DIR } = require('./pipeline-utils')
async function createAccount(args) {
const { id, name, desc, format, imageModel, videoModel, references } = args
if (!id) { console.error('错误: 必须指定 --id <账号ID>'); process.exit(1) }
if (!/^[a-z0-9_-]+$/.test(id)) { console.error('错误: id 只允许小写字母/数字/短横线/下划线'); process.exit(1) }
if (!name) { console.error('错误: 必须指定 --name <账号名>'); process.exit(1) }
const accountDir = path.join(ACCOUNTS_DIR, id)
if (fs.existsSync(accountDir)) { console.error(`错误: 账号已存在: ${accountDir}`); process.exit(1) }
ensureDir(accountDir)
ensureDir(path.join(accountDir, 'prompts'))
ensureDir(path.join(accountDir, 'references'))
ensureDir(path.join(accountDir, 'styles'))
// 复制参考图到 references/ 并上传 OSS
const refs = (references || '').split(',').filter(Boolean)
const uploadedRefs = []
if (refs.length > 0) {
const { uploadFile } = require('../oss-upload')
for (const refPath of refs) {
const absPath = path.resolve(refPath)
if (!fs.existsSync(absPath)) { console.error(`参考图不存在: ${absPath}`); continue }
const fileName = path.basename(absPath)
const destPath = path.join(accountDir, 'references', fileName)
fs.copyFileSync(absPath, destPath)
try {
const { url } = await uploadFile(destPath)
uploadedRefs.push({ file: fileName, url })
log('account', `参考图 ${fileName} → OK`)
} catch (err) {
uploadedRefs.push({ file: fileName })
log('account', `参考图 ${fileName} 上传失败: ${err.message}(仅保存本地)`)
}
}
}
// 生成 account.json
const styleName = args.style || id
const accountConfig = {
id,
name,
description: desc || '',
defaultFormat: format || '9:16',
imageModel: imageModel || 'gemini',
videoModel: videoModel || '',
batchSize: 30,
storyboardPrompt: 'prompts/分镜.md',
imageStylePrompt: 'prompts/图片提示词.md',
videoStylePrompt: 'prompts/视频提示词.md',
capcut: {
effects: [],
filter: '',
subtitleStyle: {
fontSize: 36,
color: '#FFFFFF',
highlightColor: '#FF6B35',
bold: true,
},
defaultBGM: '',
},
}
if (uploadedRefs.length > 0) {
accountConfig.styles = {
[styleName]: { references: uploadedRefs },
}
}
const accountPath = path.join(accountDir, 'account.json')
fs.writeFileSync(accountPath, JSON.stringify(accountConfig, null, 2), 'utf-8')
// 生成默认风格骨架
const stylePath = path.join(accountDir, 'styles', `${styleName}.md`)
const styleContent = [
`# ${styleName}`,
'',
`${desc || name} 的视觉风格。`,
'',
'---',
'',
'## 图片提示词',
'',
'### 核心视觉要素',
'',
'(待填充:描述关键视觉元素)',
'',
'### 色调方案',
'',
'(待填充)',
'',
'### 图片 Prompt 模板',
'',
'(待填充)',
'',
'### 图片禁止项',
'',
'- 文字水印',
'- 字幕覆盖',
'',
'---',
'',
'## 视频提示词',
'',
'### 运镜规则',
'',
'(待填充)',
'',
'### 视频 Prompt 模板',
'',
'(待填充)',
'',
].join('\n')
fs.writeFileSync(stylePath, styleContent, 'utf-8')
console.log(`\n账号已创建: ${accountDir}`)
console.log(` ID: ${id}`)
console.log(` 名称: ${name}`)
console.log(` 模型: ${accountConfig.imageModel} + ${accountConfig.videoModel || '(未指定)'}`)
console.log(` 参考图: ${uploadedRefs.length} 张(${uploadedRefs.filter(r => r.url).length} 已上传)`)
console.log(` 风格: ${styleName}`)
console.log(`\n下一步: 编辑 ${stylePath} 完善提示词策略\n`)
return accountPath
}
module.exports = { createAccount }