fix(extensions): back-fill agent-context extension in integration install/switch/upgrade#2885
Open
PascalThuet wants to merge 4 commits into
Open
fix(extensions): back-fill agent-context extension in integration install/switch/upgrade#2885PascalThuet wants to merge 4 commits into
PascalThuet wants to merge 4 commits into
Conversation
…tall/switch/upgrade `specify init` was the only path that installed the bundled agent-context extension. `specify integration install/switch/upgrade` wrote/refreshed its config file without installing it, leaving projects that predate the extension with an inert config — and, once inline updates are removed in v0.12.0, with frozen context files. Extract init's install logic into a shared, idempotent `ensure_agent_context_extension()` helper and call it from init, integration install, switch, and upgrade so re-running any of these back-fills the extension. Fixes github#2881 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
install_from_directory rmtree's the extension dir and copies the bundled template (empty context_file, default markers). When a caller wrote the config before the back-fill (integration install/switch/upgrade via _update_init_options_for_integration), the real context_file was reset to "". Preserve and restore any pre-existing config around the install, in a finally so it survives even if install_from_directory raises after its internal rmtree (otherwise the config was silently destroyed while the command reported success). Add regression tests for both the success and failure paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…test Address code-review cleanup findings on the back-fill change: - Replace the copy-pasted call+warn snippet at the install/switch/upgrade sites with a shared `_backfill_agent_context()` helper so the status set and warning format live in one place. - Add an end-to-end test driving `specify integration install` on a project that predates the extension: asserts the extension is actually installed and registered (not just configured) and that context_file is preserved. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Cover the integration_switch early returns ("already default", shared-infra
refresh) and _set_default_integration so switching to / refreshing an
already-installed integration also back-fills the bundled agent-context
extension. Add tests for both switch paths.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes #2881
Problem
specify initwas the only path that installed the bundledagent-contextextension.specify integration install/switch/upgradewrote/refreshed its config file (agent-context-config.yml) without installing the extension. Projects that predate the extension (or where a prior install was skipped) are left with an inert config: the.ymlexists but the extension is absent and unregistered. This is masked today by the deprecated inline updater; once inline updates are removed in v0.12.0, those projects stop updating their context files. The only recovery was re-runningspecify init --here --force.Change
Extract init's install logic into a shared, idempotent
ensure_agent_context_extension()helper and call it frominit,integration install,switch, andupgrade. Re-running any of those now back-fills the extension.extensions.py: newensure_agent_context_extension()— install-if-missing, never raises, returns(status, detail).commands/init.py: reuse the helper (no behavior change; same tracker output).integrations/_helpers.py: shared_backfill_agent_context()wrapper for the install/switch/upgrade sites.integrations/_install_commands.py,integrations/_migrate_commands.py: call it after setup; warn (non-fatal) on failure.Clobber-safety
install_from_directoryrmtree's the extension dir and copies the bundled template (emptycontext_file, default markers). Since the integration commands write the realcontext_filebefore the back-fill runs, a naive install would reset it to"". The helper snapshots any pre-existing config and restores it after install — in afinally, so it survives even ifinstall_from_directoryraises after its internal rmtree (otherwise the config was silently destroyed while the command reported success).Testing
uv run python -m pytest tests/extensions tests/integrations tests/test_agent_config_consistency.py→ 2382 passed, 15 skipped. Added:specify integration installon a pre-extension project installs+registers the extension and preservescontext_file.Out of scope (follow-ups)
/speckit.agent-context.updatecommand for the new agent (onlyswitchre-registers). Tracked separately in [Bug]: integration install/upgrade don't register extension commands for the new agent (only switch does) #2886 (pre-existing onmain).specify integration install <already-installed-key>early-exits before the back-fill; recovery is via installing another agent,switch, orupgrade.Minimal approach that aligns
install/switch/upgradewithinit. Happy to redirect if this overlaps the planned v0.12 migration design.🤖 Generated with Claude Code