mirror of
https://github.com/github/spec-kit.git
synced 2026-08-03 06:26:30 +08:00
`specify integration use copilot` against a Copilot install configured with `--integration-options "--skills"` dropped `"ai_skills": true` from init-options.json and regenerated extension commands in the legacy `.agent.md`/`.prompt.md` layout, contradicting `integration.json`'s stored `parsed_options.skills: true`. `_update_init_options_for_integration` only inspected `SkillsIntegration` / the instance `_skills_mode` flag. On the `use` path no `setup()` runs, so the freshly-resolved Copilot instance has `_skills_mode == False` and the stored skills intent in `parsed_options` was ignored. Thread the resolved `parsed_options` through and treat `parsed_options["skills"]` as skills mode. Adds a regression test that resets the registry singleton's `_skills_mode` to simulate a fresh process (in-process singleton reuse otherwise masks the bug). Assisted-by: GitHub Copilot (model: Claude Opus 4.8, autonomous) Copilot-Session: 06fb6ae9-f444-4dfd-ab3f-d0669c5d0604 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -260,6 +260,7 @@ def _update_init_options_for_integration(
|
||||
project_root: Path,
|
||||
integration: Any,
|
||||
script_type: str | None = None,
|
||||
parsed_options: dict[str, Any] | None = None,
|
||||
) -> None:
|
||||
"""Update init-options.json to reflect *integration* as the active one.
|
||||
|
||||
@@ -278,7 +279,17 @@ def _update_init_options_for_integration(
|
||||
opts["speckit_version"] = _get_speckit_version()
|
||||
if script_type:
|
||||
opts["script"] = script_type
|
||||
if isinstance(integration, SkillsIntegration) or getattr(integration, "_skills_mode", False):
|
||||
# Skills mode is either intrinsic (SkillsIntegration), set on the instance
|
||||
# during setup() (_skills_mode), or requested via parsed options (e.g.
|
||||
# Copilot's --skills, persisted as parsed_options["skills"]). The latter is
|
||||
# the only signal available on the `use` path, where no setup() runs and a
|
||||
# fresh integration instance has _skills_mode == False (issue #3550).
|
||||
skills_mode = (
|
||||
isinstance(integration, SkillsIntegration)
|
||||
or getattr(integration, "_skills_mode", False)
|
||||
or bool((parsed_options or {}).get("skills"))
|
||||
)
|
||||
if skills_mode:
|
||||
opts["ai_skills"] = True
|
||||
else:
|
||||
opts.pop("ai_skills", None)
|
||||
@@ -334,7 +345,9 @@ def _set_default_integration(
|
||||
) from exc
|
||||
|
||||
_write_integration_json(project_root, key, installed_keys, settings)
|
||||
_update_init_options_for_integration(project_root, integration, script_type=resolved_script)
|
||||
_update_init_options_for_integration(
|
||||
project_root, integration, script_type=resolved_script, parsed_options=parsed_options
|
||||
)
|
||||
|
||||
|
||||
def _set_default_integration_or_exit(*args: Any, **kwargs: Any) -> None:
|
||||
|
||||
@@ -1566,6 +1566,43 @@ class TestIntegrationUse:
|
||||
assert opts["integration"] == "codex"
|
||||
assert opts["ai"] == "codex"
|
||||
|
||||
def test_use_preserves_copilot_skills_mode(self, tmp_path):
|
||||
"""`use` on a skills-mode Copilot keeps ``ai_skills`` (issue #3550).
|
||||
|
||||
Re-selecting the same skills-mode Copilot must not drop ``ai_skills``
|
||||
from init-options.json nor regenerate extension commands in the legacy
|
||||
``.agent.md``/``.prompt.md`` layout.
|
||||
"""
|
||||
project = _init_project(tmp_path, "copilot", integration_options="--skills")
|
||||
|
||||
opts = json.loads((project / ".specify" / "init-options.json").read_text(encoding="utf-8"))
|
||||
assert opts.get("ai_skills") is True, "precondition: init recorded skills mode"
|
||||
|
||||
result = _run_in_project(project, ["extension", "add", "git"])
|
||||
assert result.exit_code == 0, f"extension add failed: {result.output}"
|
||||
|
||||
# Simulate a fresh process: `use` in real life runs in its own process
|
||||
# where the registry's Copilot instance has _skills_mode == False (it is
|
||||
# only set during setup()). In-process test invocations otherwise reuse
|
||||
# the singleton left in skills mode by init, masking the bug (#3550).
|
||||
from specify_cli.integrations import get_integration
|
||||
|
||||
get_integration("copilot")._skills_mode = False
|
||||
|
||||
result = _run_in_project(project, ["integration", "use", "copilot"])
|
||||
assert result.exit_code == 0, result.output
|
||||
|
||||
opts = json.loads((project / ".specify" / "init-options.json").read_text(encoding="utf-8"))
|
||||
assert opts.get("ai_skills") is True, "ai_skills must survive `use copilot`"
|
||||
|
||||
# No legacy command-layout files should be regenerated for the
|
||||
# skills-mode agent.
|
||||
assert not (project / ".github" / "agents" / "speckit.git.feature.agent.md").exists()
|
||||
assert not (project / ".github" / "prompts" / "speckit.git.feature.prompt.md").exists()
|
||||
assert (
|
||||
project / ".github" / "skills" / "speckit-git-feature" / "SKILL.md"
|
||||
).exists()
|
||||
|
||||
def test_use_requires_installed_integration(self, tmp_path):
|
||||
project = _init_project(tmp_path, "claude")
|
||||
old_cwd = os.getcwd()
|
||||
|
||||
Reference in New Issue
Block a user