Compare commits

...

11 Commits

Author SHA1 Message Date
Tal
c3f8ef939c Merge pull request #1914 from abhinav-1305/fix/gitlab-webhook
apply repository settings before processing push commands in GitLab webhook
2025-07-05 09:08:57 +03:00
Tal
34cc434459 Update gitlab_webhook.py 2025-07-05 09:07:47 +03:00
Tal
a3d52f9cc7 Update pr_agent/servers/gitlab_webhook.py
Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>
2025-07-05 09:05:23 +03:00
Tal
f56728fbca Merge pull request #1913 from abhinav-1305/add-ask-tool
clarify that Fetching Ticket Context affects Ask tool
2025-07-05 09:03:30 +03:00
Tal
19ddf1b2e4 Merge pull request #1911 from abhinav-1305/diagram-marker
add support for PR sequence diagram in description markers
2025-07-05 08:58:44 +03:00
23ce79589c Update pr_agent/settings/pr_description_prompts.toml
Co-authored-by: qodo-merge-for-open-source[bot] <189517486+qodo-merge-for-open-source[bot]@users.noreply.github.com>
2025-07-05 11:27:38 +05:30
8a7b37ab4c Revert "clarify that Fetching Ticket Context affects Ask tool"
This reverts commit 822a253eb5.
2025-07-02 19:13:01 +05:30
3b071ccb4e apply repository settings before processing push commands in GitLab webhook 2025-07-02 19:11:53 +05:30
822a253eb5 clarify that Fetching Ticket Context affects Ask tool 2025-07-02 18:49:58 +05:30
aeb1bd8dbc fix suggestions 2025-07-02 18:11:19 +05:30
df8290a290 add support for PR sequence diagram in description markers 2025-07-02 18:07:54 +05:30
5 changed files with 17 additions and 4 deletions

View File

@ -177,9 +177,12 @@ pr_agent:summary
## PR Walkthrough:
pr_agent:walkthrough
## PR Diagram:
pr_agent:diagram
```
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.
The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` will be replaced with the PR summary, `pr_agent:walkthrough` will be replaced with the PR walkthrough, and `pr_agent:diagram` will be replaced with the sequence diagram (if enabled).
![Describe markers before](https://codium.ai/images/pr_agent/describe_markers_before.png){width=512}
@ -191,6 +194,7 @@ becomes
- `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.
- `diagram`: if present as a marker, will be replaced by the PR sequence diagram (if enabled).
## Custom labels

View File

@ -234,6 +234,9 @@ async def gitlab_webhook(background_tasks: BackgroundTasks, request: Request):
get_logger().info(f"Skipping draft MR: {url}")
return JSONResponse(status_code=status.HTTP_200_OK, content=jsonable_encoder({"message": "success"}))
# Apply repo settings before checking push commands or handle_push_trigger
apply_repo_settings(url)
commands_on_push = get_settings().get(f"gitlab.push_commands", {})
handle_push_trigger = get_settings().get(f"gitlab.handle_push_trigger", False)
if not commands_on_push or not handle_push_trigger:
@ -282,8 +285,8 @@ def handle_ask_line(body, data):
question = body.replace('/ask', '').strip()
path = data['object_attributes']['position']['new_path']
side = 'RIGHT' # if line_range_['start']['type'] == 'new' else 'LEFT'
comment_id = data['object_attributes']["discussion_id"]
get_logger().info("Handling line comment")
_id = data['object_attributes']["discussion_id"]
get_logger().info("Handling line ")
body = f"/ask_line --line_start={start_line} --line_end={end_line} --side={side} --file_name={path} --comment_id={comment_id} {question}"
except Exception as e:
get_logger().error(f"Failed to handle ask line comment: {e}")

View File

@ -81,6 +81,7 @@ the tool will replace every marker of the form `pr_agent:marker_name` in the PR
- `type`: the PR type.
- `summary`: the PR summary.
- `walkthrough`: the PR walkthrough.
- `diagram`: the PR sequence diagram (if enabled).
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.

View File

@ -48,7 +48,7 @@ class PRDescription(BaseModel):
description: str = Field(description="summarize the PR changes in up to four bullet points, each up to 8 words. For large PRs, add sub-bullets if needed. Order bullets by importance, with each bullet highlighting a key change group.")
title: str = Field(description="a concise and descriptive title that captures the PR's main theme")
{%- if enable_pr_diagram %}
changes_diagram: str = Field(description="a horizontal diagram that represents the main PR changes, in the format of a valid mermaid LR flowchart. The diagram should be concise and easy to read. Leave empty if no diagram is relevant. To create robust Mermaid diagrams, follow this two-step process: (1) Declare the nodes: nodeID["node description"]. (2) Then define the links: nodeID1 -- "link text" --> nodeID2. Node description must always be surrounded with quotation marks.")
changes_diagram: str = Field(description="a horizontal diagram that represents the main PR changes, in the format of a valid mermaid LR flowchart. The diagram should be concise and easy to read. Leave empty if no diagram is relevant. To create robust Mermaid diagrams, follow this two-step process: (1) Declare the nodes: nodeID[\"node description\"]. (2) Then define the links: nodeID1 -- \"link text\" --> nodeID2. Node description must always be surrounded with quotation marks.")
{%- endif %}
{%- if enable_semantic_files_types %}
pr_files: List[FileDescription] = Field(max_items=20, description="a list of all the files that were changed in the PR, and summary of their changes. Each file must be analyzed regardless of change size.")

View File

@ -538,6 +538,11 @@ class PRDescription:
get_logger().error(f"Failing to process walkthrough {self.pr_id}: {e}")
body = body.replace('pr_agent:walkthrough', "")
# Add support for pr_agent:diagram marker (plain and HTML comment formats)
ai_diagram = self.data.get('changes_diagram')
if ai_diagram:
body = re.sub(r'<!--\s*pr_agent:diagram\s*-->|pr_agent:diagram', ai_diagram, body)
return title, body, walkthrough_gfm, pr_file_changes
def _prepare_pr_answer(self) -> Tuple[str, str, str, List[dict]]: