Agent 标签
/// 文档注释中的标签用于补充代码本身无法表达的信息。所有标签都是可选的。
<!---
Adds a task and saves the list.
@llm Append a task and save; returns the new list.
@prefer @add_task($tasks, title: 'x') over $tasks->push(), which doesn't save.
@avoid Calling it in a loop: it saves each time. Build the list, then call @save_tasks once.
@pitfall title is trimmed, and an empty title throws Validation.
@example @add_task($tasks, title: 'Buy milk')
-->
<fn name="add_task" params="tasks: list, title: string">
<!-- … -->
</fn>
<!---
Only for the tests.
@agent hide
-->
<fn name="reset_store">
<!-- … -->
</fn>/// Adds a task and saves the list.
/// @llm Append a task and save; returns the new list.
/// @prefer @add_task($tasks, title: 'x') over $tasks->push(), which doesn't save.
/// @avoid Calling it in a loop: it saves each time. Build the list, then call @save_tasks once.
/// @pitfall title is trimmed, and an empty title throws Validation.
/// @example @add_task($tasks, title: 'Buy milk')
fn add_task(tasks: list, title: string) {
// …
}
/// Only for the tests.
/// @agent hide
fn reset_store() {
// …
}| 标签 | 作用 |
|---|---|
@llm |
供 agent 阅读的一行内容,用于替代摘要。若未提供,agent 将获取摘要的第一句。两者都会被截断为 120 个字符。 |
@prefer |
应当让 agent 优先选择的用法写法。 |
@avoid |
应当让 agent 避免选择的用法。 |
@pitfall |
容易犯的错误。 |
@example |
当内容能放进一行、最多 100 个字符时显示。 |
@agent hide |
将该符号从 agent 文档中排除。 |
编辑器在悬停提示中也会显示 @prefer、@avoid 和 @pitfall,因此它们同样对人有帮助。在 XML 中,请在元素之前的 <!--- ... --> 注释中写入相同的标签。