:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(devbox): add --template flag to devbox:start and devbox:task (#58503)
Raúl Negrón-Otero2df91cdafd48
diff --git a/tools/hogli-commands/hogli_commands/devbox/cli.py b/tools/hogli-commands/hogli_commands/devbox/cli.pyindex b0fb94af8318..76c84dad5b37 100644--- a/tools/hogli-commands/hogli_commands/devbox/cli.py+++ b/tools/hogli-commands/hogli_commands/devbox/cli.py@@ -22,6 +22,7 @@ from hogli.manifest import get_manifestfrom .coder import (CLAUDE_CODE_OAUTH_ENV,+ DEFAULT_TEMPLATE,DOTFILES_URI_PARAMETER,GIT_EMAIL_PARAMETER,GIT_NAME_PARAMETER,@@ -792,10 +793,18 @@ def devbox_unshare(workspace: str | None, users: tuple[str, ...]) -> None:default="100",help="Disk size in GiB (default: 100)",)+ "-t",+ "--template",+ default=DEFAULT_TEMPLATE,+ show_default=True,+ help="Coder workspace template to use when creating a new devbox",+)@click.option("-v", "--verbose", is_flag=True, help="Show full Coder/Terraform build output")def devbox_start(workspace: str | None,disk: str,+ template: str,verbose: bool,) -> None:"""Start or create the remote devbox."""@@ -809,13 +818,14 @@ def devbox_start(config = load_config()- click.echo(f"Creating devbox '{name}' (disk={disk}GiB)...")+ click.echo(f"Creating devbox '{name}' (template={template}, disk={disk}GiB)...")create_workspace(name,int(disk),git_name=config.get("git_name"),git_email=config.get("git_email"),dotfiles_uri=config.get("dotfiles_uri"),+ template=template,verbose=verbose,)click.echo("Created.")@@ -927,8 +937,15 @@ def devbox_logs(workspace: str | None, follow: bool) -> None:@click.argument("prompt", required=False)@click.option("--name", "task_name", default=None, help="Task name (auto-generated if omitted)")@click.option("-q", "--quiet", is_flag=True, help="Only print the created task's ID")-def devbox_task(prompt: str | None, task_name: str | None, quiet: bool) -> None:- """Start a background Coder task on the posthog-linux template.+ "-t",+ "--template",+ default=DEFAULT_TEMPLATE,+ show_default=True,+ help="Coder workspace template to run the task on",+)+def devbox_task(prompt: str | None, task_name: str | None, quiet: bool, template: str) -> None:+ """Start a background Coder task on the chosen workspace template.The Coder deployment provisions a fresh workspace per task and hands theprompt to the agent configured in the template. Pass the prompt as a@@ -958,7 +975,7 @@ def devbox_task(prompt: str | None, task_name: str | None, quiet: bool) -> None:f"{CLAUDE_CODE_OAUTH_ENV}`) to set it.",err=True,)- create_task(prompt, task_name=task_name, quiet=quiet)+ create_task(prompt, task_name=task_name, quiet=quiet, template=template)def _ensure_user_secrets_supported() -> None:diff --git a/tools/hogli-commands/hogli_commands/devbox/coder.py b/tools/hogli-commands/hogli_commands/devbox/coder.pyindex 2de2b0453963..727b19511499 100644--- a/tools/hogli-commands/hogli_commands/devbox/coder.py+++ b/tools/hogli-commands/hogli_commands/devbox/coder.py@@ -11,7 +11,6 @@ import sysimport jsonimport shleximport shutil-import tempfileimport itertoolsimport threadingimport subprocess@@ -19,13 +18,12 @@ import webbrowserfrom pathlib import Pathfrom typing import Any, NoReturn-import yamlimport clickimport requestsfrom hogli.manifest import load_manifest_MACOS_TAILSCALE_CLI = "/Applications/Tailscale.app/Contents/MacOS/Tailscale"-TEMPLATE_NAME = "posthog-linux"+DEFAULT_TEMPLATE = "posthog-linux"BREW_PACKAGE = "coder/coder/coder"RUNTIME_SETUP_HINT = "Run `hogli devbox:setup`."_MANAGED_CODER_DIR = Path.home() / ".hogli" / "bin"@@ -44,14 +42,14 @@ JETBRAINS_IDES_PARAMETER = "jetbrains_ides"GIT_SIGNING_KEY_SECRET = "POSTHOG_GIT_SIGNING_KEY"-# Default values for all optional template parameters. Passing these explicitly-# prevents the Coder CLI from prompting interactively for missing values.-# Update this dict when new optional parameters are added to the template.-_TEMPLATE_PARAMETER_DEFAULTS: dict[str, str] = {- DOTFILES_URI_PARAMETER: "",- DOTFILES_BRANCH_PARAMETER: "",- JETBRAINS_IDES_PARAMETER: "[]",-}+# Coder rejects --parameter values for keys the chosen template does not+# define, with this exact message: `parameter "X" is not present in the+# template`. The check happens client-side before any provisioning starts,+# so a failed call is cheap to retry. _run_with_param_retry drops the+# offending key from the candidate set and retries on this match. Anchored+# to the start of a line so a user-supplied parameter value containing this+# phrase cannot trick the matcher.+_PARAM_NOT_PRESENT_RE = re.compile(r'^parameter "([^"]+)" is not present', re.MULTILINE)_STEP_RE = re.compile(r"^==>.*?(\w[\w ]+)")_LABEL_RE = re.compile(r"^[a-z0-9]([a-z0-9-]*[a-z0-9])?$")@@ -223,26 +221,40 @@ def _run_build(args: list[str], *, verbose: bool = False) -> subprocess.Completereturn subprocess.CompletedProcess(args, returncode, "".join(captured), "")-def _run_with_rich_parameters(- args: list[str], parameters: dict[str, str], *, verbose: bool | None = None-) -> subprocess.CompletedProcess[str]:- """Run a Coder command with sensitive parameters passed via a temp YAML file.+def _append_parameter_flags(args: list[str], parameters: dict[str, str]) -> list[str]:+ """Append `--parameter key=value` flags for each entry in ``parameters``."""+ out = list(args)+ for key, value in parameters.items():+ out += ["--parameter", f"{key}={value}"]+ return out- When verbose is None, runs without build filtering. When True/False,- delegates to _run_build for spinner-based output.- """- with tempfile.NamedTemporaryFile(mode="w", suffix=".yaml", delete=False) as parameter_file:- yaml.safe_dump(parameters, parameter_file)- file_path = Path(parameter_file.name)- try:- file_path.chmod(0o600)- full_args = [*args, "--rich-parameter-file", str(file_path)]- if verbose is None:- return _run(full_args)- return _run_build(full_args, verbose=verbose)- finally:- file_path.unlink(missing_ok=True)+def _run_with_param_retry(+ base_args: list[str],+ parameters: dict[str, str],+ *,+ verbose: bool = False,+) -> subprocess.CompletedProcess[str]:+ """Run a Coder build command, dropping unknown parameters and retrying.++ Coder validates ``--parameter`` keys client-side before any provisioning+ starts, so retrying after a `parameter "X" is not present in the+ template` error is cheap and safe. All other failures bubble up+ unchanged. Used by every write path that forwards parameters (`coder+ create`, `coder update`) so callers never have to know which keys the+ chosen template happens to accept.+ """+ remaining = dict(parameters)+ while True:+ result = _run_build(_append_parameter_flags(base_args, remaining), verbose=verbose)+ if result.returncode == 0:+ return result+ match = _PARAM_NOT_PRESENT_RE.search(result.stdout or "")+ if not match or match.group(1) not in remaining:+ return result+ dropped = match.group(1)+ click.echo(click.style(f"Template doesn't accept '{dropped}', retrying without it.", fg="yellow"))+ del remaining[dropped]def _resolve_tailscale() -> str | None:@@ -745,11 +757,18 @@ def create_workspace(dotfiles_uri: str | None = None,repo: str = "https://github.com/PostHog/posthog",*,+ template: str = DEFAULT_TEMPLATE,verbose: bool = False,) -> None:- """Create a new Coder workspace."""- parameters = {- **_TEMPLATE_PARAMETER_DEFAULTS,+ """Create a new Coder workspace.++ Only parameters with explicit caller-supplied values are forwarded.+ Anything the template defines but we do not supply falls back to the+ template's Terraform default via ``--use-parameter-defaults``. If a+ forwarded parameter does not exist on the chosen template, coder errors+ pre-provisioning and the retry loop drops the offending key.+ """+ parameters: dict[str, str] = {"disk_size": str(disk_size),"repo": repo,}@@ -760,15 +779,16 @@ def create_workspace(if dotfiles_uri:parameters[DOTFILES_URI_PARAMETER] = dotfiles_uri- args = [+ base_args = ["coder","create",name,"--template",- TEMPLATE_NAME,+ template,+ "--use-parameter-defaults","--yes",]- result = _run_with_rich_parameters(args, parameters, verbose=verbose)+ result = _run_with_param_retry(base_args, parameters, verbose=verbose)if result.returncode != 0:raise SystemExit(result.returncode)@@ -800,10 +820,17 @@ def update_workspace(*,verbose: bool = False,) -> None:- """Update a workspace to the latest template version."""- merged = {**_TEMPLATE_PARAMETER_DEFAULTS, **(parameters or {})}- args = ["coder", "update", name]- result = _run_with_rich_parameters(args, merged, verbose=verbose)+ """Update a workspace to the latest template version.++ ``--use-parameter-defaults`` lets coder fall back to the template's own+ defaults for any parameter not explicitly supplied here, so we never+ need a hogli-side defaults dict. Parameters carried over from a+ previous template (e.g. a saved ``dotfiles_uri`` that the new template+ does not declare) are dropped by the retry shim instead of aborting+ the update.+ """+ base_args = ["coder", "update", name, "--use-parameter-defaults"]+ result = _run_with_param_retry(base_args, parameters or {}, verbose=verbose)if result.returncode != 0:raise SystemExit(result.returncode)@@ -816,8 +843,14 @@ def delete_workspace(name: str, *, verbose: bool = False) -> None:def update_workspace_parameters(name: str, parameters: dict[str, str]) -> None:- """Update mutable workspace parameters using a temp YAML file."""- result = _run_with_rich_parameters(["coder", "update", name], parameters)+ """Update mutable workspace parameters.++ Goes through the same retry shim as ``create_workspace`` so a stale+ local config key (for example, a saved ``dotfiles_uri`` after the user+ switches templates) does not abort the pre-start sync.+ """+ base_args = ["coder", "update", name, "--use-parameter-defaults"]+ result = _run_with_param_retry(base_args, parameters)if result.returncode != 0:raise SystemExit(result.returncode)@@ -897,15 +930,16 @@ def create_task(*,task_name: str | None = None,quiet: bool = False,+ template: str = DEFAULT_TEMPLATE,) -> None:- """Create a Coder task on the posthog-linux template.+ """Create a Coder task on the given workspace template.When ``prompt`` is None, ``--stdin`` is passed so coder reads the promptfrom the parent process's stdin; otherwise it is forwarded as thepositional input argument. Execs into the coder CLI so stdin, stdout,and the exit code flow through unchanged."""- args = ["coder", "task", "create", "--template", TEMPLATE_NAME]+ args = ["coder", "task", "create", "--template", template]if task_name:args += ["--name", task_name]if quiet:diff --git a/tools/hogli-commands/hogli_commands/tests/test_devbox.py b/tools/hogli-commands/hogli_commands/tests/test_devbox.pyindex 95a26cde5480..023ba82063af 100644--- a/tools/hogli-commands/hogli_commands/tests/test_devbox.py+++ b/tools/hogli-commands/hogli_commands/tests/test_devbox.py@@ -5,6 +5,7 @@ from __future__ import annotationsimport jsonimport errnoimport subprocess+from collections.abc import Callablefrom pathlib import Pathimport pytest@@ -474,94 +475,216 @@ class TestWorkspaceNaming:assert coder.extract_workspace_label("other-workspace") is None-class TestWorkspaceCreation:- """Test Coder workspace creation parameter passing."""+def _parse_parameter_flags(args: list[str]) -> dict[str, str]:+ """Extract `key=value` pairs from `--parameter` flags in argv."""+ out: dict[str, str] = {}+ for flag, value in zip(args, args[1:]):+ if flag == "--parameter":+ key, _, val = value.partition("=")+ out[key] = val+ return out- def test_create_workspace_passes_git_identity_as_rich_parameters(self, monkeypatch: pytest.MonkeyPatch) -> None:- captured: dict[str, object] = {}- def fake_run_with_rich_parameters(- args: list[str], parameters: dict[str, str], *, verbose: bool | None = None- ) -> subprocess.CompletedProcess[str]:- captured["args"] = args- captured["parameters"] = parameters- captured["verbose"] = verbose- return subprocess.CompletedProcess(args, 0, "", "")+def _fake_run_build_capturing(captured: dict[str, object]) -> Callable[..., subprocess.CompletedProcess[str]]:+ """Return a `_run_build` stub that records its argv and reports success."""- monkeypatch.setattr(coder, "_run_with_rich_parameters", fake_run_with_rich_parameters)+ def fake(args: list[str], *, verbose: bool = False) -> subprocess.CompletedProcess[str]:+ captured["args"] = args+ captured["verbose"] = verbose+ return subprocess.CompletedProcess(args, 0, "", "")- coder.create_workspace(- "devbox-test-user",- 50,- git_name="PostHog Engineer",- git_email="[email protected]",- verbose=True,- )+ return fake+++_DOTFILES = "https://github.com/user/dotfiles"+_REPO = "https://github.com/PostHog/posthog"- assert captured == {- "args": ["coder", "create", "devbox-test-user", "--template", "posthog-linux", "--yes"],- "parameters": {- **coder._TEMPLATE_PARAMETER_DEFAULTS,- "disk_size": "50",- "repo": "https://github.com/PostHog/posthog",- "git_name": "PostHog Engineer",- "git_email": "[email protected]",- },- "verbose": True,- }- def test_create_workspace_does_not_pass_claude_parameter(self, monkeypatch: pytest.MonkeyPatch) -> None:+class TestWorkspaceCreation:+ """Test Coder workspace creation parameter passing and template selection."""++ @pytest.mark.parametrize(+ "kwargs, expected_template, expected_params",+ [+ (+ {},+ "posthog-linux",+ {"disk_size": "100", "repo": _REPO},+ ),+ (+ {+ "git_name": "PostHog Engineer",+ "git_email": "[email protected]",+ "dotfiles_uri": _DOTFILES,+ },+ "posthog-linux",+ {+ "disk_size": "100",+ "repo": _REPO,+ "git_name": "PostHog Engineer",+ "git_email": "[email protected]",+ "dotfiles_uri": _DOTFILES,+ },+ ),+ (+ {"template": "posthog-microvm"},+ "posthog-microvm",+ {"disk_size": "100", "repo": _REPO},+ ),+ ],+ ids=["defaults", "all-optionals", "custom-template"],+ )+ def test_create_workspace_forwards_params_and_template(+ self,+ monkeypatch: pytest.MonkeyPatch,+ kwargs: dict[str, str],+ expected_template: str,+ expected_params: dict[str, str],+ ) -> None:captured: dict[str, object] = {}+ monkeypatch.setattr(coder, "_run_build", _fake_run_build_capturing(captured))- def fake_run_with_rich_parameters(- args: list[str], parameters: dict[str, str], *, verbose: bool | None = None- ) -> subprocess.CompletedProcess[str]:- captured["parameters"] = parameters- return subprocess.CompletedProcess(args, 0, "", "")+ coder.create_workspace("devbox-test-user", 100, **kwargs)++ args = captured["args"]+ assert args[:6] == [+ "coder",+ "create",+ "devbox-test-user",+ "--template",+ expected_template,+ "--use-parameter-defaults",+ ]+ assert "--yes" in args+ # Security invariant: the Claude OAuth token is a Coder user secret+ # (env-injected at workspace start); it must never be forwarded as a+ # --parameter flag where it would leak into argv / process listings.+ params = _parse_parameter_flags(args)+ assert "claude_oauth_token" not in params+ assert params == expected_params++ @pytest.mark.parametrize(+ "outputs, dropped, raises",+ [+ # Single unknown param dropped, retry succeeds.+ (+ [+ (1, 'parameter "dotfiles_uri" is not present in the template\n'),+ (0, ""),+ ],+ {"dotfiles_uri"},+ False,+ ),+ # Two unknown params reported one at a time; each is dropped in+ # turn before the final call succeeds.+ (+ [+ (1, 'parameter "dotfiles_uri" is not present in the template\n'),+ (1, 'parameter "git_name" is not present in the template\n'),+ (0, ""),+ ],+ {"dotfiles_uri", "git_name"},+ False,+ ),+ # The magic phrase appearing inside a parameter value (not at the+ # start of a line) must not trigger a retry. _PARAM_NOT_PRESENT_RE+ # anchors the match to the start of a line.+ (+ [(1, "echoed back: --parameter foo='parameter \"dotfiles_uri\" is not present'\n")],+ set(),+ True,+ ),+ # Any other build failure aborts immediately.+ (+ [(1, "terraform apply failed\n")],+ set(),+ True,+ ),+ ],+ ids=["single-drop", "multi-drop", "phrase-in-value-no-retry", "unrelated-error-no-retry"],+ )+ def test_create_workspace_param_retry(+ self,+ monkeypatch: pytest.MonkeyPatch,+ outputs: list[tuple[int, str]],+ dropped: set[str],+ raises: bool,+ ) -> None:+ queue = list(outputs)+ calls: list[list[str]] = []- monkeypatch.setattr(coder, "_run_with_rich_parameters", fake_run_with_rich_parameters)+ def fake_run_build(args: list[str], *, verbose: bool = False) -> subprocess.CompletedProcess[str]:+ calls.append(args)+ rc, stdout = queue.pop(0)+ return subprocess.CompletedProcess(args, rc, stdout, "")- coder.create_workspace("devbox-test-user", 100, verbose=True)+ monkeypatch.setattr(coder, "_run_build", fake_run_build)- # The template no longer declares ``claude_oauth_token``; passing it would- # cause Coder to reject the create call.- assert "claude_oauth_token" not in captured["parameters"]+ def go() -> None:+ coder.create_workspace(+ "devbox-test-user",+ 100,+ git_name="PostHog Engineer",+ dotfiles_uri=_DOTFILES,+ )- def test_create_workspace_passes_dotfiles_uri_as_rich_parameter(self, monkeypatch: pytest.MonkeyPatch) -> None:- captured: dict[str, dict[str, str]] = {}+ if raises:+ with pytest.raises(SystemExit):+ go()+ else:+ go()- def fake_run_with_rich_parameters(- args: list[str], parameters: dict[str, str], *, verbose: bool | None = None- ) -> subprocess.CompletedProcess[str]:- captured["parameters"] = parameters- return subprocess.CompletedProcess(args, 0, "", "")+ assert len(calls) == len(outputs)+ assert dropped.isdisjoint(_parse_parameter_flags(calls[-1]))- monkeypatch.setattr(coder, "_run_with_rich_parameters", fake_run_with_rich_parameters)- coder.create_workspace(- "devbox-test-user",- 100,- dotfiles_uri="https://github.com/user/dotfiles",- verbose=True,- )+class TestWorkspaceUpdate:+ """Test that `coder update` paths share the same retry behavior as create.- assert captured["parameters"]["dotfiles_uri"] == "https://github.com/user/dotfiles"+ Without this, a stale `dotfiles_uri` (or any param the new template+ doesn't declare) saved in the user's hogli config would abort the+ pre-start parameter sync the next time they switch templates.+ """- def test_create_workspace_includes_template_defaults(self, monkeypatch: pytest.MonkeyPatch) -> None:- captured: dict[str, dict[str, str]] = {}+ @pytest.mark.parametrize(+ "call",+ [+ lambda: coder.update_workspace(+ "devbox-test-user",+ parameters={"dotfiles_uri": _DOTFILES, "git_name": "PostHog Engineer"},+ ),+ lambda: coder.update_workspace_parameters(+ "devbox-test-user",+ {"dotfiles_uri": _DOTFILES, "git_name": "PostHog Engineer"},+ ),+ ],+ ids=["update_workspace", "update_workspace_parameters"],+ )+ def test_update_paths_drop_unknown_params_and_retry(+ self,+ monkeypatch: pytest.MonkeyPatch,+ call: Callable[[], None],+ ) -> None:+ calls: list[list[str]] = []- def fake_run_with_rich_parameters(- args: list[str], parameters: dict[str, str], *, verbose: bool | None = None- ) -> subprocess.CompletedProcess[str]:- captured["parameters"] = parameters+ def fake_run_build(args: list[str], *, verbose: bool = False) -> subprocess.CompletedProcess[str]:+ calls.append(args)+ if len(calls) == 1:+ return subprocess.CompletedProcess(+ args, 1, 'parameter "dotfiles_uri" is not present in the template\n', ""+ )return subprocess.CompletedProcess(args, 0, "", "")- monkeypatch.setattr(coder, "_run_with_rich_parameters", fake_run_with_rich_parameters)+ monkeypatch.setattr(coder, "_run_build", fake_run_build)- coder.create_workspace("devbox-test-user", 100, verbose=True)+ call()- for key, value in coder._TEMPLATE_PARAMETER_DEFAULTS.items():- assert captured["parameters"][key] == value+ assert len(calls) == 2+ first = _parse_parameter_flags(calls[0])+ retried = _parse_parameter_flags(calls[1])+ assert "dotfiles_uri" in first and "git_name" in first+ assert "dotfiles_uri" not in retried+ assert retried["git_name"] == "PostHog Engineer"class TestResolveWorkspaceName:@@ -794,13 +917,20 @@ class TestDevboxCommands:monkeypatch.setattr(devbox_cli,"create_workspace",- lambda name, disk_size, git_name=None, git_email=None, dotfiles_uri=None, verbose=False: captured.update(+ lambda name,+ disk_size,+ git_name=None,+ git_email=None,+ dotfiles_uri=None,+ template="posthog-linux",+ verbose=False: captured.update({"name": name,"disk_size": str(disk_size),"git_name": git_name,"git_email": git_email,"dotfiles_uri": dotfiles_uri,+ "template": template,}),)@@ -814,6 +944,7 @@ class TestDevboxCommands:"git_name": None,"git_email": None,"dotfiles_uri": None,+ "template": "posthog-linux",}def test_devbox_start_with_name_creates_labeled_workspace(self, monkeypatch: pytest.MonkeyPatch) -> None:@@ -839,12 +970,19 @@ class TestDevboxCommands:monkeypatch.setattr(devbox_cli,"create_workspace",- lambda name, disk_size, git_name=None, git_email=None, dotfiles_uri=None, verbose=False: captured.update(+ lambda name,+ disk_size,+ git_name=None,+ git_email=None,+ dotfiles_uri=None,+ template="posthog-linux",+ verbose=False: captured.update({"name": name,"git_name": git_name,"git_email": git_email,"dotfiles_uri": dotfiles_uri,+ "template": template,}),)@@ -856,8 +994,34 @@ class TestDevboxCommands:assert captured["git_name"] == "PostHog Engineer"assert captured["git_email"] == "[email protected]"assert captured["dotfiles_uri"] == "https://github.com/user/dotfiles"+ assert captured["template"] == "posthog-linux"assert "devbox:ssh api" in result.output+ def test_devbox_start_forwards_template_flag(self, monkeypatch: pytest.MonkeyPatch) -> None:+ captured: dict[str, object] = {}++ monkeypatch.setattr(devbox_cli, "ensure_runtime_ready", lambda: None)+ monkeypatch.setattr(devbox_cli, "resolve_workspace_name", lambda ws: ("devbox-test-user", []))+ monkeypatch.setattr(devbox_cli, "get_workspace", lambda name, workspaces=None: None)+ monkeypatch.setattr(devbox_cli, "extract_workspace_label", lambda name: None)+ monkeypatch.setattr(devbox_cli, "load_config", lambda: {})+ monkeypatch.setattr(+ devbox_cli,+ "create_workspace",+ lambda name,+ disk_size,+ git_name=None,+ git_email=None,+ dotfiles_uri=None,+ template="posthog-linux",+ verbose=False: captured.update({"template": template}),+ )++ result = runner.invoke(cli, ["devbox:start", "-t", "posthog-microvm"])++ assert result.exit_code == 0, result.output+ assert captured == {"template": "posthog-microvm"}+def test_devbox_restart_calls_restart_workspace(self, monkeypatch: pytest.MonkeyPatch) -> None:captured: dict[str, object] = {}@@ -1591,6 +1755,14 @@ class TestCreateTask:assert captured == [["coder", "task", "create", "--template", "posthog-linux", *expected_tail]]+ def test_create_task_argv_uses_selected_template(self, monkeypatch: pytest.MonkeyPatch) -> None:+ captured: list[list[str]] = []+ monkeypatch.setattr(coder, "_run_or_exit", lambda args: captured.append(args))++ coder.create_task("do it", template="posthog-microvm")++ assert captured == [["coder", "task", "create", "--template", "posthog-microvm", "do it"]]+class TestDevboxTaskCommand:"""Test the devbox:task Click command."""@@ -1600,11 +1772,19 @@ class TestDevboxTaskCommand:[(["devbox:task", "fix CI on PR #1234"],- {"prompt": "fix CI on PR #1234", "task_name": None, "quiet": False},+ {"prompt": "fix CI on PR #1234", "task_name": None, "quiet": False, "template": "posthog-linux"},),(["devbox:task", "--name", "my-task", "-q", "do it"],- {"prompt": "do it", "task_name": "my-task", "quiet": True},+ {"prompt": "do it", "task_name": "my-task", "quiet": True, "template": "posthog-linux"},+ ),+ (+ ["devbox:task", "-t", "posthog-microvm", "do it"],+ {"prompt": "do it", "task_name": None, "quiet": False, "template": "posthog-microvm"},+ ),+ (+ ["devbox:task", "--template", "posthog-microvm", "do it"],+ {"prompt": "do it", "task_name": None, "quiet": False, "template": "posthog-microvm"},),],)@@ -1620,8 +1800,8 @@ class TestDevboxTaskCommand:monkeypatch.setattr(devbox_cli,"create_task",- lambda prompt, task_name=None, quiet=False: captured.update(- {"prompt": prompt, "task_name": task_name, "quiet": quiet}+ lambda prompt, task_name=None, quiet=False, template="posthog-linux": captured.update(+ {"prompt": prompt, "task_name": task_name, "quiet": quiet, "template": template}),)@@ -1655,15 +1835,15 @@ class TestDevboxTaskCommand:monkeypatch.setattr(devbox_cli,"create_task",- lambda prompt, task_name=None, quiet=False: captured.update(- {"prompt": prompt, "task_name": task_name, "quiet": quiet}+ lambda prompt, task_name=None, quiet=False, template="posthog-linux": captured.update(+ {"prompt": prompt, "task_name": task_name, "quiet": quiet, "template": template}),)result = runner.invoke(cli, ["devbox:task"], input="piped prompt\n")assert result.exit_code == 0- assert captured == {"prompt": None, "task_name": None, "quiet": False}+ assert captured == {"prompt": None, "task_name": None, "quiet": False, "template": "posthog-linux"}class TestResolveLocalSigningKey: