Files
pr-agent/docs/DESCRIBE.md

113 lines
6.0 KiB
Markdown
Raw Normal View History

2023-09-29 09:47:13 +03:00
# Describe Tool
2024-01-05 17:05:03 +02:00
The `describe` tool scans the PR code changes, and can automatically generate PR description - title, type, summary, walkthrough and labels.
The tool can be triggered automatically every time a new PR is [opened](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools), or it can be invoked manually by commenting on any PR:
2023-09-29 09:47:13 +03:00
```
/describe
```
For example:
<kbd><img src=https://codium.ai/images/pr_agent/describe_comment.png width="768"></kbd>
2023-09-29 09:47:13 +03:00
<kbd><img src=https://codium.ai/images/pr_agent/describe.png width="768"></kbd>
2023-09-29 09:47:13 +03:00
2023-12-18 13:41:50 +02:00
### Handle custom labels from the Repo's labels page :gem:
> This feature is available only in PR-Agent Pro
2023-12-18 10:08:29 +02:00
2024-01-05 17:05:03 +02:00
You can control the custom labels that will be suggested by the `describe` tool, from the repo's labels page:
* GitHub : go to `https://github.com/{owner}/{repo}/labels` (or click on the "Labels" tab in the issues or PRs page)
* GitLab : go to `https://gitlab.com/{owner}/{repo}/-/labels` (or click on "Manage" -> "Labels" on the left menu)
Now add/edit the custom labels. they should be formatted as follows:
2023-12-18 10:08:29 +02:00
* Label name: The name of the custom label.
2023-12-18 13:41:50 +02:00
* Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.<br>
2023-12-18 10:08:29 +02:00
2024-01-05 17:05:03 +02:00
The description should be comprehensive and detailed, indicating when to add the desired label. For example:
<kbd><img src=https://codium.ai/images/pr_agent/add_native_custom_labels.png width="880"></kbd>
2023-12-18 10:08:29 +02:00
2024-01-05 17:05:03 +02:00
2023-09-29 09:47:13 +03:00
### Configuration options
2024-01-05 17:05:03 +02:00
To edit [configurations](./../pr_agent/settings/configuration.toml#L28) related to the describe tool, use the following template:
2023-09-29 09:47:13 +03:00
2024-01-05 17:05:03 +02:00
```
/describe --pr_description.some_config1=... --pr_description.some_config2=...
```
2023-09-29 09:47:13 +03:00
2024-01-05 17:05:03 +02:00
**Possible configurations:**
2023-09-29 09:47:13 +03:00
- `publish_labels`: if set to true, the tool will publish the labels to the PR. Default is true.
- `publish_description_as_comment`: if set to true, the tool will publish the description as a comment to the PR. If false, it will overwrite the origianl description. Default is false.
- `add_original_user_description`: if set to true, the tool will add the original user description to the generated description. Default is false.
2023-10-08 14:35:54 +03:00
- `keep_original_user_title`: if set to true, the tool will keep the original PR title, and won't change it. Default is false.
2023-09-29 09:47:13 +03:00
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
2023-12-07 15:26:36 +02:00
2023-10-29 13:58:01 +02:00
- To enable `custom labels`, apply the configuration changes described [here](./GENERATE_CUSTOM_LABELS.md#configuration-changes)
2023-12-07 15:26:36 +02:00
2023-11-06 17:55:58 +02:00
- `enable_pr_type`: if set to false, it will not show the `PR type` as a text value in the description content. Default is true.
2023-12-07 15:26:36 +02:00
2023-12-03 10:52:00 +02:00
- `final_update_message`: if set to true, it will add a comment message [`PR Description updated to latest commit...`](https://github.com/Codium-ai/pr-agent/pull/499#issuecomment-1837412176) after finishing calling `/describe`. Default is true.
2023-12-07 15:26:36 +02:00
2024-01-04 10:27:07 +02:00
- `enable_semantic_files_types`: if set to true, "Changes walkthrough" section will be generated. Default is true.
- `collapsible_file_list`: if set to true, the file list in the "Changes walkthrough" section will be collapsible. If set to "adaptive", the file list will be collapsible only if there are more than 8 files. Default is "adaptive".
2023-11-06 17:55:58 +02:00
2023-10-19 11:43:18 +03:00
### Markers template
2024-01-05 17:05:03 +02:00
To enable markers, set `pr_description.use_description_markers=true`.
2023-09-29 11:53:39 +03:00
markers enable to easily integrate user's content and auto-generated content, with a template-like mechanism.
2023-09-29 09:47:13 +03:00
For example, if the PR original description was:
```
User content...
2024-01-05 17:05:03 +02:00
## PR Type:
pr_agent:type
2023-09-29 09:47:13 +03:00
## PR Description:
pr_agent:summary
## PR Walkthrough:
pr_agent:walkthrough
```
2024-01-05 17:05:03 +02:00
The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` will be replaced with the PR summary, and `pr_agent:walkthrough` will be replaced with the PR walkthrough.
2023-10-19 11:38:21 +03:00
<kbd><img src=https://codium.ai/images/pr_agent/describe_markers_before.png width="768"></kbd>
2023-10-19 11:40:01 +03:00
2023-10-19 11:38:21 +03:00
==>
2023-10-19 11:40:01 +03:00
<kbd><img src=https://codium.ai/images/pr_agent/describe_markers_after.png width="768"></kbd>
2023-10-19 11:45:41 +03:00
##### Configuration params:
- `use_description_markers`: if set to true, the tool will use markers template. It replaces every marker of the form `pr_agent:marker_name` with the relevant content. Default is false.
- `include_generated_by_header`: if set to true, the tool will add a dedicated header: 'Generated by PR Agent at ...' to any automatic content. Default is true.
2024-01-05 17:05:03 +02:00
## Usage Tips
- When you first install the app, the [default mode](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#github-app-automatic-tools) for the describe tool is:
```
pr_commands = ["describe --pr_description.add_original_user_description=true --pr_description.keep_original_user_title=true", ...]
```
meaning the `describe` tool will run automatically on every PR, will keep the original title, and will add the original user description above the generated description. <br> This default is quite conservative, and strikes a good balance between automation and control:
If you want more automation, just give the PR a title, and the tool will auto-write a full description; If you want more control, you can add a detailed description, and the tool will add the complementary description below it.
- For maximal automation, you can change the default mode to:
```
pr_commands = ["describe --pr_description.add_original_user_description=false --pr_description.keep_original_user_title=true", ...]
```
so the title will be auto-generated as well.
- Markers are an alternative way to control the generated description, to give maximal control to the user. If you set:
```
pr_commands = ["describe --pr_description.use_description_markers=true", ...]
```
the tool will replace every marker of the form `pr_agent:marker_name` in the PR description with the relevant content, where `marker_name` is one of the following:
- `type`: the PR type.
- `summary`: the PR summary.
- `walkthrough`: the PR walkthrough.
Note that when markers are enabled, if the original PR description does not contain any markers, the tool will not alter the description at all.