feat: add get_component_api and set_instance_properties#3
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two paired tools that close the design-system prop-API gap in both directions (tools 88 → 90):
get_component_api(read) — resolve aCOMPONENT/COMPONENT_SET/INSTANCEto the node that owns the property contract and return itscomponentPropertyDefinitionsas{ id, name, type, properties }. Property names come back verbatim for the write tool:VARIANTby bare name ("Size"),BOOLEAN/TEXT/INSTANCE_SWAPsuffixed#id("Label#2:0"). Targeted by onenodeId, 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 }), mirroringset_variable_value. Unspecified properties keep their value.Why
Previously codegen could only render an instance's current values and
figma-buildcouldcreate_instancebut 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-codegenskills and thecode_to_figma/figma_to_codeprompts; tool-count prose bumped 88 → 90.Not batchable (by design)
set_instance_propertiesis intentionally not in thebatchallowlist (same asswap_component): aVARIANTchange is a variant swap with no faithful inverse, so it can't honorbatch'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).#idboolean:get_component_api→create_instance→set_instance_properties(Size/Type/State+Show icon_R#…: false) →get_design_contextconfirmed every value applied, the underlying variant swapped, the icon hid, and the unspecified boolean kept its default. Test instance cleaned up.