命令行参数
本文档详细介绍了 Codely CLI 的所有命令行参数 和子命令的用法。
基本用法
codely [选项] [命令]
启动 Codely CLI 交互式界面,或使用 -p/--prompt 进入非交互模式。
全局选项
模型相关选项
| 参数 | 简写 | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
| --model | -m | string | 配置 / 环境变量 | 指定使用的主要模型 |
| --multimodal | - | string | CODELY_MULTIMODAL 环境变量 | 用于图像/视频分析的多模态模型 |
| --flash | - | string | CODELY_FLASH_MODEL 环境变量 | 用于内部操作的 Flash 模型(压缩、回退等,非日常聊天档位) |
示例:
codely --model qwen-max
codely --multimodal qwen-vl-max
codely --flash qwen-turbo
交互模式选项
| 参数 | 简写 | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
| --prompt | -p | string | - | 提供提示词(非交互模式)。如果同时提供 stdin 输入,会追加到输入后 |
| --prompt-interactive | -i | string | - | 执行提供的提示词后继续进入交互模式 |
注意: --prompt 和 --prompt-interactive 不能同时使用。
示例:
# 非交互模式,执行单个提示词
codely -p "帮我写一个 Python 函数"
# 执行提示词后进入交互模式
codely -i "初始化一个 React 项目"
文件和上下文选项
| 参数 | 简写 | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
| --all-files | -a | boolean | false | 将所有文件包含在上下文中 |
| --include-directories | - | array | - | 额外要包含在工作区中的目录(逗号分隔或多次使用该选项) |
已弃用: --all_files(请使用 --all-files)
示例:
# 包含所有文件
codely --all-files
# 包含额外目录
codely --include-directories /path/to/extra --include-directories /another/path
codely --include-directories /path1,/path2
协作模式与审批策略
会话行为由两个正交维度控制(桌面端心智见 模式):
| 参数 | 简写 | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
| --collaboration-mode | - | string | default | 协作模式(AI 能做什么): - default:全功能(读/写/Shell/工具)- plan:探索与写计划文件,限制改业务源码- ask:只读问答 |
| --approval-mode | - | string | default | 审批策略(操作如何批准): - default:CLI 专用,文件编辑与 Shell 等变更均需确认- auto_edit:文件编辑自动批准,Shell/Skill 等仍需确认(对应 GUI「请求授权」)- yolo:在协作模式允许范围内尽量自动批准(对应 GUI「全自动」) |
| --yolo | -y | boolean | false | --approval-mode yolo 的快捷写法 |
注意:
--yolo与--approval-mode不能同时使用。- GUI/ACP 对外审批值是
autoEdit/yolo;CLI 入参仍用auto_edit/yolo/default(snake_case)。 default审批值不会跨过 ACP 边界;Cowork 会话默认等价于协作default+ 审批auto_edit。
示例:
# 全自动审批(少打断)
codely --yolo
# 文件编辑自动批准,其他工具仍需确认
codely --approval-mode auto_edit
# 只读问答
codely --collaboration-mode ask
# 先规划再执行,并搭配自动审批
codely --collaboration-mode plan --approval-mode yolo
调试和日志选项
| 参数 | 简写 | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
| --debug | -d | boolean | false | 以调试模式运行 |
| --show-memory-usage | - | boolean | false | 在状态栏显示内存使用情况 |
已弃用: --show_memory_usage(请使用 --show-memory-usage)
示例:
codely --debug
codely --show-memory-usage
MCP 服务器选项
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| --allowed-mcp-server-names | array | - | 允许的 MCP 服务器名称列表 |
示例:
codely --allowed-mcp-server-names server1,server2
codely --allowed-mcp-server-names server1 --allowed-mcp-server-names server2
扩展选项
| 参数 | 简写 | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
| --extensions | -e | array | - | 要使用的扩展列表。如果未提供,则使用所有扩展 |
| --list-extensions | -l | boolean | false | 列出所有可用扩展并退出 |
示例:
# 只使用指定的扩展
codely --extensions github,jira
# 列出所有可用扩展
codely --list-extensions
沙箱选项 ** experimental **
| 参数 | 简写 | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
| --sandbox | -s | boolean | - | 在沙箱中运行 |
| --sandbox-image | - | string | - | 沙箱镜像 URI |
示例:
codely --sandbox
codely --sandbox-image my-sandbox-image:latest
功能开关
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| --checkpointing | -c | boolean | false |
| --experimental-acp | boolean | false | 在 ACP 模式下启动代理 |
| --agents | boolean | true | 启用或禁用代理系统 |
示例:
codely --checkpointing
codely --experimental-acp
codely --agents=false
网络和代理选项
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| --proxy | string | - | Gemini 客户端的代理,格式:schema://user:password@host:port |
示例:
codely --proxy http://user:pass@proxy.example.com:8080
codely --proxy socks5://127.0.0.1:1080
OpenAI 兼容性选项
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| --openai-logging | boolean | - | 启用 OpenAI API 调用的日志记录以进行调试和分析 |
| --openai-api-key | string | - | 用于身份验证的 OpenAI API 密钥 |
| --openai-base-url | string | - | OpenAI 基础 URL(用于自定义端点) |
| --reasoning_effort | string | - | OpenAI reasoning_effort 参数(minimal|low|medium|high) |
| --enable_thinking | boolean | - | OpenAI 兼容扩展:设置 chat_template_kwargs.enable_thinking |
别名: --reasoning_effort 可简写为 --reasoningEffort --enable_thinking 可简写为 --enableThinking
示例:
codely --openai-api-key sk-xxx --openai-base-url https://api.openai.com/v1
codely --reasoning_effort high --enable_thinking
Web 搜索选项
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| --tavily-api-key | string | - | Tavily API 密钥,用于 Web 搜索功能 |
| --searxng-url | string | - | SearXNG 实例 URL,用于 Web 搜索 |
示例 :
codely --tavily-api-key tvly-xxx
codely --searxng-url https://searx.example.com
示例提示词和工具选项
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| --example-prompt | string | - | 从 example-prompts 文件夹加载并执行示例提示词(仅非交互模式) |
| --list-example-prompts | boolean | false | 列出所有可用的示例提示词 |
| --list-tools | boolean | false | 列出所有可用的内置工具 |
| --exclude-tools | array | - | 为此会话排除特定工具(不修改设置) |
注意: --example-prompt 不能与 --prompt 或 --prompt-interactive 同时使用。
示例:
# 列出所有示例提示词
codely --list-example-prompts
# 使用示例提示词
codely --example-prompt my-prompt
# 列出所有工具
codely --list-tools
# 排除特定工具
codely --exclude-tools shell,edit
输出格式选项
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| --output-format | string | text | 响应的输出格式(text|json|stream-json) |
示例:
codely --output-format json
codely --output-format stream-json
通用选项
| 参数 | 简写 | 描述 |
|---|---|---|
| --version | -v | 显示版本号并退出 |
| --help | -h | 显示帮助信息 |
子命令
mcp 命令
管理 MCP 服务器,以扩展 Tuanjie AI 的功能和外部工具及服务。
mcp add
添加新的 MCP 服务器。
codely mcp add <name> <commandOrUrl> [args...] [选项]
选项:
| 参数 | 简写 | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
| --scope | -s | string | project | 配置范围(user 或 project) |
| --transport | -t | string | stdio | 传输类型(stdio|sse|http) |
| --env | -e | array | - | 设置环境变量(如 -e KEY=value) |
| --header | -H | array | - | 为 SSE 和 HTTP 传输设置 HTTP 头 |
| --timeout | - | number | - | 设置连接超时(毫秒) |
| --trust | - | boolean | - | 信任服务器(绕过所有工具调用确认提示) |
| --description | - | string | - | 设置服务器的描述 |
| --include-tools | - | array | - | 要包含的工具列表(逗号分隔) |
| --exclude-tools | - | array | - | 要排除的工具列表(逗号分隔) |
示例:
# 添加 stdio 服务器
codely mcp add my-server python /path/to/server.py --env API_KEY=abc123 --env DEBUG=true
# 添加 HTTP 服务器
codely mcp add my-http-server http://localhost:8000 --transport http --header "Authorization: Bearer token"
# 添加带有工具过滤的服务器
codely mcp add my-server python /path/to/server.py --include-tools tool1,tool2 --exclude-tools dangerous-tool
# 添加用户级配置
codely mcp add my-server python /path/to/server.py --scope user --description "我的个人工具服务器"
# 添加受信任的远程 HTTP 服务器
codely mcp add secure-server https://api.example.com/mcp --transport http --header "X-API-Key: abc123xyz" --trust
mcp remove
移除指定的 MCP 服务器。
codely mcp remove <name> [选项]
选项:
| 参数 | 简写 | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
| --scope | -s | string | project | 配置范围(user 或 project) |
示例:
# 移除项目级服务器
codely mcp remove my-server
# 移除用户级服务器
codely mcp remove my-server --scope user
mcp list
列出所有已配置的 MCP 服务器及其连接状态。
codely mcp list
输出示例:
✓ my-server: python /path/to/server.py (stdio) - Connected
✗ http-server: http://localhost:8000 (http) - Disconnected
extensions 命令
管理 Codely CLI 扩展。完全兼容 https://geminicli.com/extensions/
extensions install
从 git 仓库 URL 或本地路径安装扩展。
codely extensions install <source> [选项]
位置参数:
| 参数 | 描述 |
|---|---|
| source | GitHub URL(如 https://github.com/owner/repo 或 owner/repo)、git URL 或扩展的本地路径 |
选项:
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| --ref | string | - | 要安装的 git 引用 |
| --auto-update | boolean | - | 为此扩展启用自动更新 |
| --pre-release | boolean | - | 为此扩展启用预发布版本 |
| --consent | boolean | false | 确认安装扩展的安全风险并跳过确认提示 |
示例:
# 从 GitHub 安装(完整 URL)
codely extensions install https://github.com/owner/repo
# 从 GitHub 安装(简写)
codely extensions install owner/repo
# 指定分支或标签
codely extensions install https://github.com/owner/repo --ref main
# 启用自动更新
codely extensions install https://github.com/owner/repo --auto-update
# 安装预发布版本
codely extensions install https://github.com/owner/repo --pre-release
# 从本地路径安装
codely extensions install /path/to/local/extension
# 跳过确认提示
codely extensions install https://github.com/owner/repo --consent