@storybook/addon-mcp 11.0.0-alpha.4 → 11.0.0-alpha.5
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/preset.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_9i6bzfq81k6 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_9i6bzfq81k6 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_9i6bzfq81k6 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_9i6bzfq81k6.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_9i6bzfq81k6.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_9i6bzfq81k6.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -18,7 +18,7 @@ import { HttpTransport } from "@tmcp/transport-http";
|
|
|
18
18
|
// package.json
|
|
19
19
|
var package_default = {
|
|
20
20
|
name: "@storybook/addon-mcp",
|
|
21
|
-
version: "11.0.0-alpha.
|
|
21
|
+
version: "11.0.0-alpha.5",
|
|
22
22
|
description: "Help agents automatically write and test stories for your UI components",
|
|
23
23
|
keywords: [
|
|
24
24
|
"ai",
|
|
@@ -111,9 +111,7 @@ async function collectTelemetry({
|
|
|
111
111
|
mcpSessionId: server.ctx.sessionId,
|
|
112
112
|
clientInfo: server.ctx.sessionInfo?.clientInfo,
|
|
113
113
|
clientCapabilities: server.ctx.sessionInfo?.clientCapabilities,
|
|
114
|
-
|
|
115
|
-
// header; everything else is a direct MCP client.
|
|
116
|
-
transport: server.ctx.custom?.cliClient ? "cli" : "mcp",
|
|
114
|
+
transport: "mcp",
|
|
117
115
|
...payload
|
|
118
116
|
});
|
|
119
117
|
} catch (error) {
|
|
@@ -127,7 +125,7 @@ import { getEffectiveToolAvailability, getToolAvailability } from "storybook/int
|
|
|
127
125
|
import { buildServerInstructions } from "storybook/internal/skills";
|
|
128
126
|
|
|
129
127
|
// src/constants.ts
|
|
130
|
-
var
|
|
128
|
+
var DEFAULT_MCP_ENDPOINT = "/mcp";
|
|
131
129
|
|
|
132
130
|
// src/tools/tool-registry.ts
|
|
133
131
|
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
@@ -279,8 +277,6 @@ async function buildStorybookStoryInstructions(options, {
|
|
|
279
277
|
transport: "mcp",
|
|
280
278
|
framework: inputs.framework,
|
|
281
279
|
renderer: inputs.renderer,
|
|
282
|
-
changeDetectionEnabled: inputs.changeDetectionEnabled,
|
|
283
|
-
reviewEnabled: inputs.reviewEnabled,
|
|
284
280
|
testSupported: (toolsets?.test ?? !0) && (addonVitestAvailable ?? inputs.testSupported),
|
|
285
281
|
a11yEnabled: a11yEnabled2 ?? inputs.a11yEnabled,
|
|
286
282
|
docsEnabled: (toolsets?.docs ?? !0) && (docsEnabled ?? inputs.docsEnabled)
|
|
@@ -512,7 +508,8 @@ function registerToolsetTool(server, options, enabled) {
|
|
|
512
508
|
}
|
|
513
509
|
|
|
514
510
|
// src/tools/tool-registry.ts
|
|
515
|
-
var isToolsetEnabled = (toolset, toolsets) => toolsets?.[toolset] ?? !0, isToolAvailable = (definition, context) => definition.available?.(context) ?? !0
|
|
511
|
+
var isToolsetEnabled = (toolset, toolsets) => toolsets?.[toolset] ?? !0, isToolAvailable = (definition, context) => definition.available?.(context) ?? !0;
|
|
512
|
+
var createToolsetEnabled = (server, toolset) => () => server.ctx.custom?.toolsets?.[toolset] ?? !0;
|
|
516
513
|
function fromToolset(definition) {
|
|
517
514
|
let { options, available, ...rest } = definition;
|
|
518
515
|
return {
|
|
@@ -588,19 +585,10 @@ var docsToolDefinitions = [
|
|
|
588
585
|
register: (server, { availability, toolsets }, enabled) => addGetUIBuildingInstructionsTool(server, enabled, {
|
|
589
586
|
docsEnabled: isToolsetEnabled("docs", toolsets) && availability.docsEnabled,
|
|
590
587
|
addonVitestAvailable: availability.testSupported
|
|
591
|
-
}),
|
|
592
|
-
getLocalTool: ({ availability, toolsets, options }) => ({
|
|
593
|
-
call: async () => ({ content: [{ type: "text", text: await buildStorybookStoryInstructions(options, {
|
|
594
|
-
toolsets,
|
|
595
|
-
a11yEnabled: availability.a11yEnabled,
|
|
596
|
-
addonVitestAvailable: availability.testSupported,
|
|
597
|
-
docsEnabled: isToolsetEnabled("docs", toolsets) && availability.docsEnabled
|
|
598
|
-
}) }] })
|
|
599
588
|
})
|
|
600
589
|
},
|
|
601
590
|
fromToolset({
|
|
602
591
|
toolset: "dev",
|
|
603
|
-
available: ({ availability }) => availability.changeDetectionEnabled,
|
|
604
592
|
options: { method: "stories.changed", mcpEventName: "tool:getChangedStories" }
|
|
605
593
|
}),
|
|
606
594
|
fromToolset({
|
|
@@ -610,7 +598,6 @@ var docsToolDefinitions = [
|
|
|
610
598
|
}),
|
|
611
599
|
fromToolset({
|
|
612
600
|
toolset: "dev",
|
|
613
|
-
available: ({ availability }) => availability.reviewEnabled,
|
|
614
601
|
options: {
|
|
615
602
|
method: "review.create",
|
|
616
603
|
mcpEventName: "tool:displayReview",
|
|
@@ -631,33 +618,6 @@ function dropToolIfToolsetMissing(name, error) {
|
|
|
631
618
|
throw error;
|
|
632
619
|
logger3.error(`Skipping MCP tool "${name}", its backing toolset is not registered: ${error}`);
|
|
633
620
|
}
|
|
634
|
-
function resolveDefinitionOrDrop(name, resolve) {
|
|
635
|
-
try {
|
|
636
|
-
return resolve();
|
|
637
|
-
} catch (error) {
|
|
638
|
-
return dropToolIfToolsetMissing(name, error);
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
function getAddonToolMetadata(context) {
|
|
642
|
-
return addonToolDefinitions.filter((definition) => isMetadataToolEnabled(definition, context)).flatMap((definition) => {
|
|
643
|
-
let metadata = resolveDefinitionOrDrop(
|
|
644
|
-
definition.name,
|
|
645
|
-
() => definition.getMetadata(context)
|
|
646
|
-
);
|
|
647
|
-
return metadata ? [metadata] : [];
|
|
648
|
-
});
|
|
649
|
-
}
|
|
650
|
-
function getAddonLocalTools(context) {
|
|
651
|
-
return Object.fromEntries(
|
|
652
|
-
addonToolDefinitions.filter((definition) => isMetadataToolEnabled(definition, context)).flatMap((definition) => {
|
|
653
|
-
let localTool = resolveDefinitionOrDrop(
|
|
654
|
-
definition.name,
|
|
655
|
-
() => definition.getLocalTool?.(context)
|
|
656
|
-
);
|
|
657
|
-
return localTool ? [[definition.name, localTool]] : [];
|
|
658
|
-
})
|
|
659
|
-
);
|
|
660
|
-
}
|
|
661
621
|
async function registerAddonMcpTools(server, context) {
|
|
662
622
|
isToolsetEnabled("dev", context.toolsets) && await addPreviewStoriesResource(server);
|
|
663
623
|
for (let definition of addonToolDefinitions)
|
|
@@ -675,9 +635,8 @@ async function registerAddonMcpTools(server, context) {
|
|
|
675
635
|
|
|
676
636
|
// src/mcp-handler.ts
|
|
677
637
|
var transport, origin, initialize, disableTelemetry, a11yEnabled, initializeMCPServer = async (options, multiSource) => {
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
let rawAvailability = await getToolAvailability(options, { features: features2 }), availability = getEffectiveToolAvailability(rawAvailability, { multiSource });
|
|
638
|
+
disableTelemetry = (await options.presets.apply("core", {}))?.disableTelemetry ?? !1;
|
|
639
|
+
let rawAvailability = await getToolAvailability(options), availability = getEffectiveToolAvailability(rawAvailability, { multiSource });
|
|
681
640
|
a11yEnabled = availability.a11yEnabled;
|
|
682
641
|
let server, serverOptions = {
|
|
683
642
|
adapter: new ValibotJsonSchemaAdapter(),
|
|
@@ -687,9 +646,7 @@ var transport, origin, initialize, disableTelemetry, a11yEnabled, initializeMCPS
|
|
|
687
646
|
devEnabled: server?.ctx.custom?.toolsets?.dev ?? !0,
|
|
688
647
|
testSupported: (server?.ctx.custom?.toolsets?.test ?? !0) && availability.testSupported,
|
|
689
648
|
docsEnabled: (server?.ctx.custom?.toolsets?.docs ?? !0) && availability.docsEnabled,
|
|
690
|
-
|
|
691
|
-
moduleGraphSupported: availability.moduleGraphSupported,
|
|
692
|
-
reviewEnabled: availability.reviewEnabled
|
|
649
|
+
moduleGraphSupported: availability.moduleGraphSupported
|
|
693
650
|
});
|
|
694
651
|
},
|
|
695
652
|
capabilities: {
|
|
@@ -726,7 +683,6 @@ var transport, origin, initialize, disableTelemetry, a11yEnabled, initializeMCPS
|
|
|
726
683
|
options,
|
|
727
684
|
endpoint,
|
|
728
685
|
toolsets: getToolsets(webRequest, addonOptions),
|
|
729
|
-
cliClient: webRequest.headers.get(STORYBOOK_MCP_PROXY_HEADER) === "true",
|
|
730
686
|
origin,
|
|
731
687
|
disableTelemetry,
|
|
732
688
|
a11yEnabled,
|
|
@@ -819,11 +775,11 @@ var isLiteralEndpointPathname = (endpoint) => {
|
|
|
819
775
|
});
|
|
820
776
|
|
|
821
777
|
// src/preset.ts
|
|
822
|
-
import * as
|
|
778
|
+
import * as v3 from "valibot";
|
|
823
779
|
import {
|
|
824
780
|
createLocalDocsAccess,
|
|
825
|
-
getEffectiveToolAvailability as
|
|
826
|
-
getToolAvailability as
|
|
781
|
+
getEffectiveToolAvailability as getEffectiveToolAvailability2,
|
|
782
|
+
getToolAvailability as getToolAvailability2,
|
|
827
783
|
loadManifests
|
|
828
784
|
} from "storybook/internal/core-server";
|
|
829
785
|
|
|
@@ -1033,22 +989,14 @@ var template_default = `<!doctype html>
|
|
|
1033
989
|
<ul class="toolset-tools">
|
|
1034
990
|
<li><code>stories-preview</code></li>
|
|
1035
991
|
<li><code>get-storybook-story-instructions</code></li>
|
|
1036
|
-
<li>
|
|
1037
|
-
<code>stories-changed</code>
|
|
1038
|
-
<span class="toolset-status {{CHANGE_DETECTION_STATUS}}"
|
|
1039
|
-
>{{CHANGE_DETECTION_STATUS}}</span
|
|
1040
|
-
>
|
|
1041
|
-
</li>
|
|
992
|
+
<li><code>stories-changed</code></li>
|
|
1042
993
|
<li>
|
|
1043
994
|
<code>stories-find-by-component</code>
|
|
1044
995
|
<span class="toolset-status {{STORIES_BY_COMPONENT_STATUS}}"
|
|
1045
996
|
>{{STORIES_BY_COMPONENT_STATUS}}</span
|
|
1046
997
|
>
|
|
1047
998
|
</li>
|
|
1048
|
-
<li>
|
|
1049
|
-
<code>review-create</code>
|
|
1050
|
-
<span class="toolset-status {{REVIEW_STATUS}}">{{REVIEW_STATUS}}</span>
|
|
1051
|
-
</li>
|
|
999
|
+
<li><code>review-create</code></li>
|
|
1052
1000
|
</ul>
|
|
1053
1001
|
{{DEV_NOTICE}}
|
|
1054
1002
|
</div>
|
|
@@ -1187,7 +1135,7 @@ var OAuthResourceMetadata = v2.object({
|
|
|
1187
1135
|
* Create a manifest provider for multi-source mode.
|
|
1188
1136
|
*
|
|
1189
1137
|
* Remote sources are fetched over HTTP with auth and caching; the local source fetches from
|
|
1190
|
-
* `localOrigin`. In `
|
|
1138
|
+
* `localOrigin`. In `docgenServer` mode core 404s the local `/manifests/*.json`, and
|
|
1191
1139
|
* the composition reads that source through its own access instead of this provider.
|
|
1192
1140
|
*/
|
|
1193
1141
|
createManifestProvider(localOrigin) {
|
|
@@ -1319,9 +1267,6 @@ function extractBearerToken(authHeader) {
|
|
|
1319
1267
|
|
|
1320
1268
|
// src/auth/resolve-composition-sources.ts
|
|
1321
1269
|
import { getRefsFromConfig } from "storybook/internal/core-server";
|
|
1322
|
-
import { ComponentManifestMap as ComponentManifestMap2 } from "storybook/internal/toolsets-docs";
|
|
1323
|
-
import * as v3 from "valibot";
|
|
1324
|
-
var MANIFEST_PROBE_TIMEOUT_MS = 3e3;
|
|
1325
1270
|
async function resolveCompositionSources(options) {
|
|
1326
1271
|
let refs = await getRefsFromConfig(options), compositionAuth = new CompositionAuth();
|
|
1327
1272
|
if (refs.length === 0)
|
|
@@ -1335,127 +1280,10 @@ async function resolveCompositionSources(options) {
|
|
|
1335
1280
|
multiSource: sources.some((source) => !!source.url)
|
|
1336
1281
|
};
|
|
1337
1282
|
}
|
|
1338
|
-
async function resolveServerlessCompositionSources(options) {
|
|
1339
|
-
let refs = await getRefsFromConfig(options), refsWithManifests = await Promise.all(
|
|
1340
|
-
refs.map(
|
|
1341
|
-
async (ref) => await hasServerlessComponentManifestSource(ref.url) ? ref : void 0
|
|
1342
|
-
)
|
|
1343
|
-
), sources = [
|
|
1344
|
-
{ id: "local", title: "Local" },
|
|
1345
|
-
...refsWithManifests.filter((ref) => !!ref).map((ref) => ({
|
|
1346
|
-
id: ref.id,
|
|
1347
|
-
title: ref.title,
|
|
1348
|
-
url: ref.url
|
|
1349
|
-
}))
|
|
1350
|
-
];
|
|
1351
|
-
return {
|
|
1352
|
-
refs,
|
|
1353
|
-
sources,
|
|
1354
|
-
multiSource: sources.some((source) => !!source.url)
|
|
1355
|
-
};
|
|
1356
|
-
}
|
|
1357
|
-
async function hasServerlessComponentManifestSource(refUrl) {
|
|
1358
|
-
let controller = new AbortController(), timeout = setTimeout(() => controller.abort(), MANIFEST_PROBE_TIMEOUT_MS);
|
|
1359
|
-
try {
|
|
1360
|
-
let response = await fetch(
|
|
1361
|
-
new URL("manifests/components.json", `${refUrl.replace(/\/$/, "")}/`),
|
|
1362
|
-
{
|
|
1363
|
-
headers: { Accept: "application/json" },
|
|
1364
|
-
signal: controller.signal
|
|
1365
|
-
}
|
|
1366
|
-
);
|
|
1367
|
-
if (response.status === 401 && hasOAuthResourceMetadataChallenge(response))
|
|
1368
|
-
return !0;
|
|
1369
|
-
if (!response.ok)
|
|
1370
|
-
return !1;
|
|
1371
|
-
let text = await response.text();
|
|
1372
|
-
return v3.safeParse(v3.pipe(v3.string(), v3.parseJson(), ComponentManifestMap2), text).success;
|
|
1373
|
-
} catch {
|
|
1374
|
-
return !1;
|
|
1375
|
-
} finally {
|
|
1376
|
-
clearTimeout(timeout);
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
function hasOAuthResourceMetadataChallenge(response) {
|
|
1380
|
-
return /resource_metadata="[^"]+"/.test(response.headers.get("WWW-Authenticate") ?? "");
|
|
1381
|
-
}
|
|
1382
1283
|
|
|
1383
1284
|
// src/preset.ts
|
|
1384
1285
|
import { logger as logger7 } from "storybook/internal/node-logger";
|
|
1385
1286
|
|
|
1386
|
-
// src/storybook-ai-metadata.ts
|
|
1387
|
-
import { ValibotJsonSchemaAdapter as ValibotJsonSchemaAdapter2 } from "@tmcp/adapter-valibot";
|
|
1388
|
-
import * as v4 from "valibot";
|
|
1389
|
-
import {
|
|
1390
|
-
getEffectiveToolAvailability as getEffectiveToolAvailability2,
|
|
1391
|
-
getToolAvailability as getToolAvailability2,
|
|
1392
|
-
isModuleGraphSupportedByBuilder
|
|
1393
|
-
} from "storybook/internal/core-server";
|
|
1394
|
-
import { buildServerInstructions as buildServerInstructions2 } from "storybook/internal/skills";
|
|
1395
|
-
var createEmptyInputSchema = () => ({ type: "object", properties: {} });
|
|
1396
|
-
async function buildStorybookAiMetadata(options, existingMetadata) {
|
|
1397
|
-
let toolsets = v4.parse(AddonOptions, {
|
|
1398
|
-
endpoint: options.endpoint,
|
|
1399
|
-
toolsets: options.toolsets ?? {}
|
|
1400
|
-
}).toolsets, features2 = await options.presets.apply("features", {}), devEnabled = toolsets?.dev ?? !0, moduleGraphSupported = await isModuleGraphSupportedByBuilder(options), availability = await getToolAvailability2(options, {
|
|
1401
|
-
features: features2,
|
|
1402
|
-
moduleGraphSupported
|
|
1403
|
-
}), testSupported = (toolsets?.test ?? !0) && availability.testSupported, docsToolsetEnabled = toolsets?.docs ?? !0, multiSource = docsToolsetEnabled ? (await resolveServerlessCompositionSources(options)).multiSource : !1, registryAvailability = getEffectiveToolAvailability2(availability, { multiSource }), docsEnabled = docsToolsetEnabled && registryAvailability.docsEnabled, registryContext = { availability: registryAvailability, multiSource, toolsets }, toolMetadata = getAddonToolMetadata(registryContext), localTools = {
|
|
1404
|
-
...existingMetadata?.localTools,
|
|
1405
|
-
...getAddonLocalTools({ ...registryContext, options })
|
|
1406
|
-
};
|
|
1407
|
-
return {
|
|
1408
|
-
instructions: joinInstructions(
|
|
1409
|
-
existingMetadata?.instructions,
|
|
1410
|
-
buildServerInstructions2({
|
|
1411
|
-
transport: "mcp",
|
|
1412
|
-
devEnabled,
|
|
1413
|
-
testSupported,
|
|
1414
|
-
docsEnabled,
|
|
1415
|
-
changeDetectionEnabled: availability.changeDetectionEnabled,
|
|
1416
|
-
moduleGraphSupported: availability.moduleGraphSupported,
|
|
1417
|
-
reviewEnabled: availability.reviewEnabled
|
|
1418
|
-
})
|
|
1419
|
-
),
|
|
1420
|
-
tools: mergeToolDescriptors(
|
|
1421
|
-
existingMetadata?.tools ?? [],
|
|
1422
|
-
await toToolDescriptors(toolMetadata)
|
|
1423
|
-
),
|
|
1424
|
-
localTools
|
|
1425
|
-
};
|
|
1426
|
-
}
|
|
1427
|
-
async function toToolDescriptors(toolMetadata) {
|
|
1428
|
-
let adapter = new ValibotJsonSchemaAdapter2();
|
|
1429
|
-
return Promise.all(
|
|
1430
|
-
toolMetadata.map(async ({ schema, outputSchema, ...metadata }) => ({
|
|
1431
|
-
...metadata,
|
|
1432
|
-
inputSchema: schema ? await toJsonSchema(adapter, schema) : createEmptyInputSchema(),
|
|
1433
|
-
...outputSchema ? { outputSchema: await toJsonSchema(adapter, outputSchema) } : {}
|
|
1434
|
-
}))
|
|
1435
|
-
);
|
|
1436
|
-
}
|
|
1437
|
-
async function toJsonSchema(adapter, schema) {
|
|
1438
|
-
return await adapter.toJsonSchema(
|
|
1439
|
-
schema
|
|
1440
|
-
);
|
|
1441
|
-
}
|
|
1442
|
-
function joinInstructions(...sections) {
|
|
1443
|
-
let uniqueSections = [], seen = /* @__PURE__ */ new Set();
|
|
1444
|
-
for (let section of sections) {
|
|
1445
|
-
let trimmed = section?.trim();
|
|
1446
|
-
trimmed && !seen.has(trimmed) && (seen.add(trimmed), uniqueSections.push(trimmed));
|
|
1447
|
-
}
|
|
1448
|
-
return uniqueSections.join(`
|
|
1449
|
-
|
|
1450
|
-
`);
|
|
1451
|
-
}
|
|
1452
|
-
function mergeToolDescriptors(...groups) {
|
|
1453
|
-
let toolsByName = /* @__PURE__ */ new Map();
|
|
1454
|
-
for (let tool of groups.flat())
|
|
1455
|
-
toolsByName.has(tool.name) && toolsByName.delete(tool.name), toolsByName.set(tool.name, tool);
|
|
1456
|
-
return [...toolsByName.values()];
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
1287
|
// src/utils/get-story-index.ts
|
|
1460
1288
|
import { logger as logger6 } from "storybook/internal/node-logger";
|
|
1461
1289
|
async function getStoryIndex(options) {
|
|
@@ -1472,10 +1300,10 @@ async function getStoryIndex(options) {
|
|
|
1472
1300
|
|
|
1473
1301
|
// src/preset.ts
|
|
1474
1302
|
var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotations, path.join(import.meta.dirname, "preview.js")], experimental_devServer = async (app, options) => {
|
|
1475
|
-
let addonOptions =
|
|
1303
|
+
let addonOptions = v3.parse(AddonOptions, {
|
|
1476
1304
|
endpoint: options.endpoint,
|
|
1477
1305
|
toolsets: options.toolsets ?? {}
|
|
1478
|
-
}), origin2 = `http://localhost:${options.port}`, endpoint = addonOptions.endpoint ?? DEFAULT_MCP_ENDPOINT, { refs, compositionAuth, sources, multiSource } = await resolveCompositionSources(options), rawAvailability = await
|
|
1306
|
+
}), origin2 = `http://localhost:${options.port}`, endpoint = addonOptions.endpoint ?? DEFAULT_MCP_ENDPOINT, { refs, compositionAuth, sources, multiSource } = await resolveCompositionSources(options), rawAvailability = await getToolAvailability2(options), localAccess = rawAvailability.docgenServer && refs.length > 0 ? createLocalDocsAccess({
|
|
1479
1307
|
storyIndex: { getIndex: () => getStoryIndex(options) },
|
|
1480
1308
|
getManifests: () => loadManifests(options.presets)
|
|
1481
1309
|
}) : void 0, createManifestProvider;
|
|
@@ -1514,14 +1342,12 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1514
1342
|
});
|
|
1515
1343
|
let {
|
|
1516
1344
|
moduleGraphSupported,
|
|
1517
|
-
changeDetectionEnabled,
|
|
1518
|
-
reviewEnabled,
|
|
1519
1345
|
docsEnabled,
|
|
1520
1346
|
docsHasManifests,
|
|
1521
1347
|
docsFeatureEnabled,
|
|
1522
1348
|
testSupported,
|
|
1523
1349
|
a11yEnabled: a11yEnabled2
|
|
1524
|
-
} =
|
|
1350
|
+
} = getEffectiveToolAvailability2(rawAvailability, { multiSource }), isDevEnabled = addonOptions.toolsets?.dev ?? !0, isDocsEnabled = docsEnabled && (addonOptions.toolsets?.docs ?? !0), isTestEnabled = testSupported && (addonOptions.toolsets?.test ?? !0);
|
|
1525
1351
|
return app.get(endpoint, (req, res) => {
|
|
1526
1352
|
if (!req.headers.accept?.includes("text/html"))
|
|
1527
1353
|
return requireAuth(req, res) ? void 0 : mcpServerHandler({
|
|
@@ -1540,34 +1366,32 @@ var previewAnnotations = async (existingAnnotations = []) => [...existingAnnotat
|
|
|
1540
1366
|
This toolset requires enabling the component manifest feature.
|
|
1541
1367
|
<a target="_blank" href="https://github.com/storybookjs/storybook/tree/next/code/addons/mcp">Learn how to enable it</a>
|
|
1542
1368
|
</div>`) : docsNotice = docsFeatureEnabled ? `<div class="toolset-notice">
|
|
1543
|
-
This toolset requires a components manifest, which your framework does not generate. On <code>@storybook/vue3-vite</code>, also enable <code>
|
|
1369
|
+
This toolset requires a components manifest, which your framework does not generate. On <code>@storybook/vue3-vite</code>, also enable <code>docgenServer</code>.
|
|
1544
1370
|
<a target="_blank" href="https://storybook.js.org/docs/ai/mcp/overview#framework-support">See which frameworks are supported</a>
|
|
1545
1371
|
</div>` : `<div class="toolset-notice">
|
|
1546
|
-
This toolset requires a components manifest, which is generated by the React frameworks, <code>@storybook/angular-vite</code> and <code>@storybook/vue3-vite</code>. Enable the <code>componentsManifest</code> feature, plus <code>
|
|
1372
|
+
This toolset requires a components manifest, which is generated by the React frameworks, <code>@storybook/angular-vite</code> and <code>@storybook/vue3-vite</code>. Enable the <code>componentsManifest</code> feature, plus <code>docgenServer</code> on <code>@storybook/vue3-vite</code>.
|
|
1547
1373
|
<a target="_blank" href="https://storybook.js.org/docs/ai/mcp/overview#framework-support">Learn how to enable it</a>
|
|
1548
1374
|
</div>`;
|
|
1549
1375
|
let testNoticeLines = [
|
|
1550
1376
|
!testSupported && 'This toolset requires Storybook 10.3.0+ with <code>@storybook/addon-vitest</code>. <a target="_blank" href="https://storybook.js.org/docs/writing-tests/integrations/vitest-addon#install-and-set-up">Learn how to set it up</a>',
|
|
1551
1377
|
!a11yEnabled2 && 'Add <code>@storybook/addon-a11y</code> for accessibility testing. <a target="_blank" href="https://storybook.js.org/docs/writing-tests/accessibility-testing">Learn more</a>'
|
|
1552
1378
|
].filter(Boolean), testNotice = testNoticeLines.length ? `<div class="toolset-notice">${testNoticeLines.join("<br>")}</div>` : "", a11yBadge = a11yEnabled2 ? ' <span class="toolset-status enabled">+ accessibility</span>' : "", devNoticeLines = isDevEnabled ? [
|
|
1553
|
-
!moduleGraphSupported && "<code>stories-find-by-component</code> requires a dev server with a builder that supports the module graph (Vite or Webpack 5)."
|
|
1554
|
-
|
|
1555
|
-
].filter(Boolean) : ["The <code>dev</code> toolset is disabled via addon options."], devNotice = devNoticeLines.length ? `<div class="toolset-notice">${devNoticeLines.join("<br>")}</div>` : "", statusWord = (enabled) => enabled ? "enabled" : "disabled", html = template_default.replaceAll("{{DEV_STATUS}}", isDevEnabled ? "enabled" : "disabled").replaceAll(
|
|
1379
|
+
!moduleGraphSupported && "<code>stories-find-by-component</code> requires a dev server with a builder that supports the module graph (Vite or Webpack 5)."
|
|
1380
|
+
].filter(Boolean) : ["The <code>dev</code> toolset is disabled via addon options."], devNotice = devNoticeLines.length ? `<div class="toolset-notice">${devNoticeLines.join("<br>")}</div>` : "", html = template_default.replaceAll("{{DEV_STATUS}}", isDevEnabled ? "enabled" : "disabled").replaceAll(
|
|
1556
1381
|
"{{STORIES_BY_COMPONENT_STATUS}}",
|
|
1557
|
-
|
|
1558
|
-
).
|
|
1382
|
+
isDevEnabled && moduleGraphSupported ? "enabled" : "disabled"
|
|
1383
|
+
).replace("{{DEV_NOTICE}}", devNotice).replaceAll("{{DOCS_STATUS}}", isDocsEnabled ? "enabled" : "disabled").replace("{{DOCS_NOTICE}}", docsNotice).replaceAll("{{TEST_STATUS}}", isTestEnabled ? "enabled" : "disabled").replace("{{TEST_NOTICE}}", testNotice).replace(
|
|
1559
1384
|
"{{MANIFEST_DEBUGGER_LINK}}",
|
|
1560
1385
|
rawAvailability.docsEnabled ? '<p>View the <a href="/manifests/components.html">component manifest debugger</a>.</p>' : ""
|
|
1561
1386
|
).replace("{{A11Y_BADGE}}", a11yBadge);
|
|
1562
1387
|
res.end(html);
|
|
1563
1388
|
}), app;
|
|
1564
|
-
},
|
|
1389
|
+
}, features = async (existingFeatures) => ({
|
|
1565
1390
|
...existingFeatures,
|
|
1566
1391
|
componentsManifest: !0
|
|
1567
1392
|
});
|
|
1568
1393
|
export {
|
|
1569
1394
|
experimental_devServer,
|
|
1570
|
-
experimental_storybookAi,
|
|
1571
1395
|
features,
|
|
1572
1396
|
previewAnnotations
|
|
1573
1397
|
};
|
|
@@ -4,7 +4,7 @@ var MCP_APP_PARAM = "mcp-app", MCP_APP_SIZE_CHANGED_EVENT = "storybook-mcp:size-
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "@storybook/addon-mcp",
|
|
7
|
-
version: "11.0.0-alpha.
|
|
7
|
+
version: "11.0.0-alpha.5",
|
|
8
8
|
description: "Help agents automatically write and test stories for your UI components",
|
|
9
9
|
keywords: [
|
|
10
10
|
"ai",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-mcp",
|
|
3
|
-
"version": "11.0.0-alpha.
|
|
3
|
+
"version": "11.0.0-alpha.5",
|
|
4
4
|
"description": "Help agents automatically write and test stories for your UI components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"valibot": "^1.4.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@storybook/addon-a11y": "11.0.0-alpha.
|
|
46
|
-
"@storybook/addon-vitest": "11.0.0-alpha.
|
|
47
|
-
"storybook": "11.0.0-alpha.
|
|
45
|
+
"@storybook/addon-a11y": "11.0.0-alpha.5",
|
|
46
|
+
"@storybook/addon-vitest": "11.0.0-alpha.5",
|
|
47
|
+
"storybook": "11.0.0-alpha.5",
|
|
48
48
|
"typescript": "^6.0.3"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@storybook/addon-vitest": "^11.0.0-alpha.
|
|
52
|
-
"storybook": "^11.0.0-alpha.
|
|
51
|
+
"@storybook/addon-vitest": "^11.0.0-alpha.5",
|
|
52
|
+
"storybook": "^11.0.0-alpha.5"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@storybook/addon-vitest": {
|