Reset core/viewer/editor/mcp packages and apps/editor from private-editor
Wholesale swap of packages/{core,viewer,editor,mcp} and apps/editor with the
versions from the private editor repo, which is the production source of truth.
Setup changes:
- packages/{core,viewer,editor} versions held at 0.7.0 baseline (matching
the most recent published release) so a bump=minor publishes 0.8.0
- packages/mcp held at 0.1.1 (never published; first publish will go through
the new release.yml flow)
- peerDependencies and devDependencies for inter-package @pascal-app/*
references pinned to ^0.7.0 instead of '*' / 'workspace:*' so they are
valid for npm consumers
- Root package.json: TypeScript bumped to 6.0.2, added overrides for
@types/react, @types/react-dom, @types/three to prevent JSX namespace
fragmentation across the workspace
- release.yml extended to also publish editor and mcp; 'both' option renamed
to 'all'; added a sync step that updates inter-package peerDeps/devDeps to
match the new versions on every bump (so viewer/editor/mcp tarballs always
reference the version of core they were built against)
- Root scripts gained release:editor and release:mcp shortcuts
Verification:
- bun install --frozen-lockfile is consistent
- packages/{core,viewer,mcp} build cleanly, dist/index.d.ts emitted
- packages/editor check-types reports 21 pre-existing errors, identical to
what private-editor currently reports
Open PRs against editor-v2 will need rebasing/conflict resolution.
This commit is contained in:
@@ -7,6 +7,7 @@ import type { SceneOperations } from '../../operations'
|
||||
import { isTemplateId, TEMPLATES, type TemplateId } from '../../templates'
|
||||
import { ErrorCode, throwMcpError } from '../errors'
|
||||
import { appendLiveSceneEvent } from '../live-sync'
|
||||
import { currentLevelContext, sceneMetaPayload } from '../scene-lifecycle/metadata'
|
||||
|
||||
export const createFromTemplateInput = {
|
||||
id: z
|
||||
@@ -48,6 +49,13 @@ export const createFromTemplateOutput = {
|
||||
sizeBytes: z.number(),
|
||||
nodeCount: z.number(),
|
||||
url: z.string(),
|
||||
editorUrl: z.string(),
|
||||
published: z.boolean(),
|
||||
isDraft: z.boolean(),
|
||||
saveMode: z.enum(['draft', 'checkpoint']),
|
||||
graphHash: z.string().optional(),
|
||||
levelIds: z.array(z.string()),
|
||||
defaultLevelId: z.string().nullable(),
|
||||
})
|
||||
.optional(),
|
||||
}
|
||||
@@ -121,10 +129,18 @@ export function registerCreateFromTemplate(server: McpServer, bridge: SceneOpera
|
||||
}
|
||||
|
||||
try {
|
||||
let saveProjectId = projectId
|
||||
if (!saveProjectId && bridge.canCreateProject) {
|
||||
const project = await bridge.createProject({ name: name ?? entry.name })
|
||||
saveProjectId = project.projectId
|
||||
}
|
||||
const meta = await bridge.saveScene({
|
||||
...(saveProjectId !== undefined ? { id: saveProjectId, projectId: saveProjectId } : {}),
|
||||
name: name ?? entry.name,
|
||||
...(projectId !== undefined ? { projectId } : {}),
|
||||
graph: { nodes, rootNodeIds },
|
||||
saveMode: 'draft',
|
||||
publish: false,
|
||||
operation: 'create_from_template',
|
||||
})
|
||||
bridge.setActiveScene(meta)
|
||||
await appendLiveSceneEvent(bridge, meta.id, meta.version, 'create_from_template', {
|
||||
@@ -132,17 +148,8 @@ export function registerCreateFromTemplate(server: McpServer, bridge: SceneOpera
|
||||
rootNodeIds,
|
||||
})
|
||||
const scene = {
|
||||
id: meta.id,
|
||||
name: meta.name,
|
||||
projectId: meta.projectId,
|
||||
thumbnailUrl: meta.thumbnailUrl,
|
||||
version: meta.version,
|
||||
createdAt: meta.createdAt,
|
||||
updatedAt: meta.updatedAt,
|
||||
ownerId: meta.ownerId,
|
||||
sizeBytes: meta.sizeBytes,
|
||||
nodeCount: meta.nodeCount,
|
||||
url: `/scene/${meta.id}`,
|
||||
...sceneMetaPayload(meta, { nodes, rootNodeIds }),
|
||||
...currentLevelContext(bridge),
|
||||
}
|
||||
const payload = { ...basePayload, scene }
|
||||
return {
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
||||
import { cloneSceneGraph } from '@pascal-app/core/clone-scene-graph'
|
||||
import type { AnyNode, AnyNodeId } from '@pascal-app/core/schema'
|
||||
import { z } from 'zod'
|
||||
import { rehydrateSiteChildren } from '../../lib/rehydrate-site-children'
|
||||
import type { SceneOperations } from '../../operations'
|
||||
import { isTemplateId, TEMPLATES, type TemplateId } from '../../templates'
|
||||
import { ErrorCode, throwMcpError } from '../errors'
|
||||
import { appendLiveSceneEvent } from '../live-sync'
|
||||
import { currentLevelContext, sceneMetaPayload } from '../scene-lifecycle/metadata'
|
||||
|
||||
export const createHouseFromBriefInput = {
|
||||
brief: z.string().min(1),
|
||||
projectId: z.string().optional(),
|
||||
projectName: z.string().min(1).max(200).optional(),
|
||||
bedroomCount: z.number().int().min(0).max(12).optional(),
|
||||
rooms: z.array(z.string().min(1)).optional(),
|
||||
style: z.string().optional(),
|
||||
landscaping: z.boolean().optional(),
|
||||
constraints: z.string().optional(),
|
||||
}
|
||||
|
||||
export const createHouseFromBriefOutput = {
|
||||
projectId: z.string().nullable(),
|
||||
editorUrl: z.string().nullable(),
|
||||
url: z.string().nullable(),
|
||||
version: z.number().nullable(),
|
||||
published: z.boolean(),
|
||||
isDraft: z.boolean(),
|
||||
templateId: z.string(),
|
||||
nodeCount: z.number(),
|
||||
roomCount: z.number(),
|
||||
levelIds: z.array(z.string()),
|
||||
defaultLevelId: z.string().nullable(),
|
||||
validation: z.object({
|
||||
valid: z.boolean(),
|
||||
errors: z.array(z.string()),
|
||||
}),
|
||||
summary: z.string(),
|
||||
limitations: z.array(z.string()),
|
||||
nextStep: z.string(),
|
||||
}
|
||||
|
||||
function chooseTemplate(args: {
|
||||
bedroomCount?: number
|
||||
rooms?: string[]
|
||||
landscaping?: boolean
|
||||
}): TemplateId {
|
||||
const requested = new Set((args.rooms ?? []).map((room) => room.toLowerCase()))
|
||||
if (
|
||||
args.landscaping ||
|
||||
requested.has('garden') ||
|
||||
requested.has('patio') ||
|
||||
requested.has('yard')
|
||||
) {
|
||||
return 'garden-house'
|
||||
}
|
||||
if ((args.bedroomCount ?? 0) <= 1) return 'empty-studio'
|
||||
if ((args.bedroomCount ?? 0) <= 2) return 'two-bedroom'
|
||||
return 'garden-house'
|
||||
}
|
||||
|
||||
function countNodeTypes(nodes: Record<AnyNodeId, AnyNode>): {
|
||||
nodeCount: number
|
||||
roomCount: number
|
||||
} {
|
||||
let roomCount = 0
|
||||
for (const node of Object.values(nodes)) {
|
||||
if (node.type === 'zone') roomCount++
|
||||
}
|
||||
return {
|
||||
nodeCount: Object.keys(nodes).length,
|
||||
roomCount,
|
||||
}
|
||||
}
|
||||
|
||||
export function registerCreateHouseFromBrief(server: McpServer, bridge: SceneOperations): void {
|
||||
server.registerTool(
|
||||
'create_house_from_brief',
|
||||
{
|
||||
title: 'Create house from brief',
|
||||
description:
|
||||
'High-level hosted workflow for external agents: choose a starter house from a brief, create/save/publish it, and return the editor URL. Use semantic tools afterward for exact customization.',
|
||||
inputSchema: createHouseFromBriefInput,
|
||||
outputSchema: createHouseFromBriefOutput,
|
||||
},
|
||||
async ({
|
||||
brief,
|
||||
projectId,
|
||||
projectName,
|
||||
bedroomCount,
|
||||
rooms,
|
||||
style,
|
||||
landscaping,
|
||||
constraints,
|
||||
}) => {
|
||||
const templateId = chooseTemplate({
|
||||
...(bedroomCount !== undefined ? { bedroomCount } : {}),
|
||||
...(rooms !== undefined ? { rooms } : {}),
|
||||
...(landscaping !== undefined ? { landscaping } : {}),
|
||||
})
|
||||
if (!isTemplateId(templateId)) {
|
||||
throwMcpError(ErrorCode.InternalError, `unknown_template: ${templateId}`)
|
||||
}
|
||||
|
||||
const entry = TEMPLATES[templateId]
|
||||
const cloned = rehydrateSiteChildren(cloneSceneGraph(entry.template))
|
||||
const nodes = cloned.nodes as Record<AnyNodeId, AnyNode>
|
||||
const rootNodeIds = cloned.rootNodeIds as AnyNodeId[]
|
||||
const counts = countNodeTypes(nodes)
|
||||
|
||||
try {
|
||||
bridge.setScene(nodes, rootNodeIds)
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
throwMcpError(ErrorCode.InternalError, `apply_failed: ${msg}`)
|
||||
}
|
||||
|
||||
const rawValidation = bridge.validateScene()
|
||||
const validation = {
|
||||
valid: rawValidation.valid,
|
||||
errors: rawValidation.errors.map(
|
||||
(error) => `${error.nodeId}:${error.path}: ${error.message}`,
|
||||
),
|
||||
}
|
||||
const limitations: string[] = []
|
||||
if ((bedroomCount ?? 0) > 2) {
|
||||
limitations.push(
|
||||
'MVP create_house_from_brief uses the closest built-in template for 3+ bedroom requests; refine with create_room/add_door/add_window for exact room count.',
|
||||
)
|
||||
}
|
||||
if (style || constraints) {
|
||||
limitations.push(
|
||||
'Style and constraints are recorded in the summary but not yet fully synthesized into custom geometry.',
|
||||
)
|
||||
}
|
||||
|
||||
if (!bridge.hasStore) {
|
||||
const payload = {
|
||||
projectId: null,
|
||||
editorUrl: null,
|
||||
url: null,
|
||||
version: null,
|
||||
published: false,
|
||||
isDraft: false,
|
||||
templateId,
|
||||
nodeCount: counts.nodeCount,
|
||||
roomCount: counts.roomCount,
|
||||
...currentLevelContext(bridge),
|
||||
validation,
|
||||
summary: `Applied ${entry.name} starter scene from brief: ${brief}`,
|
||||
limitations,
|
||||
nextStep:
|
||||
'No SceneStore is attached. Call save_scene later in a hosted MCP session to publish.',
|
||||
}
|
||||
return {
|
||||
content: [{ type: 'text' as const, text: JSON.stringify(payload) }],
|
||||
structuredContent: payload,
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
let saveProjectId = projectId
|
||||
if (!saveProjectId && bridge.canCreateProject) {
|
||||
const project = await bridge.createProject({ name: projectName ?? entry.name })
|
||||
saveProjectId = project.projectId
|
||||
}
|
||||
|
||||
const meta = await bridge.saveScene({
|
||||
...(saveProjectId !== undefined ? { id: saveProjectId, projectId: saveProjectId } : {}),
|
||||
name: projectName ?? entry.name,
|
||||
graph: { nodes, rootNodeIds },
|
||||
saveMode: 'draft',
|
||||
publish: false,
|
||||
operation: 'create_house_from_brief',
|
||||
})
|
||||
bridge.setActiveScene(meta)
|
||||
await appendLiveSceneEvent(bridge, meta.id, meta.version, 'create_house_from_brief', {
|
||||
nodes,
|
||||
rootNodeIds,
|
||||
})
|
||||
const scene = sceneMetaPayload(meta, { nodes, rootNodeIds })
|
||||
const payload = {
|
||||
projectId: scene.projectId ?? scene.id,
|
||||
editorUrl: scene.editorUrl,
|
||||
url: scene.url,
|
||||
version: scene.version,
|
||||
published: scene.published,
|
||||
isDraft: scene.isDraft,
|
||||
templateId,
|
||||
nodeCount: scene.nodeCount,
|
||||
roomCount: counts.roomCount,
|
||||
...currentLevelContext(bridge),
|
||||
validation,
|
||||
summary: `Created ${scene.name} from ${entry.name}. Brief: ${brief}`,
|
||||
limitations,
|
||||
nextStep:
|
||||
'Call verify_scene and get_project_status. If the brief needs more specificity, refine with semantic tools and save_scene again.',
|
||||
}
|
||||
return {
|
||||
content: [{ type: 'text' as const, text: JSON.stringify(payload) }],
|
||||
structuredContent: payload,
|
||||
}
|
||||
} catch (err) {
|
||||
const msg = err instanceof Error ? err.message : String(err)
|
||||
throwMcpError(ErrorCode.InternalError, `save_failed: ${msg}`)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
|
||||
import type { SceneOperations } from '../../operations'
|
||||
import { registerCreateFromTemplate } from './create-from-template'
|
||||
import { registerCreateHouseFromBrief } from './create-house-from-brief'
|
||||
import { registerListTemplates } from './list-templates'
|
||||
|
||||
/**
|
||||
@@ -13,6 +14,7 @@ import { registerListTemplates } from './list-templates'
|
||||
export function registerTemplateTools(server: McpServer, bridge: SceneOperations): void {
|
||||
registerListTemplates(server)
|
||||
registerCreateFromTemplate(server, bridge)
|
||||
registerCreateHouseFromBrief(server, bridge)
|
||||
}
|
||||
|
||||
export {
|
||||
@@ -20,6 +22,11 @@ export {
|
||||
createFromTemplateOutput,
|
||||
registerCreateFromTemplate,
|
||||
} from './create-from-template'
|
||||
export {
|
||||
createHouseFromBriefInput,
|
||||
createHouseFromBriefOutput,
|
||||
registerCreateHouseFromBrief,
|
||||
} from './create-house-from-brief'
|
||||
export {
|
||||
listTemplatesInput,
|
||||
listTemplatesOutput,
|
||||
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
type StoredTextContent,
|
||||
} from '../scene-lifecycle/test-utils'
|
||||
import { registerCreateFromTemplate } from './create-from-template'
|
||||
import { registerCreateHouseFromBrief } from './create-house-from-brief'
|
||||
import { registerListTemplates } from './list-templates'
|
||||
|
||||
describe('list_templates', () => {
|
||||
@@ -63,6 +64,7 @@ describe('create_from_template', () => {
|
||||
const operations = createSceneOperations({ bridge, store })
|
||||
const server = new McpServer({ name: 'test', version: '0.0.0' })
|
||||
registerCreateFromTemplate(server, operations)
|
||||
registerCreateHouseFromBrief(server, operations)
|
||||
const [srvT, cliT] = InMemoryTransport.createLinkedPair()
|
||||
client = new Client({ name: 'test-client', version: '0.0.0' })
|
||||
await Promise.all([server.connect(srvT), client.connect(cliT)])
|
||||
@@ -106,9 +108,16 @@ describe('create_from_template', () => {
|
||||
expect(result.isError).toBeFalsy()
|
||||
const parsed = parseToolText(result.content as StoredTextContent[])
|
||||
expect(parsed.scene).toBeDefined()
|
||||
const scene = parsed.scene as { id: string; name: string; url: string; nodeCount: number }
|
||||
const scene = parsed.scene as {
|
||||
id: string
|
||||
name: string
|
||||
url: string
|
||||
editorUrl: string
|
||||
nodeCount: number
|
||||
}
|
||||
expect(scene.name).toBe('My flat')
|
||||
expect(scene.url).toBe(`/scene/${scene.id}`)
|
||||
expect(scene.url).toBe(`/editor/${scene.id}`)
|
||||
expect(scene.editorUrl).toBe(`/editor/${scene.id}`)
|
||||
expect(scene.nodeCount).toBeGreaterThan(0)
|
||||
|
||||
// Confirm the store actually holds it.
|
||||
@@ -131,6 +140,26 @@ describe('create_from_template', () => {
|
||||
expect(idsB).not.toContain(id)
|
||||
}
|
||||
})
|
||||
|
||||
test('create_house_from_brief creates, saves, and returns an editor URL', async () => {
|
||||
const result = await client.callTool({
|
||||
name: 'create_house_from_brief',
|
||||
arguments: {
|
||||
brief: 'Create a compact modern two-bedroom home with a small patio.',
|
||||
projectName: 'Brief house',
|
||||
bedroomCount: 2,
|
||||
landscaping: true,
|
||||
},
|
||||
})
|
||||
expect(result.isError).toBeFalsy()
|
||||
const parsed = parseToolText(result.content as StoredTextContent[])
|
||||
expect(typeof parsed.projectId).toBe('string')
|
||||
expect(parsed.editorUrl).toBe(`/editor/${parsed.projectId}`)
|
||||
expect(parsed.version).toBe(1)
|
||||
expect(parsed.published).toBe(true)
|
||||
expect(parsed.nodeCount as number).toBeGreaterThan(0)
|
||||
expect(parsed.nextStep as string).toContain('get_project_status')
|
||||
})
|
||||
})
|
||||
|
||||
describe('create_from_template without a store', () => {
|
||||
|
||||
Reference in New Issue
Block a user