@sxl-studio/bridge 1.5.1 → 1.6.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.
- package/README.md +8 -1
- package/dist/agent-recipes.d.ts +268 -0
- package/dist/agent-recipes.js +637 -0
- package/dist/agent-recipes.js.map +1 -1
- package/dist/command-queue.js +16 -0
- package/dist/command-queue.js.map +1 -1
- package/dist/mcp-factory.js +11 -1
- package/dist/mcp-factory.js.map +1 -1
- package/dist/sxl-mcp-instructions.js +142 -2
- package/dist/sxl-mcp-instructions.js.map +1 -1
- package/dist/tools/audit.d.ts +49 -0
- package/dist/tools/audit.js +83 -0
- package/dist/tools/audit.js.map +1 -0
- package/dist/tools/catalogue-bootstrap.js +34 -0
- package/dist/tools/catalogue-bootstrap.js.map +1 -1
- package/dist/tools/compositions-orchestration.d.ts +91 -0
- package/dist/tools/compositions-orchestration.js +101 -0
- package/dist/tools/compositions-orchestration.js.map +1 -0
- package/dist/tools/mockup.d.ts +323 -0
- package/dist/tools/mockup.js +206 -0
- package/dist/tools/mockup.js.map +1 -0
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js.map +1 -1
- package/dist/tools/resources.d.ts +1 -1
- package/dist/tools/resources.js +52 -2
- package/dist/tools/resources.js.map +1 -1
- package/dist/tools/styles-orchestration.d.ts +544 -0
- package/dist/tools/styles-orchestration.js +175 -0
- package/dist/tools/styles-orchestration.js.map +1 -0
- package/dist/tools/tokens.d.ts +60 -60
- package/dist/tools/variables-orchestration.d.ts +20 -0
- package/dist/tools/variables-orchestration.js +116 -0
- package/dist/tools/variables-orchestration.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Variables orchestration — Bridge platform Phase B tools.
|
|
3
|
+
*
|
|
4
|
+
* "Thick" commands that wrap multi-step Figma Variables refactors:
|
|
5
|
+
* - `import_variable_spec` — declarative bulk create / update with aliases.
|
|
6
|
+
* - `analyze_variable_order` — read-only diff to recommend a new order.
|
|
7
|
+
* - `dedupe_variables` — find / merge duplicates (dry-run by default).
|
|
8
|
+
* - `rebind_variable_aliases` — bulk rewrite alias chains across modes.
|
|
9
|
+
* - `apply_coverage_suggestions` — convert audit_variable_coverage suggestions
|
|
10
|
+
* into safe `setBoundVariableFor*` writes.
|
|
11
|
+
*
|
|
12
|
+
* Token economy:
|
|
13
|
+
* - dry-run (default for dedupe / apply_coverage_suggestions / spec preview)
|
|
14
|
+
* returns the exact plan WITHOUT touching the canvas. Agents inspect the
|
|
15
|
+
* summary, surface it to the user, then re-call with `apply: true` /
|
|
16
|
+
* `dryRun: false` to commit.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
import { callPluginCommand } from "./shared.js";
|
|
20
|
+
const variableValueLiteralZod = z.union([
|
|
21
|
+
z.number(),
|
|
22
|
+
z.string(),
|
|
23
|
+
z.boolean(),
|
|
24
|
+
z.object({
|
|
25
|
+
r: z.number(),
|
|
26
|
+
g: z.number(),
|
|
27
|
+
b: z.number(),
|
|
28
|
+
a: z.number().optional(),
|
|
29
|
+
}),
|
|
30
|
+
]);
|
|
31
|
+
const aliasRefZod = z.union([
|
|
32
|
+
z.object({ variableId: z.string() }),
|
|
33
|
+
z.object({ variableName: z.string() }),
|
|
34
|
+
]);
|
|
35
|
+
const variableValueZod = z.union([
|
|
36
|
+
z.object({ value: variableValueLiteralZod }),
|
|
37
|
+
z.object({ alias: aliasRefZod }),
|
|
38
|
+
z.object({
|
|
39
|
+
rawAlias: z.union([
|
|
40
|
+
z.object({ type: z.literal("VARIABLE_ALIAS"), id: z.string() }),
|
|
41
|
+
z.object({ aliasOf: z.string() }),
|
|
42
|
+
]),
|
|
43
|
+
}),
|
|
44
|
+
]);
|
|
45
|
+
const modeZod = z.object({
|
|
46
|
+
key: z.string().describe("Stable mode key referenced from variable values"),
|
|
47
|
+
name: z.string().optional().describe("Display name (required when creating a new mode)"),
|
|
48
|
+
});
|
|
49
|
+
const variableTypeZod = z.enum(["COLOR", "FLOAT", "STRING", "BOOLEAN"]);
|
|
50
|
+
const variableEntryZod = z.object({
|
|
51
|
+
name: z.string(),
|
|
52
|
+
type: variableTypeZod,
|
|
53
|
+
valuesByMode: z.record(variableValueZod).optional(),
|
|
54
|
+
scopes: z.array(z.string()).optional(),
|
|
55
|
+
codeSyntax: z.record(z.string()).optional(),
|
|
56
|
+
description: z.string().optional(),
|
|
57
|
+
});
|
|
58
|
+
const collectionSpecZod = z
|
|
59
|
+
.object({
|
|
60
|
+
collectionId: z.string().optional(),
|
|
61
|
+
collectionName: z.string().optional(),
|
|
62
|
+
modes: z.array(modeZod).optional(),
|
|
63
|
+
variables: z.array(variableEntryZod).optional(),
|
|
64
|
+
})
|
|
65
|
+
.refine((c) => Boolean(c.collectionId ?? c.collectionName), {
|
|
66
|
+
message: "Collection requires collectionId or collectionName",
|
|
67
|
+
});
|
|
68
|
+
const variableSpecZod = z.object({
|
|
69
|
+
collections: z.array(collectionSpecZod).min(1),
|
|
70
|
+
resolveAliases: z.boolean().optional(),
|
|
71
|
+
dryRun: z.boolean().optional(),
|
|
72
|
+
});
|
|
73
|
+
const reorderStrategyZod = z.union([
|
|
74
|
+
z.object({ type: z.literal("alphabetical") }),
|
|
75
|
+
z.object({ type: z.literal("byPath"), separator: z.string().optional() }),
|
|
76
|
+
z.object({ type: z.literal("explicit"), order: z.array(z.string()).min(1) }),
|
|
77
|
+
]);
|
|
78
|
+
const dedupeStrategyZod = z.enum(["byName", "byDefaultModeValue"]);
|
|
79
|
+
export function registerVariablesOrchestrationTools(server, queue) {
|
|
80
|
+
server.tool("import_variable_spec", "Idempotent bulk-create / update of Variables from a single declarative spec. Creates collections + modes + variables, applies per-mode literal values, then resolves aliases in a second pass so cross-collection references work. Errors are collected per-item without aborting the run. Pass `dryRun: true` for a preview (returns the diff and skips Figma writes). CANVAS WRITE in apply mode — blocked in Dev Mode.", {
|
|
81
|
+
spec: variableSpecZod.describe("Top-level spec. `collections[]` is required; each collection identifies itself by `collectionId` (existing) or `collectionName` (resolves existing or creates new). Variable values support `{ value }` literals (hex strings auto-coerce for COLOR), `{ alias: { variableId | variableName } }`, or `{ rawAlias }` passthrough."),
|
|
82
|
+
}, async ({ spec }) => callPluginCommand(queue, "import_variable_spec", { spec }));
|
|
83
|
+
server.tool("analyze_variable_order", "READ-ONLY: produce a recommended order of variables inside a collection. Returns `moves[]` describing every position that would change. Strategies: `alphabetical`, `byPath` (with optional separator), `explicit` (caller-supplied list). Figma Plugin API does not expose a stable `move` primitive, so this command stays diff-only — use it to drive a manual reorder in the Variables panel.", {
|
|
84
|
+
collectionId: z.string().describe("Variable collection id (VariableCollectionId:...)"),
|
|
85
|
+
strategy: reorderStrategyZod,
|
|
86
|
+
}, async (args) => callPluginCommand(queue, "analyze_variable_order", args));
|
|
87
|
+
server.tool("dedupe_variables", "Find (and optionally merge) duplicate Variables. Strategies: `byName` (same name across collections) or `byDefaultModeValue` (same default-mode literal value within the same resolvedType). Default is dry-run — returns groups + suggested survivor + would-be rebindings. With `apply: true` the survivor inherits incoming aliases (via `rebind_variable_aliases`) and duplicates are removed. CANVAS WRITE only in apply mode.", {
|
|
88
|
+
strategy: dedupeStrategyZod.default("byName"),
|
|
89
|
+
apply: z.boolean().optional().describe("When true, perform the merge. Default: false (dry-run)."),
|
|
90
|
+
collectionId: z
|
|
91
|
+
.string()
|
|
92
|
+
.optional()
|
|
93
|
+
.describe("Restrict the scan to a single collection. Default: scan all local variables."),
|
|
94
|
+
}, async (args) => callPluginCommand(queue, "dedupe_variables", args));
|
|
95
|
+
server.tool("rebind_variable_aliases", "Bulk rewrite alias targets inside Variable collections. Each `{ fromVariableId, toVariableId }` pair redirects every `valuesByMode` entry that aliases the source so it points at the target. Read-only nodes / bindings are NOT touched (use `apply_coverage_suggestions` for that). Pass `dryRun: true` to count rewrites without writing.", {
|
|
96
|
+
mappings: z
|
|
97
|
+
.array(z.object({
|
|
98
|
+
fromVariableId: z.string(),
|
|
99
|
+
toVariableId: z.string(),
|
|
100
|
+
}))
|
|
101
|
+
.min(1),
|
|
102
|
+
dryRun: z.boolean().optional().describe("When true, count rewrites without applying. Default: false."),
|
|
103
|
+
}, async (args) => callPluginCommand(queue, "rebind_variable_aliases", args));
|
|
104
|
+
server.tool("apply_coverage_suggestions", "Apply the `suggestion` entries from `audit_variable_coverage` / `find_variable_coverage_misses`. Translates property paths like `fills[0].color`, `effects[2].color`, `cornerRadius` etc. into Figma `setBoundVariableForPaint` / `setBoundVariableForEffect` / `setBoundVariable` writes. Default mode is dry-run — agent receives a `preview[]` it can show the user. Set `dryRun: false` to commit. CANVAS WRITE only when `dryRun: false`.", {
|
|
105
|
+
suggestions: z
|
|
106
|
+
.array(z.object({
|
|
107
|
+
nodeId: z.string(),
|
|
108
|
+
property: z.string().describe("Property path as returned by find_variable_coverage_misses"),
|
|
109
|
+
variableId: z.string(),
|
|
110
|
+
variableName: z.string().optional(),
|
|
111
|
+
}))
|
|
112
|
+
.min(1),
|
|
113
|
+
dryRun: z.boolean().optional().describe("Default: true. Pass false to actually wire bindings."),
|
|
114
|
+
}, async (args) => callPluginCommand(queue, "apply_coverage_suggestions", args));
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=variables-orchestration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variables-orchestration.js","sourceRoot":"","sources":["../../src/tools/variables-orchestration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC;IACtC,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,MAAM,EAAE;IACV,CAAC,CAAC,OAAO,EAAE;IACX,CAAC,CAAC,MAAM,CAAC;QACP,CAAC,EAAE,CAAC,CAAC,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