The open-source full-stack studio for Opus 5.5 motion video. Reverse engineering for any video. Code video with HTML: recreate, edit and render. BYOA + BYOK · Motion.md · Images, Video, Music & Voice.
TypeScript agent-skillsagentic-aiai-agentsai-videobyokclaude-codecodexdeepseek-harnessdsh-plugingenerative-ailocal-firstmcpmotionmotion-graphicsmultimodalopenmotionreverse-engineeringvideo-editingvideo-generationworkbuddy
Validate runtime discovery manifest before writing adapters
luogao627503b7ab02
diff --git a/docs/agent-adapters.md b/docs/agent-adapters.mdindex 93bf9239..a2981658 100644--- a/docs/agent-adapters.md+++ b/docs/agent-adapters.md@@ -83,7 +83,7 @@ claude plugin list --jsonCodex 声明 `requires_local_executor`;两家原生插件均引用同一外置 Node、bootstrap、MCP 入口和数据目录。marketplace 位于各自插件 ZIP 外,原生安装使用生成的 `codex/` 或 `claude/` 目录。同名旧 `motion-local`、`openmotion-test` 或手动 MCP 已启用时,先核对、选择一个连接,避免重复加载。-Generated Codex and Claude plugin descriptions reuse the selected runtime's `.codex-plugin/plugin.json` discovery description, and Codex also retains its short description. Older runtimes without that manifest retain the generic adapter description. The five Skills carry their own intent descriptions across plugin and npm installation paths. Regenerate adapters after updating this metadata and refresh the host's discovery as described in [installation and recovery](npm-installation.md#missing-mcp-tools-or-a-failed-connection).+Generated Codex and Claude plugin descriptions reuse the selected runtime's `.codex-plugin/plugin.json` discovery description, and Codex also retains its short description. Older runtimes without that manifest retain the generic adapter description, while an invalid manifest (a non-object manifest or interface, or an empty/non-string `description` or `interface.shortDescription`) is rejected with a clear error before any adapter is written. The five Skills carry their own intent descriptions across plugin and npm installation paths. Regenerate adapters after updating this metadata and refresh the host's discovery as described in [installation and recovery](npm-installation.md#missing-mcp-tools-or-a-failed-connection).独立验证使用临时 `CODEX_HOME` / `CLAUDE_CONFIG_DIR`,安装后读取宿主实际解析的启动配置,检查工具和 `motion_get_project.dataDirectory`。卸载仅移除薄入口,保留外置运行时和用户数据。旧自带服务源码的 `check-installed-mcp.mjs` / `resolve-installed.mjs` 不用于新适配器缓存;本轮不改变旧安装器行为。diff --git a/scripts/export-adapters.ts b/scripts/export-adapters.tsindex 1fae8da1..73cb7de5 100644--- a/scripts/export-adapters.ts+++ b/scripts/export-adapters.ts@@ -36,6 +36,16 @@ export async function exportAdapters(runtimePath: string, dataPath: string, outp};const manifestFile = path.join(runtime, '.codex-plugin/plugin.json');const runtimeManifest = await exists(manifestFile) ? JSON.parse(await readFile(manifestFile, 'utf8')) : null;+ assert(runtimeManifest === null || (typeof runtimeManifest === 'object' && !Array.isArray(runtimeManifest)), 'Invalid runtime plugin manifest.');+ const manifestText = (value: unknown, field: string) => {+ if (value === undefined) return undefined;+ assert(typeof value === 'string' && value.trim().length > 0, `Invalid runtime plugin manifest ${field}; host discovery requires a non-empty string.`);+ return value;+ };+ const runtimeInterface = runtimeManifest?.interface;+ assert(runtimeInterface === undefined || (typeof runtimeInterface === 'object' && runtimeInterface !== null && !Array.isArray(runtimeInterface)), 'Invalid runtime plugin manifest interface.');+ const manifestDescription = manifestText(runtimeManifest?.description, 'description');+ const manifestShortDescription = manifestText(runtimeInterface?.shortDescription, 'interface.shortDescription');const profileFile = path.join(runtime, 'shared/mcp-release.json');const mcpProfile = await exists(profileFile) ? JSON.parse(await readFile(profileFile, 'utf8')).profile : 'legacy';assert(['legacy', 'phase1'].includes(mcpProfile), 'Invalid runtime MCP release profile.');@@ -90,10 +100,10 @@ export async function exportAdapters(runtimePath: string, dataPath: string, outp}else {const manifest = { name: 'motion', version: pkg.version,- description: runtimeManifest?.description ?? 'OpenDesign Motion with the shared local MCP runtime.',+ description: manifestDescription ?? 'OpenDesign Motion with the shared local MCP runtime.',author: { name: 'OpenDesign' }, skills: './skills/', mcpServers: './.mcp.json' };text(`.${host}-plugin/plugin.json`, host === 'codex' ? { ...manifest, requires_local_executor: true,- interface: { displayName: 'OpenDesign', shortDescription: runtimeManifest?.interface?.shortDescription ?? 'Motion production with the shared local runtime.' } } : manifest);+ interface: { displayName: 'OpenDesign', shortDescription: manifestShortDescription ?? 'Motion production with the shared local runtime.' } } : manifest);text('.mcp.json', host === 'codex' ? { mcpServers: { motion: info.transport } } : integrationConfig(info, 'mcp').text);}const directory = path.join(output, host, 'openmotion');diff --git a/tests/adapters.test.ts b/tests/adapters.test.tsindex a54f519f..76d8a43a 100644--- a/tests/adapters.test.ts+++ b/tests/adapters.test.ts@@ -127,6 +127,34 @@ test('bundled runtime adapters preserve the Node preload and launch with a minim} finally { await rm(directory, { recursive: true, force: true }); }});+test('adapter export rejects invalid runtime discovery manifest fields', async () => {+ const directory = await realpath(await mkdtemp(path.join(tmpdir(), 'motion-adapter-manifest-')));+ try {+ const data = path.join(directory, 'projects'), runtime = path.join(directory, 'runtime');+ await mkdir(path.join(runtime, 'skills'), { recursive: true }); await mkdir(path.join(runtime, 'docs'));+ for (const name of ['AGENTS.md', 'CLAUDE.md', 'mcp.ts']) await writeFile(path.join(runtime, name), '');+ await mkdir(path.join(runtime, 'web/design-system'), { recursive: true });+ for (const name of ['icons.svg', 'remix-icon-LICENSE.txt', 'remix-icon-NOTICE.txt']) await cp(path.join(source, 'web/design-system', name), path.join(runtime, 'web/design-system', name));+ await writeFile(path.join(runtime, 'package.json'), JSON.stringify({ version: '0.6.3' }));+ await mkdir(path.join(runtime, '.codex-plugin'));+ const manifestFile = path.join(runtime, '.codex-plugin/plugin.json');+ const cases: [unknown, RegExp][] = [+ [[], /Invalid runtime plugin manifest\./],+ [{ description: 42 }, /manifest description/],+ [{ description: '' }, /manifest description/],+ [{ description: 'Motion discovery', interface: 7 }, /manifest interface/],+ [{ description: 'Motion discovery', interface: { shortDescription: 42 } }, /interface\.shortDescription/],+ [{ description: 'Motion discovery', interface: { shortDescription: ' ' } }, /interface\.shortDescription/],+ ];+ for (const [index, [manifest, message]] of cases.entries()) {+ await writeFile(manifestFile, JSON.stringify(manifest));+ const output = path.join(directory, `adapters-${index}`);+ await assert.rejects(exportAdapters(runtime, data, output), message);+ assert.equal(existsSync(output), false, 'Invalid discovery metadata must be rejected before adapters are written');+ }+ } finally { await rm(directory, { recursive: true, force: true }); }+});+test('failed adapter writes remove only the new output and preserve runtime and user data', async () => {const directory = await realpath(await mkdtemp(path.join(tmpdir(), 'motion-adapter-failure-')));try {