Skip to content

fix: self-heal agent-context extension#2882

Open
nkgotcode wants to merge 1 commit into
github:mainfrom
nkgotcode:fix/2881-agent-context-backfill
Open

fix: self-heal agent-context extension#2882
nkgotcode wants to merge 1 commit into
github:mainfrom
nkgotcode:fix/2881-agent-context-backfill

Conversation

@nkgotcode

@nkgotcode nkgotcode commented Jun 6, 2026

Copy link
Copy Markdown

Description

Moves the agent-context extension repair path out of integration helpers and into the top-level CLI project startup path. Older projects now restore the bundled extension on normal CLI invocation while integration commands only update the active context config.

Fixes #2881.

Testing

  • uv run python -m pytest tests/test_agent_config_consistency.py -q
  • uv run python -m pytest tests/extensions/test_extension_agent_context.py::TestExtensionEnabledGate tests/extensions/test_extension_agent_context.py::TestAgentContextSelfHeal tests/integrations/test_integration_subcommand.py::TestIntegrationInstall::test_install_backfills_agent_context_extension_when_missing tests/integrations/test_integration_subcommand.py::TestIntegrationSwitch::test_switch_backfills_agent_context_extension_when_missing tests/integrations/test_integration_subcommand.py::TestIntegrationUpgrade::test_upgrade_backfills_agent_context_extension_when_missing -q

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 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 bundled agent-context extension when an integration has a context_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-context and 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

Comment on lines +344 to +348
# 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 mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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:

  1. agent-context auto-enables and self-heals at a top-level CLI hook (or during specify init)
  2. Integration layer just writes to agent-context-config.yml, assumes the extension is there
  3. 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?

@nkgotcode nkgotcode force-pushed the fix/2881-agent-context-backfill branch from 9772946 to aac1f2c Compare June 11, 2026 15:19
@nkgotcode nkgotcode changed the title fix: backfill agent-context extension for integrations fix: self-heal agent-context extension Jun 11, 2026
@nkgotcode

Copy link
Copy Markdown
Author

Moved this to the top-level CLI startup path in aac1f2c: non-init commands now call _self_heal_agent_context_extension(Path.cwd()), and integrations only update agent-context-config.yml.

Rebased onto current main; the branch is now mergeable. Validation passed:

  • uv run python -m pytest tests/test_agent_config_consistency.py -q -> 28 passed
  • uv run python -m pytest tests/extensions/test_extension_agent_context.py::TestExtensionEnabledGate tests/extensions/test_extension_agent_context.py::TestAgentContextSelfHeal tests/integrations/test_integration_subcommand.py::TestIntegrationInstall::test_install_backfills_agent_context_extension_when_missing tests/integrations/test_integration_subcommand.py::TestIntegrationSwitch::test_switch_backfills_agent_context_extension_when_missing tests/integrations/test_integration_subcommand.py::TestIntegrationUpgrade::test_upgrade_backfills_agent_context_extension_when_missing -q -> 9 passed
  • git diff --check origin/main...HEAD -> exit 0

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]: agent-context extension is only installed by 'specify init' — other paths write an inert config that stops updating context files at v0.12.0

3 participants