agileflow 2.79.0 → 2.81.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/package.json +1 -1
- package/scripts/agent-loop.js +765 -0
- package/scripts/agileflow-configure.js +129 -18
- package/scripts/agileflow-welcome.js +113 -16
- package/scripts/damage-control/bash-tool-damage-control.js +7 -6
- package/scripts/damage-control/edit-tool-damage-control.js +4 -24
- package/scripts/damage-control/patterns.yaml +32 -32
- package/scripts/damage-control/write-tool-damage-control.js +4 -24
- package/scripts/damage-control-bash.js +38 -125
- package/scripts/damage-control-edit.js +22 -165
- package/scripts/damage-control-write.js +22 -165
- package/scripts/get-env.js +6 -6
- package/scripts/lib/damage-control-utils.js +251 -0
- package/scripts/obtain-context.js +103 -37
- package/scripts/ralph-loop.js +243 -31
- package/scripts/screenshot-verifier.js +4 -2
- package/scripts/session-manager.js +434 -20
- package/src/core/agents/configuration-visual-e2e.md +300 -0
- package/src/core/agents/orchestrator.md +166 -0
- package/src/core/commands/babysit.md +61 -15
- package/src/core/commands/configure.md +408 -99
- package/src/core/commands/session/end.md +332 -103
- package/src/core/experts/documentation/expertise.yaml +25 -0
- package/tools/cli/commands/start.js +19 -21
- package/tools/cli/installers/ide/claude-code.js +32 -19
- package/tools/cli/tui/Dashboard.js +3 -4
- package/tools/postinstall.js +1 -9
- package/src/core/commands/setup/visual-e2e.md +0 -462
|
@@ -10,25 +10,13 @@
|
|
|
10
10
|
|
|
11
11
|
const path = require('path');
|
|
12
12
|
const fs = require('fs');
|
|
13
|
-
|
|
14
|
-
// ANSI color codes
|
|
15
|
-
const colors = {
|
|
16
|
-
reset: '\x1b[0m',
|
|
17
|
-
bold: '\x1b[1m',
|
|
18
|
-
dim: '\x1b[2m',
|
|
19
|
-
yellow: '\x1b[33m',
|
|
20
|
-
red: '\x1b[31m',
|
|
21
|
-
green: '\x1b[32m',
|
|
22
|
-
cyan: '\x1b[36m',
|
|
23
|
-
magenta: '\x1b[35m',
|
|
24
|
-
orange: '\x1b[38;2;232;104;58m',
|
|
25
|
-
bgYellow: '\x1b[43m',
|
|
26
|
-
bgRed: '\x1b[41m',
|
|
27
|
-
};
|
|
13
|
+
const { c: colors } = require('../../../lib/colors');
|
|
28
14
|
|
|
29
15
|
function showBetaWarning() {
|
|
30
16
|
console.log('');
|
|
31
|
-
console.log(
|
|
17
|
+
console.log(
|
|
18
|
+
`${colors.bgYellow}${colors.bold} BETA ${colors.reset} ${colors.yellow}This feature is in beta and not yet stable${colors.reset}`
|
|
19
|
+
);
|
|
32
20
|
console.log(`${colors.dim} Expect bugs and incomplete features${colors.reset}`);
|
|
33
21
|
console.log('');
|
|
34
22
|
}
|
|
@@ -91,13 +79,17 @@ async function showDashboard() {
|
|
|
91
79
|
const status = await loadStatus();
|
|
92
80
|
|
|
93
81
|
if (!status) {
|
|
94
|
-
console.log(
|
|
82
|
+
console.log(
|
|
83
|
+
`${colors.dim} No status.json found. Run /agileflow:story to create stories.${colors.reset}`
|
|
84
|
+
);
|
|
95
85
|
console.log('');
|
|
96
86
|
return;
|
|
97
87
|
}
|
|
98
88
|
|
|
99
89
|
// Count stories by status
|
|
100
|
-
const stories = Object.values(status).filter(
|
|
90
|
+
const stories = Object.values(status).filter(
|
|
91
|
+
s => s && typeof s === 'object' && (s.id || s.story_id)
|
|
92
|
+
);
|
|
101
93
|
const counts = {
|
|
102
94
|
in_progress: stories.filter(s => ['in_progress', 'in-progress'].includes(s.status)).length,
|
|
103
95
|
blocked: stories.filter(s => s.status === 'blocked').length,
|
|
@@ -111,7 +103,9 @@ async function showDashboard() {
|
|
|
111
103
|
// Summary
|
|
112
104
|
console.log(`${colors.bold} Summary${colors.reset}`);
|
|
113
105
|
console.log(` ────────────────────────────────────────────`);
|
|
114
|
-
console.log(
|
|
106
|
+
console.log(
|
|
107
|
+
` ${colors.yellow}In Progress:${colors.reset} ${counts.in_progress} ${colors.red}Blocked:${colors.reset} ${counts.blocked} ${colors.cyan}Ready:${colors.reset} ${counts.ready} ${colors.green}Done:${colors.reset} ${counts.completed}`
|
|
108
|
+
);
|
|
115
109
|
console.log(` ${colors.dim}Completion: ${completionPct}%${colors.reset}`);
|
|
116
110
|
console.log('');
|
|
117
111
|
|
|
@@ -140,7 +134,9 @@ async function showDashboard() {
|
|
|
140
134
|
// Ready Stories (up to 5)
|
|
141
135
|
const readyStories = stories.filter(s => s.status === 'ready').slice(0, 5);
|
|
142
136
|
if (readyStories.length > 0) {
|
|
143
|
-
console.log(
|
|
137
|
+
console.log(
|
|
138
|
+
`${colors.bold} ${colors.cyan}Ready for Work${colors.reset} ${colors.dim}(showing ${readyStories.length} of ${counts.ready})${colors.reset}`
|
|
139
|
+
);
|
|
144
140
|
console.log(` ────────────────────────────────────────────`);
|
|
145
141
|
readyStories.forEach(story => {
|
|
146
142
|
console.log(formatStory(story));
|
|
@@ -165,7 +161,9 @@ async function main() {
|
|
|
165
161
|
console.log(' npx agileflow start Show dashboard');
|
|
166
162
|
console.log(' npx agileflow start --help Show this help');
|
|
167
163
|
console.log('');
|
|
168
|
-
console.log(
|
|
164
|
+
console.log(
|
|
165
|
+
`${colors.dim}This is a beta feature. For stable commands, use Claude Code slash commands.${colors.reset}`
|
|
166
|
+
);
|
|
169
167
|
return;
|
|
170
168
|
}
|
|
171
169
|
|
|
@@ -111,7 +111,11 @@ class ClaudeCodeSetup extends BaseIdeSetup {
|
|
|
111
111
|
await this.ensureDir(damageControlTarget);
|
|
112
112
|
|
|
113
113
|
// Copy hook scripts
|
|
114
|
-
const scripts = [
|
|
114
|
+
const scripts = [
|
|
115
|
+
'bash-tool-damage-control.js',
|
|
116
|
+
'edit-tool-damage-control.js',
|
|
117
|
+
'write-tool-damage-control.js',
|
|
118
|
+
];
|
|
115
119
|
for (const script of scripts) {
|
|
116
120
|
const src = path.join(damageControlSource, script);
|
|
117
121
|
const dest = path.join(damageControlTarget, script);
|
|
@@ -162,28 +166,37 @@ class ClaudeCodeSetup extends BaseIdeSetup {
|
|
|
162
166
|
const damageControlHooks = [
|
|
163
167
|
{
|
|
164
168
|
matcher: 'Bash',
|
|
165
|
-
hooks: [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
169
|
+
hooks: [
|
|
170
|
+
{
|
|
171
|
+
type: 'command',
|
|
172
|
+
command:
|
|
173
|
+
'node $CLAUDE_PROJECT_DIR/.claude/hooks/damage-control/bash-tool-damage-control.js',
|
|
174
|
+
timeout: 5000,
|
|
175
|
+
},
|
|
176
|
+
],
|
|
170
177
|
},
|
|
171
178
|
{
|
|
172
179
|
matcher: 'Edit',
|
|
173
|
-
hooks: [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
180
|
+
hooks: [
|
|
181
|
+
{
|
|
182
|
+
type: 'command',
|
|
183
|
+
command:
|
|
184
|
+
'node $CLAUDE_PROJECT_DIR/.claude/hooks/damage-control/edit-tool-damage-control.js',
|
|
185
|
+
timeout: 5000,
|
|
186
|
+
},
|
|
187
|
+
],
|
|
178
188
|
},
|
|
179
189
|
{
|
|
180
190
|
matcher: 'Write',
|
|
181
|
-
hooks: [
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
191
|
+
hooks: [
|
|
192
|
+
{
|
|
193
|
+
type: 'command',
|
|
194
|
+
command:
|
|
195
|
+
'node $CLAUDE_PROJECT_DIR/.claude/hooks/damage-control/write-tool-damage-control.js',
|
|
196
|
+
timeout: 5000,
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
},
|
|
187
200
|
];
|
|
188
201
|
|
|
189
202
|
// Merge with existing hooks (don't duplicate)
|
|
@@ -199,8 +212,8 @@ class ClaudeCodeSetup extends BaseIdeSetup {
|
|
|
199
212
|
|
|
200
213
|
// Check if damage control hook already exists
|
|
201
214
|
const dcHook = newHook.hooks[0];
|
|
202
|
-
const hasDcHook = existing.hooks.some(
|
|
203
|
-
h.type === 'command' && h.command && h.command.includes('damage-control')
|
|
215
|
+
const hasDcHook = existing.hooks.some(
|
|
216
|
+
h => h.type === 'command' && h.command && h.command.includes('damage-control')
|
|
204
217
|
);
|
|
205
218
|
|
|
206
219
|
if (!hasDcHook) {
|
|
@@ -9,7 +9,8 @@ const fs = require('fs');
|
|
|
9
9
|
|
|
10
10
|
class Dashboard {
|
|
11
11
|
constructor(options = {}) {
|
|
12
|
-
this.statusPath =
|
|
12
|
+
this.statusPath =
|
|
13
|
+
options.statusPath || path.join(process.cwd(), 'docs', '09-agents', 'status.json');
|
|
13
14
|
this.data = null;
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -29,9 +30,7 @@ class Dashboard {
|
|
|
29
30
|
|
|
30
31
|
getStories() {
|
|
31
32
|
if (!this.data) return [];
|
|
32
|
-
return Object.values(this.data).filter(
|
|
33
|
-
s => s && typeof s === 'object' && (s.id || s.story_id)
|
|
34
|
-
);
|
|
33
|
+
return Object.values(this.data).filter(s => s && typeof s === 'object' && (s.id || s.story_id));
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
getStats() {
|
package/tools/postinstall.js
CHANGED
|
@@ -10,15 +10,7 @@
|
|
|
10
10
|
const { execSync } = require('node:child_process');
|
|
11
11
|
const path = require('node:path');
|
|
12
12
|
const fs = require('node:fs');
|
|
13
|
-
|
|
14
|
-
// ANSI color codes for terminal output
|
|
15
|
-
const colors = {
|
|
16
|
-
green: '\x1b[32m',
|
|
17
|
-
yellow: '\x1b[33m',
|
|
18
|
-
blue: '\x1b[36m',
|
|
19
|
-
dim: '\x1b[2m',
|
|
20
|
-
reset: '\x1b[0m',
|
|
21
|
-
};
|
|
13
|
+
const { c: colors } = require('../lib/colors');
|
|
22
14
|
|
|
23
15
|
function log(message, color = 'reset') {
|
|
24
16
|
console.log(`${colors[color]}${message}${colors.reset}`);
|
|
@@ -1,462 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Set up Visual E2E testing infrastructure with Playwright and screenshot verification
|
|
3
|
-
argument-hint: (no arguments)
|
|
4
|
-
compact_context:
|
|
5
|
-
priority: high
|
|
6
|
-
preserve_rules:
|
|
7
|
-
- "Install Playwright with npx playwright install --with-deps chromium"
|
|
8
|
-
- "Create playwright.config.ts with webServer config for auto-starting dev server"
|
|
9
|
-
- "Create tests/e2e/ directory with example test that takes screenshots"
|
|
10
|
-
- "Create screenshots/ directory for visual verification workflow"
|
|
11
|
-
- "Add test:e2e script to package.json"
|
|
12
|
-
- "All screenshots must be visually reviewed and renamed with 'verified-' prefix"
|
|
13
|
-
- "Use TodoWrite to track all 8 setup steps"
|
|
14
|
-
- "Run example test after setup to verify it works"
|
|
15
|
-
state_fields:
|
|
16
|
-
- playwright_installed
|
|
17
|
-
- config_created
|
|
18
|
-
- example_test_created
|
|
19
|
-
- screenshots_dir_created
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
# setup-visual-e2e
|
|
23
|
-
|
|
24
|
-
Set up Visual E2E testing infrastructure with Playwright and screenshot verification workflow for reliable UI development.
|
|
25
|
-
|
|
26
|
-
---
|
|
27
|
-
|
|
28
|
-
## STEP 0: Gather Context
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
node .agileflow/scripts/obtain-context.js visual-e2e
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
<!-- COMPACT_SUMMARY_START -->
|
|
37
|
-
|
|
38
|
-
## COMPACT SUMMARY - /agileflow:setup:visual-e2e IS ACTIVE
|
|
39
|
-
|
|
40
|
-
**CRITICAL**: You are setting up Visual E2E infrastructure. All 8 steps must complete for working setup.
|
|
41
|
-
|
|
42
|
-
**ROLE**: Visual E2E Infrastructure Bootstrapper - Install Playwright, create config, create example tests with screenshots
|
|
43
|
-
|
|
44
|
-
---
|
|
45
|
-
|
|
46
|
-
### RULE #1: ALWAYS USE TodoWrite FOR 8 STEPS
|
|
47
|
-
|
|
48
|
-
Track all steps explicitly:
|
|
49
|
-
```
|
|
50
|
-
1. Check project has package.json
|
|
51
|
-
2. Install Playwright and dependencies
|
|
52
|
-
3. Create playwright.config.ts with webServer
|
|
53
|
-
4. Create tests/e2e/ directory structure
|
|
54
|
-
5. Create screenshots/ directory
|
|
55
|
-
6. Create example e2e test with screenshot capture
|
|
56
|
-
7. Add test:e2e script to package.json
|
|
57
|
-
8. Run example test to verify setup
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Mark each step complete. This ensures comprehensive setup.
|
|
61
|
-
|
|
62
|
-
---
|
|
63
|
-
|
|
64
|
-
### RULE #2: SCREENSHOT VERIFICATION WORKFLOW
|
|
65
|
-
|
|
66
|
-
**The key insight**: Tests passing doesn't mean UI looks correct.
|
|
67
|
-
|
|
68
|
-
The Visual Mode workflow:
|
|
69
|
-
1. E2E tests capture screenshots during test runs
|
|
70
|
-
2. Claude reviews each screenshot visually
|
|
71
|
-
3. Claude renames verified screenshots with `verified-` prefix
|
|
72
|
-
4. `screenshot-verifier.js` confirms all screenshots are verified
|
|
73
|
-
5. Ralph Loop requires 2+ iterations in Visual Mode
|
|
74
|
-
|
|
75
|
-
**NEVER** declare UI work complete without visually reviewing screenshots.
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
### RULE #3: PLAYWRIGHT CONFIG WITH WEBSERVER
|
|
80
|
-
|
|
81
|
-
Always configure webServer to auto-start dev server:
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
// playwright.config.ts
|
|
85
|
-
export default defineConfig({
|
|
86
|
-
webServer: {
|
|
87
|
-
command: 'npm run dev',
|
|
88
|
-
url: 'http://localhost:3000',
|
|
89
|
-
reuseExistingServer: !process.env.CI,
|
|
90
|
-
timeout: 120000,
|
|
91
|
-
},
|
|
92
|
-
use: {
|
|
93
|
-
baseURL: 'http://localhost:3000',
|
|
94
|
-
screenshot: 'on', // Capture on every test
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
### RULE #4: EXAMPLE TEST WITH SCREENSHOTS
|
|
102
|
-
|
|
103
|
-
Create working example that captures screenshots:
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
// tests/e2e/visual-example.spec.ts
|
|
107
|
-
import { test, expect } from '@playwright/test';
|
|
108
|
-
|
|
109
|
-
test('homepage visual check', async ({ page }) => {
|
|
110
|
-
await page.goto('/');
|
|
111
|
-
|
|
112
|
-
// Capture screenshot for visual verification
|
|
113
|
-
await page.screenshot({
|
|
114
|
-
path: 'screenshots/homepage.png',
|
|
115
|
-
fullPage: true
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
// Basic assertions
|
|
119
|
-
await expect(page).toHaveTitle(/./);
|
|
120
|
-
});
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
### ANTI-PATTERNS (DON'T DO THESE)
|
|
126
|
-
|
|
127
|
-
- Create config without example test
|
|
128
|
-
- Skip screenshots directory creation
|
|
129
|
-
- Forget webServer config (user has to manually start dev server)
|
|
130
|
-
- Skip running tests after setup
|
|
131
|
-
- Declare UI work done without reviewing screenshots
|
|
132
|
-
|
|
133
|
-
### DO THESE INSTEAD
|
|
134
|
-
|
|
135
|
-
- Create config AND working example test with screenshots
|
|
136
|
-
- Create screenshots/ directory in project root
|
|
137
|
-
- Configure webServer to auto-start dev server
|
|
138
|
-
- Run test after setup to verify and generate initial screenshot
|
|
139
|
-
- Review all screenshots visually before completing UI work
|
|
140
|
-
|
|
141
|
-
---
|
|
142
|
-
|
|
143
|
-
### WORKFLOW PHASES
|
|
144
|
-
|
|
145
|
-
**Phase 1: Detection (Step 1)**
|
|
146
|
-
- Check package.json exists
|
|
147
|
-
- Detect dev server command (npm run dev, yarn dev, etc.)
|
|
148
|
-
- Check if Playwright already installed
|
|
149
|
-
|
|
150
|
-
**Phase 2: Installation (Step 2)**
|
|
151
|
-
- Install @playwright/test
|
|
152
|
-
- Install browser with npx playwright install --with-deps chromium
|
|
153
|
-
|
|
154
|
-
**Phase 3: Configuration (Steps 3-5)**
|
|
155
|
-
- Create playwright.config.ts
|
|
156
|
-
- Create tests/e2e/ directory
|
|
157
|
-
- Create screenshots/ directory
|
|
158
|
-
- Add screenshots/ to .gitignore (optional - depends on workflow)
|
|
159
|
-
|
|
160
|
-
**Phase 4: Examples (Step 6)**
|
|
161
|
-
- Create example e2e test with screenshot capture
|
|
162
|
-
- Test should pass immediately
|
|
163
|
-
|
|
164
|
-
**Phase 5: Scripts (Step 7)**
|
|
165
|
-
- Add test:e2e script to package.json
|
|
166
|
-
|
|
167
|
-
**Phase 6: Verification (Step 8)**
|
|
168
|
-
- Run example test
|
|
169
|
-
- Show generated screenshot path
|
|
170
|
-
- Remind about verification workflow
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
### KEY FILES TO REMEMBER
|
|
175
|
-
|
|
176
|
-
| File | Purpose |
|
|
177
|
-
|------|---------|
|
|
178
|
-
| `playwright.config.ts` | Playwright configuration with webServer |
|
|
179
|
-
| `tests/e2e/visual-example.spec.ts` | Example test with screenshots |
|
|
180
|
-
| `screenshots/` | Directory for test screenshots |
|
|
181
|
-
| `scripts/screenshot-verifier.js` | Verify all screenshots have verified- prefix |
|
|
182
|
-
|
|
183
|
-
---
|
|
184
|
-
|
|
185
|
-
### REMEMBER AFTER COMPACTION
|
|
186
|
-
|
|
187
|
-
- `/agileflow:setup:visual-e2e` IS ACTIVE - bootstrap Visual E2E infrastructure
|
|
188
|
-
- Install Playwright with browser dependencies
|
|
189
|
-
- Configure webServer to auto-start dev server
|
|
190
|
-
- Create example test that captures screenshots
|
|
191
|
-
- Create screenshots/ directory
|
|
192
|
-
- Run test after setup to verify
|
|
193
|
-
- Use TodoWrite to track 8 steps
|
|
194
|
-
- Visual Mode = review screenshots + verified- prefix
|
|
195
|
-
|
|
196
|
-
<!-- COMPACT_SUMMARY_END -->
|
|
197
|
-
|
|
198
|
-
## Prompt
|
|
199
|
-
|
|
200
|
-
ROLE: Visual E2E Infrastructure Bootstrapper
|
|
201
|
-
|
|
202
|
-
INPUTS
|
|
203
|
-
DEV_CMD=<command> Dev server command (default: npm run dev)
|
|
204
|
-
PORT=<number> Dev server port (default: 3000)
|
|
205
|
-
BROWSER=chromium Browser to install (default: chromium)
|
|
206
|
-
|
|
207
|
-
ACTIONS
|
|
208
|
-
1) Check project has package.json
|
|
209
|
-
2) Install Playwright and browser dependencies
|
|
210
|
-
3) Create playwright.config.ts with webServer
|
|
211
|
-
4) Create tests/e2e/ directory structure
|
|
212
|
-
5) Create screenshots/ directory
|
|
213
|
-
6) Create example e2e test with screenshot capture
|
|
214
|
-
7) Add test:e2e script to package.json
|
|
215
|
-
8) Run example test to verify setup
|
|
216
|
-
|
|
217
|
-
TODO LIST TRACKING
|
|
218
|
-
**CRITICAL**: Immediately create a todo list using TodoWrite tool to track Visual E2E setup:
|
|
219
|
-
```
|
|
220
|
-
1. Check project has package.json
|
|
221
|
-
2. Install Playwright and browser dependencies
|
|
222
|
-
3. Create playwright.config.ts with webServer
|
|
223
|
-
4. Create tests/e2e/ directory structure
|
|
224
|
-
5. Create screenshots/ directory
|
|
225
|
-
6. Create example e2e test with screenshot capture
|
|
226
|
-
7. Add test:e2e script to package.json
|
|
227
|
-
8. Run example test to verify setup
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
Mark each step complete as you finish it.
|
|
231
|
-
|
|
232
|
-
OBJECTIVE
|
|
233
|
-
Set up Visual E2E testing infrastructure with Playwright and screenshot verification workflow.
|
|
234
|
-
|
|
235
|
-
WHY VISUAL E2E?
|
|
236
|
-
|
|
237
|
-
The problem: **Tests pass but UI is broken.**
|
|
238
|
-
|
|
239
|
-
Functional tests verify behavior but not visual appearance. A button can "work" but be:
|
|
240
|
-
- Wrong color
|
|
241
|
-
- Wrong position
|
|
242
|
-
- Overlapping other elements
|
|
243
|
-
- Missing entirely (replaced by error state)
|
|
244
|
-
|
|
245
|
-
Visual E2E with screenshot verification catches these issues.
|
|
246
|
-
|
|
247
|
-
PLAYWRIGHT CONFIG
|
|
248
|
-
|
|
249
|
-
Create playwright.config.ts:
|
|
250
|
-
```typescript
|
|
251
|
-
import { defineConfig, devices } from '@playwright/test';
|
|
252
|
-
|
|
253
|
-
export default defineConfig({
|
|
254
|
-
testDir: './tests/e2e',
|
|
255
|
-
|
|
256
|
-
// Run tests in parallel
|
|
257
|
-
fullyParallel: true,
|
|
258
|
-
|
|
259
|
-
// Fail the build on CI if you accidentally left test.only
|
|
260
|
-
forbidOnly: !!process.env.CI,
|
|
261
|
-
|
|
262
|
-
// Retry on CI only
|
|
263
|
-
retries: process.env.CI ? 2 : 0,
|
|
264
|
-
|
|
265
|
-
// Opt out of parallel tests on CI
|
|
266
|
-
workers: process.env.CI ? 1 : undefined,
|
|
267
|
-
|
|
268
|
-
// Reporter
|
|
269
|
-
reporter: 'html',
|
|
270
|
-
|
|
271
|
-
use: {
|
|
272
|
-
// Base URL for navigation
|
|
273
|
-
baseURL: 'http://localhost:3000',
|
|
274
|
-
|
|
275
|
-
// Capture screenshot on every test
|
|
276
|
-
screenshot: 'on',
|
|
277
|
-
|
|
278
|
-
// Collect trace on failure
|
|
279
|
-
trace: 'on-first-retry',
|
|
280
|
-
},
|
|
281
|
-
|
|
282
|
-
// Configure webServer to auto-start dev server
|
|
283
|
-
webServer: {
|
|
284
|
-
command: 'npm run dev',
|
|
285
|
-
url: 'http://localhost:3000',
|
|
286
|
-
reuseExistingServer: !process.env.CI,
|
|
287
|
-
timeout: 120000,
|
|
288
|
-
},
|
|
289
|
-
|
|
290
|
-
projects: [
|
|
291
|
-
{
|
|
292
|
-
name: 'chromium',
|
|
293
|
-
use: { ...devices['Desktop Chrome'] },
|
|
294
|
-
},
|
|
295
|
-
],
|
|
296
|
-
});
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
EXAMPLE E2E TEST
|
|
300
|
-
|
|
301
|
-
Create tests/e2e/visual-example.spec.ts:
|
|
302
|
-
```typescript
|
|
303
|
-
import { test, expect } from '@playwright/test';
|
|
304
|
-
|
|
305
|
-
test.describe('Visual Verification Examples', () => {
|
|
306
|
-
test('homepage loads correctly', async ({ page }) => {
|
|
307
|
-
await page.goto('/');
|
|
308
|
-
|
|
309
|
-
// Capture full-page screenshot for visual verification
|
|
310
|
-
await page.screenshot({
|
|
311
|
-
path: 'screenshots/homepage-full.png',
|
|
312
|
-
fullPage: true,
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
// Basic assertions
|
|
316
|
-
await expect(page).toHaveTitle(/./);
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
test('component renders correctly', async ({ page }) => {
|
|
320
|
-
await page.goto('/');
|
|
321
|
-
|
|
322
|
-
// Capture specific element screenshot
|
|
323
|
-
const header = page.locator('header').first();
|
|
324
|
-
if (await header.isVisible()) {
|
|
325
|
-
await header.screenshot({
|
|
326
|
-
path: 'screenshots/header-component.png',
|
|
327
|
-
});
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// Verify element is visible
|
|
331
|
-
await expect(header).toBeVisible();
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
DIRECTORY STRUCTURE
|
|
337
|
-
|
|
338
|
-
Create:
|
|
339
|
-
```
|
|
340
|
-
tests/
|
|
341
|
-
└── e2e/
|
|
342
|
-
├── visual-example.spec.ts # Example test with screenshots
|
|
343
|
-
└── fixtures/ # Test data if needed
|
|
344
|
-
|
|
345
|
-
screenshots/ # Screenshot output directory
|
|
346
|
-
├── homepage-full.png # After test runs
|
|
347
|
-
└── verified-homepage-full.png # After Claude reviews
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
NPM SCRIPTS
|
|
351
|
-
|
|
352
|
-
Add to package.json:
|
|
353
|
-
```json
|
|
354
|
-
{
|
|
355
|
-
"scripts": {
|
|
356
|
-
"test:e2e": "playwright test",
|
|
357
|
-
"test:e2e:ui": "playwright test --ui",
|
|
358
|
-
"test:e2e:headed": "playwright test --headed"
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
```
|
|
362
|
-
|
|
363
|
-
INSTALLATION
|
|
364
|
-
|
|
365
|
-
```bash
|
|
366
|
-
# Install Playwright
|
|
367
|
-
npm install --save-dev @playwright/test
|
|
368
|
-
|
|
369
|
-
# Install browser (chromium is smallest)
|
|
370
|
-
npx playwright install --with-deps chromium
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
VISUAL VERIFICATION WORKFLOW
|
|
374
|
-
|
|
375
|
-
After running tests:
|
|
376
|
-
|
|
377
|
-
1. **Review screenshots**: Claude reads each screenshot in screenshots/
|
|
378
|
-
2. **Verify visually**: Check that UI looks correct
|
|
379
|
-
3. **Rename verified**: `mv screenshots/homepage.png screenshots/verified-homepage.png`
|
|
380
|
-
4. **Run verifier**: `node scripts/screenshot-verifier.js --path ./screenshots`
|
|
381
|
-
|
|
382
|
-
This ensures Claude actually looked at each screenshot before declaring completion.
|
|
383
|
-
|
|
384
|
-
INTEGRATION WITH RALPH LOOP
|
|
385
|
-
|
|
386
|
-
When using Visual Mode in Ralph Loop:
|
|
387
|
-
```bash
|
|
388
|
-
# Initialize loop with Visual Mode
|
|
389
|
-
node scripts/ralph-loop.js --init --epic=EP-XXXX --visual
|
|
390
|
-
|
|
391
|
-
# Loop checks:
|
|
392
|
-
# 1. npm test passes
|
|
393
|
-
# 2. All screenshots have verified- prefix
|
|
394
|
-
# 3. Minimum 2 iterations completed
|
|
395
|
-
```
|
|
396
|
-
|
|
397
|
-
Visual Mode prevents premature completion promises for UI work.
|
|
398
|
-
|
|
399
|
-
WORKFLOW
|
|
400
|
-
|
|
401
|
-
1. Check for package.json
|
|
402
|
-
2. Show proposed setup plan:
|
|
403
|
-
```
|
|
404
|
-
Will install:
|
|
405
|
-
- @playwright/test
|
|
406
|
-
- chromium browser (~300MB)
|
|
407
|
-
|
|
408
|
-
Will create:
|
|
409
|
-
- playwright.config.ts (with webServer config)
|
|
410
|
-
- tests/e2e/visual-example.spec.ts
|
|
411
|
-
- screenshots/ directory
|
|
412
|
-
|
|
413
|
-
Will update:
|
|
414
|
-
- package.json (add test:e2e scripts)
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
3. Ask: "Proceed with Visual E2E setup? (YES/NO)"
|
|
418
|
-
|
|
419
|
-
4. If YES:
|
|
420
|
-
- Run installations
|
|
421
|
-
- Create config files
|
|
422
|
-
- Create example test
|
|
423
|
-
- Run test to verify setup
|
|
424
|
-
|
|
425
|
-
5. Show results:
|
|
426
|
-
```
|
|
427
|
-
Visual E2E Setup Complete
|
|
428
|
-
|
|
429
|
-
Installed:
|
|
430
|
-
- @playwright/test
|
|
431
|
-
- chromium browser
|
|
432
|
-
|
|
433
|
-
Created:
|
|
434
|
-
- playwright.config.ts
|
|
435
|
-
- tests/e2e/visual-example.spec.ts
|
|
436
|
-
- screenshots/
|
|
437
|
-
|
|
438
|
-
Try running:
|
|
439
|
-
- npm run test:e2e # Run tests
|
|
440
|
-
- npm run test:e2e:headed # Watch tests run
|
|
441
|
-
|
|
442
|
-
Visual Mode workflow:
|
|
443
|
-
1. Run tests: npm run test:e2e
|
|
444
|
-
2. Review screenshots in screenshots/
|
|
445
|
-
3. Rename verified: mv file.png verified-file.png
|
|
446
|
-
4. Verify all: node scripts/screenshot-verifier.js
|
|
447
|
-
```
|
|
448
|
-
|
|
449
|
-
RULES
|
|
450
|
-
- Preview all changes (diff-first, YES/NO)
|
|
451
|
-
- Run test after setup to verify and generate screenshots
|
|
452
|
-
- Configure webServer to auto-start dev server
|
|
453
|
-
- Create working example test with screenshot capture
|
|
454
|
-
- Use chromium only (smallest browser, ~300MB)
|
|
455
|
-
- Remind about verification workflow after setup
|
|
456
|
-
|
|
457
|
-
OUTPUT
|
|
458
|
-
- Setup summary
|
|
459
|
-
- Playwright configuration with webServer
|
|
460
|
-
- Example E2E test with screenshot capture
|
|
461
|
-
- Screenshots directory
|
|
462
|
-
- Instructions for Visual Mode workflow
|