npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xin9min9/edithai-cli

v1.4.7

Published

Intelligent log analysis CLI tool supporting multiple AI models (DeepSeek, GLM, OpenAI, Anthropic) with 30+ built-in tools for file operations, system diagnostics, and log pattern recognition.

Readme

EdithAI CLI

npm version

智能日志分析命令行工具,支持多种 AI 模型(DeepSeek、GLM、OpenAI、Anthropic),内置 30+ 工具用于文件操作、系统诊断和日志模式识别。

安装

全局安装

npm install -g @xin9min9/edithai-cli

验证安装

edithai --version

前置要求

  • Node.js >= 14.0.0
  • AI 模型 API 密钥(推荐使用 DeepSeek,同时支持 GLM、OpenAI、Anthropic)

快速开始

初始化工作空间

初始化工作空间目录结构(推荐首先执行):

edithai init

这将在 ~/.edithai/ 创建结构化的工作空间,用于配置、历史记录、日志等。

设置 API 密钥

使用凭证管理器设置您的 API 密钥:

# 设置 DeepSeek API 密钥(推荐)
edithai key set deepseek:your-api-key-here

# 设置 GLM API 密钥
edithai key set glm:your-api-key-here

# 设置 OpenAI API 密钥
edithai key set openai:your-api-key-here

# 列出已配置的密钥
edithai key list

# 删除密钥
edithai key delete deepseek

或通过环境变量设置:

Linux/macOS:

# DeepSeek(推荐)
export DEEPSEEK_API_KEY="your-api-key-here"

# GLM
export GLM_API_KEY="your-api-key-here"

# OpenAI 兼容
export OPENAI_API_KEY="your-api-key-here"

Windows:

# DeepSeek(推荐)
set DEEPSEEK_API_KEY="your-api-key-here"

# GLM
set GLM_API_KEY="your-api-key-here"

Windows PowerShell:

# DeepSeek(推荐)
$env:DEEPSEEK_API_KEY="your-api-key-here"

# GLM
$env:GLM_API_KEY="your-api-key-here"

基本用法

# 分析当前目录中的错误日志
edithai query "分析当前目录中的错误日志"

# 交互模式
edithai query -i

# 获取帮助
edithai --help

历史记录管理

# 列出所有历史记录文件及元数据
edithai history list

# 显示历史记录统计信息
edithai history stats

# 清除当前历史记录(需要确认)
edithai history clear

# 删除已归档的历史记录文件
edithai history delete-archived

功能特性

核心能力

  • 智能日志分析:使用自然语言分析日志
  • 30+ 内置工具:文件操作、系统诊断、数据处理
  • 多格式支持:处理各种日志格式和时间戳
  • 实时处理:高效使用 Token 的流式分析
  • 成本估算:通过价格集成跟踪 API 成本,支持 DeepSeek、GLM、OpenAI 和 Anthropic
  • 工作空间系统:统一的目录结构用于配置、历史记录和日志
  • 日志系统:全面的日志记录,支持多级别和文件轮换
  • 历史记录管理:具有隔离模式的高级历史记录文件管理

主要工具

  • 文件操作:读取、写入和搜索文件
  • 终端命令:安全执行诊断命令
  • 日志分析:模式检测、时间线分析和错误跟踪
  • 数据处理:CSV、JSON 和文本操作
  • 系统诊断:网络、进程和性能监控

执行模式

  • 标准模式:直接 AI 工具调用
  • 交互模式-i):与 AI 持续对话
  • 规划模式-planner):AI 生成执行计划,工具本地运行
  • MCP 服务器模式-mcp-server):通过 stdio JSON-RPC 暴露工具(无需 API 密钥)
  • MCP 客户端模式:连接到外部 MCP 服务器
  • MCP 代理模式:将任何 CLI/脚本包装为 MCP 服务器

技能系统

  • 用于复杂、多步骤工作流的离线技能包
  • 支持条件执行和断言
  • 通过 -skills 标志加载技能
  • 无递归 - 技能步骤不能调用其他技能

日志系统

  • 多级别日志:debug、info、warn、error
  • 控制台和文件输出
  • 按日期自动文件轮换
  • 并发访问保护的文件锁定
  • API 调用成本估算
  • 工具执行日志记录和持续时间跟踪

使用示例

基本日志分析

# 查找特定模式
edithai query "查找所有数据库连接错误"

# 生成性能报告
edithai query "根据应用日志创建性能摘要"

# 搜索内存泄漏
edithai query "分析内存使用模式并识别潜在泄漏"

交互模式

# 启动交互式会话
edithai query -i

# 多轮对话
> 显示内存使用趋势
> 查找过去 24 小时内的内存泄漏
> 将分析导出到 report.html

文件分析

# 分析特定日志文件
edithai query "分析 /var/log/application.log 中的性能问题"

# 处理多个文件
edithai query "汇总当前目录中的所有 .log 文件"

配置

工作空间结构

~/.edithai/
├── config.json           # 全局配置
├── credentials/          # 加密的 API 密钥存储
│   └── api_keys.json
├── profiles/            # 多环境配置文件
├── skills/              # 本地技能包
│   └── index.json
├── history/             # 对话历史
├── cache/               # 缓存数据
├── logs/                # 运行时日志
├── tmp/                 # 临时文件
├── downloads/           # 临时下载
└── mcp/                 # MCP 配置
    ├── servers/           # MCP 服务器配置
    └── proxies/           # MCP 代理配置

默认设置

  • 工具输出截断:2000 字符
  • API 超时:30 秒
  • 历史记录文件:~/.edithai/history/
  • 日志目录:~/.edithai/logs/

自定义配置

~/.edithai/config.json 创建配置文件:

{
  "api": {
    "timeout": 30,
    "max_tokens": 4000
  },
  "logging": {
    "enabled": true,
    "level": "info",
    "file": "~/.edithai/logs/edithai.log",
    "max_size_mb": 10
  },
  "workspace": {
    "auto_save_history": true,
    "archive_history_files": true,
    "enable_history_file_locking": true
  },
  "security": {
    "whitelist_commands": ["ls", "cat", "grep"],
    "blacklist_commands": ["rm", "dd", "mkfs"],
    "tool_payload_max_chars": 2000
  }
}

配置优先级

默认值 → 配置文件(~/.edithai/config.json)→ 环境变量(EDITHAI_*)→ 命令行参数

环境变量

  • DEEPSEEK_API_KEY - DeepSeek API 密钥(推荐)
  • GLM_API_KEY - GLM(智谱AI)API 密钥
  • OPENAI_API_KEY - OpenAI 兼容 API 密钥
  • ANTHROPIC_API_KEY - Anthropic API 密钥
  • EDITHAI_LOGGING_ENABLED - 启用/禁用日志记录
  • EDITHAI_LOGGING_LEVEL - 设置日志级别(debug/info/warn/error)

安全特性

  • 命令白名单/黑名单:限制终端命令执行
  • 文件扩展名保护:防止执行危险文件类型
  • 路径遍历保护:防止目录遍历攻击
  • 命令注入检测:阻止 shell 操作符和危险模式

支持的平台

  • Windows:x64、ARM64
  • Linux:x64、ARM64
  • macOS:Intel (x64)、Apple Silicon (ARM64)

故障排除

"command not found: edithai"

确保二进制文件已安装到您的 PATH 中:

# 检查 npm bin 目录
npm bin -g

# 如需要重新安装
npm uninstall -g @xin9min9/edithai-cli
npm install -g @xin9min9/edithai-cli

"API key not found"

设置相应的 API 密钥环境变量:

# DeepSeek(推荐)
export DEEPSEEK_API_KEY="your-api-key-here"

# GLM
export GLM_API_KEY="your-api-key-here"

# OpenAI 兼容
export OPENAI_API_KEY="your-api-key-here"
# 添加到 ~/.bashrc 或 ~/.zshrc 以持久化
# DeepSeek(推荐)
echo 'export DEEPSEEK_API_KEY="your-api-key-here"' >> ~/.bashrc

# 或 GLM
echo 'export GLM_API_KEY="your-api-key-here"' >> ~/.bashrc

权限被拒绝(类 Unix 系统)

安装程序会自动设置可执行权限。如果遇到权限问题:

chmod +x $(which edithai)

文档

有关功能和高级特性的详细文档,请访问主 EdithAI 仓库。

许可证

MIT-0 License - 详见 LICENSE 文件。

支持

如有问题和功能请求,请访问 GitHub Issues

贡献

欢迎贡献!提交拉取请求前,请先阅读贡献指南。

开发与发布

本项目包含用于跨平台二进制文件生成的构建脚本。

构建命令

# 为所有平台构建二进制文件
npm run build

# 构建并清理旧版本
npm run build:clean

发布命令

# 补丁版本发布(1.2.2 → 1.2.3)
npm run release

# 次要版本发布(1.2.2 → 1.3.0)
npm run release:minor

# 主要版本发布(1.2.2 → 2.0.0)
npm run release:major

发布命令将执行以下操作:

  1. 更新 package.json 中的版本
  2. 创建 git 标签
  3. 构建所有平台二进制文件
  4. 发布到 npm

支持的平台

二进制文件构建针对:

  • Windows:x64、ARM64
  • Linux:x64、ARM64
  • macOS:Intel (x64)、Apple Silicon (ARM64)

二进制文件随 npm 分发包打包,并直接从包中执行。

致谢

支持多种 AI 模型(推荐使用 DeepSeek,同时支持 GLM、OpenAI、Anthropic)用于智能日志分析。