From c6c97ac98aaa4dc58f2227f3048f60290e609a61 Mon Sep 17 00:00:00 2001 From: zmeir Date: Wed, 30 Aug 2023 23:33:38 +0300 Subject: [PATCH 01/36] Try to change the improve command prompt to prevent split lines range --- .../settings/pr_code_suggestions_prompts.toml | 18 ++++++++++++------ pr_agent/tools/pr_code_suggestions.py | 7 ++----- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pr_agent/settings/pr_code_suggestions_prompts.toml b/pr_agent/settings/pr_code_suggestions_prompts.toml index f60b9cc2..6867a883 100644 --- a/pr_agent/settings/pr_code_suggestions_prompts.toml +++ b/pr_agent/settings/pr_code_suggestions_prompts.toml @@ -68,12 +68,17 @@ Code suggestions: type: string description: |- a code snippet showing the relevant code lines from a '__new hunk__' section. - It must be continuous, correctly formatted and indented, and without line numbers. - relevant lines: - type: string + It must be contiguous, correctly formatted and indented, and without line numbers. + relevant lines start: + type: integer description: |- - the relevant lines from a '__new hunk__' section, in the format of 'start_line-end_line'. - For example: '10-15'. They should be derived from the hunk line numbers, and correspond to the 'existing code' snippet above. + The relevant line number from a '__new hunk__' section where the suggestion starts (inclusive). + Should be derived from the hunk line numbers, and correspond to the 'existing code' snippet above. + relevant lines end: + type: integer + description: |- + The relevant line number from a '__new hunk__' section where the suggestion ends (inclusive). + Should be derived from the hunk line numbers, and correspond to the 'existing code' snippet above. improved code: type: string description: |- @@ -90,7 +95,8 @@ Code suggestions: Add a docstring to func1() existing code: |- def func1(): - relevant lines: '12-12' + relevant lines start: 12 + relevant lines end: 12 improved code: |- ... ``` diff --git a/pr_agent/tools/pr_code_suggestions.py b/pr_agent/tools/pr_code_suggestions.py index d9fb3051..ba45598e 100644 --- a/pr_agent/tools/pr_code_suggestions.py +++ b/pr_agent/tools/pr_code_suggestions.py @@ -113,11 +113,8 @@ class PRCodeSuggestions: if get_settings().config.verbosity_level >= 2: logging.info(f"suggestion: {d}") relevant_file = d['relevant file'].strip() - relevant_lines_str = d['relevant lines'].strip() - if ',' in relevant_lines_str: # handling 'relevant lines': '181, 190' or '178-184, 188-194' - relevant_lines_str = relevant_lines_str.split(',')[0] - relevant_lines_start = int(relevant_lines_str.split('-')[0]) # absolute position - relevant_lines_end = int(relevant_lines_str.split('-')[-1]) + relevant_lines_start = int(d['relevant lines start']) # absolute position + relevant_lines_end = int(d['relevant lines end']) content = d['suggestion content'] new_code_snippet = d['improved code'] From 48233fde237ca3c6a8513e81a0ce4d7085b41410 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 31 Aug 2023 08:02:14 +0300 Subject: [PATCH 02/36] Editing the prompts --- CONFIGURATION.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 66ec4f06..67a2be2d 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -48,6 +48,24 @@ Then when a new PR is opened, PR-Agent will run the `describe` tool with the abo Note that a local `.pr_agent.toml` file enables you to edit and customize the default parameters of any tool, not just the ones that are run automatically. +#### Editing the prompts +The prompts for the different tools of PR-Agent are defined in the `pr_agent/settings` folder. + +In practice, the prompts are loaded and stored as a standard setting object, +so editing them is similar to editing any other configuration value - just place the relevant setting in `.pr_agent.toml`file, and override the default value. + +For example, if you want to edit the prompts of the [describe](./pr_agent/settings/pr_description_prompts.toml) tool, you can add the following to your `.pr_agent.toml` file: +``` +[pr_description_prompt] +system=""" +... +""" +user=""" +... +""" +``` +Note that the new prompt will need to generate an output compatible with the relevant [post-process function](./pr_agent/tools/pr_description.py). + #### Online usage For online usage (calling tools by comments on a PR like `/ask ...`), just add `--config_path=` to any command, to edit a specific configuration value. For example if you want to edit `pr_reviewer` configurations, you can run: From e0ca594a6992d4e173821d46f0a9070c7dfe276f Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 31 Aug 2023 08:06:43 +0300 Subject: [PATCH 03/36] Editing the prompts --- CONFIGURATION.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 67a2be2d..26b72dc9 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -49,10 +49,10 @@ Then when a new PR is opened, PR-Agent will run the `describe` tool with the abo Note that a local `.pr_agent.toml` file enables you to edit and customize the default parameters of any tool, not just the ones that are run automatically. #### Editing the prompts -The prompts for the different tools of PR-Agent are defined in the `pr_agent/settings` folder. +The prompts for the various PR-Agent tools are defined in the `pr_agent/settings` folder. -In practice, the prompts are loaded and stored as a standard setting object, -so editing them is similar to editing any other configuration value - just place the relevant setting in `.pr_agent.toml`file, and override the default value. +In practice, the prompts are loaded and stored as a standard setting object. Hence, +editing them is similar to editing any other configuration value - just place the relevant key in `.pr_agent.toml`file, and override the default value. For example, if you want to edit the prompts of the [describe](./pr_agent/settings/pr_description_prompts.toml) tool, you can add the following to your `.pr_agent.toml` file: ``` From 376c4523ddb55273e0524b840817462bc1a7918c Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 31 Aug 2023 08:08:09 +0300 Subject: [PATCH 04/36] Editing the prompts --- CONFIGURATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 26b72dc9..cce29c77 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -64,7 +64,7 @@ user=""" ... """ ``` -Note that the new prompt will need to generate an output compatible with the relevant [post-process function](./pr_agent/tools/pr_description.py). +Note that the new prompt will need to generate an output compatible with the relevant [post-process function](./pr_agent/tools/pr_description.py#L137). #### Online usage For online usage (calling tools by comments on a PR like `/ask ...`), just add `--config_path=` to any command, to edit a specific configuration value. From ce9014073c0b3b2229770145ecd62b08e992ab80 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Thu, 31 Aug 2023 08:19:33 +0300 Subject: [PATCH 05/36] Editing the prompts --- CONFIGURATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index cce29c77..c54d047d 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -35,7 +35,7 @@ pr_commands = [ ] ``` This means that when a new PR is opened, PR-Agent will run the `describe` and `auto_review` tools. -For the describe tool, the `add_original_user_description` and `keep_original_user_title` parameters will be set to `true`. +For the describe tool, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true. However, you can override the default tool parameters by uploading a local configuration file called `.pr_agent.toml` to the root of your repo. For example, if your local `.pr_agent.toml` file contains: From 06d00032df3e58adbe831ae0f535587d57e3f567 Mon Sep 17 00:00:00 2001 From: szecsip Date: Thu, 31 Aug 2023 11:47:51 +0000 Subject: [PATCH 06/36] update docs for Azure DevOps --- CONFIGURATION.md | 18 ++++++++++++++++++ README.md | 44 ++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 66ec4f06..f9d3d010 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -73,8 +73,26 @@ key = ... Also review the [AiHandler](pr_agent/algo/ai_handler.py) file for instruction how to set keys for other models. +#### Changing a GIT provider +See [here](pr_agent/git_providers/__init__.py) for the list of GIT providers. + +To use GitHub, for example, set: +``` +[config] +git_provider="github" +``` + #### Extra instructions +##### General All PR-Agent tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage: ``` /update_changelog --pr_update_changelog.extra_instructions="Make sure to update also the version ..." +``` + +##### Azure DevOps provider +To use Azure DevOps provider set: +``` +[config] +git_provider="azure" +use_repo_settings_file=false ``` \ No newline at end of file diff --git a/README.md b/README.md index 095d2c04..85705c6c 100644 --- a/README.md +++ b/README.md @@ -75,27 +75,27 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull ## Overview `PR-Agent` offers extensive pull request functionalities across various git providers: -| | | GitHub | Gitlab | Bitbucket | CodeCommit | -|-------|---------------------------------------------|:------:|:------:|:---------:|:----------:| -| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | ⮑ Inline review | :white_check_mark: | :white_check_mark: | | | -| | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Auto-Description | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Improve Code | :white_check_mark: | :white_check_mark: | | | -| | ⮑ Extended | :white_check_mark: | :white_check_mark: | | | -| | Reflect and Review | :white_check_mark: | | | | -| | Update CHANGELOG.md | :white_check_mark: | | | | -| | | | | | | -| USAGE | CLI | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | App / webhook | :white_check_mark: | :white_check_mark: | | | -| | Tagging bot | :white_check_mark: | | | | -| | Actions | :white_check_mark: | | | | -| | | | | | | -| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -| | Incremental PR Review | :white_check_mark: | | | | +| | | GitHub | Gitlab | Bitbucket | CodeCommit | Azure DevOps | +|-------|---------------------------------------------|:------:|:------:|:---------:|:----------:|:----------:| +| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | ⮑ Inline review | :white_check_mark: | :white_check_mark: | | | | +| | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: +| | Auto-Description | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | +| | Improve Code | :white_check_mark: | :white_check_mark: | | | | +| | ⮑ Extended | :white_check_mark: | :white_check_mark: | | | | +| | Reflect and Review | :white_check_mark: | | | | :white_check_mark: | +| | Update CHANGELOG.md | :white_check_mark: | | | | | +| | | | | | | | +| USAGE | CLI | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | App / webhook | :white_check_mark: | :white_check_mark: | | | | +| | Tagging bot | :white_check_mark: | | | | | +| | Actions | :white_check_mark: | | | | | +| | | | | | | | +| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | Incremental PR Review | :white_check_mark: | | | | | Examples for invoking the different tools via the CLI: - **Review**: python cli.py --pr_url= review @@ -184,4 +184,4 @@ Here are some advantages of PR-Agent: - [Aider - GPT powered coding in your terminal](https://github.com/paul-gauthier/aider) - [openai-pr-reviewer](https://github.com/coderabbitai/openai-pr-reviewer) - [CodeReview BOT](https://github.com/anc95/ChatGPT-CodeReview) -- [AI-Maintainer](https://github.com/merwanehamadi/AI-Maintainer) +- [AI-Maintainer](https://github.com/merwanehamadi/AI-Maintainer) \ No newline at end of file From 24900305d6f6e0042cc9ceb10964bca8cc47d779 Mon Sep 17 00:00:00 2001 From: szecsip Date: Thu, 31 Aug 2023 11:50:41 +0000 Subject: [PATCH 07/36] update docs for Azure DevOps --- CONFIGURATION.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index f9d3d010..cedd8514 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -90,9 +90,16 @@ All PR-Agent tools have a parameter called `extra_instructions`, that enables to ``` ##### Azure DevOps provider -To use Azure DevOps provider set: +To use Azure DevOps provider use the following settings in configuration.toml: ``` [config] git_provider="azure" use_repo_settings_file=false +``` + +And use the following settings (you have to replace the values) in .secrets.toml: +``` +[azure_devops] +org = "https://dev.azure.com/YOUR_ORGANIZATION/" +pat = "YOUR_PAT_TOKEN" ``` \ No newline at end of file From be19b64542995deb7a6fbe4c0eabf07b7908aa18 Mon Sep 17 00:00:00 2001 From: szecsip Date: Thu, 31 Aug 2023 11:53:54 +0000 Subject: [PATCH 08/36] add dependencies for Azure DevOps provider --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/requirements.txt b/requirements.txt index 2441b1c1..99efa846 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,3 +17,5 @@ litellm~=0.1.504 boto3~=1.28.25 google-cloud-storage==2.10.0 ujson==5.8.0 +azure-devops==7.1.0b3 +msrest==0.7.1 \ No newline at end of file From eeea38dab3e6e1b3f4a03f35997c5578cc3e77fa Mon Sep 17 00:00:00 2001 From: Nikolay Telepenin Date: Fri, 1 Sep 2023 12:24:20 +0100 Subject: [PATCH 09/36] Gerrit support --- pr_agent/git_providers/__init__.py | 5 +- pr_agent/git_providers/gerrit_provider.py | 397 ++++++++++++++++++++++ pr_agent/servers/gerrit_server.py | 81 +++++ pr_agent/settings/configuration.toml | 14 +- 4 files changed, 494 insertions(+), 3 deletions(-) create mode 100644 pr_agent/git_providers/gerrit_provider.py create mode 100644 pr_agent/servers/gerrit_server.py diff --git a/pr_agent/git_providers/__init__.py b/pr_agent/git_providers/__init__.py index 376d09f5..968f0dfc 100644 --- a/pr_agent/git_providers/__init__.py +++ b/pr_agent/git_providers/__init__.py @@ -5,6 +5,8 @@ from pr_agent.git_providers.github_provider import GithubProvider from pr_agent.git_providers.gitlab_provider import GitLabProvider from pr_agent.git_providers.local_git_provider import LocalGitProvider from pr_agent.git_providers.azuredevops_provider import AzureDevopsProvider +from pr_agent.git_providers.gerrit_provider import GerritProvider + _GIT_PROVIDERS = { 'github': GithubProvider, @@ -12,7 +14,8 @@ _GIT_PROVIDERS = { 'bitbucket': BitbucketProvider, 'azure': AzureDevopsProvider, 'codecommit': CodeCommitProvider, - 'local' : LocalGitProvider + 'local' : LocalGitProvider, + 'gerrit': GerritProvider, } def get_git_provider(): diff --git a/pr_agent/git_providers/gerrit_provider.py b/pr_agent/git_providers/gerrit_provider.py new file mode 100644 index 00000000..d2a80a65 --- /dev/null +++ b/pr_agent/git_providers/gerrit_provider.py @@ -0,0 +1,397 @@ +import json +import logging +import os +import pathlib +import shutil +import subprocess +from collections import Counter, namedtuple +from pathlib import Path +from tempfile import mkdtemp, NamedTemporaryFile + +import requests +import urllib3.util +from git import Repo + +from pr_agent.config_loader import get_settings +from pr_agent.git_providers.git_provider import GitProvider, FilePatchInfo, \ + EDIT_TYPE +from pr_agent.git_providers.local_git_provider import PullRequestMimic + +logger = logging.getLogger(__name__) + + +def _call(*command, **kwargs) -> (int, str, str): + res = subprocess.run( + command, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + check=True, + **kwargs, + ) + return res.stdout.decode() + + +def clone(url, directory): + logger.info("Cloning %s to %s", url, directory) + stdout = _call('git', 'clone', "--depth", "1", url, directory) + logger.info(stdout) + + +def fetch(url, refspec, cwd): + logger.info("Fetching %s %s", url, refspec) + stdout = _call( + 'git', 'fetch', '--depth', '2', url, refspec, + cwd=cwd + ) + logger.info(stdout) + + +def checkout(cwd): + logger.info("Checking out") + stdout = _call('git', 'checkout', "FETCH_HEAD", cwd=cwd) + logger.info(stdout) + + +def show(*args, cwd=None): + logger.info("Show") + return _call('git', 'show', *args, cwd=cwd) + + +def diff(*args, cwd=None): + logger.info("Diff") + patch = _call('git', 'diff', *args, cwd=cwd) + if not patch: + logger.warning("No changes found") + return + return patch + + +def reset_local_changes(cwd): + logger.info("Reset local changes") + _call('git', 'checkout', "--force", cwd=cwd) + + +def add_comment(url: urllib3.util.Url, refspec, message): + *_, patchset, changenum = refspec.rsplit("/") + message = "'" + message.replace("'", "'\"'\"'") + "'" + return _call( + "ssh", + "-p", str(url.port), + f"{url.auth}@{url.host}", + "gerrit", "review", + "--message", message, + # "--code-review", score, + f"{patchset},{changenum}", + ) + + +def list_comments(url: urllib3.util.Url, refspec): + *_, patchset, _ = refspec.rsplit("/") + stdout = _call( + "ssh", + "-p", str(url.port), + f"{url.auth}@{url.host}", + "gerrit", "query", + "--comments", + "--current-patch-set", patchset, + "--format", "JSON", + ) + change_set, *_ = stdout.splitlines() + return json.loads(change_set)["currentPatchSet"]["comments"] + + +def prepare_repo(url: urllib3.util.Url, project, refspec): + repo_url = (f"{url.scheme}://{url.auth}@{url.host}:{url.port}/{project}") + + directory = pathlib.Path(mkdtemp()) + clone(repo_url, directory), + fetch(repo_url, refspec, cwd=directory) + checkout(cwd=directory) + return directory + + +def adopt_to_gerrit_message(message): + lines = message.splitlines() + buf = [] + for line in lines: + line = line.replace("*", "").replace("``", "`") + line = line.strip() + if line.startswith('#'): + buf.append("\n" + + line.replace('#', '').removesuffix(":").strip() + + ":") + continue + elif line.startswith('-'): + buf.append(line.removeprefix('-').strip()) + continue + else: + buf.append(line) + return "\n".join(buf).strip() + + +def add_suggestion(src_filename, context: str, start, end: int): + with ( + NamedTemporaryFile("w", delete=False) as tmp, + open(src_filename, "r") as src + ): + lines = src.readlines() + tmp.writelines(lines[:start - 1]) + if context: + tmp.write(context) + tmp.writelines(lines[end:]) + + shutil.copy(tmp.name, src_filename) + os.remove(tmp.name) + + +def upload_patch(patch, path): + patch_server_endpoint = get_settings().get( + 'gerrit.patch_server_endpoint') + patch_server_token = get_settings().get( + 'gerrit.patch_server_token') + + response = requests.post( + patch_server_endpoint, + json={ + "content": patch, + "path": path, + }, + headers={ + "Content-Type": "application/json", + "Authorization": f"Bearer {patch_server_token}", + } + ) + response.raise_for_status() + patch_server_endpoint = patch_server_endpoint.rstrip("/") + return patch_server_endpoint + "/" + path + + +class GerritProvider(GitProvider): + + def __init__(self, key: str, incremental=False): + self.project, self.refspec = key.split(':') + assert self.project, "Project name is required" + assert self.refspec, "Refspec is required" + base_url = get_settings().get('gerrit.url') + assert base_url, "Gerrit URL is required" + user = get_settings().get('gerrit.user') + assert user, "Gerrit user is required" + + parsed = urllib3.util.parse_url(base_url) + self.parsed_url = urllib3.util.parse_url( + f"{parsed.scheme}://{user}@{parsed.host}:{parsed.port}" + ) + + self.repo_path = prepare_repo( + self.parsed_url, self.project, self.refspec + ) + self.repo = Repo(self.repo_path) + assert self.repo + + self.pr = PullRequestMimic(self.get_pr_title(), self.get_diff_files()) + + def get_pr_title(self): + """ + Substitutes the branch-name as the PR-mimic title. + """ + return self.repo.branches[0].name + + def get_issue_comments(self): + # raise NotImplementedError( + # 'Getting comments is not implemented for the gerrit provider' + # ) + # unclear how to get right comments from gerrit + # all user's comments like this "'Patch Set 1: (1 comment)'" + # i.e. it's not clear how to get the comment body + + comments = list_comments(self.parsed_url, self.refspec) + Comments = namedtuple('Comments', ['reversed']) + Comment = namedtuple('Comment', ['body']) + return Comments([Comment(c['message']) for c in reversed(comments)]) + + def get_labels(self): + raise NotImplementedError( + 'Getting labels is not implemented for the gerrit provider') + + def add_eyes_reaction(self, issue_comment_id: int): + raise NotImplementedError( + 'Adding reactions is not implemented for the gerrit provider') + + def remove_reaction(self, issue_comment_id: int, reaction_id: int): + raise NotImplementedError( + 'Removing reactions is not implemented for the gerrit provider') + + def get_commit_messages(self): + return [self.repo.head.commit.message] + + def get_repo_settings(self): + """ + TODO: Implement support of .pr_agent.toml + """ + return "" + + def get_diff_files(self) -> list[FilePatchInfo]: + diffs = self.repo.head.commit.diff( + self.repo.head.commit.parents[0], # previous commit + create_patch=True, + R=True + ) + + diff_files = [] + for diff_item in diffs: + if diff_item.a_blob is not None: + original_file_content_str = ( + diff_item.a_blob.data_stream.read().decode('utf-8') + ) + else: + original_file_content_str = "" # empty file + if diff_item.b_blob is not None: + new_file_content_str = diff_item.b_blob.data_stream.read(). \ + decode('utf-8') + else: + new_file_content_str = "" # empty file + edit_type = EDIT_TYPE.MODIFIED + if diff_item.new_file: + edit_type = EDIT_TYPE.ADDED + elif diff_item.deleted_file: + edit_type = EDIT_TYPE.DELETED + elif diff_item.renamed_file: + edit_type = EDIT_TYPE.RENAMED + diff_files.append( + FilePatchInfo( + original_file_content_str, + new_file_content_str, + diff_item.diff.decode('utf-8'), + diff_item.b_path, + edit_type=edit_type, + old_filename=None + if diff_item.a_path == diff_item.b_path + else diff_item.a_path + ) + ) + self.diff_files = diff_files + return diff_files + + def get_files(self): + diff_index = self.repo.head.commit.diff( + self.repo.head.commit.parents[0], # previous commit + R=True + ) + # Get the list of changed files + diff_files = [item.a_path for item in diff_index] + return diff_files + + def get_languages(self): + """ + Calculate percentage of languages in repository. Used for hunk + prioritisation. + """ + # Get all files in repository + filepaths = [Path(item.path) for item in + self.repo.tree().traverse() if item.type == 'blob'] + # Identify language by file extension and count + lang_count = Counter( + ext.lstrip('.') for filepath in filepaths for ext in + [filepath.suffix.lower()]) + # Convert counts to percentages + total_files = len(filepaths) + lang_percentage = {lang: count / total_files * 100 for lang, count + in lang_count.items()} + return lang_percentage + + def get_pr_description(self): + return self.repo.head.commit.message + + def get_user_id(self): + return self.repo.head.commit.author.email + + def is_supported(self, capability: str) -> bool: + if capability in [ + # 'get_issue_comments', + 'create_inline_comment', + 'publish_inline_comments', + 'get_labels' + ]: + return False + return True + + def split_suggestion(self, msg) -> tuple[str, str]: + is_code_context = False + description = [] + context = [] + for line in msg.splitlines(): + if line.startswith('```suggestion'): + is_code_context = True + continue + if line.startswith('```'): + is_code_context = False + continue + if is_code_context: + context.append(line) + else: + description.append( + line.replace('*', '') + ) + + return ( + '\n'.join(description), + '\n'.join(context) + '\n' if context else '' + ) + + def publish_code_suggestions(self, code_suggestions: list): + msg = [] + for i, suggestion in enumerate(code_suggestions): + description, code = self.split_suggestion(suggestion['body']) + add_suggestion( + pathlib.Path(self.repo_path) / suggestion["relevant_file"], + code, + suggestion["relevant_lines_start"], + suggestion["relevant_lines_end"], + ) + patch = diff(cwd=self.repo_path) + path = "/".join(["codium-ai", self.refspec, str(i)]) + full_path = upload_patch(patch, path) + reset_local_changes(self.repo_path) + msg.append(f'* {description}\n{full_path}') + + if msg: + add_comment(self.parsed_url, self.refspec, "---\n".join(msg)) + + def publish_comment(self, pr_comment: str, is_temporary: bool = False): + if not is_temporary: + msg = adopt_to_gerrit_message(pr_comment) + add_comment(self.parsed_url, self.refspec, msg) + + def publish_description(self, pr_title: str, pr_body: str): + msg = adopt_to_gerrit_message(pr_body) + add_comment(self.parsed_url, self.refspec, pr_title + '\n' + msg) + + def publish_inline_comments(self, comments: list[dict]): + raise NotImplementedError( + 'Publishing inline comments is not implemented for the gerrit ' + 'provider') + + def publish_inline_comment(self, body: str, relevant_file: str, + relevant_line_in_file: str): + raise NotImplementedError( + 'Publishing inline comments is not implemented for the gerrit ' + 'provider') + + def create_inline_comment(self, body: str, relevant_file: str, + relevant_line_in_file: str): + raise NotImplementedError( + 'Creating inline comments is not implemented for the gerrit ' + 'provider') + + def publish_labels(self, labels): + # Not applicable to the local git provider, + # but required by the interface + pass + + def remove_initial_comment(self): + # remove repo, cloned in previous steps + # shutil.rmtree(self.repo_path) + pass + + def get_pr_branch(self): + return self.repo.head diff --git a/pr_agent/servers/gerrit_server.py b/pr_agent/servers/gerrit_server.py new file mode 100644 index 00000000..07ead55a --- /dev/null +++ b/pr_agent/servers/gerrit_server.py @@ -0,0 +1,81 @@ +import copy +import logging +import sys +from enum import Enum +from json import JSONDecodeError + +import uvicorn +from fastapi import APIRouter, FastAPI, HTTPException +from pydantic import BaseModel +from starlette.middleware import Middleware +from starlette_context import context +from starlette_context.middleware import RawContextMiddleware + +from pr_agent.agent.pr_agent import PRAgent +from pr_agent.config_loader import global_settings, get_settings + +logging.basicConfig(stream=sys.stdout, level=logging.DEBUG) +router = APIRouter() + + +class Action(str, Enum): + review = "review" + describe = "describe" + ask = "ask" + improve = "improve" + + +class Item(BaseModel): + refspec: str + project: str + msg: str = None + + +@router.post("/api/v1/gerrit/{action}") +async def handle_gerrit_request(action: Action, item: Item): + logging.debug("Received a Gerrit request") + context["settings"] = copy.deepcopy(global_settings) + + agent = PRAgent() + pr_url = f"{item.project}:{item.refspec}" + if action == Action.review: + await agent.handle_request(pr_url, "/review") + elif action == Action.describe: + await agent.handle_request(pr_url, "/describe") + elif action == Action.improve: + await agent.handle_request(pr_url, "/improve") + elif action == Action.ask: + if not item.msg: + return HTTPException( + status_code=400, + detail="msg is required for ask command" + ) + await agent.handle_request(pr_url, f"/ask {item.msg.strip()}") + + +async def get_body(request): + try: + body = await request.json() + except JSONDecodeError as e: + logging.error("Error parsing request body", e) + return {} + return body + + +@router.get("/") +async def root(): + return {"status": "ok"} + + +def start(): + # to prevent adding help messages with the output + get_settings().set("CONFIG.CLI_MODE", True) + middleware = [Middleware(RawContextMiddleware)] + app = FastAPI(middleware=middleware) + app.include_router(router) + + uvicorn.run(app, host="0.0.0.0", port=3000) + + +if __name__ == '__main__': + start() diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index f8abd555..4dfc80c8 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -1,7 +1,7 @@ [config] model="gpt-4" fallback_models=["gpt-3.5-turbo-16k"] -git_provider="github" +git_provider="gerrit" publish_output=true publish_output_progress=true verbosity_level=0 # 0,1,2 @@ -84,4 +84,14 @@ polling_interval_seconds = 30 [local] # LocalGitProvider settings - uncomment to use paths other than default # description_path= "path/to/description.md" -# review_path= "path/to/review.md" \ No newline at end of file +# review_path= "path/to/review.md" + +[gerrit] +# endpoint to the gerrit service +# url = "ssh://gerrit.example.com:29418" +# user for gerrit authentication +# user = "ai-reviewer" +# patch server where patches will be saved +# patch_server_endpoint = "http://127.0.0.1:5000/patch" +# token to authenticate in the patch server +# patch_server_token = "" From 1254ad1727f6bed23abada389385cf68d5f718d6 Mon Sep 17 00:00:00 2001 From: Nikolay Telepenin Date: Fri, 1 Sep 2023 13:56:17 +0100 Subject: [PATCH 10/36] Gerrit: - support reflect/answer --- pr_agent/git_providers/gerrit_provider.py | 7 ------- pr_agent/servers/gerrit_server.py | 19 ++++++++----------- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/pr_agent/git_providers/gerrit_provider.py b/pr_agent/git_providers/gerrit_provider.py index d2a80a65..00f91afe 100644 --- a/pr_agent/git_providers/gerrit_provider.py +++ b/pr_agent/git_providers/gerrit_provider.py @@ -197,13 +197,6 @@ class GerritProvider(GitProvider): return self.repo.branches[0].name def get_issue_comments(self): - # raise NotImplementedError( - # 'Getting comments is not implemented for the gerrit provider' - # ) - # unclear how to get right comments from gerrit - # all user's comments like this "'Patch Set 1: (1 comment)'" - # i.e. it's not clear how to get the comment body - comments = list_comments(self.parsed_url, self.refspec) Comments = namedtuple('Comments', ['reversed']) Comment = namedtuple('Comment', ['body']) diff --git a/pr_agent/servers/gerrit_server.py b/pr_agent/servers/gerrit_server.py index 07ead55a..9bb6f16b 100644 --- a/pr_agent/servers/gerrit_server.py +++ b/pr_agent/servers/gerrit_server.py @@ -23,12 +23,14 @@ class Action(str, Enum): describe = "describe" ask = "ask" improve = "improve" + reflect = "reflect" + answer = "answer" class Item(BaseModel): refspec: str project: str - msg: str = None + msg: str = "" @router.post("/api/v1/gerrit/{action}") @@ -36,21 +38,16 @@ async def handle_gerrit_request(action: Action, item: Item): logging.debug("Received a Gerrit request") context["settings"] = copy.deepcopy(global_settings) - agent = PRAgent() - pr_url = f"{item.project}:{item.refspec}" - if action == Action.review: - await agent.handle_request(pr_url, "/review") - elif action == Action.describe: - await agent.handle_request(pr_url, "/describe") - elif action == Action.improve: - await agent.handle_request(pr_url, "/improve") - elif action == Action.ask: + if action == Action.ask: if not item.msg: return HTTPException( status_code=400, detail="msg is required for ask command" ) - await agent.handle_request(pr_url, f"/ask {item.msg.strip()}") + await PRAgent().handle_request( + f"{item.project}:{item.refspec}", + f"/{action.value} {item.msg.strip()}" + ) async def get_body(request): From 8b477c694c2c4e5654774813efaebcb64656f7b4 Mon Sep 17 00:00:00 2001 From: Nikolay Telepenin Date: Fri, 1 Sep 2023 14:41:56 +0100 Subject: [PATCH 11/36] Fix after rebase on main branch --- pr_agent/git_providers/gerrit_provider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pr_agent/git_providers/gerrit_provider.py b/pr_agent/git_providers/gerrit_provider.py index 00f91afe..5ec2e3c8 100644 --- a/pr_agent/git_providers/gerrit_provider.py +++ b/pr_agent/git_providers/gerrit_provider.py @@ -292,7 +292,7 @@ class GerritProvider(GitProvider): in lang_count.items()} return lang_percentage - def get_pr_description(self): + def get_pr_description_full(self): return self.repo.head.commit.message def get_user_id(self): From 35a6eb2e5250995d2c51c7a8a9705ae3b0ab7635 Mon Sep 17 00:00:00 2001 From: Nikolay Telepenin Date: Fri, 1 Sep 2023 14:51:29 +0100 Subject: [PATCH 12/36] Add unique patch to according to multiple execution of `publish_code_suggestions` --- pr_agent/git_providers/gerrit_provider.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pr_agent/git_providers/gerrit_provider.py b/pr_agent/git_providers/gerrit_provider.py index 5ec2e3c8..af754719 100644 --- a/pr_agent/git_providers/gerrit_provider.py +++ b/pr_agent/git_providers/gerrit_provider.py @@ -4,6 +4,7 @@ import os import pathlib import shutil import subprocess +import uuid from collections import Counter, namedtuple from pathlib import Path from tempfile import mkdtemp, NamedTemporaryFile @@ -333,7 +334,7 @@ class GerritProvider(GitProvider): def publish_code_suggestions(self, code_suggestions: list): msg = [] - for i, suggestion in enumerate(code_suggestions): + for suggestion in code_suggestions: description, code = self.split_suggestion(suggestion['body']) add_suggestion( pathlib.Path(self.repo_path) / suggestion["relevant_file"], @@ -342,7 +343,8 @@ class GerritProvider(GitProvider): suggestion["relevant_lines_end"], ) patch = diff(cwd=self.repo_path) - path = "/".join(["codium-ai", self.refspec, str(i)]) + patch_id = uuid.uuid4().hex[0:4] + path = "/".join(["codium-ai", self.refspec, patch_id]) full_path = upload_patch(patch, path) reset_local_changes(self.repo_path) msg.append(f'* {description}\n{full_path}') From ae98cfe17ba128271a14cc52974e88cc681e8a02 Mon Sep 17 00:00:00 2001 From: Nikolay Telepenin Date: Fri, 1 Sep 2023 14:56:16 +0100 Subject: [PATCH 13/36] Return status of upload suggestion to the gerrit --- pr_agent/git_providers/gerrit_provider.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pr_agent/git_providers/gerrit_provider.py b/pr_agent/git_providers/gerrit_provider.py index af754719..480809b0 100644 --- a/pr_agent/git_providers/gerrit_provider.py +++ b/pr_agent/git_providers/gerrit_provider.py @@ -351,6 +351,7 @@ class GerritProvider(GitProvider): if msg: add_comment(self.parsed_url, self.refspec, "---\n".join(msg)) + return True def publish_comment(self, pr_comment: str, is_temporary: bool = False): if not is_temporary: From 2e095807b7a754655b8b9c415936c01d1fe7e124 Mon Sep 17 00:00:00 2001 From: Telepenin Nikolay Date: Fri, 1 Sep 2023 15:05:48 +0100 Subject: [PATCH 14/36] Update README.md Added information about features of gerrit provider --- README.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 095d2c04..c440fd37 100644 --- a/README.md +++ b/README.md @@ -75,27 +75,28 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull ## Overview `PR-Agent` offers extensive pull request functionalities across various git providers: -| | | GitHub | Gitlab | Bitbucket | CodeCommit | -|-------|---------------------------------------------|:------:|:------:|:---------:|:----------:| -| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | | GitHub | Gitlab | Bitbucket | CodeCommit | Gerrit | +|-------|---------------------------------------------|:------:|:------:|:---------:|:----------:|:----------:| +| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | ⮑ Inline review | :white_check_mark: | :white_check_mark: | | | -| | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Auto-Description | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Improve Code | :white_check_mark: | :white_check_mark: | | | +| | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Auto-Description | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | +| | Improve Code | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | | | ⮑ Extended | :white_check_mark: | :white_check_mark: | | | -| | Reflect and Review | :white_check_mark: | | | | +| | Reflect and Review | :white_check_mark: | | | | :white_check_mark: | | | Update CHANGELOG.md | :white_check_mark: | | | | | | | | | | | -| USAGE | CLI | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | App / webhook | :white_check_mark: | :white_check_mark: | | | -| | Tagging bot | :white_check_mark: | | | | -| | Actions | :white_check_mark: | | | | +| USAGE | CLI | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | App / webhook | :white_check_mark: | :white_check_mark: | | | | +| | Tagging bot | :white_check_mark: | | | | | +| | Actions | :white_check_mark: | | | | | +| | HTTP Server | | | | | :white_check_mark:| | | | | | | | -| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | | -| | Incremental PR Review | :white_check_mark: | | | | +| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| | Incremental PR Review | :white_check_mark: | | | | | Examples for invoking the different tools via the CLI: - **Review**: python cli.py --pr_url= review From f7c698ff54aecafc8e639bfe051ccfa44b17f063 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 19:40:38 +0300 Subject: [PATCH 15/36] update --- README.md | 81 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 85705c6c..c236c8fa 100644 --- a/README.md +++ b/README.md @@ -35,33 +35,55 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull

