Skip to content

Npm publishing#46

Open
kzhou314 wants to merge 1 commit into
mainfrom
npm-publishing
Open

Npm publishing#46
kzhou314 wants to merge 1 commit into
mainfrom
npm-publishing

Conversation

@kzhou314

Copy link
Copy Markdown
Contributor

Plugin-side changes for https://github.com/github/accessibility/issues/10755.
Makes this package installable from npm so the scanner's find action can load it during scan throughnpm install + import.

@kzhou314 kzhou314 requested a review from a team as a code owner June 26, 2026 23:39
GitHub Advanced Security started work on behalf of kzhou314 June 26, 2026 23:39 View session
GitHub Advanced Security finished work on behalf of kzhou314 June 26, 2026 23:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, dist exports, prepack build) so the package can be installed/loaded from npm.
  • Introduce opt-in alt-text-quality rule 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

Comment thread src/rules/alt-text-quality.ts Outdated
GitHub Advanced Security started work on behalf of kzhou314 June 27, 2026 00:07 View session
GitHub Advanced Security finished work on behalf of kzhou314 June 27, 2026 00:07
@kzhou314 kzhou314 requested a review from JoyceZhu June 27, 2026 00:13
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