规则
规则用于为模型提供 Chat、Edit 和 Agent 请求的指令。
您可以通过单击主工具栏上方的钢笔图标来查看当前规则
为了形成系统消息,规则按照它们在工具栏中出现的顺序用新行连接起来。这包括基本的聊天系统消息(见下文)。
规则块
规则可以添加到 Continue Hub 上的 Assistant 中。在此探索可用规则,或在 Hub 中创建您自己的规则。这些块是使用config.yaml
语法定义的,也可以在本地创建。
自动创建本地规则块
在 Agent 模式下,如果启用了 builtin_create_rule_block
工具,您可以简单地提示 Agent 为您创建规则。
例如,您可以说“为此创建一个规则”,然后将根据您的对话在 .continue/rules
中为您创建一个规则。
语法
规则块可以是简单文本,也可以具有以下属性
name
(必需):规则的显示名称/标题rule
(必需):规则的文本内容globs
(可选):当提供的文件作为上下文与此 glob 模式匹配时,将包含该规则。它可以是单个模式(例如"**/*.{ts,tsx}"
)或模式数组(例如["src/**/*.ts", "tests/**/*.ts"]
)。
config.yaml
rules:
- Always annotate Python functions with their parameter and return types
- name: TypeScript best practices
rule: Always use TypeScript interfaces to define shape of objects. Use type aliases sparingly.
globs: "**/*.{ts,tsx}"
- name: TypeScript test patterns
rule: In TypeScript tests, use Jest's describe/it pattern and follow best practices for mocking.
globs:
- "src/**/*.test.ts"
- "tests/**/*.ts"
- uses: myprofile/my-mood-setter
with:
TONE: concise
聊天系统消息
Continue 为Chat 和Agent 请求包含一个简单的默认系统消息,以帮助模型在其输出中提供可靠的代码块格式。
这可以在工具栏的规则部分查看(见上文),或在此处访问源代码
如果需要,高级用户可以使用 chatOptions.baseSystemMessage
覆盖特定模型的此系统消息。请参阅config.yaml
参考。
.continuerules
您可以通过在项目根目录添加 .continuerules
文件来创建项目特定的规则。此文件是原始文本,其全部内容将用作规则。
简单示例
- 如果您想要简洁的回答
Please provide concise answers. Don't explain obvious concepts. You can assume that I am knowledgable about most programming topics.
- 如果您想确保遵循某些实践,例如在 React 中
Whenever you are writing React code, make sure to
- use functional components instead of class components
- use hooks for state management
- define an interface for your component props
- use Tailwind CSS for styling
- modularize components into smaller, reusable pieces