Skip to content

Commit 1641602

Browse files
committed
fix: default non-interactive init integration
1 parent c079b2c commit 1641602

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/specify_cli/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,8 @@ def init(
11641164
console.print(f"[red]Error:[/red] Invalid AI assistant '{ai_assistant}'. Choose from: {', '.join(AGENT_CONFIG.keys())}")
11651165
raise typer.Exit(1)
11661166
selected_ai = ai_assistant
1167+
elif not sys.stdin.isatty():
1168+
selected_ai = "copilot"
11671169
else:
11681170
# Create options dict for selection (agent_key: display_name)
11691171
ai_choices = {key: config["name"] for key, config in AGENT_CONFIG.items()}

tests/integrations/test_cli.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,28 @@ def test_integration_copilot_creates_files(self, tmp_path):
7373
shared_manifest = project / ".specify" / "integrations" / "speckit.manifest.json"
7474
assert shared_manifest.exists()
7575

76+
def test_noninteractive_init_defaults_to_copilot(self, tmp_path, monkeypatch):
77+
from typer.testing import CliRunner
78+
from specify_cli import app
79+
import specify_cli
80+
81+
def fail_select(*_args, **_kwargs):
82+
raise AssertionError("non-interactive init should not open the integration picker")
83+
84+
monkeypatch.setattr(specify_cli, "select_with_arrows", fail_select)
85+
86+
runner = CliRunner()
87+
project = tmp_path / "noninteractive"
88+
result = runner.invoke(app, [
89+
"init", str(project), "--script", "sh", "--no-git", "--ignore-agent-tools",
90+
], catch_exceptions=False)
91+
92+
assert result.exit_code == 0, result.output
93+
assert (project / ".github" / "agents" / "speckit.plan.agent.md").exists()
94+
95+
data = json.loads((project / ".specify" / "integration.json").read_text(encoding="utf-8"))
96+
assert data["integration"] == "copilot"
97+
7698
def test_ai_copilot_auto_promotes(self, tmp_path):
7799
from typer.testing import CliRunner
78100
from specify_cli import app

0 commit comments

Comments
 (0)