发现 AI 代理的未来arrow_forward

ESA

calendar_today收录于 2026年2月26日
category智能体与应用工具
code开源
大语言模型MCPGoAI代理智能体框架CLI智能体与应用工具模型与推理框架开发者工具/代码自动化/工作流/RPA协议/API/集成

AI 驱动的命令行微 Agent 框架,通过 TOML 配置将 Shell 命令包装为 LLM 可调用函数,支持多 LLM 后端和 MCP 协议,实现安全可控的自然语言到系统操作转换。

项目简介#

ESA 是一个用 Go (71.3%) 编写的 AI 驱动命令行工具,由 meain 开发并维护(222 commits)。核心概念是"个性化微 Agent"——通过限制 LLM 只能访问高度特定、经过审计的小型工具集,实现更安全、精准、高效的系统自动化。

核心特性#

多 LLM 提供商支持#

  • OpenAI (OPENAI_API_KEY)
  • Groq (GROQ_API_KEY)
  • OpenRouter (OPENROUTER_API_KEY)
  • GitHub Models (GITHUB_MODELS_API_KEY)
  • Ollama 本地部署 (OLLAMA_API_KEY)
  • 自定义 OpenAI-compatible APIs

Agent 系统#

通过 TOML 配置文件定义专用 Agent,每个 Agent 包含:

  • system_prompt: 定义 Agent 角色和行为
  • functions: 可调用的命令定义(含参数验证、类型检查、格式化)

内置 Agent:+default(基本系统操作)、+new(创建新 Agent)、+auto(自动选择合适 Agent)

Function-Based 架构#

  • 将 Shell 脚本/CLI 命令包装为 LLM 可调用的函数
  • 支持 {{$command}} 动态执行 Shell 命令并插入输出
  • 参数验证:type、required、format

MCP Server 集成#

支持 Model Context Protocol (MCP) 服务器,可连接外部数据源和工具(文件系统、数据库、Web 服务等),支持函数级别安全控制(safe_functionsallowed_functions)。

交互模式#

  • CLI 单次执行esa "your query"
  • REPL 模式esa --repl
  • Web 界面esa --serve(WebSocket 流式响应,默认端口 8080)

安全控制#

  • 三级确认模式:none(默认)、unsafe(危险命令确认)、all(全部确认)
  • 函数安全标记:safe = true/false

对话管理#

会话历史保存与恢复(--continue--conversation <id>),历史查看(--list-history--show-history <index>),重试机制(--retry)\n

快速开始#

# 安装
go install github.com/meain/esa@latest

# 配置 API Key
export OPENAI_API_KEY="your-key"

# 基础使用
esa "what time is it"
esa +k8s "show pod status"
git diff --staged | esa +commit

Agent 配置示例#

name = "Kubernetes Command Assistant"
description = "An agent with read-only access to Kubernetes cluster"

system_prompt = """
You are a Kubernetes Command Assistant.
"""

[[functions]]
name = "get_namespaces"
description = "Retrieve all namespaces"
command = "kubectl get namespaces"
safe = true

[[functions]]
name = "get_resources"
command = "kubectl get {{resource}} {{namespace}}"
safe = true

[[functions.parameters]]
name = "resource"
type = "string"
required = true

典型应用场景#

  • DevOps/Kubernetes 管理esa +k8s "what is the secret value that starts with AUD_"
  • Git 工作流git diff --staged | esa +commit
  • JIRA 集成esa +jira "list all open issues assigned to me"
  • 代码库分析:Tree-sitter 查询生成、代码搜索
  • 个人工作流:时区转换、系统监控、Web 检索

核心价值#

  • 减少混淆(LLM 选择更精准)
  • 更好的工具调用(避免"猜脚本")
  • 更快、更便宜(可用小模型)
  • 更安全的自主性

技术要求#

  • Go 1.23.6+
  • 至少一个 LLM 提供商的 API Key
  • 配置文件路径:~/.config/esa/config.toml

保持更新

获取最新的 AI 工具和趋势,直接发送到您的收件箱。没有垃圾邮件,只有智能。

rocket_launch