docs and fixes

This commit is contained in:
mrT23
2024-09-10 20:06:48 +03:00
parent 1451d82d6b
commit 09b0a04a47
5 changed files with 77 additions and 10 deletions

View File

@ -1,2 +1,70 @@
## Overview - Static Code Analysis 💎 ## Overview - Static Code Analysis 💎
TBD
By combining static code analysis with LLM capabilities, PR-Agent can provide a comprehensive analysis of the PR code changes on a component level.
It scans the PR code changes, finds all the code components (methods, functions, classes) that changed, and enables to interactively generate tests, docs, code suggestions and similar code search for each component.
!!! note "Language that are currently supported:"
Python, Java, C++, JavaScript, TypeScript, C#.
## Capabilities
### Analyze PR
The [`analyze`](https://pr-agent-docs.codium.ai/tools/analyze/) tool enables to interactively generate tests, docs, code suggestions and similar code search for each component that changed in the PR.
It can be invoked manually by commenting on any PR:
```
/analyze
```
An example result:
![Analyze 1](https://codium.ai/images/pr_agent/analyze_1.png){width=768}
Clicking on each checkbox will trigger the relevant tool for the selected component.
### Generate Tests
The [`test`](https://pr-agent-docs.codium.ai/tools/test/) tool generate tests for a selected component, based on the PR code changes.
It can be invoked manually by commenting on any PR:
```
/test component_name
```
where 'component_name' is the name of a specific component in the PR, Or be triggered interactively by using the `analyze` tool.
![test1](https://codium.ai/images/pr_agent/test1.png){width=768}
### Generate Docs for a Component
The [`add_docs`](https://pr-agent-docs.codium.ai/tools/documentation/) tool scans the PR code changes, and automatically generate docstrings for any code components that changed in the PR.
It can be invoked manually by commenting on any PR:
```
/add_docs component_name
```
Or be triggered interactively by using the `analyze` tool.
![Docs single component](https://codium.ai/images/pr_agent/docs_single_component.png){width=768}
### Generate Code Suggestions for a Component
The [`improve_component`](https://pr-agent-docs.codium.ai/tools/improve_component/) tool generates code suggestions for a specific code component that changed in the PR.
It can be invoked manually by commenting on any PR:
```
/improve_component component_name
```
Or be triggered interactively by using the `analyze` tool.
![improve_component2](https://codium.ai/images/pr_agent/improve_component2.png){width=768}
### Find Similar Code
The [`similar code`](https://pr-agent-docs.codium.ai/tools/similar_code/) tool retrieves the most similar code components from inside the organization's codebase, or from open-source code.
For example:
`Global Search` for a method called `chat_completion`:
![similar code global](https://codium.ai/images/pr_agent/similar_code_global2.png){width=768}

View File

@ -1,7 +1,7 @@
## Overview ## Overview
The `analyze` tool combines advanced static code analysis with LLM capabilities to provide a comprehensive analysis of the PR code changes. The `analyze` tool combines advanced static code analysis with LLM capabilities to provide a comprehensive analysis of the PR code changes.
The tool scans the PR code changes, find the code components (methods, functions, classes) that changed, and enables to interactively generate tests, docs, code suggestions and similar code search for each component. The tool scans the PR code changes, finds the code components (methods, functions, classes) that changed, and enables to interactively generate tests, docs, code suggestions and similar code search for each component.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```

View File

@ -10,14 +10,10 @@ To get a list of the components that changed in the PR and choose the relevant c
## Example usage ## Example usage
Invoke the tool manually by commenting `/test` on any PR: Invoke the tool manually by commenting `/test` on any PR:
![test1](https://codium.ai/images/pr_agent/test1.png){width=704}
The tool will generate tests for the selected component (if no component is stated, it will generate tests for largest component): The tool will generate tests for the selected component (if no component is stated, it will generate tests for largest component):
![test2](https://codium.ai/images/pr_agent/test2.png){width=768} ![test1](https://codium.ai/images/pr_agent/test1.png){width=768}
![test3](https://codium.ai/images/pr_agent/test3.png){width=768}
(Example taken from [here](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment-1913679429)): (Example taken from [here](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment-1913679429)):

View File

@ -938,7 +938,10 @@ def is_value_no(value):
return False return False
def process_description(description_full: str): def process_description(description_full: str) -> Tuple[str, List]:
if not description_full:
return "", []
split_str = "### **Changes walkthrough** 📝" split_str = "### **Changes walkthrough** 📝"
description_split = description_full.split(split_str) description_split = description_full.split(split_str)
base_description_str = description_split[0] base_description_str = description_split[0]

View File

@ -79,8 +79,8 @@ async def is_valid_notification(notification, headers, handled_ids, session, use
pr_url = notification['subject']['url'] pr_url = notification['subject']['url']
latest_comment = notification['subject']['latest_comment_url'] latest_comment = notification['subject']['latest_comment_url']
if not latest_comment or not isinstance(latest_comment, str): if not latest_comment or not isinstance(latest_comment, str):
get_logger().debug(f"not latest_comment, but its ok") get_logger().debug(f"no latest_comment")
# continue return False, handled_ids
async with session.get(latest_comment, headers=headers) as comment_response: async with session.get(latest_comment, headers=headers) as comment_response:
check_prev_comments = False check_prev_comments = False
if comment_response.status == 200: if comment_response.status == 200: