Skip to content

💫 Toolkit to help you get started with SDD or any other process!

fix(copilot): use --yolo to grant all permissions in non-interactive mode (#2298)

Manfred Riem370b5b48906d
diff --git a/src/specify_cli/integrations/copilot/__init__.py b/src/specify_cli/integrations/copilot/__init__.py
index be7fc819f..45ec6f353 100644
--- a/src/specify_cli/integrations/copilot/__init__.py
+++ b/src/specify_cli/integrations/copilot/__init__.py
@@ -10,7 +10,9 @@ Copilot has several unique behaviors compared to standard markdown agents:
from __future__ import annotations
import json
+import os
import shutil
+import warnings
from pathlib import Path
from typing import Any
@@ -18,6 +20,30 @@ from ..base import IntegrationBase
from ..manifest import IntegrationManifest
+def _allow_all() -> bool:
+ """Return True if the Copilot CLI should run with full permissions.
+
+ Checks ``SPECKIT_COPILOT_ALLOW_ALL_TOOLS`` first (new canonical name).
+ Falls back to the deprecated ``SPECKIT_ALLOW_ALL_TOOLS`` if set,
+ emitting a deprecation warning. Default when neither is set: enabled.
+ """
+ new_var = os.environ.get("SPECKIT_COPILOT_ALLOW_ALL_TOOLS")
+ if new_var is not None:
+ return new_var != "0"
+
+ old_var = os.environ.get("SPECKIT_ALLOW_ALL_TOOLS")
+ if old_var is not None:
+ warnings.warn(
+ "SPECKIT_ALLOW_ALL_TOOLS is deprecated; "
+ "use SPECKIT_COPILOT_ALLOW_ALL_TOOLS instead.",
+ UserWarning,
+ stacklevel=2,
+ )
+ return old_var != "0"
+
+ return True
+
+
class CopilotIntegration(IntegrationBase):
"""Integration for GitHub Copilot (VS Code IDE + CLI).
@@ -50,13 +76,15 @@ class CopilotIntegration(IntegrationBase):
output_json: bool = True,
) -> list[str] | None:
# GitHub Copilot CLI uses ``copilot -p "prompt"`` for
- # non-interactive mode. --allow-all-tools is required for the
- # agent to perform file edits and shell commands. Controlled
- # by SPECKIT_ALLOW_ALL_TOOLS env var (default: enabled).
- import os
+ # non-interactive mode. --yolo enables all permissions
+ # (tools, paths, and URLs) so the agent can perform file
+ # edits and shell commands without interactive prompts.
+ # Controlled by SPECKIT_COPILOT_ALLOW_ALL_TOOLS env var
+ # (default: enabled). The deprecated SPECKIT_ALLOW_ALL_TOOLS
+ # is also honoured as a fallback.
args = ["copilot", "-p", prompt]
- if os.environ.get("SPECKIT_ALLOW_ALL_TOOLS", "1") != "0":
- args.append("--allow-all-tools")
+ if _allow_all():
+ args.append("--yolo")
if model:
args.extend(["--model", model])
if output_json:
@@ -91,13 +119,12 @@ class CopilotIntegration(IntegrationBase):
agent_name = f"speckit.{stem}"
prompt = args or ""
- import os
cli_args = [
"copilot", "-p", prompt,
"--agent", agent_name,
]
- if os.environ.get("SPECKIT_ALLOW_ALL_TOOLS", "1") != "0":
- cli_args.append("--allow-all-tools")
+ if _allow_all():
+ cli_args.append("--yolo")
if model:
cli_args.extend(["--model", model])
if not stream:
diff --git a/tests/test_workflows.py b/tests/test_workflows.py
index 04477015c..4c042fc7d 100644
--- a/tests/test_workflows.py
+++ b/tests/test_workflows.py
@@ -367,15 +367,49 @@ class TestBuildExecArgs:
assert args[2] == "do stuff"
assert "--json" in args
- def test_copilot_exec_args(self):
+ def test_copilot_exec_args(self, monkeypatch):
+ monkeypatch.delenv("SPECKIT_COPILOT_ALLOW_ALL_TOOLS", raising=False)
+ monkeypatch.delenv("SPECKIT_ALLOW_ALL_TOOLS", raising=False)
from specify_cli.integrations.copilot import CopilotIntegration
impl = CopilotIntegration()
args = impl.build_exec_args("do stuff", model="claude-sonnet-4-20250514")
assert args[0] == "copilot"
assert "-p" in args
- assert "--allow-all-tools" in args
+ assert "--yolo" in args
assert "--model" in args
+ def test_copilot_new_env_var_disables_yolo(self, monkeypatch):
+ monkeypatch.setenv("SPECKIT_COPILOT_ALLOW_ALL_TOOLS", "0")
+ monkeypatch.delenv("SPECKIT_ALLOW_ALL_TOOLS", raising=False)
+ from specify_cli.integrations.copilot import CopilotIntegration
+ impl = CopilotIntegration()
+ args = impl.build_exec_args("do stuff")
+ assert "--yolo" not in args
+
+ def test_copilot_deprecated_env_var_still_honoured(self, monkeypatch):
+ monkeypatch.delenv("SPECKIT_COPILOT_ALLOW_ALL_TOOLS", raising=False)
+ monkeypatch.setenv("SPECKIT_ALLOW_ALL_TOOLS", "0")
+ import warnings
+ from specify_cli.integrations.copilot import CopilotIntegration
+ impl = CopilotIntegration()
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ args = impl.build_exec_args("do stuff")
+ assert "--yolo" not in args
+ assert any(
+ "SPECKIT_ALLOW_ALL_TOOLS is deprecated" in str(x.message)
+ and issubclass(x.category, UserWarning)
+ for x in w
+ )
+
+ def test_copilot_new_env_var_takes_precedence(self, monkeypatch):
+ monkeypatch.setenv("SPECKIT_COPILOT_ALLOW_ALL_TOOLS", "1")
+ monkeypatch.setenv("SPECKIT_ALLOW_ALL_TOOLS", "0")
+ from specify_cli.integrations.copilot import CopilotIntegration
+ impl = CopilotIntegration()
+ args = impl.build_exec_args("do stuff")
+ assert "--yolo" in args
+
def test_ide_only_returns_none(self):
from specify_cli.integrations.windsurf import WindsurfIntegration
impl = WindsurfIntegration()