openpencil/packages/design-jsx
Danila Poyarkov 1dfd501d83
feat: name the call and list every problem in validation errors (#911)
* feat: name the call and list every problem in validation errors

Tool arguments were checked with v.parse, whose error names only the first problem and neither the tool nor the argument, so a model that sent a wrong create_shape call read 'Expected string but received 42'. Tool arguments in Core, which AI chat, MCP, the CLI, and WebMCP all reach, the automation bridge's file commands, design JSX component properties, and gradient stops now throw a heading that names the call followed by v.summarize, which lists each issue with its path. parseToolArgs is exported for the app's own parses of tool arguments.

* test(design-jsx): pass a deliberately wrong property value through the types

The test checks what a script sees for a non-string instance property, which the Instance types reject at compile time.

* docs: say that MCP clients get the MCP SDK's validation report

The MCP SDK validates tool arguments against the registered schema before OpenPencil's handler runs, so an MCP client already received every problem with its path and does not see parseToolArgs' message.
2026-10-05 14:06:26 +00:00
..
scripts refactor(design-jsx): extract design JSX into its own package (#793) 2026-09-30 20:55:27 +04:00
src feat: name the call and list every problem in validation errors (#911) 2026-10-05 14:06:26 +00:00
tests feat: name the call and list every problem in validation errors (#911) 2026-10-05 14:06:26 +00:00
AGENTS.md refactor: rename @open-pencil/codegen to @open-pencil/emit (#822) 2026-10-04 11:22:20 +00:00
package.json build: update dependencies (#873) 2026-10-04 12:48:24 +00:00
README.md refactor: rename @open-pencil/codegen to @open-pencil/emit (#822) 2026-10-04 11:22:20 +00:00
tsconfig.json refactor(design-jsx): extract design JSX into its own package (#793) 2026-09-30 20:55:27 +04:00
tsdown.config.ts refactor(design-jsx): extract design JSX into its own package (#793) 2026-09-30 20:55:27 +04:00

@open-pencil/design-jsx

OpenPencil design JSX: build editable scene trees with <Frame>, <Text>, and the other elements, style them with paint and effect helpers and design variables, and export scene nodes back to JSX.

Set the JSX import source in tsconfig.json ("jsx": "react-jsx", "jsxImportSource": "@open-pencil/design-jsx") or per file:

/** @jsxImportSource @open-pencil/design-jsx */
import { renderTree } from '@open-pencil/core/design-jsx'
import { Frame, Text, solid } from '@open-pencil/design-jsx'
import { SceneGraph } from '@open-pencil/scene-graph'

const graph = new SceneGraph()
await renderTree(
  graph,
  <Frame w={320} p={16} fill={solid('#FFFFFF')}>
    <Text>Hello</Text>
  </Frame>
)

JSX written as a string, as agents and the MCP render tool send it, needs no build step:

import { renderJSX } from '@open-pencil/core/design-jsx'

await renderJSX(graph, '<Frame w={320} p={16} bg="#FFFFFF"><Text>Hello</Text></Frame>')

This package depends only on @open-pencil/scene-graph and @open-pencil/emit. Rendering needs icons, SVG conversion, and layout, which @open-pencil/core/design-jsx provides; other engines can supply their own through createDesignJSXRenderer(services).