@@ -60,44 +60,50 @@ def _resolve_plugin_conflict(plugin_name: str, app_type: str) -> str:
6060 k : v for k , v in all_repos .items () if v .type == "marketplace"
6161 }
6262
63+ # Check configured marketplaces for the plugin
64+ found_in_marketplaces = []
65+ unreachable_marketplaces = []
66+
6367 for marketplace_name , repo in configured_marketplaces .items ():
64- if not repo .repo_owner or not repo .repo_name :
68+ # Handle both PluginRepo objects and installed marketplace dictionaries
69+ if hasattr (repo , 'repo_owner' ): # PluginRepo object
70+ repo_owner = repo .repo_owner
71+ repo_name = repo .repo_name
72+ repo_branch = repo .repo_branch or "main"
73+ elif isinstance (repo , dict ) and 'source' in repo : # Installed marketplace dict
74+ # Skip installed marketplaces - we'll handle them separately
75+ continue
76+ else :
77+ continue
78+
79+ if not repo_owner or not repo_name :
6580 continue
6681
6782 try :
6883 from code_assistant_manager .plugins .fetch import fetch_repo_info
69- info = fetch_repo_info (repo . repo_owner , repo . repo_name , repo . repo_branch or "main" )
84+ info = fetch_repo_info (repo_owner , repo_name , repo_branch )
7085 if info and info .plugins :
7186 for plugin in info .plugins :
7287 if plugin .get ("name" , "" ).lower () == plugin_name .lower ():
7388 found_in_marketplaces .append ({
7489 "marketplace" : marketplace_name ,
7590 "plugin" : plugin ,
76- "source" : f"github.com/{ repo .repo_owner } /{ repo .repo_name } "
91+ "source" : f"github.com/{ repo_owner } /{ repo_name } " ,
92+ "available" : True
7793 })
7894 break
79- except Exception :
80- # Skip marketplaces that can't be fetched
81- continue
82-
83- # Also check installed marketplaces in the app
84- try :
85- installed_marketplaces = handler .get_known_marketplaces ()
86- for marketplace_name , marketplace_info in installed_marketplaces .items ():
87- # If we already found it in configured marketplaces, skip
88- if any (f ["marketplace" ] == marketplace_name for f in found_in_marketplaces ):
89- continue
90-
91- # For installed marketplaces, we can't easily check their contents
92- # without fetching, but we can note they're available
93- source_info = marketplace_info .get ("source" , {}).get ("url" , "" )
94- found_in_marketplaces .append ({
95+ except Exception as e :
96+ # Log the error but don't skip the marketplace entirely
97+ import logging
98+ logger = logging .getLogger (__name__ )
99+ logger .debug (f"Failed to fetch marketplace '{ marketplace_name } ': { e } " )
100+ # Mark marketplace as unreachable but still show it
101+ unreachable_marketplaces .append ({
95102 "marketplace" : marketplace_name ,
96- "plugin" : {"name" : plugin_name }, # Placeholder
97- "source" : source_info or "installed marketplace"
103+ "source" : f"github.com/{ repo_owner } /{ repo_name } " ,
104+ "error" : str (e ),
105+ "available" : False
98106 })
99- except Exception :
100- pass
101107
102108 # Handle results
103109 if not found_in_marketplaces :
@@ -107,6 +113,11 @@ def _resolve_plugin_conflict(plugin_name: str, app_type: str) -> str:
107113 typer .echo (f"\n { Colors .CYAN } Available marketplaces:{ Colors .RESET } " )
108114 for name in sorted (configured_marketplaces .keys ()):
109115 typer .echo (f" • { name } " )
116+ # Show unreachable marketplaces if any
117+ if unreachable_marketplaces :
118+ typer .echo (f"\n { Colors .YELLOW } Unreachable marketplaces (temporarily unavailable):{ Colors .RESET } " )
119+ for unreachable in unreachable_marketplaces :
120+ typer .echo (f" • { unreachable ['marketplace' ]} ({ unreachable ['source' ]} )" )
110121 typer .echo (f"\n { Colors .CYAN } Browse plugins:{ Colors .RESET } cam plugin browse" )
111122 raise typer .Exit (1 )
112123
@@ -125,47 +136,59 @@ def _resolve_plugin_conflict(plugin_name: str, app_type: str) -> str:
125136 )
126137 typer .echo ()
127138
128- for i , found in enumerate (found_in_marketplaces , 1 ):
139+ # Combine available and unreachable marketplaces for display
140+ all_marketplaces = found_in_marketplaces + unreachable_marketplaces
141+
142+ for i , found in enumerate (all_marketplaces , 1 ):
129143 marketplace = found ["marketplace" ]
130144 source = found ["source" ]
131- plugin_info = found ["plugin" ]
145+ plugin_info = found .get ("plugin" , {})
146+ available = found .get ("available" , True )
132147 version = plugin_info .get ("version" , "" )
133148 description = plugin_info .get ("description" , "" )
134149
135- typer .echo (f" { i } . { Colors .BOLD } { marketplace } { Colors .RESET } " )
150+ status_indicator = "" if available else f" { Colors .YELLOW } (unreachable){ Colors .RESET } "
151+ typer .echo (f" { i } . { Colors .BOLD } { marketplace } { Colors .RESET } { status_indicator } " )
136152 if version :
137153 typer .echo (f" Version: { version } " )
138154 if description :
139155 typer .echo (f" Description: { description [:60 ]} { '...' if len (description ) > 60 else '' } " )
140156 typer .echo (f" Source: { source } " )
141157 typer .echo ()
142158
143- # Prompt user to choose
159+ # Prompt user to choose (only allow selecting available marketplaces)
160+ available_marketplaces = [f for f in all_marketplaces if f .get ("available" , True )]
144161 while True :
145162 try :
146163 choice = typer .prompt (
147- f"Choose marketplace (1-{ len (found_in_marketplaces )} ) or 'cancel'" ,
164+ f"Choose marketplace (1-{ len (all_marketplaces )} ) or 'cancel'" ,
148165 type = str
149166 ).strip ().lower ()
150167
151168 if choice == "cancel" :
152169 raise typer .Exit (0 )
153170
154171 choice_idx = int (choice ) - 1
155- if 0 <= choice_idx < len (found_in_marketplaces ):
156- selected = found_in_marketplaces [choice_idx ]
172+ if 0 <= choice_idx < len (all_marketplaces ):
173+ selected = all_marketplaces [choice_idx ]
174+ if not selected .get ("available" , True ):
175+ typer .echo (
176+ f"{ Colors .RED } Cannot select unreachable marketplace '{ selected ['marketplace' ]} '. Please choose an available marketplace.{ Colors .RESET } "
177+ )
178+ continue
179+
157180 marketplace = selected ["marketplace" ]
158181 typer .echo (
159182 f"{ Colors .GREEN } Selected: { marketplace } { Colors .RESET } "
160183 )
161184 return marketplace
162185 else :
163186 typer .echo (
164- f"{ Colors .RED } Invalid choice. Please enter 1-{ len (found_in_marketplaces )} or 'cancel'{ Colors .RESET } "
187+ f"{ Colors .RED } Invalid choice. Please enter 1-{ len (all_marketplaces )} or 'cancel'{ Colors .RESET } "
165188 )
166189 except ValueError :
167190 typer .echo (
168- f"{ Colors .RED } Invalid input. Please enter a number 1-{ len (found_in_marketplaces )} or 'cancel'{ Colors .RESET } "
191+ f"{ Colors .RED } Invalid input. Please enter a number 1-{ len (all_marketplaces )} or 'cancel'{ Colors .RESET } "
169192 )
170193 except (EOFError , KeyboardInterrupt ):
171194 typer .echo (f"\n { Colors .YELLOW } Cancelled.{ Colors .RESET } " )
0 commit comments