@sxl-studio/bridge 1.7.2 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/README.md +342 -16
  2. package/dist/agent-recipes.d.ts +781 -11
  3. package/dist/agent-recipes.js +886 -13
  4. package/dist/agent-recipes.js.map +1 -1
  5. package/dist/agent-runbook.d.ts +50 -0
  6. package/dist/agent-runbook.js +243 -0
  7. package/dist/agent-runbook.js.map +1 -0
  8. package/dist/asset-upload.d.ts +63 -0
  9. package/dist/asset-upload.js +225 -0
  10. package/dist/asset-upload.js.map +1 -0
  11. package/dist/audit-store.d.ts +15 -0
  12. package/dist/audit-store.js +100 -0
  13. package/dist/audit-store.js.map +1 -0
  14. package/dist/audit.d.ts +4 -3
  15. package/dist/audit.js +37 -4
  16. package/dist/audit.js.map +1 -1
  17. package/dist/auth.d.ts +8 -1
  18. package/dist/auth.js +41 -1
  19. package/dist/auth.js.map +1 -1
  20. package/dist/bridge-agent-workflow-validation-cli.d.ts +2 -0
  21. package/dist/bridge-agent-workflow-validation-cli.js +68 -0
  22. package/dist/bridge-agent-workflow-validation-cli.js.map +1 -0
  23. package/dist/bridge-agent-workflow-validation.d.ts +42 -0
  24. package/dist/bridge-agent-workflow-validation.js +170 -0
  25. package/dist/bridge-agent-workflow-validation.js.map +1 -0
  26. package/dist/bridge-contract-audit.d.ts +45 -0
  27. package/dist/bridge-contract-audit.js +345 -0
  28. package/dist/bridge-contract-audit.js.map +1 -0
  29. package/dist/bridge-health-cli.d.ts +2 -0
  30. package/dist/bridge-health-cli.js +115 -0
  31. package/dist/bridge-health-cli.js.map +1 -0
  32. package/dist/bridge-health.d.ts +33 -0
  33. package/dist/bridge-health.js +594 -0
  34. package/dist/bridge-health.js.map +1 -0
  35. package/dist/bridge-live-validation-cli.d.ts +2 -0
  36. package/dist/bridge-live-validation-cli.js +114 -0
  37. package/dist/bridge-live-validation-cli.js.map +1 -0
  38. package/dist/bridge-live-validation.d.ts +39 -0
  39. package/dist/bridge-live-validation.js +1141 -0
  40. package/dist/bridge-live-validation.js.map +1 -0
  41. package/dist/bridge-performance-profile.d.ts +81 -0
  42. package/dist/bridge-performance-profile.js +227 -0
  43. package/dist/bridge-performance-profile.js.map +1 -0
  44. package/dist/bridge-readiness-cli.d.ts +30 -0
  45. package/dist/bridge-readiness-cli.js +242 -0
  46. package/dist/bridge-readiness-cli.js.map +1 -0
  47. package/dist/bridge-runtime-summary.d.ts +50 -0
  48. package/dist/bridge-runtime-summary.js +112 -0
  49. package/dist/bridge-runtime-summary.js.map +1 -0
  50. package/dist/bridge-workflow-smoke-cli.d.ts +2 -0
  51. package/dist/bridge-workflow-smoke-cli.js +126 -0
  52. package/dist/bridge-workflow-smoke-cli.js.map +1 -0
  53. package/dist/bridge-workflow-smoke.d.ts +39 -0
  54. package/dist/bridge-workflow-smoke.js +431 -0
  55. package/dist/bridge-workflow-smoke.js.map +1 -0
  56. package/dist/codeconnect-suggestions.d.ts +74 -0
  57. package/dist/codeconnect-suggestions.js +398 -0
  58. package/dist/codeconnect-suggestions.js.map +1 -0
  59. package/dist/codeconnect-template.d.ts +98 -0
  60. package/dist/codeconnect-template.js +280 -0
  61. package/dist/codeconnect-template.js.map +1 -0
  62. package/dist/command-queue.d.ts +11 -1
  63. package/dist/command-queue.js +200 -1
  64. package/dist/command-queue.js.map +1 -1
  65. package/dist/command-safety.d.ts +13 -0
  66. package/dist/command-safety.js +59 -0
  67. package/dist/command-safety.js.map +1 -0
  68. package/dist/enabled-library-search.d.ts +49 -0
  69. package/dist/enabled-library-search.js +151 -0
  70. package/dist/enabled-library-search.js.map +1 -0
  71. package/dist/figma-mcp-parity.d.ts +49 -0
  72. package/dist/figma-mcp-parity.js +368 -0
  73. package/dist/figma-mcp-parity.js.map +1 -0
  74. package/dist/figma-mcp-skills-parity.d.ts +61 -0
  75. package/dist/figma-mcp-skills-parity.js +434 -0
  76. package/dist/figma-mcp-skills-parity.js.map +1 -0
  77. package/dist/figma-rest-diagnostics.d.ts +50 -0
  78. package/dist/figma-rest-diagnostics.js +314 -0
  79. package/dist/figma-rest-diagnostics.js.map +1 -0
  80. package/dist/figma-rest.d.ts +27 -0
  81. package/dist/figma-rest.js +116 -0
  82. package/dist/figma-rest.js.map +1 -0
  83. package/dist/http-api.d.ts +16 -2
  84. package/dist/http-api.js +329 -17
  85. package/dist/http-api.js.map +1 -1
  86. package/dist/index.js +25 -1
  87. package/dist/index.js.map +1 -1
  88. package/dist/mcp-factory.d.ts +6 -1
  89. package/dist/mcp-factory.js +23 -4
  90. package/dist/mcp-factory.js.map +1 -1
  91. package/dist/mcp-runtime-probe.d.ts +22 -0
  92. package/dist/mcp-runtime-probe.js +777 -0
  93. package/dist/mcp-runtime-probe.js.map +1 -0
  94. package/dist/mcp-server.d.ts +2 -1
  95. package/dist/mcp-server.js +2 -2
  96. package/dist/mcp-server.js.map +1 -1
  97. package/dist/sxl-mcp-instructions.js +99 -26
  98. package/dist/sxl-mcp-instructions.js.map +1 -1
  99. package/dist/tools/audit.d.ts +22 -6
  100. package/dist/tools/audit.js +49 -7
  101. package/dist/tools/audit.js.map +1 -1
  102. package/dist/tools/capability-matrix.d.ts +22 -0
  103. package/dist/tools/capability-matrix.js +38 -0
  104. package/dist/tools/capability-matrix.js.map +1 -0
  105. package/dist/tools/catalogue-bootstrap.d.ts +1 -0
  106. package/dist/tools/catalogue-bootstrap.js +665 -30
  107. package/dist/tools/catalogue-bootstrap.js.map +1 -1
  108. package/dist/tools/code-connect-context.d.ts +3 -0
  109. package/dist/tools/code-connect-context.js +319 -0
  110. package/dist/tools/code-connect-context.js.map +1 -0
  111. package/dist/tools/code-connect-template.d.ts +3 -0
  112. package/dist/tools/code-connect-template.js +111 -0
  113. package/dist/tools/code-connect-template.js.map +1 -0
  114. package/dist/tools/composition.js +15 -30
  115. package/dist/tools/composition.js.map +1 -1
  116. package/dist/tools/compositions-orchestration.d.ts +14 -14
  117. package/dist/tools/compositions-orchestration.js +2 -2
  118. package/dist/tools/compositions-orchestration.js.map +1 -1
  119. package/dist/tools/data.js +839 -27
  120. package/dist/tools/data.js.map +1 -1
  121. package/dist/tools/design-context.d.ts +3 -0
  122. package/dist/tools/design-context.js +197 -0
  123. package/dist/tools/design-context.js.map +1 -0
  124. package/dist/tools/destructive-confirmation.d.ts +10 -0
  125. package/dist/tools/destructive-confirmation.js +25 -0
  126. package/dist/tools/destructive-confirmation.js.map +1 -0
  127. package/dist/tools/diagnostics.js +76 -51
  128. package/dist/tools/diagnostics.js.map +1 -1
  129. package/dist/tools/figma-mcp-design.d.ts +3 -0
  130. package/dist/tools/figma-mcp-design.js +377 -0
  131. package/dist/tools/figma-mcp-design.js.map +1 -0
  132. package/dist/tools/figma-nodes.js +57 -43
  133. package/dist/tools/figma-nodes.js.map +1 -1
  134. package/dist/tools/figma-rc-extended.js +23 -6
  135. package/dist/tools/figma-rc-extended.js.map +1 -1
  136. package/dist/tools/figma-rest.d.ts +39 -0
  137. package/dist/tools/figma-rest.js +279 -0
  138. package/dist/tools/figma-rest.js.map +1 -0
  139. package/dist/tools/git.js +11 -7
  140. package/dist/tools/git.js.map +1 -1
  141. package/dist/tools/large-data.d.ts +14 -0
  142. package/dist/tools/large-data.js +189 -0
  143. package/dist/tools/large-data.js.map +1 -0
  144. package/dist/tools/meta.d.ts +6 -1
  145. package/dist/tools/meta.js +89 -11
  146. package/dist/tools/meta.js.map +1 -1
  147. package/dist/tools/metadata.d.ts +3 -0
  148. package/dist/tools/metadata.js +140 -0
  149. package/dist/tools/metadata.js.map +1 -0
  150. package/dist/tools/mockup.d.ts +15 -156
  151. package/dist/tools/mockup.js +54 -121
  152. package/dist/tools/mockup.js.map +1 -1
  153. package/dist/tools/orchestration.js +75 -47
  154. package/dist/tools/orchestration.js.map +1 -1
  155. package/dist/tools/prompts.d.ts +3 -0
  156. package/dist/tools/prompts.js +219 -0
  157. package/dist/tools/prompts.js.map +1 -0
  158. package/dist/tools/registry.d.ts +19 -1
  159. package/dist/tools/registry.js +4 -4
  160. package/dist/tools/registry.js.map +1 -1
  161. package/dist/tools/resources.d.ts +19 -2
  162. package/dist/tools/resources.js +149 -5
  163. package/dist/tools/resources.js.map +1 -1
  164. package/dist/tools/schema-contracts.d.ts +4763 -0
  165. package/dist/tools/schema-contracts.js +814 -0
  166. package/dist/tools/schema-contracts.js.map +1 -0
  167. package/dist/tools/screenshot.d.ts +3 -0
  168. package/dist/tools/screenshot.js +144 -0
  169. package/dist/tools/screenshot.js.map +1 -0
  170. package/dist/tools/shared.d.ts +11 -1
  171. package/dist/tools/shared.js +55 -2
  172. package/dist/tools/shared.js.map +1 -1
  173. package/dist/tools/styles-orchestration.d.ts +2 -2
  174. package/dist/tools/styles-orchestration.js +13 -5
  175. package/dist/tools/styles-orchestration.js.map +1 -1
  176. package/dist/tools/styles.js +22 -8
  177. package/dist/tools/styles.js.map +1 -1
  178. package/dist/tools/tokens.d.ts +31 -692
  179. package/dist/tools/tokens.js +175 -135
  180. package/dist/tools/tokens.js.map +1 -1
  181. package/dist/tools/variable-defs.d.ts +3 -0
  182. package/dist/tools/variable-defs.js +338 -0
  183. package/dist/tools/variable-defs.js.map +1 -0
  184. package/dist/tools/variables-orchestration.js +13 -5
  185. package/dist/tools/variables-orchestration.js.map +1 -1
  186. package/dist/tools/variables.js +18 -15
  187. package/dist/tools/variables.js.map +1 -1
  188. package/dist/types.d.ts +53 -0
  189. package/dist/ultimate-readiness-audit.d.ts +37 -0
  190. package/dist/ultimate-readiness-audit.js +431 -0
  191. package/dist/ultimate-readiness-audit.js.map +1 -0
  192. package/dist/workflow-planner.d.ts +57 -0
  193. package/dist/workflow-planner.js +464 -0
  194. package/dist/workflow-planner.js.map +1 -0
  195. package/dist/workspace-blob-store.d.ts +6 -0
  196. package/dist/workspace-blob-store.js +9 -0
  197. package/dist/workspace-blob-store.js.map +1 -1
  198. package/dist/workspace-path-http.d.ts +24 -0
  199. package/dist/workspace-path-http.js +146 -0
  200. package/dist/workspace-path-http.js.map +1 -0
  201. package/dist/ws-server.js +16 -3
  202. package/dist/ws-server.js.map +1 -1
  203. package/package.json +21 -2
