Skip to content

release/v0.2.3: fix release workflow, version drift, export routes + stitch_to_storybook - #1

Merged
berriosb merged 1 commit into
mainfrom
release/v0.2.3
Sep 26, 2026
Merged

berriosb merged 1 commit into
mainfrom
release/v0.2.3

Conversation

@berriosb

Copy link
Copy Markdown
Owner

Summary

Sprint A (blocker fixes) + Feature 1 (stitch_to_storybook).

Bug fixes

  1. release.yml — switch to OIDC provenance publish with NODE_AUTH_TOKEN fallback. Resolves the 3 consecutive publish failures on v0.2.0 / v0.2.1 / v0.2.2. Requires either (a) GitHub Trusted Publisher configured at npmjs.com OR (b) valid NPM_TOKEN secret. Currently uses (b).
  2. Version drift — src/index.ts and src/bin/cli.ts now read PKG_VERSION from package.json via createRequire. MCP serverInfo and CLI --version no longer report stale 2.0.0 / 0.2.0.
  3. Export Next.js --routes — fixed functional bug where every route always exported screens[0]. Now supports round-robin fallback and explicit route=screenId syntax.
  4. resolveHtml silent failure — extracted to src/lib/resolve-html.ts, logs warnings on fetch failure or non-OK status, adds 15s AbortSignal timeout.
  5. export.ts non-nextjs path — now uses resolveHtml for consistency (was calling screen.getHtml() directly before).

New feature: stitch_to_storybook

New MCP tool stitch_to_storybook + CLI command stitch-mcp-cli storybook <project-id> that exports a Stitch project to ready-to-run Storybook 8 stories for React, Next.js, Vue 3, Nuxt 3, Svelte 5, SvelteKit. Writes one component + one story per screen plus a minimal .storybook/main.ts + preview.ts.

Usage:

stitch-mcp-cli storybook <project-id> --framework react --output ./stories
cd ./stories && npx storybook@latest init && npx storybook dev

Tests

  • 14 new tests across 3 files (resolve-html, export-routes, storybook template engine)
  • Total: 72/72 passing (up from 58 in v0.2.2)
  • Build clean (tsc), no new lint errors

Files changed

