fix: backfill agent-context extension for integrations#2882
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #2881 by ensuring the bundled agent-context extension is backfilled (installed + registered) before integration flows update agent-context-config.yml, preventing projects from ending up with an inert config file and no runnable extension.
Changes:
- Add
_ensure_agent_context_extension()to install the bundledagent-contextextension when an integration has acontext_file. - Update integration init-options/config update flow to ensure the extension exists before touching its config.
- Add integration install/switch/upgrade tests that simulate missing
agent-contextand verify it is restored.
Show a summary per file
| File | Description |
|---|---|
src/specify_cli/integrations/_helpers.py |
Ensures agent-context is installed before integration flows update its config. |
tests/integrations/test_integration_subcommand.py |
Adds regression tests asserting backfill behavior for install/switch/upgrade when agent-context is missing. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
| # Update the agent-context extension config BEFORE init-options.json | ||
| # so a failure here doesn't leave init-options partially updated. | ||
| ext_cfg_path = project_root / _AGENT_CTX_EXT_CONFIG | ||
| if integration.context_file: | ||
| _ensure_agent_context_extension(project_root) |
mnriem
left a comment
There was a problem hiding this comment.
The agent-context extension should self-heal at the extension-system level — not get backfilled by integration flows. Integrations are consumers of the config API, not owners of extension lifecycle.
How it should work:
agent-contextauto-enables and self-heals at a top-level CLI hook (or duringspecify init)- Integration layer just writes to
agent-context-config.yml, assumes the extension is there - Older projects get fixed on any CLI invocation, not only on integration install/switch/upgrade
Can you move the backfill logic out of _helpers.py and into the extension system instead?
Description
Backfills the bundled
agent-contextextension before integration install, switch, and upgrade flows writeagent-context-config.yml. This keeps recovered or older projects from ending up with only the config file and no runnableagent-contextextension files.Fixes #2881.
Testing
uv run specify --helpuv run python -m pytest tests/integrations/test_integration_subcommand.py tests/extensions/test_extension_agent_context.py tests/test_agent_config_consistency.py -q.specify/extensions/agent-contextplus its registry entry, then ranspecify integration upgrade copilot --script sh --forceand verified the extension files and config were restored.Validation output:
AI Disclosure
This fix was prepared and validated with AI-assisted coding-agent support under human-operated OSS factory workflow controls.