Skip to content

feat(plugin-design): the design plugin rewritten on machines and Effect - #1252

Merged
omridevk merged 42 commits into
mainfrom
feat/design-rewrite
Nov 28, 2026
Merged

omridevk merged 42 commits into
mainfrom
feat/design-rewrite

Conversation

@omridevk

@omridevk omridevk commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

What

@conciv/plugin-design rewritten from scratch, at feature parity with the old design extension (design-catalog branch), on the plugin API. The old code was read for behaviour only; nothing is copied. Spec: docs/specs/design-rewrite.md; behaviour inventory: docs/specs/design-rewrite-features.md.

  • Logic is machines. Every decision is a pure <name>-machine.ts (state, event, effect unions and one transition, or pure functions for stateless steps): Figma reading, pairing, the gate, reflow, progress, verdict, the check flow itself, the cascade, stamping, the catalog walk. No I/O, clock or randomness in a machine.
  • Everything async is Effect. Figma REST, files, rasters, the pixel diff, page operations, the store and the bundler hooks are Effect services with typed errors in the plugin's evlog catalog. The pixel diff is one PixelDiff interface with a blazediff layer (the check's score) and a pixelmatch layer (the masks).
  • Tools: design_get, design_check, design_status, design_query (CEL over the stored check log), design_components.
  • Figma reading: REST or an attached document and image; frame pick, tree, roles, layout, structure and implied groups, reflow tags, paint sampling, fill stacks with blend modes, components, tokens. Assets are written to the project's public/design/ and cached in the plugin's storage.
  • No runs. design_get({frames}) reads frames, cached by Figma's file version. design_check({frames}) is refused unless those frames were read in the session. Per session and frame set the plugin keeps the last rounds for progress and the stop rules; checks on one frame set queue.
  • Page access, no page plugin change. The plugin waits for edits with the page rpc's hmr.wait and registers its own page operations: measure in a mirror iframe at a width, element shots, pictures, the tab's route.
  • COM ids. The bundler transform stamps JSX (data-conciv-key, -site, -instance) from a per-dev-server key map, never writing user files; component call sites are stamped through the ref (ref={concivStamp(...)} from the plugin's virtual module). Source lines come from the key map.
  • Store: the plugin's own SQLite under its storage directory (drizzle, generated migration) for the check log and the component catalog (walk with oxc-resolver, parse5 and get-tsconfig; rank, relate, drift, fingerprints).
  • Figma key: integration figma (key + env FIGMA_API_KEY), settings page and the design_get card, kept from the closed feat(plugin-design): Figma sources and design_get with the Figma key as a plugin integration #1234. The key is Redacted everywhere and the X-Figma-Token header is redacted in logs.

Not carried over, by decision: the old UI and the x-ray, the PNG design path (OCR, segmentation), the component preview page (comes back with the design UI work), options and tolerances nothing read, the comparator option.

Outside the plugin

  • apps/examples/tanstack-start: adds the design plugin so the rewrite can be tried there.
  • pnpm-workspace.yaml catalog: @blazediff/core, pixelmatch, culori, color-blend, pngjs, @types/culori, @types/pngjs, @marcbachmann/cel-js, oxc-resolver, parse5, get-tsconfig; pnpm-lock.yaml.

Tests

None in this PR, by decision: product code first, tests in a follow-up PR. The plugin's old tests, written for the code this replaces, are removed; conciv.testBudget is 0.

Known follow-ups

  • fix(backend-app-api): plugin bundler hooks wait while plugins start or reload #1254 (plugin bundler hooks wait while plugins start or reload) fixes a hydration mismatch on a page loaded while this plugin reloads; merge it first.
  • The engine's HttpClient does not reach an Effect plugin's start context, so the plugin falls back to FetchHttpClient when none is given (the simulation network does not reach Figma calls yet).
  • The Effect plugin entry does not type-check a service requirement no layer provides; a missing layer fails only at runtime.

🤖 Generated with Claude Code

omridevk and others added 30 commits November 28, 2026 20:06
…nd Effect services

Figma facts, tree, roles, layout inference, structure with implied groups,
reflow tags, components and token names as pure machines; Figma REST, frame
reading, the design cache and the session memory as Effect services; the
Figma key integration and its settings page and refused-key card.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hines

Id tree, Figma pairer (a pure fold), mapping, gate, paint and border rows,
wraps, page height, drift, effect rows, reflow at widths, progress, verdict and
round assembly as machines; raster on pngjs with the pixel score on blazediff
and the masks on pixelmatch as two Effect layers; colours on culori; the check
service runs one check at a time, waits for edits with the page's hmr.wait,
retries a measure an edit lands in, and keeps per-session, per-frame-set memory.
Adds the approved culori, color-blend, pngjs, @blazediff/core and pixelmatch
catalog entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…y runs its effects

CheckMachine holds every decision of a frame check as State/Event/Effect:
measure retries when an edit lands, early exits, the collapse revote, the
unsettled streak against stallRounds, keeping the last ids and mapping while
unsettled, the variants rule and the status outcome. The checker runs load,
settle, measure, confirm, decode, compare and persist effects and feeds the
results back as events. The pairer's scoring terms move to PairTermsMachine so
both files stay under 600 lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… one check queue per frame set

The browser part registers design.measure and design.shots. A same-origin mirror iframe loads the route at the
asked width; the reads (CSSOM snapshot, stamped element walk, page facts, runtime errors) are Effect services
(Mirror, PageReader, Capture) and every derivation is a pure machine: the cascade (scan, plan, specificity on
postcss-selector-parser, winner, sizing, media), the styles, the live tree with instance stamps, the page facts.
Checks on one frame set queue behind a semaphore per session and frame set, owned by the checker layer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A compile machine keeps the last build error (first non-blank line, ANSI stripped, cwd-relative file, query cut) and
clears it when the same file sends an HMR update. A check that settles while a compile error stands writes a broken
round with the compile line and replies with it; the runtime-thrown round shares the same broken outcome.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each design_check round is logged into the plugin's own SQLite (drizzle, its own migration, under the plugin
storage directory) as records per source: rounds, rows, missing, candidates, widths, regions, fom and nodes. A log
machine builds the records; the checker only writes them. design_query reads one source of this session (all
sessions when the where names session), filters and selects with CEL in an Effect service with typed parse and
eval errors, and orders and pages in a machine. The CEL expressions are Schema-validated tool input. Adds
@marcbachmann/cel-js 8.0.0 to the catalog.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The check log migration is generated as backend-defaults does: drizzle.config.ts, drizzle-kit generate into
drizzle/, and the gen-migrations script writing src/store/migrations.gen.ts from those files. The hand-written
migration module is gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… frame's assets

