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

aidoes

v0.1.4

Published

ai命令行工具

Readme

@done-coding/cli-ai

AI 对话命令行工具 - 在终端中与 AI 大模型进行流式对话

npm version License: MIT

安装

独立安装

npm install @done-coding/cli-ai
# 或
pnpm add @done-coding/cli-ai

作为 done-coding CLI 的一部分

npm install -g @done-coding/cli
# 然后使用
DC ai
# 或直接无子命令进入
DC

快速开始

# 独立使用
dc-ai

# 作为主 CLI 的子命令
DC ai

# 或直接 DC 回车后选 y
DC

# 查看帮助
dc-ai --help

功能特性

  • 🤖 多服务商支持: 通过 mrm(模型源管理器)统一管理服务商和模型
  • 🔐 API Key 持久化: 首次输入后保存到 ~/.done-coding/config.json,后续自动使用
  • 📡 SSE 流式响应: 逐 token 实时输出,体验接近 ChatGPT
  • 🎯 模型切换委托 mrm: /provider/model 内部委托 @done-coding/cli-mrm 管理
  • ⌨️ 内置命令: /provider 切换服务商、/model 切换模型、/clear 清屏、/exit 退出
  • 📦 子包帮助: 输入 /子包名 查看其他 CLI 工具的版本号和帮助信息
  • 🔄 401 自动重试: API Key 无效时自动重新引导输入

API 文档

基础命令

dc-ai chat

启动 AI 对话(默认子命令,dc-ai 不加参数等同 dc-ai chat

# 直接启动
dc-ai

# 显式指定
dc-ai chat

内置命令:

| 命令 | 说明 | |---|---| | Ctrl+C | 取消当前输入 | | /exit | 退出对话 | | /provider | 切换服务商(通过 mrm 管理) | | /model | 在当前服务商下切换模型(通过 mrm 管理) | | /clear | 清屏 | | /mrm | 查看 mrm 模型源管理器的帮助 | | /component | 查看组件工具的帮助 | | /config | 查看工程配置工具的帮助 | | /create | 查看项目创建工具的帮助 | | /extract | 查看信息提取工具的帮助 | | /inject | 查看信息注入工具的帮助 | | /publish | 查看发布工具的帮助 | | /template | 查看模板编译工具的帮助 |

首次使用流程: 选择模型服务商 → 选择具体模型 → 输入 API Key → 开始对话。

使用示例

基础使用场景

# 1. 通过主 CLI 启动(无子命令时)
DC
# 是否唤起 AI 对话? → y
# 选择模型服务商 → DeepSeek
# 选择模型 → DeepSeek V4 Flash
# 输入 API Key → ****
# 输入消息开始对话 →

# 2. 通过 ai 子命令启动
DC ai

# 3. 独立 bin 启动
dc-ai

# 4. 切换服务商
# 在对话中输入 /provider

# 5. 切换模型(当前服务商下)
# 在对话中输入 /model

作为主 CLI 的一部分

# 使用主 CLI 命令
DC ai
DC ai chat

# 无子命令,选 y 进入
DC

# 使用替代命令
dc-cli ai
done-coding ai

编程接口

import { handler } from "@done-coding/cli-ai";

// 启动 AI 对话
await handler("chat");

配置

配置持久化到 ~/.done-coding/config.jsonAI_CONFIG 字段:

{
  "AI_CONFIG": {
    "model": "deepseek-v4-flash",
    "apiKey": "sk-xxx",
    "baseUrl": "https://api.deepseek.com"
  }
}

依赖的工具包

本包集成了以下 done-coding CLI 工具:

  • @done-coding/cli-mrm: 模型源管理器(服务商/模型管理、配置写入)
  • @done-coding/cli-utils: 通用工具函数(xPrompts、outputConsole、全局配置读写)
  • @done-coding/cli-component/config/create/extract/inject/publish/template: 通过 /子包名 输出帮助信息
  • openai: OpenAI 兼容 SDK(^4.x),负责 SSE 流式调用

故障排除

常见问题

Q: 401 Authentication Fails

# API Key 无效时会自动重新引导输入
# 检查 Key 是否正确
# 确认 Key 在对应服务商的有效期内

Q: 网络请求超时

# 检查网络连接
curl -I https://api.deepseek.com

# 确认对应服务商的 API 地址可访问

Q: Token 输出中断

# 重新进入对话即可,已保存的配置不会丢失
DC ai

贡献指南

我们欢迎贡献!请遵循以下步骤:

  1. Fork 本仓库
  2. 创建功能分支:git checkout -b feature/amazing-feature
  3. 提交更改:git commit -m "feat: add amazing feature"
  4. 推送分支:git push origin feature/amazing-feature
  5. 创建 Pull Request

开发环境设置

# 克隆仓库
git clone https://github.com/done-coding/done-coding-cli.git
cd done-coding-cli/packages/ai

# 安装依赖
pnpm install

# 开发模式
pnpm dev

# 构建
pnpm build

# 本地开发测试
node es/cli.mjs --help

# 注意:本地使用 node + 入口文件,发布后使用 bin 命令名
# 功能完全一致,只是调用方式不同

许可证

MIT © done-coding

相关链接