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

dify-chat-cli

v1.0.1

Published

专为开发者设计的Dify知识库管理CLI工具,支持知识库创建、文档检索和数据采集清洗

Downloads

6

Readme

Dify Chat CLI

专为开发者设计的Dify知识库文档生成CLI工具。通过CLI与AI对话,让AI识别指定目录下的代码和文档内容,生成标准化的markdown文档,经用户核对后上传到Dify知识库。

🚀 功能特性

  • 🎯 对话式文档生成: 通过CLI对话让AI识别代码并生成文档
  • 📁 智能文件扫描: 自动识别代码文件,支持多种编程语言
  • 📝 交互式预览: 实时预览AI生成的markdown文档,支持修改
  • 🚀 一键上传: 确认无误后一键上传到Dify知识库
  • ⚡ 现代化: 基于React + Ink构建的现代化CLI体验

📦 安装

全局安装

pnpm add -g dify-chat-cli

🔧 配置

环境变量

配置文件路径: ~/.dify-chat/.env

# 必需
DIFY_API_KEY=your_dify_api_key_here

# 可选
DIFY_BASE_URL=https://api.dify.ai
NODE_ENV=production

获取API密钥

  1. 登录 Dify平台
  2. 进入应用设置
  3. 复制API密钥并配置到环境变量

🎯 使用指南

🚀 基础使用

# 启动交互式聊天
chat

# 查看帮助
chat --help

📋 交互式命令(推荐)

启动CLI后,在聊天界面中使用:

| 命令 | 功能 | |------|------| | @kb | 选择Dify知识库 | | @upload | 激活上传模式 | | @help | 显示所有可用命令 |

📁 智能文件上传

支持多种文件上传方式:

1. 直接路径输入

> ./src/main.js

2. 目录批量上传

> ./src/components

3. 拖拽文件路径

直接拖拽文件到终端,路径会自动识别

4. 复制粘贴

> /Users/yourname/Documents/project/README.md

5. 多文件上传

> ./src/main.js ./package.json ./README.md

🎯 使用流程

  1. 启动CLI: chat
  2. 选择知识库: 输入 @kb 选择目标知识库
  3. 上传文档: 直接输入文件路径或目录路径
  4. 确认上传: 系统会显示上传进度和结果

📊 支持的文件类型

  • 代码文件: .js, .ts, .tsx, .jsx, .py, .java, .go, .rs, .php, .rb
  • 配置文件: .json, .yaml, .yml, .toml, .env
  • 文档文件: .md, .txt, .html, .css
  • 其他: .sql, .sh, .dockerfile, .log

🛠️ 开发

环境要求

  • Node.js >= 18.0.0
  • pnpm >= 8.0.0

项目结构

dify-chat-cli/
├── src/
│   ├── App.tsx              # 应用程序主组件
│   ├── index.tsx            # 应用入口
│   ├── components/          # React组件
│   │   ├── Chat/            # 主聊天容器组件
│   │   ├── ChatInput/       # 聊天输入组件
│   │   ├── ChatMessages/    # 消息显示组件
│   │   ├── CommandSuggestions/ # 命令建议组件
│   │   ├── FileUploader/    # 文件上传组件
│   │   ├── KnowledgeBaseSelector/ # 知识库选择器组件
│   │   ├── PathSuggestions/ # 路径建议组件
│   │   └── StatusBar/       # 状态栏组件
│   ├── common/              # 共享代码
│   │   ├── hooks/           # 自定义钩子
│   │   │   ├── useChat.ts
│   │   │   ├── useCommandSuggestions.ts
│   │   │   ├── useFileUpload.ts
│   │   │   ├── useKnowledgeBase.ts
│   │   │   └── usePathSuggestions.ts
│   │   └── utils/           # 工具函数
│   │       ├── contextManager.ts  # 上下文管理工具
│   │       ├── yoga-compat.ts     # Yoga布局兼容层
│   │       └── index.ts           # 工具函数导出
│   ├── services/            # 服务层
│   │   ├── dify.ts          # Dify API服务
│   │   ├── openai.ts        # OpenAI API服务
│   │   ├── fileScanner.ts   # 文件扫描服务
│   │   └── config.ts        # 配置管理
│   └── types/               # 类型定义
│       ├── chat.ts          # 聊天相关类型
│       ├── cli.ts           # CLI特定类型
│       ├── dify.ts          # Dify API类型
│       ├── file.ts          # 文件相关类型
│       └── index.ts         # 类型导出索引
└── [配置文件]

使用示例

# 启动交互式文档生成
chat

# 快速文档生成
chat generate --path ./src/components

# 上传文档到知识库
chat upload --kb-id abc123 --file generated-doc.md

开发命令

# 安装依赖
pnpm install

# 开发模式(带热重载)
pnpm dev

# 生产构建
pnpm build

# 运行构建后的CLI
pnpm start

# 代码检查
pnpm lint

# 类型检查
pnpm type-check

📋 技术栈

  • Runtime: Node.js >= 18
  • UI Framework: React + Ink v4
  • Language: TypeScript
  • Build Tool: esbuild
  • HTTP Client: Axios
  • 配置管理: dotenv

📄 许可证

MIT License - 详见 LICENSE 文件