Skip to content

Automated CLI + VS Code screenshots, per-diagnostic /errors/ pages, and Zed README fix#196

Merged
MelbourneDeveloper merged 5 commits into
mainfrom
claude/practical-mestorf-0407d7
Jun 26, 2026
Merged

Automated CLI + VS Code screenshots, per-diagnostic /errors/ pages, and Zed README fix#196
MelbourneDeveloper merged 5 commits into
mainfrom
claude/practical-mestorf-0407d7

Conversation

@abdushakoor12

Copy link
Copy Markdown
Collaborator

TLDR

Replace hand-made/incorrect screenshots with automated pipelines that capture real CLI and VS Code output, generate a per-diagnostic /errors/ reference, and fix the Zed README's editor screenshot — all verified to render in CI.

What Was Added?

  • Automated CLI screenshots (website/screenshots/): npm run screenshots runs the real basilisk check --color always on each documented snippet, asserts the expected diagnostic actually fires, and renders the genuine colored output in a faithful macOS-Terminal window via Playwright (ansi.mjs, terminal.mjs, shots.mjs, generate.mjs).
  • Per-diagnostic error pages (website/src/errors/): an Eleventy-paginated template emits /errors/BSK-XXXX/ for all 160 codes from website/src/_data/rules.json, so every see: …/errors/BSK-XXXX link the CLI prints now resolves. Data is generated from the checker source by an extended scripts/gen_rules_reference.py --data; _data/{examples,ruleGroups,ruleStats}.js drive the worked-example image, grouping, and counts.
  • Real VS Code editor screenshots (vscode-extension/): npm run screenshots:editor drives the extension headed and captures the window over a dependency-free Chrome DevTools Protocol sidecar (Node built-in WebSocket — no Playwright/browser download): scripts/screenshot-watcher.mjs, scripts/capture-screenshots.mjs, src/test/suite/screenshots-capture.test.ts, takeWindowScreenshot() in screenshot.ts, and a CDP --remote-debugging-port flag in .vscode-test.mjs. Produces vscode-{diagnostics,hover,quickfix,module-explorer}.png, embedded on the docs.
  • 12 new worked-example CLI screenshots (E0017, E0020, E0023, E0026, E0027, E0029, E0031, E0033, E0040, E0041, E0099, E0115) and a real zed-screenshot.png.
  • New specs: WEBSITE-SCREENSHOTS, WEBSITE-ERROR-PAGES, VSIX-EDITOR-SCREENSHOTS.

What Was Changed or Deleted?

  • website/src/docs/rules/index.md: the hand-maintained ~155-row code table is replaced by a data-driven table (links each code to its /errors/ page); the headline count is computed (corrects a stale 155 → real 160).
  • Docs pages (install-vscode, quick-start, refactoring, index) now embed the real editor screenshots.
  • basilisk-zed/README.md + README.zh.md: hero image was a VS Code screenshot — repointed to a real Zed screenshot (images/zed-screenshot.png); render-zed-mirror.sh copies the real file into the published mirror (verified).
  • .github/workflows/ci.yml: the website job now regenerates rules.json and fails on drift; rule-source edits classify as website changes; e2e step also covers screenshot render checks.
  • All e0*.png, cli-demo.png, cli-clean.png regenerated from the real binary.