Paint sampling: a box with no paint gets its background from the frame render, and a gradient or picture when its
row and column means say so (a childless picture becomes an image node). Assets: the image, vector and fill-stack
nodes are written into public/design/ and the plugin storage cache, from the cache, else Figma REST (batched
exports halving on 414, image fills decoded with photon and flattened with color-blend), else cropped from the
frame render; the nodes get fields.asset and assetLayers, and the read reports the assets line. Wanted nodes,
crops, flattening and the report are machines; the service only fetches, decodes and writes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The rounds record of the check log carries image_mismatch, the share of each
image node's picture that did not match, in a new check_log column (migration
generated with drizzle-kit, migrations module regenerated).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The store never shipped, so check_log, catalog and image_mismatch are folded
into one generated init migration; migrations module regenerated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The plugin built its own fetch client, which bypassed the client the engine
provides to plugins (the simulation's fixed network table among them).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…(spike, not yet run green)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er all measured rounds (review 1 items 1, 6)

Progress ran on the gate rows only against all rows of the previous round, so
page, drift, effect, image, reflow and component rows read as closed every round,
and reflowHeld saw no reflow rows on this side. It now runs on the assembled
round's rows. kept[].repeat counts back over every measured round instead of the
last one only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…key store read off the REST path (review 1 items 2, 20)

Every attached frame without a link keyed as 'attached' (or by its raw JSON), so
responsive sets collapsed and the cache served the wrong frame. An attached frame
now keys as attached/<version>/<frame node id>. The Figma key store is read only
when the frame goes to the REST API.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e engine's own HMR record (review 1 items 3, 4, 9)

The plugin now records every hmr-update the bundler reports (count and time on the
engine clock). Settle waits until settleQuiet ms passed with no update and gives up
at settleQuiet + settleWait, instead of one long hmr.wait that idled when nothing
was pending; the page's hmr.wait runs only when an update arrived, so the page has
applied it. An edit during the measure is the update count moving between settle
and confirm, not a 1 ms hmr.wait. A compile error clears on the next successful
update of any file or a bundler reconnect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…dit age, early exits skip the widths, one mirror user at a time, routes are page paths (review 1 items 5, 11, 17, 18)

5: the mirror no longer listens on the host window; its error list is cleared
for every fresh mirror and stamped on the Effect clock; editedAgoMs is the time
from the last HMR update to the measure, not a fixed settleWait.
18: the early-exit decision runs on the first measure, so an unchanged or still
blank page skips the reflow widths.
11: measure and shots take one mirror lock, so they no longer remove each other's
iframe.
17: page operation and design_get routes are Schema'd as paths on the page origin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…folder (review 1 item 14)

Node ids are reduced to letters, digits, _ and - before they name a file, and a
write whose resolved path leaves the folder fails as UNWRITABLE.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s in an error cause (review 1 item 19)

Requests to Figma add x-figma-token to Headers.CurrentRedactedNames, and
FIGMA_REQUEST carries the failure reason instead of the HttpClientError (whose
request holds the header).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…path through a design.route page operation (review 1 item 8)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ne function per key, site and user ref, and React 18 plain function components get no ref (review 1 item 10)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rsion the session read, not the newest under the frame key (review 1 item 12)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lus the last settled one, round numbers come from the rounds, a deleted session drops its memory and locks (review 1 item 13)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…er resolve, token parse, cache decode/read) are logged with their cause (review 1 item 15)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
omridevk and others added 7 commits November 28, 2026 22:05
…as no match, and reads whether it names session from the CEL AST (review 1 item 16)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…sage (method, url, reason), no _tag read

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ls imports with oxc-resolver and lists rendering components from pure walk machines (Q3)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…data-conciv-site (the ref rewrite dropped it)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…alls back to fetch), and its tools carry the design namespace so they are design_get, design_check and the rest

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ures removed, test budget 0, changeset for the rewrite

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@omridevk omridevk added the plugins-rewrite Extensions rebuilt as plugins on opencode's interfaces label Nov 28, 2026
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 114 files, which is 14 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This organization's CodeRabbit subscription is cancelled. Resubscribe in Billing to continue reviews beyond the free-tier limit.

