继续CLI
CLI 继续cn)是一个自定义的命令行编码代理.

安装
macOS / Linux :
curl -fsSL https://raw.githubusercontent.com/continuedev/continue/main/extensions/cli/scripts/install.sh | bash
视窗( PowerShell ) :
irm https://raw.githubusercontent.com/continuedev/continue/main/extensions/cli/scripts/install.ps1 | iex
或安装 npm,如果您有节点.js 20+:
npm i -g @continuedev/cli
使用量
cn
无头模式
无头模式( E)-p flag)运行时没有交互终端UI,使其完美地用于:
- 脚本和自动化
- CI/CD管道
- 挂载容器
- VSCode/ IntelliJ 扩展集成
- 无 TTY 环境
# Basic usage
cn -p "Generate a conventional commit name for the current git changes."
# With piped input
echo "Review this code" | cn -p
# JSON output for scripting
cn -p "Analyze the code" --format json
# Silent mode (strips thinking tags)
cn -p "Write a README" --silent
无 TTY 环境:无头模式被设计为在没有终端(TTY)的环境中工作,例如当从VSCode/IntelliJ扩展中调用终端命令时. CLI 在无头模式下运行时不会尝试读取stdin或初始化交互式UI,同时提供快取.
会话管理
CLI 为每个终端会话自动保存您的聊天历史 。 你可以继续你离开的地方:
# Resume the last session in this terminal
cn --resume
# List recent sessions and choose one to resume
cn ls
# List sessions in JSON format (for scripting)
cn ls --json
命令行选项
-p: 无头模式运行( 无 TUI)--config <path>: 指定代理配置路径--resume: 恢复此终端的最后会话<prompt>: 可选的启动提示
环境变量
CONTINUE_CLI_DISABLE_COMMIT_SIGNATURE: 禁用在生成的承诺信件中添加继续承诺签名FORCE_NO_TTY: 强制 TTY 模式, 防止 stdin 读取( 可用于测试和自动化)
图标
cn: 启动交互式聊天会话cn ls: 列出与 TUI 选择器一起选择要恢复的最近会话cn login: 继续认证cn logout: 在当前会话中签名cn remote: 启动远程实例cn serve: 启动 HTTP 服务器模式
会话列表cn ls(中文(简体) )
显示最近的会话, 受屏幕高度限制, 以确保它适合您的终端 .
--json: 用于脚本的 JSON 格式输出( 总是显示10会话)
无 TTY 支持
CLI 完全支持在无 TTY (tterminal) 的环境中运行 :
# From Docker without TTY allocation
docker run --rm my-image cn -p "Generate docs"
# From CI/CD pipeline
cn -p "Review changes" --format json
# From VSCode/IntelliJ extension terminal tool
cn -p "Analyze code" --silent
CLI自动检测到TTY无环境并调整其行为:
- 提供提示时跳过 stdin 读取
- 禁用交互式 UI 组件
- 确保清洁 stdout/ stderr 输出
详情见 spec/tty-less-support.md。 。 。 .