Skip to content

Instantly share code, notes, and snippets.

@zonca
Last active November 4, 2026 04:28
Show Gist options
  • Select an option

  • Save zonca/5ebe5a0f82df0dc50e671ceaced16e80 to your computer and use it in GitHub Desktop.

Select an option

Save zonca/5ebe5a0f82df0dc50e671ceaced16e80 to your computer and use it in GitHub Desktop.
Configuration files for the tutorial verification loop: OpenCode subagents (executor and improver), Chrome CDP launcher, browser-use accessibility helpers, round report schema
description Fixes README.md where a tester report shows it disagrees with what actually happens
mode subagent
permissions
action resource effect
edit
*
allow
action resource effect
shell
*
deny

You fix documentation. You receive a tester report about README.md.

  • Change README.md only where the report shows a FAIL, and only the lines involved.
  • Read the code in src/ to find the correct names and arguments.
  • Do not add new sections or content. Do not change any other file.

Reply with the list of lines you changed, before and after.

description Tests README.md by following it literally as a new user, from a fresh clone
mode subagent
permissions
action resource effect
edit
*
deny
action resource effect
shell
*
allow

You are a tutorial tester. You check that README.md works for a new user.

  1. Read README.md in the current repository: that is the version under test.
  2. Create a new empty directory with mktemp -d and work only there.
  3. Run every command and every code block of README.md exactly as written, in order, using a fresh virtual environment inside that directory. Do not fix or guess anything: if a step fails, record it and continue with the next one if possible.
  4. Never edit any file in the repository.

Report a numbered list: each step as PASS or FAIL, with the command and the relevant output or error. End with one line: RESULT: ALL PASS or RESULT: N FAILURES.

Tutorial verification loop: configuration files

Companion files for the blog post "Keeping interactive tutorials up to date with an orchestrator and AI subagents".

File What it is
readme-tester.md Small version: OpenCode subagent that follows a README literally, cannot edit
readme-fixer.md Small version: OpenCode subagent that fixes the failing lines, cannot run commands
tutorial-executor.md OpenCode subagent that walks the tutorial literally in the live console
tutorial-improver.md OpenCode subagent that fixes the documentation from the executor report
chrome_cdp_start.sh Launch Chrome with a CDP endpoint on a dedicated profile
browser_helpers.py Accessibility-tree helpers for the browser-use CLI
round_report.schema.json Schema of the per-round report the executor writes

The subagent files go in .opencode/agents/ of the repository that holds the tutorials. Start with the readme-tester and readme-fixer pair, which needs nothing but a terminal. The executor is launched with the round report as its only input, the improver with the report verbatim.

Setup

# the driver
uv tool install --python 3.12 --upgrade --force browser-use

# a Chrome with a CDP endpoint on a dedicated profile, headless by default
./chrome_cdp_start.sh --headless
export BU_CDP_URL=http://127.0.0.1:9222

# then drive the browser
browser-use <<'PY'
print(page_info())
PY

The first login needs a visible window (./chrome_cdp_start.sh without --headless), because multi-factor authentication and consent screens are human gates. After that the same profile carries the session, and the runs go back to headless.

"""Accessibility-tree helpers for the browser-use CLI.
The helpers of the CLI (page_info, new_tab, switch_tab, list_tabs, click_at_xy, cdp)
are pre-imported, so this file only adds the page-reading layer on top of them.
Use the accessibility tree rather than the DOM: it pierces iframes and shadow DOM,
and it gives the same view a screen reader (and therefore a user) sees.
"""
import time
def ax_rows():
"""Every node of the accessibility tree, with its role and accessible name."""
nodes = cdp("Accessibility.getFullAXTree")["nodes"]
rows = []
for n in nodes:
role = n.get("role", {}).get("value", "")
name = n.get("name") or {}
if isinstance(name, dict):
name = name.get("value", "")
rows.append({"role": role, "name": str(name), "backend": n.get("backendDOMNodeId")})
return rows
def find(role=None, name_contains=None, exact=None):
"""First node matching the role and the name."""
for row in ax_rows():
if role and row["role"] != role:
continue
if name_contains and name_contains not in row["name"]:
continue
if exact and row["name"] != exact:
continue
return row
return None
def find_all(role=None, name_contains=None):
"""All the nodes matching the role and the name."""
out = []
for row in ax_rows():
if role and row["role"] != role:
continue
if name_contains and name_contains not in row["name"]:
continue
out.append(row)
return out
def center(entry):
"""Center of the clickable box of a node, in viewport coordinates."""
quad = cdp("DOM.getBoxModel", backendNodeId=entry["backend"])["model"]["content"]
return sum(quad[0::2]) / 4, sum(quad[1::2]) / 4
def click_entry(entry, wait_s=1.5):
"""Click a node found in the accessibility tree, by coordinates."""
x, y = center(entry)
click_at_xy(x, y)
time.sleep(wait_s)
def dump_names(roles=None, contains=None, limit=200):
"""Human-readable dump of the page, used to decide what to do next."""
out = []
for row in ax_rows():
if roles and row["role"] not in roles:
continue
if contains and contains not in row["name"]:
continue
out.append(f"{row['role']}: {row['name'][:130]}")
if len(out) >= limit:
break
return out
#!/usr/bin/env bash
# Launch Chrome with a CDP endpoint on a dedicated profile, for the browser-use CLI.
#
# Why not let the driver auto-launch Chrome: recent Chrome versions refuse
# --remote-debugging-port on the default user-data-dir, and the harness cannot pass a
# custom one, so we launch Chrome ourselves with a profile dedicated to automation.
#
# Usage: ./chrome_cdp_start.sh [--headless]
# Then export BU_CDP_URL=http://127.0.0.1:9222 and drive the browser with:
# browser-use <<'PY'
# print(page_info())
# PY
set -euo pipefail
PORT="${BU_PORT:-9222}"
PROFILE="${BU_CHROME_PROFILE:-$HOME/.config/browser-use/chrome-profile}"
MODE="visible"
if [ "${BU_HEADLESS:-0}" = "1" ] || [ "${1:-}" = "--headless" ]; then MODE="headless"; fi
if curl -fsS "http://127.0.0.1:${PORT}/json/version" >/dev/null 2>&1; then
echo "CDP already live at http://127.0.0.1:${PORT} (mode: $MODE, existing instance)"
exit 0
fi
mkdir -p "$PROFILE"
EXTRA=()
if [ "$MODE" = "headless" ]; then
EXTRA=(--headless=new --disable-gpu --window-size=1280,900 about:blank)
fi
nohup google-chrome \
--user-data-dir="$PROFILE" \
--remote-debugging-port="$PORT" \
--remote-debugging-address=127.0.0.1 \
--no-first-run --no-default-browser-check \
"${EXTRA[@]}" \
>/tmp/chrome-cdp-launch.log 2>&1 &
disown
for _ in $(seq 1 15); do
sleep 1
if curl -fsS "http://127.0.0.1:${PORT}/json/version" >/dev/null 2>&1; then
echo "CDP live at http://127.0.0.1:${PORT} (mode: $MODE, profile: $PROFILE)"
exit 0
fi
done
echo "CDP did not come up; see /tmp/chrome-cdp-launch.log" >&2
exit 1
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Round report",
"description": "One report per round of the tutorial verification loop.",
"type": "object",
"required": ["round", "phase", "results", "cleaned_up", "summary"],
"properties": {
"round": {"type": "integer", "minimum": 1},
"phase": {
"type": "string",
"enum": ["baseline_polish", "live_walkthrough", "fix", "final", "docs_site_sync"]
},
"started_at": {"type": "string", "format": "date-time"},
"model": {"type": "string"},
"commits": {"type": "array", "items": {"type": "string"}},
"results": {
"type": "array",
"description": "One entry per guide, always, even for a pure pass.",
"items": {
"type": "object",
"required": ["guide", "status", "severity"],
"properties": {
"guide": {"type": "string"},
"status": {"type": "string", "enum": ["pass", "partial", "fail"]},
"severity": {
"type": "string",
"enum": ["critical", "major", "minor", "none"],
"description": "How bad the documentation defect is for the reader, not for the agent."
},
"detail": {"type": "string"},
"evidence": {"type": "string"}
}
}
},
"resources": {
"type": "object",
"description": "Resources created by this run, plus the pre-existing inventory.",
"properties": {
"project_id": {"type": "string"},
"note": {"type": "string"}
},
"additionalProperties": {"type": "string"}
},
"actual_versions": {
"type": "object",
"description": "Exact versions observed live, used later to refresh the expected-output blocks.",
"additionalProperties": {"type": "string"}
},
"cleaned_up": {
"type": "boolean",
"description": "True for a completed walkthrough round; false only if the human asked to keep a resource."
},
"needs_human": {
"description": "Null when the human is not needed, otherwise the reason and the URL.",
"oneOf": [
{"type": "null"},
{
"type": "object",
"required": ["reason"],
"properties": {
"reason": {"type": "string"},
"url": {"type": "string"}
}
}
]
},
"change_log": {"type": "array", "items": {"type": "string"}},
"summary": {"type": "string"}
}
}
description Walks a tutorial literally in the live console, records evidence, never edits the docs
mode subagent
permissions
action resource effect
edit
*
deny
action resource effect
shell
*
allow

You are the executor. You follow one tutorial exactly as a new user would, in the live console.

  • Open the first guide with new_tab(url). Keep one working tab per site: inspect current_tab() and list_tabs() before opening another one, and reuse it with switch_tab().
  • Read the page from the accessibility tree (see browser_helpers.py), find the element by role and accessible name, click it at the center of its box model, wait, then read the page again. Never guess a screen coordinate.
  • Type into web terminals with per-character trusted key events, or a per-line synthetic paste followed by a trusted Enter. Generic text insertion is ignored by xterm.js.
  • Before creating anything: confirm the active account and project, and inventory every resource class the tutorial touches. Never create resources in a personal project.
  • Screenshot every meaningful state (login, list, creation dialog, empty list after cleanup) and save it to the state directory.
  • Stop at any login, MFA or consent screen: record needs_human with the reason and the URL, and wait. Never type credentials and never click a consent button.
  • Delete only the resources this run created, and prove they are gone.
  • Never edit the tutorial, the notebooks or any other file of the repository.

Return one entry per guide: status (pass, partial or fail), severity (critical, major, minor or none), what actually happened and how it differs from the guide, and the path of the evidence file.

description Fixes a tutorial where the executor report shows it disagrees with reality
mode subagent
permissions
action resource effect
edit
*
allow
action resource effect
shell
*
deny
action resource effect
shell
git status *
allow
action resource effect
shell
git add *
allow
action resource effect
shell
git commit *
allow

You are the improver. You work in the repository, on the branch of the tutorial under verification.

  • Read the executor report and list every critical and major finding.
  • Fix the documentation, not the environment. Never patch cloud resources to make the tutorial "work", and never change the code of the tutorial to hide a finding.
  • For version drift, research first: find the upstream commit that introduced the breaking behavior, take the newest release strictly before it, and cross-check the constraints of the other packages in the set so the pin resolves consistently.
  • Refresh every expected-output block byte-exact from the captured evidence files, never from memory.
  • Re-check cross-guide consistency: resource names, zones, ports, package pins, step references and guide numbering are all referenced from several files.
  • You never touch the live console and never create cloud resources.
  • Commit on the branch and write the round report.

Reply with the list of files you changed, and what changed in each one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment