-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add customization documentation for Team Prompts
Added documentation for customizing Team Prompts, including format, frontmatter config, and examples in English and Chinese.
- Loading branch information
Showing
4 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
layout: default | ||
title: Customize Features | ||
nav_order: 4 | ||
has_children: true | ||
permalink: /customize | ||
--- | ||
|
||
{: .no_toc } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
--- | ||
layout: default | ||
title: Prompt Override | ||
parent: Customize Features | ||
nav_order: 2 | ||
--- | ||
|
||
Prompt Override ([#54](https://github.com/unit-mesh/auto-dev/issues/54)) will override the AutoDev prompt with your own | ||
prompt. | ||
|
||
## How to use | ||
|
||
create a folder named `prompt/genius` in your project root directory, then create the prompt file which defined in | ||
Supported Action. | ||
|
||
For example, create a file named `prompts/genius/sql/sql-gen-clarify.vm`, will override the clarify prompt of AutoSQL/GenSQL | ||
|
||
## Supported Action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
layout: default | ||
title: Team Prompts | ||
parent: Customize Features | ||
nav_order: 1 | ||
permalink: /custom/team-prompts | ||
--- | ||
|
||
> Discover new ways to collaborate and share your brilliance with your team. | ||
The default Team Prompts path is prompts/, which is the prompts/ directory located in the project's root directory. | ||
|
||
AutoDev currently utilizes the Apache Velocity template engine, allowing you to customize your Team Prompts by modifying | ||
template files. | ||
|
||
{: .warning } | ||
If you make changes to the template files, make sure to save them, as otherwise, the IDE won't recognize your | ||
modifications. | ||
|
||
## Format | ||
|
||
The Team Prompts file format is .vtl, which is the Velocity Template Language file format. Will be include three parts: | ||
|
||
- frontmatter config, which is the prompt config with YAML format | ||
- chat role, like `system`, `user`, will start with \`\`\` and end with \`\`\`, like: | ||
```vtl | ||
```system``` | ||
``` | ||
- chat content, aka prompt content | ||
|
||
## FrontMatter Config | ||
|
||
``` | ||
--- | ||
interaction: AppendCursorStream # the interaction type, support AppendCursorStream, ChatPanel, AppendCursor, OutputFile | ||
priority: 99 | ||
--- | ||
``` | ||
|
||
Priority is the prompt priority, the higher the priority, the higher the prompt will be displayed in top. | ||
|
||
- the default action priority is 900~999, like `Chat with xx`, `Code complete` etc. | ||
|
||
interaction type: | ||
|
||
- AppendCursor, the prompt will be inserted at the cursor position | ||
- AppendCursorStream, the prompt will be inserted at the cursor position | ||
- ChatPanel, the prompt will be inserted in the chat panel | ||
- OutputFile, the prompt will be inserted in the output file, `output-{timestamp}.{extension}`, the extension will be | ||
parsed from the result's language. | ||
- ReplaceSelection, the prompt will replace the current selection (since version@1.6.3) | ||
|
||
## English Examples | ||
|
||
variables list: [https://ide.unitmesh.cc/variables](https://ide.unitmesh.cc/variables) | ||
|
||
--- | ||
interaction: AppendCursorStream | ||
--- | ||
```user``` | ||
|
||
You are an experienced software development engineer skilled in using Test-Driven Development (TDD) to develop software. | ||
You need to help users write test code based on their requirements. | ||
|
||
${frameworkContext} | ||
|
||
The current class-related code is as follows: | ||
|
||
${beforeCursor} | ||
|
||
The user's requirement is: ${selection} | ||
|
||
Please use ```@Test to begin writing your code block: | ||
|
||
full TDD | ||
example: [https://github.com/unit-mesh/untitled/tree/english/prompts](https://github.com/unit-mesh/untitled/tree/english/prompts) | ||
|
||
## 中文示例(Chinese example): | ||
|
||
变量列表: [AutoDev 模板变量](/variables)。 | ||
|
||
--- | ||
interaction: AppendCursorStream | ||
--- | ||
```user``` | ||
|
||
你是一个资深的软件开发工程师,你擅长使用 TDD 的方式来开发软件,你现在需要帮助帮手开发人员做好 Tasking,以方便于编写测试用例。 | ||
|
||
- Tasking 产生的任务都是具有独立业务价值的,每完成一条,都可以独立交付、产生价值。 | ||
- 采用面向业务需求的 Tasking 采用业务语言描述任务列表,更有助于开发人员和业务人员对需求进行详细的沟通和确认。 | ||
- 采用 Given When Then 的书写格式,其中 When 中所代表系统行为。 | ||
- 要考虑业务场景覆盖率,尽可能考虑到边界条件 | ||
|
||
请严格按照以下的格式输出。 | ||
|
||
示例如下: | ||
|
||
Question: 开发一个出租车计费功能,它的计算规则是这样的:不超过8公里时每公里收费0.8元,超过8公里则每公里加收50%长途费,停车等待时每分钟加收0.25元。 | ||
Answer: ### | ||
${commentSymbol} Given 出租车行驶了5公里(8公里以内),未发生等待,When 计费,Then 收费4元 | ||
${commentSymbol} Given 出租车行驶了5公里(8公里以内),等待10分钟,When 计费,Then 收费6.5元 | ||
${commentSymbol} Given 出租车恰好行驶了8公里,未发生等待,When 计费,Then 收费6.4元 | ||
${commentSymbol} Given 出租车恰好行驶了8公里,等待10分钟,When 计费,Then 收费8.9元 | ||
### | ||
Question: ${selection} | ||
Answer: ### | ||
|
||
完整的 TDD | ||
示例:[https://github.com/unit-mesh/untitled/tree/master/prompts](https://github.com/unit-mesh/untitled/tree/master/prompts) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
--- | ||
layout: default | ||
title: Variables | ||
parent: Customize Features | ||
nav_order: 999 | ||
permalink: /customize/variables | ||
--- | ||
|
||
# Variables | ||
|
||
## English version | ||
|
||
- selection: Used to get the currently selected text. | ||
- commentSymbol: Used to get the comment symbol of the current language, for example: `//`, `#`, `--`, `/* */`, etc. | ||
- beforeCursor: Used to get the text before the current cursor. | ||
- afterCursor: Used to get the text after the current cursor. | ||
- language: Used to get the language of the current file, for example: `kotlin`, `java`, `python`, `javascript`, etc. | ||
- fileName: Used to get the file name of the current file. | ||
- filePath: Used to get the file path of the current file. | ||
- methodName: Used to get the method name of the current method. | ||
- frameworkContext: Used to get the framework context of the current file, for example: `spring`, `junit`, `mockito`, | ||
etc. | ||
|
||
## 中文版本(Chinese version) | ||
|
||
- selection: 用于获取当前选中的文本。 | ||
- commentSymbol: 用于获取当前语言的注释符号,例如:`//`、`#`、`--`、`/* */` 等。 | ||
- beforeCursor: 用于获取当前光标前的文本。 | ||
- afterCursor: 用于获取当前光标后的文本。 | ||
- language: 用于获取当前文件的语言,例如:`kotlin`、`java`、`python`、`javascript` 等。 | ||
- fileName: 用于获取当前文件的文件名。 | ||
- filePath: 用于获取当前文件的文件路径。 | ||
- methodName: 用于获取当前方法的方法名。 | ||
- frameworkContext: 用于获取当前文件的框架上下文,例如:`spring`、`junit`、`mockito` 等。 | ||
|
||
# Methods | ||
|
||
use `@context.methodName()` to call the method. | ||
|
||
```kotlin | ||
interface TeamContextProvider { | ||
/** | ||
* Retrieves the code of the target file associated with the given test name. | ||
* | ||
* @param methodName the name of the test | ||
* @return the code of the target file as a string | ||
*/ | ||
fun underTestFileCode(methodName: String): String | ||
|
||
/** | ||
* Retrieves the code of the target method associated with the given test name. | ||
* | ||
* @param methodName the name of the test for which to retrieve the target method code | ||
* @return the code of the target method as a string | ||
*/ | ||
fun underTestMethodCode(methodName: String): String | ||
|
||
/** | ||
* Returns a list of similar chunks. | ||
* | ||
* This method retrieves a list of similar chunks based on a certain criteria. The chunks are represented as strings. | ||
* | ||
* @return a list of similar chunks as strings | ||
*/ | ||
fun similarChunks(): String | ||
|
||
/** | ||
* Returns the related code for the given method. | ||
* | ||
* This method retrieves the related code that is associated with the current method. The related code | ||
* can be used to understand the context or dependencies of the method. | ||
* | ||
* @return The related code as a string. | ||
*/ | ||
fun relatedCode(): String | ||
} | ||
``` |