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

@liujunb/agent-cli

v1.3.0

Published

AI驱动的终端REPL工具 — 仿 Claude Code CLI

Downloads

1,094

Readme

Agent CLI

英文文档

基于 AI 的终端 REPL 工具,灵感来自 Claude Code CLI。使用 TypeScript + Ink(React for CLI)+ Vercel AI SDK 构建,兼容 OpenAI / DeepSeek / Qwen API 格式。

安装

npm install -g @liujunb/agent-cli

使用

打开终端,直接输入:agent,如下:

liujun@liujun ~ %:agent

第一步:配置 API KEY

首次启动时会提示配置 API 密钥。输入 /config 按提示操作即可。

  • 如准备使用 Mock(mock-liujun-llm) 模型,那么随便需配置一个 API KEY 即可。

    Mock LLM 是为了方便开发和调试,只能测试头部提示的 Mock asks 的场景。

  • 如准备使用 Deepseek 模型,那么配置 Deepseek 的 API KEY 即可。

  • 如准备使用 Qwen 模型,那么配置 Deepseek 的 API KEY 即可。

第二步:选择使用的模型

输入 /model 按提示操作即可。

指令

| 命令 | 说明 | | ----------------------------- | --------------------------------------- | | /config | 管理各供应商的 API 密钥 | | /model <name> | 切换模型(/model 后按 Tab 查看建议) | | /effort <low\|medium\|high> | 设置推理力度 | | /clear | 清除对话历史 | | /help? | 显示帮助 | | /exit | 退出 |

特性

  • 交互式 REPL — 多行输入、流式输出、斜杠命令选择器
  • 多模型支持 — 内置 DeepSeek V4 Flash/Pro 和 Qwen Max/Plus 模型
  • 密钥按供应商管理 — 每个供应商独立存储密钥,切换模型时自动匹配
  • 工具执行 — AI 请求执行 shell/文件操作时需用户确认
  • 推理力度 — 支持低/中/高三档
  • 流式输出 — 实时逐 token 显示 AI 响应
  • Token 计费 — 实时显示输入/输出 token 数和费用

连接 MCP 服务

在项目的根目录创建一个 .mcp.json 文件,接着配置 MCP 服务,重新启动会自定连接。

例如,连接一个医院临床计算 MCP 服务.

{
  "mcpServers": {
    "calculator-service": {
      "command": "npx",
      "args": ["-y", "@liujunb/calculator-service"]
    }
  }
}

MCP 具体使用文档:https://www.npmjs.com/package/@liujunb/calculator-service

创建 SKILL

在项目的根目录创建 .claude/skills/ 文件夹,接着在这个目录下创建 SKILL。 例如,创建 architect-helper 技能:

.claude/skills/architect-helper/SKILL.md

---
name: architect-helper
description: 提供Android、Web、Java、微信小程序等软件架构设计方面的专家建议
---

你是一位资深软件架构师。当用户讨论系统设计、技术选型或代码结构时,请从以下角度分析:

- 架构合理性:分层是否清晰、模块边界是否合理、耦合度
- 扩展性:设计是否能适应未来需求变化
- 技术选型:依赖和框架的选择是否合理
- 性能考量:潜在瓶颈和优化方向

请使用中文回答,用 Markdown 列表组织观点。

创建好了 SKILL 之后,同样需要重新启动程序。

System Prompt

写在 .claude/CLAUDE.md 即可。

开发

npm install
npm run dev       # 开发模式(tsx watch + 可选代理)
npm run build     # 编译 TypeScript
npm start         # 运行编译后的输出

代理调试(仅开发模式,方便调试代码)

.env 中配置:

PROXY_URI=http://localhost:9090
PROXY_CA_PATH=/path/to/proxy/ca.pem

NODE_ENV=development 时自动启用。

架构

src/
├── index.ts               # 入口:Ink 渲染 + 可选代理
├── cli/
│   ├── app.tsx            # 主组件(状态机、路由、屏幕)
│   └── components/
│       ├── MessageList.tsx # 对话历史
│       ├── StreamingBox.tsx# 逐 token 输出
│       ├── InputRow.tsx    # 多行输入 + 斜杠命令选择器
│       └── StatusBar.tsx   # 模型 / token / 费用显示
├── core/
│   ├── llm/
│   │   ├── client.ts      # LLM 客户端(OpenAI 兼容)
│   │   ├── stream.ts      # 流式响应聚合
│   │   └── tools.ts       # 工具定义(shell、读写文件)
│   └── billing/
│       └── costCalculator.ts
├── config/
│   ├── settings.ts        # 持久化配置(conf)
│   └── models.ts          # 内置模型列表和定价
└── utils/
    └── logger.ts

状态机

idle → streaming → idle
idle → streaming → awaiting_confirm → streaming → idle
  • idle — 等待用户输入
  • streaming — AI 生成回复中
  • awaiting_confirm — 等待用户确认工具执行(↑↓ 选择,Enter 确认)
  • config_api_key — API 密钥配置

API 密钥存储

密钥持久化在 ~/Library/Preferences/agent-cli-nodejs.json 中,以 Record<baseURL, string> 格式存储,每个供应商一条记录。

环境要求

  • Node.js >= 20