@fredcallagan/arn-spark 5.1.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/.claude-plugin/plugin.json +9 -0
- package/.opencode/plugins/arn-spark.js +272 -0
- package/package.json +17 -0
- package/plugins/arn-spark/.claude-plugin/plugin.json +9 -0
- package/plugins/arn-spark/LICENSE +21 -0
- package/plugins/arn-spark/README.md +25 -0
- package/plugins/arn-spark/agents/arn-spark-brand-strategist.md +299 -0
- package/plugins/arn-spark/agents/arn-spark-dev-env-builder.md +228 -0
- package/plugins/arn-spark/agents/arn-spark-doctor.md +92 -0
- package/plugins/arn-spark/agents/arn-spark-forensic-investigator.md +181 -0
- package/plugins/arn-spark/agents/arn-spark-market-researcher.md +232 -0
- package/plugins/arn-spark/agents/arn-spark-marketing-pm.md +225 -0
- package/plugins/arn-spark/agents/arn-spark-persona-architect.md +259 -0
- package/plugins/arn-spark/agents/arn-spark-persona-impersonator.md +183 -0
- package/plugins/arn-spark/agents/arn-spark-product-strategist.md +191 -0
- package/plugins/arn-spark/agents/arn-spark-prototype-builder.md +497 -0
- package/plugins/arn-spark/agents/arn-spark-scaffolder.md +228 -0
- package/plugins/arn-spark/agents/arn-spark-spike-runner.md +209 -0
- package/plugins/arn-spark/agents/arn-spark-style-capture.md +196 -0
- package/plugins/arn-spark/agents/arn-spark-tech-evaluator.md +229 -0
- package/plugins/arn-spark/agents/arn-spark-ui-interactor.md +235 -0
- package/plugins/arn-spark/agents/arn-spark-use-case-writer.md +280 -0
- package/plugins/arn-spark/agents/arn-spark-ux-judge.md +215 -0
- package/plugins/arn-spark/agents/arn-spark-ux-specialist.md +200 -0
- package/plugins/arn-spark/agents/arn-spark-visual-sketcher.md +285 -0
- package/plugins/arn-spark/agents/arn-spark-visual-test-engineer.md +224 -0
- package/plugins/arn-spark/references/copilot-tools.md +62 -0
- package/plugins/arn-spark/skills/arn-brainstorming/SKILL.md +520 -0
- package/plugins/arn-spark/skills/arn-brainstorming/references/add-feature-flow.md +155 -0
- package/plugins/arn-spark/skills/arn-spark-arch-vision/SKILL.md +226 -0
- package/plugins/arn-spark/skills/arn-spark-arch-vision/references/architecture-vision-template.md +153 -0
- package/plugins/arn-spark/skills/arn-spark-arch-vision/references/technology-evaluation-guide.md +86 -0
- package/plugins/arn-spark/skills/arn-spark-clickable-prototype/SKILL.md +471 -0
- package/plugins/arn-spark/skills/arn-spark-clickable-prototype/references/clickable-prototype-criteria.md +65 -0
- package/plugins/arn-spark/skills/arn-spark-clickable-prototype/references/journey-template.md +62 -0
- package/plugins/arn-spark/skills/arn-spark-clickable-prototype/references/review-report-template.md +75 -0
- package/plugins/arn-spark/skills/arn-spark-clickable-prototype/references/showcase-capture-guide.md +213 -0
- package/plugins/arn-spark/skills/arn-spark-clickable-prototype-teams/SKILL.md +642 -0
- package/plugins/arn-spark/skills/arn-spark-clickable-prototype-teams/references/debate-protocol.md +242 -0
- package/plugins/arn-spark/skills/arn-spark-clickable-prototype-teams/references/debate-review-report-template.md +161 -0
- package/plugins/arn-spark/skills/arn-spark-clickable-prototype-teams/references/expert-interaction-review-template.md +152 -0
- package/plugins/arn-spark/skills/arn-spark-concept-review/SKILL.md +350 -0
- package/plugins/arn-spark/skills/arn-spark-concept-review/references/conflict-resolution-protocol.md +145 -0
- package/plugins/arn-spark/skills/arn-spark-concept-review/references/review-report-template.md +185 -0
- package/plugins/arn-spark/skills/arn-spark-dev-setup/SKILL.md +366 -0
- package/plugins/arn-spark/skills/arn-spark-dev-setup/references/dev-setup-checklist.md +84 -0
- package/plugins/arn-spark/skills/arn-spark-dev-setup/references/dev-setup-template.md +205 -0
- package/plugins/arn-spark/skills/arn-spark-discover/SKILL.md +303 -0
- package/plugins/arn-spark/skills/arn-spark-discover/references/competitive-landscape-template.md +87 -0
- package/plugins/arn-spark/skills/arn-spark-discover/references/discovery-questions.md +120 -0
- package/plugins/arn-spark/skills/arn-spark-discover/references/persona-profile-template.md +97 -0
- package/plugins/arn-spark/skills/arn-spark-discover/references/product-concept-template.md +253 -0
- package/plugins/arn-spark/skills/arn-spark-ensure-config/SKILL.md +23 -0
- package/plugins/arn-spark/skills/arn-spark-ensure-config/references/ensure-config.md +388 -0
- package/plugins/arn-spark/skills/arn-spark-ensure-config/references/step-0-fast-path.md +25 -0
- package/plugins/arn-spark/skills/arn-spark-ensure-config/scripts/cache-check.sh +127 -0
- package/plugins/arn-spark/skills/arn-spark-feature-extract/SKILL.md +483 -0
- package/plugins/arn-spark/skills/arn-spark-feature-extract/references/feature-backlog-template.md +176 -0
- package/plugins/arn-spark/skills/arn-spark-feature-extract/references/feature-entry-template.md +209 -0
- package/plugins/arn-spark/skills/arn-spark-help/SKILL.md +149 -0
- package/plugins/arn-spark/skills/arn-spark-help/references/pipeline-map.md +211 -0
- package/plugins/arn-spark/skills/arn-spark-init/SKILL.md +312 -0
- package/plugins/arn-spark/skills/arn-spark-init/references/agent-models-presets/all-opus.md +23 -0
- package/plugins/arn-spark/skills/arn-spark-init/references/agent-models-presets/balanced.md +23 -0
- package/plugins/arn-spark/skills/arn-spark-init/references/bkt-setup.md +55 -0
- package/plugins/arn-spark/skills/arn-spark-init/references/jira-mcp-setup.md +61 -0
- package/plugins/arn-spark/skills/arn-spark-init/references/platform-labels.md +97 -0
- package/plugins/arn-spark/skills/arn-spark-naming/SKILL.md +275 -0
- package/plugins/arn-spark/skills/arn-spark-naming/references/creative-brief-template.md +146 -0
- package/plugins/arn-spark/skills/arn-spark-naming/references/naming-methodology.md +237 -0
- package/plugins/arn-spark/skills/arn-spark-naming/references/naming-report-template.md +122 -0
- package/plugins/arn-spark/skills/arn-spark-naming/references/trademark-databases.md +88 -0
- package/plugins/arn-spark/skills/arn-spark-naming/references/whois-server-map.md +164 -0
- package/plugins/arn-spark/skills/arn-spark-naming/scripts/whois-check.js +502 -0
- package/plugins/arn-spark/skills/arn-spark-naming/scripts/whois-check.py +533 -0
- package/plugins/arn-spark/skills/arn-spark-prototype-lock/SKILL.md +260 -0
- package/plugins/arn-spark/skills/arn-spark-prototype-lock/references/lock-report-template.md +68 -0
- package/plugins/arn-spark/skills/arn-spark-prototype-lock/references/pretooluse-hook-template.json +35 -0
- package/plugins/arn-spark/skills/arn-spark-prototype-lock/references/prototype-guardrail-rules.md +38 -0
- package/plugins/arn-spark/skills/arn-spark-report/SKILL.md +144 -0
- package/plugins/arn-spark/skills/arn-spark-report/references/issue-template.md +81 -0
- package/plugins/arn-spark/skills/arn-spark-report/references/spark-knowledge-base.md +293 -0
- package/plugins/arn-spark/skills/arn-spark-scaffold/SKILL.md +239 -0
- package/plugins/arn-spark/skills/arn-spark-scaffold/references/scaffold-checklist.md +79 -0
- package/plugins/arn-spark/skills/arn-spark-scaffold/references/scaffold-summary-template.md +74 -0
- package/plugins/arn-spark/skills/arn-spark-spike/SKILL.md +209 -0
- package/plugins/arn-spark/skills/arn-spark-spike/references/spike-report-template.md +123 -0
- package/plugins/arn-spark/skills/arn-spark-static-prototype/SKILL.md +362 -0
- package/plugins/arn-spark/skills/arn-spark-static-prototype/references/review-report-template.md +65 -0
- package/plugins/arn-spark/skills/arn-spark-static-prototype/references/showcase-capture-guide.md +153 -0
- package/plugins/arn-spark/skills/arn-spark-static-prototype/references/static-prototype-criteria.md +54 -0
- package/plugins/arn-spark/skills/arn-spark-static-prototype-teams/SKILL.md +518 -0
- package/plugins/arn-spark/skills/arn-spark-static-prototype-teams/references/debate-protocol.md +230 -0
- package/plugins/arn-spark/skills/arn-spark-static-prototype-teams/references/debate-review-report-template.md +148 -0
- package/plugins/arn-spark/skills/arn-spark-static-prototype-teams/references/expert-visual-review-template.md +130 -0
- package/plugins/arn-spark/skills/arn-spark-stress-competitive/SKILL.md +166 -0
- package/plugins/arn-spark/skills/arn-spark-stress-competitive/references/competitive-report-template.md +139 -0
- package/plugins/arn-spark/skills/arn-spark-stress-competitive/references/gap-analysis-framework.md +111 -0
- package/plugins/arn-spark/skills/arn-spark-stress-interview/SKILL.md +257 -0
- package/plugins/arn-spark/skills/arn-spark-stress-interview/references/interview-protocol.md +140 -0
- package/plugins/arn-spark/skills/arn-spark-stress-interview/references/interview-report-template.md +165 -0
- package/plugins/arn-spark/skills/arn-spark-stress-interview/references/persona-casting-spec.md +138 -0
- package/plugins/arn-spark/skills/arn-spark-stress-premortem/SKILL.md +181 -0
- package/plugins/arn-spark/skills/arn-spark-stress-premortem/references/premortem-protocol.md +112 -0
- package/plugins/arn-spark/skills/arn-spark-stress-premortem/references/premortem-report-template.md +158 -0
- package/plugins/arn-spark/skills/arn-spark-stress-prfaq/SKILL.md +206 -0
- package/plugins/arn-spark/skills/arn-spark-stress-prfaq/references/prfaq-report-template.md +139 -0
- package/plugins/arn-spark/skills/arn-spark-stress-prfaq/references/prfaq-workflow.md +118 -0
- package/plugins/arn-spark/skills/arn-spark-style-explore/SKILL.md +281 -0
- package/plugins/arn-spark/skills/arn-spark-style-explore/references/style-brief-template.md +198 -0
- package/plugins/arn-spark/skills/arn-spark-use-cases/SKILL.md +359 -0
- package/plugins/arn-spark/skills/arn-spark-use-cases/references/expert-review-template.md +94 -0
- package/plugins/arn-spark/skills/arn-spark-use-cases/references/review-protocol.md +150 -0
- package/plugins/arn-spark/skills/arn-spark-use-cases/references/use-case-index-template.md +108 -0
- package/plugins/arn-spark/skills/arn-spark-use-cases/references/use-case-template.md +125 -0
- package/plugins/arn-spark/skills/arn-spark-use-cases-teams/SKILL.md +306 -0
- package/plugins/arn-spark/skills/arn-spark-use-cases-teams/references/debate-protocol.md +272 -0
- package/plugins/arn-spark/skills/arn-spark-use-cases-teams/references/review-report-template.md +112 -0
- package/plugins/arn-spark/skills/arn-spark-visual-readiness/SKILL.md +293 -0
- package/plugins/arn-spark/skills/arn-spark-visual-readiness/references/readiness-checklist.md +196 -0
- package/plugins/arn-spark/skills/arn-spark-visual-sketch/SKILL.md +376 -0
- package/plugins/arn-spark/skills/arn-spark-visual-sketch/references/aesthetic-philosophy.md +210 -0
- package/plugins/arn-spark/skills/arn-spark-visual-sketch/references/sketch-gallery-guide.md +282 -0
- package/plugins/arn-spark/skills/arn-spark-visual-sketch/references/visual-direction-template.md +174 -0
- package/plugins/arn-spark/skills/arn-spark-visual-strategy/SKILL.md +447 -0
- package/plugins/arn-spark/skills/arn-spark-visual-strategy/references/baseline-capture-script-template.js +89 -0
- package/plugins/arn-spark/skills/arn-spark-visual-strategy/references/journey-schema.md +375 -0
- package/plugins/arn-spark/skills/arn-spark-visual-strategy/references/spike-checklist.md +122 -0
- package/plugins/arn-spark/skills/arn-spark-visual-strategy/references/strategy-layers-guide.md +132 -0
- package/plugins/arn-spark/skills/arn-spark-visual-strategy/references/visual-strategy-template.md +141 -0
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: arn-spark-visual-strategy
|
|
3
|
+
description: >-
|
|
4
|
+
This skill should be used when the user says "visual strategy",
|
|
5
|
+
"arn visual strategy", "visual testing", "visual regression",
|
|
6
|
+
"screenshot testing", "compare to prototype", "visual validation",
|
|
7
|
+
"how do I test visuals", "set up visual tests", "baseline images",
|
|
8
|
+
"screenshot comparison", "pixel diff", "visual diff",
|
|
9
|
+
"does it match the prototype",
|
|
10
|
+
or wants to set up visual regression testing for development — creating
|
|
11
|
+
capture scripts, comparison scripts, and baseline images so that feature
|
|
12
|
+
implementations are automatically compared against prototype screenshots
|
|
13
|
+
to catch visual regressions during development.
|
|
14
|
+
version: 1.0.0
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Arness Visual Strategy
|
|
18
|
+
|
|
19
|
+
Set up automated visual regression testing so that **during feature development**, each implemented screen can be compared pixel-by-pixel against the approved prototype screenshots. The prototype screenshots serve as **baseline images** — the "gold standard" of what the UI should look like. As features are built, capture scripts take screenshots of the development build and comparison scripts diff them against these baselines, catching layout breaks, color mismatches, and misplaced elements before they reach the user.
|
|
20
|
+
|
|
21
|
+
This is a conversational skill that runs in normal conversation (NOT plan mode). It uses the `arn-spark-visual-test-engineer` agent for proof-of-concept validation and script generation.
|
|
22
|
+
|
|
23
|
+
The primary artifacts are:
|
|
24
|
+
- **Capture script** — takes screenshots of the development build (NOT the prototype)
|
|
25
|
+
- **Comparison script** — diffs development screenshots against prototype baselines
|
|
26
|
+
- **Baseline images** — copied from prototype screenshots, used as the reference standard
|
|
27
|
+
- **arness.md configuration** — integrates visual testing into the Arness execution pipeline so that `/arn-code-execute-plan` and `/arn-code-execute-task` automatically validate UI changes
|
|
28
|
+
|
|
29
|
+
**The core problem this solves:** during feature development, visual regressions (button on the wrong side, layout breaks, color mismatches) go undetected until the user manually inspects the application. This skill sets up the tooling so that every UI task automatically compares the development build against the prototype.
|
|
30
|
+
|
|
31
|
+
## Prerequisites
|
|
32
|
+
|
|
33
|
+
Read the project's `arness.md` for a `## Arness` section. If no `## Arness` section exists or Arness Spark fields are missing, inform the user: "Arness Spark is not configured for this project yet. Run `/arn-brainstorming` to get started — it will set everything up automatically." Do not proceed without it.
|
|
34
|
+
|
|
35
|
+
Extract:
|
|
36
|
+
- **Vision directory** (default: `.arness/vision`)
|
|
37
|
+
- **Prototypes directory** (default: `.arness/prototypes`)
|
|
38
|
+
- **Spikes directory** (default: `.arness/spikes`) -- for mini-spike workspaces
|
|
39
|
+
- **Git** / **Platform**
|
|
40
|
+
|
|
41
|
+
Check for prototype lock (strongly recommended):
|
|
42
|
+
1. Check for `### Prototype Lock` in the `## Arness` section
|
|
43
|
+
2. If found: read the locked directory path and the `LOCKED.md` manifest
|
|
44
|
+
3. If NOT found: warn the user -- "No prototype lock detected. Visual testing compares against the prototype, but the prototype is not currently protected from modification. Consider running `/arn-spark-prototype-lock` first."
|
|
45
|
+
|
|
46
|
+
Check for prototype validation evidence:
|
|
47
|
+
- `[prototypes-dir]/clickable/final-report.md`
|
|
48
|
+
- `[prototypes-dir]/static/final-report.md`
|
|
49
|
+
- Scan for showcase screenshots: `[prototypes-dir]/clickable/v[N]/showcase/screens/`, journey screenshots, static showcase screenshots
|
|
50
|
+
|
|
51
|
+
Check for architecture vision (required for stack analysis):
|
|
52
|
+
- Read `architecture-vision.md` for framework, application type, platform targets
|
|
53
|
+
|
|
54
|
+
Check for dev-setup document (for environment constraints):
|
|
55
|
+
- Read `dev-setup.md` for development environment type, platforms, and CI configuration
|
|
56
|
+
|
|
57
|
+
**If no architecture vision:** "No architecture vision found. Describe your technology stack and target platforms so I can design a visual testing strategy."
|
|
58
|
+
|
|
59
|
+
**If no prototype screenshots:** "No prototype screenshots found. Visual testing needs reference images. Either run the prototype skills first, or provide screenshots manually."
|
|
60
|
+
|
|
61
|
+
## Workflow
|
|
62
|
+
|
|
63
|
+
### Step 1: Analyze the Stack and Environment
|
|
64
|
+
|
|
65
|
+
Load context from architecture vision, dev-setup, and the current environment. Detect the current OS via `uname`. Build a constraints profile:
|
|
66
|
+
|
|
67
|
+
"Here is what I understand about your stack and environment:
|
|
68
|
+
|
|
69
|
+
**Application type:** [Browser app / Tauri desktop / Electron desktop / etc.]
|
|
70
|
+
**UI framework:** [SvelteKit / React / Vue / etc.]
|
|
71
|
+
**Rendering context:** [Browser viewport / Webview in native frame / Native window with transparency / etc.]
|
|
72
|
+
**Platform targets:** [Linux, macOS, Windows]
|
|
73
|
+
**Development environment:** [Native / WSL2 / Dev container / etc.]
|
|
74
|
+
**Current OS:** [detected via uname]
|
|
75
|
+
|
|
76
|
+
**Key constraints:**
|
|
77
|
+
- [Constraint 1: e.g., 'Tauri with transparency -- native window compositing cannot be captured by browser-based tools']
|
|
78
|
+
- [Constraint 2: e.g., 'WSL2 development -- no native Windows display server access from WSL2']
|
|
79
|
+
- [Constraint 3: e.g., 'Webview content IS accessible via standard HTTP -- Playwright can connect to the dev server']
|
|
80
|
+
|
|
81
|
+
Is this accurate? Anything to add or correct?"
|
|
82
|
+
|
|
83
|
+
Wait for user confirmation.
|
|
84
|
+
|
|
85
|
+
### Step 2: Propose Layered Testing Strategy
|
|
86
|
+
|
|
87
|
+
Based on the constraints profile, propose a multi-layer strategy. Read the strategy layers guide:
|
|
88
|
+
> Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-spark-visual-strategy/references/strategy-layers-guide.md`
|
|
89
|
+
|
|
90
|
+
Match the project's application type against the Layer Decision Matrix to determine the recommended layers. Present the layered approach:
|
|
91
|
+
|
|
92
|
+
"Based on your stack, here is a layered visual testing strategy:
|
|
93
|
+
|
|
94
|
+
**Layer 1: [Name] (Recommended first)**
|
|
95
|
+
- **What it captures:** [e.g., 'Webview content rendered in a browser via Playwright against the dev server']
|
|
96
|
+
- **Coverage:** [e.g., 'All web UI content -- layouts, components, typography, colors. Does NOT capture native window chrome, transparency, or system-level rendering.']
|
|
97
|
+
- **Environment:** [e.g., 'Runs anywhere Playwright runs -- WSL2, CI, macOS, Linux native']
|
|
98
|
+
- **Complexity:** [Low / Medium / High]
|
|
99
|
+
- **Trade-off:** [e.g., 'Fast and reliable but misses native window integration. A button on the wrong side WILL be caught; transparency blending WILL NOT.']
|
|
100
|
+
|
|
101
|
+
**Layer 2: [Name] (Optional, fills gaps)**
|
|
102
|
+
- **What it captures:** [e.g., 'Full native window screenshot including transparency, title bar, system tray integration']
|
|
103
|
+
- **Coverage:** [e.g., 'Everything visible on screen including OS chrome and compositor effects']
|
|
104
|
+
- **Environment:** [e.g., 'Requires the target OS natively -- for Tauri Windows apps, needs a Windows machine or CI runner']
|
|
105
|
+
- **Complexity:** [Medium / High]
|
|
106
|
+
- **Trade-off:** [e.g., 'Comprehensive but requires cross-environment pipeline. Screenshots depend on OS version, display scaling, and compositor.']
|
|
107
|
+
|
|
108
|
+
[Layer 3 if applicable]
|
|
109
|
+
|
|
110
|
+
**My recommendation:** Start with Layer 1. It catches 80-90% of visual regressions (layout, component rendering, color, typography) with minimal infrastructure. Add Layer 2 when you need to validate native integration or transparency.
|
|
111
|
+
|
|
112
|
+
Ask the user:
|
|
113
|
+
|
|
114
|
+
**"Which layers do you want to set up?"**
|
|
115
|
+
|
|
116
|
+
Options (based on the layers presented above, e.g.):
|
|
117
|
+
1. **Layer 1 only** (Recommended) — Start with browser-based capture
|
|
118
|
+
2. **Layer 1 + Layer 2** — Browser-based capture plus native window capture"
|
|
119
|
+
|
|
120
|
+
**Journey interaction detection (Layer 2 only):**
|
|
121
|
+
|
|
122
|
+
If Layer 2 is selected, check whether journey interaction testing is appropriate:
|
|
123
|
+
- Does the prototype have multiple routes or navigation flows?
|
|
124
|
+
- Does the implementation include interactive sequences (login, form submission, multi-step wizards)?
|
|
125
|
+
- Are there state transitions that static screenshots would miss?
|
|
126
|
+
|
|
127
|
+
If any of these conditions apply, ask the user:
|
|
128
|
+
|
|
129
|
+
Inform the user: "Layer 2 can capture static screenshots (current behavior) or walk through the app like a user using journey-based interaction testing (via UI automation APIs). Journey mode captures screenshots at each step of a user flow — login, navigation, form submission, etc."
|
|
130
|
+
|
|
131
|
+
Ask the user:
|
|
132
|
+
|
|
133
|
+
**"Do you want to enable journey interaction for Layer 2?"**
|
|
134
|
+
|
|
135
|
+
Options:
|
|
136
|
+
1. **Yes** — Enable journey-based interaction testing
|
|
137
|
+
2. **No** — Keep static screenshot capture
|
|
138
|
+
|
|
139
|
+
Record the user's choice:
|
|
140
|
+
- If yes: set `Interaction: journey` for Layer 2
|
|
141
|
+
- If no or if none of the conditions apply: set `Interaction: static` for Layer 2
|
|
142
|
+
- If the user is unsure: default to `static` and note that they can upgrade later via `arn-spark-visual-readiness`
|
|
143
|
+
|
|
144
|
+
For each selected layer that cannot be validated in the current environment (e.g., native capture from WSL2, CI-only capture):
|
|
145
|
+
|
|
146
|
+
"Layer [N] ([Name]) cannot be validated in this environment. When should it be activated?
|
|
147
|
+
|
|
148
|
+
Examples:
|
|
149
|
+
- 'After first successful build on the target platform'
|
|
150
|
+
- 'After the first feature is implemented and the app runs natively'
|
|
151
|
+
- 'When CI is configured with the required OS matrix runner'
|
|
152
|
+
|
|
153
|
+
Activation criteria for Layer [N]:"
|
|
154
|
+
|
|
155
|
+
Wait for user input. Record the activation criteria text for each deferred layer.
|
|
156
|
+
|
|
157
|
+
### Step 3: Define Baseline Sources
|
|
158
|
+
|
|
159
|
+
Map prototype screenshots to visual test baselines. Scan for available screenshots:
|
|
160
|
+
- Clickable prototype showcase: `[prototypes-dir]/clickable/v[N]/showcase/screens/`
|
|
161
|
+
- Journey captures: `[prototypes-dir]/clickable/v[N]/journeys/`
|
|
162
|
+
- Static prototype showcase: `[prototypes-dir]/static/v[M]/showcase/`
|
|
163
|
+
- Locked prototype (if available): `[prototypes-dir]/locked/clickable-v[N]/`
|
|
164
|
+
|
|
165
|
+
If using locked prototype, prefer those screenshots as they are guaranteed stable.
|
|
166
|
+
|
|
167
|
+
Present the baseline sources:
|
|
168
|
+
|
|
169
|
+
"I found these prototype screenshots that can serve as baselines:
|
|
170
|
+
|
|
171
|
+
**From clickable prototype showcase (v[N]):**
|
|
172
|
+
| Screen | Route | Screenshot | Baseline category |
|
|
173
|
+
|--------|-------|------------|-------------------|
|
|
174
|
+
| [Name] | [/route] | [path] | Layout reference |
|
|
175
|
+
| ... | ... | ... | ... |
|
|
176
|
+
|
|
177
|
+
**From journey captures (v[N]):**
|
|
178
|
+
| Journey | Step | Screenshot | Baseline category |
|
|
179
|
+
|---------|------|------------|-------------------|
|
|
180
|
+
| [Name] | [step] | [path] | Flow reference |
|
|
181
|
+
| ... | ... | ... | ... |
|
|
182
|
+
|
|
183
|
+
**From static prototype showcase (v[M]):**
|
|
184
|
+
| Section | Component | Screenshot | Baseline category |
|
|
185
|
+
|---------|-----------|------------|-------------------|
|
|
186
|
+
| [Name] | [variants] | [path] | Component reference |
|
|
187
|
+
| ... | ... | ... | ... |
|
|
188
|
+
|
|
189
|
+
Ask the user:
|
|
190
|
+
|
|
191
|
+
**"How should I organize the baselines?"**
|
|
192
|
+
|
|
193
|
+
Options:
|
|
194
|
+
1. **Screen-based** — One baseline per screen (matches clickable showcase)
|
|
195
|
+
2. **Journey-based** — One set per user journey (matches journey captures)
|
|
196
|
+
3. **Both** — Screen-level baselines for layout + journey baselines for flow
|
|
197
|
+
4. **Custom** — You specify the mapping"
|
|
198
|
+
|
|
199
|
+
### Step 4: Validate Strategy with Mini-Spike (Per Layer)
|
|
200
|
+
|
|
201
|
+
For each selected layer, run a proof-of-concept. This follows the arn-spark-spike pattern: one mini-spike per layer.
|
|
202
|
+
|
|
203
|
+
**IMPORTANT: Run spikes sequentially, one at a time.** Do NOT launch multiple visual-test-engineer agents in parallel or in the background. The agent needs Bash and Write tool access, which requires user permission approval. Parallel or background agents cannot surface permission prompts to the user, causing all tool calls to be denied.
|
|
204
|
+
|
|
205
|
+
"I will validate each testing layer with a mini-spike to confirm the capture and comparison tooling works in your environment:
|
|
206
|
+
|
|
207
|
+
**Spike: Layer 1 -- [Layer Name]**
|
|
208
|
+
- Create a proof-of-concept capture script
|
|
209
|
+
- Run it against the dev server (or the prototype as a convenient test target) to verify the tooling captures screenshots correctly
|
|
210
|
+
- Compare a captured screenshot against a prototype baseline to verify the comparison tooling works
|
|
211
|
+
- Report whether the tooling is viable for development-time use
|
|
212
|
+
|
|
213
|
+
The spike validates the **tooling**, not the prototype. The prototype is just a convenient target because it already has known-good screenshots to compare against.
|
|
214
|
+
|
|
215
|
+
Ready to proceed?"
|
|
216
|
+
|
|
217
|
+
For each layer:
|
|
218
|
+
|
|
219
|
+
1. Read the spike checklist:
|
|
220
|
+
> Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-spark-visual-strategy/references/spike-checklist.md`
|
|
221
|
+
|
|
222
|
+
2. Read the capture script template:
|
|
223
|
+
> Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-spark-visual-strategy/references/baseline-capture-script-template.js`
|
|
224
|
+
|
|
225
|
+
3. Determine the spike workspace: `[spikes-dir]/visual-strategy-spike-layer-[N]/`
|
|
226
|
+
|
|
227
|
+
4. Invoke the `arn-spark-visual-test-engineer` agent via the Task tool (foreground, not background), passing the model from `.arness/agent-models/spark.md` as the `model` parameter (see `plugins/arn-spark/skills/arn-spark-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context:
|
|
228
|
+
- Stack details (application type, framework, rendering context)
|
|
229
|
+
- Layer specification (what approach to validate)
|
|
230
|
+
- Environment constraints
|
|
231
|
+
- Dev server URL or prototype URL (as a convenient test target for validating the capture tooling)
|
|
232
|
+
- Workspace path
|
|
233
|
+
- Baseline screenshots for comparison (if available)
|
|
234
|
+
- Capture script template as a starting point
|
|
235
|
+
- Spike checklist criteria for this layer
|
|
236
|
+
|
|
237
|
+
**Additional context for journey interaction spikes:**
|
|
238
|
+
|
|
239
|
+
If the layer has `Interaction: journey`, provide additional context to the `arn-spark-visual-test-engineer` agent:
|
|
240
|
+
- Include the journey schema reference: `${CLAUDE_PLUGIN_ROOT}/skills/arn-spark-visual-strategy/references/journey-schema.md`
|
|
241
|
+
- Request accessibility tree inspection: agent should verify that the target application exposes automation IDs on key interactive elements
|
|
242
|
+
- Request minimal journey execution test: agent should generate at least one journey and execute it in dry-run mode (or full execution if app is running)
|
|
243
|
+
- For macOS targets: agent should check Accessibility permissions and prompt the user to grant them if not already granted
|
|
244
|
+
|
|
245
|
+
The spike must validate journey readiness in addition to the standard Layer 2 spike criteria. See `spike-checklist.md` in this directory for the "Layer 2 -- Journey Interaction" checklist.
|
|
246
|
+
|
|
247
|
+
5. Wait for agent to complete fully before proceeding.
|
|
248
|
+
|
|
249
|
+
6. Present results and record layer status:
|
|
250
|
+
- **Validated:** "Layer [N] works. [Evidence: captured screenshots match baselines within threshold.]"
|
|
251
|
+
Record: `status: active`, `validated: [date]`
|
|
252
|
+
- **Partially validated:** "Layer [N] works with caveats. [Evidence + caveats, e.g., anti-aliasing noise above expected threshold.]"
|
|
253
|
+
Record: `status: active`, `validated: [date]`, `caveats: [list]`
|
|
254
|
+
- **Failed:** "Layer [N] does not work in this environment. [Evidence + reason.] Should I try an alternative approach?"
|
|
255
|
+
Record: `status: failed` -- ask user whether to retry, adjust approach, or drop layer
|
|
256
|
+
- **Deferred:** "Layer [N] cannot be tested here. [Required environment + instructions.] The scripts have been created at `[workspace]` for manual validation on the target OS."
|
|
257
|
+
Record: `status: deferred`, `activation_criteria: [from Step 2]`, `deferred_reason: [evidence from spike]`
|
|
258
|
+
|
|
259
|
+
7. Proceed to the next layer only after presenting results.
|
|
260
|
+
|
|
261
|
+
### Step 5: Generate Production Scripts
|
|
262
|
+
|
|
263
|
+
After validating layers, invoke the `arn-spark-visual-test-engineer` agent again (foreground) via the Task tool, passing the model from `.arness/agent-models/spark.md` as the `model` parameter (see `plugins/arn-spark/skills/arn-spark-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context:
|
|
264
|
+
- Validated layer specifications and spike results
|
|
265
|
+
- Full baseline image set (all screens, not just the POC subset)
|
|
266
|
+
- Project structure and build configuration
|
|
267
|
+
- Request: generate production-ready capture and comparison scripts
|
|
268
|
+
|
|
269
|
+
The agent produces:
|
|
270
|
+
- **Capture script** (e.g., `scripts/visual-test-capture.mjs`) -- Playwright script that navigates to each screen of the **development build** (via the dev server), captures screenshots at specified viewport sizes, saves to `visual-tests/captures/`. This runs against the dev build, NOT the prototype.
|
|
271
|
+
- **Comparison script** (e.g., `scripts/visual-test-compare.mjs`) -- loads development captures and prototype baselines, computes pixel diff, generates a diff report with highlighted differences, reports pass/fail per screen
|
|
272
|
+
- **Baseline setup script** (e.g., `scripts/visual-test-baseline.mjs`) -- copies prototype screenshots to baseline directory with proper naming (one-time setup)
|
|
273
|
+
- **Cross-environment pipeline script (if Layer 2+)** (e.g., `scripts/visual-test-cross-env.sh`) -- WSL2-to-Windows build+capture+copy pipeline, or equivalent
|
|
274
|
+
|
|
275
|
+
Present the scripts to the user before writing to the project.
|
|
276
|
+
|
|
277
|
+
### Step 6: Set Up Baseline Images
|
|
278
|
+
|
|
279
|
+
Invoke the `arn-spark-visual-test-engineer` agent (foreground) via the Task tool, passing the model from `.arness/agent-models/spark.md` as the `model` parameter (see `plugins/arn-spark/skills/arn-spark-ensure-config/references/ensure-config.md` "Dispatch convention" for fallback). Context:
|
|
280
|
+
- Prototype screenshot locations (from Step 3)
|
|
281
|
+
- Baseline directory path (e.g., `visual-tests/baselines/`)
|
|
282
|
+
- Naming convention from the capture script
|
|
283
|
+
|
|
284
|
+
The agent:
|
|
285
|
+
1. Creates the baseline directory
|
|
286
|
+
2. Copies and renames prototype screenshots following the naming convention from the capture script (e.g., `screen-name--light.png`, `screen-name--dark.png`)
|
|
287
|
+
3. Writes a `baseline-manifest.json` mapping screen names to baseline file paths
|
|
288
|
+
4. Validates that every screen in the capture script has a corresponding baseline
|
|
289
|
+
5. Reports any gaps (screens without baselines)
|
|
290
|
+
|
|
291
|
+
### Step 7: Update .gitignore
|
|
292
|
+
|
|
293
|
+
Check if the project uses Git (from `## Arness` config or by checking for `.git/`). If not configured, skip this step silently.
|
|
294
|
+
|
|
295
|
+
If Git is configured:
|
|
296
|
+
|
|
297
|
+
1. Inventory all directories and files created or referenced by the visual testing strategy so far (spike workspaces, capture output directories, diff output directories, baseline directories, scripts, manifest files)
|
|
298
|
+
2. Classify each path as **ephemeral** (regenerated on every run, machine-specific) or **shared** (reference images, scripts, and config the team needs)
|
|
299
|
+
3. Read the project's `.gitignore` and check which paths are already covered
|
|
300
|
+
4. Present the classification to the user:
|
|
301
|
+
|
|
302
|
+
"The visual testing strategy created these paths. Which should be excluded from Git?
|
|
303
|
+
|
|
304
|
+
| Path | Type | Recommendation |
|
|
305
|
+
|------|------|----------------|
|
|
306
|
+
| [path] | [ephemeral / shared] | [ignore / track] |
|
|
307
|
+
| ... | ... | ... |
|
|
308
|
+
|
|
309
|
+
Ephemeral paths (captures, diffs, spike workspaces) are regenerated on every run and are typically ignored. Shared paths (baselines, scripts, manifests) are reference artifacts the team needs and are typically tracked.
|
|
310
|
+
|
|
311
|
+
Want to proceed with these recommendations, or adjust?"
|
|
312
|
+
|
|
313
|
+
5. Wait for user confirmation or adjustments
|
|
314
|
+
6. Add the confirmed paths to `.gitignore` under a `# Visual testing` comment block
|
|
315
|
+
|
|
316
|
+
### Step 8: Configure Test Runner Integration
|
|
317
|
+
|
|
318
|
+
Present integration options:
|
|
319
|
+
|
|
320
|
+
Ask the user:
|
|
321
|
+
|
|
322
|
+
**"How should visual tests integrate with your workflow?"**
|
|
323
|
+
|
|
324
|
+
Options:
|
|
325
|
+
1. **Manual** — Run `node scripts/visual-test-capture.mjs && node scripts/visual-test-compare.mjs` when you want to check
|
|
326
|
+
2. **npm script** — Add `visual-test` to package.json scripts (Recommended)
|
|
327
|
+
3. **CI integration** — Add a visual test step to the CI workflow
|
|
328
|
+
4. **Arness pipeline hook** — Run visual tests as part of `/arn-code-execute-task` completion verification
|
|
329
|
+
|
|
330
|
+
Based on user choice, configure the integration:
|
|
331
|
+
- **npm script:** Add `"visual-test:capture"`, `"visual-test:compare"`, and `"visual-test"` (runs both) to package.json scripts
|
|
332
|
+
- **CI:** Add a visual test job to the CI workflow file (if one exists from arn-spark-dev-setup). If no CI exists, create the workflow file or suggest running `/arn-spark-dev-setup` first.
|
|
333
|
+
- **Arness pipeline:** Add configuration to arness.md (see Step 9)
|
|
334
|
+
|
|
335
|
+
### Step 9: Write Strategy Document
|
|
336
|
+
|
|
337
|
+
Read the template:
|
|
338
|
+
> Read `${CLAUDE_PLUGIN_ROOT}/skills/arn-spark-visual-strategy/references/visual-strategy-template.md`
|
|
339
|
+
|
|
340
|
+
Populate the template with all collected information:
|
|
341
|
+
- Stack and environment analysis (from Step 1)
|
|
342
|
+
- Layer-by-layer strategy with trade-offs (from Step 2)
|
|
343
|
+
- Spike results per layer (from Step 4)
|
|
344
|
+
- Baseline image mapping (from Step 3 and Step 6)
|
|
345
|
+
- Script inventory with paths and usage (from Step 5)
|
|
346
|
+
- Cross-environment pipeline documentation (if applicable)
|
|
347
|
+
- CI integration details (if configured in Step 8)
|
|
348
|
+
- Known limitations
|
|
349
|
+
- Threshold configuration (pixel diff tolerance, per-screen overrides)
|
|
350
|
+
- How to update baselines when designs intentionally change
|
|
351
|
+
|
|
352
|
+
Write to `[vision-dir]/visual-strategy.md`.
|
|
353
|
+
|
|
354
|
+
### Step 10: Write arness.md Configuration
|
|
355
|
+
|
|
356
|
+
Add or update a `### Visual Testing` subsection in the `## Arness` section of the project's `arness.md`:
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
### Visual Testing
|
|
360
|
+
- **Strategy doc:** [vision-dir]/visual-strategy.md
|
|
361
|
+
- **Baseline directory:** visual-tests/baselines/
|
|
362
|
+
- **Screen manifest:** visual-tests/screen-manifest.json
|
|
363
|
+
- **Capture script:** scripts/visual-test-capture.mjs
|
|
364
|
+
- **Compare script:** scripts/visual-test-compare.mjs
|
|
365
|
+
- **Layers:** [Layer 1 name, Layer 2 name, ...]
|
|
366
|
+
- **Diff threshold:** [N]% (pixel difference tolerance)
|
|
367
|
+
- **Integration:** [manual / npm-script / ci / arness-pipeline]
|
|
368
|
+
|
|
369
|
+
During feature development, the capture script runs against the development build (dev server) and the comparison script diffs those captures against the prototype baselines. This catches visual regressions as features are implemented. To update baselines after intentional design changes, run `[baseline update command]`.
|
|
370
|
+
|
|
371
|
+
[For each additional layer with status other than Layer 1:]
|
|
372
|
+
|
|
373
|
+
#### Layer [N]: [Name]
|
|
374
|
+
- **Status:** [active / deferred]
|
|
375
|
+
- **Capture script:** [path]
|
|
376
|
+
- **Compare script:** [path]
|
|
377
|
+
- **Baseline directory:** [path]
|
|
378
|
+
- **Diff threshold:** [N]%
|
|
379
|
+
- **Requires dev server:** [yes / no]
|
|
380
|
+
- **Activation criteria:** [free-text condition, or "N/A" if active]
|
|
381
|
+
- **Environment:** [required OS/platform]
|
|
382
|
+
- **Spike result:** [Validated: evidence / Deferred: reason]
|
|
383
|
+
- **Interaction:** static | journey
|
|
384
|
+
- **Journey manifest:** [path to journey-manifest.json] (only if Interaction: journey)
|
|
385
|
+
- **Journey runner:** [path to platform-specific runner script] (only if Interaction: journey)
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
> **Note:** The `**Interaction:**` field distinguishes between static screenshot capture (default) and journey-based interaction testing. When set to `journey`, the `**Journey manifest:**` and `**Journey runner:**` fields specify the paths to the auto-generated journey definitions and platform runner script. These are generated by `arn-spark-visual-test-engineer` during the spike or readiness activation. If the `**Interaction:**` field is absent, `static` is assumed (backward compatible).
|
|
389
|
+
|
|
390
|
+
Top-level fields (no `####` subsection) are implicitly Layer 1 and are always active. Skills that are not layer-aware continue reading top-level fields unchanged.
|
|
391
|
+
|
|
392
|
+
### Step 11: Present Summary and Next Steps
|
|
393
|
+
|
|
394
|
+
"Visual testing strategy configured.
|
|
395
|
+
|
|
396
|
+
**Strategy:** [layers summary]
|
|
397
|
+
**Baselines:** [N] screen baselines + [M] journey baselines from prototype v[X]
|
|
398
|
+
**Scripts:** [list with paths]
|
|
399
|
+
**Spike results:** Layer 1: [result]. Layer 2: [result].
|
|
400
|
+
|
|
401
|
+
**Files created/updated:**
|
|
402
|
+
- [vision-dir]/visual-strategy.md
|
|
403
|
+
- scripts/visual-test-capture.mjs
|
|
404
|
+
- scripts/visual-test-compare.mjs
|
|
405
|
+
- scripts/visual-test-baseline.mjs
|
|
406
|
+
- visual-tests/baselines/ ([N] images)
|
|
407
|
+
- visual-tests/baselines/baseline-manifest.json
|
|
408
|
+
- [cross-env scripts if applicable]
|
|
409
|
+
- .gitignore (added visual-tests/captures/ and visual-tests/diffs/)
|
|
410
|
+
|
|
411
|
+
**arness.md updated** with `### Visual Testing` configuration.
|
|
412
|
+
|
|
413
|
+
Recommended next steps:
|
|
414
|
+
1. **Extract features:** Run `/arn-spark-feature-extract` to build the backlog
|
|
415
|
+
2. **Start developing:** If you have the Arness Code plugin installed, run `/arn-planning` to begin the development pipeline. Arness auto-configures on first use.
|
|
416
|
+
3. **Start building:** Features will be compared against prototype baselines during implementation
|
|
417
|
+
|
|
418
|
+
[If any layers were deferred:]
|
|
419
|
+
|
|
420
|
+
**Deferred layers:** [layer names]. These layers were configured but could not be validated in the current environment. After the first feature is implemented and the application builds on the target platform, run `/arn-spark-visual-readiness` to activate them."
|
|
421
|
+
|
|
422
|
+
## Agent Invocation Guide
|
|
423
|
+
|
|
424
|
+
| Situation | Action |
|
|
425
|
+
|-----------|--------|
|
|
426
|
+
| Validate a testing layer (Step 4) | Invoke `arn-spark-visual-test-engineer` sequentially (foreground, not background) with layer spec, stack, workspace, spike checklist, and capture script template. Wait for completion before starting the next spike. |
|
|
427
|
+
| Generate production scripts (Step 5) | Invoke `arn-spark-visual-test-engineer` with validated layer specs, full screen list, and project context. |
|
|
428
|
+
| Set up baselines (Step 6) | Invoke `arn-spark-visual-test-engineer` with screenshot paths, baseline directory, and naming convention. |
|
|
429
|
+
| Agent permission denied | Same as arn-spark-spike: re-run in foreground. If still denied, execute directly in conversation (write POC files and run capture commands yourself). |
|
|
430
|
+
| User asks about prototype quality | Reference the prototype lock manifest and judge reports. Do not re-run validation. |
|
|
431
|
+
| User asks about specific framework capture methods | Discuss and invoke `arn-spark-tech-evaluator` if deep comparison needed. |
|
|
432
|
+
| User asks about CI setup | Discuss briefly. If CI workflow exists, offer to add visual test step. If not, suggest running `/arn-spark-dev-setup` first. |
|
|
433
|
+
| User asks about feature implementation | Defer: "Feature implementation is handled by `/arn-code-feature-spec` and the Arness development pipeline." |
|
|
434
|
+
| Cross-environment spike deferred | Record the deferral with instructions. Create the scripts anyway. The user can run them manually on the target OS later. |
|
|
435
|
+
|
|
436
|
+
## Error Handling
|
|
437
|
+
|
|
438
|
+
- **No prototype screenshots found:** Ask the user to provide reference screenshots or run the prototype skills first. Without baselines, the strategy document can still be written but baselines cannot be set up.
|
|
439
|
+
- **Playwright not available:** Layer 1 requires Playwright. Suggest installation (`npm install -D @playwright/test`). If the user declines, note that Layer 1 is unavailable and fall back to Layer 2 options or manual testing only.
|
|
440
|
+
- **Cross-environment spike cannot run (e.g., no Windows access from WSL2):** Mark as deferred. Create the pipeline scripts and document how to run them manually on the target OS. The scripts are the artifact even if they cannot be validated here.
|
|
441
|
+
- **Diff tool comparison is too noisy (anti-aliasing, sub-pixel rendering):** Expected for some stacks. Recommend a higher threshold or switching from pixelmatch to looks-same. Discuss with the user during Step 4.
|
|
442
|
+
- **Dev server fails to start during spike:** Check for port conflicts, build errors, missing dependencies. The spike uses a running server (prototype or dev build) as a test target to validate capture tooling — the server is a means, not the end goal.
|
|
443
|
+
- **Layer 2 validation fails:** Report the failure. Layer 1 may still be sufficient for most use cases. Discuss with the user.
|
|
444
|
+
- **CI runner does not support display (headless-only):** Layer 1 (Playwright) works headless. Layer 2 (native screenshot) needs a display. Document the limitation.
|
|
445
|
+
- **Too many screens (>20 baselines):** Suggest prioritizing key screens for initial baselines. Secondary screens can be added incrementally.
|
|
446
|
+
- **Strategy already exists:** "A visual testing strategy already exists at `[path]`. Do you want to replace it, update specific layers, or add a new layer?"
|
|
447
|
+
- **No dev-setup document:** Proceed with environment detection from the current runtime. Note that CI integration will be limited without a dev-setup baseline.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual Test Capture Script Template
|
|
3
|
+
*
|
|
4
|
+
* Template used by arn-spark-visual-test-engineer to generate a project-specific
|
|
5
|
+
* capture script. The agent reads this template and adapts it based on:
|
|
6
|
+
* - The project's routes/screens (from screen-manifest.json or manual list)
|
|
7
|
+
* - Viewport configuration
|
|
8
|
+
* - Dark/light mode toggle mechanism
|
|
9
|
+
* - Dev server URL and start command
|
|
10
|
+
*
|
|
11
|
+
* Placeholders:
|
|
12
|
+
* - __BASE_URL__: Dev server URL (e.g., http://localhost:5173)
|
|
13
|
+
* - __SCREENS__: Array of {name, route, waitFor?} objects
|
|
14
|
+
* - __VIEWPORT_WIDTH__: Capture viewport width (e.g., 1280)
|
|
15
|
+
* - __VIEWPORT_HEIGHT__: Capture viewport height (e.g., 720)
|
|
16
|
+
* - __OUTPUT_DIR__: Directory for captured screenshots (e.g., visual-tests/captures)
|
|
17
|
+
* - __DARK_MODE_TOGGLE__: Selector or JS to toggle dark mode (or null if N/A)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { chromium } from '@playwright/test';
|
|
21
|
+
import { mkdirSync, existsSync } from 'fs';
|
|
22
|
+
import { join } from 'path';
|
|
23
|
+
|
|
24
|
+
const BASE_URL = '__BASE_URL__';
|
|
25
|
+
const VIEWPORT = { width: __VIEWPORT_WIDTH__, height: __VIEWPORT_HEIGHT__ };
|
|
26
|
+
const OUTPUT_DIR = '__OUTPUT_DIR__';
|
|
27
|
+
const DARK_MODE_TOGGLE = __DARK_MODE_TOGGLE__; // null or selector string
|
|
28
|
+
|
|
29
|
+
const SCREENS = __SCREENS__;
|
|
30
|
+
// Example:
|
|
31
|
+
// [
|
|
32
|
+
// { name: 'hub', route: '/', waitFor: 'networkidle' },
|
|
33
|
+
// { name: 'settings', route: '/settings', waitFor: '.settings-panel' },
|
|
34
|
+
// { name: 'pairing', route: '/pairing', waitFor: 'networkidle' },
|
|
35
|
+
// ]
|
|
36
|
+
|
|
37
|
+
async function capture() {
|
|
38
|
+
// Ensure output directory exists
|
|
39
|
+
if (!existsSync(OUTPUT_DIR)) {
|
|
40
|
+
mkdirSync(OUTPUT_DIR, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const browser = await chromium.launch({ headless: true });
|
|
44
|
+
const context = await browser.newContext({ viewport: VIEWPORT });
|
|
45
|
+
const page = await context.newPage();
|
|
46
|
+
|
|
47
|
+
console.log(`Capturing ${SCREENS.length} screens at ${VIEWPORT.width}x${VIEWPORT.height}`);
|
|
48
|
+
|
|
49
|
+
for (const screen of SCREENS) {
|
|
50
|
+
const url = `${BASE_URL}${screen.route}`;
|
|
51
|
+
console.log(` Capturing: ${screen.name} (${url})`);
|
|
52
|
+
|
|
53
|
+
await page.goto(url, { waitUntil: 'networkidle' });
|
|
54
|
+
|
|
55
|
+
// Wait for specific element or condition if specified
|
|
56
|
+
if (screen.waitFor && screen.waitFor !== 'networkidle') {
|
|
57
|
+
await page.waitForSelector(screen.waitFor, { timeout: 10000 });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Allow rendering to settle
|
|
61
|
+
await page.waitForTimeout(500);
|
|
62
|
+
|
|
63
|
+
// Capture light mode
|
|
64
|
+
const lightPath = join(OUTPUT_DIR, `${screen.name}--light.png`);
|
|
65
|
+
await page.screenshot({ path: lightPath, fullPage: false });
|
|
66
|
+
console.log(` -> ${lightPath}`);
|
|
67
|
+
|
|
68
|
+
// Capture dark mode if toggle exists
|
|
69
|
+
if (DARK_MODE_TOGGLE) {
|
|
70
|
+
await page.click(DARK_MODE_TOGGLE);
|
|
71
|
+
await page.waitForTimeout(300); // Allow transition
|
|
72
|
+
const darkPath = join(OUTPUT_DIR, `${screen.name}--dark.png`);
|
|
73
|
+
await page.screenshot({ path: darkPath, fullPage: false });
|
|
74
|
+
console.log(` -> ${darkPath}`);
|
|
75
|
+
|
|
76
|
+
// Toggle back to light mode
|
|
77
|
+
await page.click(DARK_MODE_TOGGLE);
|
|
78
|
+
await page.waitForTimeout(300);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
await browser.close();
|
|
83
|
+
console.log(`\nDone. ${SCREENS.length} screens captured to ${OUTPUT_DIR}/`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
capture().catch(err => {
|
|
87
|
+
console.error('Capture failed:', err);
|
|
88
|
+
process.exit(1);
|
|
89
|
+
});
|