Zing 论坛

正文

CLGMNI:将 Gemini 大模型能力注入终端的 Agentic AI 工具

CLGMNI 是一款面向网络安全专家、系统管理员和高级用户的终端 AI 助手,基于 Google Gemini 大模型构建。它不仅能回答问题,还能作为自主 Agent 在获得用户批准后执行系统命令,支持文件上下文注入、Google 搜索增强、会话日志记录等高级功能。

GeminiLLM终端AgentAI系统管理网络安全命令行工具Google
发布时间 2026/04/08 06:14最近活动 2026/04/08 06:20预计阅读 5 分钟
CLGMNI:将 Gemini 大模型能力注入终端的 Agentic AI 工具
1

章节 01

CLGMNI: Gemini-Powered Agentic AI Tool for Terminals

CLGMNI is a terminal AI assistant built on Google Gemini, designed for network security experts, system administrators, and advanced users. It functions as an autonomous Agent (with user approval) to execute system commands, supporting features like file context injection, Google search enhancement, session logging, and cost-controlled API management. This tool integrates Gemini's capabilities deeply into terminal workflows, balancing power and security.

2

章节 02

Project Background & Design Philosophy

CLGMNI (Command Line Gemini) was created by Jay Hawkins to address the need for a terminal-native AI tool. Its "terminal-first" design aligns with the workflows of terminal users (e.g., pipe operations, log analysis). Supported environments include Linux/macOS and Windows via WSL. Unlike web-based AI tools, it allows direct pipe of command outputs and attachment of local files as context for more informed responses.

3

章节 03

Agent Mode & Security Mechanisms

The standout feature of CLGMNI is its Agent mode (activated via -a). In this mode, Gemini acts as an interactive operator: it analyzes tasks, proposes Bash commands, waits for user approval, executes commands, and analyzes results. For example, it can check network interfaces and listening ports. Security is prioritized: commands are not auto-executed (highlighted in red for user confirmation), and sudo commands use local sudo -v for authentication (no root password is passed to AI).

4

章节 04

API Management & Context Enhancement

CLGMNI supports dual API keys (paid GEMINI_API_KEY_PAID and free GEMINI_API_KEY_FREE), with smart fallback to free if paid is unavailable. Users can force free mode with --free to control costs. Context injection features include pipe input of stdout and -f for multiple files (skipping >5MB files to stay within token limits). Google search enhancement (-g) provides real-time data to reduce hallucinations, and -s outputs source URLs.

5

章节 05

Technical Implementation Highlights

CLGMNI includes a token bucket rate limiter (300 RPM) and exponential backoff to avoid 429/503 errors. It supports multiple Gemini models: g25f (default 2.5 Flash), g25f-l (2.5 Flash-Lite), g25p (2.5 Pro), and g31p (3.1 Pro-Preview). Users can choose models based on task complexity to balance performance and cost.

6

章节 06

Practical Application Scenarios

CLGMNI is useful in several scenarios:

  1. Log Analysis: Pipe logs (e.g., SSH brute force attempts) for summary: cat /var/log/auth.log | grep "Failed password" | python3 CLGMNI.py -m g25f-l "Summarize these SSH brute force attempts."
  2. Config Diagnosis: Attach config files and logs (e.g., Nginx 502 errors) for analysis.
  3. Threat Intelligence: Use Google search to get latest TTPs/IOCs with source references.
  4. System Audit: Agent mode for comprehensive security checks and report generation.
7

章节 07

Summary & Future Outlook

CLGMNI represents a key evolution of terminal AI tools—moving beyond Q&A to become an operational assistant. Its secure design, cost control, and rich features make it valuable for sys admins and security pros. As Agentic AI grows, more such tools will combine LLM reasoning with domain-specific operations. CLGMNI is an excellent starting point for exploring AI in system management.