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

loongbot

v0.0.13

Published

终端 AI Agent 框架,基于 Anthropic API 实现智能代码助手

Downloads

1,335

Readme

LoongBot

终端 AI Agent 框架

基于 Anthropic API 的智能代码助手,帮助你更高效地编写代码。


功能特性

  • Agent Loop 模式 - LLM 推理 → 工具调用 → 结果反馈 → 循环继续,自主完成复杂任务
  • REPL 交互界面 - 类 Claude Code 风格的终端交互体验,支持实时流式输出
  • 丰富的内置工具
    • 文件读写编辑(支持安全路径校验)
    • Bash 命令执行(可配置超时)
    • 代码搜索(Glob/Grep)
  • 上下文管理
    • 自动压缩长对话(microCompact + autoCompact)
    • 保存完整对话记录到本地
  • 任务系统
    • Todo 任务管理
    • 后台任务支持(异步执行,自动通知)
    • 子代理协作(并行处理)
  • 技能扩展系统 - 通过 Markdown 文件定义自定义技能

安装

npm install -g loongbot

要求: Node.js >= 18.12.0

快速开始

1. 配置 settings.json

配置文件位于 ~/.loongBot/settings.json,首次运行时会自动创建默认配置。

手动创建配置文件:

# 创建配置目录
mkdir -p ~/.loongBot

# 创建配置文件
cat > ~/.loongBot/settings.json << 'EOF'
{
  "anthropic": {
    "apiKey": "your-api-key-here",
    "baseUrl": "https://api.anthropic.com",
    "model": "claude-sonnet-4-5"
  }
}
EOF

配置项说明:

| 配置项 | 必需 | 默认值 | 说明 | |--------|------|--------|------| | anthropic.apiKey | ✅ | - | Anthropic API 密钥 | | anthropic.baseUrl | ❌ | https://api.anthropic.com | 自定义 API 端点 | | anthropic.model | ❌ | claude-sonnet-4-5 | 模型名称 | | agent.maxTokens | ❌ | 8000 | Agent 最大 token 数 | | subagent.maxRounds | ❌ | 30 | 子代理最大轮数 | | tools.bashTimeout | ❌ | 30000 | Bash 命令超时时间(ms) |

或者使用环境变量:

export ANTHROPIC_API_KEY=your-api-key

2. 使用方式

REPL 模式(交互式):

loongbot

进入交互式对话模式,持续对话直到输入 /exit 退出。

单次执行模式:

loongbot "帮我分析当前目录的代码结构"

执行单个任务后自动退出。

使用示例

# 代码分析
loongbot "分析 src 目录的架构设计"

# Bug 修复
loongbot "修复登录页面的表单验证问题"

# 功能开发
loongbot "为用户模块添加密码重置功能"

# 代码重构
loongbot "将回调函数改为 async/await 写法"

# 文档生成
loongbot "为 API 接口生成使用文档"

内置命令

在 REPL 模式下支持以下命令:

| 命令 | 说明 | |------|------| | /help | 显示帮助信息 | | /exit | 退出程序 | | /clear | 清空对话历史 | | /compact | 手动压缩上下文 |

技能扩展

~/.loongBot/skills/ 目录下创建 SKILL.md 文件即可定义自定义技能:

---
name: my-skill
description: 技能描述
---

技能指导内容...

项目架构

src/
├── cli/           # 命令行入口、REPL、Agent Loop
├── bridge/        # 事件通信桥接(agentLoop ↔ UI)
├── ui/            # Ink React 组件
├── tool/          # 工具定义与注册
│   └── definitions/
│       ├── files/     # 文件操作工具
│       ├── compact/   # 上下文压缩
│       ├── skills/    # 技能加载
│       ├── tasks/     # 任务管理
│       ├── background/# 后台任务
│       ├── todo/      # Todo 管理
│       └── subagent/  # 子代理
├── config.ts      # 配置常量
└── utils.ts       # 工具函数(路径沙箱等)

开发

# 克隆仓库
git clone https://github.com/loongjiu/loongBot.git
cd loongBot

# 安装依赖
npm install

# 开发模式运行
npm run dev

# 构建
npm run build

# 代码检查
npm run lint

# 类型检查
npm run typecheck

安全机制

  • 路径沙箱 - 所有文件操作通过 safePath() 校验,确保只能访问工作目录内的文件
  • 编辑校验 - old_text 必须存在且唯一,防止误改

相关项目

License

MIT

贡献

欢迎提交 Issue 和 Pull Request!


如果这个项目对你有帮助,请给一个 ⭐️ Star!