From 1ab68dce541534b5ab11fdd7bf187312b7858821 Mon Sep 17 00:00:00 2001 From: Yj Date: Mon, 6 Jan 2025 23:40:50 +0800 Subject: [PATCH] fix: consolidate duplicate tool categories in list output - Replace itertools.groupby with dictionary-based grouping - Ensure tools with same category are displayed together - Fix redundant display of browsing and computer-control categories --- agentstack/cli/tools.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/agentstack/cli/tools.py b/agentstack/cli/tools.py index bee8a537..2ea7adb5 100644 --- a/agentstack/cli/tools.py +++ b/agentstack/cli/tools.py @@ -12,14 +12,19 @@ def list_tools(): List all available tools by category. """ tools = get_all_tools() - curr_category = None - + categories = {} + + # Group tools by category + for tool in tools: + if tool.category not in categories: + categories[tool.category] = [] + categories[tool.category].append(tool) + print("\n\nAvailable AgentStack Tools:") - for category, tools in itertools.groupby(tools, lambda x: x.category): - if curr_category != category: - print(f"\n{category}:") - curr_category = category - for tool in tools: + # Display tools by category + for category in sorted(categories.keys()): + print(f"\n{category}:") + for tool in categories[category]: print(" - ", end='') print(term_color(f"{tool.name}", 'blue'), end='') print(f": {tool.url if tool.url else 'AgentStack default tool'}")