@@ -80,11 +80,25 @@ def _extract_semver(s: str) -> str:
8080 m = re .search (r"\d+\.\d+(?:\.\d+)?(?:[-+][\w\.]+)?" , str (s ))
8181 return m .group (0 ) if m else ""
8282
83+ def _format_version (value ) -> str :
84+ import re
85+
86+ if value is None :
87+ return "unknown"
88+ text = str (value ).strip ()
89+ if not text :
90+ return "unknown"
91+ text = text .splitlines ()[0 ].strip ()
92+ ansi_escape = re .compile (r"\x1B\[[0-?]*[ -/]*[@-~]" )
93+ text = ansi_escape .sub ("" , text )
94+ return text or "unknown"
95+
8396 # Track tools that we skipped via pre-check
8497 precheck_skipped = {}
8598
8699 # Exclude MCP from upgradeable tools since it's now a subcommand
87100 upgradeable_tools = {k : v for k , v in registered_tools .items () if k != "mcp" }
101+ status_by_tool = {name : "pending" for name in upgradeable_tools }
88102
89103 if target == "all" :
90104 # Minimize output in test mode to avoid filling pytest capture buffers
@@ -99,7 +113,7 @@ def _extract_semver(s: str) -> str:
99113 version = tool_instance ._get_version ()
100114 except Exception :
101115 version = "unknown"
102- pre_versions [tool_name ] = version
116+ pre_versions [tool_name ] = _format_version ( version )
103117 success_count = 0
104118 total_count = 0
105119 actual_upgrades = 0
@@ -125,6 +139,7 @@ def _extract_semver(s: str) -> str:
125139 # Get install command from registry
126140 install_cmd = TOOL_REGISTRY .get_install_command (tool_key )
127141 if not install_cmd :
142+ status_by_tool [tool_name ] = "no-command"
128143 # typer.echo(f"{Colors.YELLOW}No upgrade command found for {tool_name}{Colors.RESET}")
129144 continue
130145
@@ -142,19 +157,22 @@ def _extract_semver(s: str) -> str:
142157 current_v_raw = tool ._get_version ()
143158 except Exception :
144159 current_v_raw = "unknown"
160+ current_v_display = _format_version (current_v_raw )
145161 current_v = _extract_semver (current_v_raw )
146162 latest_v = _get_latest_npm_version (pkg_name )
147163 latest_v_clean = _extract_semver (latest_v )
164+ latest_v_display = _format_version (latest_v )
148165
149166 if current_v and latest_v_clean and current_v == latest_v_clean :
150167 # typer.echo(f" {tool_name}: {Colors.YELLOW}No upgrade available (installed: {current_v}){Colors.RESET}")
151168 # Mark as skipped so we can report later
152169 if "precheck_skipped" not in locals ():
153170 precheck_skipped = {}
154171 precheck_skipped [tool_name ] = {
155- "current" : current_v ,
156- "latest" : latest_v_clean ,
172+ "current" : current_v_display ,
173+ "latest" : latest_v_display ,
157174 }
175+ status_by_tool [tool_name ] = "skipped"
158176 prepared_tools .append (
159177 (tool_name , "skipped" , None )
160178 ) # Track as prepared but skipped
@@ -261,7 +279,7 @@ def _extract_semver(s: str) -> str:
261279 # Display results for ALL upgradeable tools, including ones skipped by pre-check
262280 typer .echo (f"\n { Colors .GREEN } Upgrade results:{ Colors .RESET } " )
263281 for tool_name in upgradeable_tools .keys ():
264- before_v = pre_versions .get (tool_name , "unknown" )
282+ before_v = _format_version ( pre_versions .get (tool_name , "unknown" ) )
265283
266284 # If precheck indicated skip due to already latest
267285 if tool_name in precheck_skipped :
@@ -271,6 +289,7 @@ def _extract_semver(s: str) -> str:
271289 typer .echo (
272290 f" { tool_name } : { Colors .YELLOW } ✓ No upgrade (version unchanged){ Colors .RESET } { Colors .BLUE } ({ current } ){ Colors .RESET } "
273291 )
292+ status_by_tool [tool_name ] = "skipped"
274293 continue
275294
276295 # If tool had no install command (we decremented total_count earlier), report accordingly
@@ -289,6 +308,7 @@ def _extract_semver(s: str) -> str:
289308 typer .echo (
290309 f" { tool_name } : { Colors .YELLOW } No upgrade command available{ Colors .RESET } "
291310 )
311+ status_by_tool [tool_name ] = "no-command"
292312 continue
293313
294314 # If tool was part of the executed results
@@ -297,35 +317,37 @@ def _extract_semver(s: str) -> str:
297317 success = bool (result_data .get ("success" ))
298318 # Attempt post-upgrade version
299319 try :
300- post_version = upgradeable_tools [tool_name ](
320+ post_version_raw = upgradeable_tools [tool_name ](
301321 config
302322 )._get_version ()
303323 except Exception :
304- post_version = "unknown"
324+ post_version_raw = "unknown"
325+ post_version = _format_version (post_version_raw )
305326
306327 try :
307- same_version = (
308- str (before_v ).strip () == str (post_version ).strip ()
309- )
328+ same_version = before_v == post_version
310329 except Exception :
311330 same_version = False
312331
313332 if same_version :
314333 if success :
334+ status_by_tool [tool_name ] = "no-change"
315335 typer .echo (
316336 f" { tool_name } : { Colors .YELLOW } ✓ No upgrade (version unchanged){ Colors .RESET } { Colors .BLUE } ({ before_v } ){ Colors .RESET } "
317337 )
318338 else :
339+ status_by_tool [tool_name ] = "failed"
319340 typer .echo (
320341 f" { tool_name } : { Colors .RED } ✗ Failed during upgrade{ Colors .RESET } { Colors .BLUE } ({ before_v } -> { post_version } ){ Colors .RESET } "
321342 )
322343 else :
323344 if success :
324- actual_upgrades += 1
345+ status_by_tool [ tool_name ] = "upgraded"
325346 typer .echo (
326347 f" { tool_name } : { Colors .GREEN } ✓ Upgraded{ Colors .RESET } { Colors .BLUE } ({ before_v } -> { post_version } ){ Colors .RESET } "
327348 )
328349 else :
350+ status_by_tool [tool_name ] = "failed"
329351 typer .echo (
330352 f" { tool_name } : { Colors .RED } ✗ Failed{ Colors .RESET } { Colors .BLUE } ({ before_v } -> { post_version } ){ Colors .RESET } "
331353 )
@@ -334,9 +356,14 @@ def _extract_semver(s: str) -> str:
334356 typer .echo (
335357 f" { tool_name } : { Colors .YELLOW } No action taken{ Colors .RESET } { Colors .BLUE } ({ before_v } ){ Colors .RESET } "
336358 )
359+ status_by_tool [tool_name ] = "no-action"
337360
338361 # Skip original loop as we've replaced it
339362
363+ actual_upgrades = sum (
364+ 1 for status in status_by_tool .values () if status == "upgraded"
365+ )
366+
340367 typer .echo (
341368 f"\n { Colors .GREEN } Upgrade complete: { actual_upgrades } /{ len (upgradeable_tools )} tools upgraded successfully{ Colors .RESET } "
342369 )
0 commit comments