eng-ui-screenshot
Screenshot capture for deterministic PNG evidence and visual-contract bundles for Compozy Storybook stories and local UI URLs. Use for visual audits, regression diffs, and design-parity checks. Do not use for interactive E2E flows, remote authenticated sites, or Storybook test execution.
- License 许可
- MIT
- 所属仓库
- compozy/compozy
- 最近更新
- 2026-11-12
- Stars
- ★ 2.9k
- Forks
- 188
01 前言 Front Matter
- name
- eng-ui-screenshot
- description
- Screenshot capture for deterministic PNG evidence and visual-contract bundles for Compozy Storybook stories and local UI URLs. Use for visual audits, regression diffs, and design-parity checks. Do not use for interactive E2E flows, remote authenticated sites, or Storybook test execution.
02 资源文件 10
- 参考文档references/cdp-flow.md4.6 KB
- 参考文档references/proposal-mock-capture.md2.5 KB
- 参考文档references/storybook-urls.md3.4 KB
- 参考文档references/troubleshooting.md3.5 KB
- 参考文档references/visual-contract.md8.8 KB
- 脚本scripts/cap.mjs3.3 KB
- 脚本scripts/list-stories.mjs1.7 KB
- 脚本scripts/setup-workdir.sh1.3 KB
- 脚本scripts/validate-visual-contract.mjs5.4 KB
- 脚本scripts/visual-diff.mjs3.7 KB
03 SKILL.md 正文
Compozy UI Screenshot
Capture deterministic PNG evidence through the bundled CDP helper. The helper owns load/font settling and viewport emulation; the procedure owns target resolution, evidence checks, and process cleanup.
When a task or spec names a trusted visual reference, read
.agents/skills/eng/eng-ui-screenshot/references/visual-contract.md before the first capture or implementation; reuse its resolved contract while it remains current. Its evidence bundle, not an
implementation-only screenshot, is the completion contract.
Procedure
Step 1: Prepare an Owned Workdir
- Start at the repository root and record it:
REPO_ROOT="$(pwd)". - Run the bootstrap helper with a unique directory:
WORKDIR="$(bash "$REPO_ROOT/.agents/skills/eng/eng-ui-screenshot/scripts/setup-workdir.sh" "$(mktemp -d /tmp/eng-ui-screenshot.XXXXXX)")" - The bootstrap copies the current capture helpers into
WORKDIRso Bun resolves their dependencies from the isolated package. KeepREPO_ROOTfor references and server packages; execute the materialized helpers fromWORKDIR.
Done when: one unique workdir exists, its dependencies are installed, and every helper path resolves independently of the current directory.
Step 2: Establish Storybook Ownership
- Skip this step when the capture set has no Storybook target. Otherwise read
.agents/skills/eng/eng-ui-screenshot/references/storybook-urls.mdin full. - Probe the required server (
6006forweb,6007forpackages/ui) and reuse it only when itsindex.jsonis healthy. - If a server is absent, start the matching
bun run storybookfrom its package, redirect logs intoWORKDIR, and immediately record its PID asWORKDIR/web-storybook.pidorWORKDIR/ui-storybook.pid. - Poll the health endpoint until it returns
200or the owned process exits; on exit, fail with its log.
Done when: every required Storybook is healthy and each server started by this run has exactly one PID file; pre-existing servers have none.
Step 3: Resolve Story IDs
- Skip this step for arbitrary non-Storybook URLs.
- From
WORKDIR, run the materialized read-only helper:bun run "$WORKDIR/list-stories.mjs" http://localhost:6006 [--filter <substring>] - Confirm every requested story id appears exactly in the output; never infer an id from the app URL.
Done when: every Storybook target is backed by a real index.json entry.
Step 4: Capture Through CDP
- From
WORKDIR, run the materialized mutating helper:bun run "$WORKDIR/cap.mjs" --out <output-dir> --width <W> --height <H> --wait <ms> --shot <name> <url> [...] - Use
1440 × 900for routes,1680 × 1050for wide breakpoints,1100 × 700for primitives, and320 × 800for collapsed navigation. Read.agents/skills/eng/eng-ui-screenshot/references/cdp-flow.mdin full before changing capture mechanics or defaults. - Use
2200 msas the current route settle floor; increase to4000 msonly when captured evidence shows fallback fonts. - Treat a non-zero helper exit as a failed capture set. A sub-20 KB PNG is also suspicious and requires inspection even when capture succeeded.
Done when: every requested target prints saved, the helper exits zero, and every expected PNG exists with a plausible size.
Step 5: Capture a Proposal Mock When Requested
- Only for proposal-side state not reachable from the canonical HTML, read
.agents/skills/eng/eng-ui-screenshot/references/proposal-mock-capture.mdin full and follow its clone-and-patch branch. - Start the static server as an owned process and record its PID in
WORKDIR/proposal-server.pid. - Capture with the same
WORKDIR/cap.mjs, then remove the throwaway wrapper without editing the canonical proposal.
Done when: every requested proposal state is captured, the canonical HTML is unchanged, and the temporary wrapper is gone.
Step 6: Inspect the Evidence
- Verify the exact expected PNG set; file size is a tripwire, not proof.
- Open at least one PNG from every distinct surface or viewport and compare it with the intended state or trusted baseline.
- For visual-contract runs, inspect every reference/implementation pair and require the complete evidence bundle before reporting parity.
Done when: target identity, viewport, rendered content, fonts, and visible state are verified rather than inferred from filenames; visual-contract runs additionally have no unresolved blocking divergence.
Step 7: Tear Down Owned Processes
- Terminate only PIDs recorded under this run's
WORKDIR: request graceful termination, wait for exit, and escalate only the same proven-owned process when necessary. - Preserve healthy servers that predated this run.
- Confirm every owned PID is dead before completion; files may remain for evidence.
Done when: all processes started by this run are stopped and no unowned browser or dev server was touched.
Error Handling
- A capture exits non-zero: read stderr and
.agents/skills/eng/eng-ui-screenshot/references/troubleshooting.md; fix the failing target and recapture affected targets. Repeat the set only if shared capture inputs changed; retain valid captures for unchanged inputs. - A Storybook port is occupied but unhealthy: identify the owner and report it. Reuse only a healthy
index.json; never kill an unowned process to claim the port. - The bootstrap workdir fails: discard that unique temporary workdir and rerun the bootstrap into a new one; do not mutate repository dependencies.
- Chrome survives a crashed helper: use the printed debug port to identify the exact headless Chrome PID, verify ownership from its command line, then terminate only that PID/process group. Never use a machine-wide
pkill. - Reference and implementation dimensions differ: recapture both at the exact contract viewport; never resize one image to manufacture a diff.
04 同仓库更多 Skills
security-review
Security code review for vulnerabilities. Use when asked to "security review", "find vulnerabilities", "check for security issues", "audit security", "OWASP review", or review code for injection, XSS, authentication, authorization, cryptography issues. Provides systematic review with confidence-based reporting.
lesson-learned
Extract evidence-backed engineering lessons from recent changes or incidents. Use for requested reflection, lesson updates, or retiring an obsolete workflow rule.
compozy
Operate CompozyOS. Use when working with CompozyOS sessions, agents, native tools, skills, tasks, Loops, Goals, Terminal, desktops and windows, automation, extensions, or configuration. Don't use for unrelated projects.
remotion-upgrade
Upgrade Remotion, and related packages
remotion-studio
Preview a Remotion video
remotion-saas
Build an app with Remotion