feat(agent): 添加视频创作工作流技能系统和流程工具

新增基于 SKILL.md 的视频创作工作流系统,Agent 可通过 skills 目录加载结构化的导演指令;实现 validate_storyboard、update_manifest_items、confirm_images 三个流程工具支撑分镜校验、提示词更新和图片确认。
This commit is contained in:
2026-05-08 01:54:04 +08:00
parent 3a124f0310
commit e16305840b
7 changed files with 316 additions and 13 deletions

View File

@@ -0,0 +1,45 @@
import path from 'path';
import fs from 'fs';
import { PROJECT_ROOT, loadJSON } from './shared';
import type { ToolDefinition } from './types';
export const updateManifestItems: ToolDefinition = {
name: 'update_manifest_items',
description: '更新 manifest.json 中指定 items 的字段(如 imagePrompt、videoPrompt。只更新提供的字段不覆盖其他字段。',
input_schema: {
type: 'object',
properties: {
manifestPath: { type: 'string', description: 'manifest.json 路径' },
updates: { type: 'string', description: 'JSON 数组,每个元素需包含 idshot 序号)和要更新的字段,如 [{id:1,imagePrompt:"..."},{id:2,imagePrompt:"..."}]' },
},
required: ['manifestPath', 'updates'],
},
execute: async (params) => {
const { manifestPath, updates } = params as { manifestPath: string; updates: string };
const resolved = path.isAbsolute(manifestPath)
? manifestPath
: path.resolve(PROJECT_ROOT, manifestPath);
if (!fs.existsSync(resolved)) return `manifest 不存在: ${resolved}`;
let updateList: any[];
try { updateList = JSON.parse(updates); } catch { return '错误: updates 不是合法 JSON'; }
if (!Array.isArray(updateList)) return '错误: updates 必须是数组';
const manifest = loadJSON(resolved) as { items: any[] };
if (!manifest.items) return '错误: manifest 无 items 数组';
let updated = 0;
for (const upd of updateList) {
const idx = manifest.items.findIndex((item: any) => item.id === upd.id);
if (idx === -1) return `错误: 找不到 id=${upd.id} 的 item`;
const { id, ...fields } = upd;
Object.assign(manifest.items[idx], fields);
updated++;
}
fs.writeFileSync(resolved, JSON.stringify(manifest, null, 2), 'utf-8');
return `已更新 ${updated}/${manifest.items.length} 个 item`;
},
};