High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
chore: restructure optimization skills and tests
Luigi Agosti1e4608939829
diff --git a/.gitignore b/.gitignoreindex 87fbdd0d..c01117ef 100644--- a/.gitignore+++ b/.gitignore@@ -62,4 +62,6 @@ tests/tools/browserbench/results/tests/tools/scripts/runnerskills/agent-browsertests/stealth-score/results/-tests/stealth-score/.tmp/+# Per-lane ephemeral state written by up.sh / setup scripts (provider configs,+# generated compose overrides, etc.) — never commit.+tests/**/.tmp/diff --git a/dev b/devindex a591453a..f13c660e 100755--- a/dev+++ b/dev@@ -647,6 +647,7 @@ if [ $# -gt 0 ]; then;;*) run_command "$1" ;;esac+ exit 0fi# No args → interactive pickerdiff --git a/skills/pinchtab-coldstart/SKILL.md b/skills/pinchtab-coldstart/SKILL.mddeleted file mode 100644index 637c15f8..00000000--- a/skills/pinchtab-coldstart/SKILL.md+++ /dev/null@@ -1,79 +0,0 @@-----name: pinchtab-coldstart-description: "Run the PinchTab cold-start test. Spawns a subagent that follows tests/coldstart/subagent-context.md to validate the documented first-install user journey. Use when asked to 'run cold start', 'cold-start test', or 'test the agent onboarding flow'."------# PinchTab Cold-Start Test--Validate that an AI agent can go from zero to working with PinchTab using only the skill docs — no hand-holding.--## Prerequisites--Before spawning the subagent, clean the environment:--```bash-PROJECT_ROOT=$(git rev-parse --show-toplevel)-# Stop Docker benchmark services if running — they bind port 9867 and-# the cold-start native server will collide with them.-docker compose -f "$PROJECT_ROOT/tests/tools/docker-compose.yml" down 2>/dev/null-pkill -f 'pinchtab' 2>/dev/null-pkill -f 'Google Chrome.*pinchtab' 2>/dev/null-sleep 2-rm -f ~/.local/state/pinchtab/current-tab 2>/dev/null-rm -f "$PROJECT_ROOT/pinchtab" 2>/dev/null-rm -f ~/.pinchtab/coldstart-config-*.json 2>/dev/null-lsof -ti:9867 2>/dev/null | xargs kill 2>/dev/null-```--The cold-start uses `PINCHTAB_CONFIG=~/.pinchtab/coldstart-config-<timestamp>.json` so it never touches the user's real `~/.pinchtab/config.json`. Stale coldstart-config files from previous runs are removed above so `./pinchtab config init` writes a truly fresh OOTB config every time.--Wait 2 seconds after cleanup before spawning the agent.--## Execution--Spawn a single subagent **on Haiku 4.5** (`model: "haiku"` in the Agent tool call). Cold-start is a doc-quality test: if Haiku can complete 11/11 from the SKILL docs alone, the onboarding flow is genuinely cold-start-ready. Opus passing is unsurprising and not the signal we want. Do not let the subagent inherit Opus from the parent.--Use the prompt below. Replace `{PROJECT_ROOT}` and `{TIMESTAMP}` with actual values.--```-You are running a PinchTab cold-start validation. Your working directory is {PROJECT_ROOT}.--Start by reading the context file, then follow its instructions:--1. Read `tests/coldstart/subagent-context.md` — your full instructions.-2. Read the skill files it references.-3. Read the group files it references.-4. Execute all steps in groups 0 and 1.--Report pass/fail for every step. Write your full results to `/tmp/pinchtab-coldstart-{TIMESTAMP}.md`.-```--## Interpreting results--- **11/11 PASS**: The skill docs are sufficient for a cold start.-- **Any failure**: Check what the agent got stuck on — that's a gap in the skill docs or the CLI ergonomics.--Key things to look for in the report:-- Did the agent use the default port (9867) or pick a custom one?-- Did the agent read the server's READY output or poll health in a loop?-- Did the agent use `./pinchtab` CLI or fall back to curl/HTTP API?-- Did the agent leave `~/.pinchtab/config.json` untouched and run from a `PINCHTAB_CONFIG=~/.pinchtab/coldstart-config-*.json` throwaway path?-- Did the agent **avoid** running `./pinchtab config init`, `./pinchtab server`, and `./pinchtab session create`? The auto-flow on the first `nav` should handle all three. If the agent ran any of them, the cold-start docs failed to communicate that the auto-flow is the test.-- Did step 0.1 (cold nav) auto-create the config AND auto-start the server in a single command?-- Did step 0.5 (IDPI rejection) get a clean `idpi_domain_blocked`-style error against `https://example.com`?-- Did step 1.2 (click follows link) pass without an eval workaround?-- Did step 1.5 (fill+press login) reach `VERIFY_LOGIN_SUCCESS_DASHBOARD`?--## Comparing runs--Track token usage and tool call counts across runs to measure improvements. Thresholds are calibrated for Haiku 4.5 — recalibrate if you switch models.--| Metric | Good | Needs work |-|--------|------|------------|-| Total tokens | < 60k | > 80k |-| Tool calls | < 50 | > 60 |-| Port | 9867 (default) | Custom port |-| Server wait | Read READY | Polled health |-| API usage | CLI only | curl/HTTP fallback |--(Earlier runs on Opus 4.7 came in around 45-53k tokens / 29-38 tool calls. Haiku tends to use more tool calls for the same task; expect higher numbers and adjust thresholds after the first few Haiku runs.)diff --git a/skills/pinchtab-opt/SKILL.md b/skills/pinchtab-opt/SKILL.mdindex 7c83ff76..867ced71 100644--- a/skills/pinchtab-opt/SKILL.md+++ b/skills/pinchtab-opt/SKILL.md@@ -1,54 +1,180 @@---name: pinchtab-opt-description: "Run the PinchTab optimization loop. Spawns blind subagents that execute 108 browser automation steps across 47 groups using only the PinchTab skill, then reports pass/fail results and operation counts vs baseline. Use when asked to 'run optimization', 'run the opt loop', 'benchmark the agent', or 'test pinchtab agent'."+description: "Run the PinchTab optimization loop (Docker, 3 blind subagents on the runner's HIGH model, 108 steps across 47 groups) against chrome, cloak, ghost-chrome, or all three providers. Pass `setup` (optionally followed by a provider or `all`) to run only the setup test (native binary, single subagent forced to the runner's LOW model) that validates the fresh-install OOTB flow per provider. Use when asked to 'run optimization', 'run the opt loop', 'benchmark the agent', '/pinchtab-opt', '/pinchtab-opt cloak', '/pinchtab-opt ghost-chrome', '/pinchtab-opt setup', '/pinchtab-opt setup all', or 'test pinchtab agent'."---# PinchTab Optimization Loop-Run blind subagents against 108 browser automation steps (47 groups) to measure how well an AI agent can drive PinchTab without hand-held selectors.+Two independent modes selected by the argument. They use different runtimes, different models, and answer different questions — only one runs per invocation.++Think of the arg surface as a matrix: **mode × provider**. Model role is fixed by mode (not user-selectable).++| Mode | Providers | Runtime | Model role | Asks |+|---|---|---|---|---|+| **Optimization** (default) | `chrome` (default), `cloak`, `ghost-chrome`, `all` | Docker, 3 parallel subagents | `HIGH` (default/strong) | how few browser ops does the agent need across 108 steps vs baseline |+| **Setup** (`setup` keyword) | `chrome` (default), `cloak`, `ghost-chrome`, `all` | native binary, 1 subagent | `LOW` (small/fast) | can an agent go zero→working from the skill docs alone (OOTB doc-quality gate) |++## Model roles++This skill names model tiers abstractly so any runner (Claude, OpenAI, …) can map them at launch time:++- **`LOW`** — small/fast/cheap model. Used by the setup test because a weak model passing is the actual doc-quality signal; a strong model passing is unsurprising.+- **`HIGH`** — the runner's default/strong model. Used by the optimization benchmark because we want the realistic agent performance, not a deliberately handicapped run.++Suggested mappings (pick whatever the runner has available at the time it executes):++| Runner | `LOW` | `HIGH` |+|---|---|---|+| Claude Code | Haiku (e.g. `claude-haiku-4-5`) | inherit parent (Opus / Sonnet) |+| OpenAI Agents | `gpt-*-mini` tier | `gpt-*` flagship tier |+| Other | smallest capable model | default/best model |++The thresholds below were calibrated for Claude Haiku 4.5 as `LOW`; if you use a different `LOW`, recalibrate the token / tool-call numbers on the first run.++## Argument Parsing++`/pinchtab-opt [setup] [chrome|cloak|ghost-chrome|all]`++Positional args, in order. The first token is either a provider (optimization mode) or the literal `setup` keyword (setup mode); if `setup`, the second token is the provider.++**Optimization mode** (default — no `setup` keyword):+- `/pinchtab-opt` → opt on chrome+- `/pinchtab-opt chrome` → opt on chrome+- `/pinchtab-opt cloak` → opt on CloakBrowser+- `/pinchtab-opt ghost-chrome` → opt on ghost-chrome (Chrome image, ghost-chrome config)+- `/pinchtab-opt all` → opt on chrome, then cloak, then ghost-chrome++**Setup mode** (when first token is `setup`):+- `/pinchtab-opt setup` → setup on chrome (default)+- `/pinchtab-opt setup chrome` → setup on chrome+- `/pinchtab-opt setup cloak` → setup on cloak+- `/pinchtab-opt setup ghost-chrome` → setup on ghost-chrome+- `/pinchtab-opt setup all` → setup on each of the three, in order++Legacy `both` is **removed** (no alias) — use `all` for multi-provider runs. Anything else → print this section and abort.## Path Resolution-All paths below are relative to the **project root** (git root). Resolve it first:+All paths are relative to the **project root** (git root):```bashPROJECT_ROOT=$(git rev-parse --show-toplevel)TOOLS_DIR="$PROJECT_ROOT/tests/tools"+OPT_DIR="$PROJECT_ROOT/tests/optimization"+SETUP_DIR="$PROJECT_ROOT/tests/optimization-setup"```-The subagents must run with `$TOOLS_DIR` as their working directory because `./scripts/pt` and `./scripts/runner` live there.+The optimization subagents must run with `$TOOLS_DIR` as their working directory because `./scripts/pt` and `./scripts/runner` live there. The setup subagent runs with `$PROJECT_ROOT` as its working directory and builds a native binary.-## Prerequisites+`up.sh` / `down.sh` live in `$OPT_DIR`.++---++# Mode: setup (`/pinchtab-opt setup`)-Stop any native PinchTab server that might occupy port 9867, then ensure Docker services are running:+Validate that an AI agent can go from zero to working with PinchTab using only the skill docs — no hand-holding.++## Clean slate```bash-# Kill native PinchTab server if running — it binds the same port as Docker services.-pkill -f 'pinchtab server' 2>/dev/null-pkill -f 'pinchtab.*serve' 2>/dev/null+docker compose -f "$TOOLS_DIR/docker-compose.yml" down 2>/dev/null+docker rm -f optimization-pinchtab >/dev/null 2>&1 || true+pkill -f 'pinchtab' 2>/dev/null+pkill -f 'Google Chrome.*pinchtab' 2>/dev/null+sleep 2+rm -f ~/.local/state/pinchtab/current-tab 2>/dev/null+rm -f "$PROJECT_ROOT/pinchtab" 2>/dev/null+find ~/.pinchtab -maxdepth 1 -name 'setup-config-*.json' -delete 2>/dev/nulllsof -ti:9867 2>/dev/null | xargs kill 2>/dev/null-sleep 1```-Verify Docker health:+The setup test uses `PINCHTAB_CONFIG=~/.pinchtab/setup-config-<timestamp>.json` so it never touches the user's real `~/.pinchtab/config.json`. Stale setup-config files are removed above so the auto-flow writes a truly fresh OOTB config every time.++Wait 2 seconds after cleanup before spawning the agent.++## Spawn the setup subagent (LOW model) — for each requested provider++If the provider arg is `all`, repeat this section once per provider in order: `chrome`, `cloak`, `ghost-chrome`. Otherwise run it exactly once for the single named provider (default `chrome`).++Spawn a single subagent on the runner's **`LOW`** model (see "Model roles" above). For Claude Code that means `model: "haiku"` in the Agent tool call; for other runners pick the equivalent small/fast tier. Setup is a doc-quality test: if the `LOW` model can complete 11/11 from the SKILL docs alone, the onboarding flow is genuinely OOTB-ready. A `HIGH` model passing is unsurprising and not the signal we want — do **not** let the subagent inherit the parent's default model.++Use the prompt below. Replace `{PROJECT_ROOT}`, `{TIMESTAMP}`, and `{PROVIDER}` with actual values.-```bash-$TOOLS_DIR/scripts/pt health```+You are running a PinchTab setup validation against PROVIDER={PROVIDER}.+Your working directory is {PROJECT_ROOT}.++Start by reading the context file, then follow its instructions:-If unhealthy, start the services:+1. Read `tests/optimization-setup/subagent-context.md` — your full instructions, including the "Provider switch" section that applies when PROVIDER is not `chrome`.+2. Read the skill files it references.+3. Read the group files it references.+4. Execute all steps in groups 0 and 1 against PROVIDER={PROVIDER}.++Report pass/fail for every step. Write your full results to `/tmp/pinchtab-setup-{PROVIDER}-{TIMESTAMP}.md`.+```++## Interpret the result++- **11/11 PASS**: the skill docs are sufficient for a fresh-install start.+- **Any failure**: a gap in the skill docs or the CLI ergonomics.++Key things to look for in the report:+- Did the agent use the default port (9867) or pick a custom one?+- Did the agent read the server's READY output or poll health in a loop?+- Did the agent use `./pinchtab` CLI or fall back to curl/HTTP API?+- Did the agent leave `~/.pinchtab/config.json` untouched and run from a `PINCHTAB_CONFIG=~/.pinchtab/setup-config-*.json` throwaway path?+- Did the agent **avoid** running `./pinchtab config init`, `./pinchtab server`, and `./pinchtab session create`? The auto-flow on the first `nav` should handle all three.+- Did step 0.1 (cold nav) auto-create the config AND auto-start the server in a single command?+- Did step 0.5 (IDPI rejection) get a clean `idpi_domain_blocked`-style error against `https://example.com`?+- Did step 1.2 (click follows link) pass without an eval workaround?+- Did step 1.5 (fill+press login) reach `VERIFY_LOGIN_SUCCESS_DASHBOARD`?++Setup thresholds (calibrated for Claude Haiku 4.5 as `LOW` — recalibrate the numeric rows on the first run if your `LOW` is a different model):++| Metric | Good | Needs work |+|--------|------|------------|+| Total tokens | < 60k | > 80k |+| Tool calls | < 50 | > 60 |+| Port | 9867 (default) | Custom port |+| Server wait | Read READY | Polled health |+| API usage | CLI only | curl/HTTP fallback |++The setup subagent cleans up after itself (kills the fixture + native server, deletes the temp config and built binary).++---++# Mode: optimization (`/pinchtab-opt [chrome|cloak|ghost-chrome|all]`)++Run blind subagents against 108 browser automation steps (47 groups) to measure how well an AI agent can drive PinchTab without hand-held selectors.++## Prerequisites++Stop any native PinchTab server that might occupy port 9867, then confirm Docker is running:```bash-docker compose -f "$TOOLS_DIR/docker-compose.yml" up -d --build+pkill -f 'pinchtab server' 2>/dev/null || true+pkill -f 'pinchtab.*serve' 2>/dev/null || true+lsof -ti:9867 2>/dev/null | xargs kill -9 2>/dev/null || true+sleep 1+docker info >/dev/null 2>&1 || { echo "Docker not running"; exit 1; }```-Wait a few seconds and re-check health.+## For each requested provider++If the provider arg is `all`, repeat steps 1–5 below in order for `chrome`, then `cloak`, then `ghost-chrome`. Otherwise run them exactly once for the single named provider (default `chrome`). `up.sh` accepts all three provider names; `down.sh` is shared (it removes the standalone `optimization-pinchtab` container and the chrome compose stack regardless of which provider was active).++### 1. Bring up the provider environment++```bash+"$OPT_DIR/up.sh" "$PROVIDER"+```-## Execution+This returns `READY` with `container=...` and `token=...`. Capture those values.-### 0. Create per-agent report files+### 2. Seed isolated per-agent report files-Before spawning agents, create isolated report files so concurrent writes don't corrupt a shared file:+So concurrent agents don't corrupt each other's JSON:```bashRESULTS_DIR="$TOOLS_DIR/../benchmark/results"@@ -56,9 +182,9 @@ TIMESTAMP=$(date -u +%Y%m%d_%H%M%S)mkdir -p "$RESULTS_DIR"for agent in A B C; do- cat > "$RESULTS_DIR/agent${agent}_${TIMESTAMP}.json" <<SEED+ cat > "$RESULTS_DIR/agent${agent}_${PROVIDER}_${TIMESTAMP}.json" <<SEED{- "benchmark": {"type": "pinchtab", "timestamp": "${TIMESTAMP}", "agent": "${agent}"},+ "benchmark": {"type": "pinchtab", "provider": "${PROVIDER}", "timestamp": "${TIMESTAMP}", "agent": "${agent}"},"totals": {"steps_answered": 0},"steps": []}@@ -66,66 +192,79 @@ SEEDdone```-Save the three file paths — you'll pass one to each subagent.+Save the three report file paths — you pass the correct one to each subagent.-### 1. Spawn 3 parallel subagents+### 3. Spawn 3 parallel subagents-Use the **Agent** tool with `run_in_background: true`. Split the 45 groups into three batches:+Use the **Agent** tool with `run_in_background: true`. Split the 47 groups into three batches:-- **Batch A**: groups 0-14 (45 steps)-- **Batch B**: groups 15-29 (30 steps)-- **Batch C**: groups 30-46 (33 steps)+- **Batch A**: groups 0–14 (45 steps)+- **Batch B**: groups 15–29 (30 steps)+- **Batch C**: groups 30–46 (33 steps)-Each subagent gets the **same prompt template** — only the group range and `{REPORT_FILE}` change. Replace `{START}`, `{END}`, `{START_PAD}`, `{END_PAD}`, `{PROJECT_ROOT}`, and `{REPORT_FILE}` with actual values:+Each subagent receives a provider-aware prompt (replace the placeholders):```-You are running PinchTab optimization tasks. Your job is to execute groups {START} through {END}.+You are running PinchTab optimization tasks against PROVIDER={PROVIDER}.-CRITICAL: Your working directory MUST be {PROJECT_ROOT}/tests/tools for all commands. Prefix every shell command with `cd {PROJECT_ROOT}/tests/tools && `.+Your job is to execute groups {START} through {END}.++CRITICAL ENVIRONMENT SETUP (do this immediately):+export PINCHTAB_CONTAINER={CONTAINER_NAME}+export PINCHTAB_TOKEN={TOKEN}++CRITICAL: Your working directory MUST be {PROJECT_ROOT}/tests/tools for all commands.+Always prefix shell commands with the exports + cd when needed, e.g.:+ PINCHTAB_CONTAINER={CONTAINER_NAME} PINCHTAB_TOKEN={TOKEN} ./scripts/pt ...Your report file is: {REPORT_FILE}Use `--report-file {REPORT_FILE}` on every `./scripts/runner step-end` call.Start by reading these files to understand your tools and tasks:-1. Read `{PROJECT_ROOT}/tests/optimization/subagent-context.md` — environment, wrapper, and recording format.+1. Read `{PROJECT_ROOT}/tests/optimization/subagent-context.md` — environment, wrapper, recording format, and the Provider & Environment section.2. Read `{PROJECT_ROOT}/skills/pinchtab/SKILL.md` — full PinchTab command reference.3. Read each group file from `{PROJECT_ROOT}/tests/optimization/group-{START_PAD}.md` through `{PROJECT_ROOT}/tests/optimization/group-{END_PAD}.md`.DO NOT read `{PROJECT_ROOT}/tests/tools/scripts/baseline.sh` or any file under `{PROJECT_ROOT}/tests/benchmark/`.After reading the above files, execute each step in each group sequentially:-- Always cd to {PROJECT_ROOT}/tests/tools before running commands.-- Use `./scripts/pt` as the wrapper for all PinchTab commands.-- After each step, record the result with `./scripts/runner step-end --report-file {REPORT_FILE} <group> <step> answer "<observation>" pass "notes"` (or fail if it didn't work).+- Use the exported PINCHTAB_CONTAINER / TOKEN on every ./scripts/pt call (or keep them in your environment).+- After each step, record the result with:+ ./scripts/runner step-end --report-file {REPORT_FILE} <group> <step> answer "<observation>" pass "notes"+ (or fail / skip as appropriate).- Use your judgment to figure out the right PinchTab commands from the skill doc. The group files describe WHAT to do, not HOW.Work through every step in groups {START}-{END}. Do not skip any.```-### 2. Monitor progress+When launching the subagent, also tell it the concrete values for `{CONTAINER_NAME}`, `{TOKEN}`, and `{PROVIDER}`.-While agents run, periodically count step-end recordings in each agent's output file:+### 4. Monitor progress++While agents run, periodically count step-end recordings:```bashgrep -c "step-end" <output_file>```-Expected totals: Batch A ~45, Batch B ~30, Batch C ~33 = 108 total.+Expected totals: Batch A ~45, Batch B ~30, Batch C ~33 = 108 total per provider.-### 3. Collect and summarize+### 5. Tear down + collect results-Once all 3 agents complete, run these steps **in order**. The Agent tool returns each subagent's output file path — save all three as `TRANSCRIPT_A`, `TRANSCRIPT_B`, `TRANSCRIPT_C`.+Once all 3 agents complete, the Agent tool returns each subagent's output file path — save all three as `TRANSCRIPT_A`, `TRANSCRIPT_B`, `TRANSCRIPT_C`.```bash-SKILL_DIR=~/.claude/skills/pinchtab-opt-MERGED="$RESULTS_DIR/merged_${TIMESTAMP}.json"+"$OPT_DIR/down.sh"++SKILL_DIR="$PROJECT_ROOT/skills/pinchtab-opt"+MERGED="$RESULTS_DIR/merged_${PROVIDER}_${TIMESTAMP}.json"# Merge the three agent reports into one JSON (strip non-JSON header lines)cd "$TOOLS_DIR" && \./scripts/runner opt merge-reports \- "$RESULTS_DIR/agentA_${TIMESTAMP}.json" \- "$RESULTS_DIR/agentB_${TIMESTAMP}.json" \- "$RESULTS_DIR/agentC_${TIMESTAMP}.json" \+ "$RESULTS_DIR/agentA_${PROVIDER}_${TIMESTAMP}.json" \+ "$RESULTS_DIR/agentB_${PROVIDER}_${TIMESTAMP}.json" \+ "$RESULTS_DIR/agentC_${PROVIDER}_${TIMESTAMP}.json" \2>/dev/null | grep -v '^Loaded\|^Merged' > "$MERGED"# Inject token usage from the subagent JSONL transcripts@@ -133,30 +272,39 @@ cd "$TOOLS_DIR" && \-r "$MERGED" \"$TRANSCRIPT_A" "$TRANSCRIPT_B" "$TRANSCRIPT_C"-# Print the final comparison table — present this output to the user as-is+# Print the comparison table for this provider — present this output as-is./scripts/runner opt summarize \-r "$MERGED" \-b "$SKILL_DIR/baseline-ref.json" \"$TRANSCRIPT_A" "$TRANSCRIPT_B" "$TRANSCRIPT_C"```-The `--baseline` / `-b` flag loads stored reference timing and ops from `baseline-ref.json` so the Baseline column is fully populated. The transcripts enable the Browser ops and Ops/step rows.+The `-b` flag loads stored reference timing and ops from `baseline-ref.json` so the Baseline column is fully populated. The transcripts enable the Browser ops and Ops/step rows.++If running `all`, repeat steps 1–5 for each remaining provider, then present chrome / cloak / ghost-chrome side by side in the final summary.## Reference Numbers-- **Baseline**: 108/108 steps, 272 ops, 49s total, 0.5s/step (stored in `baseline-ref.json`)-- **Expected agent range**: 250-400 browser ops, 2.5-4 ops/step-- **Group count**: 47 groups, 108 total steps+- **Baseline**: 108/108 steps, 272 ops, ~49s total, 2.5 ops/step (stored in `baseline-ref.json`)+- **Expected agent range**: 250–400 browser ops, 2.5–4 ops/step+- **Group count**: 47 groups (`group-00` … `group-46`), 108 total steps++---## File Locations (relative to project root)| Path | Purpose ||------|---------|-| `tests/optimization/subagent-context.md` | Subagent instructions (env, wrapper, recording) |-| `tests/optimization/index.md` | Group listing |-| `tests/optimization/group-00.md` .. `group-46.md` | Task descriptions |-| `skills/pinchtab/SKILL.md` | PinchTab command reference (read by subagent) |-| `tests/tools/scripts/pt` | PinchTab wrapper (CWD must be `tests/tools`) |+| `tests/optimization-setup/subagent-context.md` | Setup subagent instructions (native build, OOTB flow) |+| `tests/optimization-setup/group-00.md` … `group-01.md` | Setup task descriptions |+| `tests/optimization/subagent-context.md` | Optimization subagent instructions (env, wrapper, recording) |+| `tests/optimization/index.md` | Optimization group listing |+| `tests/optimization/group-00.md` … `group-46.md` | Optimization task descriptions |+| `tests/optimization/up.sh` | Provider-aware setup (chrome vs cloak) |+| `tests/optimization/down.sh` | Tear down after a provider run |+| `skills/pinchtab/SKILL.md` | PinchTab command reference (read by subagents) |+| `skills/pinchtab-dev/SKILL.md` | Build instructions (read by the setup subagent) |+| `tests/tools/scripts/pt` | PinchTab Docker wrapper (CWD must be `tests/tools`) || `tests/tools/scripts/runner` | Step recorder (CWD must be `tests/tools`) |-| `tests/tools/scripts/baseline.sh` | Baseline (subagent must NOT read this) |-| `~/.claude/skills/pinchtab-opt/baseline-ref.json` | Stored baseline timing/ops reference for table |+| `tests/tools/scripts/baseline.sh` | Baseline (subagents must NOT read this) |+| `skills/pinchtab-opt/baseline-ref.json` | Stored baseline timing/ops reference for the table |diff --git a/skills/pinchtab-todo/SKILL.md b/skills/pinchtab-todo/SKILL.mddeleted file mode 100644index 40fb3f18..00000000--- a/skills/pinchtab-todo/SKILL.md+++ /dev/null@@ -1,142 +0,0 @@-----name: pinchtab-todo-description: "Process the next task from the todo pipeline. Prepares or executes one task per cycle using todo.md (backlog) and todo-next.md (current task). Use when asked to 'run todo', 'process todo', 'next task', or 'work on the next todo'."------# PinchTab Todo Runner--Two-phase pipeline: **prepare** a task (research + write up), then **execute** it next cycle. One action per invocation.--## Path Resolution--```bash-PROJECT_ROOT=$(git rev-parse --show-toplevel)-TODO_FILE="$PROJECT_ROOT/todo.md"-TODO_NEXT="$PROJECT_ROOT/todo-next.md"-```--## Execution--### 0. Ensure recurring schedule exists--Before doing any work, check whether a schedule (routine) is already active for this skill:--1. Use `CronList` to list existing routines.-2. Look for one whose name or prompt references `pinchtab-todo`.-3. **If a matching schedule exists** — continue to step 1.-4. **If no matching schedule exists** — create one using `CronCreate` that runs every 30 minutes with the prompt `/pinchtab-todo`. Then continue to step 1.--### 1. Check for `todo-next.md`--- **If `todo-next.md` does NOT exist** → go to **Phase A** (prepare).-- **If `todo-next.md` EXISTS** → go to **Phase B** (execute).-------## Phase A — Prepare the next task--Goal: pick the first incomplete task from `todo.md`, research it, and write a detailed `todo-next.md`. Do NOT implement anything.--### A1. Read `todo.md`--If the file does not exist, is empty, or every task is marked `[x]`, report that the backlog is clear and stop.--### A2. Pick the first `- [ ]` task--Take the first incomplete item from the list.--### A3. Research the task--Investigate the current codebase to understand:-- What files/packages are involved-- How similar features are implemented-- What the right approach is-- Any edge cases or risks--### A4. Write `todo-next.md`--Create `todo-next.md` with this structure:--```markdown-# <task title>--> **Source:** `todo.md` line N-> **Status:** ready--## User Story--As an [agent/user/developer], I want [what] so that [why].--## TLDR--One paragraph summary of what needs to happen and the approach.--## Details--- Files to change: ...-- Approach: ...-- Edge cases: ...-- Tests needed: ...--## Acceptance Criteria--- [ ] Criterion 1-- [ ] Criterion 2-- [ ] `./dev all` passes-```--### A5. Stop--Report that the next task has been prepared. Do not start implementation — that happens in Phase B on the next cycle.-------## Phase B — Execute the current task--Goal: implement the task described in `todo-next.md`, verify the build, then prepare the next one.--### B1. Read `todo-next.md`--Understand the task, user story, approach, and acceptance criteria.--### B2. Implement the task--Spawn a subagent to perform the work. Replace `{PROJECT_ROOT}` and `{TASK_DETAILS}` with actual values:--```-You are working on the PinchTab project at {PROJECT_ROOT}.--Your task is described below:-{TASK_DETAILS}--Start by reading the development skill for context:-1. Read `{PROJECT_ROOT}/skills/pinchtab-dev/SKILL.md` — dev commands, architecture, and workflow.-2. Read `{PROJECT_ROOT}/skills/pinchtab/SKILL.md` — PinchTab command reference (if needed).--Then implement the task following the approach and acceptance criteria.-When done, report what you changed.-```--Wait for the subagent to complete and review its output.--### B3. Verify the build--```bash-cd "$PROJECT_ROOT" && ./dev all-```--- **If `./dev all` passes**: continue to B4.-- **If `./dev all` fails**: read the failure, fix the issues, re-run. Up to 3 attempts. If still failing after 3 attempts, report the failure and stop — leave `todo-next.md` in place for the next cycle.--### B4. Mark done and clean up--1. Mark the corresponding task as `[x]` in `todo.md`.-2. Delete `todo-next.md`.--### B5. Prepare the next task--Now run **Phase A** (steps A1–A5) to prepare the next `todo-next.md` from the backlog. This way the next cycle can jump straight into execution.--### B6. Stop--Report what was completed and what was prepared for next cycle.diff --git a/tests/coldstart/subagent-context.md b/tests/coldstart/subagent-context.mddeleted file mode 100644index b6bd14f7..00000000--- a/tests/coldstart/subagent-context.md+++ /dev/null@@ -1,78 +0,0 @@-# Cold-Start Subagent Context--You are running PinchTab cold-start validation. Your job is to build PinchTab from source, then verify that the documented "fresh install" user journey works: `pinchtab nav <url>` should auto-create a config, auto-start the server, and navigate — all in one command, no manual `config init`, no manual `pinchtab server`, no `session create`. Execute groups 0-1 against local fixture HTML files.--## What to read--1. **PinchTab dev skill**: `skills/pinchtab-dev/SKILL.md` — how to build the project.-2. **PinchTab skill**: `skills/pinchtab/SKILL.md` — full command reference, configuration, and patterns.-3. **Group files**: `tests/coldstart/group-00.md` and `tests/coldstart/group-01.md` — step definitions and verification markers, written specifically for the cold-start lane (native binary, no Docker).--## What NOT to read--- `tests/tools/scripts/baseline.sh` — deterministic baseline; reading it defeats the purpose.-- `tests/benchmark/` — separate benchmark lane, not your concern.-- `tests/optimization/` — Docker-based lane; uses `./scripts/pt`, which does not apply here.--## Environment--- Project root: the git root (run `git rev-parse --show-toplevel` if needed)-- Go, Python 3, Chrome, curl, and jq are available on the host-- No Docker required — everything runs natively-- Fixture HTML files: `tests/tools/fixtures/` (wiki.html, wiki-go.html, articles.html, dashboard.html, etc.)--## Setup--### 1. Build from source--Use `./dev build` as described in the dev skill. The binary is placed at `./pinchtab` in the project root.--### 2. Start fixture HTTP server--The fixture pages need to be served over HTTP. Use Python's built-in server on a free port:--```bash-FIXTURE_PORT=$(python3 -c 'import socket; s=socket.socket(); s.bind(("",0)); print(s.getsockname()[1]); s.close()')-python3 -m http.server $FIXTURE_PORT --directory tests/tools/fixtures --bind 127.0.0.1 &-```--### 3. Point at a throwaway config — DO NOT init it or start the server--Cold-start matches the documented first-use journey from the README: a user installs PinchTab and just runs `pinchtab nav <url>`. The CLI auto-creates a config (with a generated token) and auto-starts the server. The cold-start verifies that pathway works, so **do not run any of these manually**:--- `./pinchtab config init` — the auto-flow creates the config on first command. Step 0.1 is the test of that.-- `./pinchtab server` — the auto-flow starts it on first command. Step 0.1 is the test of that.-- `./pinchtab session create` — local single-user CLI calls authenticate from the config token directly; sessions are an advanced feature.--What you DO need to do:--```bash-# Isolate from the user's real ~/.pinchtab/config.json by pointing at a throwaway path.-# The path must NOT exist yet — step 0.1 verifies the CLI creates it.-export PINCHTAB_CONFIG=~/.pinchtab/coldstart-config-$(date +%s).json-```--`~/.pinchtab/` is preferred over `/tmp` because PinchTab tightens parent-directory perms to 0700 on save; on macOS that fails on `/tmp` (root-owned `/private/tmp`). The user's home dir always works.--If a step in groups 0-1 actually requires a different config value, the agent should discover that from a failure and modify the config with `./pinchtab config set <path> <value>`. The cold-start groups have been written so this should not be necessary — they verify the OOTB auto-flow.--Use `./pinchtab` CLI commands for everything — never use `./scripts/pt` (that is the Docker wrapper) and never use curl against the HTTP API. The native CLI honors `PINCHTAB_TOKEN`, `PINCHTAB_SERVER`, and `PINCHTAB_CONFIG` env vars, so you can override any of them inline (e.g. `PINCHTAB_TOKEN=wrong-token ./pinchtab health` for the auth-rejection check in step 0.4).--## Running steps--Fixture URLs in the cold-start group files use `http://localhost:$FIXTURE_PORT/` directly — no substitution needed. Export `FIXTURE_PORT` in your shell before running the steps so the literal `$FIXTURE_PORT` in commands resolves correctly.--Execute every step in groups 0 and 1. For each step:--1. Run the appropriate PinchTab commands-2. Verify the expected markers appear in the output-3. Record pass/fail with the command used and output--## Cleanup--When finished:-- Kill the fixture server and PinchTab server.-- Delete the temp config: `rm -f "$PINCHTAB_CONFIG"`.-- Delete the built binary: `rm -f ./pinchtab`.--You should not need to restore anything — the cold-start only wrote to `~/.pinchtab/coldstart-config-<timestamp>.json`, never to the user's real `~/.pinchtab/config.json`.diff --git a/tests/coldstart/group-00.md b/tests/optimization-setup/group-00.mdsimilarity index 95%rename from tests/coldstart/group-00.mdrename to tests/optimization-setup/group-00.mdindex 22ce6dd0..f6191d59 100644--- a/tests/coldstart/group-00.md+++ b/tests/optimization-setup/group-00.md@@ -4,7 +4,7 @@ A fresh user is told to "install PinchTab and run `pinchtab nav <url>`" — the**Do not** run `./pinchtab config init` or `./pinchtab server` manually. The whole point of group 0 is to verify the auto-flow handles them. Likewise do not create a session — the CLI uses the token from the auto-created config.-The setup section in `subagent-context.md` already exported `PINCHTAB_CONFIG=~/.pinchtab/coldstart-config-<timestamp>.json` to a non-existent path. Step 0.1 is the very first command you run against the binary.+The setup section in `subagent-context.md` already exported `PINCHTAB_CONFIG=~/.pinchtab/setup-config-<timestamp>.json` to a non-existent path. Step 0.1 is the very first command you run against the binary.### 0.1 Cold nav auto-creates config and starts serverRun a single navigation against the fixture server with no preceding `pinchtab` calls:diff --git a/tests/coldstart/group-01.md b/tests/optimization-setup/group-01.mdsimilarity index 100%rename from tests/coldstart/group-01.mdrename to tests/optimization-setup/group-01.mddiff --git a/tests/optimization-setup/subagent-context.md b/tests/optimization-setup/subagent-context.mdnew file mode 100644index 00000000..38e61765--- /dev/null+++ b/tests/optimization-setup/subagent-context.md@@ -0,0 +1,96 @@+# Setup Subagent Context++You are running the PinchTab **setup** test. Your job is to build PinchTab from source, then verify that the documented "fresh install" user journey works for a chosen browser provider: `pinchtab nav <url>` should auto-create a config, auto-start the server, and navigate — all in one command, no manual `config init`, no manual `pinchtab server`, no `session create`. Execute groups 0-1 against local fixture HTML files.++You will be told the active **`PROVIDER`** when you are launched: `chrome` (default), `cloak`, or `ghost-chrome`. The auto-flow always produces a chrome-flavoured config first; the documented switch to a different provider is part of what this test validates (see "Provider switch" below).++## What to read++1. **PinchTab dev skill**: `skills/pinchtab-dev/SKILL.md` — how to build the project.+2. **PinchTab skill**: `skills/pinchtab/SKILL.md` — full command reference, configuration, and patterns.+3. **Group files**: `tests/optimization-setup/group-00.md` and `tests/optimization-setup/group-01.md` — step definitions and verification markers, written specifically for the setup lane (native binary, no Docker).++## What NOT to read++- `tests/tools/scripts/baseline.sh` — deterministic baseline; reading it defeats the purpose.+- `tests/benchmark/` — separate benchmark lane, not your concern.+- `tests/optimization/` — the Docker-based opt lane; it uses `./scripts/pt`, which does not apply here.++## Environment++- Project root: the git root (run `git rev-parse --show-toplevel` if needed)+- Go, Python 3, Chrome, curl, and jq are available on the host+- No Docker required — everything runs natively+- Fixture HTML files: `tests/tools/fixtures/` (wiki.html, wiki-go.html, articles.html, dashboard.html, etc.)++## Setup++### 1. Build from source++Use `./dev build` as described in the dev skill. The binary is placed at `./pinchtab` in the project root.++### 2. Start fixture HTTP server++The fixture pages need to be served over HTTP. Use Python's built-in server on a free port:++```bash+FIXTURE_PORT=$(python3 -c 'import socket; s=socket.socket(); s.bind(("",0)); print(s.getsockname()[1]); s.close()')+python3 -m http.server $FIXTURE_PORT --directory tests/tools/fixtures --bind 127.0.0.1 &+```++### 3. Point at a throwaway config — DO NOT init it or start the server++The setup test matches the documented first-use journey from the README: a user installs PinchTab and just runs `pinchtab nav <url>`. The CLI auto-creates a config (with a generated token) and auto-starts the server. The setup test verifies that pathway works, so **do not run any of these manually**:++- `./pinchtab config init` — the auto-flow creates the config on first command. Step 0.1 is the test of that.+- `./pinchtab server` — the auto-flow starts it on first command. Step 0.1 is the test of that.+- `./pinchtab session create` — local single-user CLI calls authenticate from the config token directly; sessions are an advanced feature.++What you DO need to do:++```bash+# Isolate from the user's real ~/.pinchtab/config.json by pointing at a throwaway path.+# The path must NOT exist yet — step 0.1 verifies the CLI creates it.+export PINCHTAB_CONFIG=~/.pinchtab/setup-config-$(date +%s).json+```++`~/.pinchtab/` is preferred over `/tmp` because PinchTab tightens parent-directory perms to 0700 on save; on macOS that fails on `/tmp` (root-owned `/private/tmp`). The user's home dir always works.++If a step in groups 0-1 actually requires a different config value, the agent should discover that from a failure and modify the config with `./pinchtab config set <path> <value>`. The setup groups have been written so this should not be necessary — they verify the OOTB auto-flow.++Use `./pinchtab` CLI commands for everything — never use `./scripts/pt` (that is the Docker wrapper) and never use curl against the HTTP API. The native CLI honors `PINCHTAB_TOKEN`, `PINCHTAB_SERVER`, and `PINCHTAB_CONFIG` env vars, so you can override any of them inline (e.g. `PINCHTAB_TOKEN=wrong-token ./pinchtab health` for the auth-rejection check in step 0.4).++## Provider switch (only if `PROVIDER` is not `chrome`)++Step 0.1 always tests the auto-flow with the default provider (chrome). After step 0.1 succeeds and before continuing to the remaining steps, switch the active browser provider using **only documented commands**:++- `cloak`: `./pinchtab config set browsers.default cloak` (and any required provider config — discover via failure rather than reading internal code).+- `ghost-chrome`: `./pinchtab config set browsers.default ghost-chrome`.+- `chrome`: skip — already the default.++This sub-step is itself part of what the setup test measures: a fresh user must be able to switch the provider via the documented CLI without diving into internals. If you cannot complete the switch with documented commands alone, record that as a setup failure.++Host prerequisites for non-chrome providers:+- `cloak` requires CloakBrowser installed at the path documented in `skills/pinchtab/SKILL.md`.+- `ghost-chrome` uses the host's Chrome installation (same as `chrome`).++If the required binary is missing, that's a legitimate setup failure — record it; do not patch around it.++## Running steps++Fixture URLs in the setup group files use `http://localhost:$FIXTURE_PORT/` directly — no substitution needed. Export `FIXTURE_PORT` in your shell before running the steps so the literal `$FIXTURE_PORT` in commands resolves correctly.++Execute every step in groups 0 and 1. For each step:++1. Run the appropriate PinchTab commands+2. Verify the expected markers appear in the output+3. Record pass/fail with the command used and output++## Cleanup++When finished:+- Kill the fixture server and PinchTab server.+- Delete the temp config: `rm -f "$PINCHTAB_CONFIG"`.+- Delete the built binary: `rm -f ./pinchtab`.++You should not need to restore anything — the setup test only wrote to `~/.pinchtab/setup-config-<timestamp>.json`, never to the user's real `~/.pinchtab/config.json`.diff --git a/tests/optimization/down.sh b/tests/optimization/down.shnew file mode 100755index 00000000..e853cbec--- /dev/null+++ b/tests/optimization/down.sh@@ -0,0 +1,15 @@+#!/usr/bin/env bash+# tests/optimization/down.sh+#+# Tear down whatever optimization benchmark instance is running.+# Safe to call even if nothing is up.+set -euo pipefail++# Remove the standalone cloak container if present+docker rm -f optimization-pinchtab >/dev/null 2>&1 || true++# Bring down the compose stack (this is a no-op if it wasn't started by us)+cd "$(git rev-parse --show-toplevel)/tests/tools" 2>/dev/null || true+docker compose -f docker-compose.yml down --remove-orphans 2>/dev/null || true++echo "optimization benchmark containers removed"diff --git a/tests/optimization/subagent-context.md b/tests/optimization/subagent-context.mdindex 5c093444..f62b6bbf 100644--- a/tests/optimization/subagent-context.md+++ b/tests/optimization/subagent-context.md@@ -1,6 +1,13 @@# Subagent Context-You are running PinchTab optimization tasks. You will be given a set of group files, each containing numbered steps to execute using the PinchTab browser automation tool.+You are running PinchTab optimization tasks against a specific browser **provider** (chrome or cloak).++You will be given:+- The active PROVIDER+- Your report file path+- The range of groups you are responsible for++You will be given a set of group files, each containing numbered steps to execute using the PinchTab browser automation tool.## What to read@@ -49,6 +56,32 @@ For failures:- **Quote actual output, don't paraphrase.** The answer field must include the literal text or marker from the tool output. For example, if the server returns `status: ok`, write `status: ok` in the answer — not "Server responded with ok". Verification patterns match against exact substrings, so paraphrasing causes false failures.- **Always include `UPPER_CASE_MARKER` strings verbatim.** Fixture pages embed verification markers like `SUGGESTIONS_VISIBLE_COUNT_2`, `VERIFY_HOME_LOADED_12345`, `SCROLL_MIDDLE_MARKER`, etc. When you see these in the page content or tool output, copy them exactly into your answer — they are the primary tokens that automated verification matches against.+## Provider & Environment++The benchmark can run against different browser providers:++- `chrome` (default)+- `cloak` (CloakBrowser for stealth / anti-detection testing)++You will be told the active `PROVIDER` when you are launched.++**Critical:** Before running any `./scripts/pt` command, export the correct container and token:++```bash+export PINCHTAB_CONTAINER=optimization-pinchtab # for cloak runs+# or+export PINCHTAB_CONTAINER=tools-pinchtab-1 # for normal compose chrome runs++export PINCHTAB_TOKEN=benchmark-token++# Then all commands go through the wrapper:+./scripts/pt nav https://...+./scripts/pt --tab "$TAB" click e5+...+```++The wrapper (`./scripts/pt`) respects these two environment variables and forwards them into the container. Always set them in your shell at the start of the session and after any subshell.+## Execution approach1. Read the PinchTab skill to learn available commands.diff --git a/tests/optimization/up.sh b/tests/optimization/up.shnew file mode 100755index 00000000..01c692c2--- /dev/null+++ b/tests/optimization/up.sh@@ -0,0 +1,224 @@+#!/usr/bin/env bash+# tests/optimization/up.sh <provider>+#+# Bring up a PinchTab instance for the optimization benchmark with the+# requested browser provider (chrome | cloak | ghost-chrome).+#+# - chrome : Uses the existing tests/tools/docker-compose.yml (regular image).+# - cloak : Starts the benchmark fixtures + a standalone container using the+# cloakbrowser smoke image (pinchtab-cloakbrowser:test).+# - ghost-chrome : Same Chrome image as `chrome` but with a config that sets+# `browsers.default = "ghost-chrome"` (static-first routing).+# Runs as a standalone container against the shared fixtures.+#+# The script ensures the internal "fixtures" hostname works for all paths+# so that group files and subagent-context.md continue to use http://fixtures/+# without changes.+#+# After success it prints READY with the container name, token, etc.+# Call down.sh when finished.+#+# Environment:+# REBUILD=1 Force rebuild of the chosen image.+set -euo pipefail++PROVIDER="${1:?provider required (chrome|cloak|ghost-chrome)}"+case "$PROVIDER" in chrome|cloak|ghost-chrome) ;; *) echo "invalid provider: $PROVIDER"; exit 2 ;; esac++ROOT="$(git rev-parse --show-toplevel)"+TOOLS_DIR="$ROOT/tests/tools"+OPT_DIR="$ROOT/tests/optimization"+NAME="optimization-pinchtab"+TOKEN="benchmark-token"++# shellcheck source=/dev/null+source "$ROOT/scripts/lib/smoke-common.sh"+# shellcheck source=/dev/null+source "$ROOT/scripts/lib/smoke-config.sh"++cd "$TOOLS_DIR"++ensure_fixtures() {+ # Make sure the nginx fixtures service (and its network) exists.+ docker compose -f docker-compose.yml up -d --no-recreate fixtures >/dev/null 2>&1 || true+}++get_fixtures_ip() {+ # Return the IP of the fixtures container on the benchmark network.+ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' tools-fixtures-1 2>/dev/null || echo ""+}++ensure_image() {+ local image="$1"+ local dockerfile="$2"++ if [ "${REBUILD:-}" = "1" ] || ! docker image inspect "$image" >/dev/null 2>&1; then+ echo "Building $image..." >&2+ if [ -n "$dockerfile" ]; then+ docker build -f "$ROOT/$dockerfile" -t "$image" "$ROOT" >&2+ else+ docker build -t "$image" "$ROOT" >&2+ fi+ else+ echo "Reusing $image (set REBUILD=1 to rebuild)" >&2+ fi+}++case "$PROVIDER" in+ chrome)+ echo "Starting optimization benchmark with chrome provider (compose)..." >&2+ docker compose -f docker-compose.yml down --remove-orphans 2>/dev/null || true+ docker compose -f docker-compose.yml up -d --build pinchtab fixtures+ # Give it a moment+ sleep 8+ if ! curl -sf -H "Authorization: Bearer $TOKEN" http://127.0.0.1:9867/health >/dev/null 2>&1; then+ echo "ERROR: chrome pinchtab did not become healthy" >&2+ docker compose logs --tail 50 pinchtab || true+ exit 1+ fi+ # The compose service name inside docker is tools-pinchtab-1 for the default project+ CONTAINER_NAME="tools-pinchtab-1"+ CLOAK_BIN=""+ ;;++ cloak)+ echo "Starting optimization benchmark with cloak provider..." >&2+ ensure_fixtures++ FIXTURES_IP="$(get_fixtures_ip)"+ if [ -z "$FIXTURES_IP" ]; then+ echo "ERROR: could not determine fixtures container IP" >&2+ exit 1+ fi++ ensure_image "pinchtab-cloakbrowser:test" "tests/tools/docker/cloakbrowser-smoke.Dockerfile"++ CONFIG_DIR="$OPT_DIR/.tmp"+ CONFIG_PATH="$CONFIG_DIR/pinchtab-cloak.json"+ mkdir -p "$CONFIG_DIR"++ # Use "fixtures" as the host (we'll add it via --add-host on the container)+ write_provider_config "cloak" "$CONFIG_PATH" "$TOKEN" "fixtures" "" "/opt/cloakbrowser/chrome"++ # Allow the benchmark fixtures (already in the config) plus localhost for convenience+ python3 - "$CONFIG_PATH" <<'PY'+import json, sys+p = sys.argv[1]+c = json.load(open(p))+c.setdefault("security", {}).setdefault("allowedDomains", [])+if "fixtures" not in c["security"]["allowedDomains"]:+ c["security"]["allowedDomains"].append("fixtures")+json.dump(c, open(p, "w"), indent=2)+PY++ docker rm -f "$NAME" >/dev/null 2>&1 || true++ docker run -d --name "$NAME" \+ --network tools_benchmark-net \+ --add-host "fixtures:${FIXTURES_IP}" \+ -p 127.0.0.1:9867:9867 \+ --shm-size=2g \+ --dns 8.8.8.8 --dns 1.1.1.1 \+ -v "$CONFIG_PATH:/fixture-config/pinchtab.json:ro" \+ -e PINCHTAB_CONFIG=/fixture-config/pinchtab.json \+ pinchtab-cloakbrowser:test >/dev/null++ echo "Waiting for /health on 127.0.0.1:9867 (cloak)..." >&2+ for i in $(seq 1 45); do+ if curl -sf -H "Authorization: Bearer $TOKEN" http://127.0.0.1:9867/health >/dev/null 2>&1; then+ CONTAINER_NAME="$NAME"+ CLOAK_BIN="/opt/cloakbrowser/chrome"+ break+ fi+ sleep 1+ done++ if [ -z "${CONTAINER_NAME:-}" ]; then+ echo "ERROR: cloak pinchtab did not become healthy after 45s" >&2+ docker logs "$NAME" 2>&1 | tail -60 >&2+ exit 1+ fi+ ;;++ ghost-chrome)+ echo "Starting optimization benchmark with ghost-chrome provider..." >&2+ ensure_fixtures++ FIXTURES_IP="$(get_fixtures_ip)"+ if [ -z "$FIXTURES_IP" ]; then+ echo "ERROR: could not determine fixtures container IP" >&2+ exit 1+ fi++ # Ghost-chrome reuses the chrome compose image (`tools-pinchtab:latest`) —+ # the difference is purely config (browsers.default = "ghost-chrome").+ CHROME_IMAGE="tools-pinchtab:latest"+ if [ "${REBUILD:-}" = "1" ] || ! docker image inspect "$CHROME_IMAGE" >/dev/null 2>&1; then+ echo "Building $CHROME_IMAGE via compose..." >&2+ docker compose -f docker-compose.yml build pinchtab >&2+ else+ echo "Reusing $CHROME_IMAGE (set REBUILD=1 to rebuild)" >&2+ fi++ CONFIG_DIR="$OPT_DIR/.tmp"+ CONFIG_PATH="$CONFIG_DIR/pinchtab-ghost-chrome.json"+ mkdir -p "$CONFIG_DIR"++ # Start from a chrome-flavoured config, then flip browsers.default to+ # "ghost-chrome" and pin configVersion so the startup wizard does not+ # rewrite the file. Mirrors writeGhostChromeConfig in+ # tests/tools/runner/internal/e2e/provider.go.+ write_provider_config "chrome" "$CONFIG_PATH" "$TOKEN" "fixtures" "" ""+ python3 - "$CONFIG_PATH" <<'PY'+import json, sys+p = sys.argv[1]+c = json.load(open(p))+c["configVersion"] = "0.8.0"+browsers = c.setdefault("browsers", {})+browsers["default"] = "ghost-chrome"+browsers["available"] = ["ghost-chrome"]+c.setdefault("security", {}).setdefault("allowedDomains", [])+if "fixtures" not in c["security"]["allowedDomains"]:+ c["security"]["allowedDomains"].append("fixtures")+json.dump(c, open(p, "w"), indent=2)+PY++ docker rm -f "$NAME" >/dev/null 2>&1 || true++ docker run -d --name "$NAME" \+ --network tools_benchmark-net \+ --add-host "fixtures:${FIXTURES_IP}" \+ -p 127.0.0.1:9867:9867 \+ --shm-size=2g \+ --dns 8.8.8.8 --dns 1.1.1.1 \+ -v "$CONFIG_PATH:/fixture-config/pinchtab.json:ro" \+ -e PINCHTAB_CONFIG=/fixture-config/pinchtab.json \+ "$CHROME_IMAGE" >/dev/null++ echo "Waiting for /health on 127.0.0.1:9867 (ghost-chrome)..." >&2+ for i in $(seq 1 30); do+ if curl -sf -H "Authorization: Bearer $TOKEN" http://127.0.0.1:9867/health >/dev/null 2>&1; then+ CONTAINER_NAME="$NAME"+ CLOAK_BIN=""+ break+ fi+ sleep 1+ done++ if [ -z "${CONTAINER_NAME:-}" ]; then+ echo "ERROR: ghost-chrome pinchtab did not become healthy after 30s" >&2+ docker logs "$NAME" 2>&1 | tail -60 >&2+ exit 1+ fi+ ;;+esac++cat <<EOF+READY+provider=$PROVIDER+container=$CONTAINER_NAME+token=$TOKEN+port=9867+config=${CONFIG_PATH:-"(compose default)"}+EOF+exit 0