diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json new file mode 100644 index 000000000..ddde0dbcc --- /dev/null +++ b/.claude-plugin/marketplace.json @@ -0,0 +1,9 @@ +{ + "plugins": [ + { + "name": "js-asset-auditor", + "description": "Audit publisher pages for third-party JS assets and generate js-assets.toml entries using Playwright", + "path": "packages/js-asset-auditor" + } + ] +} diff --git a/.claude/settings.json b/.claude/settings.json index 02b602d4f..8a63480bf 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -23,9 +23,13 @@ "Bash(git diff:*)", "Bash(git log:*)", "Bash(git status:*)", + "Bash(node scripts/js-asset-slug.mjs:*)", "mcp__plugin_chrome-devtools-mcp_chrome-devtools__new_page", - "mcp__plugin_chrome-devtools-mcp_chrome-devtools__performance_stop_trace", + "mcp__plugin_chrome-devtools-mcp_chrome-devtools__navigate_page", + "mcp__plugin_chrome-devtools-mcp_chrome-devtools__list_network_requests", "mcp__plugin_chrome-devtools-mcp_chrome-devtools__evaluate_script", + "mcp__plugin_chrome-devtools-mcp_chrome-devtools__close_page", + "mcp__plugin_chrome-devtools-mcp_chrome-devtools__performance_stop_trace" ] }, "enabledPlugins": { diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5eea36a74..688520c24 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -66,7 +66,7 @@ jobs: with: node-version: ${{ steps.node-version.outputs.node-version }} cache: "npm" - cache-dependency-path: crates/js/lib/package.json + cache-dependency-path: crates/js/lib/package-lock.json - name: Install dependencies run: npm ci @@ -76,3 +76,31 @@ jobs: - name: Run unit tests run: npm test -- --run + + test-js-asset-auditor: + name: js-asset-auditor tests + runs-on: ubuntu-latest + defaults: + run: + working-directory: packages/js-asset-auditor + steps: + - uses: actions/checkout@v4 + + - name: Retrieve Node.js version + id: node-version + working-directory: . + run: echo "node-version=$(grep '^nodejs ' .tool-versions | awk '{print $2}')" >> $GITHUB_OUTPUT + shell: bash + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ steps.node-version.outputs.node-version }} + cache: "npm" + cache-dependency-path: packages/js-asset-auditor/package-lock.json + + - name: Install dependencies + run: npm ci + + - name: Run unit tests + run: npm test diff --git a/.gitignore b/.gitignore index af70c452a..f9bc0ef27 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,9 @@ src/*.html /guest-profiles /benchmark-results/** +# JS Asset Auditor plugin +/packages/js-asset-auditor/node_modules/ + # Playwright browser tests /crates/integration-tests/browser/node_modules/ /crates/integration-tests/browser/test-results/ diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index 6b7e9396d..accca115c 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -106,6 +106,7 @@ export default withMermaid( { text: 'Configuration', link: '/guide/configuration' }, { text: 'Testing', link: '/guide/testing' }, { text: 'Integration Guide', link: '/guide/integration-guide' }, + { text: 'JS Asset Auditor', link: '/guide/js-asset-auditor' }, ], }, { diff --git a/docs/guide/js-asset-auditor.md b/docs/guide/js-asset-auditor.md new file mode 100644 index 000000000..53a00cee2 --- /dev/null +++ b/docs/guide/js-asset-auditor.md @@ -0,0 +1,242 @@ +# JS Asset Auditor + +Use the JS Asset Auditor to sweep a publisher page, capture third-party script requests, and generate candidate `js-assets.toml` and integration config entries for review. + +The auditor is a Claude Code plugin and a standalone Node.js CLI. Use it during onboarding to create the first asset list, then run it in diff mode when the publisher page changes. + +## What it generates + +The auditor can produce two outputs: + +- `js-assets.toml`, candidate `[[js_assets]]` entries for the page sweep +- `trusted-server.generated.toml`, a generated integration config skeleton when `--config` is used + +Review both files before committing or deploying them. + +## Setup + +Install the plugin dependencies and browser once: + +```bash +cd packages/js-asset-auditor +npm install +npx playwright install chromium +``` + +## Basic usage + +Run the auditor against a publisher URL from the repository root: + +```bash +audit-js-assets https://www.publisher.com +``` + +This writes `js-assets.toml` in the current directory and prints a JSON summary to stdout. Progress messages print to stderr. + +You can also run the package directly: + +```bash +node packages/js-asset-auditor/lib/audit.mjs https://www.publisher.com +``` + +## How it works + +The auditor launches Chromium through Playwright, loads the target page, and records script network responses. It also reads the final set of `