一个受 Claude Code、Gemini CLI 和 Droid 启发的 AI 驱动命令行编程工具。
- 主要界面:命令行交互式聊天
- 后端:Golang + Cobra CLI 框架
- Web 界面(可选):Next.js + WebSocket 支持
- 通信:WebSocket 用于可选的 Web 可视化
codex/
├── backend/
│ ├── cmd/codex/ # CLI 入口点
│ ├── internal/
│ │ ├── cli/ # CLI 命令(chat、serve、config 等)
│ │ ├── config/ # 配置管理
│ │ ├── session/ # 会话管理
│ │ ├── agent/ # AI 代理逻辑
│ │ ├── tools/ # 代码工具(文件操作、执行等)
│ │ ├── server/ # 可选的 WebSocket 服务器
│ │ └── ws/ # WebSocket 处理器
│ └── go.mod
├── frontend/ # 可选的 Web 界面
├── docs/ # 文档
└── ~/codex/ # 用户配置目录
├── config.json # 配置文件
└── sessions/ # 会话数据
# 克隆仓库
git clone <your-repo-url>
cd codex
# 安装依赖
make install
# 构建 CLI 二进制文件
make build
# 二进制文件将位于 backend/bin/codex详细设置和使用请参阅 docs/快速开始.md。
# 启动交互式聊天
make chat
# 或直接运行
cd backend && go run cmd/codex/main.go chat
# 使用特定模型
go run cmd/codex/main.go chat -m gpt-4
# 同时启用 Web 界面
go run cmd/codex/main.go chat --web启动 WebSocket 服务器和 Web 界面:
# 同时启动服务器和 Web 界面
make dev
# 或分别启动:
make serve # WebSocket 服务器运行在 :8080
make web # Web 界面运行在 :3000codex chat # 启动交互式聊天(主界面)
codex serve # 启动 WebSocket 服务器用于 Web 界面
codex serve -p 3000 # 在自定义端口启动
codex config show # 显示当前配置
codex config init # 初始化配置
codex config set # 设置配置值
codex config validate # 验证配置
codex version # 显示版本
codex help # 显示帮助Codex 将其配置存储在 ~/codex/config.json(JSON 格式)。配置包括:
- AI 设置:模型选择、API 密钥、参数(temperature、最大 token 等)
- 服务器设置:主机、端口、CORS 配置
- 会话设置:数据目录、自动保存间隔
- 工具设置:启用/禁用的工具和类别、执行超时
- 通用设置:语言、日志级别、彩色输出
# 查看当前配置
codex config show
# 使用默认值初始化(创建 ~/codex/config.json)
codex config init
# 获取配置文件路径
codex config path
# 验证配置
codex config validate
# 设置配置值
codex config set ai.model gpt-4-turbo
codex config set server.port 9000
codex config set general.log_level debug{
"ai": {
"default_model": "gpt-4",
"api_keys": {
"openai": "sk-...",
"anthropic": "sk-ant-..."
},
"max_tokens": 2048,
"temperature": 0.7
},
"server": {
"host": "localhost",
"port": 8080
},
"tools": {
"enabled_categories": ["file", "git", "docker", "kubernetes"],
"execution_timeout": 300
}
}详细配置文档请参阅 docs/配置模块.md。
- ✅ 交互式 CLI 聊天界面
- ✅ 配置管理:基于 JSON 的配置存储在
~/codex/config.json - ✅ 会话管理
- ✅ WebSocket 服务器用于 Web 界面
- ✅ 彩色终端输出
- ✅ 54 个内置工具分布在 6 个类别:
- 文件操作(18 个工具):读取、写入、复制、移动、删除、搜索、批量操作
- 系统信息(4 个工具):时间戳、语言、时区、平台信息
- 命令执行(1 个工具):Shell 命令执行
- Git 操作(8 个工具):状态、差异、日志、分支、添加、提交、显示、远程
- Docker 操作(10 个工具):ps、镜像、日志、检查、执行、启动/停止/重启、统计、版本
- Kubernetes 操作(13 个工具):获取 pods/services/deployments/nodes/namespaces、描述、日志、执行、应用、删除、扩展、事件、配置
详细工具文档请参阅 docs/工具说明.md。
- AI 模型集成(Claude、GPT、Gemini)
- 上下文管理
- 多轮对话
- 代码生成和编辑
- 项目感知