@bridge-ds/mcp 0.9.0 → 0.10.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/LICENSE +110 -0
- package/README.md +1 -1
- package/dist/branches.d.ts +2 -0
- package/dist/{chunk-ZVORAO5H.js → chunk-BZEPCY42.js} +161 -159
- package/dist/{chunk-TP33MW7E.js → chunk-E5V42VCS.js} +349 -84
- package/dist/figma-fixes.d.ts +40 -12
- package/dist/index.js +2 -2
- package/dist/lib.d.ts +19 -2
- package/dist/lib.js +6 -2
- package/dist/ops.d.ts +1 -0
- package/dist/server.d.ts +28 -1
- package/dist/{src-RUS6SPYZ.js → src-ATD4DJF3.js} +1 -1
- package/dist/studio.d.ts +1 -0
- package/dist/suggestions.d.ts +18 -1
- package/package.json +4 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, MIT Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-MIT
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 Florian Gouloubi
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the MIT license that is effective on the second anniversary of the date we make
|
|
91
|
+
the Software available. On or after that date, you may use the Software under
|
|
92
|
+
the MIT license, in which case the following will apply:
|
|
93
|
+
|
|
94
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
95
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
96
|
+
the Software without restriction, including without limitation the rights to
|
|
97
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
98
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
99
|
+
so, subject to the following conditions:
|
|
100
|
+
|
|
101
|
+
The above copyright notice and this permission notice shall be included in all
|
|
102
|
+
copies or substantial portions of the Software.
|
|
103
|
+
|
|
104
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
105
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
106
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
107
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
108
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
109
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
110
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ An MCP server that connects your own Claude (Claude Code, Claude Desktop or any
|
|
|
4
4
|
design system repo. Claude can read your DTCG tokens, components and docs, run your contrast gate, and
|
|
5
5
|
propose token changes as reviewable branches and pull requests. It never writes to `main`.
|
|
6
6
|
|
|
7
|
-
Free and
|
|
7
|
+
Free and source available (FSL-1.1-MIT, each version becomes MIT after two years). Local, no backend, no account: it reads files on your disk, or a GitHub repo
|
|
8
8
|
with your own token.
|
|
9
9
|
|
|
10
10
|
## Run it
|
package/dist/branches.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ export declare function branchFacts(ctx: BridgeContext, gh: GitHubClient, n: num
|
|
|
93
93
|
tokenValues: boolean;
|
|
94
94
|
autoShip: boolean;
|
|
95
95
|
statusLabel: string;
|
|
96
|
+
publishedBy: string | null;
|
|
96
97
|
}>;
|
|
97
98
|
/** One branch, the way Studio shows it: status, what blocks the merge and who acts, how it stands against main. */
|
|
98
99
|
export declare function branchStatus(ctx: BridgeContext, a: {
|
|
@@ -104,6 +105,7 @@ export declare function branchStatus(ctx: BridgeContext, a: {
|
|
|
104
105
|
shipsByItself: boolean;
|
|
105
106
|
said: string;
|
|
106
107
|
} | undefined;
|
|
108
|
+
published?: string | undefined;
|
|
107
109
|
pr: number;
|
|
108
110
|
title: string;
|
|
109
111
|
url: string;
|
|
@@ -722,7 +722,8 @@ function defineConfig(input) {
|
|
|
722
722
|
}
|
|
723
723
|
} : {},
|
|
724
724
|
...g.rights ? { rights: normalizeRights(g.rights) } : {},
|
|
725
|
-
...g.soloOwnerCanApproveBoth === true ? { soloOwnerCanApproveBoth: true } : {}
|
|
725
|
+
...g.soloOwnerCanApproveBoth === true ? { soloOwnerCanApproveBoth: true } : {},
|
|
726
|
+
...g.leadsPublishTier1 === false ? { leadsPublishTier1: false } : {}
|
|
726
727
|
},
|
|
727
728
|
products: input.products?.length ? input.products.map((p) => ({ ...p })) : DEFAULT_PRODUCTS.map((p) => ({ ...p })),
|
|
728
729
|
changes: input.changes === "direct" ? "direct" : DEFAULT_CHANGES_MODE,
|
|
@@ -850,6 +851,7 @@ function loadConfig(source) {
|
|
|
850
851
|
}
|
|
851
852
|
problems.push(...rightsProblems(gov.rights));
|
|
852
853
|
if (gov.soloOwnerCanApproveBoth !== void 0 && typeof gov.soloOwnerCanApproveBoth !== "boolean") problems.push('"governance.soloOwnerCanApproveBoth" must be true or false');
|
|
854
|
+
if (gov.leadsPublishTier1 !== void 0 && typeof gov.leadsPublishTier1 !== "boolean") problems.push('"governance.leadsPublishTier1" must be true or false');
|
|
853
855
|
}
|
|
854
856
|
}
|
|
855
857
|
problems.push(...visualImpactProblems(d.visualImpact));
|
|
@@ -1071,164 +1073,6 @@ function parseContrastChecks(text) {
|
|
|
1071
1073
|
return out;
|
|
1072
1074
|
}
|
|
1073
1075
|
|
|
1074
|
-
// ../core/src/scopes.ts
|
|
1075
|
-
var has = (segments, ...names) => names.some((n) => segments.includes(n));
|
|
1076
|
-
function defaultScopes(path, type, tier) {
|
|
1077
|
-
const s = path.split(".");
|
|
1078
|
-
switch (type) {
|
|
1079
|
-
case "color":
|
|
1080
|
-
if (tier === "primitive" || tier === "brand" && s[0] === "palette") return [];
|
|
1081
|
-
if (has(s, "text")) return ["TEXT_FILL"];
|
|
1082
|
-
if (has(s, "border", "ring", "outline")) return ["STROKE_COLOR"];
|
|
1083
|
-
if (has(s, "bg", "surface", "background")) return ["FRAME_FILL", "SHAPE_FILL"];
|
|
1084
|
-
if (has(s, "shadow")) return ["EFFECT_COLOR"];
|
|
1085
|
-
return ["FRAME_FILL", "SHAPE_FILL", "TEXT_FILL", "STROKE_COLOR"];
|
|
1086
|
-
case "dimension":
|
|
1087
|
-
if (has(s, "radius")) return ["CORNER_RADIUS"];
|
|
1088
|
-
if (has(s, "border", "width", "stroke")) return ["STROKE_FLOAT"];
|
|
1089
|
-
if (has(s, "space", "spacing", "gap")) return ["GAP", "WIDTH_HEIGHT"];
|
|
1090
|
-
if (has(s, "size") && has(s, "font")) return ["FONT_SIZE"];
|
|
1091
|
-
if (has(s, "letter-spacing")) return ["LETTER_SPACING"];
|
|
1092
|
-
return ["WIDTH_HEIGHT", "GAP"];
|
|
1093
|
-
case "fontWeight":
|
|
1094
|
-
return ["FONT_WEIGHT"];
|
|
1095
|
-
case "fontFamily":
|
|
1096
|
-
return ["FONT_FAMILY"];
|
|
1097
|
-
case "number":
|
|
1098
|
-
if (has(s, "line-height", "lineHeight")) return ["LINE_HEIGHT"];
|
|
1099
|
-
if (has(s, "opacity")) return ["OPACITY"];
|
|
1100
|
-
return ["WIDTH_HEIGHT", "GAP"];
|
|
1101
|
-
case "string":
|
|
1102
|
-
return ["TEXT_CONTENT"];
|
|
1103
|
-
default:
|
|
1104
|
-
return [];
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
var sameScopes = (a, b) => {
|
|
1108
|
-
const sa = [...new Set(a)].sort();
|
|
1109
|
-
const sb = [...new Set(b)].sort();
|
|
1110
|
-
return sa.length === sb.length && sa.every((x, i) => x === sb[i]);
|
|
1111
|
-
};
|
|
1112
|
-
var effectiveScopes = (t) => t.scopes ?? defaultScopes(t.path, t.type, t.tier);
|
|
1113
|
-
|
|
1114
|
-
// ../core/src/diff-engine.ts
|
|
1115
|
-
var normDesc = (d) => (d ?? "").trim();
|
|
1116
|
-
function fieldChanges(a, b) {
|
|
1117
|
-
const out = [];
|
|
1118
|
-
if (a.path !== b.path) out.push({ field: "path", before: a.path, after: b.path });
|
|
1119
|
-
if (a.type !== b.type) out.push({ field: "type", before: a.type, after: b.type });
|
|
1120
|
-
const modes = [.../* @__PURE__ */ new Set([...Object.keys(a.values), ...Object.keys(b.values)])];
|
|
1121
|
-
for (const mode of modes) {
|
|
1122
|
-
if (!valuesEqual(b.type, a.values[mode], b.values[mode])) out.push({ field: "value", mode, before: a.values[mode], after: b.values[mode] });
|
|
1123
|
-
}
|
|
1124
|
-
if (normDesc(a.description) !== normDesc(b.description)) out.push({ field: "description", before: a.description, after: b.description });
|
|
1125
|
-
const sa = effectiveScopes(a);
|
|
1126
|
-
const sb = effectiveScopes(b);
|
|
1127
|
-
if (!sameScopes(sa, sb)) out.push({ field: "scopes", before: sa, after: sb });
|
|
1128
|
-
return out;
|
|
1129
|
-
}
|
|
1130
|
-
function sameToken(a, b) {
|
|
1131
|
-
if (!a || !b) return a === b;
|
|
1132
|
-
return fieldChanges(a, b).length === 0;
|
|
1133
|
-
}
|
|
1134
|
-
function sideChange(from, to) {
|
|
1135
|
-
if (!from && !to) return void 0;
|
|
1136
|
-
if (!from) return { kind: "added", fields: [] };
|
|
1137
|
-
if (!to) return { kind: "removed", fields: [] };
|
|
1138
|
-
const fields = fieldChanges(from, to);
|
|
1139
|
-
if (!fields.length) return void 0;
|
|
1140
|
-
return { kind: fields.some((f) => f.field === "path") ? "renamed" : "changed", fields };
|
|
1141
|
-
}
|
|
1142
|
-
function threeWayDiff(base, figma, head) {
|
|
1143
|
-
const ids = /* @__PURE__ */ new Set([...base?.keys() ?? [], ...figma.keys(), ...head.keys()]);
|
|
1144
|
-
const result = { local: [], remote: [], conflicts: [], unchanged: 0 };
|
|
1145
|
-
for (const id of [...ids].sort()) {
|
|
1146
|
-
const b = base?.get(id);
|
|
1147
|
-
const f = figma.get(id);
|
|
1148
|
-
const h = head.get(id);
|
|
1149
|
-
const local = sideChange(b, f);
|
|
1150
|
-
const remote = sideChange(b, h);
|
|
1151
|
-
if (!local && !remote || f && h && sameToken(f, h) || !f && !h) {
|
|
1152
|
-
result.unchanged++;
|
|
1153
|
-
continue;
|
|
1154
|
-
}
|
|
1155
|
-
const entry = { id, path: (f ?? h ?? b).path, base: b, figma: f, head: h, local, remote, conflict: false };
|
|
1156
|
-
if (local && !remote) {
|
|
1157
|
-
entry.path = (f ?? b).path;
|
|
1158
|
-
result.local.push(entry);
|
|
1159
|
-
} else if (remote && !local) {
|
|
1160
|
-
entry.path = (h ?? b).path;
|
|
1161
|
-
result.remote.push(entry);
|
|
1162
|
-
} else {
|
|
1163
|
-
entry.conflict = true;
|
|
1164
|
-
result.conflicts.push(entry);
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
const byPath = (a, b) => a.path.localeCompare(b.path);
|
|
1168
|
-
result.local.sort(byPath);
|
|
1169
|
-
result.remote.sort(byPath);
|
|
1170
|
-
result.conflicts.sort(byPath);
|
|
1171
|
-
return result;
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
// ../core/src/risk.ts
|
|
1175
|
-
var RISK_LABELS = {
|
|
1176
|
-
1: "Tier 1: low risk, one code owner",
|
|
1177
|
-
2: "Tier 2: medium risk, design review then design + tech approval",
|
|
1178
|
-
3: "Tier 3: token change, needs design + tech approval"
|
|
1179
|
-
};
|
|
1180
|
-
function figmaPushTierLabel(tier, changes) {
|
|
1181
|
-
const waits = changes.some((c) => c.kind === "renamed" || c.kind === "removed");
|
|
1182
|
-
return `Tier ${tier}: token change. From Figma: design-approved, ${waits ? "waits for a developer OK (a token renamed or removed can break product code)" : "ships once the checks pass"}`;
|
|
1183
|
-
}
|
|
1184
|
-
var figmaPushNextLine = (changes) => changes.some((c) => c.kind === "renamed" || c.kind === "removed") ? "Pushed from Figma, so design-approved. A developer OKs the rename or removal before it merges." : "Pushed from Figma, so design-approved. Bridge merges it once the automatic checks pass; Undo is in History in Bridge Studio.";
|
|
1185
|
-
var BUMP_RANK = { patch: 0, minor: 1, major: 2 };
|
|
1186
|
-
var LOW = [/\.md$/, /^docs\//, /\.stories\.tsx?$/, /\.docs\.json$/, /\.test\.tsx?$/, /^\.changeset\//];
|
|
1187
|
-
var isSummary = (c) => "kind" in c;
|
|
1188
|
-
function summarizeTokenChange(c) {
|
|
1189
|
-
if (isSummary(c)) return c;
|
|
1190
|
-
const path = (c.target ?? c.current).path;
|
|
1191
|
-
if (!c.target) return { kind: "removed", path };
|
|
1192
|
-
if (!c.current) return { kind: "added", path };
|
|
1193
|
-
if (c.current.path !== c.target.path) return { kind: "renamed", path };
|
|
1194
|
-
const fields = fieldChanges(c.current, c.target);
|
|
1195
|
-
return { kind: "changed", path, descriptionOnly: fields.length > 0 && fields.every((f) => f.field === "description") };
|
|
1196
|
-
}
|
|
1197
|
-
function tokenBump(changes) {
|
|
1198
|
-
let bump;
|
|
1199
|
-
for (const c of changes.map(summarizeTokenChange)) {
|
|
1200
|
-
const b = c.kind === "removed" || c.kind === "renamed" ? "major" : c.kind === "changed" && c.descriptionOnly ? "patch" : "minor";
|
|
1201
|
-
if (!bump || BUMP_RANK[b] > BUMP_RANK[bump]) bump = b;
|
|
1202
|
-
}
|
|
1203
|
-
return bump;
|
|
1204
|
-
}
|
|
1205
|
-
function isGuardrail(path, config) {
|
|
1206
|
-
const list2 = config ? [...config.governance.guardrails, CONFIG_FILE, ...config.contrast ? [config.contrast.path] : []] : DEFAULT_GOVERNANCE.guardrails;
|
|
1207
|
-
return list2.some((g) => g.endsWith("/") ? path.startsWith(g) : path === g) || path.startsWith(".github/") || path.endsWith("/contrast.checks.json") || path === "contrast.checks.json";
|
|
1208
|
-
}
|
|
1209
|
-
function classifyRisk(input) {
|
|
1210
|
-
const reasons = [];
|
|
1211
|
-
const tokenChanges = (input.tokenChanges ?? []).map(summarizeTokenChange);
|
|
1212
|
-
for (const c of tokenChanges) {
|
|
1213
|
-
if (c.kind === "changed" && c.descriptionOnly) reasons.push({ tier: 1, text: `Token description changed: ${c.path}` });
|
|
1214
|
-
else reasons.push({ tier: 3, text: `Token ${c.kind}: ${c.path}` });
|
|
1215
|
-
}
|
|
1216
|
-
const bump = tokenBump(tokenChanges);
|
|
1217
|
-
const componentsDir = input.config?.components?.dir;
|
|
1218
|
-
for (const f of input.files ?? []) {
|
|
1219
|
-
const p = f.path.replace(/^\/+/, "");
|
|
1220
|
-
if (p.endsWith(".tokens.json")) {
|
|
1221
|
-
if (!input.tokenChanges) reasons.push({ tier: 3, text: `Token file ${f.status ?? "changed"}: ${p}` });
|
|
1222
|
-
} else if (isGuardrail(p, input.config)) reasons.push({ tier: 3, text: `Guardrail file changed: ${p}` });
|
|
1223
|
-
else if (LOW.some((r) => r.test(p))) reasons.push({ tier: 1, text: `Docs, story or test: ${p}` });
|
|
1224
|
-
else if (componentsDir && p.startsWith(`${componentsDir}/`)) reasons.push({ tier: 2, text: `Component source ${f.status ?? "changed"}: ${p}` });
|
|
1225
|
-
else reasons.push({ tier: 2, text: `Source file changed: ${p}` });
|
|
1226
|
-
}
|
|
1227
|
-
reasons.sort((a, b) => b.tier - a.tier);
|
|
1228
|
-
const tier = reasons[0]?.tier ?? 1;
|
|
1229
|
-
return { tier, label: RISK_LABELS[tier], reasons: reasons.map((r) => r.text), bump };
|
|
1230
|
-
}
|
|
1231
|
-
|
|
1232
1076
|
// ../core/src/layered.ts
|
|
1233
1077
|
var DTCG_TYPES = /* @__PURE__ */ new Set(["color", "dimension", "fontFamily", "fontWeight", "duration", "cubicBezier", "number", "strokeStyle", "border", "transition", "shadow", "gradient", "typography", "fontStyle", "string", "boolean"]);
|
|
1234
1078
|
var aliasOf = (v) => isAlias(v) ? aliasTarget(v) : null;
|
|
@@ -1596,6 +1440,164 @@ function layeredParityIssues(set) {
|
|
|
1596
1440
|
return out;
|
|
1597
1441
|
}
|
|
1598
1442
|
|
|
1443
|
+
// ../core/src/scopes.ts
|
|
1444
|
+
var has = (segments, ...names) => names.some((n) => segments.includes(n));
|
|
1445
|
+
function defaultScopes(path, type, tier) {
|
|
1446
|
+
const s = path.split(".");
|
|
1447
|
+
switch (type) {
|
|
1448
|
+
case "color":
|
|
1449
|
+
if (tier === "primitive" || tier === "brand" && s[0] === "palette") return [];
|
|
1450
|
+
if (has(s, "text")) return ["TEXT_FILL"];
|
|
1451
|
+
if (has(s, "border", "ring", "outline")) return ["STROKE_COLOR"];
|
|
1452
|
+
if (has(s, "bg", "surface", "background")) return ["FRAME_FILL", "SHAPE_FILL"];
|
|
1453
|
+
if (has(s, "shadow")) return ["EFFECT_COLOR"];
|
|
1454
|
+
return ["FRAME_FILL", "SHAPE_FILL", "TEXT_FILL", "STROKE_COLOR"];
|
|
1455
|
+
case "dimension":
|
|
1456
|
+
if (has(s, "radius")) return ["CORNER_RADIUS"];
|
|
1457
|
+
if (has(s, "border", "width", "stroke")) return ["STROKE_FLOAT"];
|
|
1458
|
+
if (has(s, "space", "spacing", "gap")) return ["GAP", "WIDTH_HEIGHT"];
|
|
1459
|
+
if (has(s, "size") && has(s, "font")) return ["FONT_SIZE"];
|
|
1460
|
+
if (has(s, "letter-spacing")) return ["LETTER_SPACING"];
|
|
1461
|
+
return ["WIDTH_HEIGHT", "GAP"];
|
|
1462
|
+
case "fontWeight":
|
|
1463
|
+
return ["FONT_WEIGHT"];
|
|
1464
|
+
case "fontFamily":
|
|
1465
|
+
return ["FONT_FAMILY"];
|
|
1466
|
+
case "number":
|
|
1467
|
+
if (has(s, "line-height", "lineHeight")) return ["LINE_HEIGHT"];
|
|
1468
|
+
if (has(s, "opacity")) return ["OPACITY"];
|
|
1469
|
+
return ["WIDTH_HEIGHT", "GAP"];
|
|
1470
|
+
case "string":
|
|
1471
|
+
return ["TEXT_CONTENT"];
|
|
1472
|
+
default:
|
|
1473
|
+
return [];
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
var sameScopes = (a, b) => {
|
|
1477
|
+
const sa = [...new Set(a)].sort();
|
|
1478
|
+
const sb = [...new Set(b)].sort();
|
|
1479
|
+
return sa.length === sb.length && sa.every((x, i) => x === sb[i]);
|
|
1480
|
+
};
|
|
1481
|
+
var effectiveScopes = (t) => t.scopes ?? defaultScopes(t.path, t.type, t.tier);
|
|
1482
|
+
|
|
1483
|
+
// ../core/src/diff-engine.ts
|
|
1484
|
+
var normDesc = (d) => (d ?? "").trim();
|
|
1485
|
+
function fieldChanges(a, b) {
|
|
1486
|
+
const out = [];
|
|
1487
|
+
if (a.path !== b.path) out.push({ field: "path", before: a.path, after: b.path });
|
|
1488
|
+
if (a.type !== b.type) out.push({ field: "type", before: a.type, after: b.type });
|
|
1489
|
+
const modes = [.../* @__PURE__ */ new Set([...Object.keys(a.values), ...Object.keys(b.values)])];
|
|
1490
|
+
for (const mode of modes) {
|
|
1491
|
+
if (!valuesEqual(b.type, a.values[mode], b.values[mode])) out.push({ field: "value", mode, before: a.values[mode], after: b.values[mode] });
|
|
1492
|
+
}
|
|
1493
|
+
if (normDesc(a.description) !== normDesc(b.description)) out.push({ field: "description", before: a.description, after: b.description });
|
|
1494
|
+
const sa = effectiveScopes(a);
|
|
1495
|
+
const sb = effectiveScopes(b);
|
|
1496
|
+
if (!sameScopes(sa, sb)) out.push({ field: "scopes", before: sa, after: sb });
|
|
1497
|
+
return out;
|
|
1498
|
+
}
|
|
1499
|
+
function sameToken(a, b) {
|
|
1500
|
+
if (!a || !b) return a === b;
|
|
1501
|
+
return fieldChanges(a, b).length === 0;
|
|
1502
|
+
}
|
|
1503
|
+
function sideChange(from, to) {
|
|
1504
|
+
if (!from && !to) return void 0;
|
|
1505
|
+
if (!from) return { kind: "added", fields: [] };
|
|
1506
|
+
if (!to) return { kind: "removed", fields: [] };
|
|
1507
|
+
const fields = fieldChanges(from, to);
|
|
1508
|
+
if (!fields.length) return void 0;
|
|
1509
|
+
return { kind: fields.some((f) => f.field === "path") ? "renamed" : "changed", fields };
|
|
1510
|
+
}
|
|
1511
|
+
function threeWayDiff(base, figma, head) {
|
|
1512
|
+
const ids = /* @__PURE__ */ new Set([...base?.keys() ?? [], ...figma.keys(), ...head.keys()]);
|
|
1513
|
+
const result = { local: [], remote: [], conflicts: [], unchanged: 0 };
|
|
1514
|
+
for (const id of [...ids].sort()) {
|
|
1515
|
+
const b = base?.get(id);
|
|
1516
|
+
const f = figma.get(id);
|
|
1517
|
+
const h = head.get(id);
|
|
1518
|
+
const local = sideChange(b, f);
|
|
1519
|
+
const remote = sideChange(b, h);
|
|
1520
|
+
if (!local && !remote || f && h && sameToken(f, h) || !f && !h) {
|
|
1521
|
+
result.unchanged++;
|
|
1522
|
+
continue;
|
|
1523
|
+
}
|
|
1524
|
+
const entry = { id, path: (f ?? h ?? b).path, base: b, figma: f, head: h, local, remote, conflict: false };
|
|
1525
|
+
if (local && !remote) {
|
|
1526
|
+
entry.path = (f ?? b).path;
|
|
1527
|
+
result.local.push(entry);
|
|
1528
|
+
} else if (remote && !local) {
|
|
1529
|
+
entry.path = (h ?? b).path;
|
|
1530
|
+
result.remote.push(entry);
|
|
1531
|
+
} else {
|
|
1532
|
+
entry.conflict = true;
|
|
1533
|
+
result.conflicts.push(entry);
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
const byPath = (a, b) => a.path.localeCompare(b.path);
|
|
1537
|
+
result.local.sort(byPath);
|
|
1538
|
+
result.remote.sort(byPath);
|
|
1539
|
+
result.conflicts.sort(byPath);
|
|
1540
|
+
return result;
|
|
1541
|
+
}
|
|
1542
|
+
|
|
1543
|
+
// ../core/src/risk.ts
|
|
1544
|
+
var RISK_LABELS = {
|
|
1545
|
+
1: "Tier 1: low risk, one code owner",
|
|
1546
|
+
2: "Tier 2: medium risk, design review then design + tech approval",
|
|
1547
|
+
3: "Tier 3: token change, needs design + tech approval"
|
|
1548
|
+
};
|
|
1549
|
+
function figmaPushTierLabel(tier, changes) {
|
|
1550
|
+
const waits = changes.some((c) => c.kind === "renamed" || c.kind === "removed");
|
|
1551
|
+
return `Tier ${tier}: token change. From Figma: design-approved, ${waits ? "waits for a developer OK (a token renamed or removed can break product code)" : "ships once the checks pass"}`;
|
|
1552
|
+
}
|
|
1553
|
+
var figmaPushNextLine = (changes) => changes.some((c) => c.kind === "renamed" || c.kind === "removed") ? "Pushed from Figma, so design-approved. A developer OKs the rename or removal before it merges." : "Pushed from Figma, so design-approved. Bridge merges it once the automatic checks pass; Undo is in History in Bridge Studio.";
|
|
1554
|
+
var BUMP_RANK = { patch: 0, minor: 1, major: 2 };
|
|
1555
|
+
var LOW = [/\.md$/, /^docs\//, /\.stories\.tsx?$/, /\.docs\.json$/, /\.test\.tsx?$/, /^\.changeset\//];
|
|
1556
|
+
var isSummary = (c) => "kind" in c;
|
|
1557
|
+
function summarizeTokenChange(c) {
|
|
1558
|
+
if (isSummary(c)) return c;
|
|
1559
|
+
const path = (c.target ?? c.current).path;
|
|
1560
|
+
if (!c.target) return { kind: "removed", path };
|
|
1561
|
+
if (!c.current) return { kind: "added", path };
|
|
1562
|
+
if (c.current.path !== c.target.path) return { kind: "renamed", path };
|
|
1563
|
+
const fields = fieldChanges(c.current, c.target);
|
|
1564
|
+
return { kind: "changed", path, descriptionOnly: fields.length > 0 && fields.every((f) => f.field === "description") };
|
|
1565
|
+
}
|
|
1566
|
+
function tokenBump(changes) {
|
|
1567
|
+
let bump;
|
|
1568
|
+
for (const c of changes.map(summarizeTokenChange)) {
|
|
1569
|
+
const b = c.kind === "removed" || c.kind === "renamed" ? "major" : c.kind === "changed" && c.descriptionOnly ? "patch" : "minor";
|
|
1570
|
+
if (!bump || BUMP_RANK[b] > BUMP_RANK[bump]) bump = b;
|
|
1571
|
+
}
|
|
1572
|
+
return bump;
|
|
1573
|
+
}
|
|
1574
|
+
function isGuardrail(path, config) {
|
|
1575
|
+
const list2 = config ? [...config.governance.guardrails, CONFIG_FILE, ...config.contrast ? [config.contrast.path] : []] : DEFAULT_GOVERNANCE.guardrails;
|
|
1576
|
+
return list2.some((g) => g.endsWith("/") ? path.startsWith(g) : path === g) || path.startsWith(".github/") || path.endsWith("/contrast.checks.json") || path === "contrast.checks.json";
|
|
1577
|
+
}
|
|
1578
|
+
function classifyRisk(input) {
|
|
1579
|
+
const reasons = [];
|
|
1580
|
+
const tokenChanges = (input.tokenChanges ?? []).map(summarizeTokenChange);
|
|
1581
|
+
for (const c of tokenChanges) {
|
|
1582
|
+
if (c.kind === "changed" && c.descriptionOnly) reasons.push({ tier: 1, text: `Token description changed: ${c.path}` });
|
|
1583
|
+
else reasons.push({ tier: 3, text: `Token ${c.kind}: ${c.path}` });
|
|
1584
|
+
}
|
|
1585
|
+
const bump = tokenBump(tokenChanges);
|
|
1586
|
+
const componentsDir = input.config?.components?.dir;
|
|
1587
|
+
for (const f of input.files ?? []) {
|
|
1588
|
+
const p = f.path.replace(/^\/+/, "");
|
|
1589
|
+
if (p.endsWith(".tokens.json")) {
|
|
1590
|
+
if (!input.tokenChanges) reasons.push({ tier: 3, text: `Token file ${f.status ?? "changed"}: ${p}` });
|
|
1591
|
+
} else if (isGuardrail(p, input.config)) reasons.push({ tier: 3, text: `Guardrail file changed: ${p}` });
|
|
1592
|
+
else if (LOW.some((r) => r.test(p))) reasons.push({ tier: 1, text: `Docs, story or test: ${p}` });
|
|
1593
|
+
else if (componentsDir && p.startsWith(`${componentsDir}/`)) reasons.push({ tier: 2, text: `Component source ${f.status ?? "changed"}: ${p}` });
|
|
1594
|
+
else reasons.push({ tier: 2, text: `Source file changed: ${p}` });
|
|
1595
|
+
}
|
|
1596
|
+
reasons.sort((a, b) => b.tier - a.tier);
|
|
1597
|
+
const tier = reasons[0]?.tier ?? 1;
|
|
1598
|
+
return { tier, label: RISK_LABELS[tier], reasons: reasons.map((r) => r.text), bump };
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1599
1601
|
// ../core/src/layered-review.ts
|
|
1600
1602
|
function checkLayeredPair(set, pair, combo) {
|
|
1601
1603
|
const base = { fg: pair.foreground, bg: pair.background, min: pair.min, modes: comboKey(combo) };
|