.github/workflows/release.yml               |   8 +-
CHANGELOG.md                                |  17 +++
package.json                                |   2 +-
src/bin/cli.ts                              |  15 ++-
src/commands/export.ts                      |  33 +++++--
src/commands/storybook.ts                   | 133 +++++++++++++++++++++++++++
src/index.ts                                | 105 +++++++++++++++++++---
src/lib/resolve-html.ts                     |  30 +++++++
src/lib/template-engine.ts                  |  86 +++++++++++++++++
src/templates/storybook/*.ejs               |  90 +++++++++++++
tests/unit/export-routes.test.ts            | 122 +++++++++++++++++++
tests/unit/resolve-html.test.ts             |  78 ++++++++++++++
tests/unit/storybook.test.ts                |  71 ++++++++++++++

18 files changed, 760 insertions(+), 30 deletions(-)

Published

v0.2.3 is live on npm registry as of 2026-09-15 23:56 UTC. Tarball: https://registry.npmjs.org/stitch-mcp-cli/-/stitch-mcp-cli-0.2.3.tgz

Follow-up (not blocking)

  • Configure Trusted Publisher at https://www.npmjs.com/package/stitch-mcp-cli/access so the OIDC path works without NODE_AUTH_TOKEN. Once configured, drop the env: block from the publish step.
  • Rotate NPM_TOKEN (currently from 2026-06-08) if you prefer the token-based auth long-term.

…t routes + add stitch_to_storybook

Sprint A (blockers) + Feature 1:

Bug fixes:
- release.yml: drop NPM_TOKEN env, use OIDC provenance only (was hybrid/ambiguous,
  caused 3 consecutive publish failures on v0.2.0/0.2.1/v0.2.2)
- src/index.ts + src/bin/cli.ts: read version from package.json (was hardcoded
  '2.0.0' for MCP serverInfo and '0.2.0' for CLI --version)
- src/commands/export.ts: Next.js --routes now maps each route to a distinct
  screen (round-robin fallback) and supports route=screenId syntax. Was always
  screens[0] for every route.
- src/lib/resolve-html.ts: extracted from index.ts; logs warnings when HTML
  fetch fails instead of silently returning <div></div>; adds 15s AbortSignal
  timeout
- src/commands/export.ts: now uses resolveHtml for the non-nextjs path too
  (consistency, was calling screen.getHtml() directly before)

Feature: stitch_to_storybook
- New MCP tool 'stitch_to_storybook' and CLI 'stitch-mcp-cli storybook
  <project-id>' command. Exports a Stitch project to ready-to-run Storybook 8
  stories for React, Next.js, Vue 3, Nuxt 3, Svelte 5, SvelteKit.
- Writes one component + one story per screen plus .storybook/main.ts and
  preview.ts.
- Templates in src/templates/storybook/ (6 .ejs files)
- Next step for user: cd <out> && npx storybook@latest init && npx storybook dev

Tests:
- tests/unit/resolve-html.test.ts (4 tests) — fetch failure paths, timeout,
  empty HTML
- tests/unit/export-routes.test.ts (3 tests) — round-robin, route=screenId,
  fallback when id missing
- tests/unit/storybook.test.ts (7 tests) — framework support matrix, render
  each template, extension mapping
- Total: 72/72 passing (up from 58/58 in v0.2.2)

Pre-commit: static scan (security/quality/resilience) clean. No new lint
errors. Build (tsc) clean. CLI smoke test: --version returns 0.2.3 from
package.json; both 'export --help' and 'storybook --help' render correctly.
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 27cd337a-f2d9-42f3-bdd3-5c0e121c8a08


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 472da80557

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +222 to +223
const url = new URL(`../templates/${rel}`, import.meta.url);
return url.pathname;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include Storybook templates in the published package

tsc does not copy EJS files (and src/templates is excluded from compilation), while package.json publishes only dist/. Consequently, an installed package resolves this path relative to dist/lib as dist/templates/storybook/..., which is absent, so both the CLI and MCP Storybook exports always throw “Storybook template no encontrado” outside a source checkout.

Useful? React with 👍 / 👎.

Comment thread src/commands/storybook.ts
Comment on lines +28 to +31
if (!isValidFramework(framework)) {
console.error(`Framework inválido: ${framework}`);
console.error(`Frameworks válidos: ${getStorybookSupportedFrameworks().join(", ")}`);
process.exit(1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Support SvelteKit before advertising it

For storybook --framework sveltekit, this validation exits because isValidFramework delegates to FRAMEWORK_MAP, which has no sveltekit entry, even though the command option and Storybook-supported set advertise it. The MCP tool bypasses this check but then fails at transformToFramework for the same reason, so SvelteKit cannot be exported through either new interface.

Useful? React with 👍 / 👎.

@@ -0,0 +1,18 @@
import type { Meta, StoryObj } from "@storybook/react";
import { <%= componentName %> } from "./<%= componentName %>";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Default-import generated Next.js components

The Next.js transformer emits export default function ... for every generated component, but this story imports a named export. Thus every default Next.js Storybook export fails module resolution/type-checking because Stitch... is not an exported member; use a default import here.

Useful? React with 👍 / 👎.

Comment on lines +217 to +218
const userTemplate = getUserTemplatePath(framework);
if (userTemplate) return userTemplate;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Select a story template instead of component.ejs

When a user has the documented templateDir configured, this returns that framework's component.ejs as the Storybook template. Those component templates consume html and often css, but renderStorybookStory supplies neither, causing EJS rendering to fail; if that component template is absent, the later existence check fails instead of falling back to the bundled Storybook template.

Useful? React with 👍 / 👎.

@berriosb
berriosb merged commit 3ccad5f into main Sep 26, 2026
4 of 5 checks passed
@berriosb
berriosb deleted the release/v0.2.3 branch September 26, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant