بنقرة واحدة
wpt-gen-cli
// Best practices for CLI infrastructure, outputs, subprocess management, and templating in WPT-Gen.
// Best practices for CLI infrastructure, outputs, subprocess management, and templating in WPT-Gen.
| name | wpt-gen-cli |
| description | Best practices for CLI infrastructure, outputs, subprocess management, and templating in WPT-Gen. |
This document outlines the best practices for working with the CLI infrastructure in the wpt-gen repository.
WPT-Gen uses Typer for building its command-line interface.
@app.command() decorators.generate) support a standard set of flags:
--provider (-p): Override the LLM provider (gemini, openai, anthropic).--wpt-dir (-w): Override the local web-platform-tests repository path.--config (-c): Path to a custom wpt-gen.yml.--show-responses (-s): Display raw LLM-generated responses.--use-lightweight / --use-reasoning: Force a specific model category.For displaying information to the user, WPT-Gen utilizes Rich.
print() function. You must route all outputs through the injected UIProvider dependency (e.g. ui.print, ui.warning, ui.error).rich.print (via UIProvider) for colored and formatted output.rich.panel.Panel to encapsulate related information (like summarizing test plans) and rich.table.Table for structured data, rather than dumping raw JSON or concatenated strings to the CLI.ui.status() wrappers to provide visual rich.progress spinners to the user so they know the command has not hung.WPT-Gen heavily relies on executing native binaries (wpt lint, grep) to empower LLM agents.
subprocess.run(), you must always provide explicit timeout=... constraints, otherwise a rogue blocking command will freeze the AI forever.env={**os.environ, "CUSTOM": "VAL"} mappings, rather than lazily mutating the global os.environ which bleeds state across Python threads. Reviewers must actively catch environment leaking.git grep or grep), scrutinize custom arguments for shell injection vulnerabilities. Force the use of the -- argument separator to securely separate binary options from user-generated patterns.WPT-Gen uses Jinja2 to template both prompts to the LLM and the final generated output (HTML/JS files).
wptgen/templates/ directory.{{ variable_name }}) to inject context retrieved via trafilatura or derived from local scans.{% if %} and {% for %} loops to dynamically construct test structures based on the suggested test footprint. Ensure large, nullable dependencies are robustly guarded behind {% if %} conditions to avoid causing context bloat.Instructions to manually test the generate workflow of WPT-Gen to verify system integrity.
Generate Web Platform Tests (WPT) from minimal XML test suggestions. The agent will autonomously determine the test type and implementation details by analyzing existing repository paradigms. Use when the user asks to generate a Web Platform Test based on a test suggestion.
Best practices for configuring LLM integrations, concurrent networking, context scraping, and managing prompts in WPT-Gen.
Instructions on managing dependencies, build tools, project architecture rules, and integrating workflows via the Makefile in WPT-Gen.
Guidelines for Python testing using pytest, including coverage constraints, mock migrations, type safety (mypy), and style linting (ruff) in WPT-Gen.
Guidelines for finalizing changes, running presubmit checks, and preparing for submission in WPT-Gen.