diff --git a/docs/plans/2026-03-11-web-automation-cloakbrowser-design.md b/docs/plans/2026-03-11-web-automation-cloakbrowser-design.md new file mode 100644 index 0000000..0279213 --- /dev/null +++ b/docs/plans/2026-03-11-web-automation-cloakbrowser-design.md @@ -0,0 +1,33 @@ +# Web Automation CloakBrowser Migration Design + +## Goal +Replace all Camoufox and direct Playwright Chromium usage in `web-automation` with CloakBrowser, while preserving the existing feature set: one-shot extraction, persistent browsing sessions, authenticated flows, multi-step automation, and markdown scraping. After local validation, keep the repo copy and docs as the canonical published version, then commit and push. + +## Architecture +`web-automation` will become CloakBrowser-only. A single browser-launch layer in `skills/web-automation/scripts/browse.ts` will provide the canonical runtime for the other scripts. Stateful flows will use CloakBrowser persistent contexts; one-shot extraction will also use CloakBrowser instead of raw `playwright.chromium`. + +## Scope +- Replace `camoufox-js` in `browse.ts` and any helper/test scripts +- Replace direct `playwright.chromium` launch in `extract.js` +- Update shared types/imports to match the CloakBrowser Playwright-compatible API +- Remove Camoufox/Chromium-specific setup instructions from skill docs +- Update package metadata and lockfile to depend on `cloakbrowser` +- Keep the user-facing command surface stable where possible + +## Compatibility Strategy +To minimize user breakage: +- keep the script filenames and CLI interfaces stable +- support old `CAMOUFOX_*` env vars as temporary aliases where practical +- introduce neutral naming in docs and code for the new canonical path + +## Testing Strategy +- Verify launcher setup directly through `browse.ts` +- Verify `extract.js` still handles: missing URL, invalid scheme, smoke extraction from `https://example.com` +- Verify one persistent-context path and one higher-level consumer (`scrape.ts` or `flow.ts`) still works +- Update docs only after the runtime is validated + +## Rollout +1. Implement and verify locally in the repo worktree +2. Update repo docs/indexes to describe CloakBrowser-based `web-automation` +3. Commit and push the repo changes +4. If needed, sync the installed OpenClaw workspace copy from the validated repo version diff --git a/docs/plans/2026-03-11-web-automation-cloakbrowser.md b/docs/plans/2026-03-11-web-automation-cloakbrowser.md new file mode 100644 index 0000000..c63754f --- /dev/null +++ b/docs/plans/2026-03-11-web-automation-cloakbrowser.md @@ -0,0 +1,136 @@ +# Web Automation CloakBrowser Migration Implementation Plan + +> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. + +**Goal:** Replace Camoufox and direct Chromium launches in `web-automation` with CloakBrowser and publish the updated repo/docs. + +**Architecture:** Use a single CloakBrowser-backed launch path in `skills/web-automation/scripts/browse.ts`, migrate `extract.js` to the same backend, update dependent scripts and tests, then update docs and publish the repo changes. + +**Tech Stack:** Node.js, TypeScript, JavaScript, Playwright-compatible browser automation, CloakBrowser, git + +--- + +### Task 1: Create isolated worktree + +**Files:** +- Modify: repo git metadata only + +**Step 1: Create worktree** + +Run: +```bash +git -C /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills worktree add /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/.worktrees/web-automation-cloakbrowser -b feature/web-automation-cloakbrowser +``` + +**Step 2: Verify baseline** + +Run: +```bash +git -C /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/.worktrees/web-automation-cloakbrowser status --short --branch +``` +Expected: clean feature branch + +### Task 2: Migrate the browser launcher + +**Files:** +- Modify: `skills/web-automation/scripts/browse.ts` +- Modify: `skills/web-automation/scripts/package.json` +- Modify: `skills/web-automation/scripts/pnpm-lock.yaml` +- Optional Modify: test helper scripts under `skills/web-automation/scripts/` + +**Step 1: Write the failing verification** + +Run: +```bash +cd /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/.worktrees/web-automation-cloakbrowser/skills/web-automation/scripts && node -e "require.resolve('cloakbrowser/package.json')" +``` +Expected: fail before dependency migration + +**Step 2: Replace backend dependency** +- remove `camoufox-js` +- add `cloakbrowser` +- update `browse.ts` to launch CloakBrowser contexts +- preserve persistent profile support + +**Step 3: Verify launcher wiring** + +Run a direct browse smoke test after install/update. + +### Task 3: Migrate dependent scripts + +**Files:** +- Modify: `skills/web-automation/scripts/extract.js` +- Modify: `skills/web-automation/scripts/auth.ts` +- Modify: `skills/web-automation/scripts/flow.ts` +- Modify: `skills/web-automation/scripts/scrape.ts` +- Modify: `skills/web-automation/scripts/test-minimal.ts` +- Modify: `skills/web-automation/scripts/test-full.ts` +- Modify: `skills/web-automation/scripts/test-profile.ts` + +**Step 1: Keep interfaces stable** +- preserve CLI usage where possible +- use CloakBrowser through shared launcher code +- keep one-shot extraction JSON output unchanged except for backend wording if needed + +**Step 2: Add compatibility aliases** +- support old `CAMOUFOX_*` env vars where practical +- document new canonical naming + +### Task 4: Verify behavior + +**Files:** +- Test: `skills/web-automation/scripts/*` + +**Step 1: Extractor error checks** + +Run: +```bash +cd /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/.worktrees/web-automation-cloakbrowser && node skills/web-automation/scripts/extract.js +``` +Expected: JSON error for missing URL + +Run: +```bash +cd /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/.worktrees/web-automation-cloakbrowser && node skills/web-automation/scripts/extract.js ftp://example.com +``` +Expected: JSON error for invalid scheme + +**Step 2: Extractor smoke test** + +Run: +```bash +cd /Users/stefano/.openclaw/workspace/projects/stef-openclaw-skills/.worktrees/web-automation-cloakbrowser && node skills/web-automation/scripts/extract.js https://example.com +``` +Expected: JSON result with title `Example Domain` and status `200` + +**Step 3: Stateful path verification** +- run one direct `browse.ts`, `scrape.ts`, or `flow.ts` command using the CloakBrowser backend +- confirm persistent-context code still initializes successfully + +### Task 5: Update docs and publish + +**Files:** +- Modify: `skills/web-automation/SKILL.md` +- Modify: `docs/web-automation.md` +- Modify: `README.md` +- Modify: `docs/README.md` + +**Step 1: Update docs** +- replace Camoufox wording with CloakBrowser wording +- replace old setup/install steps +- document any compatibility env vars and new canonical names + +**Step 2: Commit and push** + +Run: +```bash +git add skills/web-automation docs README.md +git commit -m "refactor: migrate web-automation to cloakbrowser" +git push -u origin feature/web-automation-cloakbrowser +``` + +**Step 3: Merge and cleanup** +- fast-forward or merge to `main` +- push `main` +- remove the worktree +- delete the feature branch