fix: register enabled extensions for agent on integration use/upgrade#2949
Open
PascalThuet wants to merge 7 commits into
Open
fix: register enabled extensions for agent on integration use/upgrade#2949PascalThuet wants to merge 7 commits into
PascalThuet wants to merge 7 commits into
Conversation
…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.
…-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).
Collaborator
|
I would prefer this ONLY to happen on |
Contributor
There was a problem hiding this comment.
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/upgradeafter 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
Contributor
Author
|
What changed:
Validation:
|
Collaborator
|
Please rebase on upstream/main |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_agenthelper remains best-effort: registration failures warn via_print_cli_warningand do not roll back the surroundinguse/switch/upgradetransaction.usenow registers enabled extensions after the default integration is changed.switchandupgradecontinue to register enabled extensions after their own transactions commit.Tests
test_install_defers_extension_commands_until_usetest_install_does_not_register_disabled_extensionstest_upgrade_backfills_extension_commands_for_agenttest_install_skills_mode_secondary_agent_defers_extension_artifactstest_upgrade_non_active_agent_preserves_active_agent_skillsTargeted local run:
uv run --extra test pytest tests/integrations/test_integration_subcommand.py -quvx 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.pygit diff --check origin/main...HEADCloses #2886