package/README.md CHANGED
@@ -14,10 +14,47 @@ Official [Figma MCP](https://developers.figma.com/docs/figma-mcp-server/) does n
14
14
 
15
15
  | Need | Use |
16
16
  |------|-----|
17
- | Native file operations where Figma’s MCP tools are enough (context, many canvas writes, variables in supported flows) | **Official Figma MCP** (often remote `https://mcp.figma.com/mcp`) |
17
+ | Native file operations where Figma’s MCP tools are enough (context, many canvas writes, new files, FigJam/Slides, FigJam/Slides asset upload) | **Official Figma MCP** (often remote `https://mcp.figma.com/mcp`) |
18
18
  | Plugin-only workflows: compositions, plugin token/Git APIs, whitelisted node helpers, Dev Mode codegen parity | **SXL Studio Bridge** + plugin Remote Connect |
19
+ | Cross-file/no-plugin reads for known files or teams (`whoami`, file/node metadata, screenshots/image URLs, published components/styles, variables REST endpoints), active-file design context, active-file metadata, variable/style definitions, Figma MCP-compatible library discovery/search, Figma Design image insertion, local Code Connect context/suggestions | **SXL Studio Bridge** (`get_design_context`, `get_metadata`, `get_variable_defs`, `get_libraries`, `search_design_system`, `figma_rest_*`, `get_screenshot`, `upload_assets`, `get_context_for_code_connect`, `get_code_connect_suggestions`) |
19
20
 
20
- Bridge forwards `commandType` + `payload` over WebSocket; **execution is always in the plugin** (whitelist + handlers). Adding an MCP tool in Bridge without the matching plugin handler will return `not_whitelisted`.
21
+ Bridge catalogue entries expose explicit execution metadata:
22
+
23
+ - `execution: "plugin"` — the MCP tool sends one Remote Connect command to the plugin.
24
+ - `execution: "bridge-orchestration"` — Bridge parses/aggregates input and sends one or more plugin commands.
25
+ - `execution: "bridge-local"` — Bridge answers locally and does not require a plugin command.
26
+
27
+ Plugin-routed tools list their exact `pluginCommandTypes`; each one must exist in the plugin Remote Connect whitelist and handlers. Adding a plugin-routed MCP tool in Bridge without the matching plugin contract will return `not_whitelisted`.
28
+
29
+ ### AI agent operating contract
30
+
31
+ When this README is used as context for an AI agent, the agent should treat Bridge as the controlled SXL Studio automation layer, not as a generic canvas scripting surface.
32
+
33
+ 1. Start with `get_bridge_runtime_summary` or `GET /api/runtime-summary`.
34
+ 2. If the task needs the open Figma file and Remote Connect is not connected, stop and ask the operator to open SXL Studio in Figma and enable Remote Connect. Do not fake live Figma results.
35
+ 3. For natural-language tasks, call `route_intent`, then `plan_workflow`, then `preview_workflow` before write tools.
36
+ 4. For screen generation, call `inspect_design_system`, then `validate_screen_spec`, then `build_screen` / `update_screen` with `dryRun: true`, then apply.
37
+ 5. For variable/style export, call `preview_export_variables` before `export_variables`; destructive options require top-level `confirmDestructive: true`.
38
+ 6. For Figma documentation, prefer `apply_doc_spec`, `build_component_doc`, `build_doc_flow`, `bind_variable_palette`, and `build_scenario_from_md` over ad hoc scripts.
39
+ 7. For large scans, request summaries first and use paginated detail tools only for the exact subset you need.
40
+ 8. After writes, re-run the relevant read/audit command and report changed/skipped items plus any visual review that remains.
41
+
42
+ Bridge covers active-file Figma Design + SXL Studio workflows. Official Figma MCP remains the companion for remote-only/new-file work, FigJam/Slides-specific editing, generated diagrams, and hosted-only Code Connect context. Official references:
43
+
44
+ - [Figma MCP server documentation](https://developers.figma.com/docs/figma-mcp-server/)
45
+ - [Figma MCP tools and prompts](https://developers.figma.com/docs/figma-mcp-server/tools-and-prompts/)
46
+ - [Figma skills for MCP](https://help.figma.com/hc/en-us/articles/39166810751895-Figma-skills-for-MCP)
47
+
48
+ | User intent | Start with | Then use |
49
+ |---|---|---|
50
+ | Build or update a Figma screen | `route_intent`, `inspect_design_system` | `validate_screen_spec`, `build_screen` / `update_screen` dry-run, then apply |
51
+ | Render documentation in Figma | `route_intent`, `sxl://agent/recipes/sxl-doc-builder` | `apply_doc_spec`, `build_component_doc`, `build_doc_flow`, `build_scenario_from_md` |
52
+ | Export variables/styles | `preview_export_variables` | `export_variables` with explicit options |
53
+ | Audit raw values or missing bindings | `audit_variable_coverage`, `audit_style_coverage` | paginated `find_*`, dry-run apply suggestions |
54
+ | Analyze component usage/props | `analyze_component_usage`, `analyze_component_prop_usage` | `find_component_usages`, `find_component_prop_usages` |
55
+ | Generate/apply compositions | `compose_from_url`, `list_composition_files` | `bulk_generate_compositions`, `audit_composition_drift` |
56
+ | Connect Figma components to code | `get_context_for_code_connect` | `get_code_connect_suggestions`, `generate_code_connect_template`, `codeconnect_save_binding` |
57
+ | Use repository-backed local storage | Git Sync Local Storage settings | `/api/workspace-blob`, `git_pull`, `git_push` |
21
58
 
22
59
  ### Version compatibility (npm Bridge ⟷ plugin)
23
60
 
@@ -30,28 +67,58 @@ Bridge forwards `commandType` + `payload` over WebSocket; **execution is always
30
67
  | **`1.4.x`** | **`2.1.0+`** (plugin with `apply_token_doc_spec`) | **Doc Spec v1** + `build_token_documentation` / `apply_token_doc_spec`, **MCP resources** `sxl://agent/recipes/doc-tokens` (+ doc-component, doc-composition, doc-flow), expanded MCP instructions for documentation recipes. |
31
68
  | **`1.5.x`** | **`2.2.0+`** | **Doc Builder v2**: `apply_doc_spec` (generic sections), `bind_variable_palette`, `build_component_doc`, `build_doc_flow`. Intent-router resource `sxl://agent/recipes/index` plus `template-discovery`, `doc-spec-v2`. Reinforced anti-patterns in `sxl-mcp-instructions.ts` (`/tmp` payloads, base64 loaders, `use_figma` scripts). |
32
69
  | **`1.6.x`** | **`2.3.0+`** | **Audit & Usage (Phase A)** + **Variables orchestration (Phase B)** + **Styles orchestration (Phase C)** + **Mockup-from-DesignSystem (Phase D)** + **Compositions orchestration (Phase E)**. Phase A: `audit` category — `analyze_variable_usage`, `find_variable_usages`, `render_variable_usage_page`, `audit_variable_coverage`, `find_variable_coverage_misses`, `audit_style_coverage`, `find_style_coverage_misses`, `find_unused_variables`, `find_unused_styles`. Chunked traversal with transitive-alias resolution. Token-economy: summary by default, paginated `find_*` for details. Phase B: new `variables-orchestration` category — `import_variable_spec` (idempotent bulk create / update with aliases), `analyze_variable_order` (read-only ordering diff), `dedupe_variables` (merge duplicates, dry-run by default), `rebind_variable_aliases` (bulk alias rewrite), `apply_coverage_suggestions` (audit suggestions → real bindings, dry-run by default). Phase C: new `styles-orchestration` category — `import_style_spec` (idempotent bulk create / update of Paint / Text / Effect styles), `dedupe_styles` (merge duplicates `byName | bySignature`), `rebind_style_consumers` (bulk styleId rewrite on consumer nodes), `audit_style_drift` (read-only drift between local Paint styles and Variables / `expectations[]`), `apply_style_coverage_suggestions` (Phase A `find_style_coverage_misses` → real `setStyleId*` writes). Phase D: new `mockup` category — `find_components` (read-only paginated catalogue of local + library-instantiated components with `componentPropertyDefinitions`, Dev-Mode compatible), `build_mockup` (declarative auto-layout assembly from an `instance | section | spacer | text` item tree with property / text / fill-binding overrides; `dryRun`-aware), `apply_mockup_dataset` (clone a template per dataset row with row-specific overrides; `dryRun`-aware). Phase E: new `compositions-orchestration` category — `bulk_generate_compositions` (bulk `generate` / `apply` of composition files with `fileIds | names | prefix` filters, `operation: auto | generate | apply`, per-item error isolation, `dryRun`-aware), `audit_composition_drift` (read-only drift detection between workspace composition files and tracked Figma components: `linked | unlinked | drift | missing`, Dev-Mode safe). All write commands accept `dryRun` / `apply` so Dev Mode can be used as a preview surface. Recipes: `sxl://agent/recipes/{variable-usage,audit-coverage,find-unused,bulk-variables,auto-bind-from-audit,bulk-styles,style-drift,mockup-builder,bulk-compositions,composition-drift}`. |
33
- | **`1.7.x`** | **`2.3.0+`** (plugin with Git Sync Local Storage) | **Workspace blobs API** (`GET|POST|DELETE /api/workspace-blob`): disk-backed cache for large Git Sync payloads so token/dataset bodies stay out of Figma `clientStorage`. Uses OS cache dir (`env-paths`, product id `sxl-studio-bridge`) under `workspace-blobs/` unless overridden by `SXL_BRIDGE_WORKSPACE_BLOB_ROOT`. Same `BRIDGE_AUTH_TOKEN` rules as other `/api/*`. Does **not** require an active Remote Connect WebSocket session. |
70
+ | **`1.7.x`** | **`2.3.0+`** (plugin with Git Sync Local Storage) | **Workspace blobs API** (`GET|POST|DELETE /api/workspace-blob`): disk-backed cache for large Git Sync payloads so token/dataset bodies stay out of Figma `clientStorage`. Uses OS cache dir (`env-paths`, product id `sxl-studio-bridge`) under `workspace-blobs/` unless overridden by `SXL_BRIDGE_WORKSPACE_BLOB_ROOT`. Same `BRIDGE_AUTH_TOKEN` rules as other `/api/*`; if auth is enabled, enter the same token in the plugin Sync connection's **Bridge Auth Token** field. Does **not** require an active Remote Connect WebSocket session. Contract stabilization: MCP version follows `package.json`, `route_intent` maps RU/EN natural language to SXL recipes/tools/schema hints, `plan_workflow`/`preview_workflow` add dry-run/approval gates for multi-step chains, `list_tools`/`/api/tools` expose aliases, natural-language intents, dry-run and large-data flags, `get_capability_matrix` returns a machine-readable tool matrix, `get_contract_audit` verifies required meta tools/schema entrypoints/workflow gates, `get_bridge_audit_log` reads memory or persisted JSONL audit, MCP tools return normalized envelopes, `export_variables` uses plugin-safe defaults, Code Connect accepts full binding metadata, exposes schema resources, suggests local bindings through `get_context_for_code_connect` / `get_code_connect_suggestions`, and generates dry-run-first `.figma.ts` templates through `generate_code_connect_template`, enabled libraries can be searched through `search_enabled_library_assets` and inspected through `inspect_enabled_libraries` / `list_enabled_library_variables`, `get_metadata` reads active-file plugin metadata or hosted REST metadata, `get_screenshot` renders active-file SVGs or REST image URLs, Design DSL wrappers (`inspect_design_system`, `validate_screen_spec`, `build_screen`, `update_screen`) plus component usage/prop analytics and database CRUD/portable payload tools are catalogued, `build_doc_flow` renders both node pages and workspace composition pages (`compositionFileId`) through the existing composition pipeline, and optional `figma_rest_*` tools cover Figma REST reads without a plugin session. |
34
71
 
35
72
  Treat feature alignment by changelog or release tag, not npm name alone.
36
73
 
37
74
  ## Ports
38
75
 
39
- **One TCP port** (`BRIDGE_PORT`, default **`37830`**): plugin **WebSocket**, **HTTP REST** (`/api/*`), and **MCP Streamable HTTP** (`/mcp`) share it. Override with `BRIDGE_PORT=3100 npm start` if needed (update plugin build + `mcp.json` to match).
76
+ **One TCP port** (`BRIDGE_PORT`, default **`37830`**): plugin **WebSocket**, **HTTP REST** (`/api/*`), and **MCP Streamable HTTP** (`/mcp`) share it. Override with `BRIDGE_PORT=3100 npm start` if needed, then use the same port in your MCP client and in the plugin **Remote Connect** overlay.
40
77
 
41
78
  | On port `BRIDGE_PORT` | URL (default) |
42
79
  |----------------------|---------------|
43
80
  | Plugin UI | `ws://127.0.0.1:37830` |
44
- | REST | `http://127.0.0.1:37830/api/{status,session,tools,log,command,disconnect,workspace-blob}` |
81
+ | REST | `http://127.0.0.1:37830/api/{status,session,queue,events,tools,capabilities,contract-audit,figma-mcp-parity,figma-mcp-skills-parity,figma-rest-diagnostics,performance-profile,runtime-summary,operator-runbook,ultimate-readiness,log,command,disconnect,workspace-blob}` |
45
82
  | Cursor MCP | `http://127.0.0.1:37830/mcp` |
46
83
 
47
84
  ### Optional: shared-secret auth
48
85
 
49
- Set `BRIDGE_AUTH_TOKEN` in the environment and every `/api/*` and `/mcp` request must send `Authorization: Bearer <token>`. Requests without the header return `401 BRIDGE_UNAUTHORIZED`. Useful when running Bridge on a shared machine, or behind a local proxy.
86
+ Set `BRIDGE_AUTH_TOKEN` in the environment and every `/api/*`, `/mcp`, and plugin WebSocket connection must authenticate. HTTP/MCP clients send `Authorization: Bearer <token>`; the SXL Studio plugin sends the token from the **Remote Connect** overlay. Requests without the token return `401 BRIDGE_UNAUTHORIZED` or a rejected WebSocket handshake. Useful when running Bridge on a shared machine, or behind a local proxy.
50
87
 
51
88
  ```bash
52
89
  BRIDGE_AUTH_TOKEN=s3cret npm start
53
90
  ```
54
91
 
92
+ For live Remote Connect, enter the same token in the plugin **Remote Connect** overlay. For Git Sync **Local Storage**, enter the same token in the plugin Sync connection form under **Bridge Auth Token**. Zero-config mode remains unchanged: leave `BRIDGE_AUTH_TOKEN` unset and leave the plugin fields empty.
93
+
94
+ ### Optional: Figma REST companion
95
+
96
+ Bridge can also call the Figma REST API directly for read-only hosted context that does not require the plugin to be open:
97
+
98
+ ```bash
99
+ FIGMA_TOKEN=figd_xxx npm start
100
+ # or OAuth/plan token with bearer auth:
101
+ FIGMA_ACCESS_TOKEN=xxx FIGMA_AUTH_MODE=bearer npm start
102
+ ```
103
+
104
+ Available MCP tools are `figma_rest_diagnose`, `figma_rest_whoami`, `figma_rest_get_file_metadata`, `figma_rest_get_file`, `figma_rest_get_file_nodes`, `figma_rest_get_images`, `figma_rest_get_image_fills`, `figma_rest_get_file_components`, `figma_rest_get_file_component_sets`, `figma_rest_get_file_styles`, `figma_rest_get_team_components`, `figma_rest_get_team_component_sets`, `figma_rest_get_team_styles`, `figma_rest_get_variables_local`, `figma_rest_get_variables_published`, and `figma_rest_search_design_system`.
105
+
106
+ Call `figma_rest_diagnose` first for token/auth/scopes/permission preflight. HTTP clients can use `GET /api/figma-rest-diagnostics?checks=whoami,fileMetadata&fileKey=...`. Use the REST tools for known file/team reads, authenticated `whoami`, REST variables, and known-library search. For Figma MCP-style library discovery, prefer Bridge `get_libraries` and `search_design_system`; they combine active-file enabled libraries through Remote Connect with known file/team REST sources when configured. They do not replace official Figma MCP for creating new files or FigJam/Slides asset upload.
107
+
108
+ For libraries already enabled in the open Figma file, `get_libraries` and `search_design_system` are the primary agent-facing tools. Use `search_enabled_library_assets` for lower-level enabled-library search, `inspect_enabled_libraries` for raw enabled descriptors, and `list_enabled_library_variables` for variables in a specific enabled collection. Figma Plugin API cannot enable libraries from code; Bridge reports that limitation in the compatibility tool responses.
109
+
110
+ For screenshots or rendered node images, use `get_screenshot`. `mode: "plugin-svg"` returns inline SVG from active-file nodes or current selection through Remote Connect. `mode: "rest-image"` returns Figma-hosted PNG/JPG/SVG/PDF URLs for known `fileKey/url + nodeIds` using the REST Images endpoint.
111
+
112
+ For metadata, use `get_metadata`. `mode: "plugin"` returns active-file selection/page structure or node tree metadata through Remote Connect. `mode: "rest"` returns hosted file metadata or node metadata for known `fileKey/url` and optional `nodeIds`.
113
+
114
+ For active-file design context, use `get_design_context`. It bundles SXL codegen/composition JSON, sparse metadata, native variable/style definitions, optional SVG screenshot, and optional local Code Connect suggestions for the current selection or provided node ids. This mirrors the official MCP `get_design_context` intent as a structured starting point for the agent; it does not claim to be final production code.
115
+
116
+ For Code Connect template/binding context, use `get_context_for_code_connect`. It bundles SXL registry/settings, selection status, existing bindings, SXL codegen/composition context, component discovery with props, and local source-file suggestions. It covers the active-file/local-codebase side of the official MCP `get_context_for_code_connect` workflow; hosted remote-only context remains official Figma MCP companion scope.
117
+
118
+ For `.figma.ts` Code Connect template generation, use `generate_code_connect_template`. It accepts a full SXL `CodeConnectBinding` or local targets/component names, returns dry-run content/path by default, and writes only when `writeFile: true` is explicitly passed. Keep `includePropertyAttrs` off unless you have verified that Figma property names match the code component props.
119
+
120
+ For variable/style definitions, use `get_variable_defs`. `mode: "selection"` is the official-MCP-style route for variables/styles used in the current Figma Design selection; it reads native `boundVariables`, text segment bindings, style ids, and resolved variable/style definitions through Remote Connect, then adds SXL applied-token metadata as compatibility context. `mode: "local"` reads active-file local variables/styles; `mode: "enabled-libraries"` reads variables from libraries already enabled in the open file; `mode: "rest"` reads known-file REST variable endpoints.
121
+
55
122
  ### Cursor MCP (recommended)
56
123
 
57
124
  Add `http://127.0.0.1:37830/mcp` to `.cursor/mcp.json`. Start Bridge **first** (`cd Utils/bridge && npm run build && npm start`). Then enable Remote Connect in the SXL Studio plugin.
@@ -67,12 +134,105 @@ npm run build
67
134
  node dist/index.js
68
135
  ```
69
136
 
70
- If you see `EADDRINUSE`, pick a free port: `BRIDGE_PORT=39999 npm start`, then use `http://127.0.0.1:39999/mcp` in Cursor and rebuild the plugin so `remoteBridge.ts` default matches.
137
+ If you see `EADDRINUSE`, pick a free port: `BRIDGE_PORT=39999 npm start`, then use `http://127.0.0.1:39999/mcp` in Cursor and set `39999` in the plugin **Remote Connect** overlay. The plugin remembers the last port locally; the default remains `37830`.
71
138
 
72
139
  The repo `.cursor/mcp.json` points Cursor at `http://127.0.0.1:37830/mcp`. Bridge must run **before** opening Agent chat.
73
140
 
74
141
  **MCP + stdout:** the Model Context Protocol uses **stdout** for JSON-RPC. Do not use `console.log` in this process (it corrupts the stream). Use `console.error` for diagnostics.
75
142
 
143
+ ## Health checks
144
+
145
+ Local health does not require a running Bridge server or Figma plugin. It verifies the local contract audit, local agent workflow routing/planning, and the Ultimate Bridge readiness audit. A healthy build reports `PASS`; `WARN` should be reviewed before release, while explicit Figma MCP companion/future scope is listed separately by `readiness`.
146
+
147
+ ```bash
148
+ npm run build
149
+ npm run health:local
150
+ npm run readiness
151
+ # installed package alternatives:
152
+ sxl-bridge health
153
+ sxl-bridge-health
154
+ sxl-bridge readiness
155
+ sxl-bridge-readiness
156
+ ```
157
+
158
+ Local readiness proves the code/tool surface. It does **not** prove a live Figma session. To combine local readiness with running HTTP/MCP proof, use:
159
+
160
+ ```bash
161
+ sxl-bridge-readiness --runtime --url http://127.0.0.1:37830
162
+ # package script equivalent:
163
+ npm run readiness:runtime
164
+ ```
165
+
166
+ To make the gate fail unless the SXL Studio plugin is connected and live validation passes:
167
+
168
+ ```bash
169
+ sxl-bridge-readiness --runtime --require-live --suite all
170
+ sxl-bridge-readiness --runtime --require-live --suite all --write-canary --cleanup
171
+ # non-destructive package script equivalent:
172
+ npm run readiness:live
173
+ ```
174
+
175
+ Use `--write-canary --cleanup` only with explicit approval; it creates a tiny validation frame, verifies the returned `rootNodeId`, then deletes that same frame.
176
+
177
+ Runtime smoke checks the running HTTP/MCP surface (`/mcp` initialize/session/tools-list/tools-call `get_libraries` + `search_design_system` zero-config envelopes, `get_operator_runbook`, `list_tools`, `validate_screen_spec`, `preview_export_variables`, `get_figma_mcp_skills_parity`, and `plan_workflow` for Figma Design library discovery routing, resources-list/resources-read for `runtime-summary` + `operator-runbook` + `figma-mcp-skills-parity`, prompts-list/prompts-get for `sxl-operator` + `sxl-generate-design`, plus REST `status`, `tools`, `capabilities`, `contract-audit`, `figma-mcp-parity`, `figma-mcp-skills-parity`, `performance-profile`, `runtime-summary`, `operator-runbook`, `figma-rest-diagnostics`, `ultimate-readiness`, `queue`, `events`, `log?source=disk`):
178
+
179
+ ```bash
180
+ sxl-bridge-health --runtime --url http://127.0.0.1:37830
181
+ ```
182
+
183
+ Use `--require-plugin` when the check must prove an active SXL Studio Remote Connect session:
184
+
185
+ ```bash
186
+ sxl-bridge-health --runtime --require-plugin --auth-token "$BRIDGE_AUTH_TOKEN"
187
+ ```
188
+
189
+ `npm run check` includes the local health gate after build. `release:check` remains the publish dry-run gate and is intentionally separate from the normal local check.
190
+
191
+ ## Live workflow smoke
192
+
193
+ When Figma is open and the SXL Studio plugin has an active **Remote Connect** session, run the non-destructive workflow smoke:
194
+
195
+ ```bash
196
+ cd Utils/bridge
197
+ npm run workflow:smoke
198
+ # installed package alternatives:
199
+ sxl-bridge smoke
200
+ sxl-bridge-smoke
201
+ ```
202
+
203
+ The workflow is intentionally small but real: `GET /api/status` → `get_plugin_status` → `find_components` → `build_mockup { dryRun: true }`. It proves that the plugin command path, queue, Remote Connect session, design-system discovery, and Design DSL dry-run are working together.
204
+
205
+ To write an actual smoke frame into the active Figma file, opt in explicitly:
206
+
207
+ ```bash
208
+ sxl-bridge-smoke --apply
209
+ sxl-bridge-smoke --apply --cleanup
210
+ ```
211
+
212
+ `--apply` requires `writesAllowed=true`; in Dev Mode/read-only contexts it fails before touching the canvas. `--cleanup` is only valid with `--apply`; it deletes the `rootNodeId` returned by the smoke frame creation step, so the canary can prove create/delete write access without leaving a frame in the file.
213
+
214
+ For local agent routing/workflow validation without a running Bridge or Figma session, use:
215
+
216
+ ```bash
217
+ npm run workflow:agent
218
+ # installed package alternative:
219
+ sxl-bridge-agent
220
+ ```
221
+
222
+ `workflow:agent` validates representative RU/EN requests through `route_intent`, `plan_workflow`, and `preview_workflow`. It catches stale routing, missing preflight dependencies, unsafe generated plans, and read-only intents that accidentally plan write tools. `readiness` prints the Ultimate Bridge requirement audit locally, and `health:local` includes both the agent workflow gate and readiness gate.
223
+
224
+ For a broader non-destructive live validation suite, use:
225
+
226
+ ```bash
227
+ npm run workflow:validate
228
+ # installed package alternatives:
229
+ sxl-bridge validate
230
+ sxl-bridge-live
231
+ sxl-bridge-live --suite all --write-canary --cleanup
232
+ ```
233
+
234
+ `workflow:validate` checks the running Bridge REST + MCP surface plus the connected plugin command path. The default `baseline` suite covers status, `/mcp` initialize/session/tools-list/tools-call `get_libraries` + `search_design_system` zero-config envelopes, `get_operator_runbook`, `list_tools`, `validate_screen_spec`, `preview_export_variables`, `get_figma_mcp_skills_parity`, and `plan_workflow` for Figma Design library discovery routing, resources-list/resources-read for `runtime-summary` + `operator-runbook` + `figma-mcp-skills-parity`, prompts-list/prompts-get for `sxl-operator` + `sxl-generate-design`, ultimate readiness, performance profile, operator runbook, tool catalogue, token/config reads, variable/style reads, component discovery, and a Design DSL dry-run. Readiness/performance endpoints are status-aware: `fail` fails the suite, while `warn` is surfaced without changing the non-destructive behavior. `--suite all` also verifies Code Connect registry/settings/selection status, selection variable definitions, dry-run `.figma.ts` template generation, database list commands, database payload export + import dry-run, variable/style spec dry-runs, dedupe dry-runs, variable/style coverage summary + paginated detail, variable/style coverage dry-run apply previews, unused variable/style scans, composition list + bulk dry-run + drift audit, component usage summary/detail pagination, component prop usage summary/detail pagination, and Doc Builder `build_doc_flow` dry-run. `--write-canary --cleanup` is the explicit write-path proof: it creates a tiny validation frame, verifies the returned `rootNodeId`, then deletes that same node. It requires an active Remote Connect session and exits non-zero when the plugin is not connected.
235
+
76
236
  ## MCP configuration (Cursor)
77
237
 
78
238
  Example `.cursor/mcp.json`:
@@ -111,7 +271,10 @@ Requires the plugin open in Figma, Remote Connect enabled, and Bridge running.
111
271
  curl -s http://127.0.0.1:37830/api/status
112
272
  ```
113
273
 
114
- Returns `ports`, `mcpStreamableHttp`, `session`, `queueLength`, `currentCommand`, `authEnabled`.
274
+ Returns `ports`, `mcpStreamableHttp`, `session`, `queueLength`, `currentCommand`, `queue`,
275
+ `runtime`, `telemetry`, and `authEnabled`. `runtime.health` is one of `ready`, `busy`,
276
+ `degraded`, or `disconnected`; `runtime.issues` names the actionable condition. `telemetry`
277
+ is sanitized and exposes counts/last failure metadata without payload values.
115
278
 
116
279
  ### Workspace blobs (Git Sync Local Storage)
117
280
 
@@ -147,13 +310,144 @@ curl -s 'http://127.0.0.1:37830/api/tools?devModeReadableOnly=true'
147
310
 
148
311
  Returns entries `{ name, category, description, requiresDesignMode, requiresComposition }`. MCP clients can call the equivalent `list_tools` meta-tool.
149
312
 
313
+ Current entries also include routing metadata where available: `commandType`, `execution`, `pluginCommandTypes`, `aliases`, `naturalLanguageIntents`, `dryRunSupported`, `returnsLargeData`, `preferredBefore`, `preferredAfter`, and `timeoutMs`.
314
+
315
+ ### Workflow routing
316
+
317
+ For broad natural-language requests, call `route_intent` first. For multi-step work, call `plan_workflow`, then validate the proposed sequence with `preview_workflow` before executing write tools. The preview checks unknown tools, missing or misordered `get_plugin_status`, missing or misordered design-system discovery, missing or misordered dry-run gates, and missing/misordered preflight tools declared by `preferredAfter`.
318
+
319
+ For token export, this means `preview_export_variables` should precede `export_variables`. For Figma Design library discovery/search, use Bridge `get_libraries` / `search_design_system`. For official Figma MCP companion scope such as new-file creation, FigJam/Slides, diagrams, or hosted Code Connect repository context, the planner adds an explicit handoff step; avoid Bridge write tools unless the user narrows the task back to SXL/active-file Figma Design work.
320
+
321
+ ### Capability matrix
322
+
323
+ MCP clients should call the `get_capability_matrix` tool. It returns the catalogue-derived matrix for agent routing and contract audits: execution mode, plugin command mapping, mode requirements, dry-run/large-data flags, and effective Bridge timeout. HTTP clients should use `GET /api/capabilities`, which is sourced from the same catalogue as `GET /api/tools`.
324
+
325
+ ```bash
326
+ curl -s 'http://127.0.0.1:37830/api/capabilities?category=mockup'
327
+ ```
328
+
329
+ ### Contract audit
330
+
331
+ MCP clients should call `get_contract_audit` before release checks or when connecting a new agent/client. It verifies the current Bridge surface: required meta tools, recipe references, schema entrypoints, workflow gates, tool execution mapping, plugin command declarations, Remote Connect whitelist coverage and handler-path coverage when the plugin source is available, and timeouts. HTTP clients can use:
332
+
333
+ ```bash
334
+ curl -s 'http://127.0.0.1:37830/api/contract-audit'
335
+ ```
336
+
337
+ The response is `{ ok, status, summary, requiredSurface, findings }`; release checks should treat `status: "fail"` as blocking. The CLI health gate uses the same contract audit locally, so `npm run check` catches stale catalogue/schema/recipe/Remote Connect whitelist/handler regressions before publish.
338
+
339
+ ### Figma MCP parity
340
+
341
+ Bridge exposes a machine-readable parity map between official Figma MCP tools and SXL Bridge/SXL Studio capabilities:
342
+
343
+ ```bash
344
+ curl -s 'http://127.0.0.1:37830/api/figma-mcp-parity'
345
+ ```
346
+
347
+ MCP clients can call `get_figma_mcp_parity` or attach `sxl://agent/figma-mcp-parity`. The matrix is intentionally explicit about companion requirements: Bridge plugin tools cover enabled-library search and active-file metadata in the open file, Bridge REST tools cover authenticated `whoami` and known file/team library reads when a Figma REST token is configured, `get_libraries` / `search_design_system` provide Figma MCP-compatible Figma Design library discovery/search over active-file and known REST sources, `get_design_context` covers active-file SXL-native design context, `get_metadata` covers hosted file/node metadata, `get_variable_defs` covers selection/local/enabled-library/known-file variable definitions, `get_screenshot` covers active-file SVG and known-node REST image rendering, Bridge `upload_assets` covers Figma Design image insertion, `get_context_for_code_connect` bundles active-file SXL Code Connect context, `generate_code_connect_template` generates dry-run-first local `.figma.ts` templates, and `get_code_connect_suggestions` ranks local source-file candidates before `codeconnect_save_binding`. Remote-only hosted Figma MCP capabilities such as new-file creation, hosted Code Connect repository context, and FigJam/Slides asset upload cannot be honestly implemented by a local Figma Design plugin Bridge.
348
+
349
+ Bridge also exposes skill-level parity for the current official Figma MCP skills:
350
+
351
+ ```bash
352
+ curl -s 'http://127.0.0.1:37830/api/figma-mcp-skills-parity'
353
+ ```
354
+
355
+ MCP clients can call `get_figma_mcp_skills_parity` or attach `sxl://agent/figma-mcp-skills-parity`. It maps the current official Figma MCP skills `figma-use`, `figma-use-figjam`, `figma-use-slides`, `figma-swiftui`, `figma-code-connect`, `figma-create-new-file`, `figma-generate-diagram`, `figma-generate-library`, and `figma-generate-design` to SXL recipes/resources/tools. The matrix keeps companion scope and agent-side codebase work explicit instead of pretending every official skill is a single Bridge plugin command.
356
+
357
+ `route_intent` and `plan_workflow` are skill-aware. Current official FigJam, Slides, new-file, and diagram skills route to the official Figma MCP companion. `figma-swiftui` uses Bridge for active-file design context and Code Connect hints, then agent-side Swift edits. Older client aliases remain supported: `figma-implement-design` routes to `sxl-implement-design`, `figma-create-design-system-rules` routes to `sxl-generate-library`, and `figma-code-connect-components` routes to `sxl-code-connect`.
358
+
359
+ For Figma Design image insertion, Bridge exposes `upload_assets`. It accepts PNG, JPG/JPEG, GIF, and WebP URLs or base64 payloads, enforces Figma MCP's 10MB-per-asset limit, supports `dryRun`, and applies images through the plugin's `set_image_fill` handler. It fills an existing `nodeId` when provided; otherwise it creates image rectangles. FigJam/Slides asset upload remains official Figma MCP companion scope.
360
+
361
+ ### Performance profile
362
+
363
+ MCP clients should call `get_performance_profile` before broad audits, screen generation, bulk export/apply flows, or when optimizing agent behavior. It classifies every catalogued tool as `local`, `standard`, `summary`, `paginated-detail`, `write-preview`, or `long-running`, then exposes target budgets, large-data rules, dry-run-first rules, destructive-write warnings, and recent audit timings.
364
+
365
+ ```bash
366
+ curl -s 'http://127.0.0.1:37830/api/performance-profile?auditLimit=50'
367
+ ```
368
+
369
+ Resource clients can attach `sxl://agent/performance-profile`. Treat `find_*` / large-data tools as paginated detail, use `analyze_*` / `audit_*` summaries before details, and call dry-run-capable write tools in preview mode before committing.
370
+
371
+ ### Runtime summary
372
+
373
+ MCP clients should call `get_operator_runbook` as the start-here workflow chooser, then `get_bridge_runtime_summary` before heavy workflows. HTTP clients can use:
374
+
375
+ ```bash
376
+ curl -s 'http://127.0.0.1:37830/api/operator-runbook'
377
+ curl -s 'http://127.0.0.1:37830/api/runtime-summary'
378
+ ```
379
+
380
+ The runbook chooses the workflow, tools, dry-run gates, and companion handoff. The runtime summary reports plugin connection, current/queued commands, recent event/audit failures, auth state, MCP URL, and actionable recommendations. It is intentionally compact so agents can decide whether to proceed, wait, inspect logs, or ask the operator to open Remote Connect.
381
+
382
+ ### Ultimate readiness audit
383
+
384
+ MCP clients can call `get_ultimate_readiness` before release or before claiming Bridge is complete. HTTP clients can use:
385
+
386
+ ```bash
387
+ curl -s 'http://127.0.0.1:37830/api/ultimate-readiness'
388
+ ```
389
+
390
+ Local operators can run the same audit without a running Bridge server:
391
+
392
+ ```bash
393
+ npm run readiness
394
+ sxl-bridge readiness
395
+ sxl-bridge-readiness --json
396
+ npm run readiness:runtime
397
+ npm run readiness:live
398
+ ```
399
+
400
+ The audit maps the original Ultimate Bridge plan to concrete requirement rows: contract surface, SXL skills, Design DSL, component analytics, database tools, variables/styles, compositions, documentation, Code Connect, production safety, official Figma MCP tool parity, and official Figma MCP skill parity. The contract row includes Remote Connect whitelist and handler-path evidence when the plugin source is available. It deliberately keeps companion/future Figma MCP scope explicit instead of pretending the plugin API can create new files or handle FigJam/Slides. Add `--runtime` to report running Bridge HTTP/MCP proof next to local readiness; add `--require-live` when release sign-off must fail unless an active Remote Connect plugin session passes live validation.
401
+
402
+ ### Large-data response mode
403
+
404
+ MCP tools marked `returnsLargeData` accept Bridge response controls:
405
+
406
+ - `bridgeResponseMode: "auto"` (default) returns the full payload while it fits the MCP response budget, otherwise returns a compact envelope.
407
+ - `bridgeResponseMode: "summary"` always returns `{ bridgeLargeData, summary, preview }` with counts, scalar fields, pagination hints, and a small item preview.
408
+ - `bridgeResponseMode: "full"` explicitly returns the full payload. Use it only when the user needs exact data.
409
+
410
+ Bridge strips these control fields before forwarding the command to the plugin. Raw HTTP `/api/command` remains an escape hatch for clients that intentionally want the exact plugin result.
411
+
412
+ ### Destructive confirmation gate
413
+
414
+ Bridge blocks destructive plugin commands unless the caller passes `confirmDestructive: true` in the top-level payload. This applies to `delete_*`, `remove_*`, `reset_*`, `git_hard_pull`, `detach_instance`, `flatten_nodes`, `boolean_operation`, and `export_variables` when `deleteOrphans` or `allowDestructiveReorder` is enabled. Use `preview_export_variables` before token export; it reports the exact payload, effective plugin defaults, risk flags, and whether confirmation is required without touching Figma.
415
+
416
+ ```bash
417
+ curl -s http://127.0.0.1:37830/api/command \
418
+ -H 'Content-Type: application/json' \
419
+ -d '{"commandType":"delete_nodes","payload":{"nodeIds":["1:2"],"confirmDestructive":true}}'
420
+ ```
421
+
422
+ MCP tools expose the same `confirmDestructive` field where their schema is strict. Bridge strips `confirmDestructive` and `destructiveReason` before sending the payload to the plugin, so Remote Connect handlers do not need to accept those fields. Prefer dry-run/preview tools first when they exist.
423
+
150
424
  ### Audit trail
151
425
 
152
426
  ```bash
153
427
  curl -s 'http://127.0.0.1:37830/api/log?limit=50'
428
+ curl -s 'http://127.0.0.1:37830/api/log?source=disk&limit=50'
429
+ ```
430
+
431
+ `source=memory` (default) returns the in-process ring buffer. `source=disk` reads persisted JSONL entries from the OS cache directory (`env-paths`, product id `sxl-studio-bridge`, subdir `audit`) unless `SXL_BRIDGE_AUDIT_ROOT` is set. Entries contain only sanitized command metadata: `commandType`, `status`, `durationMs`, `payloadKeys`, `idempotencyKey`, and timestamp fields. Payload values are never stored.
432
+
433
+ MCP clients can call `get_bridge_audit_log` with `{ source: "memory" | "disk", limit }`.
434
+
435
+ ### Queue snapshot
436
+
437
+ ```bash
438
+ curl -s 'http://127.0.0.1:37830/api/queue'
154
439
  ```
155
440
 
156
- Ring buffer of executed commands: `commandType`, `status`, `durationMs`, `payloadKeys`, `idempotencyKey`, `timestamp`.
441
+ Live command queue snapshot: `current`, `queued`, and `immediate` commands with `commandId`, `commandType`, `status`, timings, and `payloadKeys`. Payload values are never exposed.
442
+
443
+ ### Command events
444
+
445
+ ```bash
446
+ curl -s 'http://127.0.0.1:37830/api/events?limit=100'
447
+ curl -s 'http://127.0.0.1:37830/api/events?commandId=<command-id>'
448
+ ```
449
+
450
+ Sanitized lifecycle/progress timeline: `queued`, `started`, `completed`/`failed`, timeout/cancel events, and plugin progress events when the plugin emits them. Events include ids, status, timings, `payloadKeys`, and `detailKeys`; payload/detail values are never exposed.
157
451
 
158
452
  ### Read token file (after `list_token_files`)
159
453
 
@@ -201,24 +495,27 @@ Failures return a structured envelope:
201
495
  }
202
496
  ```
203
497
 
204
- Known codes: `EDITOR_MODE_READONLY`, `BRIDGE_TIMEOUT`, `BRIDGE_CANCELLED`, `BRIDGE_UNAUTHORIZED`, `BRIDGE_ERROR`. MCP tools decode the envelope before returning to the agent.
498
+ Known codes: `EDITOR_MODE_READONLY`, `DESTRUCTIVE_CONFIRMATION_REQUIRED`, `BRIDGE_TIMEOUT`, `BRIDGE_CANCELLED`, `BRIDGE_UNAUTHORIZED`, `BRIDGE_ERROR`. MCP tools decode the envelope before returning to the agent.
205
499
 
206
500
  ## MCP tools (summary)
207
501
 
208
502
  Registered in `src/mcp-factory.ts` via `tools/*.ts`:
209
503
 
210
- - **Diagnostics / meta:** `get_plugin_status`, `is_dev_mode`, `get_selection_summary`, `get_drift_status`, `list_tools`.
211
- - **Tokens / workspace:** `list_token_files`, `get_token_file_content`, `save_token_file` (upsert), `create_token_file`, `delete_token_file`, `move_token_file`, `rename_token_file`, `get_tokens_config`, `save_tokens_config`, `export_variables`, `reset_diff*`, `reapply_token_bindings`, `cross_file_sync_*`, `get_applied_tokens`.
504
+ - **Diagnostics / meta:** `get_plugin_status`, `is_dev_mode`, `get_selection_summary`, `get_drift_status`, `get_operator_runbook`, `route_intent`, `plan_workflow`, `preview_workflow`, `list_tools`, `get_capability_matrix`, `get_contract_audit`, `get_figma_mcp_parity`, `get_performance_profile`, `get_bridge_audit_log`, `get_ultimate_readiness`.
505
+ - **Tokens / workspace:** `list_token_files`, `get_token_file_content`, `save_token_file` (upsert), `create_token_file`, `delete_token_file`, `move_token_file`, `rename_token_file`, `get_tokens_config`, `save_tokens_config`, `preview_export_variables` (read-only export preflight), `export_variables`, `reset_diff*`, `reapply_token_bindings`, `cross_file_sync_*`, `get_applied_tokens`.
212
506
  - **Composition:** `export_composition_json`, `get_codegen`, `list_compositions`, `generate_composition`, `apply_composition`, `preview_composition`, `check_composition_linked`, `inspect_selection`.
213
507
  - **Variables:** `get_variables`, `create_variable_collection`, `create_variable`, `bind_variable`, `rename_variable`, `delete_variable`, `rename_variable_collection`, `delete_variable_collection`, `add_variable_mode`, `remove_variable_mode`, `rename_variable_mode`, `set_variable_mode_value`, `set_variable_scopes`, `set_variable_code_syntax`, plus batch ops `batch_create_variables` / `batch_set_variable_values` / `batch_delete_variables` / `batch_bind_variables`.
214
508
  - **Variables orchestration (Phase B, Bridge `1.6.0`+):** `import_variable_spec` (idempotent bulk create / update with aliases, `dryRun`), `analyze_variable_order` (read-only ordering diff), `dedupe_variables` (merge duplicates, dry-run by default; canvas write only with `apply: true`), `rebind_variable_aliases` (bulk alias rewrite, `dryRun`), `apply_coverage_suggestions` (audit suggestions → real bindings, dry-run by default).
215
509
  - **Styles:** `get_local_styles`, `create_paint_style`, `create_text_style`, `create_effect_style`, `set_text_style`, `set_effect_style`, `set_stroke_style`, `set_fill_style`, `import_style_by_key`.
216
510
  - **Styles orchestration (Phase C, Bridge `1.6.0`+):** `import_style_spec` (idempotent bulk create / update of Paint / Text / Effect styles, `dryRun`), `dedupe_styles` (merge duplicates `byName | bySignature`, dry-run by default; canvas write only with `apply: true`), `rebind_style_consumers` (bulk styleId rewrite on consumer nodes, `dryRun`), `audit_style_drift` (READ-ONLY drift between local Paint styles and Variables / `expectations[]`), `apply_style_coverage_suggestions` (Phase A `find_style_coverage_misses` → real `setStyleId*` writes, dry-run by default).
217
- - **Mockup-from-DesignSystem (Phase D, Bridge `1.6.0`+):** `find_components` (READ-ONLY paginated catalogue of local + library-instantiated components with `componentPropertyDefinitions`; Dev-Mode compatible), `build_mockup` (assemble one auto-layout mockup from a declarative `instance | section | spacer | text` item tree with property / text / fill-binding overrides; `dryRun`-aware), `apply_mockup_dataset` (clone a template per dataset row with row-specific overrides; `dryRun`-aware). Replaces hand-rolled `use_figma { figma.createInstance(...).setProperties(...) }` loops.
511
+ - **Mockup-from-DesignSystem / Design DSL (Phase D):** `inspect_design_system` (READ-ONLY aggregate: components/props, variables, styles, token config, composition index), `validate_screen_spec`, `build_screen`, `update_screen`, `find_components`, `build_mockup`, `apply_mockup_dataset`. Prefer `inspect_design_system validate_screen_spec/build_screen dryRun build_screen/update_screen` for full screens; keep `build_mockup` as the low-level compatible DSL. Payload contract is exposed at `sxl://agent/schemas/design-dsl-v1`. Replaces hand-rolled `use_figma { figma.createInstance(...).setProperties(...) }` loops.
512
+ - **Figma REST companion:** `figma_rest_diagnose`, `figma_rest_whoami`, `figma_rest_get_file_metadata`, `figma_rest_get_file`, `figma_rest_get_file_nodes`, `figma_rest_get_images`, `figma_rest_get_image_fills`, `figma_rest_get_file_components`, `figma_rest_get_file_component_sets`, `figma_rest_get_file_styles`, `figma_rest_get_team_components`, `figma_rest_get_team_component_sets`, `figma_rest_get_team_styles`, `figma_rest_get_variables_local`, `figma_rest_get_variables_published`, `figma_rest_search_design_system`. Bridge-local, read-only, no Remote Connect session required; use `FIGMA_TOKEN` / `FIGMA_ACCESS_TOKEN`. The Figma MCP-compatible `get_libraries` / `search_design_system` tools can orchestrate these REST reads together with active-file plugin sources.
218
513
  - **Compositions orchestration (Phase E, Bridge `1.6.0`+):** `bulk_generate_compositions` (bulk `generate` / `apply` of composition files in one MCP call; filters `fileIds | names | prefix`; `operation: auto | generate | apply`; per-item error isolation; `dryRun`-aware), `audit_composition_drift` (READ-ONLY drift detector between workspace composition files and tracked Figma components; statuses `linked | unlinked | drift | missing`; Dev-Mode safe). Replaces hand-rolled `for-of` loops over `generate_composition` / `apply_composition` and per-file `check_composition_linked` polling.
219
- - **Data / nodes:** `apply_mapping`, `apply_all_mappings`, `count_apply_targets`, `generate_instances`, `apply_image`, plus direct node helpers in `data.ts` / `figma-nodes.ts` (`set_node_fill_variable`, `create_rectangle`, `set_auto_layout`, `duplicate_subtree`, `create_component_instance`, `apply_documentation_payload`, extended `create_frame` / `create_text`).
514
+ - **Data / nodes:** database CRUD (`list_datasets`, `get_dataset`, `save_dataset`, `delete_dataset`, `list_assets`, `get_asset`, `save_asset`, `delete_asset`, `list_mappings`, `get_mapping`, `save_mapping`, `delete_mapping`; save/delete support `dryRun` preview), portable database backup/restore (`export_database_payload`, `import_database_payload`; import defaults to `dryRun` and requires overwrite confirmation for existing IDs), mapping apply/generate preflights (`apply_mapping`, `apply_all_mappings`, `generate_instances`; all support `dryRun` preview before writing, and apply/count/generate workflows accept explicit `targetNodeIds` as deterministic selection roots), design-context orchestration (`get_design_context`), variable/style definition orchestration (`get_variable_defs`), Figma MCP-compatible library tools (`get_libraries`, `search_design_system`), enabled-library search/read tools (`search_enabled_library_assets`, `inspect_enabled_libraries`, `list_enabled_library_variables`), `get_metadata`, `get_screenshot`, `count_apply_targets`, `apply_image`, `upload_assets` (dry-run image URL/base64 upload into Figma Design), `get_code_connect_suggestions` (local binding candidates), plus direct node helpers in `data.ts` / `figma-nodes.ts` (`set_node_fill_variable`, `create_rectangle`, `set_auto_layout`, `duplicate_subtree`, `create_component_instance`, `apply_documentation_payload`, extended `create_frame` / `create_text`).
220
515
  - **Git:** `git_pull`, `git_hard_pull`, `git_push`.
221
- - **Orchestration:** `generate_code_from_url`, `compose_from_url`, `document_component`, `index_icons_for_export` (read-only icon index: COMPONENT + COMPONENT_SET variants with page/section metadata).
516
+ - **Audit analytics:** variable/style usage and coverage tools plus component analytics (`analyze_component_usage`, `find_component_usages`, `analyze_component_prop_usage`, `find_component_prop_usages`).
517
+ - **Audit remediation:** coverage audits are read-only; use `apply_coverage_suggestions` / `apply_style_coverage_suggestions` in preview mode before committing fixes.
518
+ - **Orchestration:** `generate_code_from_url`, `compose_from_url`, `document_component`, `index_icons_for_export` (read-only icon index: COMPONENT + COMPONENT_SET variants with page/section metadata), `build_scenario_from_md`, `build_doc_flow` (node pages or `compositionFileId` pages rendered through the composition pipeline).
222
519
 
223
520
  ### MCP Resources
224
521
 
@@ -230,11 +527,34 @@ Registered in `src/mcp-factory.ts` via `tools/*.ts`:
230
527
  | `sxl://tokens/files` | Token file index |
231
528
  | `sxl://tokens/files/{fileId}` | Raw token file body |
232
529
  | `sxl://compositions/index` | Composition JSON index |
530
+ | `sxl://agent/operator-runbook` | Start-here workflow chooser: preflight, safety rules, common SXL/Figma routes, dry-run gates, and live-readiness checks |
233
531
  | `sxl://agent/recipes/index` | Intent router (start here) |
234
- | `sxl://agent/recipes/{doc-tokens,doc-component,doc-composition,doc-flow,doc-spec-v2,template-discovery,variable-palette,compose-with-variables,scenario-from-markdown,variable-usage,audit-coverage,find-unused,bulk-variables,auto-bind-from-audit,bulk-styles,style-drift,mockup-builder,bulk-compositions,composition-drift}` | Doc Builder + audit + Phase B + Phase C + Phase D + Phase E orchestration recipes |
532
+ | `sxl://agent/recipes/{sxl-use,sxl-implement-design,sxl-generate-design,sxl-generate-library,sxl-code-connect,sxl-audit,sxl-doc-builder,sxl-data-apply-mapping,sxl-data-apply-all,sxl-data-generate-instances,sxl-database-transfer,figma-mcp-companion,doc-tokens,doc-component,doc-composition,doc-flow,doc-spec-v2,template-discovery,variable-palette,compose-with-variables,scenario-from-markdown,variable-usage,audit-coverage,find-unused,bulk-variables,auto-bind-from-audit,bulk-styles,style-drift,mockup-builder,bulk-compositions,composition-drift}` | SXL skills + SXL database/data workflows + official Figma MCP companion routing + Doc Builder + audit + Phase B + Phase C + Phase D + Phase E orchestration recipes |
533
+ | `sxl://agent/figma-mcp-parity` | Official Figma MCP tool → SXL Bridge/SXL Studio equivalent / companion / future scope map |
534
+ | `sxl://agent/figma-mcp-skills-parity` | Official Figma MCP skill → SXL Bridge recipes/resources/tools / companion / agent-codebase-work map |
535
+ | `sxl://agent/performance-profile` | Command budgets, large-data/dry-run policy, destructive-write warnings, and recent audit timings |
536
+ | `sxl://agent/runtime-summary` | Plugin connection, queue pressure, recent failures, MCP URL, auth flag, and recommendations |
537
+ | `sxl://agent/ultimate-readiness` | Requirement-by-requirement Ultimate Bridge Toolkit readiness audit |
235
538
 
236
539
  Cursor / Claude can attach these as context without calling tools.
237
540
 
541
+ ### MCP Prompts
542
+
543
+ Bridge also registers prompt templates for MCP clients that support `prompts/list` / `prompts/get`:
544
+
545
+ - `sxl-router`
546
+ - `sxl-operator`
547
+ - `sxl-use`
548
+ - `sxl-implement-design`
549
+ - `sxl-generate-design`
550
+ - `sxl-generate-library`
551
+ - `sxl-code-connect`
552
+ - `sxl-audit`
553
+ - `sxl-doc-builder`
554
+ - `figma-mcp-companion`
555
+
556
+ Each prompt returns a concise workflow instruction with the relevant `sxl://agent/recipes/*` resource, preferred tools, forbidden anti-patterns, dry-run gates, and done criteria. `figma-mcp-companion` is the explicit handoff prompt for official Figma MCP remote-only scopes such as new-file creation, FigJam/Slides, and diagrams; Figma Design library discovery should use Bridge `get_libraries` / `search_design_system`. Use prompts when the MCP client can inject prompt templates directly; use resources when the client prefers attachable context.
557
+
238
558
  ## Dev Mode support
239
559
 
240
560
  | Context | Reads | Canvas writes | Token/config/git writes |
@@ -251,6 +571,12 @@ Cursor / Claude can attach these as context without calling tools.
251
571
  npm run test # Vitest
252
572
  npm run build # tsc → dist/
253
573
  npm run lint # tsc --noEmit
574
+ npm run check # lint + build + test
575
+ npm run readiness # local Ultimate Bridge requirement audit
576
+ npm run readiness:runtime # local readiness + running Bridge HTTP/MCP proof
577
+ npm run readiness:live # strict live Figma E2E proof; requires Remote Connect
578
+ npm run release:check # check + npm publish --dry-run
579
+ npm run release:check:live # check + strict live readiness gate
254
580
  ```
255
581
 
256
582
  ## Publishing to npm