Skip to content

feat: ship an agent skill in the package - #404

Merged
harlan-zw merged 9 commits into
fix/request-identityfrom
feat/package-skill
Sep 29, 2026
Merged

harlan-zw merged 9 commits into
fix/request-identityfrom
feat/package-skill

Conversation

@harlan-zw

@harlan-zw harlan-zw commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Stacked on #411.

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

Agents that drive unlighthouse keep tripping on the same things: they run unlighthouse in a script and it never exits, they copy regex into --exclude-urls, and they point --output-path somewhere that holds other files.

Adds a Skill at packages/unlighthouse/skills/unlighthouse/SKILL.md and ships it in the unlighthouse tarball. The README and the installation doc swap the old npx skilld add tip for the skilld.dev link and badge.

Only unlighthouse ships the Skill. It carries both binaries; the @unlighthouse/* packages have no separate users.

Writing the Skill turned up 21 package bugs. The fixes sit below this PR (#409, #405, #406, #407, #408, #411), so the Skill describes the fixed behaviour and should merge with them.

🤖 AI disclosure: Harlan Agent Kit modified this description. My AI open-source policy.

Agents misuse unlighthouse in ways the docs encourage: the dashboard binary never exits, several config keys are silently ignored, and some doc examples crash the scan. The Skill ships in the npm tarball so agents get the tested behaviour for 0.18.2.
@netlify

netlify Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for unlighthouse-crux-api canceled.

Name Link
🔨 Latest commit d6b3a35
🔍 Latest deploy log https://app.netlify.com/projects/unlighthouse-crux-api/deploys/6abbb52cb514f00009aa9e33

@harlan-zw

Copy link
Copy Markdown
Owner Author

Checked by hand against a packed 0.18.2 build in a throwaway consumer, scanning a local fixture site (1 to 4 URLs per run):

  • unlighthouse-ci --urls /about --budget 50 --build-static: exit 0, index.html at the .unlighthouse root, a marker file in .unlighthouse was deleted
  • --budget 99: exit 1 on accessibility 0.92; csv and jsonExpanded reporters wrote ci-result.*
  • scanner.throttle: false still reports throttlingMethod: simulate; lighthouseOptions.throttlingMethod: 'provided' reports provided
  • config cache: false resolves to cache: true under unlighthouse; config ci.buildStatic: true produced no index.html
  • --exclude-urls "/blog/.*" scanned blog pages; "/blog/**" did not
  • include without '/' in crawler mode hung until killed at 400 s; with '/' it scanned 4 routes
  • authenticate({ page }) crashed; authenticate(page) logged in and the session cookie reached the Lighthouse request
  • --cookies "sid=abc=def" sent sid=abc; config cookies sent the full value
  • README createUnlighthouse().start() threw on provider.mockRouter; the { name: 'ci' } + setCiContext() form in the Skill finished and exited 0
  • every TS block in the Skill typechecks against the packed types

@pkg-pr-new

pkg-pr-new Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@unlighthouse/cli

npm i https://pkg.pr.new/@unlighthouse/cli@404

@unlighthouse/client

npm i https://pkg.pr.new/@unlighthouse/client@404

@unlighthouse/core

npm i https://pkg.pr.new/@unlighthouse/core@404

@unlighthouse/server

npm i https://pkg.pr.new/@unlighthouse/server@404

unlighthouse

npm i https://pkg.pr.new/unlighthouse@404

unlighthouse-ci

npm i https://pkg.pr.new/unlighthouse-ci@404

commit: d6b3a35

@harlan-github-agent

harlan-github-agent Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Harlan Agent Kit posted this automated status. AI open source policy.

Action required: The pull request must be open or merged into the default branch.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one factual slip in the Skill plus a docs-consistency note.

Reviewed changes

  • Ships an agent Skill — adds packages/unlighthouse/skills/unlighthouse/SKILL.md, written against 0.18.2, covering setup, binary choice, discovery/sampling behaviour, config examples, known traps, output paths and debug tips.
  • Packages the Skill — adds "skills" to the files array in packages/unlighthouse/package.json so it lands in the tarball.
  • Docs links — replaces the npx skilld add unlighthouse tip with a skilld.dev link in README.md and docs/1.guide/1.getting-started/0.installation.md, and adds a skilld.dev badge to the README.

I cross-checked the Skill's factual claims against the source and they hold up: unlighthouse-ci deleting outputPath, ci.buildStatic config being overridden, the throttle/cache traps, the 50-URL sitemap threshold, --cookies/--extra-headers splitting, the authenticate signature, the createUnlighthouse()-without-provider throw, the cluster.close() throw and the include-skipping-/ hang. One claim does not.

ℹ️ The docs the Skill calls out are still wrong

The Traps section tells agents that authenticate({ page }) and report.score.performance come "from the docs" and crash the scan, but the docs themselves are left untouched. Agents retrieve those pages directly, so the Skill's correction only helps the subset that reads the Skill first. Since these are documentation fixes (not package bugs), aligning the source docs is cheap and doesn't force the Skill's trap lines to be removed.

Technical details
# Docs out of sync with the Skill's corrected examples

## Affected sites
- `docs/1.guide/guides/authentication.md:136` — `authenticate({ page })` crashes; hook receives the `Page` directly.
- `docs/1.guide/guides/0.config.md:172-173` — `report.score.performance` crashes; score lives at `report.report.score` and categories are an array.
- `docs/1.guide/guides/dynamic-sampling.md:66` and `docs/1.guide/recipes/large-sites.md:42` — say the default is 5; `constants.ts:184` is 8.
- `docs/1.guide/recipes/improving-accuracy.md:43`, `docs/1.guide/guides/0.config.md:103`, `docs/1.guide/1.getting-started/0.unlighthouse-cli.md:107`, `docs/1.guide/1.getting-started/0.installation.md:110` — say samples are averaged; the median run is used.

## Required outcome
- The examples users and agents copy should not crash, and stated defaults should match 0.18.2.

## Open questions for the human
- Is fixing these docs in scope for this PR, or deliberately deferred to keep it Skill-only?

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏


## Config

- `scanner.device` (`'mobile'`), `scanner.samples` (1, runs per page, averaged).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With scanner.samples > 1 the scan does not average: runLighthouseTask picks a median run via computeMedianRun(samples) (packages/core/src/puppeteer/tasks/lighthouse.ts:187-190). "averaged" here would mislead an agent reading scores.

Suggested change
- `scanner.device` (`'mobile'`), `scanner.samples` (1, runs per page, averaged).
- `scanner.device` (`'mobile'`), `scanner.samples` (1, runs per page; with more than one, the median run is used, not an average).

@harlan-zw
harlan-zw changed the base branch from main to fix/published-types September 29, 2026 10:30

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important

The fix/published-types merge fixed the package bugs that most of the Skill's Traps section documents. Shipping the Skill as-is would tell agents to work around behaviour that no longer exists in the code it ships with — see the inline comment on the Traps section.

Reviewed changes

  • Merged origin/fix/published-types — retargets the branch at fix/published-types and pulls its post-0.18.2 fix stack into the branch (safe output clearing, CLI flag/config merge, scan hang + close fixes, docs corrections, published-types compile). The Skill, README tip, installation-doc tip, and files entry are unchanged from the prior review.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Comment thread packages/unlighthouse/skills/unlighthouse/SKILL.md
The stacked fix PRs remove most traps: output folders, flag merging, throttle, hangs, and the programmatic API. The cookies trap is new and was checked against a local fixture.
@harlan-zw
harlan-zw added this pull request to stack #410 September 29, 2026 10:38

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — the incremental commit cleanly brings the Skill's Traps in line with the shipped code. One minor factual note on scanner.samples is carried over below.

Reviewed changes

  • Rewrote the Skill's Traps — the stale 0.18.2 workarounds are replaced with the fixed behaviour they ship with: output-folder ownership (.unlighthouse-output / Refusing to clear ...), scanner.throttle: false, config ci.buildStatic, the first-separator header split, the include-skips-/ exit 1, and the cookie/extraHeaders note.
  • Refreshed behaviour and config copy — flag-vs-config precedence, unlighthouse-ci exit-code meanings, default simulated throttling, static build via config, the no-provider programmatic example, and the typed task-complete categories.
  • Dropped the 0.18.2 pin — the Skill now states it is tested against the release that ships it.

I checked each new claim against the source and they hold: outputDir.ts refuses a foreign folder and writes the marker, resolveThrottling maps throttle: false to throttlingMethod: 'provided', pickCiOptions only sets passed flags (so config ci.buildStatic survives), unlighthouse.ts:349 emits No routes left to scan and both binaries exit 1, resolveConfig.ts:174 maps extraHeaders into lighthouseOptions.extraHeaders (so the Cookie-header workaround is sound), and worker.ts:308 fires task-complete unawaited so a throwing hook terminates unlighthouse-ci with exit 1.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏


## Config

- `scanner.device` (`'mobile'`), `scanner.samples` (1, runs per page, averaged), `scanner.throttle` (`true`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

With scanner.samples > 1 the scan does not average: runLighthouseTask picks a median run via computeMedianRun(samples) (packages/core/src/puppeteer/tasks/lighthouse.ts:187-190). "averaged" here would mislead an agent reading scores.

Suggested change
- `scanner.device` (`'mobile'`), `scanner.samples` (1, runs per page, averaged), `scanner.throttle` (`true`).
- `scanner.device` (`'mobile'`), `scanner.samples` (1, runs per page; with more than one, the median run is used), `scanner.throttle` (`true`).

@harlan-zw
harlan-zw removed this pull request from stack #410 September 29, 2026 10:55
@harlan-zw
harlan-zw changed the base branch from fix/published-types to fix/request-identity September 29, 2026 10:55
@harlan-zw
harlan-zw added this pull request to stack #412 September 29, 2026 10:55

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found in the new commit.

Reviewed changes — reviewed the SKILL.md guidance added since the b75c751 review, which documents three behaviours fixed on the fix/request-identity base.

  • Documented local vs. remote throttling — the Skill now says throttling is simulated for a remote site and off for a local one (localhost, 127.0.0.1), with an explicit scanner.throttle or --throttle winning (resolveConfig.ts:28 reads the user-supplied value, so the default true in constants.ts no longer forces it).
  • Documented redirect following — the Skill states the scan adopts the redirect target when site redirects (http→https, apex→www), matching validateHost (packages/cli/src/util.ts:27-29), which both binaries call.
  • Corrected the cookie guidance — the Traps entry claiming cookies never reach the Lighthouse request is gone; the auth section now says the hook's cookies go with every request, including Lighthouse, matching resolveRequestHeaders being spread into lighthouseOptions.extraHeaders per task (packages/core/src/puppeteer/tasks/lighthouse.ts:150).

One prior minor wording note on scanner.samples ("averaged") remains open and is not re-raised here.

Pullfrog  | Fix it ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@harlan-github-agent harlan-github-agent Bot added harlan-agent-running An Agent holds a Task on this issue or pull request right now. harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. labels Sep 29, 2026
@harlan-github-agent

harlan-github-agent Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🤖 MERGED

Harlan Agent Kit posted this automated review. It is not Harlan's personal review or approval. AI open source policy. Last updated: 2026-09-29 14:20 UTC.

GitHub merged this pull request.

No material findings were recorded.

The pull request closed.

@harlan-github-agent harlan-github-agent Bot added harlan-agent-ready The automated Review passed every gate on this head commit. and removed harlan-agent-running An Agent holds a Task on this issue or pull request right now. harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. labels Sep 29, 2026
@harlan-zw

Copy link
Copy Markdown
Owner Author

🤖 READY · 90/100

Harlan Agent Kit posted this automated review. It is not Harlan's personal review or approval. AI open source policy. Automated merge authorized by explicit user request.

@harlan-zw
harlan-zw merged commit b23fc3b into main Sep 29, 2026
15 checks passed
@harlan-github-agent harlan-github-agent Bot removed the harlan-agent-ready The automated Review passed every gate on this head commit. label Sep 29, 2026
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.

1 participant