feat: enhance Figma integration with full API property coverage#251
feat: enhance Figma integration with full API property coverage#251rubenmarcus merged 15 commits intomainfrom
Conversation
Wire the existing maxCost infrastructure to a new --max-cost CLI option. When no budget is set, warn users at $2/$5/$10 thresholds to encourage setting a limit. This is opt-in only — no default limit that could break existing long-running loops. Closes #211 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When sourceType is 'figma', inject domain-specific guidelines into the agent preamble: auto-layout to flexbox/grid mapping, color token extraction with @theme inline, typography fidelity, constraint conversion, responsive breakpoints, and placeholder images. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When fetching from Figma in default 'spec' mode, also fetch design tokens (CSS variables) and prepend them to the spec. The agent gets ready-to-use tokens for @theme inline instead of parsing the raw tree. Also pass all Figma CLI options through to fetchFromSource (previously only label/status/limit/issue were passed). Cap in-prompt spec at 15KB to reduce token waste — full spec remains on disk in specs/ directory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Display the model name (e.g. '3-sonnet') and cumulative cost in the loop header subtitle line, and add the full model name to the iteration separator. Users can now see what model is running and how much it costs at a glance. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add 42 new tests covering: - buildIterationContext: preamble content, Tailwind v4 guidance, iteration-aware trimming (full/abbreviated/minimal), plan rules, design quality guidelines, validation feedback, iteration log - compressValidationFeedback: truncation, section headers, ANSI stripping - buildTrimmedPlanContext: task info, subtasks, completion counts - buildCommitMessage: conventional commit detection (feat/fix/docs/ refactor/test/chore), prefix stripping (bracket and colon formats) - buildPrBody: task URL, description truncation, execution details Export buildCommitMessage and buildPrBody for testability. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add ~20 missing Figma REST API properties to types, parsers, and agent guidelines for significantly improved design-to-code fidelity. Layout: layoutSizingHorizontal/Vertical (FIXED/HUG/FILL), layoutWrap, layoutPositioning (absolute children), counterAxisSpacing, layoutAlign, min/maxWidth/Height, clipsContent, scrollBehavior, overflowDirection. Visual: individualStrokeWeights (per-side borders), strokeDashes, rotation, isMask, imageTransform→object-position, image filters→CSS filter(), hero section detection, icon SVG export. Typography: fontStyle, textTruncation + maxLines with CSS line-clamp hints, hyperlink detection. Effects: progressive blur detection, backdrop-filter hints. New parsers: font-checker (Google Fonts validation), image-collector, icon-collector (VECTOR/INSTANCE node detection + SVG export). Agent guidelines updated with sizing, wrap, absolute positioning, overflow, sticky/fixed, borders, rotation, and image filter rules. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Issue Linking ReminderThis PR doesn't appear to have a linked issue. Consider linking to:
Using If this PR doesn't need an issue, you can ignore this message. |
|
| Metric | Value |
|---|---|
| Base | 1962.84 KB |
| PR | 2234.84 KB |
| Diff | 271.99 KB (13.00%) |
Bundle breakdown
156K dist/auth
32K dist/automation
4.0K dist/cli.d.ts
4.0K dist/cli.d.ts.map
16K dist/cli.js
12K dist/cli.js.map
528K dist/commands
28K dist/config
4.0K dist/index.d.ts
4.0K dist/index.d.ts.map
4.0K dist/index.js
4.0K dist/index.js.map
808K dist/integrations
84K dist/llm
804K dist/loop
188K dist/mcp
32K dist/presets
92K dist/setup
40K dist/skills
392K dist/sources
76K dist/ui
124K dist/utils
336K dist/wizard
Greptile SummaryThis PR significantly enhances Figma integration by adding ~20 missing REST API properties for improved design-to-code fidelity. The changes span layout properties (sizing modes, wrap, absolute positioning, overflow), visual properties (per-side borders, rotation, masks, image transforms), typography enhancements (font style, text truncation), and new utility parsers for font validation, image collection, and icon extraction. Key additions:
Issues found:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Figma Source Integration] --> B[Fetch Figma File API]
B --> C[Parse Document Nodes]
C --> D[Font Checker]
C --> E[Image Collector]
C --> F[Icon Collector]
D --> G[Check Google Fonts]
G --> H[Build Font Substitutions]
E --> I[Fetch Image Fill URLs]
I --> J[Download Images]
F --> K[Export Icons as SVG]
K --> L[Download SVG Files]
C --> M[Design Spec Parser]
H --> M
I --> M
K --> M
M --> N[Generate Markdown Spec]
N --> O[Context Builder]
O --> P[Add Figma-Specific Guidelines]
P --> Q[AI Coding Loop]
J --> R[public/images/]
L --> S[public/images/icons/]
Last reviewed commit: ed8854e |
… and sequential patterns - Text/content elements always get higher z-index than visual layers (universal stacking rule) - Classify image semantic importance: person images are CRITICAL priority, never hidden at any breakpoint - Detect sequential/numbered patterns (01, 02, 03) in sibling elements, preserve exact design order - Add Universal Stacking & Layout Rules section to generated implementation plans - Add image-optimizer utility and plan-generator for Figma integration Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Keep PR branch's enhanced Figma features: plan budget tracking, expanded agent guidelines, font substitutions, image downloads, and spec size caps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace magic 0.99 threshold with epsilon-based comparison (1e-4) to eliminate the gap where values in [0.99, 1.0) could cause division by near-zero or inconsistent behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add sanitizeAssetFilename(), isValidFigmaCdnUrl(), and sanitizeSvgContent() utilities. Apply to all four Figma asset download locations in run.ts to prevent path traversal, SSRF, and SVG XSS attacks. Addresses GitHub Advanced Security review comments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🔗 Docs PreviewPreview URL: https://feat-figma-api-enhancements.ralph-starter-docs.pages.dev This preview was deployed from the latest commit on this PR. |
- Rewrite sanitizeSvgContent with iterative stripping for nested/malformed tags - Add PNG magic byte validation (isValidPngBuffer) for all image downloads - Remove existsSync checks before mkdirSync (TOCTOU race conditions) - Remove unused existsSync import from source.ts - Update pnpm-lock.yaml for sharp optional dependency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rewrite sanitizeSvgContent with substring-based parser instead of regex to satisfy CodeQL js/bad-tag-filter and js/incomplete-multi-character-sanitization rules - Fix TOCTOU race in readCache using fd-based stat+read (openSync/fstatSync) - Fix TOCTOU race in image-optimizer using readFileSync buffer instead of separate statSync + sharp(filePath) calls Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
layoutSizingHorizontal/Vertical(FIXED/HUG/FILL),layoutWrap,layoutPositioning(absolute children),counterAxisSpacing,layoutAlign,min/maxWidth/Height,clipsContent,scrollBehavior,overflowDirectionindividualStrokeWeights(per-side borders),strokeDashes,rotation,isMask,imageTransform→object-position, imagefilters→CSSfilter(), hero section detection, icon SVG exportfontStyle,textTruncation+maxLineswith CSS line-clamp hints, hyperlink detectionbackdrop-filterhintsfont-checker(Google Fonts validation),image-collector,icon-collector(VECTOR/INSTANCE node detection + SVG export)Test plan
pnpm buildpassespnpm test:run— all 213 tests passpnpm lint— no new errors (only pre-existing warnings)ralph --from figmaagainst a Figma file with auto-layout, per-side borders, images, icons, and text truncation — verify spec output includes new properties🤖 Generated with Claude Code