Skip to content

Commit 1098fcb

Browse files
Copilothi-ogawa
andcommitted
Refactor AGENTS.md files to reference existing documentation
Co-authored-by: hi-ogawa <[email protected]>
1 parent 2d8b507 commit 1098fcb

File tree

2 files changed

+65
-266
lines changed

2 files changed

+65
-266
lines changed

AGENTS.md

Lines changed: 35 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,131 +1,56 @@
11
# AI Agent Development Guide
22

3-
This document provides guidance for AI agents working with the vite-plugin-react monorepo.
3+
This document provides AI-agent-specific guidance for working with the vite-plugin-react monorepo. For comprehensive documentation, see:
44

5-
## Repository Structure
5+
- **[README.md](README.md)** - Repository overview and package links
6+
- **[CONTRIBUTING.md](CONTRIBUTING.md)** - Setup, testing, debugging, and contribution guidelines
67

7-
This is a monorepo containing multiple Vite React plugins:
8+
## Quick Reference for AI Agents
89

9-
```
10-
packages/
11-
├── plugin-react/ # Main React plugin with Babel transformation
12-
├── plugin-react-swc/ # React plugin with SWC transformation
13-
├── plugin-react-oxc/ # Deprecated React plugin (merged with plugin-react)
14-
├── plugin-rsc/ # React Server Components plugin
15-
└── common/ # Shared utilities
16-
```
10+
### Repository Navigation
1711