-

/review:

-
-

- -

-
-

/reflect_and_review:

-
-

- -

-
-

/ask:

-
-

- -

-
-

/improve:

-
-

- -

-
+ +[//]: # (

/review:

) +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
) +[//]: # (

/reflect_and_review:

) + +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
) + +[//]: # (

/ask:

) + +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
) + +[//]: # (

/improve:

) + +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
)
- +## Table of Contents - [Overview](#overview) - [Try it now](#try-it-now) - [Installation](#installation) @@ -78,7 +100,6 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull | | | GitHub | Gitlab | Bitbucket | CodeCommit | Azure DevOps | |-------|---------------------------------------------|:------:|:------:|:---------:|:----------:|:----------:| | TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | ⮑ Inline review | :white_check_mark: | :white_check_mark: | | | | | | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | Auto-Description | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | | Improve Code | :white_check_mark: | :white_check_mark: | | | | @@ -91,10 +112,10 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull | | Tagging bot | :white_check_mark: | | | | | | | Actions | :white_check_mark: | | | | | | | | | | | | | -| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | Incremental PR Review | :white_check_mark: | | | | | Examples for invoking the different tools via the CLI: From 777c773a9098f9c18ac35bb9373abd727873a235 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 19:50:10 +0300 Subject: [PATCH 16/36] update --- CONFIGURATION.md | 23 +++++++++++++++++++---- README.md | 22 +++++++--------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 320ddedf..162a51d3 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -2,18 +2,33 @@ The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** +Options that are available in the configuration file can be specified at run time when calling actions. Two examples: +``` +- /review --pr_reviewer.extra_instructions="focus on the file: ..." +- /describe --pr_description.add_original_user_description=false -pr_description.extra_instructions="make sure to mention: ..." +``` + ### Working from CLI When running from source (CLI), your local configuration file will be initially used. -Example for invoking the 'review' tools via the CLI: +Examples for invoking the different tools via the CLI: ``` -python cli.py --pr-url= review +- **Review**: python cli.py --pr_url= review +- **Describe**: python cli.py --pr_url= describe +- **Improve**: python cli.py --pr_url= improve +- **Ask**: python cli.py --pr_url= ask "Write me a poem about this PR" +- **Reflect**: python cli.py --pr_url= reflect +- **Update Changelog**: python cli.py --pr_url= update_changelog ``` -In addition to general configurations, the 'review' tool will use parameters from the `[pr_reviewer]` section (every tool has a dedicated section in the configuration file). -Note that you can print results locally, without publishing them, by setting in `configuration.toml`: +"" is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). +Notes: + +(1) In addition to general configurations, each tool has its own configurations. For example, the 'review' tool will use parameters from the `[pr_reviewer]` section. + +(2) You can print results locally, without publishing them, by setting in `configuration.toml`: ``` [config] publish_output=true diff --git a/README.md b/README.md index c236c8fa..cbf13970 100644 --- a/README.md +++ b/README.md @@ -118,29 +118,21 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull | | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | Incremental PR Review | :white_check_mark: | | | | | -Examples for invoking the different tools via the CLI: -- **Review**: python cli.py --pr_url= review -- **Describe**: python cli.py --pr_url= describe -- **Improve**: python cli.py --pr_url= improve -- **Ask**: python cli.py --pr_url= ask "Write me a poem about this PR" -- **Reflect**: python cli.py --pr_url= reflect -- **Update Changelog**: python cli.py --pr_url= update_changelog - -"" is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). - -In the [configuration](./CONFIGURATION.md) file you can select your git provider (GitHub, Gitlab, Bitbucket), and further configure the different tools. -Options that are available in the configuration file can be specified at run time when calling actions. Two examples: -- /review --pr_reviewer.extra_instructions="focus on the file: ..." -- /describe --pr_description.add_original_user_description=false -pr_description.extra_instructions="make sure to mention: ..." +Review the [configuration](./CONFIGURATION.md) section for instruction how to use the different tools, select the relevant git provider (GitHub, Gitlab, Bitbucket,...), and adjust the configuration file to your needs. ## Try it now Try GPT-4 powered PR-Agent on your public GitHub repository for free. Just mention `@CodiumAI-Agent` and add the desired command in any PR comment! The agent will generate a response based on your command. +For example, add a comment: +``` +@CodiumAI-Agent /review +``` +And the agent will respond with a review of your PR ![Review generation process](https://www.codium.ai/images/demo-2.gif) -To set up your own PR-Agent, see the [Installation](#installation) section +To set up your own PR-Agent, see the [Installation](#installation) section below. --- ## Installation From 7a6efbcb5590e21519bb76dc25697744a31791bf Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 19:56:20 +0300 Subject: [PATCH 17/36] update --- CONFIGURATION.md | 11 +++++++---- README.md | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 162a51d3..82326a27 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -2,6 +2,11 @@ The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** +The `git_provider` field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: +` +"github", "gitlab", "azure", "codecommit","local" +` + Options that are available in the configuration file can be specified at run time when calling actions. Two examples: ``` - /review --pr_reviewer.extra_instructions="focus on the file: ..." @@ -13,20 +18,18 @@ When running from source (CLI), your local configuration file will be initially Examples for invoking the different tools via the CLI: -``` - **Review**: python cli.py --pr_url= review - **Describe**: python cli.py --pr_url= describe - **Improve**: python cli.py --pr_url= improve - **Ask**: python cli.py --pr_url= ask "Write me a poem about this PR" - **Reflect**: python cli.py --pr_url= reflect - **Update Changelog**: python cli.py --pr_url= update_changelog -``` -"" is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). +`` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). Notes: -(1) In addition to general configurations, each tool has its own configurations. For example, the 'review' tool will use parameters from the `[pr_reviewer]` section. +(1) In addition to general configurations, each tool has its own configurations. For example, the 'review' tool will use parameters from the `[pr_reviewer]` section in the [configuration file](pr_agent/settings/configuration.toml) (2) You can print results locally, without publishing them, by setting in `configuration.toml`: ``` diff --git a/README.md b/README.md index cbf13970..71278a03 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,6 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull - [How it works](#how-it-works) - [Why use PR-Agent](#why-use-pr-agent) - [Roadmap](#roadmap) -- [Similar projects](#similar-projects)
@@ -133,6 +132,7 @@ And the agent will respond with a review of your PR To set up your own PR-Agent, see the [Installation](#installation) section below. + --- ## Installation From 7f6493009cbc4393176da98cd61faa0c914c2f11 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 20:05:33 +0300 Subject: [PATCH 18/36] update --- CONFIGURATION.md | 21 ++++++--------------- README.md | 6 +++--- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 82326a27..10a18aa7 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -14,7 +14,7 @@ Options that are available in the configuration file can be specified at run tim ``` ### Working from CLI -When running from source (CLI), your local configuration file will be initially used. +When running from source (CLI), your local configuration file will be used. Examples for invoking the different tools via the CLI: @@ -27,9 +27,9 @@ Examples for invoking the different tools via the CLI: `` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). -Notes: +**Notes:** -(1) In addition to general configurations, each tool has its own configurations. For example, the 'review' tool will use parameters from the `[pr_reviewer]` section in the [configuration file](pr_agent/settings/configuration.toml) +(1) In addition to general configuration options, each tool has its own configurations. For example, the 'review' tool will use parameters from the `[pr_reviewer]` section in the [configuration file](/pr_agent/settings/configuration.toml#L16) (2) You can print results locally, without publishing them, by setting in `configuration.toml`: ``` @@ -40,11 +40,11 @@ verbosity_level=2 This is useful for debugging or experimenting with the different tools. ### Working from GitHub App (pre-built repo) -When running PR-Agent from GitHub App, the default configuration file (`configuration.toml`) will be loaded. +When running PR-Agent from GitHub App, the default configuration file (`configuration.toml`) will be initially loaded. #### GitHub app default tools -The `[github_app]` section of the configuration file defines GitHub app specific configurations. -The important parameter is `pr_commands`, which is a list of tools that will be run automatically when a new PR is opened: +The `[github_app]` section defines the GitHub app specific configurations. +An important parameter is `pr_commands`, which is a list of tools that will be run automatically when a new PR is opened: ``` [github_app] pr_commands = [ @@ -109,15 +109,6 @@ key = ... Also review the [AiHandler](pr_agent/algo/ai_handler.py) file for instruction how to set keys for other models. -#### Changing a GIT provider -See [here](pr_agent/git_providers/__init__.py) for the list of GIT providers. - -To use GitHub, for example, set: -``` -[config] -git_provider="github" -``` - #### Extra instructions ##### General All PR-Agent tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage: diff --git a/README.md b/README.md index 71278a03..ec0d5315 100644 --- a/README.md +++ b/README.md @@ -117,16 +117,16 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull | | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | Incremental PR Review | :white_check_mark: | | | | | -Review the [configuration](./CONFIGURATION.md) section for instruction how to use the different tools, select the relevant git provider (GitHub, Gitlab, Bitbucket,...), and adjust the configuration file to your needs. +Review the [configuration](./CONFIGURATION.md) section for instructions how to use the different tools, select the relevant git provider (GitHub, Gitlab, Bitbucket,...), and adjust the configuration file to your needs. ## Try it now Try GPT-4 powered PR-Agent on your public GitHub repository for free. Just mention `@CodiumAI-Agent` and add the desired command in any PR comment! The agent will generate a response based on your command. -For example, add a comment: +For example, add a comment to any pull request with the following text: ``` @CodiumAI-Agent /review ``` -And the agent will respond with a review of your PR +and the agent will respond with a review of your PR ![Review generation process](https://www.codium.ai/images/demo-2.gif) From 4d6d6c48121c06f677be6dcc0e5b9ddccdaace37 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 20:09:53 +0300 Subject: [PATCH 19/36] update --- CONFIGURATION.md | 17 ++++++++--------- README.md | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 10a18aa7..5124bb63 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -4,7 +4,7 @@ The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via t The `git_provider` field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: ` -"github", "gitlab", "azure", "codecommit","local" +"github", "gitlab", "azure", "codecommit", "local" ` Options that are available in the configuration file can be specified at run time when calling actions. Two examples: @@ -18,12 +18,12 @@ When running from source (CLI), your local configuration file will be used. Examples for invoking the different tools via the CLI: -- **Review**: python cli.py --pr_url= review -- **Describe**: python cli.py --pr_url= describe -- **Improve**: python cli.py --pr_url= improve -- **Ask**: python cli.py --pr_url= ask "Write me a poem about this PR" -- **Reflect**: python cli.py --pr_url= reflect -- **Update Changelog**: python cli.py --pr_url= update_changelog +- **Review**: `python cli.py --pr_url= review` +- **Describe**: `python cli.py --pr_url= describe` +- **Improve**: `python cli.py --pr_url= improve` +- **Ask**: `python cli.py --pr_url= ask "Write me a poem about this PR"` +- **Reflect**: `python cli.py --pr_url= reflect` +- **Update Changelog**: `python cli.py --pr_url= update_changelog` `` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). @@ -110,13 +110,12 @@ key = ... Also review the [AiHandler](pr_agent/algo/ai_handler.py) file for instruction how to set keys for other models. #### Extra instructions -##### General All PR-Agent tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage: ``` /update_changelog --pr_update_changelog.extra_instructions="Make sure to update also the version ..." ``` -##### Azure DevOps provider +#### Azure DevOps provider To use Azure DevOps provider use the following settings in configuration.toml: ``` [config] diff --git a/README.md b/README.md index ec0d5315..d0f8e9db 100644 --- a/README.md +++ b/README.md @@ -117,11 +117,11 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull | | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | Incremental PR Review | :white_check_mark: | | | | | -Review the [configuration](./CONFIGURATION.md) section for instructions how to use the different tools, select the relevant git provider (GitHub, Gitlab, Bitbucket,...), and adjust the configuration file to your needs. +Review the **[configuration](./CONFIGURATION.md)** section for detailed instructions how to use the different tools, select the relevant git provider (GitHub, Gitlab, Bitbucket,...), and adjust the configuration file to your needs. ## Try it now -Try GPT-4 powered PR-Agent on your public GitHub repository for free. Just mention `@CodiumAI-Agent` and add the desired command in any PR comment! The agent will generate a response based on your command. +You can try GPT-4 powered PR-Agent, on your public GitHub repository, instantly. Just mention `@CodiumAI-Agent` and add the desired command in any PR comment. The agent will generate a response based on your command. For example, add a comment to any pull request with the following text: ``` @CodiumAI-Agent /review From 44b790567b03be1832989b3969bfeaed987fa478 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 19:40:38 +0300 Subject: [PATCH 20/36] update readme --- CONFIGURATION.md | 50 ++++++++++++---------- README.md | 107 ++++++++++++++++++++++++++--------------------- 2 files changed, 89 insertions(+), 68 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 320ddedf..5124bb63 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -2,18 +2,36 @@ The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** +The `git_provider` field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: +` +"github", "gitlab", "azure", "codecommit", "local" +` + +Options that are available in the configuration file can be specified at run time when calling actions. Two examples: +``` +- /review --pr_reviewer.extra_instructions="focus on the file: ..." +- /describe --pr_description.add_original_user_description=false -pr_description.extra_instructions="make sure to mention: ..." +``` + ### Working from CLI -When running from source (CLI), your local configuration file will be initially used. +When running from source (CLI), your local configuration file will be used. -Example for invoking the 'review' tools via the CLI: +Examples for invoking the different tools via the CLI: -``` -python cli.py --pr-url= review -``` -In addition to general configurations, the 'review' tool will use parameters from the `[pr_reviewer]` section (every tool has a dedicated section in the configuration file). +- **Review**: `python cli.py --pr_url= review` +- **Describe**: `python cli.py --pr_url= describe` +- **Improve**: `python cli.py --pr_url= improve` +- **Ask**: `python cli.py --pr_url= ask "Write me a poem about this PR"` +- **Reflect**: `python cli.py --pr_url= reflect` +- **Update Changelog**: `python cli.py --pr_url= update_changelog` -Note that you can print results locally, without publishing them, by setting in `configuration.toml`: +`` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). +**Notes:** + +(1) In addition to general configuration options, each tool has its own configurations. For example, the 'review' tool will use parameters from the `[pr_reviewer]` section in the [configuration file](/pr_agent/settings/configuration.toml#L16) + +(2) You can print results locally, without publishing them, by setting in `configuration.toml`: ``` [config] publish_output=true @@ -22,11 +40,11 @@ verbosity_level=2 This is useful for debugging or experimenting with the different tools. ### Working from GitHub App (pre-built repo) -When running PR-Agent from GitHub App, the default configuration file (`configuration.toml`) will be loaded. +When running PR-Agent from GitHub App, the default configuration file (`configuration.toml`) will be initially loaded. #### GitHub app default tools -The `[github_app]` section of the configuration file defines GitHub app specific configurations. -The important parameter is `pr_commands`, which is a list of tools that will be run automatically when a new PR is opened: +The `[github_app]` section defines the GitHub app specific configurations. +An important parameter is `pr_commands`, which is a list of tools that will be run automatically when a new PR is opened: ``` [github_app] pr_commands = [ @@ -91,23 +109,13 @@ key = ... Also review the [AiHandler](pr_agent/algo/ai_handler.py) file for instruction how to set keys for other models. -#### Changing a GIT provider -See [here](pr_agent/git_providers/__init__.py) for the list of GIT providers. - -To use GitHub, for example, set: -``` -[config] -git_provider="github" -``` - #### Extra instructions -##### General All PR-Agent tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage: ``` /update_changelog --pr_update_changelog.extra_instructions="Make sure to update also the version ..." ``` -##### Azure DevOps provider +#### Azure DevOps provider To use Azure DevOps provider use the following settings in configuration.toml: ``` [config] diff --git a/README.md b/README.md index 85705c6c..d0f8e9db 100644 --- a/README.md +++ b/README.md @@ -35,33 +35,55 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull

-

/review:

-
-

- -

-
-

/reflect_and_review:

-
-

- -

-
-

/ask:

-
-

- -

-
-

/improve:

-
-

- -

-
+ +[//]: # (

/review:

) +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
) +[//]: # (

/reflect_and_review:

) + +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
) + +[//]: # (

/ask:

) + +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
) + +[//]: # (

/improve:

) + +[//]: # (
) + +[//]: # (

) + +[//]: # () + +[//]: # (

) + +[//]: # (
)
- +## Table of Contents - [Overview](#overview) - [Try it now](#try-it-now) - [Installation](#installation) @@ -69,7 +91,6 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull - [How it works](#how-it-works) - [Why use PR-Agent](#why-use-pr-agent) - [Roadmap](#roadmap) -- [Similar projects](#similar-projects)
@@ -78,7 +99,6 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull | | | GitHub | Gitlab | Bitbucket | CodeCommit | Azure DevOps | |-------|---------------------------------------------|:------:|:------:|:---------:|:----------:|:----------:| | TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | ⮑ Inline review | :white_check_mark: | :white_check_mark: | | | | | | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | Auto-Description | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | | Improve Code | :white_check_mark: | :white_check_mark: | | | | @@ -91,34 +111,27 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull | | Tagging bot | :white_check_mark: | | | | | | | Actions | :white_check_mark: | | | | | | | | | | | | | -| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | -| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | | :white_check_mark: | +| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | Incremental PR Review | :white_check_mark: | | | | | -Examples for invoking the different tools via the CLI: -- **Review**: python cli.py --pr_url= review -- **Describe**: python cli.py --pr_url= describe -- **Improve**: python cli.py --pr_url= improve -- **Ask**: python cli.py --pr_url= ask "Write me a poem about this PR" -- **Reflect**: python cli.py --pr_url= reflect -- **Update Changelog**: python cli.py --pr_url= update_changelog - -"" is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). - -In the [configuration](./CONFIGURATION.md) file you can select your git provider (GitHub, Gitlab, Bitbucket), and further configure the different tools. -Options that are available in the configuration file can be specified at run time when calling actions. Two examples: -- /review --pr_reviewer.extra_instructions="focus on the file: ..." -- /describe --pr_description.add_original_user_description=false -pr_description.extra_instructions="make sure to mention: ..." +Review the **[configuration](./CONFIGURATION.md)** section for detailed instructions how to use the different tools, select the relevant git provider (GitHub, Gitlab, Bitbucket,...), and adjust the configuration file to your needs. ## Try it now -Try GPT-4 powered PR-Agent on your public GitHub repository for free. Just mention `@CodiumAI-Agent` and add the desired command in any PR comment! The agent will generate a response based on your command. +You can try GPT-4 powered PR-Agent, on your public GitHub repository, instantly. Just mention `@CodiumAI-Agent` and add the desired command in any PR comment. The agent will generate a response based on your command. +For example, add a comment to any pull request with the following text: +``` +@CodiumAI-Agent /review +``` +and the agent will respond with a review of your PR ![Review generation process](https://www.codium.ai/images/demo-2.gif) -To set up your own PR-Agent, see the [Installation](#installation) section + +To set up your own PR-Agent, see the [Installation](#installation) section below. --- From 20c32375e197d45984d2223e6ed00a573b9a0535 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 20:14:14 +0300 Subject: [PATCH 21/36] auto --- CONFIGURATION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 5124bb63..7790f9f5 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -44,7 +44,7 @@ When running PR-Agent from GitHub App, the default configuration file (`configur #### GitHub app default tools The `[github_app]` section defines the GitHub app specific configurations. -An important parameter is `pr_commands`, which is a list of tools that will be run automatically when a new PR is opened: +An important parameter is `pr_commands`, which is a list of tools that will be **run automatically when a new PR is opened**: ``` [github_app] pr_commands = [ @@ -55,7 +55,7 @@ pr_commands = [ This means that when a new PR is opened, PR-Agent will run the `describe` and `auto_review` tools. For the describe tool, the `add_original_user_description` and `keep_original_user_title` parameters will be set to true. -However, you can override the default tool parameters by uploading a local configuration file called `.pr_agent.toml` to the root of your repo. +However, you can override the default tool parameters by uploading a local configuration file, called `.pr_agent.toml`, to the root of your repo. For example, if your local `.pr_agent.toml` file contains: ``` [pr_description] From 690c8194790af018ad6fd0ff74ec283160376202 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 20:22:10 +0300 Subject: [PATCH 22/36] update CONFIGURATION.md --- CONFIGURATION.md | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index b92d6e0b..e7ab2d65 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -2,18 +2,36 @@ The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** +The `git_provider` field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: +` +"github", "gitlab", "azure", "codecommit", "local" +` + +Options that are available in the configuration file can be specified at run time when calling actions. Two examples: +``` +- /review --pr_reviewer.extra_instructions="focus on the file: ..." +- /describe --pr_description.add_original_user_description=false -pr_description.extra_instructions="make sure to mention: ..." +``` + ### Working from CLI -When running from source (CLI), your local configuration file will be initially used. +When running from source (CLI), your local configuration file will be used. -Example for invoking the 'review' tools via the CLI: +Examples for invoking the different tools via the CLI: -``` -python cli.py --pr-url= review -``` -In addition to general configurations, the 'review' tool will use parameters from the `[pr_reviewer]` section (every tool has a dedicated section in the configuration file). +- **Review**: `python cli.py --pr_url= review` +- **Describe**: `python cli.py --pr_url= describe` +- **Improve**: `python cli.py --pr_url= improve` +- **Ask**: `python cli.py --pr_url= ask "Write me a poem about this PR"` +- **Reflect**: `python cli.py --pr_url= reflect` +- **Update Changelog**: `python cli.py --pr_url= update_changelog` -Note that you can print results locally, without publishing them, by setting in `configuration.toml`: +`` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). +**Notes:** + +(1) In addition to general configuration options, each tool has its own configurations. For example, the 'review' tool will use parameters from the `[pr_reviewer]` section in the [configuration file](/pr_agent/settings/configuration.toml#L16) + +(2) You can print results locally, without publishing them, by setting in `configuration.toml`: ``` [config] publish_output=true @@ -22,7 +40,7 @@ verbosity_level=2 This is useful for debugging or experimenting with the different tools. ### Working from GitHub App (pre-built repo) -When running PR-Agent from GitHub App, the default configuration file (`configuration.toml`) will be loaded. +When running PR-Agent from GitHub App, the default configuration file (`configuration.toml`) will be initially loaded. #### GitHub app default tools The `[github_app]` section defines the GitHub app specific configurations. @@ -91,23 +109,13 @@ key = ... Also review the [AiHandler](pr_agent/algo/ai_handler.py) file for instruction how to set keys for other models. -#### Changing a GIT provider -See [here](pr_agent/git_providers/__init__.py) for the list of GIT providers. - -To use GitHub, for example, set: -``` -[config] -git_provider="github" -``` - #### Extra instructions -##### General All PR-Agent tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage: ``` /update_changelog --pr_update_changelog.extra_instructions="Make sure to update also the version ..." ``` -##### Azure DevOps provider +#### Azure DevOps provider To use Azure DevOps provider use the following settings in configuration.toml: ``` [config] From e79bcbed930b62feaf51128807fab62c87a5bd8d Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 20:25:07 +0300 Subject: [PATCH 23/36] update CONFIGURATION.md --- CONFIGURATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index e7ab2d65..872caedc 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -2,7 +2,7 @@ The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** -The `git_provider` field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: +The [git_provider](pr-agent/blob/main/pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: ` "github", "gitlab", "azure", "codecommit", "local" ` From d52c11b907cdb5fded834fe3047f840b34e634b6 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 20:26:36 +0300 Subject: [PATCH 24/36] update CONFIGURATION.md --- CONFIGURATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 872caedc..f3daa1d0 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -2,7 +2,7 @@ The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** -The [git_provider](pr-agent/blob/main/pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: +The [git_provider](pr-agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: ` "github", "gitlab", "azure", "codecommit", "local" ` From 98019fe97f11142072959add69bb6edc7ff97c55 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Fri, 1 Sep 2023 20:27:29 +0300 Subject: [PATCH 25/36] update CONFIGURATION.md --- CONFIGURATION.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index f3daa1d0..b02c7e2b 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -2,7 +2,7 @@ The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** -The [git_provider](pr-agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: +The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: ` "github", "gitlab", "azure", "codecommit", "local" ` From 2b8a8ce824f4dfda40ac5c3aaa78bd4486169341 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sat, 2 Sep 2023 09:19:35 +0300 Subject: [PATCH 26/36] update README.md --- INSTALL.md | 78 ++++++++++++++++++------------------ README.md | 10 ++--- CONFIGURATION.md => Usage.md | 73 ++++++++++++++++++++++++--------- 3 files changed, 99 insertions(+), 62 deletions(-) rename CONFIGURATION.md => Usage.md (62%) diff --git a/INSTALL.md b/INSTALL.md index e778e266..37bee57e 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -9,8 +9,8 @@ To get started with PR-Agent quickly, you first need to acquire two tokens: There are several ways to use PR-Agent: - [Method 1: Use Docker image (no installation required)](INSTALL.md#method-1-use-docker-image-no-installation-required) -- [Method 2: Run as a GitHub Action](INSTALL.md#method-2-run-as-a-github-action) -- [Method 3: Run from source](INSTALL.md#method-3-run-from-source) +- [Method 2: Run from source](INSTALL.md#method-2-run-from-source) +- [Method 3: Run as a GitHub Action](INSTALL.md#method-3-run-as-a-github-action) - [Method 4: Run as a polling server](INSTALL.md#method-4-run-as-a-polling-server) - [Method 5: Run as a GitHub App](INSTALL.md#method-5-run-as-a-github-app) - [Method 6: Deploy as a Lambda Function](INSTALL.md#method-6---deploy-as-a-lambda-function) @@ -55,7 +55,41 @@ Possible questions you can ask include: --- -### Method 2: Run as a GitHub Action +### Method 2: Run from source + +1. Clone this repository: + +``` +git clone https://github.com/Codium-ai/pr-agent.git +``` + +2. Install the requirements in your favorite virtual environment: + +``` +pip install -r requirements.txt +``` + +3. Copy the secrets template file and fill in your OpenAI key and your GitHub user token: + +``` +cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml +chmod 600 pr_agent/settings/.secrets.toml +# Edit .secrets.toml file +``` + +4. Add the pr_agent folder to your PYTHONPATH, then run the cli.py script: + +``` +export PYTHONPATH=[$PYTHONPATH:] +python pr_agent/cli.py --pr_url review +python pr_agent/cli.py --pr_url ask +python pr_agent/cli.py --pr_url describe +python pr_agent/cli.py --pr_url improve +``` + +--- + +### Method 3: Run as a GitHub Action You can use our pre-built Github Action Docker image to run PR-Agent as a Github Action. @@ -114,7 +148,7 @@ The GITHUB_TOKEN secret is automatically created by GitHub. 3. Merge this change to your main branch. When you open your next PR, you should see a comment from `github-actions` bot with a review of your PR, and instructions on how to use the rest of the tools. -4. You may configure PR-Agent by adding environment variables under the env section corresponding to any configurable property in the [configuration](./CONFIGURATION.md) file. Some examples: +4. You may configure PR-Agent by adding environment variables under the env section corresponding to any configurable property in the [configuration](./Usage.md) file. Some examples: ```yaml env: # ... previous environment values @@ -125,40 +159,6 @@ When you open your next PR, you should see a comment from `github-actions` bot w --- -### Method 3: Run from source - -1. Clone this repository: - -``` -git clone https://github.com/Codium-ai/pr-agent.git -``` - -2. Install the requirements in your favorite virtual environment: - -``` -pip install -r requirements.txt -``` - -3. Copy the secrets template file and fill in your OpenAI key and your GitHub user token: - -``` -cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml -chmod 600 pr_agent/settings/.secrets.toml -# Edit .secrets.toml file -``` - -4. Add the pr_agent folder to your PYTHONPATH, then run the cli.py script: - -``` -export PYTHONPATH=[$PYTHONPATH:] -python pr_agent/cli.py --pr_url review -python pr_agent/cli.py --pr_url ask -python pr_agent/cli.py --pr_url describe -python pr_agent/cli.py --pr_url improve -``` - ---- - ### Method 4: Run as a polling server Request reviews by tagging your Github user on a PR @@ -253,7 +253,7 @@ docker push codiumai/pr-agent:github_app # Push to your Docker repository > **Note:** When running PR-Agent from GitHub App, the default configuration file (configuration.toml) will be loaded.
> However, you can override the default tool parameters by uploading a local configuration file
-> For more information please check out [CONFIGURATION.md](CONFIGURATION.md#working-from-github-app-pre-built-repo) +> For more information please check out [CONFIGURATION.md](Usage.md#working-from-github-app-pre-built-repo) --- ### Method 6 - Deploy as a Lambda Function diff --git a/README.md b/README.md index d0f8e9db..cdd2688f 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull - [Overview](#overview) - [Try it now](#try-it-now) - [Installation](#installation) -- [Configuration](./CONFIGURATION.md) +- [Usage guide](./Usage.md) - [How it works](#how-it-works) - [Why use PR-Agent](#why-use-pr-agent) - [Roadmap](#roadmap) @@ -117,7 +117,7 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull | | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | Incremental PR Review | :white_check_mark: | | | | | -Review the **[configuration](./CONFIGURATION.md)** section for detailed instructions how to use the different tools, select the relevant git provider (GitHub, Gitlab, Bitbucket,...), and adjust the configuration file to your needs. +Review the **[usage guide](./Usage.md)** section for detailed instructions how to use the different tools, select the relevant git provider (GitHub, Gitlab, Bitbucket,...), and adjust the configuration file to your needs. ## Try it now @@ -145,8 +145,8 @@ To get started with PR-Agent quickly, you first need to acquire two tokens: There are several ways to use PR-Agent: - [Method 1: Use Docker image (no installation required)](INSTALL.md#method-1-use-docker-image-no-installation-required) -- [Method 2: Run as a GitHub Action](INSTALL.md#method-2-run-as-a-github-action) -- [Method 3: Run from source](INSTALL.md#method-3-run-from-source) +- [Method 2: Run from source](INSTALL.md#method-2-run-from-source) +- [Method 3: Run as a GitHub Action](INSTALL.md#method-3-run-as-a-github-action) - [Method 4: Run as a polling server](INSTALL.md#method-4-run-as-a-polling-server) - Request reviews by tagging your GitHub user on a PR - [Method 5: Run as a GitHub App](INSTALL.md#method-5-run-as-a-github-app) @@ -170,7 +170,7 @@ Here are some advantages of PR-Agent: - We emphasize **real-life practical usage**. Each tool (review, improve, ask, ...) has a single GPT-4 call, no more. We feel that this is critical for realistic team usage - obtaining an answer quickly (~30 seconds) and affordably. - Our [PR Compression strategy](./PR_COMPRESSION.md) is a core ability that enables to effectively tackle both short and long PRs. -- Our JSON prompting strategy enables to have **modular, customizable tools**. For example, the '/review' tool categories can be controlled via the [configuration](./CONFIGURATION.md) file. Adding additional categories is easy and accessible. +- Our JSON prompting strategy enables to have **modular, customizable tools**. For example, the '/review' tool categories can be controlled via the [configuration](pr_agent/settings/configuration.toml) file. Adding additional categories is easy and accessible. - We support **multiple git providers** (GitHub, Gitlab, Bitbucket, CodeCommit), **multiple ways** to use the tool (CLI, GitHub Action, GitHub App, Docker, ...), and **multiple models** (GPT-4, GPT-3.5, Anthropic, Cohere, Llama2). - We are open-source, and welcome contributions from the community. diff --git a/CONFIGURATION.md b/Usage.md similarity index 62% rename from CONFIGURATION.md rename to Usage.md index b02c7e2b..baca3db9 100644 --- a/CONFIGURATION.md +++ b/Usage.md @@ -1,20 +1,39 @@ -## Configuration +## Usage guide +### Introduction + +There are 3 basic ways to invoke CodiumAI PR-Agent: +1. Locally running a CLI command +2. Online usage - by [commenting](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901) on a PR +3. Enabling PR-Agent specific tools to run automatically when a new PR is opened + +See the [installation guide](/INSTALL.md) for instructions on how to install and run your own PR-Agent. + +Specifically, CLI commands can be issued by invoking a pre-built [docker image](/INSTALL.md#running-from-source), or by invoking a [locally cloned repo](INSTALL.md#method-2-run-from-source) + +For online usage, you will need to setup either a [GitHub App](INSTALL.md#method-5-run-as-a-github-app), or a [GitHub Action](INSTALL.md#method-3-run-as-a-github-action). +GitHub App and GitHub Action also enable to run PR-Agent specific tool automatically when a new PR is opened. + + +#### The configuration file The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** +In addition to general configuration options, each tool has its own configurations. For example, the 'review' tool will use parameters from the `[pr_reviewer]` section in the [configuration file](/pr_agent/settings/configuration.toml#L16) +** git provider:** The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: ` "github", "gitlab", "azure", "codecommit", "local" ` +** online usage:** Options that are available in the configuration file can be specified at run time when calling actions. Two examples: ``` - /review --pr_reviewer.extra_instructions="focus on the file: ..." - /describe --pr_description.add_original_user_description=false -pr_description.extra_instructions="make sure to mention: ..." ``` -### Working from CLI -When running from source (CLI), your local configuration file will be used. +### Working from a local repo (CLI) +When running from your local repo (CLI), your local configuration file, which you can edit, will be used. Examples for invoking the different tools via the CLI: @@ -28,8 +47,10 @@ Examples for invoking the different tools via the CLI: `` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). **Notes:** - -(1) In addition to general configuration options, each tool has its own configurations. For example, the 'review' tool will use parameters from the `[pr_reviewer]` section in the [configuration file](/pr_agent/settings/configuration.toml#L16) +(1) in addition to editing the configuration file, you can also override any configuration by adding it to the command line: +``` +python cli.py --pr_url= review --pr_reviewer.extra_instructions="focus on the file: ..." +``` (2) You can print results locally, without publishing them, by setting in `configuration.toml`: ``` @@ -39,10 +60,32 @@ verbosity_level=2 ``` This is useful for debugging or experimenting with the different tools. -### Working from GitHub App (pre-built repo) -When running PR-Agent from GitHub App, the default configuration file (`configuration.toml`) will be initially loaded. -#### GitHub app default tools +### Online usage + +Online usage means invoking PR-Agent tools by [comments](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901) on a PR. +Commands for invoking the different tools via comments: + +- **Review**: `/review` +- **Describe**: `/describe` +- **Improve**: `/improve` +- **Ask**: `/ask "Write me a poem about this PR"` +- **Reflect**: `/reflect` +- **Update Changelog**: `/update_changelog` + + +To edit a specific configuration value, just add `--config_path=` to any command. +For example if you want to edit the `review` tool configurations, you can run: +``` +/review --pr_reviewer.extra_instructions="..." --pr_reviewer.require_score_review=false ... +``` +Any configuration value in [configuration file](pr_agent/settings/configuration.toml) file can be similarly edited. + + +### Working with GitHub App +When running PR-Agent from [GitHub App](INSTALL.md#method-5-run-as-a-github-app), the default configuration file of a pre-built repo will be initially loaded. + +#### GitHub app automatic tools The `[github_app]` section defines the GitHub app specific configurations. An important parameter is `pr_commands`, which is a list of tools that will be **run automatically when a new PR is opened**: ``` @@ -62,7 +105,7 @@ For example, if your local `.pr_agent.toml` file contains: add_original_user_description = false keep_original_user_title = false ``` -Then when a new PR is opened, PR-Agent will run the `describe` tool with the above parameters. +When a new PR is opened, PR-Agent will run the `describe` tool with the above parameters. Note that a local `.pr_agent.toml` file enables you to edit and customize the default parameters of any tool, not just the ones that are run automatically. @@ -84,16 +127,10 @@ user=""" ``` Note that the new prompt will need to generate an output compatible with the relevant [post-process function](./pr_agent/tools/pr_description.py#L137). -#### Online usage -For online usage (calling tools by comments on a PR like `/ask ...`), just add `--config_path=` to any command, to edit a specific configuration value. -For example if you want to edit `pr_reviewer` configurations, you can run: -``` -/review --pr_reviewer.extra_instructions="..." --pr_reviewer.require_score_review=false ... -``` -Any configuration value in `configuration.toml` file can be similarly edited. +### Working with GitHub Action +TBD - -### General configuration walkthrough +### Appendix - general configuration walkthrough #### Changing a model See [here](pr_agent/algo/__init__.py) for the list of available models. From 990f69a95d9664e7138ebc54bd1dfd849be3da70 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sat, 2 Sep 2023 09:25:38 +0300 Subject: [PATCH 27/36] update README.md --- Usage.md | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Usage.md b/Usage.md index baca3db9..f54ef26f 100644 --- a/Usage.md +++ b/Usage.md @@ -5,9 +5,9 @@ There are 3 basic ways to invoke CodiumAI PR-Agent: 1. Locally running a CLI command 2. Online usage - by [commenting](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901) on a PR -3. Enabling PR-Agent specific tools to run automatically when a new PR is opened +3. Enabling PR-Agent tools to run automatically when a new PR is opened -See the [installation guide](/INSTALL.md) for instructions on how to install and run your own PR-Agent. +See the [installation guide](/INSTALL.md) for instructions on how to setup your own PR-Agent. Specifically, CLI commands can be issued by invoking a pre-built [docker image](/INSTALL.md#running-from-source), or by invoking a [locally cloned repo](INSTALL.md#method-2-run-from-source) @@ -17,7 +17,7 @@ GitHub App and GitHub Action also enable to run PR-Agent specific tool automatic #### The configuration file The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** -In addition to general configuration options, each tool has its own configurations. For example, the 'review' tool will use parameters from the `[pr_reviewer]` section in the [configuration file](/pr_agent/settings/configuration.toml#L16) +In addition to general configuration options, each tool has its own configurations. For example, the `review` tool will use parameters from the `[pr_reviewer]` section in the [configuration file](/pr_agent/settings/configuration.toml#L16) ** git provider:** The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: @@ -25,12 +25,17 @@ The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configu "github", "gitlab", "azure", "codecommit", "local" ` -** online usage:** -Options that are available in the configuration file can be specified at run time when calling actions. Two examples: -``` -- /review --pr_reviewer.extra_instructions="focus on the file: ..." -- /describe --pr_description.add_original_user_description=false -pr_description.extra_instructions="make sure to mention: ..." -``` +[//]: # (** online usage:**) + +[//]: # (Options that are available in the configuration file can be specified at run time when calling actions. Two examples:) + +[//]: # (```) + +[//]: # (- /review --pr_reviewer.extra_instructions="focus on the file: ...") + +[//]: # (- /describe --pr_description.add_original_user_description=false -pr_description.extra_instructions="make sure to mention: ...") + +[//]: # (```) ### Working from a local repo (CLI) When running from your local repo (CLI), your local configuration file, which you can edit, will be used. @@ -47,7 +52,7 @@ Examples for invoking the different tools via the CLI: `` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). **Notes:** -(1) in addition to editing the configuration file, you can also override any configuration by adding it to the command line: +(1) in addition to editing the configuration file, you can also override any configuration value by adding it to the command line: ``` python cli.py --pr_url= review --pr_reviewer.extra_instructions="focus on the file: ..." ``` @@ -83,10 +88,10 @@ Any configuration value in [configuration file](pr_agent/settings/configuration. ### Working with GitHub App -When running PR-Agent from [GitHub App](INSTALL.md#method-5-run-as-a-github-app), the default configuration file of a pre-built repo will be initially loaded. +When running PR-Agent from [GitHub App](INSTALL.md#method-5-run-as-a-github-app), the default configurations of a pre-built repo will be initially loaded. #### GitHub app automatic tools -The `[github_app]` section defines the GitHub app specific configurations. +The `[github_app]` section of the [configuration file](pr_agent/settings/configuration.toml) defines GitHub app specific configurations. An important parameter is `pr_commands`, which is a list of tools that will be **run automatically when a new PR is opened**: ``` [github_app] @@ -112,8 +117,8 @@ Note that a local `.pr_agent.toml` file enables you to edit and customize the de #### Editing the prompts The prompts for the various PR-Agent tools are defined in the `pr_agent/settings` folder. -In practice, the prompts are loaded and stored as a standard setting object. Hence, -editing them is similar to editing any other configuration value - just place the relevant key in `.pr_agent.toml`file, and override the default value. +In practice, the prompts are loaded and stored as a standard setting object. +Hence, editing them is similar to editing any other configuration value - just place the relevant key in `.pr_agent.toml`file, and override the default value. For example, if you want to edit the prompts of the [describe](./pr_agent/settings/pr_description_prompts.toml) tool, you can add the following to your `.pr_agent.toml` file: ``` @@ -130,7 +135,7 @@ Note that the new prompt will need to generate an output compatible with the rel ### Working with GitHub Action TBD -### Appendix - general configuration walkthrough +### Appendix - additional configurations walkthrough #### Changing a model See [here](pr_agent/algo/__init__.py) for the list of available models. From 1f7a833a540e60cab531696d992b54e0ecd352b9 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sat, 2 Sep 2023 09:33:33 +0300 Subject: [PATCH 28/36] update README.md --- Usage.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Usage.md b/Usage.md index f54ef26f..c1277103 100644 --- a/Usage.md +++ b/Usage.md @@ -8,9 +8,7 @@ There are 3 basic ways to invoke CodiumAI PR-Agent: 3. Enabling PR-Agent tools to run automatically when a new PR is opened See the [installation guide](/INSTALL.md) for instructions on how to setup your own PR-Agent. - Specifically, CLI commands can be issued by invoking a pre-built [docker image](/INSTALL.md#running-from-source), or by invoking a [locally cloned repo](INSTALL.md#method-2-run-from-source) - For online usage, you will need to setup either a [GitHub App](INSTALL.md#method-5-run-as-a-github-app), or a [GitHub Action](INSTALL.md#method-3-run-as-a-github-action). GitHub App and GitHub Action also enable to run PR-Agent specific tool automatically when a new PR is opened. @@ -19,7 +17,7 @@ GitHub App and GitHub Action also enable to run PR-Agent specific tool automatic The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** In addition to general configuration options, each tool has its own configurations. For example, the `review` tool will use parameters from the `[pr_reviewer]` section in the [configuration file](/pr_agent/settings/configuration.toml#L16) -** git provider:** +**git provider:** The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: ` "github", "gitlab", "azure", "codecommit", "local" @@ -38,7 +36,7 @@ The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configu [//]: # (```) ### Working from a local repo (CLI) -When running from your local repo (CLI), your local configuration file, which you can edit, will be used. +When running from your local repo (CLI), your local configuration file will be used. Examples for invoking the different tools via the CLI: @@ -52,7 +50,7 @@ Examples for invoking the different tools via the CLI: `` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). **Notes:** -(1) in addition to editing the configuration file, you can also override any configuration value by adding it to the command line: +(1) in addition to editing your local configuration file, you can also change any configuration value by adding it to the command line: ``` python cli.py --pr_url= review --pr_reviewer.extra_instructions="focus on the file: ..." ``` @@ -74,7 +72,7 @@ Commands for invoking the different tools via comments: - **Review**: `/review` - **Describe**: `/describe` - **Improve**: `/improve` -- **Ask**: `/ask "Write me a poem about this PR"` +- **Ask**: `/ask "..."` - **Reflect**: `/reflect` - **Update Changelog**: `/update_changelog` @@ -82,7 +80,7 @@ Commands for invoking the different tools via comments: To edit a specific configuration value, just add `--config_path=` to any command. For example if you want to edit the `review` tool configurations, you can run: ``` -/review --pr_reviewer.extra_instructions="..." --pr_reviewer.require_score_review=false ... +/review --pr_reviewer.extra_instructions="..." --pr_reviewer.require_score_review=false ``` Any configuration value in [configuration file](pr_agent/settings/configuration.toml) file can be similarly edited. @@ -91,7 +89,7 @@ Any configuration value in [configuration file](pr_agent/settings/configuration. When running PR-Agent from [GitHub App](INSTALL.md#method-5-run-as-a-github-app), the default configurations of a pre-built repo will be initially loaded. #### GitHub app automatic tools -The `[github_app]` section of the [configuration file](pr_agent/settings/configuration.toml) defines GitHub app specific configurations. +The [github_app](pr_agent/settings/configuration.toml#L56) section defines GitHub app specific configurations. An important parameter is `pr_commands`, which is a list of tools that will be **run automatically when a new PR is opened**: ``` [github_app] From 9567199bb2b723b17dad03113fa951e2282d952b Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sat, 2 Sep 2023 09:37:44 +0300 Subject: [PATCH 29/36] update README.md --- Usage.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Usage.md b/Usage.md index c1277103..329bba54 100644 --- a/Usage.md +++ b/Usage.md @@ -8,14 +8,16 @@ There are 3 basic ways to invoke CodiumAI PR-Agent: 3. Enabling PR-Agent tools to run automatically when a new PR is opened See the [installation guide](/INSTALL.md) for instructions on how to setup your own PR-Agent. -Specifically, CLI commands can be issued by invoking a pre-built [docker image](/INSTALL.md#running-from-source), or by invoking a [locally cloned repo](INSTALL.md#method-2-run-from-source) + +Specifically, CLI commands can be issued by invoking a pre-built [docker image](/INSTALL.md#running-from-source), or by invoking a [locally cloned repo](INSTALL.md#method-2-run-from-source). + For online usage, you will need to setup either a [GitHub App](INSTALL.md#method-5-run-as-a-github-app), or a [GitHub Action](INSTALL.md#method-3-run-as-a-github-action). GitHub App and GitHub Action also enable to run PR-Agent specific tool automatically when a new PR is opened. #### The configuration file -The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)** -In addition to general configuration options, each tool has its own configurations. For example, the `review` tool will use parameters from the `[pr_reviewer]` section in the [configuration file](/pr_agent/settings/configuration.toml#L16) +The different tools and sub-tools used by CodiumAI PR-Agent are adjustable via the **[configuration file](pr_agent/settings/configuration.toml)**. +In addition to general configuration options, each tool has its own configurations. For example, the `review` tool will use parameters from the [pr_reviewer](/pr_agent/settings/configuration.toml#L16) section in the configuration file. **git provider:** The [git_provider](pr_agent/settings/configuration.toml#L4) field in the configuration file determines the GIT provider that will be used by PR-Agent. Currently, the following providers are supported: @@ -50,6 +52,7 @@ Examples for invoking the different tools via the CLI: `` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). **Notes:** + (1) in addition to editing your local configuration file, you can also change any configuration value by adding it to the command line: ``` python cli.py --pr_url= review --pr_reviewer.extra_instructions="focus on the file: ..." @@ -86,7 +89,7 @@ Any configuration value in [configuration file](pr_agent/settings/configuration. ### Working with GitHub App -When running PR-Agent from [GitHub App](INSTALL.md#method-5-run-as-a-github-app), the default configurations of a pre-built repo will be initially loaded. +When running PR-Agent from [GitHub App](INSTALL.md#method-5-run-as-a-github-app), the default configurations from a pre-built repo will be initially loaded. #### GitHub app automatic tools The [github_app](pr_agent/settings/configuration.toml#L56) section defines GitHub app specific configurations. From 544bac70109fdaf848abb9dd28fb3ac64d7e4416 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sat, 2 Sep 2023 09:43:46 +0300 Subject: [PATCH 30/36] update README.md --- Usage.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Usage.md b/Usage.md index 329bba54..12ff23aa 100644 --- a/Usage.md +++ b/Usage.md @@ -1,5 +1,13 @@ ## Usage guide +### Table of Contents +- [Introduction](#introduction) +- [Working from a local repo (CLI)](#working-from-a-local-repo-cli) +- [Online usage](#online-usage) +- [Working with GitHub App](#working-with-github-app) +- [Working with GitHub Action](#working-with-github-action) +- [Appendix - additional configurations walkthrough](#appendix---additional-configurations-walkthrough) + ### Introduction There are 3 basic ways to invoke CodiumAI PR-Agent: From 0203086aac2bdb12bc8bf858cdafdbe37bd004f0 Mon Sep 17 00:00:00 2001 From: Phill Zarfos Date: Sat, 2 Sep 2023 15:39:57 -0400 Subject: [PATCH 31/36] removed duplicate swift statement --- pr_agent/git_providers/git_provider.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pr_agent/git_providers/git_provider.py b/pr_agent/git_providers/git_provider.py index 4651d47d..330590a1 100644 --- a/pr_agent/git_providers/git_provider.py +++ b/pr_agent/git_providers/git_provider.py @@ -161,7 +161,6 @@ def get_main_pr_language(languages, files) -> str: most_common_extension == 'scala' and top_language == 'scala' or \ most_common_extension == 'kt' and top_language == 'kotlin' or \ most_common_extension == 'pl' and top_language == 'perl' or \ - most_common_extension == 'swift' and top_language == 'swift' or \ most_common_extension == top_language: main_language_str = top_language From 916d7c236ed167028b1149f8e2407b8b77fb57a4 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Sun, 3 Sep 2023 11:16:20 +0300 Subject: [PATCH 32/36] update README.md --- INSTALL.md | 8 ++++---- README.md | 30 +++++++++++++++--------------- Usage.md | 14 +++++++------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 37bee57e..74368ac0 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -81,10 +81,10 @@ chmod 600 pr_agent/settings/.secrets.toml ``` export PYTHONPATH=[$PYTHONPATH:] -python pr_agent/cli.py --pr_url review -python pr_agent/cli.py --pr_url ask -python pr_agent/cli.py --pr_url describe -python pr_agent/cli.py --pr_url improve +python pr_agent/cli.py --pr_url /review +python pr_agent/cli.py --pr_url /ask +python pr_agent/cli.py --pr_url /describe +python pr_agent/cli.py --pr_url /improve ``` --- diff --git a/README.md b/README.md index cdd2688f..f946a59c 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,20 @@ Making pull requests less painful with an AI agent CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull requests faster and more efficiently. It automatically analyzes the pull request and can provide several types of PR feedback: -**Auto-Description**: Automatically generating [PR description](https://github.com/Codium-ai/pr-agent/pull/229#issue-1860711415) - title, type, summary, code walkthrough and labels. +**Auto Description (/describe)**: Automatically generating [PR description](https://github.com/Codium-ai/pr-agent/pull/229#issue-1860711415) - title, type, summary, code walkthrough and labels. \ -**Auto Review**: [Adjustable feedback](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695022908) about the PR main theme, type, relevant tests, security issues, score, and various suggestions for the PR content. +**Auto Review (/review)**: [Adjustable feedback](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695022908) about the PR main theme, type, relevant tests, security issues, score, and various suggestions for the PR content. \ -**Question Answering**: Answering [free-text questions](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021332) about the PR. +**Question Answering (/ask ...)**: Answering [free-text questions](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021332) about the PR. \ -**Code Suggestions**: [Committable code suggestions](https://github.com/Codium-ai/pr-agent/pull/229#discussion_r1306919276) for improving the PR. +**Code Suggestions (/improve)**: [Committable code suggestions](https://github.com/Codium-ai/pr-agent/pull/229#discussion_r1306919276) for improving the PR. \ -**Update Changelog**: Automatically updating the CHANGELOG.md file with the [PR changes](https://github.com/Codium-ai/pr-agent/pull/168#discussion_r1282077645). +**Update Changelog (/update_changelog)**: Automatically updating the CHANGELOG.md file with the [PR changes](https://github.com/Codium-ai/pr-agent/pull/168#discussion_r1282077645). -

Example results:

+ +See the [usage guide](./Usage.md) for instructions how to run the different tools from [CLI](./Usage.md#working-from-a-local-repo-cli), or by [online usage](./Usage.md#online-usage). + +

Example results:

/describe:

@@ -36,16 +39,13 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull

-[//]: # (

/review:

) -[//]: # (
) +

/review:

+
+

+ +

+
-[//]: # (

) - -[//]: # () - -[//]: # (

) - -[//]: # (
) [//]: # (

/reflect_and_review:

) [//]: # (
) diff --git a/Usage.md b/Usage.md index 12ff23aa..336de974 100644 --- a/Usage.md +++ b/Usage.md @@ -50,12 +50,12 @@ When running from your local repo (CLI), your local configuration file will be u Examples for invoking the different tools via the CLI: -- **Review**: `python cli.py --pr_url= review` -- **Describe**: `python cli.py --pr_url= describe` -- **Improve**: `python cli.py --pr_url= improve` -- **Ask**: `python cli.py --pr_url= ask "Write me a poem about this PR"` -- **Reflect**: `python cli.py --pr_url= reflect` -- **Update Changelog**: `python cli.py --pr_url= update_changelog` +- **Review**: `python cli.py --pr_url= /review` +- **Describe**: `python cli.py --pr_url= /describe` +- **Improve**: `python cli.py --pr_url= /improve` +- **Ask**: `python cli.py --pr_url= /ask "Write me a poem about this PR"` +- **Reflect**: `python cli.py --pr_url= /reflect` +- **Update Changelog**: `python cli.py --pr_url= /update_changelog` `` is the url of the relevant PR (for example: https://github.com/Codium-ai/pr-agent/pull/50). @@ -63,7 +63,7 @@ Examples for invoking the different tools via the CLI: (1) in addition to editing your local configuration file, you can also change any configuration value by adding it to the command line: ``` -python cli.py --pr_url= review --pr_reviewer.extra_instructions="focus on the file: ..." +python cli.py --pr_url= /review --pr_reviewer.extra_instructions="focus on the file: ..." ``` (2) You can print results locally, without publishing them, by setting in `configuration.toml`: From ae3d7067d353e3a890b163f6a908101dc771a915 Mon Sep 17 00:00:00 2001 From: Phill Zarfos Date: Sun, 3 Sep 2023 09:22:08 -0400 Subject: [PATCH 33/36] implemented 'improve' command for CodeCommit --- README.md | 4 +- pr_agent/git_providers/codecommit_client.py | 54 +++++++++++++++---- pr_agent/git_providers/codecommit_provider.py | 42 ++++++++++++--- tests/unittest/test_codecommit_client.py | 2 +- 4 files changed, 82 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index f946a59c..5bf7d52e 100644 --- a/README.md +++ b/README.md @@ -101,8 +101,8 @@ See the [usage guide](./Usage.md) for instructions how to run the different tool | TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | Auto-Description | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | -| | Improve Code | :white_check_mark: | :white_check_mark: | | | | -| | ⮑ Extended | :white_check_mark: | :white_check_mark: | | | | +| | Improve Code | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | +| | ⮑ Extended | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | | | Reflect and Review | :white_check_mark: | | | | :white_check_mark: | | | Update CHANGELOG.md | :white_check_mark: | | | | | | | | | | | | | diff --git a/pr_agent/git_providers/codecommit_client.py b/pr_agent/git_providers/codecommit_client.py index 6200340d..1112ee22 100644 --- a/pr_agent/git_providers/codecommit_client.py +++ b/pr_agent/git_providers/codecommit_client.py @@ -90,7 +90,11 @@ class CodeCommitClient: ): differences.extend(page.get("differences", [])) except botocore.exceptions.ClientError as e: - raise ValueError(f"Failed to retrieve differences from CodeCommit PR #{self.pr_num}") from e + if e.response["Error"]["Code"] == 'RepositoryDoesNotExistException': + raise ValueError(f"CodeCommit cannot retrieve differences: Repository does not exist: {repo_name}") from e + raise ValueError(f"CodeCommit cannot retrieve differences for {source_commit}..{destination_commit}") from e + except Exception as e: + raise ValueError(f"CodeCommit cannot retrieve differences for {source_commit}..{destination_commit}") from e output = [] for json in differences: @@ -122,6 +126,8 @@ class CodeCommitClient: try: response = self.boto_client.get_file(repositoryName=repo_name, commitSpecifier=sha_hash, filePath=file_path) except botocore.exceptions.ClientError as e: + if e.response["Error"]["Code"] == 'RepositoryDoesNotExistException': + raise ValueError(f"CodeCommit cannot retrieve PR: Repository does not exist: {repo_name}") from e # if the file does not exist, but is flagged as optional, then return an empty string if optional and e.response["Error"]["Code"] == 'FileDoesNotExistException': return "" @@ -133,11 +139,12 @@ class CodeCommitClient: return response.get("fileContent", "") - def get_pr(self, pr_number: int): + def get_pr(self, repo_name: str, pr_number: int): """ Get a information about a CodeCommit PR. Args: + - repo_name: Name of the repository - pr_number: The PR number you are requesting Returns: @@ -155,6 +162,8 @@ class CodeCommitClient: except botocore.exceptions.ClientError as e: if e.response["Error"]["Code"] == 'PullRequestDoesNotExistException': raise ValueError(f"CodeCommit cannot retrieve PR: PR number does not exist: {pr_number}") from e + if e.response["Error"]["Code"] == 'RepositoryDoesNotExistException': + raise ValueError(f"CodeCommit cannot retrieve PR: Repository does not exist: {repo_name}") from e raise ValueError(f"CodeCommit cannot retrieve PR: {pr_number}: boto client error") from e except Exception as e: raise ValueError(f"CodeCommit cannot retrieve PR: {pr_number}") from e @@ -201,7 +210,7 @@ class CodeCommitClient: except Exception as e: raise ValueError(f"Error calling publish_description") from e - def publish_comment(self, repo_name: str, pr_number: int, destination_commit: str, source_commit: str, comment: str): + def publish_comment(self, repo_name: str, pr_number: int, destination_commit: str, source_commit: str, comment: str, annotation_file: str = None, annotation_line: int = None): """ Publish a comment to a pull request @@ -210,7 +219,13 @@ class CodeCommitClient: - pr_number: number of the pull request - destination_commit: The commit hash you want to merge into (the "before" hash) (usually on the main or master branch) - source_commit: The commit hash of the code you are adding (the "after" branch) - - pr_comment: comment + - comment: The comment you want to publish + - annotation_file: The file you want to annotate (optional) + - annotation_line: The line number you want to annotate (optional) + + Comment annotations for CodeCommit are different than GitHub. + CodeCommit only designates the starting line number for the comment. + It does not support the ending line number to highlight a range of lines. Returns: - None @@ -223,13 +238,30 @@ class CodeCommitClient: self._connect_boto_client() try: - self.boto_client.post_comment_for_pull_request( - pullRequestId=str(pr_number), - repositoryName=repo_name, - beforeCommitId=destination_commit, - afterCommitId=source_commit, - content=comment, - ) + # If the comment has code annotations, + # then set the file path and line number in the location dictionary + if annotation_file and annotation_line: + self.boto_client.post_comment_for_pull_request( + pullRequestId=str(pr_number), + repositoryName=repo_name, + beforeCommitId=destination_commit, + afterCommitId=source_commit, + content=comment, + location={ + "filePath": annotation_file, + "filePosition": annotation_line, + "relativeFileVersion": "AFTER", + }, + ) + else: + # The comment does not have code annotations + self.boto_client.post_comment_for_pull_request( + pullRequestId=str(pr_number), + repositoryName=repo_name, + beforeCommitId=destination_commit, + afterCommitId=source_commit, + content=comment, + ) except botocore.exceptions.ClientError as e: if e.response["Error"]["Code"] == 'RepositoryDoesNotExistException': raise ValueError(f"Repository does not exist: {repo_name}") from e diff --git a/pr_agent/git_providers/codecommit_provider.py b/pr_agent/git_providers/codecommit_provider.py index d43409c3..1f570a1a 100644 --- a/pr_agent/git_providers/codecommit_provider.py +++ b/pr_agent/git_providers/codecommit_provider.py @@ -180,10 +180,37 @@ class CodeCommitProvider(GitProvider): comment=pr_comment, ) except Exception as e: - raise ValueError(f"CodeCommit Cannot post comment for PR: {self.pr_num}") from e + raise ValueError(f"CodeCommit Cannot publish comment for PR: {self.pr_num}") from e def publish_code_suggestions(self, code_suggestions: list) -> bool: - return [""] # not implemented yet + counter = 1 + for suggestion in code_suggestions: + # Verify that each suggestion has the required keys + if not all(key in suggestion for key in ["body", "relevant_file", "relevant_lines_start"]): + logging.warning(f"Skipping code suggestion #{counter}: Each suggestion must have 'body', 'relevant_file', 'relevant_lines_start' keys") + continue + + # Publish the code suggestion to CodeCommit + try: + logging.debug(f"Code Suggestion #{counter} in file: {suggestion['relevant_file']}: {suggestion['relevant_lines_start']}") + self.codecommit_client.publish_comment( + repo_name=self.repo_name, + pr_number=self.pr_num, + destination_commit=self.pr.destination_commit, + source_commit=self.pr.source_commit, + comment=suggestion["body"], + annotation_file=suggestion["relevant_file"], + annotation_line=suggestion["relevant_lines_start"], + ) + except Exception as e: + raise ValueError(f"CodeCommit Cannot publish code suggestions for PR: {self.pr_num}") from e + + counter += 1 + + # The calling function passes in a list of code suggestions, and this function publishes each suggestion one at a time. + # If we were to return False here, the calling function will attempt to publish the same list of code suggestions again, one at a time. + # Since this function publishes the suggestions one at a time anyway, we always return True here to avoid the retry. + return True def publish_labels(self, labels): return [""] # not implemented yet @@ -195,6 +222,7 @@ class CodeCommitProvider(GitProvider): return "" # not implemented yet def publish_inline_comment(self, body: str, relevant_file: str, relevant_line_in_file: str): + # https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/codecommit/client/post_comment_for_compared_commit.html raise NotImplementedError("CodeCommit provider does not support publishing inline comments yet") def create_inline_comment(self, body: str, relevant_file: str, relevant_line_in_file: str): @@ -255,9 +283,11 @@ class CodeCommitProvider(GitProvider): return self.codecommit_client.get_file(self.repo_name, settings_filename, self.pr.source_commit, optional=True) def add_eyes_reaction(self, issue_comment_id: int) -> Optional[int]: + logging.info("CodeCommit provider does not support eyes reaction yet") return True def remove_reaction(self, issue_comment_id: int, reaction_id: int) -> bool: + logging.info("CodeCommit provider does not support removing reactions yet") return True @staticmethod @@ -315,16 +345,16 @@ class CodeCommitProvider(GitProvider): return re.match(r"^[a-z]{2}-(gov-)?[a-z]+-\d\.console\.aws\.amazon\.com$", hostname) is not None def _get_pr(self): - response = self.codecommit_client.get_pr(self.pr_num) + response = self.codecommit_client.get_pr(self.repo_name, self.pr_num) if len(response.targets) == 0: raise ValueError(f"No files found in CodeCommit PR: {self.pr_num}") - # TODO: implement support for multiple commits in one CodeCommit PR - # for now, we are only using the first commit in the PR + # TODO: implement support for multiple targets in one CodeCommit PR + # for now, we are only using the first target in the PR if len(response.targets) > 1: logging.warning( - "Multiple commits in one PR is not supported for CodeCommit yet. Continuing, using the first commit only..." + "Multiple targets in one PR is not supported for CodeCommit yet. Continuing, using the first target only..." ) # Return our object that mimics PullRequest class from the PyGithub library diff --git a/tests/unittest/test_codecommit_client.py b/tests/unittest/test_codecommit_client.py index 5d09bdd1..0aa1ffa6 100644 --- a/tests/unittest/test_codecommit_client.py +++ b/tests/unittest/test_codecommit_client.py @@ -125,7 +125,7 @@ class TestCodeCommitProvider: } } - pr = api.get_pr(321) + pr = api.get_pr("my_test_repo", 321) assert pr.title == "My PR" assert pr.description == "My PR description" From 7584ec84ce5a5d403de4457dae1cebc39730cacc Mon Sep 17 00:00:00 2001 From: Telepenin Nikolay Date: Mon, 4 Sep 2023 15:48:18 +0100 Subject: [PATCH 34/36] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c440fd37..e75b0c53 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ CodiumAI `PR-Agent` is an open-source tool aiming to help developers review pull | | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | Auto-Description | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | | | Improve Code | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | -| | ⮑ Extended | :white_check_mark: | :white_check_mark: | | | +| | ⮑ Extended | :white_check_mark: | :white_check_mark: | | | :white_check_mark: | | | Reflect and Review | :white_check_mark: | | | | :white_check_mark: | | | Update CHANGELOG.md | :white_check_mark: | | | | | | | | | | | From 53ce6092662680ed9618db4ec158ee4504c166a0 Mon Sep 17 00:00:00 2001 From: Nikolay Telepenin Date: Mon, 4 Sep 2023 15:49:30 +0100 Subject: [PATCH 35/36] Msg is mandatory field for the request --- pr_agent/git_providers/gerrit_provider.py | 2 +- pr_agent/servers/gerrit_server.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pr_agent/git_providers/gerrit_provider.py b/pr_agent/git_providers/gerrit_provider.py index 480809b0..03faf2a1 100644 --- a/pr_agent/git_providers/gerrit_provider.py +++ b/pr_agent/git_providers/gerrit_provider.py @@ -350,7 +350,7 @@ class GerritProvider(GitProvider): msg.append(f'* {description}\n{full_path}') if msg: - add_comment(self.parsed_url, self.refspec, "---\n".join(msg)) + add_comment(self.parsed_url, self.refspec, "\n".join(msg)) return True def publish_comment(self, pr_comment: str, is_temporary: bool = False): diff --git a/pr_agent/servers/gerrit_server.py b/pr_agent/servers/gerrit_server.py index 9bb6f16b..04232ea9 100644 --- a/pr_agent/servers/gerrit_server.py +++ b/pr_agent/servers/gerrit_server.py @@ -30,7 +30,7 @@ class Action(str, Enum): class Item(BaseModel): refspec: str project: str - msg: str = "" + msg: str @router.post("/api/v1/gerrit/{action}") @@ -46,7 +46,7 @@ async def handle_gerrit_request(action: Action, item: Item): ) await PRAgent().handle_request( f"{item.project}:{item.refspec}", - f"/{action.value} {item.msg.strip()}" + f"/{item.msg.strip()}" ) From 4a54532b6a19aa0c9a367d32709505adb326e95f Mon Sep 17 00:00:00 2001 From: Nikolay Telepenin Date: Tue, 5 Sep 2023 09:09:35 +0100 Subject: [PATCH 36/36] Set github provider by default - merge README.md --- README.md | 29 ++++++++++++++-------------- pr_agent/settings/configuration.toml | 2 +- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 5bf7d52e..c6f14497 100644 --- a/README.md +++ b/README.md @@ -96,26 +96,27 @@ See the [usage guide](./Usage.md) for instructions how to run the different tool ## Overview `PR-Agent` offers extensive pull request functionalities across various git providers: -| | | GitHub | Gitlab | Bitbucket | CodeCommit | Azure DevOps | -|-------|---------------------------------------------|:------:|:------:|:---------:|:----------:|:----------:| -| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: -| | Auto-Description | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | -| | Improve Code | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | -| | ⮑ Extended | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | -| | Reflect and Review | :white_check_mark: | | | | :white_check_mark: | -| | Update CHANGELOG.md | :white_check_mark: | | | | | +| | | GitHub | Gitlab | Bitbucket | CodeCommit | Azure DevOps | Gerrit | +|-------|---------------------------------------------|:------:|:------:|:---------:|:----------:|:----------:|:----------:| +| TOOLS | Review | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Ask | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Auto-Description | :white_check_mark: | :white_check_mark: | | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Improve Code | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | +| | ⮑ Extended | :white_check_mark: | :white_check_mark: | | :white_check_mark: | | :white_check_mark: | +| | Reflect and Review | :white_check_mark: | | | | :white_check_mark: | :white_check_mark: | +| | Update CHANGELOG.md | :white_check_mark: | | | | | | | | | | | | | | | USAGE | CLI | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | | | App / webhook | :white_check_mark: | :white_check_mark: | | | | | | Tagging bot | :white_check_mark: | | | | | | | Actions | :white_check_mark: | | | | | +| | Web server | | | | | | :white_check_mark: | | | | | | | | | -| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| | Incremental PR Review | :white_check_mark: | | | | | +| CORE | PR compression | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Repo language prioritization | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Adaptive and token-aware
file patch fitting | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Multiple models support | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| | Incremental PR Review | :white_check_mark: | | | | | | Review the **[usage guide](./Usage.md)** section for detailed instructions how to use the different tools, select the relevant git provider (GitHub, Gitlab, Bitbucket,...), and adjust the configuration file to your needs. diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 4dfc80c8..c46412ed 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -1,7 +1,7 @@ [config] model="gpt-4" fallback_models=["gpt-3.5-turbo-16k"] -git_provider="gerrit" +git_provider="github" publish_output=true publish_output_progress=true verbosity_level=0 # 0,1,2