CLI
配置
管理 CLI 持久配置。
config 命令组管理存储在 ~/.north-coder/cli-config.json 中的持久配置。配置用于设置默认值,避免每次输入重复选项。
配置项
| 键 | 默认值 | 说明 |
|---|---|---|
server | — | 默认服务端地址,用于服务发现 Level 3。 |
token | — | 认证令牌(敏感,显示时遮蔽为 ***)。 |
output | human | 输出格式偏好。 |
default_project_id | — | 项目入口的默认项目 ID,仅在未提供 --workspace 或 --conversation 时被 run 使用。 |
config show
查看当前配置。
# 查看所有配置
ncoder config show
# 查看单个配置项
ncoder config show server
# 查看服务端可用的 Agent profiles 和模型
ncoder config show profiles
ncoder config show models敏感字段(如 token)显示为 ***。未设置的字段显示为空。
profiles 和 models 不是本地持久配置项,而是通过当前发现到的后端读取服务端配置,便于在 run --profile、run --model、message send --profile 和 message send --model 中选择 ID。
JSON 模式下,不带参数的 config show 会合并本地配置与服务端信息;如果服务不可达,profiles / models 为 null,并带有 server_reachable: false:
{
"server": "http://127.0.0.1:8848",
"token": "***",
"default_project_id": "proj_abc123",
"profiles": null,
"models": null,
"server_reachable": false
}config set
设置配置项。
ncoder config set KEY VALUE| 参数 | 说明 |
|---|---|
KEY | 配置项名称(见上方表格)。 |
VALUE | 要设置的值。传入 null 表示清除。 |
示例
# 设置默认服务地址
ncoder config set server http://192.168.1.10:8848
# 设置默认项目
ncoder config set default_project_id proj_abc123
# 清除配置项
ncoder config set server null安全注意事项
- 配置文件在 Unix 上使用受限权限(目录
0700,文件0600)。 token字段在 Windows 上不允许持久化存储(无法保证文件权限安全)。Windows 上设置 token 会被拒绝,建议使用NC_TOKEN环境变量。
config path
显示配置文件路径。
ncoder config pathJSON 输出:
{
"path": "/Users/you/.north-coder/cli-config.json",
"exists": true
}常用配置场景
日常开发
本地使用,设置默认项目即可:
ncoder config set default_project_id proj_abc123之后 ncoder run "..." 不再需要 --project。ncoder run -w <workspace> 或 ncoder run -c <conversation> 不会读取这个默认项目。
远程服务器
连接到团队共享的远程 North Coder:
ncoder config set server http://team-server:8848
export NC_TOKEN="your-token"CI/CD 集成
CI 环境中推荐使用环境变量,不依赖配置文件:
export NC_SERVER="http://ci-server:8848"
export NC_TOKEN="$CI_SECRET_TOKEN"
ncoder run "run all tests" --project proj_abc --wait --timeout 600