@bridge-ds/mcp 0.7.1 → 0.7.2

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.
@@ -11745,7 +11745,7 @@ async function visualImpact(ctx, a, run2) {
11745
11745
  if (ctx.mode !== "local" || !ctx.root) throw new Error("Visual impact needs a local checkout (start Bridge with --root): it builds Storybook and the app at both refs.");
11746
11746
  if (!ctx.isGit) throw new Error(`${ctx.root} is not a git repository.`);
11747
11747
  const out = a.out ? resolve3(ctx.root, a.out) : join5(ctx.root, "visual-impact");
11748
- const runImpact = run2 ?? (await import("./src-ABI7LARD.js")).runImpact;
11748
+ const runImpact = run2 ?? (await import("./src-D6YUOJC7.js")).runImpact;
11749
11749
  const r = await runImpact({
11750
11750
  root: ctx.root,
11751
11751
  base: a.base ?? "main",
@@ -12811,7 +12811,7 @@ async function pushFigmaComponentOp(ctx, a) {
12811
12811
  }
12812
12812
 
12813
12813
  // src/server.ts
12814
- var VERSION = true ? "0.7.1" : "dev";
12814
+ var VERSION = true ? "0.7.2" : "dev";
12815
12815
  var ok = (data) => ({ content: [{ type: "text", text: typeof data === "string" ? data : JSON.stringify(data, null, 2) }] });
12816
12816
  var fail2 = (e) => ({ content: [{ type: "text", text: `Error: ${e.message ?? String(e)}` }], isError: true });
12817
12817
  var run = (fn) => async (a) => {
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  VERSION,
4
4
  optionsFromArgv,
5
5
  serveStdio
6
- } from "./chunk-YCKNSKPW.js";
6
+ } from "./chunk-FAB4HMPJ.js";
7
7
  import "./chunk-BZ3KXXMM.js";
8
8
 
9
9
  // src/index.ts
package/dist/lib.js CHANGED
@@ -28,7 +28,7 @@ import {
28
28
  serveStdio,
29
29
  studio_exports,
30
30
  suggestions_exports
31
- } from "./chunk-YCKNSKPW.js";
31
+ } from "./chunk-FAB4HMPJ.js";
32
32
  import {
33
33
  CONFIG_FILE,
34
34
  loadConfig,
@@ -127,6 +127,81 @@ function impactedModules(index, input) {
127
127
  return { modules, globalHits };
128
128
  }
129
129
 
130
+ // ../core/src/storybook.ts
131
+ var StorybookIndexError = class extends Error {
132
+ constructor(code, message, status) {
133
+ super(message);
134
+ this.code = code;
135
+ this.status = status;
136
+ this.name = "StorybookIndexError";
137
+ }
138
+ code;
139
+ status;
140
+ };
141
+ var isObj = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
142
+ var str = (v) => typeof v === "string" && v.trim() ? v : void 0;
143
+ function entryFrom(key, raw, v3) {
144
+ if (!isObj(raw)) return null;
145
+ const id = str(raw.id) ?? key;
146
+ const title = str(raw.title) ?? str(raw.kind);
147
+ const name = str(raw.name) ?? str(raw.story);
148
+ if (!id || !title || !name) return null;
149
+ const params = isObj(raw.parameters) ? raw.parameters : {};
150
+ const type = raw.type === "docs" || raw.type === "story" ? raw.type : v3 && params.docsOnly === true ? "docs" : "story";
151
+ const e = {
152
+ id,
153
+ title,
154
+ name,
155
+ type,
156
+ importPath: str(raw.importPath) ?? str(params.fileName) ?? "",
157
+ tags: Array.isArray(raw.tags) ? raw.tags.filter((t) => typeof t === "string") : []
158
+ };
159
+ const subtype = str(raw.subtype);
160
+ if (subtype) e.subtype = subtype;
161
+ const exportName = str(raw.exportName);
162
+ if (exportName) e.exportName = exportName;
163
+ const componentPath = str(raw.componentPath);
164
+ if (componentPath) e.componentPath = componentPath;
165
+ return e;
166
+ }
167
+ function groupStorybookComponents(entries) {
168
+ const byTitle = /* @__PURE__ */ new Map();
169
+ for (const e of entries) {
170
+ let c = byTitle.get(e.title);
171
+ if (!c) {
172
+ const parts = e.title.split("/").map((p) => p.trim()).filter(Boolean);
173
+ c = { title: e.title, name: parts[parts.length - 1] ?? e.title, group: parts.slice(0, -1), stories: [], docs: [], tags: [] };
174
+ byTitle.set(e.title, c);
175
+ }
176
+ if (e.type === "docs") c.docs.push(e);
177
+ else if (e.subtype !== "test") c.stories.push(e);
178
+ for (const t of e.tags) if (!c.tags.includes(t)) c.tags.push(t);
179
+ }
180
+ const out = [...byTitle.values()].filter((c) => c.stories.length || c.docs.length);
181
+ for (const c of out) c.tags.sort();
182
+ return out.sort((a, b) => a.title.localeCompare(b.title));
183
+ }
184
+ function parseStorybookIndex(json, source) {
185
+ if (!isObj(json)) throw new StorybookIndexError("not-json", "The Storybook index is not a JSON object.");
186
+ if (typeof json.loginUrl === "string" && !("entries" in json) && !("stories" in json)) {
187
+ throw new StorybookIndexError("private", "This Storybook is private: it asks for a sign-in before showing its index.");
188
+ }
189
+ const map = isObj(json.entries) ? json.entries : isObj(json.stories) ? json.stories : null;
190
+ if (!map) throw new StorybookIndexError("empty", "This file has no Storybook entries.");
191
+ const v3 = !isObj(json.entries);
192
+ const entries = Object.entries(map).map(([k, raw]) => entryFrom(k, raw, v3)).filter((e) => e !== null);
193
+ if (!entries.length) throw new StorybookIndexError("empty", "This Storybook index lists no stories or docs.");
194
+ const version = typeof json.v === "number" ? json.v : v3 ? 3 : 4;
195
+ return { version, source: source ?? (v3 ? "stories.json" : "index.json"), entries, components: groupStorybookComponents(entries) };
196
+ }
197
+ var pairs = (o) => Object.entries(o).map(([k, v]) => `${encodeURIComponent(k)}:${encodeURIComponent(v)}`).join(";");
198
+ function storybookIframeUrl(base, id, o = {}) {
199
+ let url = `${base.replace(/\/+$/, "")}/iframe.html?id=${encodeURIComponent(id)}&viewMode=${o.viewMode ?? "story"}`;
200
+ if (o.globals && Object.keys(o.globals).length) url += `&globals=${pairs(o.globals)}`;
201
+ if (o.args && Object.keys(o.args).length) url += `&args=${pairs(o.args)}`;
202
+ return url;
203
+ }
204
+
130
205
  // ../visual/src/capture.ts
131
206
  import { mkdir, writeFile } from "node:fs/promises";
132
207
  import { dirname } from "node:path";
@@ -521,7 +596,7 @@ function routeUrl(base, route, tenant, theme) {
521
596
  return `${base.replace(/\/$/, "")}/?tenant=${encodeURIComponent(tenant)}&theme=${encodeURIComponent(theme)}&density=comfortable&lang=en#${route.pathByTenant?.[tenant] ?? route.path}`;
522
597
  }
523
598
  function storyUrl(base, id, brand, theme) {
524
- return `${base.replace(/\/$/, "")}/iframe.html?id=${encodeURIComponent(id)}&viewMode=story&globals=brand:${brand};theme:${theme};density:comfortable`;
599
+ return storybookIframeUrl(base, id, { globals: { brand, theme, density: "comfortable" } });
525
600
  }
526
601
  var shotKey = (...parts) => parts.map((p) => p.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-|-$/g, "")).join("__");
527
602
 
@@ -812,8 +887,8 @@ function changedTokens(before, after) {
812
887
  return [...modes.entries()].map(([path, m]) => ({ path, kind: direct.has(path) ? "direct" : "alias", modes: m })).sort((a, b) => Number(a.kind === "alias") - Number(b.kind === "alias") || a.path.localeCompare(b.path));
813
888
  }
814
889
  async function readIndexJson(dir) {
815
- const raw = JSON.parse(await readFile3(join3(dir, "index.json"), "utf8"));
816
- return Object.values(raw.entries).filter((e) => e.type === "story").map(({ id, title, name, importPath }) => ({ id, title, name, importPath }));
890
+ const index = parseStorybookIndex(JSON.parse(await readFile3(join3(dir, "index.json"), "utf8")), "index.json");
891
+ return index.entries.filter((e) => e.type === "story").map(({ id, title, name, importPath }) => ({ id, title, name, importPath }));
817
892
  }
818
893
  async function planImpact(o) {
819
894
  const root = resolve(o.root);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bridge-ds/mcp",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "type": "module",
5
5
  "description": "Bridge MCP server: lets Claude (Claude Code, Claude Desktop or any MCP client) read, check and propose changes to a DTCG design system repo through pull requests.",
6
6
  "license": "MIT",
@@ -54,8 +54,8 @@
54
54
  "build:package": "node ../../scripts/build-packages.mjs mcp"
55
55
  },
56
56
  "dependencies": {
57
- "@bridge-ds/core": "^0.11.0",
58
- "@bridge-ds/visual": "^0.3.5",
57
+ "@bridge-ds/core": "^0.12.0",
58
+ "@bridge-ds/visual": "^0.3.6",
59
59
  "@modelcontextprotocol/sdk": "1.31.0",
60
60
  "typescript": "5.9.3",
61
61
  "zod": "3.25.76"