feat(mcp,editor): Option A+B storage + 10 agent deliverables (Phase 7)
Ships the combined filesystem/Supabase storage adapter + MCP scene lifecycle tools + Next.js API routes + editor /scene/[id] route, so an MCP save is directly openable at /scene/<id> without any injection hack. End-to-end verified: 10/10 e2e steps pass. Storage (A1/A2/A3): - SceneStore interface + error classes + slug helpers - FilesystemSceneStore at $PASCAL_DATA_DIR (defaults XDG/~/.pascal) with atomic writes, .index sidecar, optimistic locking - SupabaseSceneStore with scenes + scene_revisions tables, RLS migration SQL, mock-backed unit tests - createSceneStore(env) auto-selects based on SUPABASE_URL + SUPABASE_SERVICE_ROLE_KEY MCP tools (A4, A8, A9, A10): - save_scene / load_scene / list_scenes / delete_scene / rename_scene - list_templates / create_from_template (3 seed templates: empty-studio, two-bedroom, garden-house) - generate_variants (7 mutation kinds, seeded RNG, save=true|false) - photo_to_scene (vision sampling → scene graph → save) Editor (A5, A6): - /api/scenes + /api/scenes/[id] with RFC 7232 If-Match locking - /scene/[id] and /scenes route pages with save button, SceneLoader - Removed the window.__pascalScene dev injection hack Security + UX edges (A7, A8): - AssetUrl Zod validator: asset:// blob: data:image/ /path https: (http://localhost for dev) + PASCAL_ALLOWED_ASSET_ORIGINS env allowlist. Hardens scan.url, guide.url, item.asset.src, material.texture.url, MaterialMaps.*Map - Auto-frame camera on empty→non-empty scene transition (camera-controls:fit-scene emitter event) Shared utilities: - rehydrateSiteChildren() extracted to packages/mcp/src/lib/ and used by both create-from-template and generate-variants to work around the SiteNode.children-as-objects vs. ids inconsistency (CROSS_CUTTING §2) - Storage + MCP subpath exports added to packages/mcp/package.json (CROSS_CUTTING §4) Tests: 293 pass / 0 fail across 40 files (was 142 pre-Phase-7). Biome: clean. Phase-7 e2e script at packages/mcp/test-reports/phase7-e2e.ts: MCP HTTP + editor Next.js both point at $PASCAL_DATA_DIR = /tmp/pascal-e2e, save_scene from MCP, GET /api/scenes/<id> from editor server, /scenes list page renders all saved scenes, scene page renders SceneLoader, delete_scene works. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
42bd05db9c
commit
e8d0b13ff5
@@ -168,18 +168,21 @@ async function main(): Promise<void> {
|
||||
}
|
||||
|
||||
// ---- 1. get_scene ------------------------------------------------------
|
||||
const sceneResult = await run('get_scene', {}, {
|
||||
describe: (r) => {
|
||||
const s = r.structuredContent as any
|
||||
const nodeCount = s?.nodes ? Object.keys(s.nodes).length : 0
|
||||
const rootCount = s?.rootNodeIds?.length ?? 0
|
||||
return `${nodeCount} nodes, ${rootCount} roots`
|
||||
const sceneResult = await run(
|
||||
'get_scene',
|
||||
{},
|
||||
{
|
||||
describe: (r) => {
|
||||
const s = r.structuredContent as any
|
||||
const nodeCount = s?.nodes ? Object.keys(s.nodes).length : 0
|
||||
const rootCount = s?.rootNodeIds?.length ?? 0
|
||||
return `${nodeCount} nodes, ${rootCount} roots`
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
// Discover key node ids from the scene snapshot.
|
||||
const sceneNodes: Record<string, any> =
|
||||
(sceneResult?.structuredContent as any)?.nodes ?? {}
|
||||
const sceneNodes: Record<string, any> = (sceneResult?.structuredContent as any)?.nodes ?? {}
|
||||
const sceneRoots: string[] = (sceneResult?.structuredContent as any)?.rootNodeIds ?? []
|
||||
|
||||
const findFirst = (type: string): any | null => {
|
||||
@@ -198,30 +201,41 @@ async function main(): Promise<void> {
|
||||
)
|
||||
|
||||
// ---- 2. get_node -------------------------------------------------------
|
||||
await run('get_node', { id: siteNode?.id ?? sceneRoots[0] ?? '' }, {
|
||||
describe: (r) => {
|
||||
const n = (r.structuredContent as any)?.node
|
||||
return `node type=${n?.type}, id=${n?.id}`
|
||||
await run(
|
||||
'get_node',
|
||||
{ id: siteNode?.id ?? sceneRoots[0] ?? '' },
|
||||
{
|
||||
describe: (r) => {
|
||||
const n = (r.structuredContent as any)?.node
|
||||
return `node type=${n?.type}, id=${n?.id}`
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
// ---- 3. describe_node --------------------------------------------------
|
||||
await run('describe_node', { id: siteNode?.id ?? sceneRoots[0] ?? '' }, {
|
||||
describe: (r) => {
|
||||
const s = r.structuredContent as any
|
||||
return `type=${s?.type}, ${s?.childrenIds?.length ?? 0} children`
|
||||
await run(
|
||||
'describe_node',
|
||||
{ id: siteNode?.id ?? sceneRoots[0] ?? '' },
|
||||
{
|
||||
describe: (r) => {
|
||||
const s = r.structuredContent as any
|
||||
return `type=${s?.type}, ${s?.childrenIds?.length ?? 0} children`
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
// ---- 4. find_nodes -----------------------------------------------------
|
||||
const findLevels = await run('find_nodes', { type: 'level' }, {
|
||||
describe: (r) => `${(r.structuredContent as any)?.nodes?.length ?? 0} level node(s)`,
|
||||
})
|
||||
const findLevels = await run(
|
||||
'find_nodes',
|
||||
{ type: 'level' },
|
||||
{
|
||||
describe: (r) => `${(r.structuredContent as any)?.nodes?.length ?? 0} level node(s)`,
|
||||
},
|
||||
)
|
||||
|
||||
// Refresh levelNode from find_nodes output (most current).
|
||||
const foundLevels = (findLevels?.structuredContent as any)?.nodes ?? []
|
||||
const groundLevelId: string | undefined =
|
||||
foundLevels[0]?.id ?? levelNode?.id ?? undefined
|
||||
const groundLevelId: string | undefined = foundLevels[0]?.id ?? levelNode?.id ?? undefined
|
||||
console.log(`[t1] groundLevelId=${groundLevelId}`)
|
||||
|
||||
// ---- 5. measure --------------------------------------------------------
|
||||
@@ -462,38 +476,58 @@ async function main(): Promise<void> {
|
||||
}
|
||||
|
||||
// ---- 14. undo ----------------------------------------------------------
|
||||
await run('undo', {}, {
|
||||
describe: (r) => `undone=${(r.structuredContent as any)?.undone}`,
|
||||
})
|
||||
await run(
|
||||
'undo',
|
||||
{},
|
||||
{
|
||||
describe: (r) => `undone=${(r.structuredContent as any)?.undone}`,
|
||||
},
|
||||
)
|
||||
|
||||
// ---- 15. redo ----------------------------------------------------------
|
||||
await run('redo', {}, {
|
||||
describe: (r) => `redone=${(r.structuredContent as any)?.redone}`,
|
||||
})
|
||||
await run(
|
||||
'redo',
|
||||
{},
|
||||
{
|
||||
describe: (r) => `redone=${(r.structuredContent as any)?.redone}`,
|
||||
},
|
||||
)
|
||||
|
||||
// ---- 16. export_json ---------------------------------------------------
|
||||
await run('export_json', { pretty: true }, {
|
||||
describe: (r) => {
|
||||
const s = r.structuredContent as any
|
||||
return `${s?.json?.length ?? 0} chars JSON`
|
||||
await run(
|
||||
'export_json',
|
||||
{ pretty: true },
|
||||
{
|
||||
describe: (r) => {
|
||||
const s = r.structuredContent as any
|
||||
return `${s?.json?.length ?? 0} chars JSON`
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
// ---- 17. export_glb ----------------------------------------------------
|
||||
await run('export_glb', {})
|
||||
|
||||
// ---- 18. validate_scene ------------------------------------------------
|
||||
await run('validate_scene', {}, {
|
||||
describe: (r) => {
|
||||
const s = r.structuredContent as any
|
||||
return `valid=${s?.valid}, errors=${s?.errors?.length ?? 0}`
|
||||
await run(
|
||||
'validate_scene',
|
||||
{},
|
||||
{
|
||||
describe: (r) => {
|
||||
const s = r.structuredContent as any
|
||||
return `valid=${s?.valid}, errors=${s?.errors?.length ?? 0}`
|
||||
},
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
// ---- 19. check_collisions ----------------------------------------------
|
||||
await run('check_collisions', {}, {
|
||||
describe: (r) => `${(r.structuredContent as any)?.collisions?.length ?? 0} collision(s)`,
|
||||
})
|
||||
await run(
|
||||
'check_collisions',
|
||||
{},
|
||||
{
|
||||
describe: (r) => `${(r.structuredContent as any)?.collisions?.length ?? 0} collision(s)`,
|
||||
},
|
||||
)
|
||||
|
||||
// ---- 20. analyze_floorplan_image — expected sampling_unavailable -------
|
||||
await run(
|
||||
|
||||
Reference in New Issue
Block a user