fix: discover and cache module sources from local bundles#141
Open
michaeljabbour wants to merge 1 commit intomainfrom
Open
fix: discover and cache module sources from local bundles#141michaeljabbour wants to merge 1 commit intomainfrom
michaeljabbour wants to merge 1 commit intomainfrom
Conversation
When a bundle is registered as a local file (e.g. insight-blocks mapped to
~/.amplifier/bundles/insight-blocks.md), `amplifier update` never found or
cached the git-sourced modules declared in that bundle's hooks/tools/providers
sections. This caused FileNotFoundError crashes at session startup because
modules like hooks-insight-blocks were never cloned into ~/.amplifier/cache/.
Root cause: _check_all_bundle_status() only tracked each bundle's own top-level
URI as a SourceStatus. It never parsed the bundle file to extract module source
URIs from hooks[n].source / tools[n].source / providers[n].source. For file://
local bundles (Branch C), the result was BundleStatus.sources containing only
a single placeholder SourceStatus with has_update=None and no module URIs, so
_collect_unified_modules() found nothing to discover or cache.
Fix: add three focused helpers and wire them into _check_all_bundle_status()
for ALL bundle types (file://, git, and well-known editable installs):
_read_bundle_file(uri, parsed, cache_dir, git_handler) -> str | None
Locates and reads bundle.md / bundle.yaml from either the local
filesystem (file:// URIs) or the already-cloned git cache directory
(git URIs, using GitSourceHandler._get_cache_path()).
_extract_git_sources_from_bundle_content(content) -> list[str]
Parses YAML frontmatter from .md files (or plain YAML from .yaml files)
and collects source: field values from hooks, tools, and providers
sections. Only git+ URIs are returned; file:// sources are excluded.
Deduplicates and is fully exception-safe (returns [] on any parse error).
_get_module_source_statuses(uri, parsed, cache_dir, git_handler)
Combines the two above, then calls git_handler.get_status() for each
discovered URI so the resulting SourceStatus objects carry accurate
cached_commit / remote_commit / has_update data.
After creation of each BundleStatus the module source statuses are appended
to BundleStatus.sources. The existing _collect_unified_modules() and update
executor logic then picks them up transparently — no changes needed downstream.
Verified:
- ruff format + ruff lint: clean
- Unit tests for _extract_git_sources_from_bundle_content():
hooks/tools/providers extraction, pure YAML, empty, malformed YAML,
deduplication, file:// exclusion — all pass
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.
Summary
When a bundle is registered as a local file path (e.g.,
insight-blocks: ~/.amplifier/bundles/insight-blocks.md),amplifier updatenever discovers or caches the git-sourced modules declared inside that bundle'shooks:,tools:, orproviders:sections. This causesFileNotFoundErrorcrashes at session startup when the loader tries to access the expected cache directory._read_bundle_file()to read bundle content from bothfile://and git-cached bundles_extract_git_sources_from_bundle_content()to parse YAML frontmatter and extract module git source URIs_get_module_source_statuses()to check git status for each discovered module source_check_all_bundle_status()Root Cause
_check_all_bundle_status()incommands/update.pyonly tracks the bundle's own top-level URI as a source. It never loads bundle content to extract module source URIs fromhooks[n].source,tools[n].source, orproviders[n].sourcefields. For localfile://bundles, module sources were completely invisible to the update/cache pipeline.Test Plan
.mdfrontmatter extractionfile://source exclusion🤖 Generated with Amplifier