CLI 命令参考
SII CLI 完整命令行参考文档。
概述
SII CLI 为 AI 辅助软件开发和研究提供了强大的命令行界面。本参考文档涵盖所有可用命令、选项和使用模式。
基本用法
交互模式
启动交互式会话:
sii非交互模式
执行单个提示后退出:
sii -p "解释这个代码库"执行提示后继续交互模式:
sii -i "分析项目结构"管道输入
处理管道内容:
cat file.txt | sii -p "总结这段内容"全局选项
模型选择
-m, --model <模型>
指定要使用的 AI 模型。
sii --model gpt-4o
sii -m claude-sonnet-4默认值: limi-1029 (或环境配置中的值)
提示选项
-p, --prompt <文本>
在非交互模式下执行提示。如果提供了 stdin 输入,会附加到输入后面。
sii -p "什么是 Docker?"-i, --prompt-interactive <文本>
执行提示后继续交互模式。
sii -i "分析这个项目"--prompt-file <路径>
仅在本次会话使用自定义系统提示文件。
sii --prompt-file ./custom-prompt.md--prompt-inline <文本>
提供内联 Markdown 内容作为系统提示。
sii --prompt-inline "你是一个 Python 专家。专注于最佳实践。"远程连接
-R, --remote <句柄>
连接到远程 SII WebSocket 会话(推荐方法)。
sii --remote my-session-handle--connect-session-id <ID>
通过 ID 连接到 SII WebSocket 会话(非交互式流式传输)。
sii --connect-session-id abc123--connect-client-id <ID>
指定 WebSocket 连接的客户端 ID(默认为 cli-<随机>).
sii --connect-client-id my-client沙箱选项
-s, --sandbox
在沙箱模式下运行以实现隔离执行。
sii --sandbox--sandbox-image <URI>
指定自定义沙箱 Docker 镜像。
sii --sandbox-image ghcr.io/GAIR-NLP/sii-cli:latest调试和开发
-d, --debug
启用调试模式,输出详细日志。
sii --debug--openai-logging
启用 OpenAI API 调用日志记录以进行调试。
sii --openai-logging文件上下文
-a, --all-files
在上下文中包含所有文件(绕过 .gitignore)。
sii --all-files--show-memory-usage
在状态栏显示内存使用情况。
sii --show-memory-usage批准模式
-y, --yolo
自动接受所有操作而不提示(YOLO 模式)。
sii --yolo⚠️ 警告: 谨慎使用,因为这会绕过所有安全提示。
遥测选项
--telemetry
启用遥测数据收集。
sii --telemetry--telemetry-target <目标>
设置遥测目标: local 或 gcp。
sii --telemetry-target local--telemetry-otlp-endpoint <URL>
设置遥测的自定义 OTLP 端点。
sii --telemetry-otlp-endpoint http://localhost:4318--telemetry-log-prompts
在遥测中启用用户提示的日志记录。
sii --telemetry-log-prompts--telemetry-outfile <路径>
将遥测输出重定向到文件。
sii --telemetry-outfile ./telemetry.log高级选项
-c, --checkpointing
启用文件编辑的检查点功能。
sii --checkpointing--experimental-acp
在 ACP(代理通信协议)模式下启动代理。
sii --experimental-acp--allowed-mcp-server-names <名称...>
指定允许的 MCP 服务器名称。
sii --allowed-mcp-server-names server1 server2-e, --extensions <名称...>
指定要使用的扩展(如果未提供,则使用所有扩展)。
sii --extensions ext1 ext2-l, --list-extensions
列出所有可用扩展并退出。
sii --list-extensions--ide-mode
在 IDE 模式下运行。
sii --ide-mode身份验证
--openai-api-key <密钥>
提供 OpenAI API 密钥进行身份验证。
sii --openai-api-key sk-...--openai-base-url <URL>
设置自定义 OpenAI 兼容 API 端点。
sii --openai-base-url https://api.openai.com/v1--token <令牌>
使用 SII 访问令牌而不是用户名/密码。
sii --token your-access-token网络
--proxy <URL>
为 API 客户端设置代理。
sii --proxy http://user:password@proxy.example.com:8080自动合成模式
--auto-synthesize <路径>
启用自动合成模式,使用包含 PR 数据的 JSON 文件或目录。
sii --auto-synthesize ./pr-data.json--synthesize-workspace <路径>
设置克隆仓库的工作区目录。
sii --synthesize-workspace ./workspace默认值: ./synthesis-workspace
--synthesize-max-turns <数字>
合成迭代的最大轮数。
sii --synthesize-max-turns 5默认值: 3
--synthesize-username <用户名>
覆盖合成身份验证的 SII 用户名。
sii --synthesize-username myuser--synthesize-password <密码>
覆盖合成身份验证的 SII 密码。
sii --synthesize-password mypass--synthesize-api-url <URL>
覆盖合成的 SII API URL。
sii --synthesize-api-url https://api.opensii.ai--synthesize-judge-model <模型>
覆盖合成评估的评判模型。
sii --synthesize-judge-model gpt-4o--synthesize-judge-temperature <数字>
设置评判评估温度(0-1)。
sii --synthesize-judge-temperature 0.2默认值: 0.1
--synthesize-judge-system-prompt <路径>
自定义评判系统提示文件的路径。
sii --synthesize-judge-system-prompt ./judge-prompt.md--synthesize-git-timeout-minutes <数字>
Git 操作超时时间(分钟)(-1 表示禁用)。
sii --synthesize-git-timeout-minutes 60默认值: 30
--synthesize-execution-timeout-minutes <数字>
模型执行超时时间(分钟)(-1 表示禁用)。
sii --synthesize-execution-timeout-minutes 60默认值: 30
版本和帮助
-v, --version
显示版本号。
sii --version-h, --help
显示帮助信息。
sii --help子命令
SDD (规范驱动开发)
SII CLI 原生支持规范驱动开发工作流。
sii sdd specify [描述...]
创建新的功能规范和分支。
sii sdd specify 添加 OAuth 登录流程选项:
--json- 仅输出 JSON(默认: true)
输出:
{
"BRANCH_NAME": "001-add-oauth-login",
"SPEC_FILE": "/path/to/specs/001-add-oauth-login/spec.md",
"FEATURE_NUM": "1"
}sii sdd plan
生成实施计划并强制执行澄清门控。
sii sdd plan选项:
--no-strict- 绕过澄清门控(仅警告)--json- 仅输出 JSON(默认: true)
输出:
{
"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
扫描功能目录并列出可用文档。
sii sdd tasks选项:
--json- 仅输出 JSON(默认: true)
输出:
{
"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)。
sii sdd implement选项:
--no-strict- 绕过 tasks.md 要求(仅警告)--json- 仅输出 JSON(默认: true)
输出:
{
"FEATURE_DIR": "/path/to/001-add-oauth-login",
"AVAILABLE_DOCS": [...]
}sii sdd init
初始化 SDD 结构,包括模板和目录。
sii sdd init选项:
--force- 覆盖现有模板文件--with-commands- 同时创建.sii/commands/*markdown 辅助文件--json- 仅输出 JSON(默认: true)
输出:
{
"TEMPLATES_DIR": "/path/to/.specify/templates",
"SPECS_DIR": "/path/to/specs",
"COMMANDS_DIR": "/path/to/.sii/commands"
}提示管理
管理系统提示以自定义 SII CLI 行为。
sii prompts show
显示当前活动的系统提示。
sii prompts show选项:
--raw- 显示原始 Markdown 内容--resolved- 显示带占位符的解析提示(默认: true)--file <路径>- 使用特定提示文件预览--inline <文本>- 使用内联 Markdown 内容预览
示例:
sii prompts show --raw
sii prompts show --file ./custom-prompt.mdsii prompts edit
在 $EDITOR 中打开配置的提示文件。
sii prompts edit选项:
--file <路径>- 编辑特定提示文件--scope <范围>- 要更新的设置范围:user、workspace或system
示例:
sii prompts edit --file ./my-prompt.md --scope workspacesii prompts set
更新设置以使用提示文件或内联内容。
sii prompts set --file ./my-prompt.md选项:
--file <路径>- 包含系统提示的 Markdown 文件路径--inline <文本>- 系统提示的内联 Markdown 内容--append-template- 使用--inline时附加默认模板--scope <范围>- 设置范围:user、workspace或system
示例:
sii prompts set --inline "你是一个 Python 专家" --append-template
sii prompts set --file ./prompt.md --scope usersii prompts reload
重新加载提示设置并清除缓存。
sii prompts reload命令管理
管理 SII CLI 的自定义斜杠命令。
sii commands init
初始化命令目录并创建 README。
sii commands init选项:
--global- 在全局用户目录(~/.sii/commands)中初始化
示例:
sii commands init
sii commands init --globalsii commands create <名称>
创建新的命令文件。
sii commands create mycommand选项:
--global- 在全局用户目录中创建--format <格式>- 文件格式:md、yaml或toml(默认:md)--force- 覆盖现有文件
示例:
sii commands create review --format toml
sii commands create deploy --global --format yamlsii commands list
列出所有可用命令。
sii commands list选项:
--global- 仅列出全局命令
示例:
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 使用分层设置系统:
- 系统:
/etc/sii/settings.json(Linux/macOS)或%PROGRAMDATA%\sii\settings.json(Windows) - 用户:
~/.sii/settings.json - 工作区:
./.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)
示例
基本用法
# 启动交互式会话
sii
# 执行单个提示
sii -p "解释这个函数"
# 继续之前的对话
sii -c
# 使用自定义模型
sii --model gpt-4o
# 调试模式
sii --debugSDD 工作流
# 初始化 SDD 结构
sii sdd init --with-commands
# 创建功能规范
sii sdd specify 添加用户认证
# 生成计划
sii sdd plan
# 扫描文档
sii sdd tasks
# 实施
sii sdd implement自定义提示
# 显示当前提示
sii prompts show
# 编辑提示
sii prompts edit
# 设置自定义提示
sii prompts set --file ./my-prompt.md
# 使用内联提示
sii prompts set --inline "你是一个安全专家"自定义命令
# 创建命令
sii commands create review --format toml
# 列出命令
sii commands list
# 在会话中使用
sii
> /review 检查安全问题远程会话
# 连接到远程会话
sii --remote my-session
# 通过会话 ID 连接
sii --connect-session-id abc123沙箱模式
# 在沙箱中运行
sii --sandbox
# 自定义沙箱镜像
sii --sandbox --sandbox-image custom-image:latest