- Execution order: perform tasks strictly top to bottom.
- Gating: do not start a task until the previous task is implemented, tested, and verified.
- Every "Implement" task must include adding unit/integration tests and running them successfully before proceeding.
- Use Rust tests (tokio, wiremock) for backend; use a small JS harness only for Chrome extension UX where needed.
- After completing a section, run
npm run build:alland the targeted tests for that section before advancing. - Keep changes minimal and targeted; avoid broad refactors.
- Match existing project style and folder layout.
- Prefer Rust for backend: server + MCP use rmcp.
- Preserve HTTP/MCP JSON shapes and semantics.
- Use feature flags to switch Rust vs legacy paths.
- Do not remove JS Chrome extension; test it via small JS harness.
- Testing: prefer Rust (tokio, wiremock); keep JS tests only where browser/DevTools is required.
- No network in unit tests. Mock with wiremock/httpmock.
- In transitional period, a Node test fetch proxy is allowed to keep legacy Jest+nock passing. Remove when Rust tests cover the cases.
- Respect licenses. Add THIRD_PARTY_NOTICES for embedded Node/Lighthouse. Do not ship unvetted binaries.
- Error handling: no panics in non‑test code; use anyhow or crate error types. Return early on errors.
- Security: bind HTTP to 127.0.0.1 by default; warn on non‑loopback binds.
- Performance: prefer async Rust (tokio); avoid blocking calls.
- Documentation: update convert-rust.md and README when user- visible behavior or flags change.
- Create
crates/Rust workspace and top‑level Cargo.toml - Add
crates/corewith shared types and errors - Add
crates/serverHTTP/WS service crate - Add
crates/mcpMCP stdio server crate (rmcp) - Add
crates/browserCDP abstraction crate (scaffold) - Add
crates/lighthouse-shim(scaffold; optional feature) - Add
xtask/or scripts for building prebuilt binaries
- Define DTOs mirroring existing JSON: logs, audits, identity
- Implement bounded ring buffer with JSON‑safe truncation
- Implement path conversion helper (WSL/UNC -> native)
- Implement error model and human messages (parity with TS)
- Add serde + schemars derives for future schema docs
- Unit tests for ring buffer, truncation, and errors
- Choose framework (axum). Add tokio, serde, thiserror
- Implement health
/.identity(signature/name/version) - Implement
/.port - In‑memory state: console logs (ring buffer)
- In‑memory state: console errors (ring buffer)
- In‑memory state: network errors (ring buffer)
- In‑memory state: network success (ring buffer)
- In‑memory state: all‑xhr aggregator (sorted merge)
- In‑memory state: selected element store
- In‑memory state: current URL
- Implement
GET /console-logs - Test
GET /console-logs(limits, truncation) - Implement
GET /console-errors - Test
GET /console-errors(limits, truncation) - Implement
GET /network-errors - Test
GET /network-errors(limits, truncation) - Implement
GET /network-success - Test
GET /network-success(limits, truncation) - Implement
GET /all-xhr(merge/sort) - Test
GET /all-xhrmerge order and limits - Implement
POST /selected-element - Implement
GET /selected-element - Test selected-element set/get (round‑trip)
- Implement
POST /wipelogs - Test
POST /wipelogsclears all buffers - Implement
POST /current-url - Implement
GET /current-url - Test current-url set/get (round‑trip)
- Enforce log limits per route (
logLimit,queryLimit) - Truncate long strings and JSON fields consistently
- JSON body size limit 50MB (align with Express)
- Per‑route timeouts and error mapping
- CORS config parity with Express defaults
- Graceful shutdown handling and signal traps
- Define screenshot message contract (base64 payload)
- Create folder if missing (Downloads/mcp-screenshots)
- Safe filename generation (timestamp + sanitized title)
- Atomic write to avoid partial files on crash
- Disk quota/size guard; error mapping
- Implement cookies/localStorage/sessionStorage handlers
- Payload size guards and structured logging
- Tests: folder creation, safe filename, atomic write, quota error mapping, payload size rejection
- Env proxy detection: HTTP(S)_PROXY, lowercase variants
- NO_PROXY wildcards, suffixes, and exact matches
- Local/private range bypass (127/localhost/10/172/192.168)
- HTTP/HTTPS vs SOCKS agent selection
-
test_connectivityAPI using reqwest agents - Unit tests: private ranges, NO_PROXY, bad proxy URL
test_connectivityimplemented with reqwest. Integration test binds to localhost and is marked#[ignore]by default to support restricted sandboxes. Run withcargo test -p webai-server -- --ignoredin CI/dev.- Linux auto-paste uses xclip + xdotool and requires X11. On Wayland, the fallback may not work; a Wayland-specific helper may be needed.
- Windows registry App Paths + BLBeacon implemented via injectable
RegProbe trait. Real registry integration can be added behind a
windows-regfeature for Windows CI; tests use a FakeReg.
- macOS: AppleScript via
osascriptfallback - macOS: optional native APIs (feature flag)
- Windows:
windowscrate clipboard + focus - Windows: PowerShell fallback path
- Linux: xdotool/X11; Wayland caveats noted
- Endpoint parity and message texts
- Per‑OS tests and error mapping
- Windows: HKLM/HKCU App Paths + BLBeacon probe
- Windows: Program Files x64/x86 fallbacks
- macOS: app bundle paths;
mdfindfallback - Linux:
which+ common paths (apt/snap/flatpak) - Opera detection via Chromium location
- Cache detected path and verify exists
- Env overrides: CHROME_PATH, BROWSER_EXECUTABLE
- Per‑browser overrides: CHROME/EDGE/BRAVE/FIREFOX_PATH
- User‑data‑dir lifecycle and cleanup
- Unit tests: win/mac/linux detection heuristics
- WSL path conversion tests (UNC/drive letters)
- Tests: env override precedence and caching
- Evaluate
chromiumoxidevsheadless_chrome - Implement headless browser lifecycle (user‑data‑dir)
- Executable path detection (Chrome/Edge/Brave; partial FF)
- Navigation with options: headers, cookies, viewport, UA, locale, timezone (interfaces only)
- Resource blocking via CDP (options scaffold)
- Network condition emulation (options scaffold)
- Replace Puppeteer calls behind feature flag
- Fallback path to legacy JS (env var)
- Implement WebSocket route
/extension-ws - Schema: standard request envelope with
requestId - Schema: success/error response envelopes
- Screenshot: request schema and validations
- Screenshot: success handler, save path, tests
- Screenshot: error/timeout mapping and tests
- Get‑HTML‑by‑selector: request schema
- Get‑HTML‑by‑selector: request schema
- Get‑HTML‑by‑selector: success/error/timeout tests
- Refresh‑browser: request/response + tests
- Click‑element: request/response + tests
- Fill‑input: request/response + tests
- Select‑option: request/response + tests
- Submit‑form: request/response + tests
- Backpressure: max inflight; queue/drop policy
- Backpressure: max inflight; queue/drop policy
- Reconnection: resume behavior and cleanup
- Feature
audit-lighthouse(default on) - Package embedded Node + Lighthouse assets
- First‑run extraction to cache dir
- Spawn management and lifecycle
- Flags mapping and pure LHR JSON return
-
--no-auditdisables audits entirely - Robust error mapping (Chrome missing, spawn ENOENT)
- THIRD_PARTY_NOTICES and license texts
- Tests: spawn success, missing Chrome, missing assets
- Add rmcp dependency and initialize stdio server
- Implement identity/version reporting
- Tool list: expose stable tool names
- Tool: getConsoleLogs (inputs, JSON, errors)
- Tool: getConsoleErrors (parity + errors)
- Tool: getNetworkErrors (parity + errors)
- Tool: getNetworkSuccess (parity + errors)
- Tool: getAllXhr (merged ordering parity)
- Tool: selected-element get
- Tool: selected-element set
- Tool: capture screenshot
- Tool: cookies (list)
- Tool: localStorage (get)
- Tool: sessionStorage (get)
- Tool: audits (accessibility/perf/seo/best)
- Streaming: progress and cancellation
- Structured error handling parity with TS
- CLI subcommand
mcpthat runs stdio server - Tests: snapshot outputs for every tool; error paths
- Create top‑level binary
webai - Subcommand
server(HTTP/WS) - Subcommand
mcp(stdio MCP) - Subcommand
all(run both; shared state) - Flags: host, port, data‑dir, log limits
- Flags: feature toggles (browser, legacy)
- Version banner matches package versioning
- Logging levels and JSON logs toggle
- Config precedence: CLI > ENV > config file
- Config validation and helpful errors
-
@cpjet64/webai-server: JS bin that prefers Rust binary - Postinstall: download prebuilt or build via cargo
- Fallback to legacy JS server only if binary missing
-
@cpjet64/webai-mcp: JS bin that prefers Rust MCP - Keep legacy JS MCP as temporary fallback
- Ensure
/.identityreports package version
- Add Rust unit tests for core types and helpers
- Add Rust integration tests for all HTTP endpoints
- Add WS integration tests for message flows
- Use
wiremockfor external service stubs - Add JSON snapshots with
instafor parity - Add deterministic ports and fixtures
- CI: run Rust test matrix on all platforms
- Snapshot tests for each MCP tool output
- Parity tests for every HTTP route
- Flaky‑resistant retries for browser tests
- Keep minimal Jest harness for Chrome extension E2E
- (Optional) Temporary Node fetch proxy for legacy tests
- Document deprecation of nock‑based backend tests
- Update convert-rust.md with progress links
- Update README with single‑binary usage
- Add CLI help and examples
- Add troubleshooting for audits and browsers
- Add development guide for building from source
- Build prebuilt binaries for macOS, Linux, Windows
- Code‑sign where applicable (optional)
- Include THIRD_PARTY_NOTICES
- Bundle Node/Lighthouse assets when feature enabled
- Verify licenses for all bundled deps
- Bind to 127.0.0.1 by default
- Add rate limits or backpressure if needed
- Ensure graceful shutdown and cleanup of temp dirs
- Fuzz test parsers and JSON inputs (optional)
- Warn when binding to non‑loopback host
- Temp dir cleanup verification tests
- Redaction toggle and tests (PII/tokens)
- Remove temporary Node fetch proxy once Rust tests pass
- Mark legacy JS server paths as deprecated
- Keep Chrome extension JS; document its interface
- Track blockers or decisions here during implementation.
- macOS native auto-paste: blocked in this sandbox due to restricted network (cannot add Cocoa/objc crates). The feature gate and stubs exist; native implementation will be added once deps can be fetched in CI/dev.
- Define
BrowserProvidertrait with common ops - Capability matrix type and endpoint
GET /capabilities - Chromium provider via CDP
- Firefox provider via BiDi; fallback WebDriver
- Safari provider via safaridriver (macOS only)
- Opera detection reusing Chromium paths
- Browser executable detection per OS
- Env/CLI overrides for executable paths
- User‑data‑dir lifecycle and cleanup
- Viewport, UA, locale, timezone settings
- Network emulation (3G/4G/offline/latency)
- Resource blocklist (images/fonts/media)
- Robust retries/backoff for nav/waits
- Feature flags per browser provider
- CSS/XPath/ARIA/Text selectors
- Shadow DOM piercing
- Auto‑wait for visible/stable/attached
- Deterministic selection and error texts
- Action recorder (WS events -> script)
- Export to Rust/TS test scripts
- Deterministic waits (network idle, element conditions)
- CLI:
webai recordandwebai replay
- HAR capture per session
- HAR redaction rules
- HAR replay for deterministic tests
- CLI:
webai har capture|replay
- Full‑page screenshots
- Region crop
- PDF/MHTML export
- Visual diff (SSIM/threshold)
- Structured logs with per‑session ids
- OpenTelemetry traces + metrics (feature flag)
- Sampling controls via config
- Timeline view data: network waterfall, console correlation (JSON API)
- Auto crash bundle (logs, HAR, traces)
- Privacy redaction policies
- CLI:
webai diag bundle
- Token/PII redaction rules (regex + allowlist)
- Sandboxed modes: disable downloads, dialogs
- Allow/deny lists for URLs and downloads
- Proxy rotation + NO_PROXY handling parity
- Single binary UX:
webai server|mcp|all - Config layering: CLI > ENV > file
- JSON schema for config; validate on load
- First‑run diagnostics (browser detection, permissions, env checks)
- Browser downloader helper for CI
- Remote worker protocol (gRPC/WS)
- Per‑tenant namespaces and quotas
- Secure auth for remote execution
- Progress and cancellation streaming
- Tool schema introspection endpoint
- Attachment streaming (screenshots, HAR, PDF) with chunking