feat(video-pipeline): 优化子 Agent 模板交互并新增模板路径工具

- 重构 SKILL.md,要求子 Agent 直接读取模板文件而非由主 Agent 摘要传送
- 新增 get-template-path.js 脚本,支持按账号和类型获取模板文件绝对路径
- 移除 capcut_assemble.js 中的关键字氛围词功能及相关依赖
This commit is contained in:
2026-05-02 01:18:30 +08:00
parent 4d5c8cb96d
commit ac753ef367
9 changed files with 347 additions and 48 deletions

View File

@@ -20,11 +20,11 @@ const fs = require('fs')
const { US, parseArgs, getResolution, getAudioDurationSec } = require('./lib/capcut-api')
const { buildTimeline, adjustVideoSpeed } = require('./lib/capcut-timeline')
const {
loadAccountConfig, loadSubtitleStyle, loadKeywordStyle,
loadAccountConfig, loadSubtitleStyle,
loadKenBurns, loadTransitions,
addImages, addVideos, addKenBurns,
addVoiceover, addBGM,
addSubtitles, addKeywordOverlays,
addSubtitles,
addEffects, addFilter,
} = require('./lib/capcut-tracks')
const { saveManifest } = require('./lib/pipeline-utils')
@@ -239,7 +239,7 @@ async function assemble(args) {
const steps = []
if (mode === 'images') steps.push('upload')
steps.push('draft', 'materials', 'kenburns', 'audio_oss', 'voiceover', 'audio', 'subtitles', 'keywords', 'effects', 'filter', 'save', 'sync')
steps.push('draft', 'materials', 'kenburns', 'audio_oss', 'voiceover', 'audio', 'subtitles', 'effects', 'filter', 'save', 'sync')
const totalSteps = steps.length
let step = 0
@@ -387,16 +387,7 @@ async function assemble(args) {
console.log(' 跳过')
}
// -- 关键字氛围词 --
step++; console.log(`[${step}/${totalSteps}] 添加关键字氛围词...`)
const keywordStyle = loadKeywordStyle(manifest)
if (Object.keys(keywordStyle).length > 0 && items.some(i => i.keyword)) {
await addKeywordOverlays(draftUrl, items, timeline, keywordStyle)
} else {
console.log(' 跳过(无关键字或未配置 keywordStyle')
}
// -- 特效 --
// -- 特效 -- // -- 特效 --
step++; console.log(`[${step}/${totalSteps}] 添加特效...`)
if (finalEffects) {
try {

View File

@@ -0,0 +1,103 @@
#!/usr/bin/env node
/**
* 获取账号专属模板文件的完整路径
*
* 用法:
* node get-template-path.js --account 军事账号 --type storyboard
* node get-template-path.js --account 军事账号 --type image
* node get-template-path.js --account 军事账号 --type video
*
* 输出:
* 完整的绝对路径,可直接传给 Read 工具或 fs.readFileSync
*/
const fs = require('fs')
const path = require('path')
// 路径常量
const SCRIPTS_DIR = path.join(__dirname, '..')
const SKILLS_DIR = path.join(SCRIPTS_DIR, '..')
const PROJECT_ROOT = path.join(SKILLS_DIR, '..', '..')
const ACCOUNTS_DIR = path.join(PROJECT_ROOT, 'accounts')
function getTemplatePath(accountId, templateType) {
// 1. 读取账号配置
const accountPath = path.join(ACCOUNTS_DIR, accountId, 'account.json')
if (!fs.existsSync(accountPath)) {
throw new Error(`账号不存在: ${accountPath}`)
}
const account = JSON.parse(fs.readFileSync(accountPath, 'utf-8'))
// 2. 映射模板类型到字段名
const fieldMap = {
storyboard: 'storyboardPrompt',
image: 'imageStylePrompt',
video: 'videoStylePrompt'
}
const fieldName = fieldMap[templateType]
if (!fieldName) {
throw new Error(`未知模板类型: ${templateType},支持: storyboard, image, video`)
}
// 3. 获取相对路径
const relativePath = account[fieldName]
if (!relativePath) {
throw new Error(`账号配置缺少字段: ${fieldName}`)
}
// 4. 判断是否为绝对路径
let absolutePath
if (path.isAbsolute(relativePath)) {
// 已经是绝对路径,直接使用
absolutePath = relativePath
} else {
// 相对路径,拼接账号目录(相对于账号目录)
absolutePath = path.join(ACCOUNTS_DIR, accountId, relativePath)
}
// 5. 检查文件是否存在
if (!fs.existsSync(absolutePath)) {
throw new Error(`模板文件不存在: ${absolutePath}`)
}
// 6. 转换为相对于项目根目录的相对路径(子 Agent 友好)
const relativeToProject = path.relative(PROJECT_ROOT, absolutePath)
return relativeToProject
}
// ============================================================================
// CLI 入口
// ============================================================================
function main() {
const args = process.argv.slice(2)
const accountIndex = args.indexOf('--account')
const typeIndex = args.indexOf('--type')
if (accountIndex === -1 || typeIndex === -1) {
console.error('用法node get-template-path.js --account <账号ID> --type <storyboard|image|video>')
process.exit(1)
}
const accountId = args[accountIndex + 1]
const templateType = args[typeIndex + 1]
try {
const fullPath = getTemplatePath(accountId, templateType)
console.log(fullPath)
} catch (err) {
console.error(`错误: ${err.message}`)
process.exit(1)
}
}
if (require.main === module) {
main()
}
module.exports = { getTemplatePath }