Skip to content

feat: add adapter_hints to browser analyze, wire it up as a real command - #236

Open
ayushsingh82 wants to merge 1 commit into
agentrhq:mainfrom
ayushsingh82:fix/226-adapter-hints
Open

feat: add adapter_hints to browser analyze, wire it up as a real command#236
ayushsingh82 wants to merge 1 commit into
agentrhq:mainfrom
ayushsingh82:fix/226-adapter-hints

Conversation

@ayushsingh82

Copy link
Copy Markdown

Summary

Per the issue: browser recon runs on the Playwright-style browser run sandbox while adapters stay on the stable IPage/registry API, and nothing bridged the two — an agent doing recon had to manually re-derive strategy choice and adapter shape from raw evidence, with only a prose reminder ("do not paste Playwright code into an adapter") standing between the two contracts.

analyze.ts already computed most of what's needed for this (pattern classification, anti-bot detection, scored network evidence, nearest adapter) via analyzeSite(), but per #217 the CLI wrapper that used to drive it was removed during the browser-run migration, leaving the whole module unreachable from any command.

What this PR does:

  • Adds buildAdapterHints() / AdapterHints to analyze.ts: a recommended discovery-time strategy (PUBLIC_API/COOKIE_API/UI_SELECTOR/DOM_STATE/INTERCEPT), the adapter-compatible path it maps to (browser:false -> func(args) vs browser:true -> func(page,args)), flagged state hazards (anti-bot, auth failures, missing cookies when a cookie strategy is recommended), a pointer to the snapshot tool for selector evidence (not something PageSignals captures), and a fixed do-not-copy-Playwright notice. Wired into AnalyzeReport as adapter_hints.
  • Re-registers webcmd browser analyze --stdin|--file as a pure JSON-in/JSON-out command — no live session, no daemon/CDP integration, just scores PageSignals an agent already captured via browser run and prints the AnalyzeReport (including adapter_hints). This deliberately avoids resurrecting the exact bug webcmd-adapter-author skill: browser analyze example is missing the required <session> argument #217 reported (a required <session> arg with no documented example) by not taking a session at all — recon evidence capture stays entirely in the existing browser run sandbox.
  • Updates site-recon.md with an optional PageSignals-shaped recon script piped into the new command, and SKILL.md's Step 3 to mention it as an alternative to manually reading the pattern table.
  • IPage is untouched, per the issue's explicit constraint to only extend it when evals prove a missing capability.

Fixes #226

Test plan

  • Unit: buildAdapterHints across Pattern A (with/without anti-bot), B, C, D, E — strategy recommendation, adapter-compatible path, and hazard flags (src/browser/analyze.test.ts)
  • Integration: browser analyze end-to-end via --file and --stdin, plus validation errors (neither/both flags, invalid JSON, missing required field) (src/cli.test.ts)
  • Updated the two tests asserting the exact registered browser subcommand list/count to include analyze
  • Manually exercised the built CLI: --file, --stdin, and all four error paths, confirmed exit codes and messages
  • npm run typecheck clean, npm run build clean, generated artifacts (cli-manifest.json, hosted-contract.json, webcmd-plugin.json) show no diff
  • npm test — 385 test files / 4629 passed, 1 skipped

Browser recon now runs on the Playwright-style `browser run` sandbox
while adapters stay on the stable IPage/registry API. Nothing bridged
the two: an agent doing recon had to manually re-derive strategy choice
and adapter shape from raw evidence, with only a prose reminder ("do
not paste Playwright code into an adapter") standing between the two
contracts.

analyze.ts already computed most of what's needed (pattern
classification, anti-bot detection, scored network evidence, nearest
adapter) via analyzeSite(), but per agentrhq#217 the CLI wrapper that used to
drive it was removed in the browser-run migration, leaving it
unreachable from any command.

- Add buildAdapterHints()/AdapterHints to analyze.ts: a recommended
  discovery-time strategy (PUBLIC_API/COOKIE_API/UI_SELECTOR/DOM_STATE/
  INTERCEPT), the adapter-compatible path it maps to (browser:false ->
  func(args) vs browser:true -> func(page,args)), flagged state hazards
  (anti-bot, auth failures, missing cookies when a cookie strategy is
  recommended), a pointer to the snapshot tool for selector evidence
  (not captured by PageSignals), and a fixed do-not-copy-Playwright
  notice. Wired into AnalyzeReport as `adapter_hints`.
- Re-register `webcmd browser analyze --stdin|--file` as a pure JSON-in/
  JSON-out command: no live session, no daemon/CDP integration, just
  scores PageSignals an agent already captured via `browser run` and
  prints the AnalyzeReport (including adapter_hints). This intentionally
  avoids the exact bug agentrhq#217 reported (a required <session> arg with no
  documented example) by not taking a session at all.
- Update site-recon.md with an optional PageSignals-shaped recon script
  piped into the new command, and SKILL.md's Step 3 to mention it.
- IPage is untouched, per the issue's explicit constraint to only extend
  it when evals prove a missing capability.

Fixes agentrhq#226
@ayushsingh82

Copy link
Copy Markdown
Author

@beubax Fixed — this PR adds a structured adapter_hints object to the recon/analyze output (recommended strategy, adapter-compatible func signature, network/selector evidence, state hazards, and a fixed do-not-copy-Playwright notice), and re-wires webcmd browser analyze as a pure JSON-in/JSON-out command over PageSignals an agent already captured via browser run — no live session, no IPage changes, per your proposal. Closes #226.

@github-actions

github-actions Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🟠 Maintainer review suggested — low confidence

The automated review could not reach a fully supported conclusion.

Limitations

  • Some automated findings could not be verified against the pull request diff.

This review is advisory and does not block merging.

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.

[Feature]: Keep adapter API stable; add recon-to-adapter translation hints

1 participant