Check out review usage here.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3da8c907-b60e-4ed8-809b-d8a8d90de45b
Commits

Reviewing files that changed from the base of the PR and between 07375fe and bcae26a.

Files ignored due to path filters: 1

  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 114

  • .changeset/design-plugin-rewrite.md
  • apps/examples/tanstack-start/package.json
  • apps/examples/tanstack-start/vite.config.ts
  • packages/plugins/design/drizzle.config.ts
  • packages/plugins/design/drizzle/20261128193640_init/migration.sql
  • packages/plugins/design/drizzle/20261128193640_init/snapshot.json
  • packages/plugins/design/package.json
  • packages/plugins/design/scripts/build-css.ts
  • packages/plugins/design/src/assets/assets-machine.ts
  • packages/plugins/design/src/assets/design-assets.ts
  • packages/plugins/design/src/assets/fill-stack-machine.ts
  • packages/plugins/design/src/catalog/catalog-machine.ts
  • packages/plugins/design/src/catalog/catalog-round-machine.ts
  • packages/plugins/design/src/catalog/catalog.ts
  • packages/plugins/design/src/catalog/component-rows-machine.ts
  • packages/plugins/design/src/catalog/frameworks-machine.ts
  • packages/plugins/design/src/catalog/hint-machine.ts
  • packages/plugins/design/src/catalog/module-walk.ts
  • packages/plugins/design/src/catalog/parse-module-machine.ts
  • packages/plugins/design/src/catalog/project-facts.ts
  • packages/plugins/design/src/catalog/readme-machine.ts
  • packages/plugins/design/src/catalog/token-machine.ts
  • packages/plugins/design/src/catalog/walk-machine.ts
  • packages/plugins/design/src/check/check-machine.ts
  • packages/plugins/design/src/check/checker.ts
  • packages/plugins/design/src/check/compile-machine.ts
  • packages/plugins/design/src/check/extras-machine.ts
  • packages/plugins/design/src/check/gate-machine.ts
  • packages/plugins/design/src/check/id-tree-machine.ts
  • packages/plugins/design/src/check/image-machine.ts
  • packages/plugins/design/src/check/look-machine.ts
  • packages/plugins/design/src/check/mapping-machine.ts
  • packages/plugins/design/src/check/page.ts
  • packages/plugins/design/src/check/paint-machine.ts
  • packages/plugins/design/src/check/pair-machine.ts
  • packages/plugins/design/src/check/pair-terms-machine.ts
  • packages/plugins/design/src/check/progress-machine.ts
  • packages/plugins/design/src/check/reflow-machine.ts
  • packages/plugins/design/src/check/round-machine.ts
  • packages/plugins/design/src/check/verdict-machine.ts
  • packages/plugins/design/src/check/widths-machine.ts
  • packages/plugins/design/src/check/wraps-machine.ts
  • packages/plugins/design/src/com/jsx-openings.ts
  • packages/plugins/design/src/com/key-map.ts
  • packages/plugins/design/src/com/stamp-machine.ts
  • packages/plugins/design/src/com/stamp.ts
  • packages/plugins/design/src/design.ts
  • packages/plugins/design/src/errors/errors.ts
  • packages/plugins/design/src/figma/components-machine.ts
  • packages/plugins/design/src/figma/facts-machine.ts
  • packages/plugins/design/src/figma/figma-api.ts
  • packages/plugins/design/src/figma/figma-key.ts
  • packages/plugins/design/src/figma/figma-schema.ts
  • packages/plugins/design/src/figma/layout-machine.ts
  • packages/plugins/design/src/figma/link-machine.ts
  • packages/plugins/design/src/figma/paint-sample-machine.ts
  • packages/plugins/design/src/figma/reflow-tags-machine.ts
  • packages/plugins/design/src/figma/roles-machine.ts
  • packages/plugins/design/src/figma/structure-machine.ts
  • packages/plugins/design/src/figma/tree-machine.ts
  • packages/plugins/design/src/geometry/box-machine.ts
  • packages/plugins/design/src/geometry/color-machine.ts
  • packages/plugins/design/src/geometry/text-machine.ts
  • packages/plugins/design/src/key/figma-key-form.tsx
  • packages/plugins/design/src/key/figma-key-model.ts
  • packages/plugins/design/src/key/figma-key-text.ts
  • packages/plugins/design/src/key/figma-key-views.tsx
  • packages/plugins/design/src/machine-driver.ts
  • packages/plugins/design/src/model/catalog.ts
  • packages/plugins/design/src/model/check.ts
  • packages/plugins/design/src/model/design.ts
  • packages/plugins/design/src/model/document.ts
  • packages/plugins/design/src/model/live.ts
  • packages/plugins/design/src/model/tree-machine.ts
  • packages/plugins/design/src/options.ts
  • packages/plugins/design/src/page/capture.ts
  • packages/plugins/design/src/page/cascade-machine.ts
  • packages/plugins/design/src/page/live-machine.ts
  • packages/plugins/design/src/page/mirror.ts
  • packages/plugins/design/src/page/operations.ts
  • packages/plugins/design/src/page/page-machine.ts
  • packages/plugins/design/src/page/page-reader.ts
  • packages/plugins/design/src/page/raw.ts
  • packages/plugins/design/src/page/styles-machine.ts
  • packages/plugins/design/src/plugin-experimental.tsx
  • packages/plugins/design/src/raster/photon.ts
  • packages/plugins/design/src/raster/raster-machine.ts
  • packages/plugins/design/src/raster/raster.ts
  • packages/plugins/design/src/read/design-cache.ts
  • packages/plugins/design/src/read/design-reader.ts
  • packages/plugins/design/src/read/document-machine.ts
  • packages/plugins/design/src/read/frame-reader.ts
  • packages/plugins/design/src/read/read-machine.ts
  • packages/plugins/design/src/scripts/gen-migrations.ts
  • packages/plugins/design/src/session/session-machine.ts
  • packages/plugins/design/src/store/cel.ts
  • packages/plugins/design/src/store/check-store.ts
  • packages/plugins/design/src/store/log-machine.ts
  • packages/plugins/design/src/store/migrations.gen.ts
  • packages/plugins/design/src/store/query-machine.ts
  • packages/plugins/design/src/store/store-schema.ts
  • packages/plugins/design/src/tolerances.ts
  • packages/plugins/design/src/tools/design-check.ts
  • packages/plugins/design/src/tools/design-components.ts
  • packages/plugins/design/src/tools/design-get.ts
  • packages/plugins/design/src/tools/design-query.ts
  • packages/plugins/design/src/tools/tool-error.ts
  • packages/plugins/design/src/tools/tool-options.ts
  • packages/plugins/design/test/it/.gitkeep
  • packages/plugins/design/test/it/design.it.test.ts
  • packages/plugins/design/test/unit/com-keys.unit.test.ts
  • packages/plugins/design/tsconfig.json
  • packages/plugins/design/uno.config.ts
  • pnpm-workspace.yaml

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

omridevk and others added 3 commits November 28, 2026 22:29
…o the rewrite can be tried there

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oading state (spread order), so every check stopped without a reply; no open page is a NO_PAGE error that tells the agent to open the page; a stuck check names its step

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r reload, so a page served then is transformed by every plugin and its SSR HTML matches the client

The design plugin stamps data-conciv-key/-site in its transform hook. A page served
while plugins were (re)activating got server HTML from modules transformed without the
hook and client modules transformed with it, so React reported a hydration mismatch
on every stamped attribute. transform, resolveId and load now await plugin activation,
as plugin.invoke does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@omridevk
omridevk merged commit 4f81409 into main Nov 28, 2026
29 checks passed
@omridevk
omridevk deleted the feat/design-rewrite branch November 28, 2026 23:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plugins-rewrite Extensions rebuilt as plugins on opencode's interfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant