AgentSkillsCN

figjam-plugin

FigJam 插件开发流程。在修改 code.ts(画布渲染)、ui.ts(WebSocket/UI)、修复插件构建错误,或新增渲染功能时使用。

SKILL.md
--- frontmatter
name: figjam-plugin
description: FigJam plugin development workflow. Use when modifying code.ts (canvas rendering), ui.ts (WebSocket/UI), fixing plugin build errors, or adding new rendering features.

FigJam Plugin Development

Architecture

ThreadFileAPIsRole
Maincode.tsfigma.* onlyCanvas rendering
UIui.tsBrowser APIsWebSocket client, connection UI

Critical: code.ts has NO browser APIs (window, document, fetch, WebSocket).

Communication

code
CLI ←─ WebSocket ─→ ui.ts ←─ postMessage ─→ code.ts ←─ figma.* ─→ Canvas

Build & Import

bash
cd packages/plugin && bun run build

Import: Figma Desktop → Plugins → Development → Import from manifest → packages/plugin/manifest.json

Debugging

  • UI errors: Right-click plugin UI → Inspect
  • Main errors: Plugins → Development → Open console

JSON Import

  • Accepts DSL (nodes array) or IR (nodes object)
  • Validates with @figram/core, normalizes to IR
  • Errors shown in alert with path + message

Key Files

FilePurpose
manifest.jsonPlugin config
src/code.tsCanvas rendering
src/ui.tsWebSocket + UI
src/icons/Service icons