Skip to content

CLI 命令参考

SII CLI 完整命令行参考文档。

概述

SII CLI 为 AI 辅助软件开发和研究提供了强大的命令行界面。本参考文档涵盖所有可用命令、选项和使用模式。

基本用法

交互模式

启动交互式会话:

bash
sii

非交互模式

执行单个提示后退出:

bash
sii -p "解释这个代码库"

执行提示后继续交互模式:

bash
sii -i "分析项目结构"

管道输入

处理管道内容:

bash
cat file.txt | sii -p "总结这段内容"

全局选项

模型选择

-m, --model <模型>

指定要使用的 AI 模型。

bash
sii --model gpt-4o
sii -m claude-sonnet-4

默认值: limi-1029 (或环境配置中的值)

提示选项

-p, --prompt <文本>

在非交互模式下执行提示。如果提供了 stdin 输入,会附加到输入后面。

bash
sii -p "什么是 Docker?"

-i, --prompt-interactive <文本>

执行提示后继续交互模式。

bash
sii -i "分析这个项目"

--prompt-file <路径>

仅在本次会话使用自定义系统提示文件。

bash
sii --prompt-file ./custom-prompt.md

--prompt-inline <文本>

提供内联 Markdown 内容作为系统提示。

bash
sii --prompt-inline "你是一个 Python 专家。专注于最佳实践。"

远程连接

-R, --remote <句柄>

连接到远程 SII WebSocket 会话(推荐方法)。

bash
sii --remote my-session-handle

--connect-session-id <ID>

通过 ID 连接到 SII WebSocket 会话(非交互式流式传输)。

bash
sii --connect-session-id abc123

--connect-client-id <ID>

指定 WebSocket 连接的客户端 ID(默认为 cli-<随机>).

bash
sii --connect-client-id my-client

沙箱选项

-s, --sandbox

在沙箱模式下运行以实现隔离执行。

bash
sii --sandbox

--sandbox-image <URI>

指定自定义沙箱 Docker 镜像。

bash
sii --sandbox-image ghcr.io/GAIR-NLP/sii-cli:latest

调试和开发

-d, --debug

启用调试模式,输出详细日志。

bash
sii --debug

--openai-logging

启用 OpenAI API 调用日志记录以进行调试。

bash
sii --openai-logging

文件上下文

-a, --all-files

在上下文中包含所有文件(绕过 .gitignore)。

bash
sii --all-files

--show-memory-usage

在状态栏显示内存使用情况。

bash
sii --show-memory-usage

批准模式

-y, --yolo

自动接受所有操作而不提示(YOLO 模式)。

bash
sii --yolo

⚠️ 警告: 谨慎使用,因为这会绕过所有安全提示。

遥测选项

--telemetry

启用遥测数据收集。

bash
sii --telemetry

--telemetry-target <目标>

设置遥测目标: localgcp

bash
sii --telemetry-target local

--telemetry-otlp-endpoint <URL>

设置遥测的自定义 OTLP 端点。

bash
sii --telemetry-otlp-endpoint http://localhost:4318

--telemetry-log-prompts

在遥测中启用用户提示的日志记录。

bash
sii --telemetry-log-prompts

--telemetry-outfile <路径>

将遥测输出重定向到文件。

bash
sii --telemetry-outfile ./telemetry.log

高级选项

-c, --checkpointing

启用文件编辑的检查点功能。

bash
sii --checkpointing

--experimental-acp

在 ACP(代理通信协议)模式下启动代理。

bash
sii --experimental-acp

--allowed-mcp-server-names <名称...>

指定允许的 MCP 服务器名称。

bash
sii --allowed-mcp-server-names server1 server2

-e, --extensions <名称...>

指定要使用的扩展(如果未提供,则使用所有扩展)。

bash
sii --extensions ext1 ext2

-l, --list-extensions

列出所有可用扩展并退出。

bash
sii --list-extensions

--ide-mode

在 IDE 模式下运行。

bash
sii --ide-mode

身份验证

--openai-api-key <密钥>

提供 OpenAI API 密钥进行身份验证。

bash
sii --openai-api-key sk-...

--openai-base-url <URL>

设置自定义 OpenAI 兼容 API 端点。

bash
sii --openai-base-url https://api.openai.com/v1

--token <令牌>

使用 SII 访问令牌而不是用户名/密码。

bash
sii --token your-access-token

网络

--proxy <URL>

为 API 客户端设置代理。

bash
sii --proxy http://user:password@proxy.example.com:8080

自动合成模式

--auto-synthesize <路径>

启用自动合成模式,使用包含 PR 数据的 JSON 文件或目录。

bash
sii --auto-synthesize ./pr-data.json

--synthesize-workspace <路径>

设置克隆仓库的工作区目录。

bash
sii --synthesize-workspace ./workspace

默认值: ./synthesis-workspace

--synthesize-max-turns <数字>

合成迭代的最大轮数。

bash
sii --synthesize-max-turns 5

默认值: 3

--synthesize-username <用户名>

覆盖合成身份验证的 SII 用户名。

bash
sii --synthesize-username myuser

--synthesize-password <密码>

覆盖合成身份验证的 SII 密码。

bash
sii --synthesize-password mypass

--synthesize-api-url <URL>

覆盖合成的 SII API URL。

bash
sii --synthesize-api-url https://api.opensii.ai

--synthesize-judge-model <模型>

覆盖合成评估的评判模型。

bash
sii --synthesize-judge-model gpt-4o

--synthesize-judge-temperature <数字>

设置评判评估温度(0-1)。

bash
sii --synthesize-judge-temperature 0.2

默认值: 0.1

--synthesize-judge-system-prompt <路径>

自定义评判系统提示文件的路径。

bash
sii --synthesize-judge-system-prompt ./judge-prompt.md

--synthesize-git-timeout-minutes <数字>

Git 操作超时时间(分钟)(-1 表示禁用)。

bash
sii --synthesize-git-timeout-minutes 60

默认值: 30

--synthesize-execution-timeout-minutes <数字>

模型执行超时时间(分钟)(-1 表示禁用)。

bash
sii --synthesize-execution-timeout-minutes 60

默认值: 30

版本和帮助

-v, --version

显示版本号。

bash
sii --version

-h, --help

显示帮助信息。

bash
sii --help

子命令

SDD (规范驱动开发)

SII CLI 原生支持规范驱动开发工作流。

sii sdd specify [描述...]

创建新的功能规范和分支。

bash
sii sdd specify 添加 OAuth 登录流程

选项:

  • --json - 仅输出 JSON(默认: true)

输出:

json
{
  "BRANCH_NAME": "001-add-oauth-login",
  "SPEC_FILE": "/path/to/specs/001-add-oauth-login/spec.md",
  "FEATURE_NUM": "1"
}

sii sdd plan

生成实施计划并强制执行澄清门控。

bash
sii sdd plan

选项:

  • --no-strict - 绕过澄清门控(仅警告)
  • --json - 仅输出 JSON(默认: true)

输出:

json
{
  "FEATURE_SPEC": "/path/to/spec.md",
  "IMPL_PLAN": "/path/to/plan.md",
  "SPECS_DIR": "/path/to/specs",
  "BRANCH": "001-add-oauth-login",
  "HAS_GIT": "true"
}

sii sdd tasks

扫描功能目录并列出可用文档。

bash
sii sdd tasks

选项:

  • --json - 仅输出 JSON(默认: true)

输出:

json
{
  "FEATURE_DIR": "/path/to/001-add-oauth-login",
  "AVAILABLE_DOCS": [
    "/path/to/spec.md",
    "/path/to/plan.md",
    "/path/to/contracts/api.yaml"
  ]
}

sii sdd implement

扫描实施的先决条件(默认需要 tasks.md)。

bash
sii sdd implement

选项:

  • --no-strict - 绕过 tasks.md 要求(仅警告)
  • --json - 仅输出 JSON(默认: true)

输出:

json
{
  "FEATURE_DIR": "/path/to/001-add-oauth-login",
  "AVAILABLE_DOCS": [...]
}

sii sdd init

初始化 SDD 结构,包括模板和目录。

bash
sii sdd init

选项:

  • --force - 覆盖现有模板文件
  • --with-commands - 同时创建 .sii/commands/* markdown 辅助文件
  • --json - 仅输出 JSON(默认: true)

输出:

json
{
  "TEMPLATES_DIR": "/path/to/.specify/templates",
  "SPECS_DIR": "/path/to/specs",
  "COMMANDS_DIR": "/path/to/.sii/commands"
}

提示管理

管理系统提示以自定义 SII CLI 行为。

sii prompts show

显示当前活动的系统提示。

bash
sii prompts show

选项:

  • --raw - 显示原始 Markdown 内容
  • --resolved - 显示带占位符的解析提示(默认: true)
  • --file <路径> - 使用特定提示文件预览
  • --inline <文本> - 使用内联 Markdown 内容预览

示例:

bash
sii prompts show --raw
sii prompts show --file ./custom-prompt.md

sii prompts edit

$EDITOR 中打开配置的提示文件。

bash
sii prompts edit

选项:

  • --file <路径> - 编辑特定提示文件
  • --scope <范围> - 要更新的设置范围: userworkspacesystem

示例:

bash
sii prompts edit --file ./my-prompt.md --scope workspace

sii prompts set

更新设置以使用提示文件或内联内容。

bash
sii prompts set --file ./my-prompt.md

选项:

  • --file <路径> - 包含系统提示的 Markdown 文件路径
  • --inline <文本> - 系统提示的内联 Markdown 内容
  • --append-template - 使用 --inline 时附加默认模板
  • --scope <范围> - 设置范围: userworkspacesystem

示例:

bash
sii prompts set --inline "你是一个 Python 专家" --append-template
sii prompts set --file ./prompt.md --scope user

sii prompts reload

重新加载提示设置并清除缓存。

bash
sii prompts reload

命令管理

管理 SII CLI 的自定义斜杠命令。

sii commands init

初始化命令目录并创建 README。

bash
sii commands init

选项:

  • --global - 在全局用户目录(~/.sii/commands)中初始化

示例:

bash
sii commands init
sii commands init --global

sii commands create <名称>

创建新的命令文件。

bash
sii commands create mycommand

选项:

  • --global - 在全局用户目录中创建
  • --format <格式> - 文件格式: mdyamltoml(默认: md)
  • --force - 覆盖现有文件

示例:

bash
sii commands create review --format toml
sii commands create deploy --global --format yaml

sii commands list

列出所有可用命令。

bash
sii commands list

选项:

  • --global - 仅列出全局命令

示例:

bash
sii commands list
sii commands list --global

交互式会话命令

这些命令在交互式 SII CLI 会话中可用(使用 sii 启动)。

会话管理

  • /help - 显示可用命令
  • /new - 开始新的对话会话
  • /clear - 清除屏幕并开始新会话(与 /new 相同)
  • /compress - 压缩对话历史以节省令牌
  • /status - 显示当前会话信息和令牌使用情况
  • /exit/quit - 退出 SII CLI

SDD 工作流命令

使用自定义命令(.sii/commands/*.toml)时,这些斜杠命令可用:

  • /specify <描述> - 创建功能规范(调用 sii sdd specify)
  • /plan - 生成实施计划(调用 sii sdd plan)
  • /tasks - 扫描可用文档(调用 sii sdd tasks)
  • /implement - 最终实施扫描(调用 sii sdd implement)

自定义命令

自定义命令可以定义在:

  • 项目: ./.sii/commands/*.{md,yaml,toml}
  • 全局: ~/.sii/commands/*.{md,yaml,toml}

使用方式: /<命令名称> [参数]

环境变量

SII CLI 遵循以下环境变量:

身份验证

  • SII_OPENAI_API_KEY - OpenAI 兼容 API 密钥
  • SII_OPENAI_BASE_URL - OpenAI 兼容 API 端点
  • SII_OPENAI_MODEL - 要使用的默认模型
  • SII_USERNAME - SII 账户用户名
  • SII_PASSWORD - SII 账户密码
  • SII_BASE_URL - SII API 基础 URL(默认: https://www.opensii.ai/backend)

旧版变量(自动迁移)

  • OPENAI_API_KEY - 旧版 API 密钥(提示迁移到 SII_OPENAI_API_KEY)
  • OPENAI_BASE_URL - 旧版基础 URL(提示迁移到 SII_OPENAI_BASE_URL)
  • OPENAI_MODEL - 旧版模型(提示迁移到 SII_OPENAI_MODEL)

SDD 工作流

  • SPECIFY_FEATURE - 覆盖功能目录/分支检测

编辑器

  • EDITOR - sii prompts edit 的默认编辑器(默认: vi)

配置文件

设置文件

SII CLI 使用分层设置系统:

  1. 系统: /etc/sii/settings.json(Linux/macOS)或 %PROGRAMDATA%\sii\settings.json(Windows)
  2. 用户: ~/.sii/settings.json
  3. 工作区: ./.sii/settings.json

设置按工作区 > 用户 > 系统的优先级合并。

项目环境

  • .env - 项目特定的环境变量
  • .sii/config.json - 项目配置
  • .sii/commands/ - 自定义斜杠命令
  • .specify/templates/ - 自定义 SDD 模板(覆盖 ./templates/)

全局配置

  • ~/.sii/config.json - 用户配置
  • ~/.sii/commands/ - 全局自定义命令
  • ~/.sii/prompts/ - 用户提示文件

退出代码

  • 0 - 成功
  • 1 - 一般错误
  • 2 - 无效参数
  • 130 - 用户中断(Ctrl+C)

示例

基本用法

bash
# 启动交互式会话
sii

# 执行单个提示
sii -p "解释这个函数"

# 继续之前的对话
sii -c

# 使用自定义模型
sii --model gpt-4o

# 调试模式
sii --debug

SDD 工作流

bash
# 初始化 SDD 结构
sii sdd init --with-commands

# 创建功能规范
sii sdd specify 添加用户认证

# 生成计划
sii sdd plan

# 扫描文档
sii sdd tasks

# 实施
sii sdd implement

自定义提示

bash
# 显示当前提示
sii prompts show

# 编辑提示
sii prompts edit

# 设置自定义提示
sii prompts set --file ./my-prompt.md

# 使用内联提示
sii prompts set --inline "你是一个安全专家"

自定义命令

bash
# 创建命令
sii commands create review --format toml

# 列出命令
sii commands list

# 在会话中使用
sii
> /review 检查安全问题

远程会话

bash
# 连接到远程会话
sii --remote my-session

# 通过会话 ID 连接
sii --connect-session-id abc123

沙箱模式

bash
# 在沙箱中运行
sii --sandbox

# 自定义沙箱镜像
sii --sandbox --sandbox-image custom-image:latest

另请参阅

Released under the MIT License.