Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-11119): make skyvern CLI robust to click 8.2+ and lift the click<8.2 pin (#6652)
Aaron Perez78bd7207892b
diff --git a/pyproject.toml b/pyproject.tomlindex bad6d3171..c6f42fb3e 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -14,7 +14,7 @@ dependencies = ["orjson>=3.9.10,<4","structlog>=23.2.0,<24","typer>=0.16.0,<0.26",- "click>=8,<8.2",+ "click>=8,<9","httpx[socks]>=0.27.0","rich>=13.7.0,<14",]diff --git a/skyvern/cli/block.py b/skyvern/cli/block.pyindex 1e095c689..468b03d1c 100644--- a/skyvern/cli/block.py+++ b/skyvern/cli/block.py@@ -10,8 +10,11 @@ from skyvern._cli_bootstrap import prepare_cli_runtimefrom skyvern.utils.env_paths import EnvIntentfrom .commands._output import resolve_inline_or_file, run_tool+from .lazy import SkyvernTyperGroup-block_app = typer.Typer(help="Workflow block schema and validation commands.", no_args_is_help=True)+block_app = typer.Typer(+ cls=SkyvernTyperGroup, help="Workflow block schema and validation commands.", no_args_is_help=True+)async def tool_block_schema(**kwargs: Any) -> dict[str, Any]:diff --git a/skyvern/cli/commands/browser.py b/skyvern/cli/commands/browser.pyindex bf375dca8..8a413178b 100644--- a/skyvern/cli/commands/browser.py+++ b/skyvern/cli/commands/browser.py@@ -53,16 +53,17 @@ from skyvern.cli.core.guards import (from skyvern.cli.core.ngrok import check_ngrok_auth, detect_ngrok, offer_install_ngrok, offer_setup_authfrom skyvern.cli.core.session_ops import do_session_close, do_session_create, do_session_listfrom skyvern.cli.core.telemetry import capture_cli_tool_call+from skyvern.cli.lazy import SkyvernTyperGroupfrom skyvern.cli.mcp_tools.browser import skyvern_login as tool_loginfrom skyvern.cli.mcp_tools.browser import skyvern_run_task as tool_run_taskfrom skyvern.cli.mcp_tools.inspection import skyvern_har_start, skyvern_har_stop-browser_app = typer.Typer(help="Browser automation commands.", no_args_is_help=True)-session_app = typer.Typer(help="Manage browser sessions.", no_args_is_help=True)-frame_app = typer.Typer(help="Manage iframe context.", no_args_is_help=True)-state_app = typer.Typer(help="Save and load browser auth state.", no_args_is_help=True)-storage_app = typer.Typer(help="Read, write, and clear web storage.", no_args_is_help=True)-network_app = typer.Typer(help="Network inspection and interception.", no_args_is_help=True)+browser_app = typer.Typer(cls=SkyvernTyperGroup, help="Browser automation commands.", no_args_is_help=True)+session_app = typer.Typer(cls=SkyvernTyperGroup, help="Manage browser sessions.", no_args_is_help=True)+frame_app = typer.Typer(cls=SkyvernTyperGroup, help="Manage iframe context.", no_args_is_help=True)+state_app = typer.Typer(cls=SkyvernTyperGroup, help="Save and load browser auth state.", no_args_is_help=True)+storage_app = typer.Typer(cls=SkyvernTyperGroup, help="Read, write, and clear web storage.", no_args_is_help=True)+network_app = typer.Typer(cls=SkyvernTyperGroup, help="Network inspection and interception.", no_args_is_help=True)browser_app.add_typer(session_app, name="session")browser_app.add_typer(frame_app, name="frame")browser_app.add_typer(state_app, name="state")diff --git a/skyvern/cli/config_command.py b/skyvern/cli/config_command.pyindex 837e52a27..4162936c6 100644--- a/skyvern/cli/config_command.py+++ b/skyvern/cli/config_command.py@@ -11,6 +11,7 @@ from skyvern.forge.sdk.schemas.organizations import Organization, OrganizationUpfrom skyvern.utils.env_paths import EnvIntentfrom .commands._output import run_tool+from .lazy import SkyvernTyperGroup_SETTABLE_KEYS: frozenset[str] = frozenset(OrganizationUpdate.model_fields)# ``clear_*`` keys are write-only verbs (reset to NULL); not surfaced by ``get``.@@ -20,6 +21,7 @@ _READABLE_KEYS: frozenset[str] = frozenset(config_app = typer.Typer(+ cls=SkyvernTyperGroup,help="Read and update organization settings (max_steps_per_run, webhook URL, retries, artifact URL expiry).",no_args_is_help=True,)diff --git a/skyvern/cli/credential.py b/skyvern/cli/credential.pyindex 4d9d53657..977533b1d 100644--- a/skyvern/cli/credential.py+++ b/skyvern/cli/credential.py@@ -10,8 +10,10 @@ from skyvern._cli_bootstrap import prepare_cli_runtimefrom skyvern.utils.env_paths import EnvIntentfrom .commands._output import run_tool+from .lazy import SkyvernTyperGroupcredential_app = typer.Typer(+ cls=SkyvernTyperGroup,help="MCP-parity credential commands (list/get/delete). Use `skyvern credentials add` for secure creation.",no_args_is_help=True,)diff --git a/skyvern/cli/lazy.py b/skyvern/cli/lazy.pyindex cacdf941c..b4c768847 100644--- a/skyvern/cli/lazy.py+++ b/skyvern/cli/lazy.py@@ -104,12 +104,33 @@ class _LazyPlaceholder(click.Command):return real.invoke(ctx)+# ---------------------------------------------------------------------------+# Click-version-robust group base+# ---------------------------------------------------------------------------+++class SkyvernTyperGroup(typer.core.TyperGroup):+ """TyperGroup that prints help and exits 0 when invoked with no subcommand.++ Click 8.2 changed ``no_args_is_help`` to raise ``NoArgsIsHelpError`` (a+ ``UsageError``, exit code 2) instead of echoing help and exiting 0 as click+ <8.2 did. Re-implementing the pre-8.2 branch here keeps ``skyvern <group>``+ exiting 0 regardless of the installed click version.+ """++ def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]:+ if not args and self.no_args_is_help and not ctx.resilient_parsing:+ click.echo(ctx.get_help(), color=ctx.color)+ ctx.exit()+ return super().parse_args(ctx, args)++# ---------------------------------------------------------------------------# LazyTyperGroup# ----------------------------------------------------------------------------class LazyTyperGroup(typer.core.TyperGroup):+class LazyTyperGroup(SkyvernTyperGroup):"""A TyperGroup subclass that includes lazily-registered commands.Commands registered via :func:`register_lazy_command` appear indiff --git a/skyvern/cli/mcp_commands.py b/skyvern/cli/mcp_commands.pyindex d44721111..ead498a9e 100644--- a/skyvern/cli/mcp_commands.py+++ b/skyvern/cli/mcp_commands.py@@ -22,6 +22,7 @@ from rich.syntax import Syntaxfrom rich.table import Tablefrom .console import console+from .lazy import SkyvernTyperGroupfrom .setup_commands import (_backup_config_path,_claude_code_global_config_path,@@ -47,8 +48,12 @@ from .setup_commands import (_write_mcp_config,)-mcp_app = typer.Typer(help="Manage local MCP configs and optional saved Skyvern profiles.", no_args_is_help=True)-profile_app = typer.Typer(help="Manage saved Skyvern MCP profiles.", no_args_is_help=True)+mcp_app = typer.Typer(+ cls=SkyvernTyperGroup,+ help="Manage local MCP configs and optional saved Skyvern profiles.",+ no_args_is_help=True,+)+profile_app = typer.Typer(cls=SkyvernTyperGroup, help="Manage saved Skyvern MCP profiles.", no_args_is_help=True)mcp_app.add_typer(profile_app, name="profile")LOG = structlog.get_logger(__name__)diff --git a/skyvern/cli/schedule_command.py b/skyvern/cli/schedule_command.pyindex 58195cf45..e880aee7c 100644--- a/skyvern/cli/schedule_command.py+++ b/skyvern/cli/schedule_command.py@@ -12,8 +12,10 @@ from skyvern._cli_bootstrap import prepare_cli_runtimefrom skyvern.utils.env_paths import EnvIntentfrom .commands._output import run_tool+from .lazy import SkyvernTyperGroupschedule_app = typer.Typer(+ cls=SkyvernTyperGroup,help="Manage workflow schedules (list, create, update, enable/disable, delete).",no_args_is_help=True,)diff --git a/skyvern/cli/workflow.py b/skyvern/cli/workflow.pyindex 8c6d121bf..eda6a8330 100644--- a/skyvern/cli/workflow.py+++ b/skyvern/cli/workflow.py@@ -10,8 +10,9 @@ from skyvern._cli_bootstrap import prepare_cli_runtimefrom skyvern.utils.env_paths import EnvIntentfrom .commands._output import resolve_inline_or_file, run_tool+from .lazy import SkyvernTyperGroup-workflow_app = typer.Typer(help="Manage Skyvern workflows.", no_args_is_help=True)+workflow_app = typer.Typer(cls=SkyvernTyperGroup, help="Manage Skyvern workflows.", no_args_is_help=True)async def tool_workflow_list(**kwargs: Any) -> dict[str, Any]:diff --git a/tests/unit/test_cli_no_args_help.py b/tests/unit/test_cli_no_args_help.pynew file mode 100644index 000000000..2ba497a89--- /dev/null+++ b/tests/unit/test_cli_no_args_help.py@@ -0,0 +1,76 @@+"""Regression guard: typer groups must exit 0 (printing help) when invoked with+no subcommand, across click <8.2 and >=8.2.++Click 8.2 changed ``no_args_is_help`` to raise ``NoArgsIsHelpError`` (exit code+2) instead of echoing help and exiting 0. ``SkyvernTyperGroup`` restores the+exit-0 behavior so ``skyvern <group>`` keeps working on click 8.2+.+"""++from __future__ import annotations++import typer+from typer.testing import CliRunner++from skyvern.cli.lazy import SkyvernTyperGroup++runner = CliRunner()+++def _build_group() -> typer.Typer:+ app = typer.Typer(cls=SkyvernTyperGroup, help="Top help.", no_args_is_help=True)+ sub = typer.Typer(cls=SkyvernTyperGroup, help="Sub help.", no_args_is_help=True)+ app.add_typer(sub, name="sub")++ @app.command("foo")+ def foo() -> None:+ typer.echo("foo ran")++ @sub.command("bar")+ def bar() -> None:+ typer.echo("bar ran")++ return app+++class TestSkyvernTyperGroupNoArgs:+ def test_group_with_no_subcommand_exits_zero(self) -> None:+ result = runner.invoke(_build_group(), [])+ assert result.exit_code == 0+ assert "Top help." in result.output++ def test_nested_group_with_no_subcommand_exits_zero(self) -> None:+ result = runner.invoke(_build_group(), ["sub"])+ assert result.exit_code == 0+ assert "Sub help." in result.output++ def test_valid_subcommand_runs(self) -> None:+ result = runner.invoke(_build_group(), ["foo"])+ assert result.exit_code == 0+ assert "foo ran" in result.output++ def test_unknown_subcommand_is_usage_error(self) -> None:+ result = runner.invoke(_build_group(), ["does-not-exist"])+ assert result.exit_code == 2+++class TestRealCliGroupsNoArgs:+ def test_top_level_cli_exits_zero(self) -> None:+ from skyvern.cli.commands import cli_app++ result = runner.invoke(cli_app, [])+ assert result.exit_code == 0+ assert "Skyvern CLI" in result.output++ def test_browser_group_exits_zero(self) -> None:+ from skyvern.cli.commands.browser import browser_app++ result = runner.invoke(browser_app, [])+ assert result.exit_code == 0+ assert "Browser automation commands" in result.output++ def test_browser_session_group_exits_zero(self) -> None:+ from skyvern.cli.commands.browser import browser_app++ result = runner.invoke(browser_app, ["session"])+ assert result.exit_code == 0+ assert "Manage browser sessions" in result.outputdiff --git a/uv.lock b/uv.lockindex 49519a9bf..267b56679 100644--- a/uv.lock+++ b/uv.lock@@ -893,14 +893,14 @@ wheels = [[[package]]name = "click"-version = "8.1.8"+version = "8.4.1"source = { registry = "https://pypi.org/simple" }dependencies = [{ name = "colorama", marker = "sys_platform == 'win32'" },]-sdist = { url = "https://files.pythonhosted.org/packages/b9/2e/0090cbf739cee7d23781ad4b89a9894a41538e4fcf4c31dcdd705b78eb8b/click-8.1.8.tar.gz", hash = "sha256:ed53c9d8990d83c2a27deae68e4ee337473f6330c040a31d4225c9574d16096a", size = 226593, upload-time = "2024-12-21T18:38:44.339Z" }+sdist = { url = "https://files.pythonhosted.org/packages/9b/98/518d8e5081007684232226f475082b30087d0f585e8457db087298259f49/click-8.4.1.tar.gz", hash = "sha256:918b5633eddf6b41c32d4f454bf0de810065c74e3f7dbf8ee5452f8be88d3e96", size = 353007, upload-time = "2026-05-22T04:08:37.769Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/7e/d4/7ebdbd03970677812aac39c869717059dbb71a4cfc033ca6e5221787892c/click-8.1.8-py3-none-any.whl", hash = "sha256:63c132bbbed01578a06712a2d1f497bb62d9c1c0d329b7903a866228027263b2", size = 98188, upload-time = "2024-12-21T18:38:41.666Z" },+ { url = "https://files.pythonhosted.org/packages/c7/0d/67e5b4109ea4a837e80daa87c2c696711955e40449a97e8926672534def2/click-8.4.1-py3-none-any.whl", hash = "sha256:482be17c6991b8c19c5429a1e995d9b0efdbb63172824c41f99965dc0ade8ec2", size = 116639, upload-time = "2026-05-22T04:08:35.26Z" },][[package]]@@ -5989,7 +5989,7 @@ requires-dist = [{ name = "azure-storage-blob", marker = "extra == 'local'", specifier = ">=12.26.0" },{ name = "azure-storage-blob", marker = "extra == 'server'", specifier = ">=12.26.0" },{ name = "cachetools", specifier = ">=5.3.2,<6" },- { name = "click", specifier = ">=8,<8.2" },+ { name = "click", specifier = ">=8,<9" },{ name = "croniter", marker = "extra == 'local'", specifier = ">=1.3.8,<4" },{ name = "croniter", marker = "extra == 'server'", specifier = ">=1.3.8,<4" },{ name = "cryptography", marker = "extra == 'local'", specifier = ">=48.0.1" },