@bridge-ds/mcp 0.5.0 → 0.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.
@@ -188,7 +188,7 @@ export declare function tryBranch(ctx: BridgeContext, a: {
188
188
  }[];
189
189
  share: {
190
190
  message?: import("@bridge-ds/core").ShareMessage | undefined;
191
- state: "ready" | "building" | "failed" | "closed" | "no-packages" | "shipped";
191
+ state: "ready" | "building" | "failed" | "closed" | "shipped" | "no-packages";
192
192
  install: string | null;
193
193
  sentence: string;
194
194
  };
@@ -558,6 +558,8 @@ function sameProducts(a, b) {
558
558
 
559
559
  // ../core/src/config.ts
560
560
  var CONFIG_FILE = "bridge.config.json";
561
+ var CHANGES_MODES = ["suggest", "direct"];
562
+ var DEFAULT_CHANGES_MODE = "suggest";
561
563
  var DEFAULT_OVERRIDE = { allowed: [], requireReason: true, minReasonLength: 20 };
562
564
  var DEFAULT_TOKEN_PATHS = {
563
565
  root: "tokens",
@@ -697,6 +699,8 @@ function defineConfig(input) {
697
699
  ...g.rights ? { rights: normalizeRights(g.rights) } : {}
698
700
  },
699
701
  products: input.products?.length ? input.products.map((p) => ({ ...p })) : DEFAULT_PRODUCTS.map((p) => ({ ...p })),
702
+ changes: input.changes === "direct" ? "direct" : DEFAULT_CHANGES_MODE,
703
+ ...input.storybook?.url ? { storybook: { url: input.storybook.url.trim().replace(/\/+$/, "") } } : {},
700
704
  ...input.audit ? { audit: { ...input.audit } } : {},
701
705
  ...input.visualImpact ? { visualImpact: { mode: input.visualImpact.mode === "on-demand" ? "on-demand" : "auto" } } : {},
702
706
  ...input.integrations ? { integrations: { ...input.integrations } } : {},
@@ -819,6 +823,13 @@ function loadConfig(source) {
819
823
  }
820
824
  }
821
825
  problems.push(...visualImpactProblems(d.visualImpact));
826
+ if (d.changes !== void 0 && !CHANGES_MODES.includes(d.changes)) problems.push(`"changes" must be "suggest" or "direct" (got ${JSON.stringify(d.changes)})`);
827
+ const sb = d.storybook;
828
+ if (sb !== void 0) {
829
+ if (!isObj(sb) || !isStr(sb.url)) problems.push('"storybook" must be { "url" } with the deployed Storybook address');
830
+ else if (!/^https:\/\/[^\s/]+/.test(sb.url.trim())) problems.push('"storybook.url" must start with https://, for example https://storybook.example.com');
831
+ else for (const k of Object.keys(sb)) if (k !== "url") problems.push(`"storybook.${k}" is not a known key`);
832
+ }
822
833
  problems.push(...productProblems(d.products));
823
834
  const audit = d.audit;
824
835
  if (audit !== void 0) {
@@ -851,6 +862,7 @@ function loadConfig(source) {
851
862
  var tokensPath = (config, rel = "") => [config.tokens.root === "." ? "" : config.tokens.root, rel].filter(Boolean).join("/");
852
863
  var protectedBranchesOf = (config) => [.../* @__PURE__ */ new Set([...config.governance.protectedBranches, ...config.repo ? [config.repo.defaultBranch] : []])];
853
864
  var baseBranchOf = (config) => config.repo?.defaultBranch ?? "main";
865
+ var changesMode = (config) => config?.changes === "direct" ? "direct" : DEFAULT_CHANGES_MODE;
854
866
  function toConfigJson(config, schema = "./packages/core/bridge.config.schema.json") {
855
867
  return {
856
868
  $schema: schema,
@@ -867,6 +879,8 @@ function toConfigJson(config, schema = "./packages/core/bridge.config.schema.jso
867
879
  ...config.audit ? { audit: config.audit } : {},
868
880
  ...config.previews ? { previews: config.previews } : {},
869
881
  ...config.visualImpact ? { visualImpact: config.visualImpact } : {},
882
+ changes: changesMode(config),
883
+ ...config.storybook ? { storybook: config.storybook } : {},
870
884
  ...config.products && !sameProducts(config.products, DEFAULT_PRODUCTS) ? { products: config.products } : {}
871
885
  };
872
886
  }
@@ -1943,11 +1957,17 @@ async function commitToNewLocalBranch(root, args) {
1943
1957
  throw new Error(`Refusing to write branch "${args.branch}": ${err.message}`);
1944
1958
  }
1945
1959
  if (await branchExists(root, args.branch)) throw new Error(`Branch "${args.branch}" already exists. Pick another title or delete it first.`);
1946
- const baseSha = (await git(root, ["rev-parse", "--verify", `${args.base}^{commit}`])).trim();
1960
+ const { sha, parent } = await commitTree(root, args);
1961
+ await git(root, ["update-ref", `refs/heads/${args.branch}`, sha, ""]);
1962
+ const diff = await git(root, ["diff", parent, sha]);
1963
+ return { sha, diff };
1964
+ }
1965
+ async function commitTree(root, args) {
1966
+ const parent = (await git(root, ["rev-parse", "--verify", `${args.base}^{commit}`])).trim();
1947
1967
  const dir = await mkdtemp(join(tmpdir(), "bridge-index-"));
1948
1968
  const env = { GIT_INDEX_FILE: join(dir, "index") };
1949
1969
  try {
1950
- await git(root, ["read-tree", baseSha], { env });
1970
+ await git(root, ["read-tree", parent], { env });
1951
1971
  for (const f of args.files) {
1952
1972
  if (f.content === null) {
1953
1973
  await git(root, ["update-index", "--force-remove", f.path], { env });
@@ -1958,10 +1978,8 @@ async function commitToNewLocalBranch(root, args) {
1958
1978
  }
1959
1979
  const tree = (await git(root, ["write-tree"], { env })).trim();
1960
1980
  const ident = await identityEnv(root);
1961
- const sha = (await git(root, ["commit-tree", tree, "-p", baseSha, "-F", "-"], { input: args.message, env: ident })).trim();
1962
- await git(root, ["update-ref", `refs/heads/${args.branch}`, sha, ""]);
1963
- const diff = await git(root, ["diff", baseSha, sha]);
1964
- return { sha, diff };
1981
+ const sha = (await git(root, ["commit-tree", tree, "-p", parent, "-F", "-"], { input: args.message, env: ident })).trim();
1982
+ return { sha, parent };
1965
1983
  } finally {
1966
1984
  await rm(dir, { recursive: true, force: true });
1967
1985
  }
@@ -2035,6 +2053,7 @@ export {
2035
2053
  assertSafeBranch,
2036
2054
  DEFAULT_COMPONENT_SPECS_FILE,
2037
2055
  coverageSummary,
2056
+ variantKeyOf,
2038
2057
  parseComponentSpecs,
2039
2058
  figmaCell,
2040
2059
  FIGMA_REFERENCES_BRANCH,