How Do The Automated Tests Prove It Works?

  • website/tests/e2e/errors.spec.ts: asserts every code in rules.json has a built /errors/<code>/index.html (≥155), the /errors/ index links all of them, a sampled page renders its code/title/severity, and every worked-example screenshot decodes.
  • website/tests/e2e/screenshots.spec.ts: asserts the rule-docs CLI screenshots, the homepage before/after demo, and all four vscode-*.png editor screenshots are embedded and decode to non-zero pixels.
  • CI website drift guard: gen_rules_reference.py --data is regenerated and diffed against the committed rules.json.
  • Verified locally against every CI job: lint (cargo fmt, ruff 0.15.17, clippy, eslint, deslop 0.5.1); website (drift + build + 26 e2e); zed (wasm build + clippy + 97 tests); Rust coverage (all per-crate thresholds met) + conformance gate (46%) + FP gate; shipwright manifest/version gate; VS Code e2e (189 passing — the one local failure is the macOS-only cooperative-sampler test that is this.skip()-ed on CI's ubuntu runner and passes in isolation); Neovim (45% ≥ 39%). Mutation testing is unaffected (no .rs changed); CI runs the full sharded suite regardless.

Spec / Doc Changes

New specs docs/specs/{WEBSITE-SCREENSHOTS,WEBSITE-ERROR-PAGES,VSIX-EDITOR-SCREENSHOTS}-SPEC.md, indexed in docs/INDEX.md. CLAUDE.md documents the three regeneration workflows (npm run screenshots, gen_rules_reference.py --data, npm run screenshots:editor).

Breaking Changes

  • None — no new runtime dependencies; the editor sidecar uses Node's built-in WebSocket. New tooling is opt-in (no-op without BASILISK_SCREENSHOTS=1); committed images are regenerated locally and only render-verified in CI.

Replace the manual macOS Terminal.app + screencapture + ImageMagick process
with a reproducible generator. `npm run screenshots` runs the real
`basilisk check --color always` on each documented snippet in a throwaway,
PII-free temp dir, asserts the documented diagnostic actually fires, and
renders the genuine coloured output inside a faithful macOS Terminal window
via Playwright.

- screenshots/{shots,ansi,terminal,generate}.mjs — manifest + ANSI→HTML +
  Terminal chrome + generator. The snippet→expected-code pairing is the
  automated form of "verify the example triggers the rule".
- tests/e2e/screenshots.spec.ts — verifies every image renders on the docs
  pages and homepage (imports the manifest, so it can't drift).
- All e0001–e0025 + cli-demo/cli-clean regenerated from basilisk 0.20.0.
- Spec: docs/specs/WEBSITE-SCREENSHOTS-SPEC.md [WEBSITE-SCREENSHOTS];
  INDEX, CLAUDE.md and the CI website job updated.

CI only verifies the committed images render; it never captures or uploads
them ([GITHUB-NO-ARTIFACTS]).
…orked examples

The CLI prints `see: https://www.basilisk-python.dev/errors/BSK-XXXX` for every
diagnostic, but none of those ~155 pages existed — each was a 404. Generate a
landing page per code, plus richer worked examples, all from the checker source.

Error pages ([WEBSITE-ERROR-PAGES]):
- scripts/gen_rules_reference.py --data extracts code, severity, summary, the
  doc-comment body (prose + ```python examples) and docs_url for all 160 codes
  into website/src/_data/rules.json (single source of truth).
- src/errors/error.njk paginates it to /errors/BSK-XXXX/ (summary, severity
  badge, explanation, worked-example screenshot when present, fix guidance,
  canonical URL); src/errors/index.njk is a grouped directory. All 160 pages
  land in sitemap.xml.
- /docs/rules/ table + counts now render from the same data (removes the
  hand-maintained 155-row table; fixes a stale 155 vs real 160 count).
- CI drift guard: the website job regenerates rules.json and diffs it; rule
  source edits now classify as website changes so a new rule can't ship without
  its page.

More worked examples ([WEBSITE-SCREENSHOTS-MANIFEST]):
- Added 12 verified, isolated snippets (E0017, E0020, E0023, E0026, E0027,
  E0029, E0031, E0033, E0040, E0041, E0099, E0115) — worked-example coverage
  15 → 27 codes. _data/examples.js maps each code to its screenshot via the
  manifest's `expect` field, so error pages embed real CLI output automatically.

Verification: tests/e2e/errors.spec.ts asserts every code has a rendered page,
the index links them all, and every worked example decodes on its page. Spec:
docs/specs/WEBSITE-ERROR-PAGES-SPEC.md; INDEX + CLAUDE.md updated.
The site described editor features (diagnostics, hover, refactoring, the
activity panel) in prose with no visuals — and the only VS Code capture in the
repo was a gitignored, full-screen local-debug grab. Add an automated pipeline
that drives the real extension headed and captures the actual window, then embed
the results on the docs.

Pipeline ([VSIX-EDITOR-SCREENSHOTS], vscode-extension/):
- screenshot-watcher.mjs — dependency-free CDP sidecar over Node's built-in
  WebSocket (no Playwright, no browser download); forces a uniform 1440×900@2×
  viewport and captures the workbench page on a signal file.
- screenshot.ts takeWindowScreenshot() — signals the sidecar, waits for the PNG;
  no-op unless BASILISK_SCREENSHOTS=1.
- .vscode-test.mjs — adds --remote-debugging-port when capturing.
- screenshots-capture.test.ts — "Editor screenshots" suite (skipped unless the
  env flag is set) that drives each feature, strips transient chrome, and shoots.
- scripts/capture-screenshots.mjs + `npm run screenshots:editor` — stage binary,
  copy shipwright.json, launch sidecar, run the suite. (Prereq:
  cargo build -p basilisk-cli -p basilisk-profiler-helper.)

Captured + embedded (real, 2880×1800):
- vscode-diagnostics.png   → /docs/install-vscode/
- vscode-hover.png         → /docs/quick-start/
- vscode-quickfix.png      → /docs/refactoring/
- vscode-module-explorer.png → /docs/

Verification: tests/e2e/screenshots.spec.ts asserts each editor screenshot is
embedded and decodes. PNGs are committed and regenerated locally; CI only
verifies they render, never captures ([GITHUB-NO-ARTIFACTS]). Spec:
docs/specs/VSIX-EDITOR-SCREENSHOTS-SPEC.md; INDEX + CLAUDE.md updated.
The basilisk-zed README (and its published mirror) showed
website/src/assets/images/screenshot.png — a VS Code window — as its hero,
misrepresenting the Zed extension.

Add a real Zed screenshot (website/src/assets/images/zed-screenshot.png),
repoint the extension's image symlink to it, and update both READMEs (en + zh)
to reference images/zed-screenshot.png with Zed-specific alt text. The
render-zed-mirror.sh `-L` deref already copies the real file into the standalone
mirror, so the published Nimblesite/basilisk-zed repo now ships the Zed image
(verified by rendering the mirror to a temp tree). The shared screenshot.png
stays for the VS Code / root / nvim READMEs that still reference it.
CI-prep fixes (no behaviour change):
- ruff-format scripts/gen_rules_reference.py (matches the pinned ruff 0.15.17
  `ruff format --check` gate).
- Move the editor-screenshot CDP sidecar from
  vscode-extension/src/test/suite/screenshot-watcher.mjs to
  vscode-extension/scripts/screenshot-watcher.mjs: the extension's `eslint src/`
  project-service config rejects a stray .mjs under src/, and the scripts/ dir
  (where the orchestrator already lives) is not linted. Path math and references
  updated accordingly; the spec doc and capture-suite comment follow.

Verified locally against every CI job: lint (fmt/clippy/eslint/deslop 0.5.1),
website (drift+build+e2e), zed (wasm+clippy+97 tests), Rust coverage +
conformance + FP gates, shipwright binary gate, VS Code e2e (the lone local
failure is the macOS-only cooperative-sampler test, skipped on CI's ubuntu
runner and green in isolation), and Neovim (45% ≥ 39%).
@MelbourneDeveloper MelbourneDeveloper merged commit cf33b7d into main Jun 26, 2026
22 checks passed
@MelbourneDeveloper MelbourneDeveloper deleted the claude/practical-mestorf-0407d7 branch June 26, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants