Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,14 @@ python -m webwright.run.cli \

### 🚩 Flags

| Flag | Description |
|------|-------------|
| Flag / Command | Description |
|----------------|-------------|
| `-c` | Config file(s) from `src/webwright/config/` (stackable). |
| `-t` | Task instruction. |
| `--start-url` | Initial page. |
| `--task-id` | Output subfolder name. |
| `-o` | Output directory. |
| `list-configs` | Print all available built-in config file names (`python -m webwright.run.cli list-configs`). |

---

Expand Down
27 changes: 22 additions & 5 deletions src/webwright/run/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from rich.console import Console

from webwright.agents import get_agent
from webwright.config import get_config_from_spec, snapshot_config_specs
from webwright.config import builtin_config_dir, get_config_from_spec, snapshot_config_specs
from webwright.environments import get_environment
from webwright.models import get_model
from webwright.utils.serialize import UNSET, recursive_merge
Expand All @@ -17,7 +17,7 @@

DEFAULT_CONFIGS = ["base.yaml", "model_openai.yaml"]

app = typer.Typer(no_args_is_help=True)
app = typer.Typer()
console = Console(highlight=False)


Expand Down Expand Up @@ -134,10 +134,22 @@ def run_one(
return result


@app.command()
@app.command("list-configs")
def list_configs() -> None:
"""List all available built-in config files."""
configs = sorted(builtin_config_dir.glob("*.yaml"))
if not configs:
console.print("No config files found.")
return
for path in configs:
console.print(path.name)


@app.callback(invoke_without_command=True)
def main(
task: str = typer.Option(
..., "-t", "--task", help="Natural language task description."
ctx: typer.Context,
task: str | None = typer.Option(
None, "-t", "--task", help="Natural language task description."
),
task_id: str | None = typer.Option(
None, "--task-id", help="Optional identifier used in the output directory name."
Expand All @@ -153,6 +165,11 @@ def main(
help="Launch headed local Playwright with devtools and keep it open for inspection.",
),
) -> Any:
if ctx.invoked_subcommand is not None:
return
if task is None:
console.print(ctx.get_help())
raise typer.Exit()
return run_one(
task=task,
task_id=task_id,
Expand Down
14 changes: 7 additions & 7 deletions src/webwright/run/doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def check_playwright():
return False, ("playwright not installed\nFix: pip install playwright")


def check_chromium():
def check_firefox():
try:
result = subprocess.run(
["playwright", "install", "--dry-run"],
Expand All @@ -36,9 +36,9 @@ def check_chromium():
)

if result.returncode == 0:
return True, "chromium available"
return True, "firefox available"

return False, ("chromium missing\nFix: playwright install chromium")
return False, ("firefox missing\nFix: playwright install firefox")

except Exception as e:
return False, str(e)
Expand All @@ -51,7 +51,7 @@ def check_screenshot():
screenshot_path = Path("doctor_test.png")

with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
browser = p.firefox.launch(headless=True)

page = browser.new_page()

Expand All @@ -70,8 +70,8 @@ def check_screenshot():

except Exception:
return False, (
"unable to launch Chromium for screenshot validation\n"
"Fix: playwright install"
"unable to launch Firefox for screenshot validation\n"
"Fix: playwright install firefox"
)


Expand Down Expand Up @@ -108,7 +108,7 @@ def check_plugin_manifests():
CHECKS = [
("Python", check_python),
("Playwright", check_playwright),
("Chromium", check_chromium),
("Firefox", check_firefox),
("Screenshot", check_screenshot),
("OpenAI Key", check_openai_key),
("Plugins", check_plugin_manifests),
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_doctor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path

from webwright.run.doctor import (
check_chromium,
check_firefox,
check_openai_key,
check_playwright,
check_plugin_manifests,
Expand All @@ -24,8 +24,8 @@ def test_check_playwright():
assert isinstance(message, str)


def test_check_chromium():
ok, message = check_chromium()
def test_check_firefox():
ok, message = check_firefox()

assert isinstance(ok, bool)
assert isinstance(message, str)
Expand Down