@stackwright-pro/mcp 0.2.0-alpha.103 → 0.2.0-alpha.104

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/dist/server.mjs CHANGED
@@ -556,7 +556,7 @@ function registerDashboardTools(server2) {
556
556
  yamlLines.push(` header: Status`);
557
557
  yamlLines.push(` type: badge`);
558
558
  }
559
- const yaml2 = yamlLines.join("\n");
559
+ const yaml3 = yamlLines.join("\n");
560
560
  return {
561
561
  content: [
562
562
  {
@@ -566,7 +566,7 @@ function registerDashboardTools(server2) {
566
566
  Layout: ${layout}
567
567
 
568
568
  \`\`\`yaml
569
- ${yaml2}
569
+ ${yaml3}
570
570
  \`\`\`
571
571
 
572
572
  \u{1F4A1} Add this to pages/dashboard/content.yml and validate with stackwright_validate_pages.`
@@ -647,7 +647,7 @@ ${yaml2}
647
647
  yamlLines.push(" action: navigate");
648
648
  yamlLines.push(` href: "/${entity}"`);
649
649
  yamlLines.push(" style: secondary");
650
- const yaml2 = yamlLines.join("\n");
650
+ const yaml3 = yamlLines.join("\n");
651
651
  return {
652
652
  content: [
653
653
  {
@@ -655,7 +655,7 @@ ${yaml2}
655
655
  text: `\u{1F4C4} Generated Detail Page for: ${entity}
656
656
 
657
657
  \`\`\`yaml
658
- ${yaml2}
658
+ ${yaml3}
659
659
  \`\`\`
660
660
 
661
661
  \u{1F4A1} Add this to pages/${entity}/[${slugField}]/content.yml and validate.`
@@ -2455,7 +2455,7 @@ function enrichErrors(issues, synonyms) {
2455
2455
  });
2456
2456
  }
2457
2457
  function handleValidateYamlFragment(input) {
2458
- const { schemaName, yaml: yaml2 } = input;
2458
+ const { schemaName, yaml: yaml3 } = input;
2459
2459
  if (!SUPPORTED_SCHEMA_NAMES.includes(schemaName)) {
2460
2460
  return {
2461
2461
  valid: false,
@@ -2465,7 +2465,7 @@ function handleValidateYamlFragment(input) {
2465
2465
  const name = schemaName;
2466
2466
  let parsed;
2467
2467
  try {
2468
- parsed = yamlLoad(yaml2);
2468
+ parsed = yamlLoad(yaml3);
2469
2469
  } catch (err) {
2470
2470
  return {
2471
2471
  valid: false,
@@ -2491,8 +2491,8 @@ function registerValidateYamlFragmentTool(server2) {
2491
2491
  ),
2492
2492
  yaml: z11.string().describe("YAML string to validate (can also be JSON \u2014 js-yaml parses both)")
2493
2493
  },
2494
- async ({ schemaName, yaml: yaml2 }) => {
2495
- const result = handleValidateYamlFragment({ schemaName, yaml: yaml2 });
2494
+ async ({ schemaName, yaml: yaml3 }) => {
2495
+ const result = handleValidateYamlFragment({ schemaName, yaml: yaml3 });
2496
2496
  return {
2497
2497
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
2498
2498
  };
@@ -5801,7 +5801,7 @@ import { join as join8, basename } from "path";
5801
5801
  var _checksums = /* @__PURE__ */ new Map([
5802
5802
  [
5803
5803
  "stackwright-pro-api-otter.json",
5804
- "a5ff25531c330289af89e433e696ba1ffef8f7ea09985a559cf915592c9734ad"
5804
+ "023352bac8303d86b33559719dc3f8d06d3a5a1458719eb74e1dc76019cf9d2f"
5805
5805
  ],
5806
5806
  [
5807
5807
  "stackwright-pro-auth-otter.json",
@@ -5825,7 +5825,7 @@ var _checksums = /* @__PURE__ */ new Map([
5825
5825
  ],
5826
5826
  [
5827
5827
  "stackwright-pro-foreman-otter.json",
5828
- "c23436769a9db06fa6f9d312b4fdd8b2cef6646461020eeaf227303350073593"
5828
+ "9d68b7b20af7a8a1668e2a693b4a2b05cf37acce1e9f6298a0966c97a3417e9f"
5829
5829
  ],
5830
5830
  [
5831
5831
  "stackwright-pro-form-wizard-otter.json",
@@ -5853,7 +5853,7 @@ var _checksums = /* @__PURE__ */ new Map([
5853
5853
  ],
5854
5854
  [
5855
5855
  "stackwright-pro-theme-otter.json",
5856
- "b0eccc1945e30b80a0f9a3209c5428e8e32cd09063bd9b2ef7ecb891343774f2"
5856
+ "01d16d0597d475db60362e3b8020035e140817d197c36f4307a48b95f4b28b60"
5857
5857
  ],
5858
5858
  [
5859
5859
  "stackwright-services-otter.json",
@@ -7755,6 +7755,140 @@ function registerListSpecsTool(server2) {
7755
7755
  );
7756
7756
  }
7757
7757
 
7758
+ // src/tools/consolidate-integrations.ts
7759
+ import { z as z24 } from "zod";
7760
+ import { readdirSync as readdirSync7, readFileSync as readFileSync14, writeFileSync as writeFileSync10, existsSync as existsSync14, mkdirSync as mkdirSync9 } from "fs";
7761
+ import { lockSync as lockSync2 } from "proper-lockfile";
7762
+ import { join as join15, basename as basename3 } from "path";
7763
+ import yaml2 from "js-yaml";
7764
+ var BASE_MOCK_PORT = 4011;
7765
+ var STRIP_SUFFIXES2 = ["-openapi", "-asyncapi", "-api", "-spec"];
7766
+ function deriveNameFromFilename(filename) {
7767
+ const base = basename3(filename, ".json").replace(/^api-config-/, "");
7768
+ for (const suffix of STRIP_SUFFIXES2) {
7769
+ if (base.endsWith(suffix)) return base.slice(0, -suffix.length);
7770
+ }
7771
+ return base;
7772
+ }
7773
+ function handleConsolidateIntegrations(input) {
7774
+ const { projectRoot } = input;
7775
+ const artifactsDir = join15(projectRoot, ".stackwright", "artifacts");
7776
+ if (!existsSync14(artifactsDir)) {
7777
+ return { written: false, integrationCount: 0, reason: "no per-spec artifacts found" };
7778
+ }
7779
+ let entries;
7780
+ try {
7781
+ entries = readdirSync7(artifactsDir).filter(
7782
+ (f) => f.startsWith("api-config-") && f.endsWith(".json") && f !== "api-config.json"
7783
+ );
7784
+ } catch {
7785
+ return { written: false, integrationCount: 0, reason: "could not read artifacts directory" };
7786
+ }
7787
+ if (entries.length === 0) {
7788
+ return { written: false, integrationCount: 0, reason: "no per-spec artifacts found" };
7789
+ }
7790
+ entries.sort();
7791
+ const integrationsByName = /* @__PURE__ */ new Map();
7792
+ entries.forEach((filename, index) => {
7793
+ let artifact = {};
7794
+ try {
7795
+ const raw = readFileSync14(join15(artifactsDir, filename), "utf-8");
7796
+ artifact = JSON.parse(raw);
7797
+ } catch {
7798
+ }
7799
+ const name = artifact.integrationName ?? deriveNameFromFilename(filename);
7800
+ const spec = artifact.integrationSpec ?? artifact.specPath ?? `./specs/${name}.yaml`;
7801
+ const mockUrl = artifact.mockUrl ?? `http://localhost:${BASE_MOCK_PORT + index}`;
7802
+ const baseUrl = artifact.baseUrl ?? "";
7803
+ const auth = artifact.auth ?? { type: "none" };
7804
+ const isAsyncApi = artifact.skipped?.some((s) => s.format === "asyncapi") ?? false;
7805
+ const integrationType = artifact.integrationFormat ?? (isAsyncApi ? "asyncapi" : "openapi");
7806
+ const entry = {
7807
+ type: integrationType,
7808
+ name,
7809
+ spec,
7810
+ mockUrl,
7811
+ baseUrl,
7812
+ auth
7813
+ };
7814
+ if (artifact.integrationEndpoints) {
7815
+ entry.endpoints = artifact.integrationEndpoints;
7816
+ }
7817
+ integrationsByName.set(name, entry);
7818
+ });
7819
+ const integrations = Array.from(integrationsByName.values());
7820
+ const dedupedCount = entries.length - integrations.length;
7821
+ const integrationsYmlPath = join15(projectRoot, "stackwright.integrations.yml");
7822
+ let existing = {};
7823
+ if (existsSync14(integrationsYmlPath)) {
7824
+ try {
7825
+ const raw = readFileSync14(integrationsYmlPath, "utf-8");
7826
+ existing = yaml2.load(raw) ?? {};
7827
+ } catch {
7828
+ existing = {};
7829
+ }
7830
+ }
7831
+ const merged = { ...existing, integrations };
7832
+ mkdirSync9(join15(projectRoot), { recursive: true });
7833
+ if (!existsSync14(integrationsYmlPath)) {
7834
+ writeFileSync10(integrationsYmlPath, "", "utf-8");
7835
+ }
7836
+ const release = lockSync2(integrationsYmlPath, {
7837
+ realpath: false,
7838
+ stale: 1e4
7839
+ });
7840
+ try {
7841
+ const header = `# stackwright.integrations.yml \u2014 Auto-generated by stackwright_pro_consolidate_integrations
7842
+ `;
7843
+ const body = yaml2.dump(merged, { lineWidth: 120, noRefs: true });
7844
+ writeFileSync10(integrationsYmlPath, header + body, "utf-8");
7845
+ } finally {
7846
+ release();
7847
+ }
7848
+ return {
7849
+ written: true,
7850
+ integrationCount: integrations.length,
7851
+ path: "stackwright.integrations.yml",
7852
+ ...dedupedCount > 0 ? { dedupedCount } : {}
7853
+ };
7854
+ }
7855
+ function registerConsolidateIntegrationsTool(server2) {
7856
+ server2.tool(
7857
+ "stackwright_pro_consolidate_integrations",
7858
+ [
7859
+ "Assemble stackwright.integrations.yml from per-spec api-config-*.json artifacts.",
7860
+ "Called by the foreman AFTER all parallel api-otter invocations complete (swp-3l9j).",
7861
+ "Reads .stackwright/artifacts/api-config-{name}.json for each spec, deduplicates by",
7862
+ "integration name (last-write-wins), preserves any non-integrations top-level keys in",
7863
+ "an existing stackwright.integrations.yml, and writes the merged result atomically.",
7864
+ "Returns { written, integrationCount, path } on success or { written: false, reason } if",
7865
+ "no per-spec artifacts are found."
7866
+ ].join(" "),
7867
+ {
7868
+ projectRoot: z24.string().describe("Absolute path to the project root directory")
7869
+ },
7870
+ async ({ projectRoot }) => {
7871
+ try {
7872
+ const result = handleConsolidateIntegrations({ projectRoot });
7873
+ return {
7874
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
7875
+ };
7876
+ } catch (err) {
7877
+ const message = err instanceof Error ? err.message : String(err);
7878
+ return {
7879
+ content: [
7880
+ {
7881
+ type: "text",
7882
+ text: JSON.stringify({ written: false, error: message })
7883
+ }
7884
+ ],
7885
+ isError: true
7886
+ };
7887
+ }
7888
+ }
7889
+ );
7890
+ }
7891
+
7758
7892
  // package.json
7759
7893
  var package_default = {
7760
7894
  dependencies: {
@@ -7767,7 +7901,7 @@ var package_default = {
7767
7901
  "@stackwright-pro/pulse": "workspace:*",
7768
7902
  "@stackwright-pro/telemetry": "workspace:*",
7769
7903
  "@stackwright-pro/types": "workspace:*",
7770
- "@stackwright/mcp": "0.6.0-alpha.1",
7904
+ "@stackwright/mcp": "0.6.0-alpha.2",
7771
7905
  "@types/js-yaml": "^4.0.9",
7772
7906
  "js-yaml": "^4.2.0",
7773
7907
  "proper-lockfile": "^4.1.2",
@@ -7789,7 +7923,7 @@ var package_default = {
7789
7923
  "test:coverage": "vitest run --coverage"
7790
7924
  },
7791
7925
  name: "@stackwright-pro/mcp",
7792
- version: "0.2.0-alpha.103",
7926
+ version: "0.2.0-alpha.104",
7793
7927
  description: "MCP tools for Stackwright Pro - Data Explorer, Security, ISR, and Dashboard generation",
7794
7928
  license: "SEE LICENSE IN LICENSE",
7795
7929
  main: "./dist/server.js",
@@ -7871,6 +8005,7 @@ registerCompileTools(server);
7871
8005
  registerStripLegacyIntegrationsTool(server);
7872
8006
  registerEmitterTools(server);
7873
8007
  registerListSpecsTool(server);
8008
+ registerConsolidateIntegrationsTool(server);
7874
8009
  registerContentTypeTools(server);
7875
8010
  registerPageTools(server);
7876
8011
  registerSiteTools(server);