Skip to content

Commit

Permalink
docs and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mrT23 committed Sep 10, 2024
1 parent 1451d82 commit 09b0a04
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 10 deletions.
70 changes: 69 additions & 1 deletion docs/docs/core-abilities/static_code_analysis.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,70 @@
## 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}
2 changes: 1 addition & 1 deletion docs/docs/tools/analyze.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Overview
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:
```
Expand Down
6 changes: 1 addition & 5 deletions docs/docs/tools/test.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ To get a list of the components that changed in the PR and choose the relevant c
## Example usage

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):

![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)):

Expand Down
5 changes: 4 additions & 1 deletion pr_agent/algo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,10 @@ def is_value_no(value):
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** 📝"
description_split = description_full.split(split_str)
base_description_str = description_split[0]
Expand Down
4 changes: 2 additions & 2 deletions pr_agent/servers/github_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ async def is_valid_notification(notification, headers, handled_ids, session, use
pr_url = notification['subject']['url']
latest_comment = notification['subject']['latest_comment_url']
if not latest_comment or not isinstance(latest_comment, str):
get_logger().debug(f"not latest_comment, but its ok")
# continue
get_logger().debug(f"no latest_comment")
return False, handled_ids
async with session.get(latest_comment, headers=headers) as comment_response:
check_prev_comments = False
if comment_response.status == 200:
Expand Down

0 comments on commit 09b0a04

Please sign in to comment.