Codev: Coding Agent That Runs in Your Terminal
Codev CLI 是一个基于 agentica 库的 AI 编码助手,它提供了一个交互式终端界面,让您可以与 AI 助手进行对话,执行命令和编辑文件。
功能特点
- 💬 在终端直接交互的聊天界面
- 🚀 支持命令执行和文件编辑
- 📝 历史记录管理,包括命令和文件编辑历史
- 🔒 多种审批策略(suggest、auto-edit、full-auto)
- 🖼️ 支持图像输入(用于视觉模型)
- 🛠️ 支持MCP服务器和工具集成
安装
方式一:通过 pip 安装
pip install pycodev
方式二:从源码安装
# 克隆仓库
git clone https://github.com/shibing624/codev.git
cd codev
pip install -r requirements.txt
pip install -e .
设置 OpenAI API 密钥
export OPENAI_API_KEY=你的API密钥
export OPENAI_BASE_URL=你的API基础URL # https://api.openai.com/v1
您也可以在 ~/.agentica/.env 文件中设置这些环境变量。
使用方法
基本使用
codev
使用初始提示
codev --prompt "创建一个简单的 Python HTTP 服务器"
指定模型
codev --model gpt-4o --prompt "优化这段代码"
使用图像
codev --image path/to/image.png --prompt "解释这张图中的代码"
设置审批策略
# 建议模式(默认):AI 助手会请求您确认命令和文件编辑
codev --approval suggest
# 自动编辑模式:AI 助手可以自动编辑文件,但需要您确认命令
codev --approval auto-edit
# 完全自动模式:AI 助手可以自动执行命令和编辑文件,无需确认
codev --approval full-auto
使用配置文件
codev --config path/to/config.json
配置文件示例(config.json):
{
"model": "gpt-4o",
"instructions": "你是一个专注于 Python 开发的 AI 助手",
"theme": {
"user": "blue",
"assistant": "green",
"system": "yellow",
"error": "red",
"loading": "cyan"
}
}
命令行选项
| 参数 | 描述 |
|---|---|
--model, -m |
使用的模型(例如 gpt-4o, gpt-4-turbo) |
--prompt, -p |
初始提示发送给模型 |
--image, -i |
图像文件路径(可多次使用) |
--approval, -a |
命令审批策略(suggest, auto-edit, full-auto) |
--full-stdout, -f |
显示完整的命令输出 |
--config, -c |
配置文件路径 |
--version, -v |
显示版本信息 |
审批策略
suggest:AI 助手会建议命令和文件编辑,但需要您的批准auto-edit:AI 助手可以自动编辑文件,但需要您批准 shell 命令full-auto:AI 助手可以自动执行命令和编辑文件,无需批准
交互式命令
在交互式会话中,您可以使用以下命令:
/help- 显示帮助信息/model [model_name]- 查看或更改当前使用的模型/approval [policy]- 查看或更改当前的审批策略/history [all] [full]- 显示历史记录/clear- 清除当前会话/clearhistory [session]- 清除历史记录/compact- 将对话上下文压缩为摘要/exit或/quit- 退出程序
键盘快捷键
- Enter - 发送消息
- Ctrl+J - 插入换行符
- 上/下方向键 - 滚动浏览提示历史
- Esc(×2) - 中断当前操作
- Ctrl+C - 退出 Codev
使用 agentica 库
此版本的 Codev CLI 使用 agentica 库作为底层 AI 交互框架。agentica 是一个强大的框架,用于构建智能、具备反思能力、可协作的多模态 AI 代理。
更多关于 agentica 的信息,请访问:https://github.com/shibing624/agentica
联系我们
- 问题和建议:
- 邮件:xuming624@qq.com
- 微信:加我微信(ID:xuming624),备注:"姓名-公司-NLP"加入我们的NLP讨论群。
引用
如果你在研究中使用了codev,请按如下格式引用:
APA:
Xu, M. Codev: coding agent that runs in your terminal (Version 0.0.2) [Computer software]. https://github.com/shibing624/codev
BibTeX:
@misc{Xu_codev,
title={Codev: coding agent that runs in your terminal},
author={Xu Ming},
year={2025},
howpublished={\url{https://github.com/shibing624/codev}},
}
许可证
本项目采用Apache License 2.0授权协议,可免费用于商业用途。请在产品说明中附加codev的链接和授权协议。
贡献
我们欢迎对这个项目进行改进的贡献!在提交拉取请求之前,请:
- 在
tests目录中添加适当的单元测试 - 运行
python -m pytest确保所有测试通过 - 提交PR时附上清晰的更改描述
致谢
感谢他们的杰出工作!
Metadata
Release files for pycodev 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pycodev-0.1.1.tar.gz | 29.8 kB | Without provenance | Details for pycodev-0.1.1.tar.gz |
Release files / pycodev-0.1.1.tar.gz
| Download URL | pycodev-0.1.1.tar.gz |
|---|---|
| Size | 29.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2e43c935dbad72fe90a862e0ef96574bf61bec7d816f1f5f0b16e8239e69ee3
|
|
BLAKE2b-256 checksum How to use checksums |
b29bc93f18ffbbf0baf9bd3928b747232efd60292373645b289e906aa16c002e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|
Security for pycodev 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.