fix(mcp): templates use string IDs for SiteNode.children
PR #320 changed SiteNode.children from embedded BuildingNode/ItemNode objects to flat string[] IDs. PR #325 updated the runtime call sites but missed the three scene templates, which still mutated the site node's children array to embed full building objects after building the flat dict. This caused AnyNode.safeParse to fail for site_empty, site_2br, and site_garden in bun test --cwd packages/mcp. Remove the obsolete mutation blocks; each template already initialises site.children with the correct string id (e.g. ['building_empty']). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
fb7d46df84
commit
3e8b972b8f
@@ -238,16 +238,6 @@ function buildTemplate(): SceneGraph {
|
||||
nodes[node.id as AnyNodeId] = node
|
||||
}
|
||||
|
||||
// SiteNode.children is a discriminatedUnion of BuildingNode/ItemNode objects
|
||||
// (not string ids) — so the site must embed the full building node. The
|
||||
// rest of the tree uses string ids per the BaseNode/LevelNode/WallNode
|
||||
// schemas. We mutate the flat-dict copy of the site here so the nested
|
||||
// representation round-trips through AnyNode.safeParse.
|
||||
const siteInDict = nodes['site_empty' as AnyNodeId] as unknown as {
|
||||
children: unknown[]
|
||||
}
|
||||
siteInDict.children = [nodes['building_empty' as AnyNodeId]]
|
||||
|
||||
return {
|
||||
nodes,
|
||||
rootNodeIds: ['site_empty'] as AnyNodeId[],
|
||||
|
||||
@@ -263,10 +263,6 @@ function buildTemplate(): SceneGraph {
|
||||
],
|
||||
} as unknown as AnyNode
|
||||
|
||||
// SiteNode.children is a discriminatedUnion of BuildingNode/ItemNode objects
|
||||
// (not string ids) per the schema — embed the full building node here.
|
||||
;(nodes.site_garden as unknown as { children: unknown[] }).children = [nodes.building_garden!]
|
||||
|
||||
return {
|
||||
nodes: nodes as Record<AnyNodeId, AnyNode>,
|
||||
rootNodeIds: ['site_garden'] as AnyNodeId[],
|
||||
|
||||
@@ -291,10 +291,6 @@ function buildTemplate(): SceneGraph {
|
||||
],
|
||||
} as unknown as AnyNode
|
||||
|
||||
// SiteNode.children is a discriminatedUnion of BuildingNode/ItemNode objects
|
||||
// (not string ids) per the schema — embed the full building node here.
|
||||
;(nodes.site_2br as unknown as { children: unknown[] }).children = [nodes.building_2br!]
|
||||
|
||||
return {
|
||||
nodes: nodes as Record<AnyNodeId, AnyNode>,
|
||||
rootNodeIds: ['site_2br'] as AnyNodeId[],
|
||||
|
||||
Reference in New Issue
Block a user