Skip to content

fix: register enabled extensions for agent on integration use/upgrade#2949

Open
PascalThuet wants to merge 7 commits into
github:mainfrom
PascalThuet:fix/2886-install-upgrade-register-extensions
Open

fix: register enabled extensions for agent on integration use/upgrade#2949
PascalThuet wants to merge 7 commits into
github:mainfrom
PascalThuet:fix/2886-install-upgrade-register-extensions

Conversation

@PascalThuet

@PascalThuet PascalThuet commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

What

Enabled extension command/skill registration now happens only when an integration is selected or refreshed:

  • specify integration use <agent>
  • specify integration switch <agent>
  • specify integration upgrade <agent>

Plain specify integration install <agent> installs only that integration core command artifacts. This follows maintainer feedback in #2949 and avoids extension side effects for secondary integrations until they are selected.

Behavior

The shared _register_extensions_for_agent helper remains best-effort: registration failures warn via _print_cli_warning and do not roll back the surrounding use/switch/upgrade transaction.

use now registers enabled extensions after the default integration is changed. switch and upgrade continue to register enabled extensions after their own transactions commit.

Tests

  • test_install_defers_extension_commands_until_use
  • test_install_does_not_register_disabled_extensions
  • test_upgrade_backfills_extension_commands_for_agent
  • test_install_skills_mode_secondary_agent_defers_extension_artifacts
  • test_upgrade_non_active_agent_preserves_active_agent_skills

Targeted local run:

  • uv run --extra test pytest tests/integrations/test_integration_subcommand.py -q
  • uvx ruff check src/specify_cli/integrations/_install_commands.py src/specify_cli/integrations/_query_commands.py src/specify_cli/integrations/_helpers.py tests/integrations/test_integration_subcommand.py
  • git diff --check origin/main...HEAD

Closes #2886

…rade

install and upgrade only set up the integration's own core commands; only
switch re-registered the enabled extensions' commands for the target agent.
A second integration added via install (or refreshed via upgrade) was
therefore silently missing the extension commands the existing agents
already had (e.g. the bundled agent-context extension).

Extract switch's registration into a shared _register_extensions_for_agent
helper and call it from install and upgrade too, so every installed agent
ends up with every enabled extension's commands — full parity with switch.

Closes github#2886
 limitation

Extension skill rendering is scoped to the active agent (init-options track a
single ai / ai_skills pair), so a skills-mode agent registered while not active
(e.g. Copilot --skills installed as a secondary integration) gets command files
rather than skills. install/upgrade match extension add here; only switch
renders skills, because it activates the target first.

Add a regression test pinning this behavior and document the limitation on the
shared helper. Per-agent skills parity is tracked separately in github#2948.
@PascalThuet PascalThuet requested a review from mnriem as a code owner June 12, 2026 04:54
…-active agent

register_enabled_extensions_for_agent runs an active-agent-scoped skills pass
(_register_extension_skills resolves the skills dir from init-options["ai"],
ignoring the passed agent). Routing install/upgrade of a secondary integration
through it re-rendered the *active* skills-mode agent's extension skills as a
side effect — resurrecting skill files the user had deliberately deleted. Gate
the skills pass on the target being the active agent; switch is unaffected
because it activates the target first.

Also harden the skills-mode install test (assert a core skill so --skills is
load-bearing, drop a vacuous registered_skills assertion) and add a regression
test. Surfaced by review of the PR; skills parity for non-active agents stays
tracked in github#2948.
…st-commit

Review cleanups, no behavior change on the success path:

- Extract the best-effort ExtensionManager scaffold (lazy import, instantiate,
  except -> _print_cli_warning) into _best_effort_extension_op. Both
  _register_extensions_for_agent and a new _unregister_extensions_for_agent
  delegate to it, removing the duplicate block left inline in switch.
- Invoke the best-effort extension registration AFTER the install/switch/upgrade
  try/except has committed, so a failure in it can never trigger the rollback
  (install and switch teardown on except).
@mnriem

mnriem commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

I would prefer this ONLY to happen on specify integration use or specify integration switch or specify integration upgrade.

@PascalThuet PascalThuet changed the title fix: register enabled extensions for agent on integration install/upgrade fix: register enabled extensions for agent on integration use/upgrade Jun 16, 2026
@mnriem mnriem requested a review from Copilot June 16, 2026 21:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes when enabled extensions are (re)registered for an agent: extension command/skill back-fill is deferred until an integration is selected (integration use), switched to (integration switch), or refreshed (integration upgrade), avoiding extension side effects during plain integration install while still ensuring parity on selection/refresh.

Changes:

  • Add shared best-effort helpers for extension (un)registration and wire them into integration use/switch/upgrade after the core transaction completes.
  • Adjust extension registration to avoid re-rendering the active agent’s extension skills when registering extensions for a non-active agent.
  • Add integration-subcommand tests covering deferred install behavior, disabled extensions, upgrade back-fill, and skills-mode edge cases.
Show a summary per file
File Description
tests/integrations/test_integration_subcommand.py Adds regression/behavior tests for deferring extension registration until use, and for upgrade back-fill + skills-mode safety.
src/specify_cli/integrations/_query_commands.py Updates integration use to best-effort register enabled extensions after changing the default integration.
src/specify_cli/integrations/_migrate_commands.py Refactors switch to use shared unregister helper and performs extension re-registration post-commit; adds post-upgrade extension re-registration.
src/specify_cli/integrations/_helpers.py Introduces shared best-effort extension operation helpers used by use/switch/upgrade paths.
src/specify_cli/extensions.py Gates extension skill rendering to the active agent to prevent side effects when registering for non-active agents.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment thread tests/integrations/test_integration_subcommand.py
Comment thread tests/integrations/test_integration_subcommand.py
@PascalThuet

PascalThuet commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

What changed:

  • integration install no longer registers enabled extension artifacts for the newly installed agent.
  • integration use now registers enabled extensions after selecting the default integration.
  • switch and upgrade continue registering enabled extensions after their transactions commit.
  • Tests now assert that install defers extension artifacts until use, including Copilot skills mode.

Validation:

  • uv run --extra test pytest tests/integrations/test_integration_subcommand.py -q -> 111 passed
  • uvx ruff check src/specify_cli/integrations/_install_commands.py src/specify_cli/integrations/_query_commands.py src/specify_cli/integrations/_helpers.py tests/integrations/test_integration_subcommand.py -> passed
  • git diff --check origin/main...HEAD -> passed
  • Merged latest origin/main; GitHub reports MERGEABLE.
  • gh pr checks currently reports no checks on the branch.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new

@mnriem

mnriem commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Please rebase on upstream/main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: integration install/upgrade don't register extension commands for the new agent (only switch does)

3 participants