feat: /understand-figma — Figma design knowledge graph (foundation)#516
Open
smjeong84 wants to merge 20 commits into
Open
feat: /understand-figma — Figma design knowledge graph (foundation)#516smjeong84 wants to merge 20 commits into
smjeong84 wants to merge 20 commits into
Conversation
…tion) Sub-project 1 of 5: Figma REST API ingestion behind a source-adapter seam, shallow structural graph (page/screen/component/componentSet/ instance) + light design-system model (token nodes, uses_token), a new design-analyzer LLM agent, kind:"design" dashboard view with hybrid text-node + sidebar-thumbnail rendering. B/C/D/E captured as roadmap.
15 TDD tasks: schema (design types, figmaMeta, instance_of promotion), core figma module (source adapter, parse-document, tokens, merge, barrel), design-analyzer agent, /understand-figma skill + scan/merge scripts, dashboard node colors + sidebar thumbnail, incremental version skip.
…ercasing sanitizeGraph lowercases every node type, and componentSet is the only camelCase canonical NodeType. Without a lowercased-form alias it became "componentset", failed the enum check, and was dropped along with its variant_of/contains edges — silently losing all component sets from a design graph. Add componentset->componentSet alias + regression test.
The NodeType union widened with 6 design types (page/screen/component/ componentSet/instance/token). NODE_TYPE_TO_CATEGORY is Record<NodeType, NodeCategory>, so the dashboard build failed until every key was present. Group the design types under the existing "code" category (matching the runtime `?? "code"` fallback) so design graphs stay visible by default; a dedicated "design" category is deferred polish.
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.
Why this feature?
Understand Anything already turns code (
/understand), wikis (/understand-knowledge), and business domains (/understand-domain) into interactive knowledge graphs. But a huge part of how a product actually works lives in Figma — screens, component libraries, design tokens, and (for many teams) written product/spec notes kept right inside the file. Today that knowledge is invisible to the tool, so the picture of a product stops at the code boundary./understand-figmaextends the same "analyze anything → navigable graph" idea to Figma so a newcomer can see how a product's screens, design system, and components fit together — the design-side analogue of the architecture graph/understandbuilds for code.Why it's needed (use cases):
This PR delivers the foundation only (see Scope below); the higher-value capabilities are designed for but intentionally deferred so this lands as a reviewable, self-contained unit.
What it does
/understand-figma <figma-url-or-key>:uses_tokenlinks),design-analyzeragent to add summaries / tags / screen-purpose,knowledge-graph.jsonthe rest of the tool uses, taggedkind:"design",How it's used
Prereqs: Node ≥ 22, pnpm ≥ 10, and a Figma personal access token in the environment.
Re-running is incremental: if the Figma file
versionis unchanged it printsUP_TO_DATEand skips.Design & architecture (how it fits the codebase)
Mirrors the existing "new analysis mode" pattern (
/understand-knowledge,/understand-domain): deterministic structural parsing lives in core, the LLM does semantics, and the same schema / persistence / dashboard are reused.packages/core/src/figma/(Node-only) —source/(FigmaSourceadapter seam +FigmaApiSource),parse/(parse-document,tokens),merge.ts, barrelindex.ts; thedesign-analyzeragent; the/understand-figmaskill +figma-scan.mjs/figma-merge.mjs.FigmaSourceinterface, so an offline local-JSON source can be added later with no rework — and it is deliberately kept out of the dashboard's browser-safe subpath exports./understand-dashboardauto-launch.Schema additions (additive, backward-compatible)
page,screen,component,componentSet,instance,token.instance_of,variant_of,uses_token(instance_ofpromoted from an alias to a first-class edge).FigmaMeta(passthrough, alongsidedomainMeta/knowledgeMeta):fileKey,nodeId,thumbnailUrl,dimensions,tokenKind, plus forward-lookingprototypeTargets/componentKey(recorded now so the deferred flow/code-mapping work needs no re-parse).kind:"design"added to the graph union. Existing graphs (nokind→codebase) are unaffected.Verification
pnpm --filter @understand-anything/core test→ 760 passing (incl. new figma suites:api-source,parse-document,tokens,merge, + a schema regression test).pnpm --filter @understand-anything/dashboard test→ 47 passing (incl. a guard test that fails if a design node type is ever dropped from the dashboard's visible-types set).pnpm --filter @understand-anything/core buildandpnpm --filter @understand-anything/dashboard build→ green.pnpm lint(eslint .) → clean.figma-scan.mjsfails fast with a friendly error whenFIGMA_TOKENis unset; a test asserts the token never appears in error output./understand-figma <url>against a real Figma file (needs a token) — recommended as the reviewer's acceptance check.Implemented test-first (TDD) and reviewed task-by-task. The review process caught and fixed three real issues, called out for transparency:
componentSet(the only camelCase node type) was being dropped by the schema's lowercasing sanitizer → added acomponentset → componentSetnormalization alias + regression test.page → articlealias would have rewritten designpagenodes → removed (knowledge agents emitarticledirectly).allVisibleTypes) → fixed and locked with the guard test above.Security
FIGMA_TOKENis read from the environment only; it travels solely in theX-Figma-Tokenheader and is never written to the graph,meta.json, logs, or intermediate files.api.figma.com— a departure from the otherwise fully-offline pipeline. This is documented in the skill and surfaced to the user.Scope & roadmap
This PR is the foundation (ingestion + structure + light design-system model). Deferred to their own spec → plan → PR cycles (designed for, not built here):
navigates_to+ flow view)figmaMeta.componentKey↔ the code graph)claim/entitynodes)Docs
docs/superpowers/specs/2026-06-24-understand-figma-foundation-design.md(+ Korean…-design.ko.md)docs/superpowers/plans/2026-06-24-understand-figma-foundation.mdNotes for reviewers