File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change 11from typing import Optional
22import itertools
3+ from difflib import get_close_matches
34import inquirer
4- from agentstack import conf
5+ from agentstack import conf , log
56from agentstack .utils import term_color , is_snake_case
67from agentstack import generation
78from agentstack import repo
8- from agentstack ._tools import get_all_tools
9+ from agentstack ._tools import get_all_tools , get_all_tool_names
910from agentstack .agents import get_all_agents
1011from pathlib import Path
1112import sys
@@ -63,6 +64,16 @@ def add_tool(tool_name: Optional[str], agents=Optional[list[str]]):
6364 """
6465 conf .assert_project ()
6566
67+ all_tool_names = get_all_tool_names ()
68+ if tool_name and not tool_name in all_tool_names :
69+ # tool was provided, but not found. make a suggestion.
70+ suggestions = get_close_matches (tool_name , all_tool_names , n = 1 )
71+ message = f"Tool '{ tool_name } ' not found."
72+ if suggestions :
73+ message += f"\n Did you mean '{ suggestions [0 ]} '?"
74+ log .error (message )
75+ return
76+
6677 if not tool_name :
6778 # Get all available tools including custom ones
6879 available_tools = [t for t in get_all_tools () if t is not None ]
You can’t perform that action at this time.
0 commit comments