Skip to content

recipes tool: Add tilde expansion and improve bundle path handling #175

@michaeljabbour

Description

@michaeljabbour

Summary

The recipes tool's path resolution has two issues that cause confusing "Recipe file not found" errors:

Issue 1: Tilde (~) expansion not supported

When a path like ~/dev/my-recipes/recipe.yaml is passed to the recipes tool, it fails because tilde is not expanded.

Current code (amplifier-bundle-recipes/.../amplifier_module_tool_recipes/__init__.py:344-359):

def _resolve_path(self, path_str: str) -> Path | None:
    if path_str.startswith("@"):
        mention_resolver = self.coordinator.get_capability("mention_resolver")
        if mention_resolver is None:
            return None
        return mention_resolver.resolve(path_str)
    return Path(path_str)  # <-- No .expanduser() call

Fix: Add .expanduser() to the fallback path:

return Path(path_str).expanduser()

Issue 2: Bundle paths without @ prefix fail silently

When users pass bundle:path/to/recipe.yaml (without the @ prefix), it falls through to Path(path_str) which treats it as a literal path and fails.

This is confusing because:

  • The bundle.md format uses bundle:path syntax (no @)
  • The @ requirement is not immediately obvious

Options:

  1. Document clearly that @ is required (done in amplifier-module-stories README)
  2. Detect colon in path and provide a helpful error message suggesting the @ prefix
  3. Auto-detect bundle paths (if path contains : and doesn't look like a Windows drive letter)

Reproduction

# Fails - tilde not expanded
amplifier tool invoke recipes operation=validate recipe_path="~/dev/my-bundle/recipes/test.yaml"

# Fails - missing @ prefix (confusing)
amplifier tool invoke recipes operation=validate recipe_path="my-bundle:recipes/test.yaml"

# Works
amplifier tool invoke recipes operation=validate recipe_path="@my-bundle:recipes/test.yaml"

Suggested Fix

Minimal change to _resolve_path():

def _resolve_path(self, path_str: str) -> Path | None:
    """Resolve a path string, handling @mention syntax."""
    if path_str.startswith("@"):
        mention_resolver = self.coordinator.get_capability("mention_resolver")
        if mention_resolver is None:
            return None
        return mention_resolver.resolve(path_str)
    
    # Expand ~ to home directory
    return Path(path_str).expanduser()

Impact

This affects any user who:

  • Uses ~ in recipe paths (common pattern)
  • Forgets the @ prefix on bundle paths (easy mistake)

Both result in the same unhelpful error: "Recipe file not found: [path]"


Discovered while using amplifier-module-stories recipes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions