-
Notifications
You must be signed in to change notification settings - Fork 42
Add dynamic tools to Available Toolsets #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7c96f50
add dynamic tools to Available Toolsets
yannbf ca1596f
fix: apply oxfmt formatting to dynamic-tools files
yannbf 3e0e4de
temp fix
yannbf d6f1729
Revert "temp fix"
yannbf abaf32b
address review feedback
yannbf e93b2f4
Merge branch 'main' into yann/update-available-toolsets
yannbf 2cb2c99
improve naming consistency
yannbf f0b2000
add tests
yannbf 1744cad
format
yannbf 902debf
update release note
yannbf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@storybook/addon-mcp": patch | ||
| --- | ||
|
|
||
| Surface the change-detection and review tools on the `/mcp` landing page. The "Available Toolsets" list now includes `get-stories-by-component`, `get-changed-stories`, and `display-review` under **dev** (each with an enabled/disabled badge reflecting its real runtime gate), and `get-documentation-for-story` under **docs**. The page and the MCP server now derive tool availability from a single shared helper (`getToolAvailability`) so the rendered badges can't drift from the tools that are actually registered. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import type { Options } from 'storybook/internal/types'; | ||
| import { isDependencyGraphSupported } from './change-detection.ts'; | ||
| import { getReviewStatus } from './is-review-available.ts'; | ||
| import { getManifestStatus } from '../tools/is-manifest-available.ts'; | ||
| import { getAddonVitestConstants } from '../tools/run-story-tests.ts'; | ||
| import { isAddonA11yEnabled } from './is-addon-a11y-enabled.ts'; | ||
|
|
||
| export interface ToolAvailability { | ||
| /** Dev-server builder supports the dependency-graph API. Gates `get-stories-by-component`. */ | ||
| dependencyGraphSupported: boolean; | ||
|
Comment on lines
+9
to
+10
|
||
| /** The `changeDetection` feature flag is enabled. Gates `get-changed-stories`. */ | ||
| changeDetectionEnabled: boolean; | ||
| /** `changeDetection` flag + `@storybook/addon-review` are both present. Gates `display-review`. */ | ||
| reviewAvailable: boolean; | ||
| /** Component-manifest feature is on AND manifests were found. Gates the `docs` toolset. */ | ||
| docsAvailable: boolean; | ||
| /** Any component manifests were found (drives the docs "why disabled" copy). */ | ||
| docsHasManifests: boolean; | ||
| /** The component-manifest feature flag is enabled (drives the docs "why disabled" copy). */ | ||
| docsFeatureEnabled: boolean; | ||
| /** `@storybook/addon-vitest` is installed. Gates the `test` toolset (`run-story-tests`). */ | ||
| testSupported: boolean; | ||
| /** `@storybook/addon-a11y` is enabled. Gates the accessibility sub-feature of `run-story-tests`. */ | ||
| a11yEnabled: boolean; | ||
| } | ||
|
|
||
| export interface GetToolAvailabilityOptions { | ||
| /** | ||
| * Pre-resolved `features` preset. Pass it to avoid re-applying the preset and | ||
| * risking a different snapshot than the caller already resolved. | ||
| */ | ||
| features?: { changeDetection?: boolean } | undefined; | ||
| } | ||
|
|
||
| /** | ||
| * Single source of truth for the runtime gates that decide whether each tool is | ||
| * registered (and how the landing page badges it). | ||
| * | ||
| * Every dynamic gate lives here — the dependency graph, the change-detection | ||
| * pipeline, review, the component manifest (docs), addon-vitest (test) and the | ||
| * accessibility sub-feature — so the MCP server (which registers the tools) and | ||
| * the browser landing page (which shows enabled/disabled badges) can never drift | ||
| * apart. Add new gates here rather than computing them ad-hoc at a call site. | ||
| */ | ||
| export async function getToolAvailability( | ||
|
yannbf marked this conversation as resolved.
|
||
| options: Options, | ||
| { features }: GetToolAvailabilityOptions = {}, | ||
| ): Promise<ToolAvailability> { | ||
| const resolvedFeatures = | ||
| features ?? | ||
| ((await options.presets.apply('features', {})) as { changeDetection?: boolean } | undefined); | ||
|
|
||
| const [ | ||
| dependencyGraphSupported, | ||
| reviewStatus, | ||
| manifestStatus, | ||
| addonVitestConstants, | ||
| a11yEnabled, | ||
| ] = await Promise.all([ | ||
| isDependencyGraphSupported(), | ||
| getReviewStatus(options, { features: resolvedFeatures }), | ||
| getManifestStatus(options), | ||
| getAddonVitestConstants(), | ||
| isAddonA11yEnabled(options), | ||
| ]); | ||
|
|
||
| return { | ||
| dependencyGraphSupported, | ||
| changeDetectionEnabled: resolvedFeatures?.changeDetection ?? false, | ||
| reviewAvailable: reviewStatus.available, | ||
| docsAvailable: manifestStatus.available, | ||
| docsHasManifests: manifestStatus.hasManifests, | ||
| docsFeatureEnabled: manifestStatus.hasFeatureFlag, | ||
| testSupported: !!addonVitestConstants, | ||
| a11yEnabled, | ||
| }; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.