opencli

快速开始

环境要求

构建项目

cargo build

初始化配置

cargo run -- config init

默认配置文件路径:~/.config/opencli/config.json

最小可用示例:

{
  "provider": "openai-compatible",
  "baseUrl": "https://api.openai.com/v1",
  "apiKey": "<your-api-key>",
  "model": "gpt-4.1",
  "approvalMode": "on-write",
  "nonInteractiveApproval": "deny",
  "workspaceRoot": ".",
  "allowedToolKinds": [
    "filesystem-read",
    "filesystem-search",
    "shell",
    "agent"
  ],
  "allowedTools": []
}

第一次运行

单轮执行:

cargo run -- "Explain this repository"

聊天模式:

cargo run -- chat

带上下文运行:

cargo run -- run --file crates/opencli-core/src/lib.rs "Explain this file"
cargo run -- run --dir crates/opencli-core/src "Summarize this codebase"

常见本地安装方式

Unix-like 环境:

./scripts/install.sh

Windows PowerShell:

./scripts/install.ps1

建议阅读顺序

  1. 先看 项目概览
  2. 再看 配置说明
  3. 最后按需查 命令参考