From ae6ec7cea1103bb1e8d78a87d82c10933a04ab3d Mon Sep 17 00:00:00 2001 From: rob Date: Sat, 17 Jan 2026 04:10:30 -0400 Subject: [PATCH] Fix collections CLI to handle API's expanded tool format The API returns tools as objects with owner/name fields, but the CLI expected string refs. Now handles both formats correctly. Co-Authored-By: Claude Opus 4.5 --- src/cmdforge/cli/collections_commands.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/cmdforge/cli/collections_commands.py b/src/cmdforge/cli/collections_commands.py index fb2e3d0..be11dd3 100644 --- a/src/cmdforge/cli/collections_commands.py +++ b/src/cmdforge/cli/collections_commands.py @@ -103,8 +103,15 @@ def _cmd_collections_info(args): print(f"Tags: {', '.join(tags)}") print(f"\nTools ({len(tools)}):") - for tool_ref in tools: - version_constraint = pinned.get(tool_ref, "") + for tool in tools: + # Handle both object format (from API) and string format + if isinstance(tool, dict): + tool_ref = f"{tool['owner']}/{tool['name']}" + version_constraint = tool.get('pinned_version', '') + else: + tool_ref = tool + version_constraint = pinned.get(tool_ref, '') + if version_constraint: print(f" - {tool_ref} @ {version_constraint}") else: @@ -156,8 +163,15 @@ def _cmd_collections_install(args): installed = 0 failed = 0 - for tool_ref in tools: - version = pinned.get(tool_ref) + for tool in tools: + # Handle both object format (from API) and string format + if isinstance(tool, dict): + tool_ref = f"{tool['owner']}/{tool['name']}" + version = tool.get('pinned_version') if use_pinned else None + else: + tool_ref = tool + version = pinned.get(tool_ref) if use_pinned else None + try: print(f" Installing {tool_ref}...", end=" ", flush=True) resolved = install_from_registry(tool_ref, version)