@nextcli/cli

中文文档
0.1.1发布于 2026/11/02Apache-2.0TypeScriptES Module零依赖构建来源已验证

NextCLI CLI

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. Headless Mode
  4. Session Management
  5. Command Line Options
  6. Environment Variables
  7. Commands
  8. Session Listing ( cn ls )
  9. TTY-less Support

NextCLI CLI

The NextCLI CLI (cn) is a customizable command line coding agent.

NextCLI CLI Demo

Installation

macOS / Linux:

curl -fsSL https://raw.githubusercontent.com/nextcli-dev/nextcli/main/extensions/cli/scripts/install.sh | bash

Windows (PowerShell):

irm https://raw.githubusercontent.com/nextcli-dev/nextcli/main/extensions/cli/scripts/install.ps1 | iex

Or install with npm if you have Node.js 20+:

npm i -g @nextcli/cli

Usage

cn

Headless Mode

Headless mode (-p flag) runs without an interactive terminal UI, making it perfect for:

  • Scripts and automation
  • CI/CD pipelines
  • Docker containers
  • VS Code extension integration
  • Environments without a 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-less Environments: Headless mode is designed to work in environments without a terminal (TTY), such as when called from the VS Code extension using terminal commands. The CLI will not attempt to read stdin or initialize the interactive UI when running in headless mode with a supplied prompt.

Command safety in headless mode: headless mode runs Bash commands without asking. Two kinds of command are still refused:

  • Commands that would destroy the system, a home directory or a disk (rm -rf /, rm -rf ~, find / -delete, wipefs -a) never run, in any mode.
  • Broad deletes (a top-level directory such as /tmp, a path the CLI can't resolve, such as rm -rf $DIR) need a person. The interactive CLI asks first; headless mode refuses them.

These checks read the command text, so they are best-effort: a command can always hide what it deletes. For untrusted prompts or repositories, run cn -p in a container or sandbox, and restrict Bash in ~/.continue/permissions.yaml.

Session Management

The CLI automatically saves your chat history for each terminal session. You can resume where you left off:

# 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

Command Line Options

  • -p: Run in headless mode (no TUI)
  • --config <path>: Specify agent configuration path
  • --resume: Resume the last session for this terminal
  • <prompt>: Optional prompt to start with

Environment Variables

  • CONTINUE_CLI_DISABLE_COMMIT_SIGNATURE: Disable adding the Continue commit signature to generated commit messages
  • FORCE_NO_TTY: Force TTY-less mode, prevents stdin reading (useful for testing and automation)

Commands

  • cn: Start an interactive chat session
  • cn ls: List recent sessions with TUI selector to choose one to resume
  • cn login: Authenticate with Continue
  • cn logout: Sign out of current session
  • cn remote: Launch a remote instance
  • cn serve: Start HTTP server mode

Session Listing (cn ls)

Shows recent sessions, limited by screen height to ensure it fits on your terminal.

  • --json: Output in JSON format for scripting (always shows 10 sessions)

TTY-less Support

The CLI fully supports running in environments without a TTY (terminal):

# 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 the VS Code extension terminal tool
cn -p "Analyze code" --silent

The CLI automatically detects TTY-less environments and adjusts its behavior:

  • Skips stdin reading when a prompt is supplied
  • Disables interactive UI components
  • Ensures clean stdout/stderr output

For more details, see spec/tty-less-support.md.

版本与发布记录

@nextcli/cli 共发布 3 个版本,首次发布于 2026/11/02;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.1.1latest2026/11/021 天前
0.1.02026/11/021 天前
0.0.0-stage2026/11/021 天前

关于 @nextcli/cli 的常见问题

@nextcli/cli 是什么?

NextCLI CLI

如何安装 @nextcli/cli?

在项目目录运行 npm install @nextcli/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 cn,可以用 npx cn 直接运行。

@nextcli/cli 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@nextcli/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@nextcli/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@nextcli/cli 可以商用吗?

@nextcli/cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@nextcli/cli 还在维护吗?

最新版本 0.1.1 发布于 2026/11/02(1 天前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/11/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。