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
fix(studio): resolve history defaults from packaged runtime
罗高b70a1e073e05
diff --git a/shared/studio-history-availability.ts b/shared/studio-history-availability.tsindex 8001857c..7785ed5d 100644--- a/shared/studio-history-availability.ts+++ b/shared/studio-history-availability.ts@@ -1,10 +1,9 @@import { accessSync, constants, statSync } from 'node:fs';import path from 'node:path';-import { DEFAULT_HISTORY_ROOT, HISTORY_START } from '@hyperframes/studio-server';import type { ProjectHistory } from '@hyperframes/studio-server';/** Filter the offered steps; native undo/redo still validates files immediately before writing. */-export function withAvailableHistorySteps(history: ProjectHistory, historyRoot = DEFAULT_HISTORY_ROOT): ProjectHistory {+export function withAvailableHistorySteps(history: ProjectHistory, historyRoot: string): ProjectHistory {const home = path.join(historyRoot, history.projectId);// shortcut: the pinned 0.9.7 API has no blob-existence probe; replace this when upstream exposes one.const readable = (hash: string) => /^[a-f0-9]{64}$/.test(hash) && ['blobs', 'aside'].some(directory => {@@ -20,7 +19,7 @@ export function withAvailableHistorySteps(history: ProjectHistory, historyRoot =const entry = history.next(direction, who);if (!entry) return undefined;const entries = history.list();- const current: Record<string, string | null> = history.peek(entries.at(-1)?.id ?? HISTORY_START) ?? {};+ const current: Record<string, string | null> = history.peek(entries.at(-1)?.id ?? 'start') ?? {};// A pending step is not in the log yet, but its after hashes describe the observed files.if (!entries.some(saved => saved.id === entry.id)) {for (const file of entry.files) current[file.path] = file.after;diff --git a/shared/workspace-studio.ts b/shared/workspace-studio.tsindex c8830c70..68afa51e 100644--- a/shared/workspace-studio.ts+++ b/shared/workspace-studio.ts@@ -19,6 +19,9 @@ export async function startWorkspaceStudio(runtimeRoot: string, dataDirectory: sconst { createStudioServer } = await import(pathToFileURL(path.join(cli, 'dist', bundles[0])).href);if (typeof createStudioServer !== 'function') throw new Error('Hyperframes workspace host factory is unavailable');const { getRequestListener } = await import(pathToFileURL(require.resolve('@hono/node-server')).href);+ const historyModule = path.join(path.dirname(require.resolve('@hyperframes/studio-server/package.json')), 'dist/history/index.js');+ const { DEFAULT_HISTORY_ROOT } = await import(pathToFileURL(historyModule).href);+ const historyRoot = process.env.HYPERFRAMES_HISTORY_ROOT ?? DEFAULT_HISTORY_ROOT;const store = new WorkspaceStore(dataDirectory);const hosts = new Map<string, Promise<any>>();let origin = '', closing = false;@@ -32,11 +35,11 @@ export async function startWorkspaceStudio(runtimeRoot: string, dataDirectory: sawait repairGeneratedRegistry(scoped.projectDirectory);if (closing) throw new Error('Studio is stopping');const host = createStudioServer({ projectDir: scoped.projectDirectory, projectName: id,- origin: () => origin, historyRoot: process.env.HYPERFRAMES_HISTORY_ROOT });+ origin: () => origin, historyRoot });const openHistory = host.adapter.history;host.adapter.history = async () => {const history = await openHistory();- return history && withAvailableHistorySteps(history, process.env.HYPERFRAMES_HISTORY_ROOT);+ return history && withAvailableHistorySteps(history, historyRoot);};return host;})().catch(error => { hosts.delete(id); throw error; });diff --git a/tests/workspace-studio.test.ts b/tests/workspace-studio.test.tsindex 6591b1bc..4527c490 100644--- a/tests/workspace-studio.test.ts+++ b/tests/workspace-studio.test.ts@@ -1,10 +1,21 @@import test from 'node:test';import assert from 'node:assert/strict';-import { mkdtemp, mkdir, writeFile, rm } from 'node:fs/promises';+import { mkdtemp, mkdir, writeFile, copyFile, rm } from 'node:fs/promises';import { tmpdir } from 'node:os';import path from 'node:path';+import { pathToFileURL } from 'node:url';import { startWorkspaceStudio } from '../shared/workspace-studio.ts';+test('the shipped history availability module loads without plugin-local node_modules', async () => {+ const root = await mkdtemp(path.join(tmpdir(), 'motion-history-module-'));+ try {+ const module = path.join(root, 'history.ts');+ await copyFile(new URL('../shared/studio-history-availability.ts', import.meta.url), module);+ const detached = await import(pathToFileURL(module).href);+ assert.equal(typeof detached.withAvailableHistorySteps, 'function');+ } finally { await rm(root, { recursive: true, force: true }); }+});+test('workspace host refuses unsupported, missing, ambiguous and incompatible native factories before serving', async () => {const root = await mkdtemp(path.join(tmpdir(), 'motion-host-contract-'));const cli = path.join(root, 'node_modules/hyperframes');