mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-02 02:40:51 +08:00
* feat(game-studio): add Game Studio tab, local game service and MCP game tools Game Studio page with template waterfall, My games sidebar, landscape/portrait choice and auto-open of Agent-created drafts; local game projects service with rooms, playtest, simulate and cover capture; openmotion_game_* MCP tools; openmotion-game handbook ported from the MIT higgsfield-ai/skills handbook; coop-3d and arcade-2d starter kits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(game-studio): register game tools, dedupe handbook provenance, fix search and code reload Register the openmotion_game_* tools in MCP counts, onboarding scenarios and tracking dimensions; keep them out of WebMCP. Move the shared MIT provenance note to PROVENANCE.md. Studio search now matches localized titles, and the Code tab reloads its source. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(game-studio): harden game service and fix invite copy and code fullscreen Case-insensitive reserved paths and request-id saves; sandbox CSP for game documents; WebSocket fragment count, time and buffer limits; AST-based determinism check; single-player start for playtest and cover capture; atomic batch writes with rollback. Studio: clipboard-write for embedded games and Code-tab fullscreen on the stage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(game-studio): trim KayKit characters below 1 MiB for the storage policy Keep 12 common clips per character (meshes, skin and bones unchanged) so Knight.glb and Mage.glb stay ordinary Git files; update the character README and the 3D handbook. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(game-studio): hand drafts to the user's Agent; derive the WebSocket test nonce Drafts show "Waiting for your Agent" until the Agent sets building. The draft page offers Copy instruction and Open in Codex (prefill only) with the full instruction: game id, brief and steps. GET /api/games/:id/handoff returns it for any workspace draft, including drafts created elsewhere and remixes; creation now includes the portrait layout in the instruction. Tests derive the RFC 6455 sample nonce at runtime so release scanning stays strict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(game-studio): spin the detail status only while the Agent is building Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(game-studio): exercise all twelve game tools in the packaged MCP smoke test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(game-studio): vendor acorn so packaged builds can run the game rules sandbox Packaged builds ship without node_modules, so openmotion_game_simulate failed with "Cannot find module 'acorn'". Ship acorn 8.19.0 (MIT, license in the file header) under shared/vendor and import it relatively. Verified in a node_modules-free copy of the phase1 file list: create plus reference simulation wins at tick 809. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(game-studio): resolve browser and trailer dependencies from the host runtime root Packaged builds install npm dependencies under the data directory, so playtest, cover capture and trailer recording failed with "Cannot find module 'puppeteer-core'" and the trailer looked for HyperFrames in the plugin folder. Server and phase1 hosts now pass their runtime root; puppeteer, HyperFrames checks, the trailer's Phase1Service and render queue use it (source checkouts fall back to the plugin root). Verified in a node_modules-free phase1 file copy: playtest, cover, simulate, publish and a trailer through ready. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(game-studio): isolate catalog entries, smoke-test solo logic and run the game suite in CI Review follow-ups: - The catalog skips and reports a game folder it cannot read (an orphan or malformed game.json) instead of failing GET /api/games; create and remix remove their folder when a step fails, so a partial create no longer leaves an orphan. - Validation runs the bounded logic.js smoke check for every game with rules. Single-player games follow validateAction as live play does, the loop stops when the game ends, and a kit game missing logic.js is reported. Room checks stay multiplayer-only. - tests/game-projects.test.ts runs in the Distribution browser lane (Chrome and native export cases skip themselves when unavailable) and leaves the unscheduled list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(game-studio): stabilize scrolling and animate build indicator * fix(game-studio): validate runtime before browser discovery Resolve the requested runtime dependencies before detecting Chrome so missing-runtime diagnostics remain deterministic on Linux. Preserve all tests and emit failed Game Studio assertions as GitHub check annotations. * fix(game-studio): stop waiting for network silence during capture Wait for the document load and visible canvas while retaining room, startup and runtime assertions. Add a real polling regression that reproduces the 20-second navigation timeout and verifies successful background responses during capture. --------- Co-authored-by: zhanghuihua <zhanghuihua@huihuideMacBook-Pro.local> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: zhanghuihua <zhanghuihua@Mac.lan> Co-authored-by: stevenguotj <stevenguotj@stevengotjdeMBP.lan>
50 lines
3.0 KiB
JavaScript
50 lines
3.0 KiB
JavaScript
import { readFile } from 'node:fs/promises';
|
|
import { pathToFileURL } from 'node:url';
|
|
|
|
/** GLB 2 inspector; no engine, network or third-party dependencies. */
|
|
export function inspectGlb(bytes) {
|
|
if (bytes.length < 20 || bytes.toString('ascii', 0, 4) !== 'glTF' || bytes.readUInt32LE(4) !== 2 || bytes.readUInt32LE(8) !== bytes.length) throw Error('Invalid GLB 2 header');
|
|
let doc, binary;
|
|
for (let offset = 12; offset < bytes.length;) {
|
|
if (offset + 8 > bytes.length) throw Error('Truncated GLB chunk');
|
|
const length = bytes.readUInt32LE(offset), type = bytes.readUInt32LE(offset + 4);
|
|
if (length % 4 || offset + 8 + length > bytes.length) throw Error('Invalid GLB chunk length');
|
|
const chunk = bytes.subarray(offset + 8, offset + 8 + length);
|
|
if (type === 0x4e4f534a) doc = JSON.parse(chunk.toString('utf8').trim());
|
|
if (type === 0x004e4942) binary = chunk;
|
|
offset += 8 + length;
|
|
}
|
|
if (!doc) throw Error('Missing GLB JSON chunk');
|
|
function times(index) {
|
|
const accessor = doc.accessors[index];
|
|
if (accessor.componentType !== 5126 || accessor.type !== 'SCALAR' || accessor.sparse) throw Error('Unsupported animation time accessor');
|
|
const view = doc.bufferViews[accessor.bufferView];
|
|
if (!binary || view.buffer !== 0) throw Error('Animation requires an embedded buffer');
|
|
const start = (view.byteOffset ?? 0) + (accessor.byteOffset ?? 0), stride = view.byteStride ?? 4;
|
|
const result = [];
|
|
for (let i = 0; i < accessor.count; i++) {
|
|
const offset = start + i * stride;
|
|
if (offset + 4 > binary.length || offset + 4 > (view.byteOffset ?? 0) + view.byteLength) throw Error('Truncated animation accessor');
|
|
result.push(binary.readFloatLE(offset));
|
|
}
|
|
return result;
|
|
}
|
|
const meshes = (doc.meshes ?? []).map((mesh, i) => ({ name: mesh.name ?? `mesh-${i}`, triangles: (mesh.primitives ?? []).reduce((sum, p) => {
|
|
const n = doc.accessors[p.indices ?? p.attributes.POSITION].count, mode = p.mode ?? 4;
|
|
return sum + (mode === 4 ? Math.floor(n / 3) : mode === 5 || mode === 6 ? Math.max(0, n - 2) : 0);
|
|
}, 0) }));
|
|
return { meshes, skins: (doc.skins ?? []).map((skin, i) => ({ name: skin.name ?? `skin-${i}`, bones: skin.joints.length })),
|
|
boneCount: new Set((doc.skins ?? []).flatMap(s => s.joints)).size,
|
|
animations: (doc.animations ?? []).map((clip, i) => {
|
|
let min = Infinity, max = -Infinity;
|
|
for (const sampler of clip.samplers) for (const time of times(sampler.input)) { min = Math.min(min, time); max = Math.max(max, time); }
|
|
return { name: clip.name ?? `clip-${i}`, duration: Number.isFinite(max) ? +(max - min).toFixed(6) : 0 };
|
|
}), triangleCount: meshes.reduce((sum, m) => sum + m.triangles, 0) };
|
|
}
|
|
if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
|
|
try {
|
|
if (!process.argv[2]) throw Error('Usage: node scripts/game-glb-inspect.mjs character.glb');
|
|
console.log(JSON.stringify(inspectGlb(await readFile(process.argv[2])), null, 2));
|
|
} catch (error) { console.error(error.message); process.exitCode = 1; }
|
|
}
|