18-
## Development Workflow
12+
This monorepo contains multiple packages (see [README.md](README.md#packages) for details):
1913

20-
### Prerequisites
14+
- `packages/plugin-react/` - Main React plugin with Babel
15+
- `packages/plugin-react-swc/` - SWC-based React plugin
16+
- `packages/plugin-rsc/` - React Server Components ([AI guidance](packages/plugin-rsc/AGENTS.md))
17+
- `packages/plugin-react-oxc/` - Deprecated (merged with plugin-react)
2118

22-
- Node.js ^20.19.0 || >=22.12.0
23-
- pnpm (package manager) - version 10.15.0
24-
25-
### Setup
19+
### Essential Setup Commands
2620

2721
```bash
28-
# Install dependencies
29-
pnpm install
30-
31-
# Build all packages
32-
pnpm build
33-
34-
# Start development mode (watch builds)
35-
pnpm dev
22+
pnpm install && pnpm build # Initial setup (see CONTRIBUTING.md for details)
23+
pnpm dev # Watch mode development
24+
pnpm test # Run all tests
3625
```
3726

38-
### Key Commands
39-
40-
```bash
41-
# Linting
42-
pnpm lint # ESLint across all packages
43-
pnpm format # Prettier formatting
44-
45-
# Type checking
46-
pnpm typecheck # TypeScript checking
47-
48-
# Testing
49-
pnpm test # Run all tests
50-
pnpm test-unit # Unit tests only
51-
pnpm test-serve # Development server tests
52-
pnpm test-build # Build tests
53-
```
54-
55-
## Important Files
56-
57-
- `package.json` - Monorepo configuration and scripts
58-
- `pnpm-workspace.yaml` - Workspace configuration
59-
- `eslint.config.js` - ESLint configuration
60-
- `playground/` - Test applications for each plugin
61-
62-
## Plugin-Specific Notes
63-
64-
### @vitejs/plugin-react
65-
66-
- Located in `packages/plugin-react/`
67-
- Uses Babel for transformation
68-
- Primary React plugin for Vite
69-
70-
### @vitejs/plugin-react-swc
71-
72-
- Located in `packages/plugin-react-swc/`
73-
- Uses SWC for faster transformation
74-
- Alternative to Babel-based plugin
75-
76-
### @vitejs/plugin-rsc
77-
78-
- Located in `packages/plugin-rsc/`
79-
- Experimental React Server Components support
80-
- See [packages/plugin-rsc/AGENTS.md](packages/plugin-rsc/AGENTS.md) for detailed guidance
81-
82-
## Testing Guidelines
83-
84-
Each package has its own test suite. The playground directory contains integration tests that verify plugin functionality in realistic scenarios.
85-
86-
### Running Package-Specific Tests
87-
88-
```bash
89-
# Test specific package
90-
pnpm --filter ./packages/plugin-react test
91-
pnpm --filter ./packages/plugin-rsc test-e2e
92-
```
93-
94-
## Code Quality
95-
96-
- Code is automatically formatted with Prettier on commit
97-
- ESLint enforces code quality and consistency
98-
- TypeScript provides type safety
99-
- All packages require tests for new features
27+
### AI-Specific Workflow Tips
10028

101-
## Contributing
29+
1. **Start with existing documentation** - Always read package-specific READMEs before making changes
30+
2. **Use playground tests** - Each package has `playground/` examples for testing changes
31+
3. **Focus on minimal changes** - Prefer surgical edits over large refactors
32+
4. **Test early and often** - Run `pnpm test` after each logical change
33+
5. **Follow existing patterns** - Study similar implementations in the codebase first
10234

103-
1. Follow the existing code style and patterns
104-
2. Add tests for new functionality
105-
3. Update documentation as needed
106-
4. Ensure all linting and tests pass
107-
5. Keep changes focused and atomic
35+
### Common Development Tasks
10836

109-
## Common Tasks for AI Agents
37+
#### Making Changes to Plugin Logic
11038

111-
### Adding a New Feature
39+
1. Read the package README and existing code patterns
40+
2. Use `pnpm dev` for watch mode during development
41+
3. Test changes with relevant playground examples
42+
4. Run tests: `pnpm test-serve` and `pnpm test-build`
11243

113-
1. Identify the appropriate package
114-
2. Read existing code patterns
115-
3. Add implementation with proper TypeScript types
116-
4. Add comprehensive tests
117-
5. Update relevant documentation
44+
#### Debugging Build Issues
11845

119-
### Debugging Issues
46+
1. Check individual package builds with `pnpm --filter ./packages/<name> build`
47+
2. Use playground tests to isolate problems
48+
3. See [CONTRIBUTING.md debugging section](CONTRIBUTING.md#debugging) for detailed guidance
12049

121-
1. Check playground tests for reproduction cases
122-
2. Use `pnpm dev` for live development
123-
3. Run specific test suites to isolate problems
124-
4. Review build outputs and error messages
50+
#### Adding Tests
12551

126-
### Performance Optimization
52+
1. Follow patterns in existing `__tests__` directories
53+
2. Use playground integration tests for feature verification
54+
3. See [CONTRIBUTING.md testing section](CONTRIBUTING.md#running-tests) for comprehensive testing guide
12755

128-
1. Profile with `vite-plugin-inspect`
129-
2. Analyze bundle sizes in playground builds
130-
3. Test with various React application patterns
131-
4. Ensure backward compatibility
56+
For detailed development setup, testing procedures, and contribution guidelines, refer to [CONTRIBUTING.md](CONTRIBUTING.md).

packages/plugin-rsc/AGENTS.md

Lines changed: 30 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,180 +1,54 @@
11
# AI Agent Guide for @vitejs/plugin-rsc
22

3-
This document provides specific guidance for AI agents working with the React Server Components (RSC) plugin.
3+
This document provides AI-agent-specific guidance for the React Server Components (RSC) plugin. For comprehensive documentation, see:
44

5-
## Overview
5+
- **[README.md](README.md)** - Plugin overview, concepts, and examples
6+
- **[CONTRIBUTING.md](CONTRIBUTING.md)** - Development setup and testing guidelines
67

7-
The `@vitejs/plugin-rsc` provides React Server Components support for Vite. It's built on the Vite environment API and enables:
8+
## Quick Reference for AI Agents
89

9-
- Framework-agnostic RSC bundler features
10-
- HMR support for both client and server components
11-
- CSS code-splitting and injection
12-
- Runtime-agnostic builds (works with various deployment targets)
10+
### Key Plugin Concepts
1311

14-
## Key Concepts
12+
The RSC plugin creates three environments (see [README.md Basic Concepts](README.md#basic-concepts) for diagrams):
1513

16-
### Environments
14+
- **rsc** - Server component rendering
15+
- **ssr** - Server-side rendering
16+
- **client** - Browser hydration
1717

18-
The plugin creates three distinct environments:
19-
20-
1. **rsc** - React server components rendering
21-
2. **ssr** - Server-side rendering environment
22-
3. **client** - Browser environment for hydration
23-
24-
### Architecture
25-
26-
```
27-
RSC Component → RSC Stream → SSR/Client Consumption → DOM/HTML
28-
```
29-
30-
See [Basic Concepts](README.md#basic-concepts) in the README for detailed flow diagrams.
31-
32-
## Development Workflow
33-
34-
### Setup
18+
### Essential Commands
3519

3620
```bash
37-
# Build the plugin
38-
pnpm -C packages/plugin-rsc dev
39-
40-
# Type checking
41-
pnpm -C packages/plugin-rsc tsc-dev
21+
pnpm -C packages/plugin-rsc dev # Watch mode development
22+
pnpm -C packages/plugin-rsc test-e2e # Run e2e tests
23+
pnpm -C packages/plugin-rsc test-e2e basic # Test specific example
4224
```
4325

44-
### Testing
26+
### AI-Specific Development Tips
4527

46-
```bash
47-
# Run all e2e tests
48-
pnpm -C packages/plugin-rsc test-e2e
49-
50-
# Run with UI (interactive filtering)
51-
pnpm -C packages/plugin-rsc test-e2e --ui
28+
#### Making RSC Changes
5229

53-
# Run specific test file
54-
pnpm -C packages/plugin-rsc test-e2e basic
30+
1. **Start with `examples/starter/`** - Best learning resource for understanding RSC flows
31+
2. **Use `examples/basic/` for testing** - Comprehensive test suite with routing
32+
3. **Test across all environments** - Verify rsc, ssr, and client functionality
33+
4. **Check virtual modules** - Important for RSC manifest and reference handling
5534

56-
# Run with grep filter
57-
pnpm -C packages/plugin-rsc test-e2e -g "hmr"
58-
```
35+
#### Testing Patterns
5936

60-
### Examples
37+
- **examples/basic** - Add test cases to `src/routes/`, update routing, add tests to `e2e/basic.test.ts`
38+
- **setupInlineFixture** - For isolated edge cases (see `e2e/ssr-thenable.test.ts` pattern)
6139

62-
- `examples/starter/` - **Start here** - Comprehensive learning resource
63-
- `examples/basic/` - Advanced features and main e2e test suite
64-
- `examples/ssg/` - Static site generation example
65-
- `examples/react-router/` - React Router integration
66-
67-
## Important Files
68-
69-
### Core Plugin Files
40+
#### Important File Locations
7041

7142
- `src/plugin.ts` - Main plugin implementation
7243
- `src/environment/` - Environment-specific logic
73-
- `src/types/` - TypeScript definitions
74-
- `types/` - External type definitions
75-
76-
### Runtime APIs
77-
78-
- `rsc/` - Server component runtime
79-
- `ssr/` - SSR runtime
80-
- `browser/` - Client runtime
81-
- `vendor/` - Vendored react-server-dom
82-
83-
### Configuration
84-
85-
- `vite.config.ts` - Development configuration
86-
- `tsdown.config.ts` - Build configuration
87-
- `playwright.config.ts` - E2E test configuration
44+
- `rsc/`, `ssr/`, `browser/` - Runtime APIs
45+
- `examples/` - Test applications and learning resources
8846

89-
## Testing Patterns
90-
91-
### Test Fixture Patterns
92-
93-
1. **examples/basic** - Comprehensive test suite
94-
- Add test cases to `src/routes/`
95-
- Update routing in `src/routes/root.tsx`
96-
- Add tests to `e2e/basic.test.ts`
97-
98-
2. **setupInlineFixture** - Isolated edge case testing
99-
- Best for specific scenarios
100-
- See `e2e/ssr-thenable.test.ts` for pattern
101-
- Dependencies managed in `examples/e2e/package.json`
102-
103-
### Adding Tests
104-
105-
```bash
106-
# Create new test project (automatically runnable)
107-
pnpm -C packages/plugin-rsc/examples/e2e/temp/my-test dev
108-
```
109-
110-
## Common Development Tasks
111-
112-
### Adding New RSC Features
113-
114-
1. Understand the React Server Components specification
115-
2. Check existing implementation in `src/environment/`
116-
3. Add runtime support in appropriate environment
117-
4. Update type definitions
118-
5. Add comprehensive tests
119-
6. Update documentation
120-
121-
### Debugging Issues
47+
### Debugging RSC Issues
12248

12349
1. Use `examples/starter` for basic reproduction
124-
2. Check environment-specific builds in `.vite/`
125-
3. Examine RSC streams and manifests
126-
4. Test across all three environments
127-
5. Verify HMR behavior
128-
129-
### Performance Optimization
130-
131-
1. Analyze bundle outputs with metadata plugins
132-
2. Check CSS code-splitting effectiveness
133-
3. Monitor RSC payload sizes
134-
4. Test streaming performance
135-
136-
## Key Plugin APIs
137-
138-
### Virtual Modules
139-
140-
- `virtual:vite-rsc/assets-manifest`
141-
- `virtual:vite-rsc/client-references`
142-
- `virtual:vite-rsc/server-references`
143-
- `virtual:vite-rsc/encryption-key`
144-
145-
### Environment Helper API
146-
147-
- `import.meta.viteRsc.loadCss()` - CSS loading
148-
- `?vite-rsc-css-export=<name>` - CSS exports
149-
150-
### Runtime Modules
151-
152-
- `@vitejs/plugin-rsc/rsc` - Server component rendering
153-
- `@vitejs/plugin-rsc/ssr` - SSR utilities
154-
- `@vitejs/plugin-rsc/browser` - Client-side RSC
155-
156-
## Best Practices
157-
158-
1. **Use setupInlineFixture for new tests** - More maintainable and faster
159-
2. **Follow existing patterns** - Check `examples/basic` for comprehensive examples
160-
3. **Test across environments** - Ensure functionality works in rsc, ssr, and client
161-
4. **Maintain backward compatibility** - RSC ecosystem is evolving rapidly
162-
5. **Document breaking changes** - Update CHANGELOG.md appropriately
163-
164-
## Troubleshooting
165-
166-
### Common Issues
167-
168-
1. **Module resolution errors** - Check `optimizeDeps.include` configuration
169-
2. **CSS not loading** - Verify `loadCss()` usage and environment setup
170-
3. **HMR not working** - Check component boundaries and environment isolation
171-
4. **Build failures** - Verify environment-specific configurations
172-
173-
### Debugging Tools
174-
175-
- Vite's built-in inspect plugin
176-
- Browser DevTools for client environment
177-
- Server logs for rsc/ssr environments
178-
- Playwright test inspector for e2e tests
50+
2. Check environment builds in `.vite/` directory
51+
3. Examine RSC streams and client/server manifests
52+
4. Verify HMR behavior across environments
17953

180-
For more detailed contributing guidelines, see [CONTRIBUTING.md](CONTRIBUTING.md).
54+
For detailed setup, testing procedures, and architectural deep-dives, refer to the comprehensive documentation in [README.md](README.md) and [CONTRIBUTING.md](CONTRIBUTING.md).

0 commit comments

Comments
 (0)