How sudohopex/kaligpt works
Purpose and Entry Points
HackerX/KaliGPT is a Linux command-line AI assistant aimed at ethical-hacking and cybersecurity workflows. Its installed kaligpt command routes user prompts to selectable AI providers, supports interactive model/tool management, can launch provider web chats, and manages provider credentials. The Python package entry point is agents/__main__.py; package initialization is in agents/__init__.py. Installation is orchestrated by install.sh and platform installers under installers/.
CLI Orchestration
agents/__main__.py is the top-level control boundary for command parsing and modes such as Gemini, Ollama, OpenRouter, ChatGPT, LiteLLM, web launch, API-key setup, update, and provider listing. It dispatches into provider implementations rather than exposing a web service. Provider/model configuration and persistent selection logic are centralized under:
• agents/utils/agent_management.py
• agents/utils/agent_configs.py
• agents/utils/api.config.json
Provider Adapter Layer
Each supported backend has a dedicated adapter module, insulating the CLI and shared agent flow from vendor SDK/API differences:
• agents/gemini.py
• agents/chatgpt.py
• agents/ollama.py
• agents/openrouter.py
• agents/litellm_provider.py
Gemini, OpenAI/ChatGPT, OpenRouter, and LiteLLM are network-backed providers requiring credentials; Ollama targets a local runtime but may also access cloud-hosted models. LiteLLM is the broad-provider integration point, advertised as supporting 100+ vendors.
Agent Conversation and Response Flow
A typical invocation flows from CLI mode/prompt selection to provider/model resolution, prompt construction, model execution, optional tool-call handling, and terminal rendering. Shared interaction responsibilities are separated into:
• agents/utils/prompts.py
• agents/utils/parse_n_print_response.py
• agents/utils/openai_tool_adapter.py
The OpenAI tool adapter is an important compatibility boundary: it likely normalizes tool/function-call semantics for provider responses into the application’s tool execution flow. Ollama-specific tool-thinking capability detection is isolated in agents/utils/ollama_tool_think_support_check.py.
Tool Execution and Web Retrieval
The agent can expose tools to models and execute actions locally or through external retrieval services. Tool implementations are grouped in:
• agents/utils/tools/locals.py
• agents/utils/tools/web_request_framework.py
• agents/utils/tools/opensearchapi.py
locals.py represents host-local actions, creating the principal boundary between model output and the user’s machine. Web requests are mediated by a shared framework, while OpenSearchAPI is a distinct external search service integration. agents/utils/openserp_management.py manages the search-service-facing behavior/configuration.
Configuration, Credentials, and User-Facing Launching
Provider API configuration is stored in agents/utils/api.config.json; agent defaults and model choices are handled through the agent configuration/management modules. The separate web-chat launcher uses:
• agents/web_launcher.py
• agents/utils/web_launcher.json
This path opens official provider web interfaces rather than sending requests through the CLI provider adapters.
Runtime and Delivery
The runtime is Python with dependencies declared in requirements/pip-requirements.txt. Delivery is shell-based: install.sh selects or invokes platform-specific scripts for Arch, Debian-family Linux, and Termux:
• installers/installer.arch.sh
• installers/installer.deb.sh
• installers/installer.termux.sh
The repository also contains a focused LiteLLM integration test at tests/test_litellm_provider.py, reflecting the provider abstraction’s external dependency risk.
Main entry points: prompts.py Prompt builder · parse_n_print_response.py Response renderer · __main__.py kaligpt CLI entry · agent_management.py Agent management
Components 21
CLI & Conversation
- kaligpt CLI entry · Parses modes and dispatches provider, setup, update, and web-launch commands.
agents/__main__.py - Agent management · Resolves persistent provider and model selections.
agents/utils/agent_management.py - Agent defaults
agents/utils/agent_configs.py - Provider API config · Stores provider API settings and credentials metadata.
agents/utils/api.config.json - Prompt builder
agents/utils/prompts.py - Response renderer · Parses model output and renders terminal responses.
agents/utils/parse_n_print_response.py - OpenAI tool adapter · Normalizes tool/function calls into the execution flow.
agents/utils/openai_tool_adapter.py - Provider web launcher · Opens official provider web chat interfaces.
agents/web_launcher.py - Web launcher config
agents/utils/web_launcher.json
Provider Adapters
- Gemini
agents/gemini.py - ChatGPT
agents/chatgpt.py - Ollama · Targets the local Ollama runtime or cloud-hosted models.
agents/ollama.py - OpenRouter
agents/openrouter.py - LiteLLM · Broad integration path for 100+ vendors.
agents/litellm_provider.py - Ollama tool-thinking check
agents/utils/ollama_tool_think_support_check.py
Tool Execution
- Local tools · Principal boundary for model-directed actions on the user's machine.
agents/utils/tools/locals.py - Web request framework
agents/utils/tools/web_request_framework.py - OpenSearchAPI
agents/utils/tools/opensearchapi.py - Search service management
agents/utils/openserp_management.py
Runtime & Delivery
- Python dependencies
requirements/pip-requirements.txt - Linux installers · Platform installers for Arch, Debian-family Linux, and Termux.
install.sh
Connections 23
- kaligpt CLI entry → Agent management: selects provider/model
- Agent management → Agent defaults: loads defaults
- Agent management → Provider API config: reads API settings
- kaligpt CLI entry → Prompt builder: builds request
- Prompt builder → Gemini: prompt
- Prompt builder → ChatGPT: prompt
- Prompt builder → Ollama: prompt
- Prompt builder → OpenRouter: prompt
- Prompt builder → LiteLLM: prompt
- Ollama → Ollama tool-thinking check: checks tool support
- Gemini → Response renderer: model response
- ChatGPT → Response renderer: model response
- Ollama → Response renderer: model response
- OpenRouter → Response renderer: model response
- LiteLLM → Response renderer: model response
- Response renderer → OpenAI tool adapter: tool calls
- OpenAI tool adapter → Local tools: executes local actions
- OpenAI tool adapter → Web request framework: executes retrieval
- Web request framework → OpenSearchAPI: search request
- Search service management → OpenSearchAPI: configures
- kaligpt CLI entry → Provider web launcher: web-chat mode
- Provider web launcher → Web launcher config: loads destinations
- Linux installers → Python dependencies: installs runtime dependencies