Skip to content

fix(ai-code-mode-skills): make root export Worker/browser-safe (#486)#736

Open
tombeckenham wants to merge 2 commits into
mainfrom
486-root-export-is-not-workerbrowser-safe-because-it-eagerly-imports-node-only-file-storage
Open

fix(ai-code-mode-skills): make root export Worker/browser-safe (#486)#736
tombeckenham wants to merge 2 commits into
mainfrom
486-root-export-is-not-workerbrowser-safe-because-it-eagerly-imports-node-only-file-storage

Conversation

@tombeckenham

@tombeckenham tombeckenham commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🎯 Changes

Fixes #486. The @tanstack/ai-code-mode-skills root export was not Worker/browser-safe: it re-exported createFileSkillStorage via export * from './storage', which eagerly imports node:fs / node:path. Cloudflare Workers and browser bundlers failed at build time even for consumers that only used non-storage helpers like createSkillManagementTools or createSkillsSystemPrompt.

  • src/index.ts — root entry no longer re-exports the whole ./storage barrel. It re-exports only the browser-safe createMemorySkillStorage (+ MemorySkillStorageOptions). The Skill / SkillStorage / SkillIndexEntry types are unaffected (still exported via the existing ./types block).
  • The Node-only createFileSkillStorage is now available only from @tanstack/ai-code-mode-skills/storage.
  • Updated README, docs (code-mode-with-skills.md), and the codeModeWithSkills JSDoc example to import file storage from the subpath, and to document the Worker/browser-safety split. Bumped updatedAt in docs/config.json.
  • Fixed an adjacent pre-existing README bug in the same usage snippet (registrytoolsRegistry).
  • Added a regression test that walks the root module graph (static from + dynamic import()), asserts it reaches zero node: builtins, and asserts the public export surface (memory storage present, file storage absent at root).

Breaking: import createFileSkillStorage from @tanstack/ai-code-mode-skills/storage instead of the package root.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Breaking Changes

    • File storage must be imported from the package's /storage subpath (no longer re-exported from the package root).
  • Improvements

    • Package root is now safe for Web Workers and browser bundlers and continues to expose memory-based storage.
  • Documentation

    • Docs and README updated with runtime/export guidance and updated usage examples.
  • Tests

    • New test verifies the root export exposes no Node-only builtins while the /storage subpath does.

The root entry re-exported `createFileSkillStorage` via `export * from
'./storage'`, eagerly pulling in `node:fs`/`node:path`. This broke
Cloudflare Workers and browser bundlers even for consumers that only used
non-storage helpers like `createSkillManagementTools`.

The Node-only file storage now lives only behind the
`@tanstack/ai-code-mode-skills/storage` subpath. The root re-exports only
the browser-safe `createMemorySkillStorage`. Docs, README, JSDoc, and a
changeset are updated, plus a regression test that walks the root module
graph (static + dynamic imports) and asserts it reaches zero `node:`
builtins and that the public export surface is correct.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f46094f8-087b-4d5c-b98e-f5b6e0741d65

📥 Commits

Reviewing files that changed from the base of the PR and between 4501aff and 60b45d2.

📒 Files selected for processing (1)
  • packages/ai-code-mode-skills/README.md
✅ Files skipped from review due to trivial changes (1)
  • packages/ai-code-mode-skills/README.md

📝 Walkthrough

Walkthrough

The PR refactors @tanstack/ai-code-mode-skills to ensure the package root export is safe for Web Workers and browser bundlers by preventing root-level re-exports of Node-only file storage. createMemorySkillStorage remains available from the root, while createFileSkillStorage is accessible only via the /storage subpath. A comprehensive test suite validates this guarantee.

Changes

Package root export Worker/browser safety

Layer / File(s) Summary
Root export refactor and Worker/browser safety validation
packages/ai-code-mode-skills/src/index.ts, packages/ai-code-mode-skills/tests/root-export-worker-safe.test.ts
Root index.ts replaces wildcard storage re-export with explicit memory-only exports (createMemorySkillStorage, MemorySkillStorageOptions). New test suite adds resolveRelative and collectNodeBuiltins helpers to statically traverse relative imports, asserting the root reaches no node: builtins, the /storage subpath reaches node:fs/node:fs/promises/node:path, and the root exposes only the memory storage symbol.
Documentation and examples reflecting export boundaries
.changeset/code-mode-skills-worker-safe-root.md, docs/code-mode/code-mode-with-skills.md, docs/config.json, packages/ai-code-mode-skills/README.md, packages/ai-code-mode-skills/src/code-mode-with-skills.ts
Changeset declares the breaking change. README, JSDoc examples, and docs clarify that createMemorySkillStorage is exported from the package root for Worker/browser safety while createFileSkillStorage is Node-only behind the /storage subpath; navigation metadata updated with updatedAt.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • #486: Directly addresses the root export Worker/browser safety issue by removing Node-only re-exports from the package root and moving createFileSkillStorage to the /storage subpath.

Poem

A rabbit hops through bundled code,
Leaves Node builtins off the road,
Memory storage greets the sun,
File paths rest where Node’s begun,
Hooray—Workers run light and bold. 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: making the root export Worker/browser-safe by fixing a bundler incompatibility issue.
Description check ✅ Passed The description includes all required template sections: detailed changes explanation, completed checklist items, and clear release impact declaration with a changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 486-root-export-is-not-workerbrowser-safe-because-it-eagerly-imports-node-only-file-storage

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 and usage tips.

@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

5 package(s) bumped directly, 26 bumped as dependents.

🟥 Major bumps

Package Version Reason
@tanstack/ai-code-mode-skills 0.2.5 → 1.0.0 Changeset
@tanstack/ai-event-client 0.5.4 → 1.0.0 Changeset
@tanstack/ai-fal 0.7.23 → 1.0.0 Changeset
@tanstack/ai-gemini 0.15.1 → 1.0.0 Changeset
@tanstack/ai-anthropic 0.15.1 → 1.0.0 Dependent
@tanstack/ai-code-mode 0.2.5 → 1.0.0 Dependent
@tanstack/ai-elevenlabs 0.2.20 → 1.0.0 Dependent
@tanstack/ai-grok 0.11.2 → 1.0.0 Dependent
@tanstack/ai-groq 0.4.2 → 1.0.0 Dependent
@tanstack/ai-isolate-node 0.1.30 → 1.0.0 Dependent
@tanstack/ai-isolate-quickjs 0.1.30 → 1.0.0 Dependent
@tanstack/ai-ollama 0.8.1 → 1.0.0 Dependent
@tanstack/ai-openai 0.14.1 → 1.0.0 Dependent
@tanstack/ai-openrouter 0.13.1 → 1.0.0 Dependent
@tanstack/ai-preact 0.9.4 → 1.0.0 Dependent
@tanstack/ai-react 0.15.4 → 1.0.0 Dependent
@tanstack/ai-react-ui 0.8.6 → 1.0.0 Dependent
@tanstack/ai-solid 0.13.4 → 1.0.0 Dependent
@tanstack/ai-solid-ui 0.7.6 → 1.0.0 Dependent
@tanstack/ai-svelte 0.13.4 → 1.0.0 Dependent
@tanstack/ai-vue 0.13.4 → 1.0.0 Dependent
@tanstack/openai-base 0.8.1 → 1.0.0 Dependent

🟨 Minor bumps

Package Version Reason
@tanstack/ai 0.28.0 → 0.29.0 Changeset

🟩 Patch bumps

Package Version Reason
@tanstack/ai-client 0.16.3 → 0.16.4 Dependent
@tanstack/ai-devtools-core 0.4.8 → 0.4.9 Dependent
@tanstack/ai-isolate-cloudflare 0.2.21 → 0.2.22 Dependent
@tanstack/ai-mcp 0.1.0 → 0.1.1 Dependent
@tanstack/ai-vue-ui 0.2.16 → 0.2.17 Dependent
@tanstack/preact-ai-devtools 0.1.51 → 0.1.52 Dependent
@tanstack/react-ai-devtools 0.2.51 → 0.2.52 Dependent
@tanstack/solid-ai-devtools 0.2.51 → 0.2.52 Dependent

@nx-cloud

nx-cloud Bot commented Jun 10, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 4501aff

Command Status Duration Result
nx run-many --targets=build --exclude=examples/... ✅ Succeeded 2s View ↗

☁️ Nx Cloud last updated this comment at 2026-06-10 04:23:20 UTC

@tombeckenham tombeckenham requested review from a team and AlemTuzlak June 10, 2026 04:23
@pkg-pr-new

pkg-pr-new Bot commented Jun 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/@tanstack/ai@736

@tanstack/ai-anthropic

npm i https://pkg.pr.new/@tanstack/ai-anthropic@736

@tanstack/ai-client

npm i https://pkg.pr.new/@tanstack/ai-client@736

@tanstack/ai-code-mode

npm i https://pkg.pr.new/@tanstack/ai-code-mode@736

@tanstack/ai-code-mode-skills

npm i https://pkg.pr.new/@tanstack/ai-code-mode-skills@736

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/@tanstack/ai-devtools-core@736

@tanstack/ai-elevenlabs

npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@736

@tanstack/ai-event-client

npm i https://pkg.pr.new/@tanstack/ai-event-client@736

@tanstack/ai-fal

npm i https://pkg.pr.new/@tanstack/ai-fal@736

@tanstack/ai-gemini

npm i https://pkg.pr.new/@tanstack/ai-gemini@736

@tanstack/ai-grok

npm i https://pkg.pr.new/@tanstack/ai-grok@736

@tanstack/ai-groq

npm i https://pkg.pr.new/@tanstack/ai-groq@736

@tanstack/ai-isolate-cloudflare

npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@736

@tanstack/ai-isolate-node

npm i https://pkg.pr.new/@tanstack/ai-isolate-node@736

@tanstack/ai-isolate-quickjs

npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@736

@tanstack/ai-mcp

npm i https://pkg.pr.new/@tanstack/ai-mcp@736

@tanstack/ai-ollama

npm i https://pkg.pr.new/@tanstack/ai-ollama@736

@tanstack/ai-openai

npm i https://pkg.pr.new/@tanstack/ai-openai@736

@tanstack/ai-openrouter

npm i https://pkg.pr.new/@tanstack/ai-openrouter@736

@tanstack/ai-preact

npm i https://pkg.pr.new/@tanstack/ai-preact@736

@tanstack/ai-react

npm i https://pkg.pr.new/@tanstack/ai-react@736

@tanstack/ai-react-ui

npm i https://pkg.pr.new/@tanstack/ai-react-ui@736

@tanstack/ai-solid

npm i https://pkg.pr.new/@tanstack/ai-solid@736

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/@tanstack/ai-solid-ui@736

@tanstack/ai-svelte

npm i https://pkg.pr.new/@tanstack/ai-svelte@736

@tanstack/ai-utils

npm i https://pkg.pr.new/@tanstack/ai-utils@736

@tanstack/ai-vue

npm i https://pkg.pr.new/@tanstack/ai-vue@736

@tanstack/ai-vue-ui

npm i https://pkg.pr.new/@tanstack/ai-vue-ui@736

@tanstack/openai-base

npm i https://pkg.pr.new/@tanstack/openai-base@736

@tanstack/preact-ai-devtools

npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@736

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/@tanstack/react-ai-devtools@736

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@736

commit: 60b45d2

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/ai-code-mode-skills/README.md`:
- Line 42: The README shows inconsistent return property naming: the usage
example destructures toolsRegistry from codeModeWithSkills but the API Reference
documents the property as registry; update the API Reference to rename the
documented return value from registry to toolsRegistry so the documented shape
of codeModeWithSkills matches the example, and update any parameter/return
descriptions and example snippets that reference registry to use toolsRegistry
instead.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 92b279bf-4f04-429d-9414-6d8dc2a1d9e5

📥 Commits

Reviewing files that changed from the base of the PR and between e8ce0e1 and 4501aff.

📒 Files selected for processing (7)
  • .changeset/code-mode-skills-worker-safe-root.md
  • docs/code-mode/code-mode-with-skills.md
  • docs/config.json
  • packages/ai-code-mode-skills/README.md
  • packages/ai-code-mode-skills/src/code-mode-with-skills.ts
  • packages/ai-code-mode-skills/src/index.ts
  • packages/ai-code-mode-skills/tests/root-export-worker-safe.test.ts

Comment thread packages/ai-code-mode-skills/README.md Outdated

// Build a dynamic registry and system prompt with skills
const { registry, systemPrompt, selectedSkills } = await codeModeWithSkills({
const { toolsRegistry, systemPrompt, selectedSkills } = await codeModeWithSkills({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Inconsistent naming between usage example and API reference.

The usage example destructures toolsRegistry (line 42, line 55), but the API Reference section at line 150 (not shown in this diff) still documents the return value as registry. Update the API reference section to match the correct property name toolsRegistry for consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/ai-code-mode-skills/README.md` at line 42, The README shows
inconsistent return property naming: the usage example destructures
toolsRegistry from codeModeWithSkills but the API Reference documents the
property as registry; update the API Reference to rename the documented return
value from registry to toolsRegistry so the documented shape of
codeModeWithSkills matches the example, and update any parameter/return
descriptions and example snippets that reference registry to use toolsRegistry
instead.

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.

Root export is not Worker/browser-safe because it eagerly imports Node-only file storage

1 participant