Coverage for src/alprina_cli/tools/__init__.py: 72%

25 statements  

« prev     ^ index     » next       coverage.py v7.11.3, created at 2025-11-14 11:27 +0100

1""" 

2Alprina CLI Tools 

3 

4Context-engineered tool system following Anthropic's best practices. 

5 

6Tools vs Agents: 

7- Tools = Callable utilities with clear interfaces (lightweight) 

8- Agents = Full LLM instances with prompts (heavy) 

9 

10We use tools for efficiency, composability, and context management. 

11""" 

12 

13from alprina_cli.tools.base import ( 

14 AlprinaToolBase, 

15 SyncToolBase, 

16 ToolResult, 

17 ToolOk, 

18 ToolError, 

19 TParams 

20) 

21 

22# Import tools 

23from alprina_cli.tools.security.network_analyzer import NetworkAnalyzerTool 

24from alprina_cli.tools.security.scan import ScanTool 

25from alprina_cli.tools.security.recon import ReconTool 

26from alprina_cli.tools.security.vuln_scan import VulnScanTool 

27from alprina_cli.tools.security.exploit import ExploitTool 

28from alprina_cli.tools.security.red_team import RedTeamTool 

29from alprina_cli.tools.security.blue_team import BlueTeamTool 

30from alprina_cli.tools.security.dfir import DFIRTool 

31from alprina_cli.tools.security.android_sast import AndroidSASTTool 

32from alprina_cli.tools.file.glob import GlobTool 

33from alprina_cli.tools.file.grep import GrepTool 

34from alprina_cli.tools.file.read import ReadFileTool 

35 

36# Tool registry - tools are auto-registered here 

37ALL_TOOLS = [ 

38 # Core security tools 

39 NetworkAnalyzerTool(), 

40 ScanTool(), 

41 ReconTool(), 

42 VulnScanTool(), 

43 ExploitTool(), 

44 # Specialized security tools 

45 RedTeamTool(), 

46 BlueTeamTool(), 

47 DFIRTool(), 

48 AndroidSASTTool(), 

49 # File tools (critical for context engineering) 

50 GlobTool(), 

51 GrepTool(), 

52 ReadFileTool(), 

53] 

54 

55 

56def register_tool(tool_instance): 

57 """Register a tool in the global registry""" 

58 ALL_TOOLS.append(tool_instance) 

59 return tool_instance 

60 

61 

62def get_tool_by_name(name: str): 

63 """ 

64 Get tool by name from registry. 

65 

66 Context: Just-in-time tool lookup (not pre-loading all tools). 

67 """ 

68 for tool in ALL_TOOLS: 

69 if tool.name == name: 

70 return tool 

71 raise ValueError(f"Tool not found: {name}") 

72 

73 

74def get_all_tools(): 

75 """Get all registered tools""" 

76 return ALL_TOOLS.copy() 

77 

78 

79__all__ = [ 

80 # Base classes 

81 "AlprinaToolBase", 

82 "SyncToolBase", 

83 "ToolResult", 

84 "ToolOk", 

85 "ToolError", 

86 "TParams", 

87 # Registry functions 

88 "register_tool", 

89 "get_tool_by_name", 

90 "get_all_tools", 

91 "ALL_TOOLS" 

92]