Skip to content

Commit d982c2f

Browse files
WOLIKIMCHENGroot
andauthored
feat(copilot): warn before skills default rollout (#3256)
* feat(copilot): default to skills mode * feat(copilot): warn before skills default rollout * Make Copilot skills warning test less brittle --------- Co-authored-by: root <kinsonnee@gmail.com>
1 parent e8ade11 commit d982c2f

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

src/specify_cli/integrations/copilot/__init__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ def _allow_all() -> bool:
5757
return True
5858

5959

60+
def _warn_legacy_markdown_default() -> None:
61+
"""Warn that Copilot's default markdown scaffold is being phased out."""
62+
warnings.warn(
63+
"Copilot legacy markdown mode is deprecated and will stop being the "
64+
'default in a future Spec Kit release; pass --integration-options "--skills" '
65+
"to opt in to Copilot skills mode now.",
66+
UserWarning,
67+
stacklevel=3,
68+
)
69+
70+
6071
class _CopilotSkillsHelper(SkillsIntegration):
6172
"""Internal helper used when Copilot is scaffolded in skills mode.
6273
@@ -316,6 +327,8 @@ def setup(
316327
self._skills_mode = bool(parsed_options.get("skills"))
317328
if self._skills_mode:
318329
return self._setup_skills(project_root, manifest, parsed_options, **opts)
330+
if "skills" not in parsed_options:
331+
_warn_legacy_markdown_default()
319332
return self._setup_default(project_root, manifest, parsed_options, **opts)
320333

321334
def _setup_default(

tests/integrations/test_integration_copilot.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import json
44
import os
5+
import warnings
56

7+
import pytest
68
import yaml
79

810
from specify_cli.integrations import get_integration
@@ -34,6 +36,31 @@ def test_setup_creates_agent_md_files(self, tmp_path):
3436
assert f.parent == tmp_path / ".github" / "agents"
3537
assert f.name.endswith(".agent.md")
3638

39+
def test_setup_warns_legacy_markdown_default_is_deprecated(self, tmp_path):
40+
from specify_cli.integrations.copilot import CopilotIntegration
41+
copilot = CopilotIntegration()
42+
m = IntegrationManifest("copilot", tmp_path)
43+
44+
with pytest.warns(UserWarning, match="Copilot legacy markdown mode is deprecated"):
45+
created = copilot.setup(tmp_path, m)
46+
47+
assert any(f.name.endswith(".agent.md") for f in created)
48+
49+
def test_skills_setup_does_not_warn_about_legacy_default(self, tmp_path):
50+
from specify_cli.integrations.copilot import CopilotIntegration
51+
copilot = CopilotIntegration()
52+
m = IntegrationManifest("copilot", tmp_path)
53+
54+
with warnings.catch_warnings(record=True) as caught:
55+
warnings.simplefilter("always")
56+
created = copilot.setup(tmp_path, m, parsed_options={"skills": True})
57+
58+
assert not any(
59+
"Copilot legacy markdown mode is deprecated" in str(item.message)
60+
for item in caught
61+
)
62+
assert any(f.name == "SKILL.md" for f in created)
63+
3764
def test_setup_creates_companion_prompts(self, tmp_path):
3865
from specify_cli.integrations.copilot import CopilotIntegration
3966
copilot = CopilotIntegration()
@@ -295,6 +322,51 @@ def test_complete_file_inventory_ps(self, tmp_path):
295322
f"Extra: {sorted(set(actual) - set(expected))}"
296323
)
297324

325+
def test_default_cli_init_warns_legacy_markdown_is_deprecated(self, tmp_path):
326+
"""Default Copilot init should warn users about the future skills default."""
327+
from typer.testing import CliRunner
328+
from specify_cli import app
329+
project = tmp_path / "default-warning"
330+
project.mkdir()
331+
old_cwd = os.getcwd()
332+
try:
333+
os.chdir(project)
334+
with pytest.warns(
335+
UserWarning,
336+
match="Copilot legacy markdown mode is deprecated",
337+
):
338+
result = CliRunner().invoke(app, [
339+
"init", "--here", "--integration", "copilot", "--script", "sh",
340+
], catch_exceptions=False)
341+
finally:
342+
os.chdir(old_cwd)
343+
344+
assert result.exit_code == 0, result.output
345+
346+
def test_skills_cli_init_does_not_warn_about_legacy_markdown(self, tmp_path):
347+
"""Explicit Copilot skills mode should not warn about the legacy default."""
348+
from typer.testing import CliRunner
349+
from specify_cli import app
350+
project = tmp_path / "skills-no-warning"
351+
project.mkdir()
352+
old_cwd = os.getcwd()
353+
try:
354+
os.chdir(project)
355+
with warnings.catch_warnings(record=True) as caught:
356+
warnings.simplefilter("always")
357+
result = CliRunner().invoke(app, [
358+
"init", "--here", "--integration", "copilot",
359+
"--integration-options", "--skills", "--script", "sh",
360+
], catch_exceptions=False)
361+
finally:
362+
os.chdir(old_cwd)
363+
364+
assert result.exit_code == 0, result.output
365+
assert not any(
366+
"Copilot legacy markdown mode is deprecated" in str(item.message)
367+
for item in caught
368+
)
369+
298370

299371
class TestCopilotSkillsMode:
300372
"""Tests for Copilot integration in --skills mode."""

0 commit comments

Comments
 (0)