From c80735e7f25c9fc5b41c38576fd2d24762681e1d Mon Sep 17 00:00:00 2001 From: "musher-dagger[bot]" <359324146+musher-dagger[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2026 06:36:32 +0000 Subject: [PATCH] fix: keep config and other files when select() has no filters Bundle.select() built its files from the typed handles alone, so a select() with no filters, which reads as everything, dropped every config and other asset from files(). With no filters the selection now holds every file in the bundle; a filter still selects only the files of the resources it names. Fixes #19 Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- src/musher/_bundle.py | 15 ++++++++++++--- tests/test_bundle.py | 33 ++++++++++++++++++++++++++++++--- uv.lock | 4 ++-- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4242e15..6105738 100644 --- a/README.md +++ b/README.md @@ -170,7 +170,7 @@ path = musher.cache_path() # cache directory path - `fetch_asset()` — fetch individual assets by logical path - Sync (`Client`) and async (`AsyncClient`) clients - Typed handles: `SkillHandle`, `PromptHandle`, `ToolsetHandle`, `AgentSpecHandle` -- `bundle.select()` — filter resources by type +- `bundle.select()` — filter resources by type; with no filters it selects the whole bundle, `config` and `other` files included - Content-addressable cache with TTL and garbage collection - Cache management: `cache_info()`, `cache_remove()`, `cache_clear()`, `cache_clean()`, `cache_path()` - `export_claude_plugin()` / `install_claude_skills()` — Claude integration diff --git a/src/musher/_bundle.py b/src/musher/_bundle.py index dd6043c..0189a48 100644 --- a/src/musher/_bundle.py +++ b/src/musher/_bundle.py @@ -258,8 +258,15 @@ def select( toolsets: list[str] | None = None, agent_specs: list[str] | None = None, ) -> BundleSelection: - """Return a filtered subset of this bundle's resources.""" + """Return a filtered subset of this bundle's resources. + + With no filter, the selection is the whole bundle: its ``files()`` are + every file, ``config`` and ``other`` assets included. With any filter, + they are the files of the selected skills, prompts, toolsets and agent + specs. + """ self._build_handles() + assert self._file_handles is not None # noqa: S101 assert self._skill_handles is not None # noqa: S101 assert self._prompt_handles is not None # noqa: S101 assert self._toolset_handles is not None # noqa: S101 @@ -270,8 +277,10 @@ def select( sel_toolsets = _filter_map(self._toolset_handles, toolsets) sel_agent_specs = _filter_map(self._agent_spec_handles, agent_specs) - # Collect files belonging to selected resources - sel_files: dict[str, FileHandle] = {} + # No filter selects everything, untyped files included; a filter selects + # the files of the resources it names. + unfiltered = all(f is None for f in (skills, prompts, toolsets, agent_specs)) + sel_files: dict[str, FileHandle] = dict(self._file_handles) if unfiltered else {} for sh in sel_skills.values(): for fh in sh.files(): sel_files[fh.logical_path] = fh diff --git a/tests/test_bundle.py b/tests/test_bundle.py index 875e622..9e299a0 100644 --- a/tests/test_bundle.py +++ b/tests/test_bundle.py @@ -20,9 +20,9 @@ def _make_resolve() -> ResolveResult: }) -def _make_bundle_with_typed_assets() -> Bundle: - """Create a bundle with assets of various types for handle testing.""" - assets: dict[str, Asset] = {} +def _make_bundle_with_typed_assets(extra: dict[str, Asset] | None = None) -> Bundle: + """Create a bundle with assets of various types for handle testing, plus ``extra``.""" + assets: dict[str, Asset] = dict(extra or {}) # Skill assets (a skill folder with SKILL.md) assets["skills/search/SKILL.md"] = Asset( @@ -295,6 +295,33 @@ def test_select_prompts_subset(self): assert len(sel.prompts()) == 1 assert len(sel.skills()) == 0 + def test_select_with_no_filters_keeps_untyped_files(self): + """#19: select() with no filters is the whole bundle, config and other files included.""" + untyped = { + path: Asset( + asset_id=path, + logical_path=path, + asset_type=asset_type, + content=b"x", + content_sha256=path, + size_bytes=1, + ) + for path, asset_type in ( + ("config/settings.yaml", AssetType.CONFIG), + ("assets/logo.svg", AssetType.OTHER), + ) + } + bundle = _make_bundle_with_typed_assets(untyped) + + sel = bundle.select() + + assert {f.logical_path for f in sel.files()} == {f.logical_path for f in bundle.files()} + assert sel.file("config/settings.yaml") is not None + assert sel.file("assets/logo.svg") is not None + # A filter still selects only the files of the resources it names. + filtered = bundle.select(skills=["search"]) + assert filtered.file("config/settings.yaml") is None + def test_select_empty(self): bundle = _make_bundle_with_typed_assets() sel = bundle.select(skills=[], prompts=[], toolsets=[], agent_specs=[]) diff --git a/uv.lock b/uv.lock index 78397be..a995a00 100644 --- a/uv.lock +++ b/uv.lock @@ -1,5 +1,5 @@ version = 1 -revision = 3 +revision = 5 requires-python = ">=3.13" [[package]] @@ -1439,7 +1439,7 @@ wheels = [ [[package]] name = "musher-sdk" -version = "0.3.3" +version = "0.3.5" source = { editable = "." } dependencies = [ { name = "httpx" },