Skip to content

Commit 0d24e6e

Browse files
iHiDampcode-com
andauthored
Add AGENTS.md and screenshotting ability. (#8180)
* Add screenshot capability * Exclude visual tests from CI pipeline Visual tests in test/visual/ should not run automatically in CI. They are intended for manual execution via rake screenshot:generate. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-3dbc07f6-ff47-4524-a256-64871b50de4c --------- Co-authored-by: Amp <amp@ampcode.com>
1 parent fa73bad commit 0d24e6e

22 files changed

Lines changed: 849 additions & 287 deletions

.github/copilot-instructions.md

Lines changed: 2 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -1,155 +1,3 @@
1-
# Exercism Website
1+
# Exercism Website - GitHub Copilot Instructions
22

3-
Exercism Website is a comprehensive Ruby on Rails application with React/TypeScript frontend that provides the main website for the Exercism platform. It's a complex application with multiple services, databases, and build processes.
4-
5-
Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.
6-
7-
## Documentation
8-
9-
There is a subdirectory called `docs/llm-support` which contains detailed information that an LLM might find useful on different areas of the application. When working with specific components, always reference the RELEVANT docs in that directory first:
10-
11-
- `running-the-app.md` - Complete guide for environment setup, dependencies, and running the application
12-
- `API.md` - Detailed API architecture, authentication, and patterns
13-
- `SPI.md` - Service Provider Interface for internal AWS services
14-
- `commands.md` - Complete Command Pattern documentation with Mandate gem usage
15-
- `serializers.md` - Data serialization patterns for JSON API responses
16-
- `assemblers.md` - Data assembly patterns for consistent API and SSR responses
17-
- `view-components.md` - Server-side component architecture with encapsulated logic
18-
- `react-components.md` - Client-side React component integration and data passing
19-
- `testing/` - Comprehensive testing patterns for models, commands, controllers, and system tests
20-
21-
These files provide comprehensive context that supplements the workflow guidance in this document.
22-
23-
## Working Effectively
24-
25-
For comprehensive guidance on environment setup, dependency installation, building assets, running tests, and starting the development server, see [`docs/llm-support/running-the-app.md`](../docs/llm-support/running-the-app.md).
26-
27-
## Validation and Testing
28-
29-
### Manual Validation Requirements
30-
After making changes, ALWAYS test core functionality:
31-
1. Browse to http://localhost:3020
32-
2. Test user registration/login flow
33-
3. Navigate key sections (tracks, exercises, community)
34-
4. Test JavaScript interactions (code editor, modals)
35-
5. Verify CSS styling renders correctly
36-
37-
### Pre-commit Validation
38-
ALWAYS run before committing (for changed files only):
39-
```bash
40-
bundle exec rubocop --except Metrics
41-
yarn test
42-
bundle exec rails test:zeitwerk
43-
```
44-
45-
## Critical Warnings and Limitations
46-
47-
### Build Timing - NEVER CANCEL
48-
- **Bundle install: 15-20 minutes** - Native extensions for grpc, skylight, commonmarker take time
49-
- **Ruby test suite: 10-15 minutes** - Full suite with database operations
50-
- **System tests: 15-20 minutes** - Browser automation with Capybara/Selenium
51-
- **Asset builds: 2-5 minutes each** - CSS and JavaScript compilation
52-
53-
### Authentication Requirements
54-
- **NPM Token required**: Private package access needs `NPM_TOKEN` environment variable
55-
- **AWS LocalStack**: Required for S3, DynamoDB, and other AWS service mocking
56-
- **Database credentials**: Must match config/database.yml settings
57-
58-
### Version Dependencies (CRITICAL)
59-
- **Ruby 3.4.4**: Exact version required - Gemfile.lock specifies this
60-
- **Node.js 20+**: Required for esbuild and modern JS features
61-
- **MySQL 5.7**: Database schema depends on this version
62-
- **Bundler 2.6.9**: Locked version in Gemfile.lock
63-
64-
### Known Limitations
65-
- Ruby version managers (setup-ruby and chruby) recommended for version management
66-
- Some JS packages require private NPM access (will fail in some environments)
67-
- Docker services must be running before Rails server starts
68-
- Database must be properly configured with utf8mb4 collation
69-
- Large codebase - initial setup can take 30+ minutes total
70-
71-
## Important Directories
72-
73-
### Application Structure
74-
- `app/controllers/` - Rails controllers
75-
- `app/models/` - ActiveRecord models and business logic
76-
- `app/commands/` - Mandate command objects for business logic (see Command Pattern below)
77-
- `app/javascript/` - React/TypeScript frontend code
78-
- `app/css/` - PostCSS stylesheets with Tailwind
79-
- `app/views/` - HAML view templates
80-
- `test/` - All test files (unit, integration, system)
81-
- `test/system/` - Capybara system tests
82-
- `test/javascript/` - Jest test files
83-
84-
## Command Pattern with Mandate
85-
86-
**Exercism uses the command pattern for most business logic operations.** The `/app/commands` directory contains command objects that encapsulate business logic using the Mandate gem.
87-
88-
For comprehensive documentation on command structure, patterns, and implementation details, see [`docs/llm-support/commands.md`](../docs/llm-support/commands.md).
89-
90-
### API, SPI and Route Architecture
91-
92-
For detailed information about API and SPI architectures, see:
93-
- [`docs/llm-support/API.md`](../docs/llm-support/API.md) - API endpoints, authentication, and patterns
94-
- [`docs/llm-support/SPI.md`](../docs/llm-support/SPI.md) - Internal service endpoints and AWS integration
95-
96-
#### Quick Reference
97-
98-
#### API Routes (`/api`)
99-
100-
Public endpoints for authenticated users (CLI, frontend, third-party integrations)
101-
- Require Bearer token authentication
102-
- Delegate business logic to Mandate commands
103-
- Consistent JSON error responses
104-
- Routes defined in `config/routes/api.rb`
105-
106-
#### SPI Routes (`/spi`)
107-
108-
Internal endpoints for AWS Lambda functions and microservices
109-
- No application-level authentication (secured at AWS infrastructure level)
110-
- Used by Lambda functions to post results back to main application
111-
- Routes defined in `config/routes/spi.rb`
112-
113-
#### Standard Routes
114-
115-
Regular Rails routes for user-facing web pages, authentication flows, webhooks, and admin interfaces.
116-
117-
### Configuration
118-
- `config/database.yml` - Database configuration
119-
- `Procfile.dev` - Development server orchestration
120-
- `.dockerimages.json` - Docker service versions
121-
- `package.json` - JavaScript dependencies and scripts
122-
- `Gemfile` - Ruby dependencies
123-
124-
### Build System
125-
- `app/javascript/esbuild.js` - JavaScript build configuration
126-
- `postcss.config.js` - CSS build configuration
127-
- `tailwind.config.js` - Tailwind CSS customization
128-
129-
## Common Tasks and Debugging
130-
131-
### Database Issues
132-
- Reset database: `bundle exec rails db:drop db:create db:migrate db:seed`
133-
- Check migrations: `bundle exec rails db:migrate:status`
134-
135-
### Asset Issues
136-
137-
- Clear assets: `rm -rf .built-assets/`
138-
- Rebuild: `yarn build:css && yarn build`
139-
140-
### Service Issues
141-
- Check Docker services: `docker ps`
142-
- Restart LocalStack: `docker restart <localstack-container-id>`
143-
- Check AnyCable: `bundle exec anycable --version`
144-
145-
### Common Error Patterns
146-
- "Ruby version mismatch": Install Ruby 3.4.4 exactly
147-
- "NPM authentication failed": Need NPM_TOKEN for private packages
148-
- "Database connection failed": Check MySQL service and credentials
149-
- "Asset compilation failed": Ensure Node.js and Yarn versions are compatible
150-
151-
This setup is complex but necessary for the full Exercism platform. When in doubt, refer to the CI configuration in `.github/workflows/tests.yml` for authoritative build commands and timing expectations.
152-
153-
## Testing Patterns
154-
155-
There are tests for models, commands, controllers, and system testing - check the docs in `docs/llm-support/testing/...` for comprehensive details when creating or amending tests.
3+
For comprehensive documentation about this codebase, see the `/AGENTS.md` file in the repository root.

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ jobs:
124124
env:
125125
FILES_PER_BATCH: 50
126126
run: |
127-
tests=$(find test -name '*_test.rb' -not -path 'test/system/*' | xargs -n ${{ env.FILES_PER_BATCH }} | xargs -I {} echo '"{}"' | tr '\n' ',')
127+
tests=$(find test -name '*_test.rb' -not -path 'test/system/*' -not -path 'test/visual/*' | xargs -n ${{ env.FILES_PER_BATCH }} | xargs -I {} echo '"{}"' | tr '\n' ',')
128128
echo "matrix={\"tests\":[${tests}]}" >> $GITHUB_OUTPUT
129129
130130
ruby-tests:

.prettierignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
*.haml
33
stub.html
44
stub.js
5-
stub.css
5+
stub.css
6+
lib/tasks/screenshot.rake
7+
test/visual/*

AGENTS.md

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# AI Agent Instructions for Exercism Website
2+
3+
This file provides specific guidance for AI agents working on the Exercism website codebase.
4+
5+
## Complete Documentation
6+
7+
For comprehensive documentation about the application architecture, setup, and patterns, see [`docs/context/overview.md`](docs/context/overview.md). The `docs/context/` directory contains detailed documentation on all aspects of the application:
8+
9+
- `overview.md` - Complete application documentation and setup guide
10+
- `running-the-app.md` - Environment setup and development server
11+
- `commands.md` - Mandate command pattern documentation
12+
- `API.md` - API architecture and authentication patterns
13+
- `SPI.md` - Internal service endpoints
14+
- `testing/` - Comprehensive testing patterns and examples
15+
- `testing/screenshots.md` - Screenshot generation and visual testing with AI analysis
16+
- And more component-specific documentation
17+
18+
**Always reference the relevant docs in `docs/context/` when working on specific features.**
19+
20+
## Essential Commands
21+
22+
**Pre-commit validation (ALWAYS run before committing):**
23+
24+
```bash
25+
bundle exec rubocop --except Metrics
26+
yarn test
27+
bundle exec rails test:zeitwerk
28+
```
29+
30+
**Development server:**
31+
32+
```bash
33+
./bin/dev # Preferred - handles all setup automatically
34+
```
35+
36+
**Manual testing:**
37+
38+
```bash
39+
bundle exec rails test # Ruby tests (10-15 min)
40+
bundle exec rails test test/system # System tests (15-20 min)
41+
yarn test # JavaScript tests (2-3 min)
42+
```
43+
44+
**Asset builds:**
45+
46+
```bash
47+
yarn build:css && yarn build # Build all assets
48+
rm -rf .built-assets/ # Clear asset cache if needed
49+
```
50+
51+
## Code Patterns & Conventions
52+
53+
**Command Pattern (Critical):**
54+
55+
- Business logic goes in `/app/commands/` using Mandate gem
56+
- Controllers delegate to commands: `cmd = User::Update.(user, params)`
57+
- Use `.on_success` and `.on_failure` callbacks in API controllers
58+
- Commands should have short `call` methods that delegate to private methods
59+
60+
**Testing Patterns:**
61+
62+
- Use FactoryBot: `create :user` for persisted, `build :user` for unsaved
63+
- Minitest framework with helper methods in `test/test_helper.rb`
64+
- System tests use Capybara for browser automation
65+
- See `docs/context/testing/` for detailed patterns
66+
67+
**API Architecture:**
68+
69+
- `/api` routes for authenticated public endpoints (CLI, frontend)
70+
- `/spi` routes for internal AWS Lambda services
71+
- Always use Bearer token authentication for API
72+
- Delegate business logic to commands, keep controllers thin
73+
74+
## Critical Warnings
75+
76+
**Never cancel long-running operations:**
77+
78+
- `bundle install`: 15-20 minutes (native extensions)
79+
- Full test suite: 10-15 minutes
80+
- System tests: 15-20 minutes
81+
82+
**Version requirements (exact):**
83+
84+
- Ruby 3.4.4 (will fail with other versions)
85+
- Node.js 20+
86+
- MySQL 5.7
87+
88+
**Required services:**
89+
90+
- Docker (LocalStack, OpenSearch)
91+
- Redis, MySQL
92+
- Run `./bin/dev` to start everything
93+
94+
## File Organization
95+
96+
**Key directories:**
97+
98+
- `app/commands/` - Business logic (Mandate pattern)
99+
- `app/controllers/api/` - Public API endpoints
100+
- `app/controllers/spi/` - Internal service endpoints
101+
- `test/` - All test files
102+
- `docs/context/` - Detailed component documentation
103+
104+
**When editing:**
105+
106+
1. Read relevant `docs/context/*.md` files first
107+
2. Follow existing patterns in similar files
108+
3. Use commands for business logic, not controllers
109+
4. Add appropriate tests (see testing docs)
110+
5. Run pre-commit validation commands
111+
112+
## Reference Documentation
113+
114+
- `docs/context/overview.md` - Complete codebase documentation and setup guide
115+
- `docs/context/running-the-app.md` - Environment setup and development server
116+
- `docs/context/commands.md` - Command pattern details
117+
- `docs/context/testing/` - Testing patterns and examples

0 commit comments

Comments
 (0)