Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/specify_cli/integration_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ def with_integration_setting(
elif raw_options is not None:
current.pop("parsed_options", None)

# Recompute the separator from the options actually STORED on ``current``
# after the update, not the raw ``parsed_options`` argument. When only
# ``script_type`` changes (``parsed_options`` and ``raw_options`` both
# None), the previously-stored ``parsed_options`` are retained above, so
# deriving the separator from the argument (None) would drop an
# options-dependent separator (e.g. Copilot ``--skills`` -> "-") back to
# the default ".".
current["invoke_separator"] = integration.effective_invoke_separator(
parsed_options, project_root
current.get("parsed_options"), project_root
)
settings[key] = current
return settings
Expand Down
28 changes: 28 additions & 0 deletions tests/integrations/test_integration_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,31 @@ def test_write_integration_json_strips_integration_key(tmp_path):
assert state["integration"] == "claude"
assert state["default_integration"] == "claude"
assert state["installed_integrations"] == ["claude"]


def test_with_integration_setting_recomputes_separator_from_retained_options():
"""Updating only script_type must not drop an options-dependent separator.

Copilot resolves the command-ref separator to '-' when '--skills' options
are stored and '.' otherwise. A second call that changes only script_type
(parsed_options=None, raw_options=None) retains the stored parsed_options,
so invoke_separator must stay '-', not be recomputed from the None argument.
"""
from specify_cli.integrations import get_integration
from specify_cli.integration_runtime import with_integration_setting

copilot = get_integration("copilot")

settings = with_integration_setting(
{}, "copilot", copilot, parsed_options={"skills": True}
)
assert settings["copilot"]["invoke_separator"] == "-"

settings2 = with_integration_setting(
{"integration_settings": settings}, "copilot", copilot, script_type="ps"
)
# parsed_options are retained (only script_type changed) ...
assert settings2["copilot"]["parsed_options"] == {"skills": True}
assert settings2["copilot"]["script"] == "ps"
# ... so the separator must reflect them, not the (None) argument.
assert settings2["copilot"]["invoke_separator"] == "-"