Skip to content

feat: add connect script, Vite plugin, and init command#10

Merged
piotrski merged 6 commits intomainfrom
feat/connect
Feb 10, 2026
Merged

feat: add connect script, Vite plugin, and init command#10
piotrski merged 6 commits intomainfrom
feat/connect

Conversation

@piotrski
Copy link
Owner

@piotrski piotrski commented Feb 10, 2026

Summary

  • agent-react-devtools/connect — single-import browser module that handles Vite hook stub deletion, react-devtools-core init, and WebSocket connection with SSR/production guards and 2s timeout
  • agent-react-devtools/vite — zero-code Vite plugin (reactDevtools()) that injects the connect script via transformIndexHtml in dev mode only
  • agent-react-devtools init — CLI command that auto-detects framework (Vite, Next.js, CRA, React Native) and patches config files with --dry-run support
  • Expo example app (SDK 54) for testing React Native integration
  • Updated example react-app to use the Vite plugin, removing manual boilerplate
  • Updated README with docs for all connection approaches including React Native
  • 11 new tests for init framework detection and config patching (49 total, all passing)

Test plan

  • bun run build — all 3 tsup targets (CLI, connect, vite) produce JS + DTS
  • bun run typecheck — clean
  • bun run test — 49/49 pass
  • npm pack --dry-run — includes connect.js, connect.d.ts, vite.js, vite.d.ts
  • Expo example app launches on iOS simulator (SDK 54)
  • Manual test: start daemon + example react-app with Vite plugin, verify get tree works
  • Manual test: start daemon + Expo app, verify RN auto-connects

🤖 Generated with Claude Code


Note

Medium Risk
Introduces new public entrypoints that inject browser code and auto-modify user project files, which could cause integration/build issues across frameworks if edge cases aren’t handled. Guards for SSR/production and idempotent patching reduce runtime risk, but the init patching and bundler/plugin behavior still warrant review.

Overview
Adds zero-config app connection via three new surfaces: agent-react-devtools/connect (browser-side auto-connect with SSR/prod guards and non-blocking timeout), agent-react-devtools/vite (dev-only Vite plugin that injects the connect import + optional host/port meta tags), and a new agent-react-devtools init [--dry-run] CLI command that detects Vite/Next.js (Pages vs App Router), CRA, or React Native and patches the appropriate config/entry files (including generating a Next.js App Router 'use client' wrapper).

Updates packaging/build to ship the new connect and vite exports (separate tsup targets, optional peer deps for react-devtools-core/vite), adds focused vitest coverage for framework detection and patching behavior, refreshes docs, and updates/expands examples (Vite example uses the plugin; new Expo example app for RN validation).

Written by Cursor Bugbot for commit 48d5865. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link

changeset-bot bot commented Feb 10, 2026

🦋 Changeset detected

Latest commit: 48d5865

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
agent-react-devtools Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Reduce React app connection boilerplate from ~30 lines to a single import
or zero-code Vite plugin:

- `agent-react-devtools/connect`: browser module that handles hook stub
  deletion, react-devtools-core initialization, and WebSocket connection
- `agent-react-devtools/vite`: Vite plugin that injects the connect
  script via transformIndexHtml (dev only)
- `agent-react-devtools init`: CLI command that auto-detects framework
  (Vite/Next.js/CRA/React Native) and patches config files
- Expo example app (SDK 54) for testing React Native integration
- Updated example react-app to use the Vite plugin
- Updated README with connection docs for all approaches
- 11 new tests for init command framework detection and patching

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

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

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: 7a54137d2c

ℹ️ 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".

…lude react-devtools-core

App Router's layout.tsx is a Server Component, so directly importing connect
there never runs client-side. Now creates a 'use client' wrapper (devtools.ts)
and imports that from layout instead. Pages Router still uses direct import.
Also fixes install instructions to always include react-devtools-core since
connect.ts dynamically imports it for all frameworks, and fixes idempotency
for repeated init runs on App Router projects.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…geset

- connect.ts: check import.meta.env.PROD (Vite/bundlers) in addition to
  process.env.NODE_ENV so the production guard works in browser environments
- init.ts: fix dry-run printing misleading "Next steps" when already configured
  by removing the !dryRun condition from the early exit check
- Add changeset for all fixes in this PR

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
piotrski and others added 2 commits February 10, 2026 21:04
…olidate changeset

- Rename examples/react-app → examples/vite-app to better reflect the framework
- Wrap connect() in top-level try/catch so missing react-devtools-core
  doesn't produce an unhandled rejection
- Replace partial changeset with a single minor changeset covering all
  new features on this branch
- Add example-expo-app to changeset ignore list

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@piotrski piotrski merged commit 0c88c11 into main Feb 10, 2026
4 checks passed
@piotrski piotrski deleted the feat/connect branch February 10, 2026 20:48
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