@wbytts/one
v0.0.3
Published
Command-line version of Cline AI coding assistant
Maintainers
Readme
Cline CLI - 命令行版本的 AI 编程助手
基于 Cline VSCode 插件 的核心逻辑,提供命令行版本的 AI 编程助手。
功能特性
- 🤖 多模型支持: 支持 Anthropic、OpenAI、DeepSeek 等 20+ 种 AI 模型
- 💻 交互式对话: 类似 ChatGPT 的交互体验
- 🛠️ 强大工具系统: 文件操作、命令执行、代码搜索等
- ⚡ 轻量级: 无需 VSCode,启动快速
- 🔧 灵活配置: 支持多种配置方式
- 👀 文件监听: 自动检测文件变化并处理
安装
npm install -g cline-cli或者本地开发:
git clone <此仓库>
cd cline-cli
npm install
npm run build快速开始
1. 配置 API
# Anthropic Claude (推荐)
cline config set --provider anthropic --api-key sk-xxx --model claude-3-5-sonnet-20241022
# DeepSeek (中文优化)
cline config set --provider deepseek --api-key sk-xxx --model deepseek-chat
# OpenAI GPT
cline config set --provider openai --api-key sk-xxx --model gpt-42. 启动交互模式
cline chat3. 执行单个任务
cline task "创建一个 React 组件"
cline task "重构这个函数" --files src/utils.js使用指南
配置管理
# 查看当前配置
cline config list
# 设置工作目录
cline config set --directory /path/to/project
# 启用自动批准模式
cline config set --auto-approve
# 重置配置
cline config reset交互模式
在交互模式下,你可以:
- 直接与 AI 对话
- 使用特殊命令:
exit或quit- 退出clear- 清空对话历史
任务执行模式
# 基本任务
cline task "创建一个新的 Express 服务器"
# 指定相关文件
cline task "优化这个算法" --files src/algorithm.js --files test/algorithm.test.js
# 在指定目录工作
cline task "初始化 React 项目" --directory ./my-app
# 自动批准所有操作
cline task "运行测试并修复错误" --auto-approve文件监听模式
# 监听所有文件
cline watch
# 监听特定模式
cline watch --pattern "src/**/*.js"
# 在指定目录监听
cline watch --pattern "**/*.py" --directory ./python-project可用工具
Cline CLI 提供以下工具来完成编程任务:
文件操作
read_file- 读取文件内容write_to_file- 写入文件list_files- 列出目录内容search_files- 搜索文件内容
系统操作
execute_command- 执行 shell 命令
配置文件
配置文件位于 ~/.clinerc.json,支持以下配置:
{
"apiProvider": "anthropic",
"apiKey": "your-api-key",
"model": "claude-3-5-sonnet-20241022",
"workingDirectory": ".",
"autoApprove": false,
"customInstructions": "始终使用中文回复,优先使用 TypeScript",
"tools": {
"executeCommand": {
"enabled": true,
"autoApprove": ["npm install", "git status"],
"timeout": 30000
},
"fileOperations": {
"enabled": true,
"watchPatterns": ["src/**/*", "*.json"],
"excludePatterns": ["node_modules/**", ".git/**"]
}
},
"security": {
"allowFileDelete": false,
"allowSystemCommands": true,
"restrictedCommands": ["rm -rf", "sudo"]
}
}支持的 AI 模型
Anthropic Claude
cline config set --provider anthropic --model claude-3-5-sonnet-20241022OpenAI GPT
cline config set --provider openai --model gpt-4
cline config set --provider openai --model gpt-3.5-turboDeepSeek (中文优化)
cline config set --provider deepseek --model deepseek-chat
cline config set --provider deepseek --model deepseek-coder其他模型
- OpenRouter (多模型聚合)
- Google Gemini
- Mistral AI
- Ollama (本地模型)
- LM Studio
示例场景
1. 代码重构
cline task "重构这个 React 组件,使其更简洁" --files src/components/UserProfile.jsx2. 错误修复
cline task "修复测试失败的问题" --files test/api.test.js src/api.js3. 新功能开发
cline task "添加用户认证功能,包括登录和注册"4. 代码审查
cline task "审查这个 PR 的代码" --files src/new-feature.js开发
项目结构
cline-cli/
├── src/
│ ├── core/
│ │ └── ClineCLI.ts # 核心逻辑类
│ ├── config/
│ │ └── ConfigManager.ts # 配置管理
│ ├── types/
│ │ └── Config.ts # 类型定义
│ └── cli.ts # 命令行入口
├── package.json
└── README.md本地开发
# 安装依赖
npm install
# 开发模式运行
npm run dev
# 构建
npm run build
# 运行测试
npm test与 Cline VSCode 插件的区别
| 特性 | Cline VSCode | Cline CLI | |------|-------------|-----------| | 环境依赖 | VSCode | 任何终端 | | 用户界面 | 图形界面 | 命令行 | | 文件编辑 | VSCode 编辑器 | 直接文件操作 | | 浏览器控制 | 支持 | 不支持 | | 资源占用 | 较高 | 较低 | | 自动化 | 有限 | 完全支持 |
贡献
欢迎提交 Issue 和 Pull Request!
许可证
Apache-2.0
致谢
基于 Cline 和 Cline Chinese 项目开发。
