Npm publishing#46
Open
kzhou314 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes the alt-text plugin publishable to npm (with a build output in dist/) so the accessibility scanner can install/import it at runtime, and adds an opt-in model-backed alt-text-quality rule (plus supporting judge infrastructure and extraction context) to detect higher-level alt text quality issues beyond deterministic pattern rules.
Changes:
- Add npm packaging/build setup (
tsconfig.build.json,distexports,prepackbuild) so the package can be installed/loaded from npm. - Introduce opt-in
alt-text-qualityrule backed by GitHub Models (optionally Azure Vision augmentation), including caching and an offline probe harness. - Expand image extraction + types to capture richer context (intrinsic dimensions, link/button, figcaption, nearby text, page title, section heading) and update tests/fixtures/docs accordingly.
Show a summary per file
| File | Description |
|---|---|
tsconfig.json |
Includes scripts/**/*.ts in the main TS project for typechecking tooling scripts. |
tsconfig.build.json |
Adds a dedicated build config to emit JS + types into dist/ for npm publishing. |
package.json |
Switches to a publishable package (@github/...), adds dist exports, and adds build/prepack/probe scripts. |
package-lock.json |
Locks new dev dependency (tsx) and its transitive deps. |
index.ts |
Allows rules to be sync or async by awaiting rule.evaluate(ctx). |
src/types.ts |
Extends ImageRecord with additional context fields and allows async rules. |
src/rules/index.ts |
Registers the new alt-text-quality rule in the append-only rule registry. |
src/rules/alt-text-quality.ts |
Implements the model-backed opt-in rule and maps judge verdicts to findings. |
src/extract.ts |
Enriches extracted image records with context (dimensions, surrounding text, heading/title, link/button, figcaption). |
src/utils/fetch-with-retry.ts |
Adds retrying fetch helper with timeout + exponential backoff for model/vision calls. |
src/utils/load-image-data-url.ts |
Adds helper to load images from URL/path/data: and normalize to base64 data: URLs. |
src/judges/index.ts |
Adds judge factory wiring for copilot vs azure-augmented modes with caching layers. |
src/judges/types.ts |
Defines shared judge input/output contracts for model-backed judging. |
src/judges/prompt.ts |
Centralizes system prompt + strict JSON schema for structured verdict output. |
src/judges/copilot-judge.ts |
Implements GitHub Models judge client using shared prompt/schema and retrying fetch. |
src/judges/azure-augmented-judge.ts |
Decorator that enriches judge context with Azure Vision pre-analysis (optional). |
src/judges/azure-vision-api-client.ts |
Implements real Azure Vision Image Analysis 4.0 client. |
src/judges/caching.ts |
Adds content-hash caches for judge verdicts and Azure vision analyses. |
scripts/probe-alt-quality.ts |
Adds an offline probe harness for scoring/model agreement on curated fixtures. |
schema/config.schema.json |
Documents and exposes alt-text-quality as a configurable rule override. |
README.md |
Documents the new opt-in rule, required tokens/credentials, and workflow env wiring. |
.github/workflows/scan-static-sites.yml |
Wires job-level env vars for model-backed rule tokens/credentials. |
.gitignore |
Ignores .env used by the probe harness. |
tests/utils/helpers.ts |
Updates test helpers/types for richer ImageRecord and sync-vs-async rule evaluation. |
tests/unit/vague-alt-text.test.ts |
Updates for async-capable rule API (await evaluate). |
tests/unit/missing-alt-text.test.ts |
Updates for async-capable rule API (await evaluate). |
tests/unit/load-image-data-url.test.ts |
Adds coverage for data: URL normalization behavior. |
tests/unit/judges-caching.test.ts |
Adds coverage for caching behavior and error non-caching. |
tests/unit/alt-text-quality.test.ts |
Adds unit tests for alt-text-quality mapping, skipping, sanitization, and context fields. |
tests/extract.test.ts |
Adds coverage for page title normalization and nearest preceding heading extraction. |
tests/example-site.test.ts |
Skips opt-in rules when validating “enabled by default” behavior. |
tests/fixtures/alt-quality/cases.json |
Adds offline fixture corpus for probe harness and rule evaluation. |
tests/fixtures/alt-quality/cases-github.json |
Adds GitHub/MDN/W3C-based fixture corpus variants for probing. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 30/33 changed files
- Comments generated: 1
- Review effort level: Low
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plugin-side changes for https://github.com/github/accessibility/issues/10755.
Makes this package installable from npm so the scanner's
findaction can load it during scan throughnpm install+import.