Skip to content

feat: add declarative Figma canvas authoring - #152

Draft
Justineo wants to merge 4 commits into
mainfrom
feat/write-to-figma
Draft

feat: add declarative Figma canvas authoring#152
Justineo wants to merge 4 commits into
mainfrom
feat/write-to-figma

Conversation

@Justineo

@Justineo Justineo commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Add opt-in get_design_system and apply_canvas MCP tools so agents can discover native components and variables, then submit one declarative Figma result instead of driving individual Plugin API calls.
  • Reconcile create and update results locally in the extension with stable identities, scoped incremental writes, component and variable reuse, no-op detection, validation, and automatic undo on failure.
  • Add the session-only Canvas writes control, behavioral coverage, design documentation, and the figma-canvas-authoring skill with an explicit empty-document workflow.
  • Allow the MCP publish workflow to select a safe npm dist-tag for prereleases.

This bumps the extension to 0.21.0. The MCP package is published as @tempad-dev/mcp@0.8.0-alpha.0 under the alpha tag; latest remains 0.7.1.

Checked with pnpm typecheck, pnpm lint, pnpm test:run, pnpm build:mcp, pnpm build:ext, and an npm publish dry run.

@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
tempad-dev-site Ready Ready Preview, Comment Jul 27, 2026 6:11am

Request Review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces opt-in, declarative Figma canvas authoring to TemPad Dev’s MCP integration, allowing agents to discover a file’s native design system (components/variables) and submit a single desired canvas result that the extension safely reconciles against the live document.

Changes:

  • Add new MCP tool contracts and routing for get_design_system and apply_canvas, including result summaries, validation, and inline-budget retry guidance.
  • Implement extension-side design-system discovery and a scoped, rollback-capable reconciliation engine for declarative canvas writes (gated by a session-only “Canvas writes” toggle).
  • Add/expand tests, documentation, and a new figma-canvas-authoring skill + install/setup messaging.

Reviewed changes

Copilot reviewed 41 out of 41 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
vitest.config.ts Adds new extension MCP tool files to coverage/exclude configuration.
README.zh-Hans.md Documents new tools and the session-only Canvas writes toggle (ZH-Hans).
README.md Documents new tools and the session-only Canvas writes toggle (EN).
packages/site/src/sections/ConnectSection.vue Updates landing-page setup copy for plugin vs non-plugin agent paths.
packages/shared/tests/mcp/tools.test.ts Adds schema tests for canvas authoring and design-system query parameters.
packages/shared/tests/mcp/responses.test.ts Adds tests for new tool result summary builders.
packages/shared/tests/mcp/install.test.ts Updates agent setup prompt assertions to include the new skill.
packages/shared/tests/mcp/index.test.ts Ensures new schemas are exported from the shared MCP barrel.
packages/shared/tests/mcp/constants-errors.test.ts Verifies new canvas authoring error codes.
packages/shared/src/mcp/tools.ts Adds shared contracts/schemas for get_design_system and apply_canvas.
packages/shared/src/mcp/responses.ts Adds response summary builders for new tools.
packages/shared/src/mcp/install.ts Updates plugin deep-link prompt to reference both skills.
packages/shared/src/mcp/errors.ts Adds new error codes for canvas authoring.
packages/mcp-server/tests/tools.test.ts Extends MCP server tests for new tools, summaries, and validation.
packages/mcp-server/src/tools.ts Adds tool defs + response formatting/validation for new tools.
packages/mcp-server/src/instructions.md Adds agent guidance for declarative canvas authoring workflow.
packages/mcp-server/README.zh-Hans.md Documents new tools and Canvas writes toggle (ZH-Hans).
packages/mcp-server/README.md Documents new tools and Canvas writes toggle (EN).
packages/mcp-server/package.json Bumps MCP server version to 0.8.0-alpha.0.
packages/mcp-server/CHANGELOG.md Adds changelog entry for 0.8.0-alpha.0.
packages/extension/vitest.node.config.ts Adds new extension MCP tool files to node test config exclusions.
packages/extension/ui/state.ts Adds session-only canvasWritesOn UI state.
packages/extension/tests/mcp/tools/design-system.test.ts Adds behavioral tests for design-system discovery logic.
packages/extension/tests/mcp/tools/canvas.test.ts Adds extensive behavioral tests for apply/reconcile/gating/rollback.
packages/extension/tests/mcp/runtime.test.ts Verifies new tool handlers are registered and exposed as expected.
packages/extension/tests/composables/mcp.test.ts Ensures Canvas writes is cleared when MCP is not connected/enabled.
packages/extension/package.json Bumps extension version to 0.21.0.
packages/extension/mcp/tools/design-system.ts Implements design-system discovery and query ranking/capping.
packages/extension/mcp/tools/canvas.ts Implements declarative create/update reconciliation with safety gates.
packages/extension/mcp/runtime.ts Wires new tool handlers into MCP runtime routing.
packages/extension/composables/mcp.ts Clears session Canvas writes on disconnect/disable.
packages/extension/components/sections/AgentIntegrationSection.vue Adds the session-only “Canvas writes” toggle to the UI.
packages/extension/CHANGELOG.md Adds changelog entry describing canvas authoring feature set.
packages/extension/AGENTS.md Updates docs routing to include canvas authoring design doc.
docs/extension/mcp-canvas-authoring-design.md Adds design/requirements doc for the new authoring model.
AGENTS.md Adds link to the new canvas authoring design doc.
agent-plugins/tempad-dev/skills/figma-canvas-authoring/SKILL.md Introduces the new authoring skill guidance and workflow.
agent-plugins/tempad-dev/skills/figma-canvas-authoring/agents/openai.yaml Adds OpenAI agent UI metadata for the new skill.
agent-plugins/tempad-dev/README.md Updates plugin README to mention new skill + write toggle.
agent-plugins/tempad-dev/.codex-plugin/plugin.json Updates plugin metadata to include canvas authoring capability.
agent-plugins/tempad-dev/.claude-plugin/plugin.json Updates plugin metadata to include canvas authoring capability.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 59 to 63
function getAgentDescription(agent: AgentIntegrationConfig): string {
return agent.actions.some(({ id }) => id === 'plugin-prompt')
? 'The plugin adds MCP access and the design skill.'
: 'Add MCP access and the design skill.'
? 'The plugin adds MCP access and design skills.'
: 'Add MCP access and a design skill.'
}
Comment on lines +316 to 323
function isDesignSystemResult(payload: unknown): payload is ToolResultMap['get_design_system'] {
return (
isRecord(payload) &&
isRecord(payload.page) &&
Array.isArray(payload.components) &&
Array.isArray(payload.variables)
)
}
Copilot AI review requested due to automatic review settings July 27, 2026 04:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 41 out of 41 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (2)

packages/site/src/sections/ConnectSection.vue:63

  • The non-plugin setup path still says "a design skill", but this PR introduces two skills (design-to-code + canvas authoring). This UI copy is now inconsistent with the rest of the docs and can mislead users following the manual setup path.
    packages/mcp-server/src/tools.ts:333
  • The new result validators are too permissive: isDesignSystemResult accepts any object with page as an object and components/variables arrays, and isApplyCanvasResult doesn’t validate array element/value types. This can allow malformed extension payloads through and produce incorrect summaries (or downstream runtime issues) instead of throwing the intended "Invalid … payload" error.
function isDesignSystemResult(payload: unknown): payload is ToolResultMap['get_design_system'] {
  return (
    isRecord(payload) &&
    isRecord(payload.page) &&
    Array.isArray(payload.components) &&
    Array.isArray(payload.variables)
  )
}

function isApplyCanvasResult(payload: unknown): payload is ToolResultMap['apply_canvas'] {
  return (
    isRecord(payload) &&
    typeof payload.rootNodeId === 'string' &&
    isRecord(payload.nodeIdsByKey) &&
    Array.isArray(payload.createdNodeIds) &&
    Array.isArray(payload.updatedNodeIds) &&
    typeof payload.mutationCount === 'number'
  )

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 42 out of 42 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

packages/site/src/sections/ConnectSection.vue:63

  • The non-plugin setup path description says “a design skill”, but the non-plugin actions install the whole skills bundle (npx skills add …), which now includes both figma-design-to-code and figma-canvas-authoring. This copy is inconsistent with the plugin path (“design skills”) and can mislead users into thinking only one skill is needed.

Comment on lines +364 to +370
const hasBinding = !!spec.variables?.[field]
if (hasBinding) {
if (paints !== figma.mixed && paints.length === 1 && paints[0]?.type === 'SOLID') return
if (color === null) {
const label = field === 'fill' ? 'Fill' : 'Stroke'
specError(`${label} variable binding on "${spec.key}" requires a solid fallback paint.`)
}

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

packages/site/src/sections/ConnectSection.vue:63

  • The non-plugin install path still says “a design skill”, but this PR introduces two skills (design-to-code + canvas authoring). This copy is now misleading; it should refer to “design skills” (plural) consistently.

Comment on lines +51 to +55
class="tp-grid-end"
:options="toggleOptions"
:model-value="canvasWritesOn"
@update:model-value="canvasWritesOn = $event === true"
/>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 43 out of 43 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

packages/extension/components/sections/AgentIntegrationSection.vue:54

  • The Canvas writes toggle handler is assigning to the imported ref binding (canvasWritesOn = ...). In Vue templates this attempts to reassign the imported constant and will not update the ref’s .value (and can throw at runtime). Update the ref value instead.
          :options="toggleOptions"
          :model-value="canvasWritesOn"
          @update:model-value="canvasWritesOn = $event === true"

Comment thread README.md

- `get_code`: High-fidelity JSX/Vue + TailwindCSS code output by default, plus attached assets and the codegen preset/config used.
- `get_design_system`: Query-ranked native Figma component and variable references.
- `apply_canvas`: A declarative desired result that the extension safely reconciles with the live canvas. This requires the separate, session-only **Canvas writes** toggle.
Comment thread README.zh-Hans.md

- `get_code`:默认输出高保真的 JSX/Vue + TailwindCSS 代码,同时包含相关资源以及使用的 codegen 预设和配置。
- `get_design_system`:返回按查询排序的原生 Figma 组件和变量引用。
- `apply_canvas`:提交声明式目标结果,由扩展与实时画布安全地进行增量协调;需要单独启用仅当前会话有效的 **Canvas writes**。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants