Skip to content

feat: add get_component_api and set_instance_properties#3

Merged
awdr74100 merged 1 commit into
mainfrom
feat/component-prop-api
Jun 24, 2026
Merged

feat: add get_component_api and set_instance_properties#3
awdr74100 merged 1 commit into
mainfrom
feat/component-prop-api

Conversation

@awdr74100

Copy link
Copy Markdown
Owner

What

Two paired tools that close the design-system prop-API gap in both directions (tools 88 → 90):

  • get_component_api (read) — resolve a COMPONENT / COMPONENT_SET / INSTANCE to the node that owns the property contract and return its componentPropertyDefinitions as { id, name, type, properties }. Property names come back verbatim for the write tool: VARIANT by bare name ("Size"), BOOLEAN/TEXT/INSTANCE_SWAP suffixed #id ("Label#2:0"). Targeted by one nodeId, so no doc-wide scan.
  • set_instance_properties (write) — instance.setProperties() using those exact keys. Value is a typed union (string | boolean | { type:"VARIABLE_ALIAS", id }), mirroring set_variable_value. Unspecified properties keep their value.

Why

Previously codegen could only render an instance's current values and figma-build could create_instance but never configure its props. Now codegen can emit a component's full prop types, and build can drive variant / boolean / text / instance-swap props.

Equal-or-better (no regression)

Both are pure additions — no existing tool changes, and the hot path (get_design_context) is deliberately untouched (the read is a separate, bounded tool, not a field on the tree). The full existing suite stays green.

Wiring & docs

Registered server + plugin (cross-package registry guard passes); referenced in the figma-build / figma-codegen skills and the code_to_figma / figma_to_code prompts; tool-count prose bumped 88 → 90.

Not batchable (by design)

set_instance_properties is intentionally not in the batch allowlist (same as swap_component): a VARIANT change is a variant swap with no faithful inverse, so it can't honor batch's all-or-nothing rollback. It fails fast with a clear message inside a batch.

Verification

  • pnpm typecheck && pnpm lint && pnpm format:check && pnpm knip && pnpm build && pnpm test — green (675 tests / 130 files).
  • Live round-trip in Figma against a real 3-axis button variant set + #id boolean: get_component_apicreate_instanceset_instance_properties (Size/Type/State + Show icon_R#…: false) → get_design_context confirmed every value applied, the underlying variant swapped, the icon hid, and the unspecified boolean kept its default. Test instance cleaned up.

Expose a component's full property contract and let an agent configure an
instance's properties — closing the design-system prop-API gap in both
directions (codegen reads the contract; build configures instances).

- get_component_api (read): resolve a COMPONENT / COMPONENT_SET / INSTANCE
  to the node that owns the contract and return its
  componentPropertyDefinitions, keyed verbatim — VARIANT by bare name,
  BOOLEAN/TEXT/INSTANCE_SWAP suffixed #id. Targeted by one nodeId, so no
  doc-wide scan and no get_design_context payload change.
- set_instance_properties (write): setProperties with those exact keys;
  value is a typed union (string | boolean | VARIABLE_ALIAS), mirroring
  set_variable_value. Unspecified properties keep their value.

Both are pure additions: no existing tool changes and the hot path
(get_design_context) is untouched. Wired into the figma-build /
figma-codegen skills and the code/figma prompts. Tools 88 -> 90.

Not batchable by design (same as swap_component): a VARIANT change is a
variant swap with no faithful inverse.
@awdr74100 awdr74100 merged commit b3258dc into main Jun 24, 2026
2 checks passed
@awdr74100 awdr74100 deleted the feat/component-prop-api branch June 24, 2026 18:38
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.

1 participant