Skip to main content

配置

Continue 可以进行深度定制。用户级别的配置存储在您的主目录中的 config.json 文件中,并且可以编辑:

  • ~/.continue/config.json (MacOS / Linux)
  • %USERPROFILE%\.continue\config.json (Windows)

要打开config.json,你可以点击Continue Chat侧边栏右下角的“齿轮”图标。在编辑此文件时,你可以看到输入时建议的可用选项,或查看下面的参考。

当你保存config.json时,Continue 会自动刷新以考虑你的更改。config.json在你第一次使用 Continue 时会自动创建。如果config.json不存在,它会自动生成。

在绝大多数情况下,您只需要编辑config.json。然而,Continue提供了两种额外的自定义配置方式:

  • .continuerc.json - 工作区级别的配置。如果您希望将某些设置限定到特定的工作区,可以在项目的根目录中添加一个.continuerc.json。这可以设置为与用户级别的config.json合并覆盖它。
  • config.ts - 高级配置(可能不需要) - 一个位于您主目录中的TypeScript文件,可用于以编程方式修改(合并config.json模式:
    • ~/.continue/config.ts (MacOS / Linux)
    • %USERPROFILE%\.continue\config.ts (Windows)

config.json

查看config.json的完整参考这里

.continuerc.json

.continuerc.json 的格式与 config.json 相同,加上一个额外的属性 mergeBehavior,可以设置为 "merge" 或 "overwrite"。如果设置为 "merge"(默认值),.continuerc.json 将应用于 config.json 之上(数组和对象将被合并)。如果设置为 "overwrite",则 .continuerc.json 的每个顶级属性将覆盖 config.json 中的相应属性。

示例

.continuerc.json
{
"tabAutocompleteOptions": {
"disable": true
},
"mergeBehavior": "overwrite"
}

config.ts

要以编程方式扩展 config.json,你可以在与 config.json 相同的目录中放置一个 config.ts 脚本,并导出一个 modifyConfig 函数,如下所示:

config.ts
export function modifyConfig(config: Config): Config {
config.slashCommands?.push({
name: "commit",
description: "Write a commit message",
run: async function* (sdk) {
// The getDiff function takes a boolean parameter that indicates whether
// to include unstaged changes in the diff or not.
const diff = await sdk.ide.getDiff(false); // Pass false to exclude unstaged changes
for await (const message of sdk.llm.streamComplete(
`${diff}\n\nWrite a commit message for the above changes. Use no more than 20 tokens to give a brief description in the imperative mood (e.g. 'Add feature' not 'Added feature'):`,
new AbortController().signal,
{
maxTokens: 20,
},
)) {
yield message;
}
},
});
return config;
}

这可以用于斜杠命令和自定义上下文提供者。