| doc_id | fusion-design/readme | ||||
|---|---|---|---|---|---|
| product | fusion-design | ||||
| class | platform | ||||
| entry | developer | ||||
| doc_type | readme | ||||
| title |
|
||||
| audience | developer | ||||
| status | draft | ||||
| version | 0.1.36 | ||||
| updated | 2026-12-02 | ||||
| owner | @dahai | ||||
| source_of_truth |
|
Local offline AI visual design workbench for macOS — built on OpenPencil (Rust) + fusion-mlx local multimodal inference, embedded in Fusion-Desk WKWebView.
Status: v0.1.36 closes issue #58 (two-way design-system sync surface for agents: the new fusion-design tokens-export subcommand emits a builtin design system's tokens as machine-readable JSON — name/value pairs with the dark overlay merged and CSS custom properties — deliverable via file or fd-ecosystem IPC, and the new fusion-design verify-proposal subcommand parses an agent component proposal (HTML or PenDocument JSON) and lints it against the desigma gate with a JSON verdict plus a binary exit code, also deliverable via IPC; six e2e contract tests pin the pull, write-back, and IPC paths). v0.1.35 closes issue #56 (nightly-20261202 design-d03 regression: GET /api/tokens used to flip the registry-global theme on every call — a GET with a global side effect — and the concurrently-run eval suite raced d04's dark fetch against d03's /api/design-systems read; the global is now untouched, requested theme stays local to the response, contract test pins the fix). v0.1.34 closes issue #54 (nightly-20261129 design-d14 regression: root cause is the eval-side verify contract content == listing summary, broken after the fusion-eval artifacts vision cohort created long multi-line artifacts in the shared engine whose listing summary is truncated to 200 chars; fd-server proxies engine fields verbatim — no product defect, upstream fusion-eval#47, version-bump-only release). v0.1.33 closes issue #52 (start.sh now resolves FUSION_CLIENT_KEY durably — env first, then gateway config auth.api_keys[admin], same chain as supervisor — after the nightly eval ran keyless and every /api/generate got fusion-mlx 403; real-model generate verified live). v0.1.32 closes issue #50 (nightly-eval design regression: restored the eval-pinned user-facing strings the v0.1.31 English-only pass had translated — /api/version 400 payloads and the 编辑:n1 mutate version label — with new contract pins so translation passes cannot touch product strings again; start.sh now warns at start when FUSION_CLIENT_KEY is unset after the d28 403 root cause). v0.1.31 closes issue #48 (English-only source cleanup: all Chinese comments, log messages, and error strings translated to English across the 15-crate workspace; remaining CJK is intentional user-facing/i18n prompt strings and UTF-8 test fixtures, marked // i18n:; also fixes unwrap-expect-allowlist drift after translation and bumps url 2.5.9 for RUSTSEC-2026-0592). v0.1.30 closes issue #45 (CI retrofit per the fusion#2 checklist: concurrency group with cancel-in-progress on ci.yml/docs.yml, docs-only PR path-ignore on the Rust gate; sharding/tiered-gate assessed and not adopted with reasoning) and clears 7 new RustSec advisories at the dependency level — tokio 1.54.1, rustix 1.1.6, quinn-udp 0.5.16, chacha20 0.10.2, resvg 0.45→0.50 (drops unmaintained rustybuzz/ttf-parser), scraper 0.22→0.29 (drops unmaintained fxhash); zero audit.toml ignores. v0.1.29 closes issue #44 — a design-intelligence data layer: six curated offline CSV datasets (24 styles, 24 palettes, 20 font pairings, 40 UX guidelines, 12 chart types, 16 per-stack notes, authored in-repo), a new fd-search crate with deterministic keyword scoring, fusion-design search CLI, GET /api/design-intel/search, automatic [Design intelligence] context injection into /api/generate, and a provenance sha256 data-QA test enforced in CI (docs/DATASETS.md). v0.1.28 closes issue #43 — start.sh shell-manifest registration now sends admin auth (FUSION_ADMIN_KEY env, falling back to gateway config web_shell.admin_key, same order as supervisor/cowork) so the fusion-design module actually registers with the gateway; failure modes (401/403 vs 404 vs unreachable) are logged distinctly instead of one opaque "skipped". 14 crates + vendored op-ai, 556+ tests pass, WASM build verified, CI green (fmt/clippy/test/wasm/deny-panic/deny-unwrap-expect/deny-external-http/cargo-audit), release packaging. v0.1.27 closes issue #41 — a desigma acceptance gate in fd-design-lint (4 Error-severity token-alignment rules: bare color literal, off-token spacing/radius, missing dark pair; --profile desigma --gate gives cowork a binary exit code; new builtin desigma-aligned preset with dark pairs on every token; mapping doc docs/DESIGMA_TOKEN_MAPPING.md) — and issue #42 — the web workbench is now a standard union-web shell module (web/manifest.json per PRD §5.1, ?embedded=1, token panel with constrained picking, canvas drag persisted via the new POST /api/session/<id>/mutate, Save .fusiondesign, inline 401 that never redirects; gateway hosting requested upstream in dahai80/fusion-gateway#601). v0.1.26 fixes the router so unknown /api/* paths return 404 instead of a misleading 405 (acceptance issue #36) — 405 is now reserved for known paths with a wrong method; the reported api/v1/share-base frontend references do not exist in this repo's bundle (share state lives in fusion-artifacts-engine). v0.1.25 closes the acceptance issue #35: one unified API contract (docs/API.md) with field-located 4xx errors ({"error","field"}) across generate/iterate/rollback/restore/export, a GET-only tokens endpoint with 405 hints, a pinning contract test suite, and the minimum canvas UX — layer list, node selection wired through the wasm bridge (node.select / node.click), and visible undo/redo stepping the version stack. v0.1.24 adds region-based iteration for long docs: /api/iterate accepts region:[node_id,...], sends only the selected nodes (O(region) instead of O(doc)) with a fixed stable-prefix prompt order (constant system prompt, user = TOC → changelog → base JSON → instruction), then merges results back deterministically — unlisted nodes are guaranteed unchanged; also fixes a parse round-trip bug (node kind is now case-insensitive, model echo of PascalCase no longer fails). v0.1.23 makes the workbench model selectable (chat models only, no more showing the embedding model bge-m3) and follows the shell-standard theme/language switching (module-local toggles removed). v0.1.22 fixes a duplicate-ingest bug: Save to Artifacts used to write the IPC message and create the artifact over REST, so the engine's own IPC consumer stored a second type=data copy; REST is now primary and IPC is only a fallback when the engine is down. v0.1.21 adds an in-place Artifact viewer: clicking a card opens artifact.html?id=... and renders the artifact body (HTML in a sandboxed iframe), with download and continue-in-workbench actions, instead of re-opening the chat. v0.1.20 turned the Design module entry into an Artifacts landing page (All / Mine / Shared tabs, search + sort, three create cards for Document / Slides / Design that pre-fill the chat prompt, paginated artifact grid) and makes "Save to Artifacts" really create the artifact in fusion-artifacts-engine instead of only writing an unused IPC message. v0.1.19 aligned the workbench UI with the fusion-web-shell design language. v0.1.18 added the fd-server web workbench. See docs/changes/v0.1.36.md and docs/API.md.
Fusion-Design is one of the flagship products in the Fusion-MLX "one core, nine endpoints" matrix, positioned as a fully local offline, AI conversational UI/prototype design workbench.
| Dimension | Value |
|---|---|
| Comparable products | Claude Design (cloud, closed-source), Figma, Penpot |
| Inference engine | fusion-mlx (local multimodal LLM inference, cloud models forbidden) |
| Platform | macOS Apple Silicon (M-series, Metal/ANE hardware acceleration) |
| Foundation | OpenPencil (Rust) secondary encapsulation + custom fusion-mlx adapter |
| Core positioning | Bidirectional sync with Fusion Code, design-to-runnable-code in one click |
| License | Apache-2.0 |
- ✅ 100% local offline — all AI generation, design files, and assets stay on-device, zero cloud uploads
- ✅ Native Apple MLX — local multimodal vision model driven, no API fees, no network dependency
- ✅ Deep Fusion ecosystem integration — links with simulation, automation, knowledge base, and code tools
- ✅ Native desktop app — embedded in Fusion-Desk WKWebView, no standalone web page needed
- ✅ Open-source foundation — no vendor lock-in, private deployment supported
- Infinite vector canvas — zoom/pan/grid/multi-artboard/layer management, CSS Flex/Grid layout declarations (rendered by layout-aware codegen / browser)
- Conversational AI design generation — text-to-UI, image-to-UI, SSE streaming, multimodal visual input
- Local design system — two built-in specs (Apple HIG / Admin Dashboard), Light/Dark themes, global Token sync
- Design lint + auto-fix — 13 lint rules + auto-fix for Token references / null cleanup / auto-naming
- Fusion Code bidirectional sync — canvas one-click export to React/HTML/Tailwind, reverse style sync
- Prototype interaction & handoff — PNG/SVG/PDF/HTML export, batch export
- Ecosystem integration — Simulation / Desk / KB / CLI full integration, async file watching, template tag search
- Undo/Redo + Diff — snapshot stack (50 levels) + node-level Diff
- Full-featured CLI — generate / export / export-batch / lint --fix / undo / redo / health / diff / theme / chat(机器可读流式 NDJSON delta/chat_done/error,CLI/脚本管道消费;issue #17 设想 studio 经此入口取代直连 MLX,但核实 studio 走 gateway TCP chat_event,本子命令无 studio 消费方)
- Design spec document generation — AI auto-generates interaction specs / component specs / page architecture docs (SpecDocSkill)
- Page flow batch generation — AI generates multi-page layouts from flow descriptions with unified style (PageFlowSkill)
- Named version management (REMOVED) — version snapshots / switching / renaming / deletion / adjacent diff comparison
死代码清理(H-A14/P2-4):
VersionedDocument/NamedVersion命名版本 API(save_version/switch_to/diff_versions 等)跨 crate 零生产消费者,.fusiondesign实存裸PenDocument,CLI undo/redo 走独立UndoRedoStack。审计定性「260 行死代码」,save_version 同时入版本表+undo 栈致进程内双份深拷贝。已整段移除(同 H-A13 apply_patch);随同移除 uuid_v4/now_iso/civil_from_days/VERSION_SEQ/MAX_VERSIONED_FILE_BYTES。撤销/重做能力不受影响(feature 8 的UndoRedoStack独立提供)。如未来需命名版本,按 delta-COW 设计,勿复活整快照方案。
- Built-in scene templates — 4 preset categories (mobile app / admin dashboard / marketing site / mini program), one-click install
fusion-design/
├── crates/ ← Fusion-Design custom Rust crates (workspace)
│ ├── fd-canvas-core/ ← Canvas data model (PenDocument/PenNode + UndoRedo/Diff, Flex/Grid layout declarations)
│ ├── fd-ai-adapter/ ← op-ai → fusion-mlx adapter (SSE streaming / multimodal vision / 7 Skills)
│ ├── fd-codegen/ ← HTML/React+Tailwind code export (layout-aware Flex/Grid CSS)
│ ├── fd-design-system/ ← Three built-in design specs (Apple HIG / minimal dashboard / robot-sim) + Token + Light/Dark themes
│ ├── fd-design-lint/ ← 13 lint rules + auto-fix (Token references / null cleanup / auto-naming)
│ ├── fd-ecosystem/ ← Ecosystem integration (file IPC + template tag search + 4 built-in scene templates)
│ ├── fd-host-desk/ ← Fusion-Desk WKWebView host bridge
│ ├── fd-host-web/ ← WASM frontend rendering (WebShell + BridgeCommand)
│ ├── fd-export/ ← PNG/SVG/PDF/HTML batch export
│ ├── fd-server/ ← Web workbench HTTP service (:11493, issue #31) — chat generate/iterate/restore/export/rollback + WASM canvas hosting
│ └── fd-cli/ ← CLI (generate/export/lint/undo/redo/health/diff/theme)
├── vendor/
│ └── openpencil/ ← Trimmed OpenPencil subset (Git subtree)
└── frontend/
└── dist/ ← Compiled static assets (loaded by WKWebView)
| Layer | Technology |
|---|---|
| Foundation | OpenPencil (Rust workspace) — op-ai (vendored) |
| AI inference | fusion-mlx (local multimodal, Metal/ANE accelerated) |
| Host | Fusion-Desk WKWebView (macOS native) |
| Frontend | WASM (wasm32-unknown-unknown) + DOM/Canvas rendering |
| Communication | Local private HTTP (127.0.0.1) + WKWebView Bridge |
| Async | tokio + notify (file watching) + futures (SSE streaming) |
Scenario-based usage + troubleshooting (bilingual):
- Usage Guide / 使用指南 — 9 scenarios: first text-to-UI, export, lint+fix, image-to-ui, multi-variant, batch+spec-doc, codegen, streaming pipeline, design-system switch. Plus a 22-subcommand quick reference.
- Troubleshooting / 排障手册 — 12 symptoms → root cause → fix: MLX unreachable, 502/503 loading, false-green models, auth 401, stream break/CJK garble, deserialize over-limit, IPC/path-traversal, Token color unresolved, wasm/studio sync, model drift, lint rules, XSS guardrail.
cargo check --workspace # Full workspace compiles
cargo test --workspace # full suite (+ignored perf/E2E baselines)
bash Scripts/deny-unwrap-expect.sh # 零 unwrap/expect 门禁(allowlist 基线)
bash Scripts/deny-external-http.sh # 出站 HTTP 仅限 fd-ai-adapter(离线硬约束)
cargo test --release -- --ignored perf_baseline # 1000-node perf baseline (<500ms each)
cargo build -p fd-host-web --target wasm32-unknown-unknown # WASM build succeeds
cargo run -p fd-cli -- --help # CLI available
./Scripts/build.sh # Release tarball → dist/
Endpoint 覆盖:CLI --endpoint 默认经 FUSION_MLX_BASE_URL 解析(优先级:显式 --endpoint > env > 默认 gateway 11432),可切回直连 fusion-mlx 11434。鉴权 key 经 FUSION_CLIENT_KEY。
服务可用性校验:fusion-design check-mlx 做三段真探测——endpoint 解析 → /v1/models 鉴权 + 模型列表 → 1-token 真推理探针。gateway 的 /v1/models 会「假绿」(列了云端/本地模型名但 MLX 未加载,generate 实返 502),故最终判定用真 chat 调用。探针模型解析:--model > FUSION_MLX_MODEL > 列表首个(建议显式传本地 mlx 模型 id)。不可用时以非零退出码 + 诊断文案 fail visibly。
M-5 重试退避:fd-ai-adapter 三处 HTTP 路径(blocking_post / chat_stream_messages / check_generate)对 502/503 瞬时错误指数退避重试(500ms→1s→2s→4s→8s 封顶,默认 4 次),等模型加载完成即成功;4xx 永久错误直接失败。FUSION_MLX_RETRY_MAX 调最大尝试次数(设 1 关闭)。流式仅覆盖建连阶段,中途断流不重试。
安全护栏:.fusiondesign 反序列化限制节点嵌套 ≤64、总数 ≤100000;IPC 消息文件 ≤8MB,防恶意输入栈溢出/OOM。
Issues #31/#33: browser-based workbench served by fusion-design-server on 127.0.0.1:11493 — same Rust kernel as the CLI, no cloud calls.
cargo build --release -p fd-server
./start.sh start # http://127.0.0.1:11493
./start.sh status|stop|log
- Chat generation/iteration —
POST /api/generate/POST /api/iterate(retry loop + model-JSON repair chain against degenerate 4-bit outputs) - Screenshot restoration —
POST /api/restore(image → local vision modelQwen2.5-VL-7B-4bit→ editable PenDocument) - Export —
POST /api/export(HTML / React+Tailwind) - Versioning —
POST /api/rollback,GET /api/version/{session}/{n},GET /api/sessions - Ecosystem exits —
POST /api/send-to-code(HTML+TSX into the fusion-code IPC dir),POST /api/save-artifact(save_artifactIPC message for fusion-artifacts-engine) - WASM canvas — the served workbench mounts the real fd-host-web canvas; assets discovered via
FUSION_DESIGN_WASM_DIR> exe dir > cwd > target wasm dirs
Real-model E2E: cargo test -p fd-server --test e2e_real_model -- --ignored (requires gateway :11432 + FUSION_CLIENT_KEY + vision model loaded).
CI:.github/workflows/ci.yml 在 push/PR 到 main 时自动跑 fmt + clippy(-D warnings) + test + wasm build + 双零 panic 门禁(deny-panic 查 panic!/unimplemented!/todo!/unreachable! 宏,deny-unwrap-expect 查裸 .unwrap()/.expect(),后者用 Scripts/unwrap-expect-allowlist.txt 基线,新增站点未在 allowlist 则失败)(ubuntu),main 通过后 macos-15 产出 release tarball artifact(2026-11-02 起 macos-14 runner image 退役,已迁移 macos-15)。
| Crate | Tests | Coverage |
|---|---|---|
| fd-canvas-core | 46 | PenDocument CRUD, UndoRedo, Diff/Patch, JSON round-trip, layout, 安全护栏, perf baseline |
| fd-ai-adapter | 85 | Mock HTTP, SSE streaming, health check, 深度可用性探针(鉴权/模型/真推理), multimodal vision, SpecDoc/PageFlow, E2E 生产路径, endpoint 解析, CJK SSE 跨 chunk 切分, H-A7 ChatProvider 增量分块 |
| fd-design-lint | 41 | 13 lint rules, auto-fix, apply_tokens, FixResult serialization |
| fd-design-system | 25 | Token, Theme, Registry, CSS output, 3 built-in presets (incl. robot-sim) |
| fd-ecosystem | 22 | IPC, sync_to_code, template tag search, built-in scene templates, 文件大小护栏 |
| fd-codegen / fd-host-web / fd-export / fd-host-desk | 4-10 each | Core functionality |
| fd-cli | 7+ | CLI argument parsing, subcommand dispatch, 商用级错误报告 |
./Scripts/build.sh # 产出 dist/fusion-design-<version>-aarch64-apple-darwin.tar.gz
含 fusion-design CLI 二进制(release strip+thin LTO)+ fd_host_web_bg.wasm + fd_host_web.js(WKWebView 前端,wasm-bindgen --target web 产物)+ INSTALL.md。100% 离线,仅 HTTP 至 127.0.0.1。
集成说明:fusion-studio 的
Scripts/build.sh从本仓target/wasm32-unknown-unknown/{release,debug}/拉取fd_host_web_bg.wasm+fd_host_web.js。build.sh已补 wasm-bindgen 后处理步骤,确保 bindgen 产物落地该目录——缺此步则 studio 同步脚本找不到_bg.wasm,回退陈旧内置件。
All optional. Unset = default. Affects runtime behavior without code changes.
| Variable | Default | 作用 / Effect | Set in |
|---|---|---|---|
FUSION_MLX_BASE_URL |
http://127.0.0.1:11432 (gateway) |
fusion-mlx inference endpoint. CLI --endpoint overrides. Comma-separated multi-node failover supported (e.g. http://a:11432,http://b:11432). |
fd-ai-adapter |
FUSION_CLIENT_KEY |
(none) | Bearer auth key for gateway/MLX. Must match the key configured on the service. Legacy alias FUSION_MLX_API_KEY still honored during migration (warns on use, removed 2027-01-01, issue #30). |
fd-ai-adapter |
FUSION_MLX_MODEL |
(list first) | Default model id for check-mlx probe (resolution: --model > env > /v1/models first entry). Pass an explicit local mlx id to avoid false-green on unloaded cloud models. |
fd-cli |
FUSION_MLX_RETRY_MAX |
4 |
Max attempts on 502/503 transient errors (exponential backoff 500ms→1s→2s→4s→8s capped). Set 1 to disable retry. 4xx permanent errors fail immediately. |
fd-ai-adapter |
FUSION_MLX_RETRY_DEADLINE_SECS |
300 |
Total deadline across all retry attempts. Exceeding bails even if attempts remain. | fd-ai-adapter |
FUSION_MLX_SSE_BUFFER_CAP |
8388608 (8 MB) |
Max bytes buffered for a single SSE stream before bail. Guards against runaway model output OOM. | fd-ai-adapter |
FUSION_MLX_STREAM_IDLE_SECS |
60 |
Max idle seconds between SSE chunks. Mid-stream stall beyond this emits error delta and fails visibly (no infinite hang). | fd-ai-adapter |
FUSION_LOG_DISABLE_FILE |
(unset) | Set 1 (or true) to disable file logging (stdout-only). Default writes daily-rotated logs to ~/Library/Logs/fusion-design/ (macOS) or ~/.local/share/fusion-design/logs (Linux). |
fd-cli |
FUSION_LOG_DIR |
(platform default) | Override the file-log directory. Default: ~/Library/Logs/fusion-design/ (macOS) / ~/.local/share/fusion-design/logs (Linux). |
fd-cli |
FUSION_VENV_ROOT |
(auto-detect) | Root path of the shared .venv for ecosystem tool invocation. Falls back to workspace-relative discovery. |
fd-ecosystem |
FUSION_TRAINER_BIN |
fusion-trainer |
Path to the fusion-trainer binary for ecosystem training IPC. Override when not on PATH. |
fd-ecosystem |
FUSION_DESIGN_PORT |
11493 |
Web workbench listen port (fd-server). Registered owner fusion-design in the workspace port-registry. |
fd-server |
FUSION_DESIGN_DATA_DIR |
~/.fusion-design |
Base dir for server data: IPC outbox (fusion-code / fusion-artifacts-engine messages) and logs (logs/server.log). |
fd-server |
FUSION_DESIGN_WASM_DIR |
(discovery chain) | Dir holding fd_host_web_bg.wasm + fd_host_web.js for the web workbench canvas. Default chain: exe dir > cwd > target/wasm32-unknown-unknown/{release,debug}. |
fd-server |
Audit note:
FUSION_MLX_STREAM_IDLE_SECSis introduced by P2 FAULT-1 (v0.1.14).FUSION_LOG_DISABLE_FILE/FUSION_LOG_DIR(file-log toggle + dir override) belong to OPS-13 (v0.1.14, fd-cli 文件日志落地). The other env vars were previously undocumented or inline-only; this table is the single source of truth (OPS-16).
Licensed under the Apache License 2.0.