Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ jobs:
node --test tests/brand-extraction.browser.test.ts tests/brand-showcase.browser.test.ts
- name: Repository template runtime regression
if: steps.scope.outputs.full == 'true'
run: node --test tests/repository-template-runtime.test.ts tests/hosted-template-catalog.test.ts tests/template-prompts.test.ts tests/integration-setup.test.ts
run: node --test tests/repository-template-runtime.test.ts tests/hosted-template-catalog.test.ts tests/template-guide.test.ts tests/template-prompts.test.ts tests/integration-setup.test.ts
- name: Workspace, wrapper and session regression
if: steps.scope.outputs.full == 'true'
timeout-minutes: 10
Expand Down
6 changes: 6 additions & 0 deletions docs/mcp-phase1-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@

Skill 是指导文档,与公开 Tool 数量分开。本次后续命名与分发对齐后,一期装入 openmotion-production、openmotion-director、openmotion-template-to-video、openmotion-recreate、openmotion-video-to-template 五个创作入口及其参考,以及按需支撑多模态素材生成的 openmotion-media。模板使用与视频转模板保留已有实际流程;openmotion-recreate 包含实际复刻流程,规则与测量脚本随 Skill 分发,不新增自动创作算法或 Tool。原九个工程 Tool 保留,本次新增目录获取和模板详情入口;详见 [Skill 路由与能力边界](skills.md)。

## Shared template guide pages

Every catalog `preview.html` URL uses the maintained guide interface. It preserves that entry's own authored sequence, declared parameters, timing, reference film, rules and frames. The authored examples are motion illustrations, not verified reconstructions of the reference films. Entries without the supported declaration retain their own source preview and Agent handoff; no substitute film or unsupported trial fields are inserted. `?raw=1` and `motion.md` preserve the original source bytes.

Comment thread
Q-baobao marked this conversation as resolved.
Resolved
`openmotion_create_project` accepts optional `guideDraft: { title, accent }` with `projectType=template` and the exact catalog `templateId`. It validates the selected guide's declaration and copies that guide's own canvas code, duration and motion document into an independent native project. Title and accent are declared as native variables for Agent editing; the JavaScript source remains available for deeper edits. The current Studio layout does not expose a Variables panel, so the guide does not promise that control. The original reference is not automatically recreated, no export is started, and the source catalog is not modified. Existing request-id deduplication and version/history protection apply. Replay the complete original creation payload, including namingLanguage, when retrying the same draft. Creation errors explicitly marked applied=false confirm that the unregistered project was cleaned up; only those permit a fresh requestId. Transport loss and unknown outcomes must retain the original request. The Studio MCP handbook exposes the same copyable guide-example scenario with its prerequisites and limits. Studio's direct and sandbox-embedded guide actions use the same authority.

## Optional native template presentation

The sixteen registered domain names (including one asset compatibility alias) share the same HTTP authority; `openmotion_assets_use` with its `openmotion_assets` compatibility name provides workspace assets without changing existing project calls. A phase-one stdio connection may additionally discover `openmotion_show_template_recommendations` when its `initialize` capabilities declare `extensions["io.modelcontextprotocol/ui"].mimeTypes` containing `text/html;profile=mcp-app`, the feature is enabled and the local presentation assets are valid. Do not infer this capability from a client name or protocol date. Clients without that declaration, including the installed direct CLI client, still discover exactly sixteen names; the legacy profile remains twenty-eight.
Expand Down
2 changes: 1 addition & 1 deletion docs/product/architecture.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions docs/product/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# 公开变更记录

## 2026-11-18: Continue authored template-guide examples

- Unify existing catalog guide pages while preserving each entry's own example, reference and breakdown. Declared text/accent trials can continue into an independent native project with the complete linked guide-source bundle.
- Document this explicit guide-example scope in the Studio MCP handbook, shared connection instructions and template workflow. It does not reconstruct the reference film or change ordinary reference routing.
- Preserve complete creation arguments across retries and language changes; only confirmed, cleaned-up creation failures permit a new request. Copying and editor-only handoff do not automatically export or send a task.

## 2026-11-18: Add the Design Styles library Skill

- Add optional [`openmotion-design-styles`](../../library/skills/openmotion-design-styles/SKILL.md): 21 design-style cards and 2 layout cards (palette, open-licensed typefaces, five rules, signature motion, what to avoid, render tier) that an Agent applies to the user's content as a short HyperFrames film.
Expand Down
4 changes: 3 additions & 1 deletion editor-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ export async function serveEditorFile(url: URL, res: ServerResponse): Promise<bo
else if (designFile) relative = 'packages/design-system/' + designFile;
else if (url.pathname === '/favicon.svg') relative = 'packages/design-system/brand/favicon.svg';
else if (/^\/editor-assets\/[a-zA-Z0-9_.-]+$/.test(url.pathname)) relative = 'studio/build' + url.pathname;
else if (/^\/guide-assets\/viewer\.(js|css)$/.test(url.pathname)) relative = 'studio/build' + url.pathname;
else if (/^\/web\/catalog\/(?:hyperframes|template-frames|provenance|covers)\.json$/.test(url.pathname) || /^\/web\/catalog\/(?:template-frames|covers)\/[a-f0-9]{24}\.(?:jpg|webp)$/.test(url.pathname)) relative = url.pathname.slice(1);
else return false;
const type = mime[path.extname(relative)];
if (!type) return false;
try {
const data = await readFile(path.join(pluginRoot, relative));
res.writeHead(200, { 'Content-Type': type, 'Content-Length': data.length }); res.end(data);
res.writeHead(200, { 'Content-Type': type, 'Content-Length': data.length,
...(designFile && /\.(?:ttf|woff2?)$/.test(designFile) ? { 'Access-Control-Allow-Origin': '*' } : {}) }); res.end(data);
} catch (error) {
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;
res.writeHead(503, { 'Content-Type': 'text/plain; charset=utf-8' });
Expand Down
54 changes: 54 additions & 0 deletions gateway/template-guide.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import path from 'node:path';
import { mkdir, writeFile } from 'node:fs/promises';
import { authoredTemplateGuide, jsonForHtml, parseTemplateGuideDraft, type TemplateGuideDraft } from '../shared/template-guide.ts';
import type { TemplateCatalog } from '../prism-templates.ts';
import { createBlankProject } from '../workspace.ts';

const attribute = (value: string) => value.replace(/&/g, '&amp;').replace(/'/g, '&#39;').replace(/"/g, '&quot;');
/** Convert the selected guide's actual canvas example, never a different built-in film. */
export async function materializeTemplateGuide(catalog: TemplateCatalog, templateId: string, directory: string, runtimeRoot: string, input: TemplateGuideDraft) {
const draft = parseTemplateGuideDraft(input);
const guide = authoredTemplateGuide((await catalog.sourceFile(templateId, 'preview.html')).toString());
if (!guide) throw new Error('GUIDE_NOT_EDITABLE: this guide has no supported authored example');
const sequence = (await catalog.sourceFile(templateId, guide.src)).toString();
const canvas = sequence.match(/<canvas\s+width="(\d+)"\s+height="(\d+)"/);
if (!canvas || Number(canvas[1]) > 4096 || Number(canvas[2]) > 4096) throw new Error('GUIDE_CANVAS_UNAVAILABLE');
const [width, height] = canvas.slice(1).map(Number);
const manifestBytes = await catalog.sourceFile(templateId, 'manifest.json');
const manifest = JSON.parse(manifestBytes.toString()) as { files: { path: string }[] };
// Preserve the selected document's complete relative resource bundle.
// Native project authority and generated entry files must never come from it.
const declared = [...new Set(['manifest.json', ...manifest.files.map(file => file.path)])];
for (const name of declared) {
if (!name || path.isAbsolute(name) || /^[a-z]:/i.test(name) || name.includes('\\')
|| name.split('/').some(part => !part || part === '.' || part === '..' || part.startsWith('.'))) throw new Error('GUIDE_SOURCE_PATH_UNAVAILABLE');
}
const reserved = new Set(['index.html', 'hyperframes.json', 'motion-project.json', 'motion-assets.json', 'guide-draft.json', 'assets/gsap.min.js']);
const names = declared.filter(name => !reserved.has(name));
const documents = await Promise.all(names.filter(name => !name.startsWith('assets/')).map(async name => [name, name === 'manifest.json' ? manifestBytes : await catalog.sourceFile(templateId, name)] as const));
// Source manifests retain omitted original-image identities for provenance.
// Their published renditions already use absolute URLs in the documents;
// copy only assets still referenced by a local relative path.
const localReferences = documents.filter(([name]) => name !== 'manifest.json').map(([, bytes]) => bytes.toString()).join('\n');
const assets = await Promise.all(names.filter(name => name.startsWith('assets/') && localReferences.includes(name)).map(async name => [name, await catalog.sourceFile(templateId, name)] as const));
const files = [...documents, ...assets];
await createBlankProject(directory, runtimeRoot, draft.title);
for (const [name, bytes] of files) {
await mkdir(path.dirname(path.join(directory, name)), { recursive: true });
await writeFile(path.join(directory, name), bytes);
}
await writeFile(path.join(directory, 'guide-draft.json'), jsonForHtml({ templateId, ...draft }));
const variables = [{ id: 'title', label: 'Title', type: 'string', default: draft.title }, { id: 'accent', label: 'Accent color', type: 'color', default: draft.accent }];
const html = `<!doctype html><html data-composition-variables='${attribute(jsonForHtml(variables))}'><head><meta charset="utf-8"><style>
html,body{margin:0;width:100%;height:100%;overflow:hidden}canvas{display:block;width:100%;height:100%;object-fit:contain}
</style></head><body data-mode="sequence"><div id="main" data-composition-id="main" data-start="0" data-duration="${guide.duration}" data-width="${width}" data-height="${height}" style="width:${width}px;height:${height}px;position:relative"><div id="guide-example" class="clip" data-composition-id="guide-example" data-start="0" data-duration="${guide.duration}" data-track-index="0" data-track-kind="graphics" data-width="${width}" data-height="${height}"><canvas width="${width}" height="${height}"></canvas></div></div>
<script src="assets/gsap.min.js"></script><script src="demos/data.js"></script><script src="demos/common.js"></script><script src="demos/scene.js"></script><script>
(() => { const defaults=${jsonForHtml(draft)}, clock={time:0};
const draw=()=>{const values=window.__hyperframes?.getVariables?.()||defaults;window.motionDemo.setParams({...defaults,...values});window.motionDemo.renderAt(clock.time)};
const timeline=gsap.timeline({paused:true});timeline.to(clock,{time:${guide.duration},duration:${guide.duration},ease:'none',onUpdate:draw},0);
window.__timelines=window.__timelines||{};window.__timelines.main=gsap.timeline({paused:true});window.__timelines['guide-example']=timeline;draw();
})();</script></body></html>`;
await writeFile(path.join(directory, 'index.html'), html);
return { draft, source: { id: templateId, provenance: 'authored-motion-guide-example', durationSeconds: guide.duration, width, height,
editing: 'Canvas example. Title and accent are declared as native variables for Agent editing; change demos/*.js for deeper edits; the reference film is not reconstructed.' } };
}
4 changes: 2 additions & 2 deletions mcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ async function invokeRpc(message: any, store: WorkspaceStore, registry: ReturnTy
const normalized = response.ok && transportName === 'openmotion_get_project' && transportArgs.workId ? normalizeInlineResult(raw) : undefined;
const value = publicToolResult(normalized?.structuredContent ?? raw);
if (!response.ok) throw Object.assign(new Error(value.error || 'Tool failed'), {
code: value.code, details: value.runtime, invalid_field: value.invalid_field, validation_rule: value.validation_rule,
code: value.code, details: value.runtime, invalid_field: value.invalid_field, validation_rule: value.validation_rule, ...(value.applied === false ? { applied: false } : {}),
});
if (finalVideo && (!value.inlineWork?.playable || value.inlineWork.state !== 'completed' || !normalized?._meta?.inlineVideo?.video))
throw new Error('FINAL_VIDEO_NOT_READY: Display only after the MP4 export completes and passes verification');
Expand Down Expand Up @@ -223,7 +223,7 @@ async function invokeRpc(message: any, store: WorkspaceStore, registry: ReturnTy
return result({ isError: true, content: [{ type: 'text', text: message }], structuredContent: { error: { code, message,
...(invalid_field ? { invalid_field, validation_rule } : {}),
...(runtimeFailure && (error as any).details ? { details: (error as any).details } : {}),
applied: runtimeFailure || /^(NATIVE_RUNTIME_NOT_READY|INVALID_|VERSION_CONFLICT|VERSION_NOT_RESTORABLE|PROJECT_NOT_|PROJECT_SESSION_|REQUEST_ID_CONFLICT|MCP_TOOL_NOT_EXPOSED|EXPORT_NOT_|TEMPLATE_NOT_)/.test(code) ? false : 'unknown' } } });
applied: (error as any).applied === false || runtimeFailure || /^(NATIVE_RUNTIME_NOT_READY|INVALID_|VERSION_CONFLICT|VERSION_NOT_RESTORABLE|PROJECT_NOT_|PROJECT_SESSION_|REQUEST_ID_CONFLICT|MCP_TOOL_NOT_EXPOSED|EXPORT_NOT_|TEMPLATE_NOT_)/.test(code) ? false : 'unknown' } } });
}
}
return { jsonrpc: '2.0', id: message.id, error: { code: -32601, message: 'Method not found' } };
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"package:phase1": "npm run build:studio && node --experimental-strip-types scripts/package.ts --mcp-profile=phase1",
"package:test": "node scripts/test-package.mjs",
"package:npm": "npm run build:studio && node scripts/package-npm.mjs",
"build:studio": "npm run build:inline && npm run build:template-cards && vite build --config studio/vite.config.ts",
"build:studio": "npm run build:inline && npm run build:template-cards && vite build --config studio/vite.config.ts && node scripts/build-template-guide.mjs",
"build:tracking": "tsc -p tracking/tsconfig.json",
"typecheck:studio": "tsc -p studio/tsconfig.json",
"design:tokens": "node --experimental-strip-types scripts/design-tokens.ts",
Expand Down
2 changes: 2 additions & 0 deletions packages/design-system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Ordinary HTML pages load `/design-system/ui.css` and set `data-motion-ui` on the
</section>
```

Use `ui-text-link` for quiet inline resource actions such as source links and document downloads. It shares the theme, focus and disabled roles with the other portable controls.

Studio imports `tailwind.css` from its stylesheet and `studio.css` from its application entry. Its existing `data-motion-studio` root maps `paper` to light and the default to dark. Both adapters consume the same `--motion-*` roles. For example, `--color-surface`, catalog surfaces and ordinary control backgrounds derive from shared surface roles; they do not carry separate palettes. Theme-specific recipes belong here, not in component overrides.

`studio/application.css`, included by `studio.css`, supplies the reusable `om-*` navigation, buttons, fields, cards, badges, avatars, switches and dialogs used by the application shell and settings. Load consumer geometry after this entry so responsive visibility and measured sizes can override the primitive defaults. The `shell` role supplies the continuous top/left backdrop; `workspace` supplies the inset content surface. The `chrome-icon`, `chrome-hover` and `chrome-active` roles distinguish quiet navigation from the main content; shared transition recipes respect reduced motion. Provider artwork uses a neutral `brand-surface` tile, with identical local assets shared by lists, details and model choices. Keep colors, materials, focus and disabled states in the package. Composite fields use one visible focus ring around the whole control.
Expand Down
4 changes: 4 additions & 0 deletions packages/design-system/controls.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
:where([data-motion-ui]) .ui-button--danger:hover:not(:disabled) { background: var(--motion-danger-soft); color: var(--motion-danger); border-color: var(--motion-danger); }
:where([data-motion-ui]) .ui-button--sm { min-height: var(--motion-control-sm); padding: var(--motion-space-4) var(--motion-space-8); font-size: var(--motion-text-sm); }
:where([data-motion-ui]) .ui-button--icon { width: var(--motion-icon-button); min-height: var(--motion-icon-button); padding: var(--motion-space-6); }
/* Quiet resource actions shared by ordinary HTML guides and other portable surfaces. */
:where([data-motion-ui]) .ui-text-link { display: inline-flex; align-items: center; gap: var(--motion-space-6); min-height: var(--motion-control-sm); padding: 0; border: 0; background: transparent; color: var(--motion-muted); font-size: var(--motion-text-sm); font-weight: var(--motion-weight-regular); line-height: var(--motion-leading-body); text-decoration: none; white-space: nowrap; cursor: pointer; }
:where([data-motion-ui]) .ui-text-link:hover:not(:disabled):not([aria-disabled="true"]) { text-decoration: underline; }
:where([data-motion-ui]) .ui-text-link:is(:disabled,[aria-disabled="true"]) { color: var(--motion-control-disabled); cursor: default; }
:where([data-motion-ui]) .ui-field { display: flex; flex-direction: column; gap: var(--motion-space-8); font-size: var(--motion-text-sm); color: var(--motion-muted); }
:where([data-motion-ui]) .ui-input {
width: 100%; min-width: 0; min-height: var(--motion-control);
Expand Down
Loading
Loading