Skip to content

fix: read nested bundle URIs from in-memory registry in bundle list --all#92

Open
colombod wants to merge 1 commit intomicrosoft:mainfrom
colombod:fix/bundle-list-nested-uri-source
Open

fix: read nested bundle URIs from in-memory registry in bundle list --all#92
colombod wants to merge 1 commit intomicrosoft:mainfrom
colombod:fix/bundle-list-nested-uri-source

Conversation

@colombod
Copy link
Contributor

Summary

Fixes the display half of microsoft-amplifier/amplifier-support#62.

amplifier bundle list --all showed GitHub URLs for nested bundles even when the parent bundle was overridden to a local path via settings.local.yaml. The nested bundles and dependencies categories read URIs from stale ~/.amplifier/registry.json on disk instead of the in-memory registry that has current overrides applied.

Root Cause

get_bundle_categories() in discovery.py used three inconsistent data sources for its output categories:

Category Data Source Reflected Overrides?
Well-Known Bundles Re-resolved via _find_packaged_bundle()
User-Added Bundles AppSettings().get_added_bundles()
Nested Bundles ~/.amplifier/registry.json on disk ❌ Stale
Dependencies ~/.amplifier/registry.json on disk ❌ Stale

The default bundle list view (without --all) already correctly reads from the in-memory registry via discovery.find(). The --all view was the only inconsistent path.

Change

Replaced the registry.json file-read block with self._registry.get_state() which returns the in-memory BundleState objects that reflect current session state including local overrides.

Before (read from disk):

registry_path = Path.home() / ".amplifier" / "registry.json"
if registry_path.exists():
    with open(registry_path, encoding="utf-8") as f:
        data = json.load(f)
    for name, bundle_data in data.get("bundles", {}).items():
        entry = {"name": name, "uri": bundle_data.get("uri", "")}
        ...

After (read from in-memory registry):

all_states = self._registry.get_state()
if isinstance(all_states, dict):
    for name, state in all_states.items():
        entry = {"name": name, "uri": state.uri}
        ...

The output format and category logic are preserved exactly — only the data source changes.

Evidence

Diff stats

  • amplifier_app_cli/lib/bundle_loader/discovery.py: +25/−33 lines (net reduction — simpler code)
  • tests/lib/bundle_loader/test_discovery.py: +146 lines (NEW file, 3 regression tests)

Test results

Suite Before After Delta
amplifier-app-cli full suite 165 passed ✅ 168 passed ✅ +3 new, 0 regressions

Note: app-cli tests were run with the local amplifier-foundation checkout (including the companion PR's changes) via uv pip install -e + uv run --no-sync, since BundleState.explicitly_requested is needed at runtime.

New regression tests (TestGetBundleCategoriesNestedURIs)

Test What it verifies
test_nested_bundles_reflect_in_memory_state Injected in-memory BundleState entries appear in get_bundle_categories() output with correct URIs
test_stale_persisted_uri_not_used_for_nested_bundles When registry.json has a git+ URI but in-memory state has been updated to file://, the output reflects the in-memory URI
test_dependencies_reflect_in_memory_state Dependencies also read from in-memory registry with correct included_by metadata

Companion PR

This is the second of two PRs for issue #62. The companion PR is microsoft/amplifier-foundation#83 which fixes the persistent state in BundleRegistry._load_single(). The foundation PR should merge first (it fixes the persistent state), then this PR (it fixes the display).

Together, both PRs ensure:

  1. Foundation: Registry entries are refreshed when bundles reload from different sources
  2. App CLI (this PR): bundle list --all reads from refreshed in-memory state, not stale disk data

How to verify end-to-end

After both PRs merge:

  1. Add bundle.added.foundation: ../../amplifier-foundation to settings.local.yaml
  2. Run any Amplifier session (to trigger bundle loading with the override)
  3. Run amplifier bundle list --all
  4. Confirm nested bundles show local paths, not git+ GitHub URLs

…-all

The get_bundle_categories() method read nested bundle and dependency URIs
from ~/.amplifier/registry.json on disk, which could contain stale git+
URIs that don't reflect current local path overrides from settings.local.yaml.

Changed to read from the in-memory BundleRegistry (via get_state()) which
has current overrides applied, aligning the --all view with the default
bundle list view that already reads from in-memory state.

Fixes: microsoft-amplifier/amplifier-support#62

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
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.

1 participant