config.yml 手动配置详解
2026年6月7日 上午10:13:25
SolonCode 安装后,配置文件位于 ~/.soloncode/config.yml。
config.yml 是 SolonCode 的基础配置文件。用户级路径为 ~/.soloncode/config.yml,工作区路径为 .soloncode/config.yml。配置内容应放在 soloncode: 节下。
1、最小可用配置
soloncode:
models:
- name: "deepseek"
apiUrl: "https://api.deepseek.com/v1/chat/completions"
apiKey: "sk-xxxxxx"
model: "deepseek-chat"
timeout: "180s"
2、核心配置项
| 配置项 | 默认值 | 描述 |
|---|---|---|
tools | ** | 启用工具配置(** = 所有工具;* = 仅公域工具) |
disallowedTools | / | 禁用工具配置(需要具体的名字,不支持 *),子代理也会受其控制 |
maxTurns | 30 | Agent 最大执行回合(超过后,触发自我反思) |
autoRethink | true | 自我反思,到达回合上限后是否允许模型反思并继续) |
sessionWindowSize | 8 | 新任务携带的历史消息窗口 |
summaryWindowSize | 40 | 触发摘要压缩的消息条数阈值 |
summaryWindowToken | 60_000 | 触发上下文压缩的 token 阈值 |
summaryModel | 空 | 指定摘要模型,空则使用当前模型 |
工具权限配置选择(for: tools、disallowedTools)
| 工具名 | 类型 | 描述 |
|---|---|---|
** | - | 所有公域 + 私域工具 |
* | - | 仅所有公域工具 |
pi | - | 微形命令行工具(包括工具:read, write, edit, bash) |
hitl | 私域 | 人工介入审核 |
generate | 私域 | 动态生成子代理 |
restapi | 私域 | Web 服务 API 接入 |
mcp | 私域 | MCP 服务接入 |
code | 公域 | 编码指引(自动分析项目类型、编译指令等) |
lsp | 公域 | LSP服务(提升代码编辑器的智能感知能力) |
codesearch | 公域 | 网络代码搜索 |
websearch | 公域 | 网络搜索 |
webfetch | 公域 | 网页内容抓取 |
todo | 公域 | 任务清单管理 |
skill | 公域 | 专家技能调用 |
task | 公域 | 子代理任务委派 |
bash | 公域 | Shell 命令执行 |
ls | 公域 | 列出目录内容 |
grep | 公域 | 递归内容搜索 |
glob | 公域 | 通配符文件搜索 |
edit | 公域 | 文件编辑(含 write、edit、read) |
read | 公域 | 读取文件内容 |
3、安全与执行配置
| 配置项 | 默认值 | 说明 |
|---|---|---|
sandboxMode | true | 限制工具访问范围,降低误操作风险 |
hitlEnabled | false | 是否启用人工审批 |
subagentEnabled | true | 是否启用子代理 |
bashAsyncEnabled | true | 是否允许 Bash 异步执行 |
thinkPrinted | true | 是否显示思考内容 |
cliPrintSimplified | true | CLI 是否简化工具输出 |
4、MCP Gateway、OpenAPI Gateway、LSP 配置与开关
| 配置项 | 默认值 | 说明 |
|---|---|---|
mcpEnabled | true | MCP Gateway 开关 |
openApiEnabled | true | OpenAPI Gateway 开关 |
lspEnabled | true | LSP 代码智能开关 |
apiRetries | 3 | OpenAPI/HTTP 调用重试次数 |
mcpRetries | 3 | MCP 调用重试次数 |
mcpServers | / | MCP 服务器配置 |
apiServers | / | OpenAPI 服务器配置 |
lspServers | / | LSP 服务器配置 |
MCP 配置
soloncode:
mcpServers:
memory:
command: "npx"
args: ["-y", "@modelcontextprotocol/server-memory"]
gitee:
type: "streamable"
url: "https://api.gitee.com/mcp"
headers:
Authorization: "Bearer xxx"
OpenAPI / REST API 配置
soloncode:
apiServers:
user-service:
docUrl: "https://api.example.com/openapi.json"
apiBaseUrl: "https://api.example.com"
headers:
Authorization: "Bearer xxx"
LSP 配置
soloncode:
lspServers:
java:
command: ["jdtls"]
extensions: [".java"]
typescript:
command: ["typescript-language-server", "--stdio"]
extensions: [".ts", ".tsx", ".js", ".jsx"]
当前源码已内置了 Java、TypeScript、Go、Python、Rust、C/C++、C#、Ruby、PHP、Bash、Lua、Dart、Swift、Kotlin、YAML 等默认 LSP 模板,但默认不启用,需要在 Web 设置页或配置中开启并确保本机已安装对应语言服务器。
5、models 模型配置
| 配置项 | 默认值 | 说明 |
|---|---|---|
models | / | 模型配置 |
modelRetries | 3 | 模型请求重试次数 |
支持所有主流大模型 API(注意 apiUrl 是全地址,不是 baseUrl):
soloncode:
models:
- name: "bigmodel-glm5.1" #名字(管理用)。可选
description: "Bigmodel coding plan(更新更强些)" #描述(管理和 llm 选的对参考用)。可选
apiUrl: "https://open.bigmodel.cn/api/anthropic/v1/messages"
apiKey: "***"
model: "GLM-5.1"
timeout: "300s"
userAgent: "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; SolonCode/1.0; +https://solon.noear.org/)"
- name: "aliyun-kimi2.5"
description: "Aliyun coding plan(适合简单任务)"
apiUrl: "https://coding.dashscope.aliyuncs.com/v1/chat/completions"
apiKey: "***"
model: "kimi-2.5"
timeout: "300s"
userAgent: "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; SolonCode/1.0; +https://solon.noear.org/)"
详细配置参考:《模型配置与请求选项》。关于 apiUrl 可以参考:《支持哪些模型?及方言定制》。
7、完整配置示例
solon.logging.appender:
console:
enable: false # 控制台日志(启用会干扰 CLI)
file:
level: DEBUG
soloncode:
# 核心配置
tools: "**"
# disallowedTools: "bash"
maxTurns: 20
autoRethink: true
sessionWindowSize: 8
summaryWindowSize: 40
summaryWindowToken: 60_000
# 安全与执行配置
sandboxMode: true
hitlEnabled: false
subagentEnabled: true
memoryEnabled: true
memoryIsolation: false
mcpEnabled: true
openApiEnabled: true
lspEnabled: true
# CLI 配置
cliPrintSimplified: true
# AI 模型配置
modelRetries: 3
models:
- apiUrl: "https://api.deepseek.com/v1/chat/completions"
apiKey: "sk-xxxxxx"
model: "deepseek-chat"
timeout: "120s"
# REST API 接入(可选)
apiRetries: 3
apiServers:
api1:
docUrl: "https://api.example.com/openapi.json"
apiBaseUrl: "https://api.example.com"
headers: { Authorization: "Bearer xxx" }
# MCP 服务接入(可选)
mcpRetries: 3
mcpServers:
memory:
command: "npx"
args: [ "-y", "@modelcontextprotocol/server-memory" ]
# LSP 服务接入(可选)
lspServers:
java:
command: ["jdtls", "-data", ".solon/lsp/java-workspace"]
extensions: [".java"]
typescript:
command: ["typescript-language-server", "--stdio"]
extensions: [".ts", ".tsx", ".js", ".jsx"]
go:
command: ["gopls"]
extensions: [".go"]
python:
command: ["pylsp"]
extensions: [".py"]