Compare commits

...

180 Commits

Author SHA1 Message Date
db5138dc42 Improve YAML parsing with additional fallback strategies for AI predictions 2025-05-17 20:38:05 +03:00
Tal
9a9feb47a6 Merge pull request #1786 from qodo-ai/pr-1736
Pr 1736
2025-05-17 15:29:23 +03:00
52ce74a31a Remove debug print statements from repository filtering tests 2025-05-16 17:25:10 +03:00
f47da75e6f Remove debug print statement from should_process_pr_logic function 2025-05-16 17:23:27 +03:00
42557feb97 Enhance repository filtering with regex pattern matching for ignore_repositories 2025-05-16 17:20:54 +03:00
Tal
c15fb16528 Merge pull request #1779 from dnnspaul/main
Enable usage of OpenAI like APIs
2025-05-16 16:59:18 +03:00
Tal
d268db5f0d Merge pull request #1778 from smartandhandsome/main
Cleanup: Remove Unused import and Fix Parameter Typo
2025-05-16 16:54:55 +03:00
Tal
ec626f0193 Merge pull request #1785 from qodo-ai/tr/gemini-2.5-pro-preview-05-06
Add Gemini-2.5-pro-preview-05-06 model and update litellm dependency
2025-05-16 16:53:50 +03:00
9974015682 Add Gemini-2.5-pro-preview-05-06 model and update litellm dependency 2025-05-16 16:32:45 +03:00
250870a3da enable usage of openai like apis 2025-05-15 16:05:05 +02:00
a3c9fbbf2c revert try except 2025-05-15 19:40:40 +09:00
c79b655864 Fix typo in method parameter name 2025-05-15 18:42:08 +09:00
e55fd64bda Remove unnecessary nested try-except block for cleaner code. Streamlined the import statement to remove an unused reference to get_git_provider. 2025-05-15 18:41:39 +09:00
b6a401bcc2 Merge remote-tracking branch 'origin/main' 2025-05-14 07:35:17 +03:00
72bcb0ec4c docs: add Gemini-2.5-flash-preview benchmark comparisons to PR benchmark table 2025-05-14 07:35:09 +03:00
Tal
35d75e996f Merge pull request #1770 from dst03106/fix/add-ttl-when-callback-enabled
fix: add timeout to asyncio.wait during CLI execution to avoid hanging when callback is enabled
2025-05-13 18:33:56 +03:00
d3262d37e1 Merge pull request #1767 from qodo-ai/hl/manual_more_suggestions_docs
docs: enhance improve.md with manual suggestions for Bitbucket and Gi…
2025-05-13 18:19:56 +03:00
3ddd53d4fe docs: add link to example model card in benchmark documentation 2025-05-13 11:48:01 +03:00
e2af22d2a0 Log a warning for pending asyncio tasks with coroutine details 2025-05-13 17:37:09 +09:00
d86d1ef3dc Log a warning when there are pending asyncio tasks
Co-authored-by: qodo-merge-pro-for-open-source[bot] <189517486+qodo-merge-pro-for-open-source[bot]@users.noreply.github.com>
2025-05-13 17:34:30 +09:00
eb449202c9 Merge remote-tracking branch 'origin/main' 2025-05-13 11:31:57 +03:00
90c46bb2dd docs: update link to "Changing a model" documentation page 2025-05-13 11:31:28 +03:00
Tal
ad35e7dc07 Merge pull request #1771 from qodo-ai/tr/new_benchmark
Tr/new benchmark
2025-05-13 11:18:34 +03:00
Tal
87f4783fa0 Update docs/mkdocs.yml
Co-authored-by: qodo-merge-pro-for-open-source[bot] <189517486+qodo-merge-pro-for-open-source[bot]@users.noreply.github.com>
2025-05-13 09:11:06 +03:00
f0fa27535c docs: improve model comparison headings in benchmark documentation 2025-05-13 09:07:46 +03:00
cbfbfa662d docs: enhance benchmark table with colored win rates and improve comparison headings 2025-05-13 09:05:07 +03:00
3ec5bc12b7 s 2025-05-13 08:53:03 +03:00
e7317ce99f Add timeout to asyncio.wait 2025-05-13 14:46:50 +09:00
25530a8b2c docs: add benchmark methodology and improve model comparison formatting 2025-05-13 08:39:19 +03:00
489a16a3e6 docs: reorganize documentation structure and move PR benchmark section 2025-05-13 08:05:36 +03:00
b334bcd250 docs: enhance improve.md with manual suggestions for Bitbucket and GitLab 2025-05-12 16:54:28 +03:00
Tal
9cc6d37165 Merge pull request #1764 from twdkeule/bugfix/markdown-link-in-prompt
Changelog prompt: fix markdown link
2025-05-12 16:01:28 +03:00
Tal
bcbb3ac228 Merge pull request #1746 from twdkeule/feature/azure-devops-persistent-comment
Implement Azure Devops persistent comment
2025-05-12 15:56:12 +03:00
d6aaf8a709 docs: Update "Apply this suggestion" to "Apply / Chat" 2025-05-12 11:13:01 +03:00
db0c213d72 AzureDevops webhook: allow disabling BasicAuth
Azure webhooks do not allow BasicAuth without HTTPS
2025-05-12 09:00:36 +02:00
954d61e5dc Azure: refactor publish_code_suggestions() to use azure classes 2025-05-12 09:00:36 +02:00
24a90cab8e Azure: handle inline /ask 2025-05-12 09:00:17 +02:00
d6a7c89762 docs: add Gemini-2.5-pro-preview vs GPT-4.1 benchmark comparison 2025-05-12 09:53:59 +03:00
67272700a6 Azure: handle line comments 2025-05-12 08:31:15 +02:00
3a07b55d0c Azure: dont start threads as active because they block the pull request 2025-05-12 08:31:15 +02:00
c924affebc Azure devops provider: add persistent comment 2025-05-12 08:31:15 +02:00
e516d66c1c Azure: return Comment object when creating comment 2025-05-12 08:31:15 +02:00
212c72eb7d Changelog prompt: fix markdown link 2025-05-12 08:26:19 +02:00
bd911b67d8 docs: add Gemini-2.5-pro-preview model comparison to benchmark documentation 2025-05-12 08:11:57 +03:00
c5bcc21a61 docs: update timestamp label for clarity on recent updates page 2025-05-11 17:32:07 +03:00
Tal
eb1138148b Merge pull request #1762 from qodo-ai/tr/docker_action
fix: update Docker base image to slim version and install required de…
2025-05-11 17:20:27 +03:00
Tal
4210262e27 Update Dockerfile.github_action
Co-authored-by: qodo-merge-pro-for-open-source[bot] <189517486+qodo-merge-pro-for-open-source[bot]@users.noreply.github.com>
2025-05-11 17:19:58 +03:00
df0d065705 fix: update Docker base image to slim version and install required dependencies 2025-05-11 17:17:58 +03:00
Tal
682ceaa5db Merge pull request #1761 from qodo-ai/tr/recent_updates
docs: add recent updates and future roadmap section to documentation
2025-05-11 12:40:19 +03:00
90445342b3 docs: fix typo in scan repo discussions tool name and add help docs tool 2025-05-11 12:35:50 +03:00
22e4276f1a docs: fix typo in scan repo discussions tool name and add help docs tool 2025-05-11 12:33:55 +03:00
0e102a4ad5 docs: add recent updates and future roadmap section to documentation 2025-05-11 11:53:22 +03:00
91b3f2ee80 docs: improve improve tool documentation with visual section headers 2025-05-11 11:12:58 +03:00
Tal
850583acb4 Merge pull request #1758 from joosomi/fix/pr-description-type-header
fix: avoid duplicate header for list types to prevent markdown break
2025-05-11 11:06:42 +03:00
Tal
38a81dd691 Merge pull request #1760 from isExample/fix/local-configuration-file-description
docs: clarify that .pr_agent.toml can be updated post PR creation
2025-05-11 11:06:35 +03:00
Tal
ccf8182c53 Merge pull request #1757 from qodo-ai/of/new_tab_to_improve_tool
docs: improve readability of improve tool documentation with tabs
2025-05-11 11:05:06 +03:00
Tal
f1e02e311d Merge pull request #1759 from qodo-ai/tr/feedback_on_draft_pr
docs: add information about feedback on draft PRs
2025-05-11 11:02:58 +03:00
6596f782e1 docs: clarify that .pr_agent.toml can be updated post PR creation 2025-05-10 16:05:37 +09:00
Tal
943fe57231 Merge pull request #1753 from jihan-chillin/fix/logger-artifact-key
fix:correct typo in logger parameter from 'artifacts' to 'artifact'
2025-05-10 08:50:59 +03:00
625085a0f8 docs: add information about feedback on draft PRs 2025-05-09 16:16:26 +03:00
57eaba0e75 fix: ensure string conversion for list elements 2025-05-09 21:33:42 +09:00
6062c99c47 fix: avoid duplicate header for list types to prevent markdown break 2025-05-09 21:20:04 +09:00
171be6727a docs: fix typos and improve wording in improve tool documentation 2025-05-09 14:53:03 +03:00
b658986a5e docs: improve readability of improve tool documentation with tabs 2025-05-09 14:24:07 +03:00
c357f09967 fix:correct typo in logger parameter from 'artifacts' to 'artifact' 2025-05-09 11:12:04 +09:00
Tal
36307e66f1 Merge pull request #1749 from simonstamm/main
fix(gitlab): trigger when MR changes from draft to ready
2025-05-08 19:18:53 +03:00
Tal
8bc39c0120 Merge pull request #1745 from MaxnSter/fix/extra_instruction
fix: Prevent duplicate language instructions in extra_instructions
2025-05-08 19:04:53 +03:00
Tal
f5857f0fde Merge pull request #1744 from irfansofyana/openrouter-support
Openrouter support
2025-05-08 19:02:02 +03:00
Tal
0c21d4a48a Merge pull request #1742 from twdkeule/feature/parse-azure-url
Azure devops: parse PR url starting from the end
2025-05-08 19:00:32 +03:00
38f00386b4 fix(gitlab): trigger when MR changes from draft to ready 2025-05-08 12:50:54 +02:00
a11e97b5f5 fix: Prevent duplicate language instructions in extra_instructions 2025-05-07 18:26:12 +08:00
4a8722acd5 docs: Add tip about using keywords to direct the agent in code suggestions 2025-05-07 11:21:59 +03:00
5061fb5a24 docs: add support for openrouter 2025-05-07 12:04:45 +07:00
7a6a28d2b9 feat: add openrouter support in litellm 2025-05-07 11:54:07 +07:00
df1d859e54 Azure devops: parse PR url starting from the end 2025-05-06 15:01:48 +02:00
f85587fb1f docs: add configuration options for best practices in improve tool 2025-05-04 17:47:25 +03:00
Tal
e9924eab89 Merge pull request #1737 from qodo-ai/of/update-fallback-model
doc: title refinement
2025-05-04 16:45:07 +03:00
f0db5cb43b revert model fixation 2025-05-04 16:35:14 +03:00
Tal
8bb207f0bd Merge pull request #1738 from qodo-ai/tr/docker_slim
Use slim Docker image and install git and curl dependencies
2025-05-02 09:20:11 +03:00
5a3010389d Optimize Docker image by cleaning apt cache after installing dependencies 2025-05-02 09:16:43 +03:00
8edacf08bb Use slim Docker image and install git and curl dependencies 2025-05-02 09:13:21 +03:00
914d053801 improve.md: refine a sub-title 2025-05-01 08:38:21 +03:00
897a5c66fa Update fallback model 2025-05-01 08:31:19 +03:00
d606672801 Add ignore_repositories config for PR filtering
What Changed?
* Added support to ignore PRs/MRs from specific repositories in GitHub, Bitbucket, and GitLab webhook logic
* Updated configuration.toml to include ignore_repositories option
* Added unit tests for ignore_repositories across all supported providers
2025-04-30 14:09:40 -07:00
ef9e0b1f12 Merge pull request #1735 from qodo-ai/of/read-me-updatea
docs: add data privacy and contributing sections to README and update news
2025-04-30 19:33:37 +03:00
968d2ee39b docs: add data privacy and contributing sections to README and update news 2025-04-30 17:00:13 +03:00
b09eec265e docs: clarify that RAG capability is exclusive to specific tools 2025-04-30 13:29:45 +03:00
ed5b8e7828 Merge remote-tracking branch 'origin/main' 2025-04-30 11:15:00 +03:00
056adc6545 Update documentation for improve tool by removing GitHub link and clarifying text 2025-04-30 11:14:50 +03:00
75a047f348 docs: add clarification about RAG capability tools list 2025-04-30 10:49:05 +03:00
Tal
14ad0445f5 Merge pull request #1731 from Yash-1511/docs/update-gemini
docs: update Gemini model path from google_ai_studio to gemini in con…
2025-04-30 10:44:10 +03:00
Tal
bf16fcd0fb Merge pull request #1728 from barnett-yuxiang/fix/reportInvalidTypeForm
Fix type hint for get_pr_description method and clean up whitespace
2025-04-30 10:43:06 +03:00
63f50bc162 docs: convert RAG context enrichment applications to tabbed format 2025-04-30 09:14:45 +03:00
bfca4f2515 docs: update Gemini model path from google_ai_studio to gemini in configuration docs 2025-04-29 20:57:41 +05:30
7b82b08173 fix: correct grammar in Qodo Merge orchestrator agent description 2025-04-29 12:35:10 +03:00
3dc0cac975 docs: Chat on code suggestions: Add interactive code suggestions documentation with tabbed examples 2025-04-29 09:12:20 +03:00
4cbd265082 Merge pull request #1727 from qodo-ai/of/gan-and-chat-updates
Add documentation for chat on code suggestions with example image and update RAG platform support
2025-04-28 19:05:16 +03:00
e69b17cb1a Update code suggestion chat documentation with orchestrator agent description 2025-04-28 13:59:44 +03:00
26dc3b7f21 Update code suggestion chat documentation with multi-node agent description 2025-04-28 13:02:54 +03:00
4ad43c48e5 Fix type hint for get_pr_description method and clean up whitespace 2025-04-28 17:59:09 +08:00
ab0e3bde49 Remove extra blank lines in improve.md documentation 2025-04-28 08:52:06 +03:00
1c3629d4c2 Add documentation for chat on code suggestions with example image and update RAG platform support 2025-04-28 08:50:58 +03:00
cbe03b82fe Remove Help Docs entry and update Auto Best Practices platform support 2025-04-27 16:15:46 +03:00
9926a10b00 Add Help Docs, Code Validation, and Auto Best Practices features to platform support tables 2025-04-27 15:58:14 +03:00
Tal
f137509c78 Merge pull request #1718 from barnett-yuxiang/fix/poetry-install-error
Update .gitignore and fix license format in pyproject.toml
2025-04-27 11:17:35 +03:00
Tal
43f9a6fc17 Merge pull request #1721 from bananana0118/fix-typo-in-docs
Docs: fix typo in response_language setting inside .pr-agent.toml configuration guide
2025-04-27 11:16:13 +03:00
Tal
1b0aa16282 Merge pull request #1726 from qodo-ai/tr/multi_model_prompt
Tr/multi model prompt
2025-04-27 11:15:39 +03:00
f505c7ad3c Add multi-model support for different reasoning tasks 2025-04-27 11:00:34 +03:00
c951fc9a87 Improve dynamic context handling with partial line matching and adjust model configuration 2025-04-27 10:46:23 +03:00
3f194e6730 Improve dynamic context handling in git patch processing 2025-04-27 10:07:56 +03:00
f53bd524c5 Support multiple model types for different reasoning tasks 2025-04-27 08:50:03 +03:00
60a887ffe1 Improve code suggestion prompts for clarity, accuracy, and evaluation criteria 2025-04-27 08:42:28 +03:00
bb8e606f93 docs: fix spacing after equals sign in TOML example 2025-04-25 14:55:31 +09:00
9549289a71 docs: fix typo in response_language setting 2025-04-25 14:51:15 +09:00
ff00e303cc docs: fix typo in documentation about config response_language from pr-agent.toml 2025-04-25 14:38:37 +09:00
31e5517833 Merge remote-tracking branch 'origin/main' 2025-04-24 18:05:57 +03:00
4ff2bd176b Fix typo in Qodo Merge bot detection documentation 2025-04-24 18:05:48 +03:00
Tal
8684baf050 Merge pull request #1719 from qodo-ai/of/docs-improve-free-chat
Add documentation for chat functionality in code suggestions
2025-04-24 17:43:58 +03:00
68737b6432 Add platform support indicators for chat on code suggestions feature 2025-04-24 15:39:48 +03:00
4a231f8933 Add documentation for chat functionality in code suggestions 2025-04-24 15:32:01 +03:00
87532cf68c Add documentation about preserving original PR descriptions in Qodo Merge 2025-04-24 14:59:58 +03:00
9df0f71d4a Update .gitignore and fix license format in pyproject.toml 2025-04-24 16:14:02 +08:00
dedad94a20 Fix code indentation in get_review_thread_comments method 2025-04-24 09:34:51 +03:00
5d5b57255e Merge pull request #1687 from benedict-lee/feat/add-conversation-history-on-line-question
Improvement: Enhance ask_line tool by adding PR review comment threads as context
2025-04-24 09:32:43 +03:00
6ceea2b134 Clarify Qodo Merge's exclusive features and bot handling behavior 2025-04-24 08:28:23 +03:00
c35942c12b mprove get_review_thread_comments method implementation
Co-authored-by: ofir-frd <85901822+ofir-frd@users.noreply.github.com>
2025-04-24 11:23:16 +09:00
ddb94ec9b4 mprove get_review_thread_comments method implementation
Co-authored-by: ofir-frd <85901822+ofir-frd@users.noreply.github.com>
2025-04-24 11:22:43 +09:00
29d4fe510e Improve get_review_thread_comments method implementation
Co-authored-by: ofir-frd <85901822+ofir-frd@users.noreply.github.com>
2025-04-24 11:21:49 +09:00
7d17ed5b7f fix linting 2025-04-23 21:15:00 +03:00
Tal
47e46ee001 Merge pull request #1715 from qodo-ai/tr/improve_prompts
Improve field descriptions for code suggestion model clarity and brevity
2025-04-22 14:22:03 +03:00
1aa0186f5c Improve field descriptions for code suggestion model clarity and brevity 2025-04-22 14:19:54 +03:00
4685c25209 Merge remote-tracking branch 'origin/main' 2025-04-22 10:57:03 +03:00
fe0d5df145 Improve documentation formatting and navigation features 2025-04-22 10:56:53 +03:00
15b2b57677 Uncomment search plugin in mkdocs configuration 2025-04-22 08:49:30 +03:00
8a45e41749 Update Qodo Merge documentation with consistent heading capitalization 2025-04-22 08:14:53 +03:00
581f35db99 Update Qodo Merge documentation with detailed licensing information 2025-04-22 08:12:40 +03:00
fef0bc6146 Update Qodo Merge documentation with detailed licensing information 2025-04-22 08:09:49 +03:00
9906ec3687 Improve conversation history formatting with numbered comments 2025-04-21 17:14:36 +09:00
8b4bf49f1c Improve conversation history handling and prompts for line questions 2025-04-21 16:50:37 +09:00
e11c2e1c7f Reorganize imports according to Python conventions 2025-04-21 16:30:27 +09:00
a434d0af9b Improve comment thread retrieval by using in_reply_to_id instead of line numbers 2025-04-21 16:28:42 +09:00
Tal
baf361f0f0 Merge pull request #1712 from qodo-ai/tr/multi_model
Update model references from o3-mini to o4-mini and add Gemini models
2025-04-19 09:29:02 +03:00
4ac0aa56e5 Update model references from o3-mini to o4-mini and add Gemini models 2025-04-19 09:26:35 +03:00
Tal
ca88ec96d6 Merge pull request #1710 from PeterDaveHelloKitchen/SwitchDefaultTo-o4-mini
Replace default o3-mini with o4-mini
2025-04-19 09:00:35 +03:00
e854383123 Replace default o3-mini with o4-mini 2025-04-19 03:52:10 +08:00
Tal
1327a4437d Merge pull request #1711 from nicohein/feature/simplified-bitbucket-pipeline
Feature/simplified bitbucket pipeline
2025-04-18 21:51:49 +03:00
002c71f1ba Merge branch 'qodo-ai:main' into feature/simplified-bitbucket-pipeline 2025-04-18 14:44:28 -04:00
2fa4438310 docs: itemization fix 2025-04-18 14:42:51 -04:00
e41050d39c Merge remote-tracking branch 'origin/main' 2025-04-18 21:40:50 +03:00
5e98926b5a Update scan_repo_discussions.md to clarify focus on best practices 2025-04-18 21:40:39 +03:00
Tal
a459e8c8e1 Merge pull request #1703 from nicohein/feature/simplified-bitbucket-pipeline
docs: updated bitbucket pipeline docs
2025-04-18 21:26:54 +03:00
Tal
151daa070f Merge pull request #1709 from PeterDaveHelloKitchen/Ignore.venv
Add .venv/ to .dockerignore and .gitignore for virtual env compatibility
2025-04-18 21:19:06 +03:00
Tal
11ebbc994f Merge pull request #1708 from PeterDaveHelloKitchen/UpgradeLiteLLM
Upgrade litellm to v1.66.3
2025-04-18 21:18:31 +03:00
Tal
f177ff4214 Merge pull request #1707 from dst03106/feature/add-support-for-mistral-and-codestral
Add support for Mistral and Codestral models
2025-04-18 21:17:27 +03:00
Tal
8f6edadbeb Merge pull request #1704 from DongjaJ/ci/update-github-actions-versions
Update GitHub actions version
2025-04-18 21:11:03 +03:00
Tal
246f372e4a Merge pull request #1706 from PeterDaveHelloKitchen/ImproveDocs
Improve markdown docs formatting for consistency and readability
2025-04-18 21:10:47 +03:00
e6ee2b96e2 Add .venv/ to .dockerignore and .gitignore for virtual env compatibility
Include .venv/ alongside venv/ to align with common Python virtual
environment practices as recommended in the official documentation.
2025-04-18 21:43:05 +08:00
fab4717449 Upgrade litellm to v1.66.3 2025-04-18 20:27:46 +08:00
869a179506 feat: add support for Mistral and Codestral models 2025-04-18 14:04:59 +09:00
f0fc777a44 Improve markdown docs formatting for consistency and readability 2025-04-18 03:34:20 +08:00
Tal
58f6943b12 Merge pull request #1705 from qodo-ai/tr/basic_auth
Add Basic Authentication method for Jira Data Center/Server and valid…
2025-04-17 19:14:47 +03:00
999d03f7aa Add Basic Authentication method for Jira Data Center/Server and validation script 2025-04-17 18:51:50 +03:00
2628f2a997 Upgrade litellm to v1.66.2 2025-04-17 23:37:33 +08:00
6cf0ae0731 ci: Upgrade Codecov action to v5 in workflow files 2025-04-17 23:05:47 +09:00
be957cd2ea ci: Upgrade docker/build-push-action to v6 in workflow files 2025-04-17 23:05:10 +09:00
8ad3eb583a ci: Upgrade Docker Buildx action to v3 in workflow files 2025-04-17 23:02:48 +09:00
2e18053e02 ci: Update actions/checkout to v4 in workflow files 2025-04-17 22:57:18 +09:00
Tal
696cdc3b45 Merge pull request #1702 from PeterDaveHelloKitchen/add-o3-and-o4-mini
Add OpenAI o3 & 4o-mini reasoning models
2025-04-17 11:00:00 +03:00
e5df079dce docs: updated bitbucket pipeline docs to make direct use of the pr-agent image without docker in docker 2025-04-16 18:01:58 -04:00
4e3e963ce5 Add OpenAI o3 & 4o-mini reasoning models
Reference:
- https://platform.openai.com/docs/models/o3
- https://platform.openai.com/docs/models/o4-mini
- https://openai.com/index/introducing-o3-and-o4-mini/
2025-04-17 02:32:14 +08:00
bc3ef4763d Update scan_repo_discussions.md to include links and customization notes 2025-04-16 14:17:59 +03:00
Tal
c332a8866b Merge pull request #1701 from qodo-ai/tr/scan_repo_discussions_docs
Add new tool for scanning repository discussions and generating best …
2025-04-16 13:45:35 +03:00
717b03de6e Fix link to Scan Repo Discussions tool in index.md 2025-04-16 13:43:37 +03:00
a5cb0e48fe Fix link to Scan Repo Discussions tool in index.md 2025-04-16 13:42:18 +03:00
7704379e62 Add new tool for scanning repository discussions and generating best practices 2025-04-16 13:39:52 +03:00
9c06b6b266 Apply PR review feedback: Code style and functionality improvements 2025-04-10 21:56:37 +09:00
c5165d917b refactor: Validate all required parameters before proceeding
Co-authored-by: ofir-frd <85901822+ofir-frd@users.noreply.github.com>
2025-04-10 19:59:34 +09:00
6bf093a6a1 refactor: Add GitHub provider check for conversation history
Co-authored-by: ofir-frd <85901822+ofir-frd@users.noreply.github.com>
2025-04-10 19:41:43 +09:00
8952459f6d Update pr_agent/tools/pr_line_questions.py
Co-authored-by: Prateek <110811408+Prateikx@users.noreply.github.com>
2025-04-10 08:48:59 +09:00
b53d2773a9 improve ask_line tool(add conversation history context) 2025-04-09 23:45:04 +09:00
103 changed files with 1790 additions and 789 deletions

View File

@ -1,3 +1,4 @@
.venv/
venv/ venv/
pr_agent/settings/.secrets.toml pr_agent/settings/.secrets.toml
pics/ pics/

View File

@ -14,15 +14,15 @@ jobs:
steps: steps:
- id: checkout - id: checkout
uses: actions/checkout@v2 uses: actions/checkout@v4
- id: dockerx - id: dockerx
name: Setup Docker Buildx name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- id: build - id: build
name: Build dev docker name: Build dev docker
uses: docker/build-push-action@v2 uses: docker/build-push-action@v6
with: with:
context: . context: .
file: ./docker/Dockerfile file: ./docker/Dockerfile

View File

@ -15,15 +15,15 @@ jobs:
steps: steps:
- id: checkout - id: checkout
uses: actions/checkout@v2 uses: actions/checkout@v4
- id: dockerx - id: dockerx
name: Setup Docker Buildx name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- id: build - id: build
name: Build dev docker name: Build dev docker
uses: docker/build-push-action@v2 uses: docker/build-push-action@v6
with: with:
context: . context: .
file: ./docker/Dockerfile file: ./docker/Dockerfile
@ -41,7 +41,6 @@ jobs:
docker cp test_container:/app/coverage.xml coverage.xml docker cp test_container:/app/coverage.xml coverage.xml
docker rm test_container docker rm test_container
- name: Validate coverage report - name: Validate coverage report
run: | run: |
if [ ! -f coverage.xml ]; then if [ ! -f coverage.xml ]; then
@ -49,6 +48,6 @@ jobs:
exit 1 exit 1
fi fi
- name: Upload coverage to Codecov - name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1 uses: codecov/codecov-action@v5
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}

View File

@ -11,14 +11,14 @@ jobs:
name: PR-Agent E2E GitHub App Test name: PR-Agent E2E GitHub App Test
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v4
- name: Setup Docker Buildx - name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- id: build - id: build
name: Build dev docker name: Build dev docker
uses: docker/build-push-action@v2 uses: docker/build-push-action@v6
with: with:
context: . context: .
file: ./docker/Dockerfile file: ./docker/Dockerfile
@ -32,14 +32,13 @@ jobs:
- id: test1 - id: test1
name: E2E test github app name: E2E test github app
run: | run: |
docker run -e GITHUB.USER_TOKEN=${{ secrets.TOKEN_GITHUB }} --rm codiumai/pr-agent:test pytest -v tests/e2e_tests/test_github_app.py docker run -e GITHUB.USER_TOKEN=${{ secrets.TOKEN_GITHUB }} --rm codiumai/pr-agent:test pytest -v tests/e2e_tests/test_github_app.py
- id: test2 - id: test2
name: E2E gitlab webhook name: E2E gitlab webhook
run: | run: |
docker run -e gitlab.PERSONAL_ACCESS_TOKEN=${{ secrets.TOKEN_GITLAB }} --rm codiumai/pr-agent:test pytest -v tests/e2e_tests/test_gitlab_webhook.py docker run -e gitlab.PERSONAL_ACCESS_TOKEN=${{ secrets.TOKEN_GITLAB }} --rm codiumai/pr-agent:test pytest -v tests/e2e_tests/test_gitlab_webhook.py
- id: test3 - id: test3
name: E2E bitbucket app name: E2E bitbucket app
run: | run: |

View File

@ -11,7 +11,7 @@ jobs:
pre-commit: pre-commit:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/setup-python@v5 - uses: actions/setup-python@v5
# SEE https://github.com/pre-commit/action # SEE https://github.com/pre-commit/action
- uses: pre-commit/action@v3.0.1 - uses: pre-commit/action@v3.0.1

2
.gitignore vendored
View File

@ -2,6 +2,7 @@
.lsp/ .lsp/
.vscode/ .vscode/
.env .env
.venv/
venv/ venv/
pr_agent/settings/.secrets.toml pr_agent/settings/.secrets.toml
__pycache__ __pycache__
@ -11,3 +12,4 @@ build/
.DS_Store .DS_Store
docs/.cache/ docs/.cache/
.qodo .qodo
poetry.lock

View File

@ -1,6 +1,7 @@
## 2023-08-03 ## 2023-08-03
### Optimized ### Optimized
- Optimized PR diff processing by introducing caching for diff files, reducing the number of API calls. - Optimized PR diff processing by introducing caching for diff files, reducing the number of API calls.
- Refactored `load_large_diff` function to generate a patch only when necessary. - Refactored `load_large_diff` function to generate a patch only when necessary.
- Fixed a bug in the GitLab provider where the new file was not retrieved correctly. - Fixed a bug in the GitLab provider where the new file was not retrieved correctly.
@ -8,6 +9,7 @@
## 2023-08-02 ## 2023-08-02
### Enhanced ### Enhanced
- Updated several tools in the `pr_agent` package to use commit messages in their functionality. - Updated several tools in the `pr_agent` package to use commit messages in their functionality.
- Commit messages are now retrieved and stored in the `vars` dictionary for each tool. - Commit messages are now retrieved and stored in the `vars` dictionary for each tool.
- Added a section to display the commit messages in the prompts of various tools. - Added a section to display the commit messages in the prompts of various tools.
@ -15,6 +17,7 @@
## 2023-08-01 ## 2023-08-01
### Enhanced ### Enhanced
- Introduced the ability to retrieve commit messages from pull requests across different git providers. - Introduced the ability to retrieve commit messages from pull requests across different git providers.
- Implemented commit messages retrieval for GitHub and GitLab providers. - Implemented commit messages retrieval for GitHub and GitLab providers.
- Updated the PR description template to include a section for commit messages if they exist. - Updated the PR description template to include a section for commit messages if they exist.
@ -22,10 +25,10 @@
- Implemented this feature for both GitHub and GitLab providers. - Implemented this feature for both GitHub and GitLab providers.
- Added a new configuration option 'use_repo_settings_file' to enable or disable the use of a repo-specific settings file. - Added a new configuration option 'use_repo_settings_file' to enable or disable the use of a repo-specific settings file.
## 2023-07-30 ## 2023-07-30
### Enhanced ### Enhanced
- Added the ability to modify any configuration parameter from 'configuration.toml' on-the-fly. - Added the ability to modify any configuration parameter from 'configuration.toml' on-the-fly.
- Updated the command line interface and bot commands to accept configuration changes as arguments. - Updated the command line interface and bot commands to accept configuration changes as arguments.
- Improved the PR agent to handle additional arguments for each action. - Improved the PR agent to handle additional arguments for each action.
@ -33,6 +36,7 @@
## 2023-07-28 ## 2023-07-28
### Improved ### Improved
- Enhanced error handling and logging in the GitLab provider. - Enhanced error handling and logging in the GitLab provider.
- Improved handling of inline comments and code suggestions in GitLab. - Improved handling of inline comments and code suggestions in GitLab.
- Fixed a bug where an additional unneeded line was added to code suggestions in GitLab. - Fixed a bug where an additional unneeded line was added to code suggestions in GitLab.
@ -40,6 +44,7 @@
## 2023-07-26 ## 2023-07-26
### Added ### Added
- New feature for updating the CHANGELOG.md based on the contents of a PR. - New feature for updating the CHANGELOG.md based on the contents of a PR.
- Added support for this feature for the Github provider. - Added support for this feature for the Github provider.
- New configuration settings and prompts for the changelog update feature. - New configuration settings and prompts for the changelog update feature.

View File

@ -42,4 +42,3 @@ with regard to the reporter of an incident.
This Code of Conduct is adapted from the This Code of Conduct is adapted from the
[Contributor Covenant](https://contributor-covenant.org), version 1.3.0, available at [Contributor Covenant](https://contributor-covenant.org), version 1.3.0, available at
[contributor-covenant.org/version/1/3/0/](https://contributor-covenant.org/version/1/3/0/) [contributor-covenant.org/version/1/3/0/](https://contributor-covenant.org/version/1/3/0/)

View File

@ -1,6 +1,6 @@
# Contributing to PR-Agent # Contributing to PR-Agent
Thank you for your interest in contributing to the PR-Agent project! Thank you for your interest in contributing to the PR-Agent project!
## Getting Started ## Getting Started

View File

@ -1,4 +1,6 @@
FROM python:3.12 as base FROM python:3.12.10-slim AS base
RUN apt-get update && apt-get install --no-install-recommends -y git curl && apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
ADD pyproject.toml . ADD pyproject.toml .

152
README.md
View File

@ -2,7 +2,6 @@
<div align="center"> <div align="center">
<picture> <picture>
<source media="(prefers-color-scheme: dark)" srcset="https://www.qodo.ai/wp-content/uploads/2025/02/PR-Agent-Purple-2.png"> <source media="(prefers-color-scheme: dark)" srcset="https://www.qodo.ai/wp-content/uploads/2025/02/PR-Agent-Purple-2.png">
<source media="(prefers-color-scheme: light)" srcset="https://www.qodo.ai/wp-content/uploads/2025/02/PR-Agent-Purple-2.png"> <source media="(prefers-color-scheme: light)" srcset="https://www.qodo.ai/wp-content/uploads/2025/02/PR-Agent-Purple-2.png">
@ -11,9 +10,9 @@
</picture> </picture>
<br/> <br/>
[Installation Guide](https://qodo-merge-docs.qodo.ai/installation/) | [Installation Guide](https://qodo-merge-docs.qodo.ai/installation/) |
[Usage Guide](https://qodo-merge-docs.qodo.ai/usage-guide/) | [Usage Guide](https://qodo-merge-docs.qodo.ai/usage-guide/) |
[Tools Guide](https://qodo-merge-docs.qodo.ai/tools/) | [Tools Guide](https://qodo-merge-docs.qodo.ai/tools/) |
[Qodo Merge](https://qodo-merge-docs.qodo.ai/overview/pr_agent_pro/) 💎 [Qodo Merge](https://qodo-merge-docs.qodo.ai/overview/pr_agent_pro/) 💎
PR-Agent aims to help efficiently review and handle pull requests, by providing AI feedback and suggestions PR-Agent aims to help efficiently review and handle pull requests, by providing AI feedback and suggestions
@ -39,7 +38,6 @@ PR-Agent aims to help efficiently review and handle pull requests, by providing
[//]: # () [//]: # ()
[//]: # (- See the [Tools Guide]&#40;https://qodo-merge-docs.qodo.ai/tools/&#41; for a detailed description of the different tools, and the available configurations for each tool.) [//]: # (- See the [Tools Guide]&#40;https://qodo-merge-docs.qodo.ai/tools/&#41; for a detailed description of the different tools, and the available configurations for each tool.)
## Table of Contents ## Table of Contents
- [News and Updates](#news-and-updates) - [News and Updates](#news-and-updates)
@ -49,83 +47,92 @@ PR-Agent aims to help efficiently review and handle pull requests, by providing
- [Qodo Merge](https://qodo-merge-docs.qodo.ai/overview/pr_agent_pro/) - [Qodo Merge](https://qodo-merge-docs.qodo.ai/overview/pr_agent_pro/)
- [How it works](#how-it-works) - [How it works](#how-it-works)
- [Why use PR-Agent?](#why-use-pr-agent) - [Why use PR-Agent?](#why-use-pr-agent)
- [Data privacy](#data-privacy)
- [Contributing](#contributing)
- [Links](#links)
## News and Updates ## News and Updates
## Apr 30, 2025
A new feature is now available in the `/improve` tool for Qodo Merge 💎 - Chat on code suggestions.
<img width="512" alt="image" src="https://codium.ai/images/pr_agent/improve_chat_on_code_suggestions_ask.png" />
Read more about it [here](https://qodo-merge-docs.qodo.ai/tools/improve/#chat-on-code-suggestions).
## Apr 16, 2025
New tool for Qodo Merge 💎 - `/scan_repo_discussions`.
<img width="635" alt="image" src="https://codium.ai/images/pr_agent/scan_repo_discussions_2.png" />
Read more about it [here](https://qodo-merge-docs.qodo.ai/tools/scan_repo_discussions/).
## Apr 14, 2025 ## Apr 14, 2025
GPT-4.1 is out. And its quite good on coding tasks... GPT-4.1 is out. And it's quite good on coding tasks...
https://openai.com/index/gpt-4-1/ https://openai.com/index/gpt-4-1/
<img width="635" alt="image" src="https://github.com/user-attachments/assets/a8f4c648-a058-4bdc-9825-2a4bb71a23e5" /> <img width="512" alt="image" src="https://github.com/user-attachments/assets/a8f4c648-a058-4bdc-9825-2a4bb71a23e5" />
## March 28, 2025 ## March 28, 2025
A new version, v0.28, was released. See release notes [here](https://github.com/qodo-ai/pr-agent/releases/tag/v0.28). A new version, v0.28, was released. See release notes [here](https://github.com/qodo-ai/pr-agent/releases/tag/v0.28).
This version includes a new tool, [Help Docs](https://qodo-merge-docs.qodo.ai/tools/help_docs/), which can answer free-text questions based on a documentation folder. This version includes a new tool, [Help Docs](https://qodo-merge-docs.qodo.ai/tools/help_docs/), which can answer free-text questions based on a documentation folder.
`/help_docs` is now being used to provide immediate automatic feedback to any user who [opens an issue](https://github.com/qodo-ai/pr-agent/issues/1608#issue-2897328825) on PR-Agent's open-source project `/help_docs` is now being used to provide immediate automatic feedback to any user who [opens an issue](https://github.com/qodo-ai/pr-agent/issues/1608#issue-2897328825) on PR-Agent's open-source project
### Feb 28, 2025
A new version, v0.27, was released. See release notes [here](https://github.com/qodo-ai/pr-agent/releases/tag/v0.27).
### Feb 27, 2025
- Updated the default model to `o3-mini` for all tools. You can still use the `gpt-4o` as the default model by setting the `model` parameter in the configuration file.
- Important updates and bug fixes for Azure DevOps, see [here](https://github.com/qodo-ai/pr-agent/pull/1583)
- Added support for adjusting the [response language](https://qodo-merge-docs.qodo.ai/usage-guide/additional_configurations/#language-settings) of the PR-Agent tools.
### December 30, 2024
Following feedback from the community, we have addressed two vulnerabilities identified in the open-source PR-Agent project. The [fixes](https://github.com/qodo-ai/pr-agent/pull/1425) are now included in the newly released version (v0.26), available as of today.
## Overview ## Overview
<div style="text-align:left;"> <div style="text-align:left;">
Supported commands per platform: Supported commands per platform:
| | | GitHub | GitLab | Bitbucket | Azure DevOps | | | | GitHub | GitLab | Bitbucket | Azure DevOps |
|-------|---------------------------------------------------------------------------------------------------------|:--------------------:|:--------------------:|:---------:|:------------:| | ----- |---------------------------------------------------------------------------------------------------------|:------:|:------:|:---------:|:------------:|
| TOOLS | [Review](https://qodo-merge-docs.qodo.ai/tools/review/) | ✅ | ✅ | ✅ | ✅ | | TOOLS | [Review](https://qodo-merge-docs.qodo.ai/tools/review/) | ✅ | ✅ | ✅ | ✅ |
| | [Describe](https://qodo-merge-docs.qodo.ai/tools/describe/) | ✅ | ✅ | ✅ | ✅ | | | [Describe](https://qodo-merge-docs.qodo.ai/tools/describe/) | ✅ | ✅ | ✅ | ✅ |
| | [Improve](https://qodo-merge-docs.qodo.ai/tools/improve/) | ✅ | ✅ | ✅ | ✅ | | | [Improve](https://qodo-merge-docs.qodo.ai/tools/improve/) | ✅ | ✅ | ✅ | ✅ |
| | [Ask](https://qodo-merge-docs.qodo.ai/tools/ask/) | ✅ | ✅ | ✅ | ✅ | | | [Ask](https://qodo-merge-docs.qodo.ai/tools/ask/) | ✅ | ✅ | ✅ | ✅ |
| | ⮑ [Ask on code lines](https://qodo-merge-docs.qodo.ai/tools/ask/#ask-lines) | ✅ | ✅ | | | | | ⮑ [Ask on code lines](https://qodo-merge-docs.qodo.ai/tools/ask/#ask-lines) | ✅ | ✅ | | |
| | [Update CHANGELOG](https://qodo-merge-docs.qodo.ai/tools/update_changelog/) | ✅ | ✅ | ✅ | ✅ | | | [Update CHANGELOG](https://qodo-merge-docs.qodo.ai/tools/update_changelog/) | ✅ | ✅ | ✅ | ✅ |
| | [Help Docs](https://qodo-merge-docs.qodo.ai/tools/help_docs/?h=auto#auto-approval) | ✅ | ✅ | ✅ | | | | [Help Docs](https://qodo-merge-docs.qodo.ai/tools/help_docs/?h=auto#auto-approval) | ✅ | ✅ | ✅ | |
| | [Ticket Context](https://qodo-merge-docs.qodo.ai/core-abilities/fetching_ticket_context/) 💎 | ✅ | ✅ | ✅ | | | | [Ticket Context](https://qodo-merge-docs.qodo.ai/core-abilities/fetching_ticket_context/) 💎 | ✅ | ✅ | ✅ | |
| | [Utilizing Best Practices](https://qodo-merge-docs.qodo.ai/tools/improve/#best-practices) 💎 | ✅ | ✅ | ✅ | | | | [Utilizing Best Practices](https://qodo-merge-docs.qodo.ai/tools/improve/#best-practices) 💎 | ✅ | ✅ | ✅ | |
| | [PR Chat](https://qodo-merge-docs.qodo.ai/chrome-extension/features/#pr-chat) 💎 | ✅ | | | | | | [PR Chat](https://qodo-merge-docs.qodo.ai/chrome-extension/features/#pr-chat) 💎 | ✅ | | | |
| | [Suggestion Tracking](https://qodo-merge-docs.qodo.ai/tools/improve/#suggestion-tracking) 💎 | ✅ | ✅ | | | | | [Suggestion Tracking](https://qodo-merge-docs.qodo.ai/tools/improve/#suggestion-tracking) 💎 | ✅ | ✅ | | |
| | [CI Feedback](https://qodo-merge-docs.qodo.ai/tools/ci_feedback/) 💎 | ✅ | | | | | | [CI Feedback](https://qodo-merge-docs.qodo.ai/tools/ci_feedback/) 💎 | | | | |
| | [PR Documentation](https://qodo-merge-docs.qodo.ai/tools/documentation/) 💎 | ✅ | ✅ | | | | | [PR Documentation](https://qodo-merge-docs.qodo.ai/tools/documentation/) 💎 | ✅ | ✅ | | |
| | [Custom Labels](https://qodo-merge-docs.qodo.ai/tools/custom_labels/) 💎 | ✅ | ✅ | | | | | [Custom Labels](https://qodo-merge-docs.qodo.ai/tools/custom_labels/) 💎 | ✅ | ✅ | | |
| | [Analyze](https://qodo-merge-docs.qodo.ai/tools/analyze/) 💎 | ✅ | ✅ | | | | | [Analyze](https://qodo-merge-docs.qodo.ai/tools/analyze/) 💎 | ✅ | ✅ | | |
| | [Similar Code](https://qodo-merge-docs.qodo.ai/tools/similar_code/) 💎 | ✅ | | | | | | [Similar Code](https://qodo-merge-docs.qodo.ai/tools/similar_code/) 💎 | | | | |
| | [Custom Prompt](https://qodo-merge-docs.qodo.ai/tools/custom_prompt/) 💎 | ✅ | ✅ | ✅ | | | | [Custom Prompt](https://qodo-merge-docs.qodo.ai/tools/custom_prompt/) 💎 | ✅ | ✅ | ✅ | |
| | [Test](https://qodo-merge-docs.qodo.ai/tools/test/) 💎 | ✅ | ✅ | | | | | [Test](https://qodo-merge-docs.qodo.ai/tools/test/) 💎 | ✅ | ✅ | | |
| | [Implement](https://qodo-merge-docs.qodo.ai/tools/implement/) 💎 | ✅ | ✅ | ✅ | | | | [Implement](https://qodo-merge-docs.qodo.ai/tools/implement/) 💎 | ✅ | ✅ | ✅ | |
| | [Auto-Approve](https://qodo-merge-docs.qodo.ai/tools/improve/?h=auto#auto-approval) 💎 | ✅ | | | | | | [Scan Repo Discussions](https://qodo-merge-docs.qodo.ai/tools/scan_repo_discussions/) 💎 | ✅ | | | |
| | | | | | | | | [Auto-Approve](https://qodo-merge-docs.qodo.ai/tools/improve/?h=auto#auto-approval) 💎 | ✅ | ✅ | | |
| USAGE | [CLI](https://qodo-merge-docs.qodo.ai/usage-guide/automations_and_usage/#local-repo-cli) | ✅ | ✅ | | | | | | | | | |
| | [App / webhook](https://qodo-merge-docs.qodo.ai/usage-guide/automations_and_usage/#github-app) | ✅ | ✅ | ✅ | ✅ | | USAGE | [CLI](https://qodo-merge-docs.qodo.ai/usage-guide/automations_and_usage/#local-repo-cli) | ✅ | ✅ | ✅ | ✅ |
| | [Tagging bot](https://github.com/Codium-ai/pr-agent#try-it-now) | ✅ | | | | | | [App / webhook](https://qodo-merge-docs.qodo.ai/usage-guide/automations_and_usage/#github-app) | | ✅ | | |
| | [Actions](https://qodo-merge-docs.qodo.ai/installation/github/#run-as-a-github-action) | ✅ |✅| || | | [Tagging bot](https://github.com/Codium-ai/pr-agent#try-it-now) | ✅ | | | |
| | | | | | | | | [Actions](https://qodo-merge-docs.qodo.ai/installation/github/#run-as-a-github-action) | ✅ | ✅ | | |
| CORE | [PR compression](https://qodo-merge-docs.qodo.ai/core-abilities/compression_strategy/) | ✅ | ✅ | | | | | | | | | |
| | Adaptive and token-aware file patch fitting | ✅ | ✅ | ✅ | ✅ | | CORE | [PR compression](https://qodo-merge-docs.qodo.ai/core-abilities/compression_strategy/) | ✅ | ✅ | ✅ | ✅ |
| | [Multiple models support](https://qodo-merge-docs.qodo.ai/usage-guide/changing_a_model/) | ✅ | ✅ | ✅ | ✅ | | | Adaptive and token-aware file patch fitting | ✅ | ✅ | ✅ | ✅ |
| | [Local and global metadata](https://qodo-merge-docs.qodo.ai/core-abilities/metadata/) | ✅ || ✅ | | | | [Multiple models support](https://qodo-merge-docs.qodo.ai/usage-guide/changing_a_model/) | ✅ | | ✅ | |
| | [Dynamic context](https://qodo-merge-docs.qodo.ai/core-abilities/dynamic_context/) | ✅ | ✅ | ✅ | | | | [Local and global metadata](https://qodo-merge-docs.qodo.ai/core-abilities/metadata/) | ✅ | | ✅ | |
| | [Self reflection](https://qodo-merge-docs.qodo.ai/core-abilities/self_reflection/) | ✅ ||| ✅ | | | [Dynamic context](https://qodo-merge-docs.qodo.ai/core-abilities/dynamic_context/) | || | |
| | [Static code analysis](https://qodo-merge-docs.qodo.ai/core-abilities/static_code_analysis/) 💎 | ✅ | ✅ | | | | | [Self reflection](https://qodo-merge-docs.qodo.ai/core-abilities/self_reflection/) | | | ✅ | |
| | [Global and wiki configurations](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) 💎 | ✅ | ✅ | | | | | [Static code analysis](https://qodo-merge-docs.qodo.ai/core-abilities/static_code_analysis/) 💎 | ✅ | ✅ | | |
| | [PR interactive actions](https://www.qodo.ai/images/pr_agent/pr-actions.mp4) 💎 | ✅ | | | | | | [Global and wiki configurations](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) 💎 || | | |
| | [Impact Evaluation](https://qodo-merge-docs.qodo.ai/core-abilities/impact_evaluation/) 💎 | ✅ | ✅ | | | | | [PR interactive actions](https://www.qodo.ai/images/pr_agent/pr-actions.mp4) 💎 | ✅ | | | |
- 💎 means this feature is available only in [Qodo-Merge](https://www.qodo.ai/pricing/) | | [Impact Evaluation](https://qodo-merge-docs.qodo.ai/core-abilities/impact_evaluation/) 💎 | ✅ | ✅ | | |
| | [Code Validation 💎](https://qodo-merge-docs.qodo.ai/core-abilities/code_validation/) | ✅ | ✅ | ✅ | ✅ |
| | [Auto Best Practices 💎](https://qodo-merge-docs.qodo.ai/core-abilities/auto_best_practices/) | ✅ | | | |
- 💎 means this feature is available only in [Qodo Merge](https://www.qodo.ai/pricing/)
[//]: # (- Support for additional git providers is described in [here]&#40;./docs/Full_environments.md&#41;) [//]: # (- Support for additional git providers is described in [here]&#40;./docs/Full_environments.md&#41;)
___ ___
@ -162,6 +169,7 @@ ___
___ ___
## Example results ## Example results
</div> </div>
<h4><a href="https://github.com/Codium-ai/pr-agent/pull/530">/describe</a></h4> <h4><a href="https://github.com/Codium-ai/pr-agent/pull/530">/describe</a></h4>
<div align="center"> <div align="center">
@ -190,40 +198,37 @@ ___
</p> </p>
</div> </div>
<div align="left"> <div align="left">
</div> </div>
<hr> <hr>
## Try it now ## Try it now
Try the Claude Sonnet powered PR-Agent instantly on _your public GitHub repository_. Just mention `@CodiumAI-Agent` and add the desired command in any PR comment. The agent will generate a response based on your command. Try the Claude Sonnet powered PR-Agent instantly on _your public GitHub repository_. 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: For example, add a comment to any pull request with the following text:
``` ```
@CodiumAI-Agent /review @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.
Note that this is a promotional bot, suitable only for initial experimentation. Note that this is a promotional bot, suitable only for initial experimentation.
It does not have 'edit' access to your repo, for example, so it cannot update the PR description or add labels (`@CodiumAI-Agent /describe` will publish PR description as a comment). In addition, the bot cannot be used on private repositories, as it does not have access to the files there. It does not have 'edit' access to your repo, for example, so it cannot update the PR description or add labels (`@CodiumAI-Agent /describe` will publish PR description as a comment). In addition, the bot cannot be used on private repositories, as it does not have access to the files there.
--- ---
## Qodo Merge 💎 ## Qodo Merge 💎
[Qodo Merge](https://www.qodo.ai/pricing/) is a hosted version of PR-Agent, provided by Qodo. It is available for a monthly fee, and provides the following benefits: [Qodo Merge](https://www.qodo.ai/pricing/) is a hosted version of PR-Agent, provided by Qodo. It is available for a monthly fee, and provides the following benefits:
1. **Fully managed** - We take care of everything for you - hosting, models, regular updates, and more. Installation is as simple as signing up and adding the Qodo Merge app to your GitHub\GitLab\BitBucket repo.
1. **Fully managed** - We take care of everything for you - hosting, models, regular updates, and more. Installation is as simple as signing up and adding the Qodo Merge app to your GitHub/GitLab/BitBucket repo.
2. **Improved privacy** - No data will be stored or used to train models. Qodo Merge will employ zero data retention, and will use an OpenAI account with zero data retention. 2. **Improved privacy** - No data will be stored or used to train models. Qodo Merge will employ zero data retention, and will use an OpenAI account with zero data retention.
3. **Improved support** - Qodo Merge users will receive priority support, and will be able to request new features and capabilities. 3. **Improved support** - Qodo Merge users will receive priority support, and will be able to request new features and capabilities.
4. **Extra features** -In addition to the benefits listed above, Qodo Merge will emphasize more customization, and the usage of static code analysis, in addition to LLM logic, to improve results. 4. **Extra features** - In addition to the benefits listed above, Qodo Merge will emphasize more customization, and the usage of static code analysis, in addition to LLM logic, to improve results.
See [here](https://qodo-merge-docs.qodo.ai/overview/pr_agent_pro/) for a list of features available in Qodo Merge. See [here](https://qodo-merge-docs.qodo.ai/overview/pr_agent_pro/) for a list of features available in Qodo Merge.
## How it works ## How it works
The following diagram illustrates PR-Agent tools and their flow: The following diagram illustrates PR-Agent tools and their flow:
@ -241,8 +246,7 @@ Here are some advantages of PR-Agent:
- We emphasize **real-life practical usage**. Each tool (review, improve, ask, ...) has a single LLM call, no more. We feel that this is critical for realistic team usage - obtaining an answer quickly (~30 seconds) and affordably. - We emphasize **real-life practical usage**. Each tool (review, improve, ask, ...) has a single LLM 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](https://qodo-merge-docs.qodo.ai/core-abilities/#pr-compression-strategy) is a core ability that enables to effectively tackle both short and long PRs. - Our [PR Compression strategy](https://qodo-merge-docs.qodo.ai/core-abilities/#pr-compression-strategy) 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](pr_agent/settings/configuration.toml) 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), **multiple ways** to use the tool (CLI, GitHub Action, GitHub App, Docker, ...), and **multiple models** (GPT, Claude, Deepseek, ...) - We support **multiple git providers** (GitHub, GitLab, BitBucket), **multiple ways** to use the tool (CLI, GitHub Action, GitHub App, Docker, ...), and **multiple models** (GPT, Claude, Deepseek, ...)
## Data privacy ## Data privacy
@ -263,6 +267,10 @@ https://openai.com/enterprise-privacy
- The [Qodo Merge Chrome extension](https://chromewebstore.google.com/detail/qodo-merge-ai-powered-cod/ephlnjeghhogofkifjloamocljapahnl) serves solely to modify the visual appearance of a GitHub PR screen. It does not transmit any user's repo or pull request code. Code is only sent for processing when a user submits a GitHub comment that activates a PR-Agent tool, in accordance with the standard privacy policy of Qodo-Merge. - The [Qodo Merge Chrome extension](https://chromewebstore.google.com/detail/qodo-merge-ai-powered-cod/ephlnjeghhogofkifjloamocljapahnl) serves solely to modify the visual appearance of a GitHub PR screen. It does not transmit any user's repo or pull request code. Code is only sent for processing when a user submits a GitHub comment that activates a PR-Agent tool, in accordance with the standard privacy policy of Qodo-Merge.
## Contributing
To contribute to the project, get started by reading our [Contributing Guide](https://github.com/qodo-ai/pr-agent/blob/b09eec265ef7d36c232063f76553efb6b53979ff/CONTRIBUTING.md).
## Links ## Links
- Discord community: https://discord.gg/kG35uSHDBc - Discord community: https://discord.gg/kG35uSHDBc

View File

@ -1,4 +1,5 @@
## [Version 0.11] - 2023-12-07 ## [Version 0.11] - 2023-12-07
- codiumai/pr-agent:0.11 - codiumai/pr-agent:0.11
- codiumai/pr-agent:0.11-github_app - codiumai/pr-agent:0.11-github_app
- codiumai/pr-agent:0.11-bitbucket-app - codiumai/pr-agent:0.11-bitbucket-app
@ -7,16 +8,18 @@
- codiumai/pr-agent:0.11-github_action - codiumai/pr-agent:0.11-github_action
### Added::Algo ### Added::Algo
- New section in `/describe` tool - [PR changes walkthrough](https://github.com/Codium-ai/pr-agent/pull/509) - New section in `/describe` tool - [PR changes walkthrough](https://github.com/Codium-ai/pr-agent/pull/509)
- Improving PR Agent [prompts](https://github.com/Codium-ai/pr-agent/pull/501) - Improving PR Agent [prompts](https://github.com/Codium-ai/pr-agent/pull/501)
- Persistent tools (`/review`, `/describe`) now send an [update message](https://github.com/Codium-ai/pr-agent/pull/499) after finishing - Persistent tools (`/review`, `/describe`) now send an [update message](https://github.com/Codium-ai/pr-agent/pull/499) after finishing
- Add Amazon Bedrock [support](https://github.com/Codium-ai/pr-agent/pull/483) - Add Amazon Bedrock [support](https://github.com/Codium-ai/pr-agent/pull/483)
### Fixed ### Fixed
- Update [dependencies](https://github.com/Codium-ai/pr-agent/pull/503) in requirements.txt for Python 3.12 - Update [dependencies](https://github.com/Codium-ai/pr-agent/pull/503) in requirements.txt for Python 3.12
## [Version 0.10] - 2023-11-15 ## [Version 0.10] - 2023-11-15
- codiumai/pr-agent:0.10 - codiumai/pr-agent:0.10
- codiumai/pr-agent:0.10-github_app - codiumai/pr-agent:0.10-github_app
- codiumai/pr-agent:0.10-bitbucket-app - codiumai/pr-agent:0.10-bitbucket-app
@ -25,6 +28,7 @@
- codiumai/pr-agent:0.10-github_action - codiumai/pr-agent:0.10-github_action
### Added::Algo ### Added::Algo
- Review tool now works with [persistent comments](https://github.com/Codium-ai/pr-agent/pull/451) by default - Review tool now works with [persistent comments](https://github.com/Codium-ai/pr-agent/pull/451) by default
- Bitbucket now publishes review suggestions with [code links](https://github.com/Codium-ai/pr-agent/pull/428) - Bitbucket now publishes review suggestions with [code links](https://github.com/Codium-ai/pr-agent/pull/428)
- Enabling to limit [max number of tokens](https://github.com/Codium-ai/pr-agent/pull/437/files) - Enabling to limit [max number of tokens](https://github.com/Codium-ai/pr-agent/pull/437/files)
@ -34,11 +38,13 @@
- Decoupled custom labels from [PR type](https://github.com/Codium-ai/pr-agent/pull/431) - Decoupled custom labels from [PR type](https://github.com/Codium-ai/pr-agent/pull/431)
### Fixed ### Fixed
- Fixed bug in [parsing quotes](https://github.com/Codium-ai/pr-agent/pull/446) in CLI - Fixed bug in [parsing quotes](https://github.com/Codium-ai/pr-agent/pull/446) in CLI
- Preserve [user-added labels](https://github.com/Codium-ai/pr-agent/pull/433) in pull requests - Preserve [user-added labels](https://github.com/Codium-ai/pr-agent/pull/433) in pull requests
- Bug fixes in GitLab and BitBucket - Bug fixes in GitLab and BitBucket
## [Version 0.9] - 2023-10-29 ## [Version 0.9] - 2023-10-29
- codiumai/pr-agent:0.9 - codiumai/pr-agent:0.9
- codiumai/pr-agent:0.9-github_app - codiumai/pr-agent:0.9-github_app
- codiumai/pr-agent:0.9-bitbucket-app - codiumai/pr-agent:0.9-bitbucket-app
@ -47,6 +53,7 @@
- codiumai/pr-agent:0.9-github_action - codiumai/pr-agent:0.9-github_action
### Added::Algo ### Added::Algo
- New tool - [generate_labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/GENERATE_CUSTOM_LABELS.md) - New tool - [generate_labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/GENERATE_CUSTOM_LABELS.md)
- New ability to use [customize labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/GENERATE_CUSTOM_LABELS.md#how-to-enable-custom-labels) on the `review` and `describe` tools. - New ability to use [customize labels](https://github.com/Codium-ai/pr-agent/blob/main/docs/GENERATE_CUSTOM_LABELS.md#how-to-enable-custom-labels) on the `review` and `describe` tools.
- New tool - [add_docs](https://github.com/Codium-ai/pr-agent/blob/main/docs/ADD_DOCUMENTATION.md) - New tool - [add_docs](https://github.com/Codium-ai/pr-agent/blob/main/docs/ADD_DOCUMENTATION.md)
@ -56,14 +63,17 @@
- PR Description default mode is now in [bullet points](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L35). - PR Description default mode is now in [bullet points](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L35).
### Added::Documentation ### Added::Documentation
Significant documentation updates (see [Installation Guide](https://github.com/Codium-ai/pr-agent/blob/main/INSTALL.md), [Usage Guide](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md), and [Tools Guide](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md)) Significant documentation updates (see [Installation Guide](https://github.com/Codium-ai/pr-agent/blob/main/INSTALL.md), [Usage Guide](https://github.com/Codium-ai/pr-agent/blob/main/Usage.md), and [Tools Guide](https://github.com/Codium-ai/pr-agent/blob/main/docs/TOOLS_GUIDE.md))
### Fixed ### Fixed
- Fixed support for BitBucket pipeline (see [link](https://github.com/Codium-ai/pr-agent/pull/386)) - Fixed support for BitBucket pipeline (see [link](https://github.com/Codium-ai/pr-agent/pull/386))
- Fixed a bug in `review -i` tool - Fixed a bug in `review -i` tool
- Added blacklist for specific file extensions in `add_docs` tool (see [link](https://github.com/Codium-ai/pr-agent/pull/385/)) - Added blacklist for specific file extensions in `add_docs` tool (see [link](https://github.com/Codium-ai/pr-agent/pull/385/))
## [Version 0.8] - 2023-09-27 ## [Version 0.8] - 2023-09-27
- codiumai/pr-agent:0.8 - codiumai/pr-agent:0.8
- codiumai/pr-agent:0.8-github_app - codiumai/pr-agent:0.8-github_app
- codiumai/pr-agent:0.8-bitbucket-app - codiumai/pr-agent:0.8-bitbucket-app
@ -72,16 +82,18 @@ Significant documentation updates (see [Installation Guide](https://github.com/C
- codiumai/pr-agent:0.8-github_action - codiumai/pr-agent:0.8-github_action
### Added::Algo ### Added::Algo
- GitHub Action: Can control which tools will run automatically when a new PR is created. (see usage guide: https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-action) - GitHub Action: Can control which tools will run automatically when a new PR is created. (see usage guide: https://github.com/Codium-ai/pr-agent/blob/main/Usage.md#working-with-github-action)
- Code suggestion tool: Will try to avoid an 'add comments' suggestion (see https://github.com/Codium-ai/pr-agent/pull/327) - Code suggestion tool: Will try to avoid an 'add comments' suggestion (see https://github.com/Codium-ai/pr-agent/pull/327)
### Fixed ### Fixed
- Gitlab: Fixed a bug of improper usage of pr_id
- Gitlab: Fixed a bug of improper usage of pr_id
## [Version 0.7] - 2023-09-20 ## [Version 0.7] - 2023-09-20
### Docker Tags ### Docker Tags
- codiumai/pr-agent:0.7 - codiumai/pr-agent:0.7
- codiumai/pr-agent:0.7-github_app - codiumai/pr-agent:0.7-github_app
- codiumai/pr-agent:0.7-bitbucket-app - codiumai/pr-agent:0.7-bitbucket-app
@ -90,14 +102,17 @@ Significant documentation updates (see [Installation Guide](https://github.com/C
- codiumai/pr-agent:0.7-github_action - codiumai/pr-agent:0.7-github_action
### Added::Algo ### Added::Algo
- New tool /similar_issue - Currently on GitHub app and CLI: indexes the issues in the repo, find the most similar issues to the target issue. - New tool /similar_issue - Currently on GitHub app and CLI: indexes the issues in the repo, find the most similar issues to the target issue.
- Describe markers: Empower the /describe tool with a templating capability (see more details in https://github.com/Codium-ai/pr-agent/pull/273). - Describe markers: Empower the /describe tool with a templating capability (see more details in https://github.com/Codium-ai/pr-agent/pull/273).
- New feature in the /review tool - added an estimated effort estimation to the review (https://github.com/Codium-ai/pr-agent/pull/306). - New feature in the /review tool - added an estimated effort estimation to the review (https://github.com/Codium-ai/pr-agent/pull/306).
### Added::Infrastructure ### Added::Infrastructure
- Implementation of a GitLab webhook. - Implementation of a GitLab webhook.
- Implementation of a BitBucket app. - Implementation of a BitBucket app.
### Fixed ### Fixed
- Protection against no code suggestions generated. - Protection against no code suggestions generated.
- Resilience to repositories where the languages cannot be automatically detected. - Resilience to repositories where the languages cannot be automatically detected.

View File

@ -1,6 +1,6 @@
# Security Policy # Security Policy
PR-Agent is an open-source tool to help efficiently review and handle pull requests. Qodo Merge is a paid version of PR-Agent, designed for companies and teams that require additional features and capabilities. PR-Agent is an open-source tool to help efficiently review and handle pull requests. Qodo Merge is a paid version of PR-Agent, designed for companies and teams that require additional features and capabilities.
This document describes the security policy of PR-Agent. For Qodo Merge's security policy, see [here](https://qodo-merge-docs.qodo.ai/overview/data_privacy/#qodo-merge). This document describes the security policy of PR-Agent. For Qodo Merge's security policy, see [here](https://qodo-merge-docs.qodo.ai/overview/data_privacy/#qodo-merge).
@ -9,13 +9,13 @@ This document describes the security policy of PR-Agent. For Qodo Merge's securi
When using PR-Agent with your OpenAI (or other LLM provider) API key, the security relationship is directly between you and the provider. We do not send your code to Qodo servers. When using PR-Agent with your OpenAI (or other LLM provider) API key, the security relationship is directly between you and the provider. We do not send your code to Qodo servers.
Types of [self-hosted solutions](https://qodo-merge-docs.qodo.ai/installation): Types of [self-hosted solutions](https://qodo-merge-docs.qodo.ai/installation):
- Locally - Locally
- GitHub integration - GitHub integration
- GitLab integration - GitLab integration
- BitBucket integration - BitBucket integration
- Azure DevOps integration - Azure DevOps integration
## PR-Agent Supported Versions ## PR-Agent Supported Versions
This section outlines which versions of PR-Agent are currently supported with security updates. This section outlines which versions of PR-Agent are currently supported with security updates.
@ -25,6 +25,7 @@ This section outlines which versions of PR-Agent are currently supported with se
#### Latest Version #### Latest Version
For the most recent updates, use our latest Docker image which is automatically built nightly: For the most recent updates, use our latest Docker image which is automatically built nightly:
```yaml ```yaml
uses: qodo-ai/pr-agent@main uses: qodo-ai/pr-agent@main
``` ```
@ -46,6 +47,7 @@ steps:
#### Enhanced Security with Docker Digest #### Enhanced Security with Docker Digest
For maximum security, you can specify the Docker image using its digest: For maximum security, you can specify the Docker image using its digest:
```yaml ```yaml
steps: steps:
- name: PR Agent action step - name: PR Agent action step

View File

@ -1,4 +1,6 @@
FROM python:3.12.3 AS base FROM python:3.12.10-slim AS base
RUN apt update && apt install --no-install-recommends -y git curl && apt-get clean && rm -rf /var/lib/apt/lists/*
WORKDIR /app WORKDIR /app
ADD pyproject.toml . ADD pyproject.toml .

View File

@ -4,10 +4,10 @@
Search through our documentation using AI-powered natural language queries. Search through our documentation using AI-powered natural language queries.
</p> </p>
<div class="search-container"> <div class="search-container">
<input <input
type="text" type="text"
id="searchInput" id="searchInput"
class="search-input" class="search-input"
placeholder="Enter your search term..." placeholder="Enter your search term..."
> >
<button id="searchButton" class="search-button">Search</button> <button id="searchButton" class="search-button">Search</button>
@ -206,13 +206,13 @@ window.addEventListener('load', function() {
const resultsContainer = document.getElementById('results'); const resultsContainer = document.getElementById('results');
const spinner = document.getElementById('spinner'); const spinner = document.getElementById('spinner');
const searchContainer = document.querySelector('.search-container'); const searchContainer = document.querySelector('.search-container');
// Hide spinner // Hide spinner
spinner.style.display = 'none'; spinner.style.display = 'none';
// Scroll to search bar // Scroll to search bar
searchContainer.scrollIntoView({ behavior: 'smooth', block: 'start' }); searchContainer.scrollIntoView({ behavior: 'smooth', block: 'start' });
try { try {
const results = JSON.parse(responseText); const results = JSON.parse(responseText);
@ -224,7 +224,7 @@ window.addEventListener('load', function() {
}); });
const htmlContent = marked.parse(results.message); const htmlContent = marked.parse(results.message);
resultsContainer.className = 'markdown-content'; resultsContainer.className = 'markdown-content';
resultsContainer.innerHTML = htmlContent; resultsContainer.innerHTML = htmlContent;
@ -234,7 +234,7 @@ window.addEventListener('load', function() {
const offset = 55; // Offset from top in pixels const offset = 55; // Offset from top in pixels
const elementPosition = searchContainer.getBoundingClientRect().top; const elementPosition = searchContainer.getBoundingClientRect().top;
const offsetPosition = elementPosition + window.pageYOffset - offset; const offsetPosition = elementPosition + window.pageYOffset - offset;
window.scrollTo({ window.scrollTo({
top: offsetPosition, top: offsetPosition,
behavior: 'smooth' behavior: 'smooth'
@ -261,7 +261,7 @@ window.addEventListener('load', function() {
spinner.style.display = 'flex'; spinner.style.display = 'flex';
resultsContainer.innerHTML = ''; resultsContainer.innerHTML = '';
try { try {
const data = { const data = {
"query": searchTerm "query": searchTerm
}; };
@ -299,11 +299,11 @@ window.addEventListener('load', function() {
// Add event listeners // Add event listeners
const searchButton = document.getElementById('searchButton'); const searchButton = document.getElementById('searchButton');
const searchInput = document.getElementById('searchInput'); const searchInput = document.getElementById('searchInput');
if (searchButton) { if (searchButton) {
searchButton.addEventListener('click', performSearch); searchButton.addEventListener('click', performSearch);
} }
if (searchInput) { if (searchInput) {
searchInput.addEventListener('keypress', function(e) { searchInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') { if (e.key === 'Enter') {
@ -312,4 +312,4 @@ window.addEventListener('load', function() {
}); });
} }
}); });
</script> </script>

View File

@ -17,8 +17,8 @@ Qodo Merge constructs a comprehensive context for each pull request, incorporati
<img src="https://codium.ai/images/pr_agent/pr_chat_1.png" width="768"> <img src="https://codium.ai/images/pr_agent/pr_chat_1.png" width="768">
<img src="https://codium.ai/images/pr_agent/pr_chat_2.png" width="768"> <img src="https://codium.ai/images/pr_agent/pr_chat_2.png" width="768">
### Toolbar extension ### Toolbar extension
With Qodo Merge Chrome extension, it's [easier than ever](https://www.youtube.com/watch?v=gT5tli7X4H4) to interactively configure and experiment with the different tools and configuration options. With Qodo Merge Chrome extension, it's [easier than ever](https://www.youtube.com/watch?v=gT5tli7X4H4) to interactively configure and experiment with the different tools and configuration options.
For private repositories, after you found the setup that works for you, you can also easily export it as a persistent configuration file, and use it for automatic commands. For private repositories, after you found the setup that works for you, you can also easily export it as a persistent configuration file, and use it for automatic commands.
@ -37,7 +37,6 @@ For example, you can choose to present only message from Qodo Merge, or filter t
<img src="https://codium.ai/images/pr_agent/pr_agent_filters2.png" width="256"> <img src="https://codium.ai/images/pr_agent/pr_agent_filters2.png" width="256">
### Enhanced code suggestions ### Enhanced code suggestions
Qodo Merge Chrome extension adds the following capabilities to code suggestions tool's comments: Qodo Merge Chrome extension adds the following capabilities to code suggestions tool's comments:
@ -45,7 +44,6 @@ Qodo Merge Chrome extension adds the following capabilities to code suggestions
- Auto-expand the table when you are viewing a code block, to avoid clipping. - Auto-expand the table when you are viewing a code block, to avoid clipping.
- Adding a "quote-and-reply" button, that enables to address and comment on a specific suggestion (for example, asking the author to fix the issue) - Adding a "quote-and-reply" button, that enables to address and comment on a specific suggestion (for example, asking the author to fix the issue)
<img src="https://codium.ai/images/pr_agent/chrome_extension_code_suggestion1.png" width="512"> <img src="https://codium.ai/images/pr_agent/chrome_extension_code_suggestion1.png" width="512">
<img src="https://codium.ai/images/pr_agent/chrome_extension_code_suggestion2.png" width="512"> <img src="https://codium.ai/images/pr_agent/chrome_extension_code_suggestion2.png" width="512">

View File

@ -2,7 +2,7 @@
With a single-click installation you will gain access to a context-aware chat on your pull requests code, a toolbar extension with multiple AI feedbacks, Qodo Merge filters, and additional abilities. With a single-click installation you will gain access to a context-aware chat on your pull requests code, a toolbar extension with multiple AI feedbacks, Qodo Merge filters, and additional abilities.
The extension is powered by top code models like Claude 3.7 Sonnet and o3-mini. All the extension's features are free to use on public repositories. The extension is powered by top code models like Claude 3.7 Sonnet and o4-mini. All the extension's features are free to use on public repositories.
For private repositories, you will need to install [Qodo Merge](https://github.com/apps/qodo-merge-pro){:target="_blank"} in addition to the extension (Quick GitHub app setup with a 14-day free trial. No credit card needed). For private repositories, you will need to install [Qodo Merge](https://github.com/apps/qodo-merge-pro){:target="_blank"} in addition to the extension (Quick GitHub app setup with a 14-day free trial. No credit card needed).
For a demonstration of how to install Qodo Merge and use it with the Chrome extension, please refer to the tutorial video at the provided [link](https://codium.ai/images/pr_agent/private_repos.mp4){:target="_blank"}. For a demonstration of how to install Qodo Merge and use it with the Chrome extension, please refer to the tutorial video at the provided [link](https://codium.ai/images/pr_agent/private_repos.mp4){:target="_blank"}.

View File

@ -14,12 +14,10 @@ Alternatively, you can access the options page directly using this URL:
<img src="https://codium.ai/images/pr_agent/chrome_ext_options.png" width="256"> <img src="https://codium.ai/images/pr_agent/chrome_ext_options.png" width="256">
### Configuration Options ### Configuration Options
<img src="https://codium.ai/images/pr_agent/chrome_ext_settings_page.png" width="512"> <img src="https://codium.ai/images/pr_agent/chrome_ext_settings_page.png" width="512">
#### API Base Host #### API Base Host
For single-tenant customers, you can configure the extension to communicate directly with your company's Qodo Merge server instance. For single-tenant customers, you can configure the extension to communicate directly with your company's Qodo Merge server instance.

View File

@ -1,4 +1,5 @@
# Auto Best Practices 💎 # Auto Best Practices 💎
`Supported Git Platforms: GitHub` `Supported Git Platforms: GitHub`
## Overview ## Overview
@ -9,17 +10,16 @@
### Finding Code Problems - Exploration Phase ### Finding Code Problems - Exploration Phase
The `improve` tool identifies potential issues, problems and bugs in Pull Request (PR) code changes. The `improve` tool identifies potential issues, problems and bugs in Pull Request (PR) code changes.
Rather than focusing on minor issues like code style or formatting, the tool intelligently analyzes code to detect meaningful problems. Rather than focusing on minor issues like code style or formatting, the tool intelligently analyzes code to detect meaningful problems.
The analysis intentionally takes a flexible, _exploratory_ approach to identify meaningful potential issues, allowing the tool to surface relevant code suggestions without being constrained by predefined categories. The analysis intentionally takes a flexible, _exploratory_ approach to identify meaningful potential issues, allowing the tool to surface relevant code suggestions without being constrained by predefined categories.
### Tracking Implemented Suggestions ### Tracking Implemented Suggestions
Qodo Merge features a novel [tracking system](https://qodo-merge-docs.qodo.ai/tools/improve/#suggestion-tracking) that automatically detects when PR authors implement AI-generated code suggestions. Qodo Merge features a novel [tracking system](https://qodo-merge-docs.qodo.ai/tools/improve/#suggestion-tracking) that automatically detects when PR authors implement AI-generated code suggestions.
All accepted suggestions are aggregated in a repository-specific wiki page called [`.pr_agent_accepted_suggestions`](https://github.com/qodo-ai/pr-agent/wiki/.pr_agent_accepted_suggestions) All accepted suggestions are aggregated in a repository-specific wiki page called [`.pr_agent_accepted_suggestions`](https://github.com/qodo-ai/pr-agent/wiki/.pr_agent_accepted_suggestions)
### Learning and Applying Auto Best Practices ### Learning and Applying Auto Best Practices
Monthly, Qodo Merge analyzes the collection of accepted suggestions to generate repository-specific best practices, stored in [`.pr_agent_auto_best_practices`](https://github.com/qodo-ai/pr-agent/wiki/.pr_agent_auto_best_practices) wiki file. Monthly, Qodo Merge analyzes the collection of accepted suggestions to generate repository-specific best practices, stored in [`.pr_agent_auto_best_practices`](https://github.com/qodo-ai/pr-agent/wiki/.pr_agent_auto_best_practices) wiki file.
@ -33,17 +33,15 @@ This creates a two-phase analysis:
By keeping these phases decoupled, the tool remains free to discover new or unseen issues and problems, while also learning from past experiences. By keeping these phases decoupled, the tool remains free to discover new or unseen issues and problems, while also learning from past experiences.
When presenting the suggestions generated by the `improve` tool, Qodo Merge will add a dedicated label for each suggestion generated from the auto best practices - 'Learned best practice': When presenting the suggestions generated by the `improve` tool, Qodo Merge will add a dedicated label for each suggestion generated from the auto best practices - 'Learned best practice':
![Auto best practice suggestion](https://www.qodo.ai/images/pr_agent/auto_best_practices.png){width=684} ![Auto best practice suggestion](https://www.qodo.ai/images/pr_agent/auto_best_practices.png){width=684}
## Auto Best Practices vs Custom Best Practices ## Auto Best Practices vs Custom Best Practices
Teams and companies can also manually define their own [custom best practices](https://qodo-merge-docs.qodo.ai/tools/improve/#best-practices) in Qodo Merge. Teams and companies can also manually define their own [custom best practices](https://qodo-merge-docs.qodo.ai/tools/improve/#best-practices) in Qodo Merge.
When custom best practices exist, Qodo Merge will still generate an 'auto best practices' wiki file, though it won't be used by the `improve` tool. When custom best practices exist, Qodo Merge will still generate an 'auto best practices' wiki file, though it won't be used by the `improve` tool.
However, this auto-generated file can still serve two valuable purposes: However, this auto-generated file can still serve two valuable purposes:
1. It can help enhance your custom best practices with additional insights derived from suggestions your team found valuable enough to implement 1. It can help enhance your custom best practices with additional insights derived from suggestions your team found valuable enough to implement
@ -66,4 +64,4 @@ extra_instructions = ""
# Max number of patterns to be detected # Max number of patterns to be detected
max_patterns = 5 max_patterns = 5
``` ```

View File

@ -1,4 +1,5 @@
## Introduction ## Introduction
The Git environment usually represents the final stage before code enters production. Hence, Detecting bugs and issues during the review process is critical. The Git environment usually represents the final stage before code enters production. Hence, Detecting bugs and issues during the review process is critical.
The [`improve`](https://qodo-merge-docs.qodo.ai/tools/improve/) tool provides actionable code suggestions for your pull requests, aiming to help detect and fix bugs and problems. The [`improve`](https://qodo-merge-docs.qodo.ai/tools/improve/) tool provides actionable code suggestions for your pull requests, aiming to help detect and fix bugs and problems.
@ -32,8 +33,8 @@ Read more about this process in the [self-reflection](https://qodo-merge-docs.qo
## Conclusion ## Conclusion
The validation methods described above enhance the reliability of code suggestions and help PR authors determine which suggestions are safer to apply in the Git environment. The validation methods described above enhance the reliability of code suggestions and help PR authors determine which suggestions are safer to apply in the Git environment.
Of course, additional factors should be considered, such as suggestion complexity and potential code impact. Of course, additional factors should be considered, such as suggestion complexity and potential code impact.
Human judgment remains essential. After clicking 'apply', Qodo Merge still presents the 'before' and 'after' code snippets for review, allowing you to assess the changes before finalizing the commit. Human judgment remains essential. After clicking 'apply', Qodo Merge still presents the 'before' and 'after' code snippets for review, allowing you to assess the changes before finalizing the commit.
![improve](https://codium.ai/images/pr_agent/improve.png){width=512} ![improve](https://codium.ai/images/pr_agent/improve.png){width=512}

View File

@ -1,5 +1,6 @@
## Overview - PR Compression Strategy ## Overview - PR Compression Strategy
There are two scenarios: There are two scenarios:
1. The PR is small enough to fit in a single prompt (including system and user prompt) 1. The PR is small enough to fit in a single prompt (including system and user prompt)
@ -8,6 +9,7 @@ There are two scenarios:
For both scenarios, we first use the following strategy For both scenarios, we first use the following strategy
#### Repo language prioritization strategy #### Repo language prioritization strategy
We prioritize the languages of the repo based on the following criteria: We prioritize the languages of the repo based on the following criteria:
1. Exclude binary files and non code files (e.g. images, pdfs, etc) 1. Exclude binary files and non code files (e.g. images, pdfs, etc)
@ -15,28 +17,33 @@ We prioritize the languages of the repo based on the following criteria:
3. We sort the PR files by the most common languages in the repo (in descending order): 3. We sort the PR files by the most common languages in the repo (in descending order):
* ```[[file.py, file2.py],[file3.js, file4.jsx],[readme.md]]``` * ```[[file.py, file2.py],[file3.js, file4.jsx],[readme.md]]```
### Small PR ### Small PR
In this case, we can fit the entire PR in a single prompt: In this case, we can fit the entire PR in a single prompt:
1. Exclude binary files and non code files (e.g. images, pdfs, etc) 1. Exclude binary files and non code files (e.g. images, pdfs, etc)
2. We Expand the surrounding context of each patch to 3 lines above and below the patch 2. We Expand the surrounding context of each patch to 3 lines above and below the patch
### Large PR ### Large PR
#### Motivation #### Motivation
Pull Requests can be very long and contain a lot of information with varying degree of relevance to the pr-agent. Pull Requests can be very long and contain a lot of information with varying degree of relevance to the pr-agent.
We want to be able to pack as much information as possible in a single LMM prompt, while keeping the information relevant to the pr-agent. We want to be able to pack as much information as possible in a single LMM prompt, while keeping the information relevant to the pr-agent.
#### Compression strategy #### Compression strategy
We prioritize additions over deletions:
- Combine all deleted files into a single list (`deleted files`)
- File patches are a list of hunks, remove all hunks of type deletion-only from the hunks in the file patch
#### Adaptive and token-aware file patch fitting We prioritize additions over deletions:
* Combine all deleted files into a single list (`deleted files`)
* File patches are a list of hunks, remove all hunks of type deletion-only from the hunks in the file patch
#### Adaptive and token-aware file patch fitting
We use [tiktoken](https://github.com/openai/tiktoken) to tokenize the patches after the modifications described above, and we use the following strategy to fit the patches into the prompt: We use [tiktoken](https://github.com/openai/tiktoken) to tokenize the patches after the modifications described above, and we use the following strategy to fit the patches into the prompt:
1. Within each language we sort the files by the number of tokens in the file (in descending order): 1. Within each language we sort the files by the number of tokens in the file (in descending order):
- ```[[file2.py, file.py],[file4.jsx, file3.js],[readme.md]]``` * ```[[file2.py, file.py],[file4.jsx, file3.js],[readme.md]]```
2. Iterate through the patches in the order described above 2. Iterate through the patches in the order described above
3. Add the patches to the prompt until the prompt reaches a certain buffer from the max token length 3. Add the patches to the prompt until the prompt reaches a certain buffer from the max token length
4. If there are still patches left, add the remaining patches as a list called `other modified files` to the prompt until the prompt reaches the max token length (hard stop), skip the rest of the patches. 4. If there are still patches left, add the remaining patches as a list called `other modified files` to the prompt until the prompt reaches the max token length (hard stop), skip the rest of the patches.

View File

@ -7,7 +7,8 @@ This approach balances providing sufficient context for accurate analysis, while
## Introduction ## Introduction
Pull request code changes are retrieved in a unified diff format, showing three lines of context before and after each modified section, with additions marked by '+' and deletions by '-'. Pull request code changes are retrieved in a unified diff format, showing three lines of context before and after each modified section, with additions marked by '+' and deletions by '-'.
```
```diff
@@ -12,5 +12,5 @@ def func1(): @@ -12,5 +12,5 @@ def func1():
code line that already existed in the file... code line that already existed in the file...
code line that already existed in the file... code line that already existed in the file...
@ -25,7 +26,6 @@ Pull request code changes are retrieved in a unified diff format, showing three
This unified diff format can be challenging for AI models to interpret accurately, as it provides limited context for understanding the full scope of code changes. This unified diff format can be challenging for AI models to interpret accurately, as it provides limited context for understanding the full scope of code changes.
The presentation of code using '+', '-', and ' ' symbols to indicate additions, deletions, and unchanged lines respectively also differs from the standard code formatting typically used to train AI models. The presentation of code using '+', '-', and ' ' symbols to indicate additions, deletions, and unchanged lines respectively also differs from the standard code formatting typically used to train AI models.
## Challenges of expanding the context window ## Challenges of expanding the context window
While expanding the context window is technically feasible, it presents a more fundamental trade-off: While expanding the context window is technically feasible, it presents a more fundamental trade-off:
@ -43,6 +43,7 @@ Pull requests often encompass multiple changes across many files, potentially sp
- Increased context expands the token count, increasing processing time and cost, and may prevent the model from processing the entire pull request in a single pass. - Increased context expands the token count, increasing processing time and cost, and may prevent the model from processing the entire pull request in a single pass.
## Asymmetric and dynamic context ## Asymmetric and dynamic context
To address these challenges, Qodo Merge employs an **asymmetric** and **dynamic** context strategy, providing the model with more focused and relevant context information for each code change. To address these challenges, Qodo Merge employs an **asymmetric** and **dynamic** context strategy, providing the model with more focused and relevant context information for each code change.
**Asymmetric:** **Asymmetric:**
@ -62,7 +63,8 @@ To prevent overwhelming the model with excessive context, we impose a limit on t
This balance allows for comprehensive understanding while maintaining efficiency and limiting context token usage. This balance allows for comprehensive understanding while maintaining efficiency and limiting context token usage.
## Appendix - relevant configuration options ## Appendix - relevant configuration options
```
```toml
[config] [config]
patch_extension_skip_types =[".md",".txt"] # Skip files with these extensions when trying to extend the context patch_extension_skip_types =[".md",".txt"] # Skip files with these extensions when trying to extend the context
allow_dynamic_context=true # Allow dynamic context extension allow_dynamic_context=true # Allow dynamic context extension

View File

@ -1,7 +1,9 @@
# Fetching Ticket Context for PRs # Fetching Ticket Context for PRs
`Supported Git Platforms: GitHub, GitLab, Bitbucket` `Supported Git Platforms: GitHub, GitLab, Bitbucket`
## Overview ## Overview
Qodo Merge streamlines code review workflows by seamlessly connecting with multiple ticket management systems. Qodo Merge streamlines code review workflows by seamlessly connecting with multiple ticket management systems.
This integration enriches the review process by automatically surfacing relevant ticket information and context alongside code changes. This integration enriches the review process by automatically surfacing relevant ticket information and context alongside code changes.
@ -27,16 +29,17 @@ Ticket Recognition Requirements:
- For Jira tickets, you should follow the instructions in [Jira Integration](https://qodo-merge-docs.qodo.ai/core-abilities/fetching_ticket_context/#jira-integration) in order to authenticate with Jira. - For Jira tickets, you should follow the instructions in [Jira Integration](https://qodo-merge-docs.qodo.ai/core-abilities/fetching_ticket_context/#jira-integration) in order to authenticate with Jira.
### Describe tool ### Describe tool
Qodo Merge will recognize the ticket and use the ticket content (title, description, labels) to provide additional context for the code changes. Qodo Merge will recognize the ticket and use the ticket content (title, description, labels) to provide additional context for the code changes.
By understanding the reasoning and intent behind modifications, the LLM can offer more insightful and relevant code analysis. By understanding the reasoning and intent behind modifications, the LLM can offer more insightful and relevant code analysis.
### Review tool ### Review tool
Similarly to the `describe` tool, the `review` tool will use the ticket content to provide additional context for the code changes. Similarly to the `describe` tool, the `review` tool will use the ticket content to provide additional context for the code changes.
In addition, this feature will evaluate how well a Pull Request (PR) adheres to its original purpose/intent as defined by the associated ticket or issue mentioned in the PR description. In addition, this feature will evaluate how well a Pull Request (PR) adheres to its original purpose/intent as defined by the associated ticket or issue mentioned in the PR description.
Each ticket will be assigned a label (Compliance/Alignment level), Indicates the degree to which the PR fulfills its original purpose, Options: Fully compliant, Partially compliant or Not compliant. Each ticket will be assigned a label (Compliance/Alignment level), Indicates the degree to which the PR fulfills its original purpose, Options: Fully compliant, Partially compliant or Not compliant.
![Ticket Compliance](https://www.qodo.ai/images/pr_agent/ticket_compliance_review.png){width=768} ![Ticket Compliance](https://www.qodo.ai/images/pr_agent/ticket_compliance_review.png){width=768}
By default, the tool will automatically validate if the PR complies with the referenced ticket. By default, the tool will automatically validate if the PR complies with the referenced ticket.
@ -63,6 +66,7 @@ Since Qodo Merge is integrated with GitHub, it doesn't require any additional co
We support both Jira Cloud and Jira Server/Data Center. We support both Jira Cloud and Jira Server/Data Center.
### Jira Cloud ### Jira Cloud
There are two ways to authenticate with Jira Cloud: There are two ways to authenticate with Jira Cloud:
**1) Jira App Authentication** **1) Jira App Authentication**
@ -101,7 +105,6 @@ jira_api_token = "YOUR_API_TOKEN"
jira_api_email = "YOUR_EMAIL" jira_api_email = "YOUR_EMAIL"
``` ```
### Jira Data Center/Server ### Jira Data Center/Server
[//]: # () [//]: # ()
@ -163,9 +166,67 @@ jira_api_email = "YOUR_EMAIL"
[//]: # (* You will be redirected back to Qodo Merge and you will see a success message.) [//]: # (* You will be redirected back to Qodo Merge and you will see a success message.)
[//]: # (Personal Access Token &#40;PAT&#41; Authentication) [//]: # (Personal Access Token &#40;PAT&#41; Authentication)
Currently, JIRA integration for Data Center/Server is available via Personal Access Token (PAT) Authentication method
#### Using Basic Authentication for Jira Data Center/Server
You can use your Jira username and password to authenticate with Jira Data Center/Server.
In your Configuration file/Environment variables/Secrets file, add the following lines:
```toml
jira_api_email = "your_username"
jira_api_token = "your_password"
```
(Note that indeed the 'jira_api_email' field is used for the username, and the 'jira_api_token' field is used for the user password.)
##### Validating Basic authentication via Python script
If you are facing issues retrieving tickets in Qodo Merge with Basic auth, you can validate the flow using a Python script.
This following steps will help you check if the basic auth is working correctly, and if you can access the Jira ticket details:
1. run `pip install jira==3.8.0`
2. run the following Python script (after replacing the placeholders with your actual values):
??? example "Script to validate basic auth"
```python
from jira import JIRA
if __name__ == "__main__":
try:
# Jira server URL
server = "https://..."
# Basic auth
username = "..."
password = "..."
# Jira ticket code (e.g. "PROJ-123")
ticket_id = "..."
print("Initializing JiraServerTicketProvider with JIRA server")
# Initialize JIRA client
jira = JIRA(
server=server,
basic_auth=(username, password),
timeout=30
)
if jira:
print(f"JIRA client initialized successfully")
else:
print("Error initializing JIRA client")
# Fetch ticket details
ticket = jira.issue(ticket_id)
print(f"Ticket title: {ticket.fields.summary}")
except Exception as e:
print(f"Error fetching JIRA ticket details: {e}")
```
#### Using a Personal Access Token (PAT) for Jira Data Center/Server
1. Create a [Personal Access Token (PAT)](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html) in your Jira account 1. Create a [Personal Access Token (PAT)](https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html) in your Jira account
2. In your Configuration file/Environment variables/Secrets file, add the following lines: 2. In your Configuration file/Environment variables/Secrets file, add the following lines:
@ -176,9 +237,9 @@ jira_base_url = "YOUR_JIRA_BASE_URL" # e.g. https://jira.example.com
jira_api_token = "YOUR_API_TOKEN" jira_api_token = "YOUR_API_TOKEN"
``` ```
#### Validating PAT token via Python script ##### Validating PAT token via Python script
If you are facing issues retrieving tickets in Qodo Merge with PAT token, you can validate the flow using a Python script. If you are facing issues retrieving tickets in Qodo Merge with PAT token, you can validate the flow using a Python script.
This following steps will help you check if the token is working correctly, and if you can access the Jira ticket details: This following steps will help you check if the token is working correctly, and if you can access the Jira ticket details:
1. run `pip install jira==3.8.0` 1. run `pip install jira==3.8.0`

View File

@ -3,22 +3,24 @@
Demonstrating the return on investment (ROI) of AI-powered initiatives is crucial for modern organizations. Demonstrating the return on investment (ROI) of AI-powered initiatives is crucial for modern organizations.
To address this need, Qodo Merge has developed an AI impact measurement tools and metrics, providing advanced analytics to help businesses quantify the tangible benefits of AI adoption in their PR review process. To address this need, Qodo Merge has developed an AI impact measurement tools and metrics, providing advanced analytics to help businesses quantify the tangible benefits of AI adoption in their PR review process.
## Auto Impact Validator - Real-Time Tracking of Implemented Qodo Merge Suggestions ## Auto Impact Validator - Real-Time Tracking of Implemented Qodo Merge Suggestions
### How It Works ### How It Works
When a user pushes a new commit to the pull request, Qodo Merge automatically compares the updated code against the previous suggestions, marking them as implemented if the changes address these recommendations, whether directly or indirectly: When a user pushes a new commit to the pull request, Qodo Merge automatically compares the updated code against the previous suggestions, marking them as implemented if the changes address these recommendations, whether directly or indirectly:
1. **Direct Implementation:** The user directly addresses the suggestion as-is in the PR, either by clicking on the "apply code suggestion" checkbox or by making the changes manually. 1. **Direct Implementation:** The user directly addresses the suggestion as-is in the PR, either by clicking on the "apply code suggestion" checkbox or by making the changes manually.
2. **Indirect Implementation:** Qodo Merge recognizes when a suggestion's intent is fulfilled, even if the exact code changes differ from the original recommendation. It marks these suggestions as implemented, acknowledging that users may achieve the same goal through alternative solutions. 2. **Indirect Implementation:** Qodo Merge recognizes when a suggestion's intent is fulfilled, even if the exact code changes differ from the original recommendation. It marks these suggestions as implemented, acknowledging that users may achieve the same goal through alternative solutions.
### Real-Time Visual Feedback ### Real-Time Visual Feedback
Upon confirming that a suggestion was implemented, Qodo Merge automatically adds a ✅ (check mark) to the relevant suggestion, enabling transparent tracking of Qodo Merge's impact analysis. Upon confirming that a suggestion was implemented, Qodo Merge automatically adds a ✅ (check mark) to the relevant suggestion, enabling transparent tracking of Qodo Merge's impact analysis.
Qodo Merge will also add, inside the relevant suggestions, an explanation of how the new code was impacted by each suggestion. Qodo Merge will also add, inside the relevant suggestions, an explanation of how the new code was impacted by each suggestion.
![Suggestion_checkmark](https://codium.ai/images/pr_agent/auto_suggestion_checkmark.png){width=512} ![Suggestion_checkmark](https://codium.ai/images/pr_agent/auto_suggestion_checkmark.png){width=512}
### Dashboard Metrics ### Dashboard Metrics
The dashboard provides macro-level insights into the overall impact of Qodo Merge on the pull-request process with key productivity metrics. The dashboard provides macro-level insights into the overall impact of Qodo Merge on the pull-request process with key productivity metrics.
By offering clear, data-driven evidence of Qodo Merge's impact, it empowers leadership teams to make informed decisions about the tool's effectiveness and ROI. By offering clear, data-driven evidence of Qodo Merge's impact, it empowers leadership teams to make informed decisions about the tool's effectiveness and ROI.
@ -26,6 +28,7 @@ By offering clear, data-driven evidence of Qodo Merge's impact, it empowers lead
Here are key metrics that the dashboard tracks: Here are key metrics that the dashboard tracks:
#### Qodo Merge Impacts per 1K Lines #### Qodo Merge Impacts per 1K Lines
![Dashboard](https://codium.ai/images/pr_agent/impacts_per_1k_llines.png){width=512} ![Dashboard](https://codium.ai/images/pr_agent/impacts_per_1k_llines.png){width=512}
> Explanation: for every 1K lines of code (additions/edits), Qodo Merge had on average ~X suggestions implemented. > Explanation: for every 1K lines of code (additions/edits), Qodo Merge had on average ~X suggestions implemented.
@ -36,9 +39,11 @@ Here are key metrics that the dashboard tracks:
3. **Quantifies Value and ROI:** The metric directly correlates with the value Qodo Merge is providing, showing how frequently it offers improvements relative to the amount of new code being written. This provides a clear, quantifiable way to demonstrate Qodo Merge's return on investment to stakeholders. 3. **Quantifies Value and ROI:** The metric directly correlates with the value Qodo Merge is providing, showing how frequently it offers improvements relative to the amount of new code being written. This provides a clear, quantifiable way to demonstrate Qodo Merge's return on investment to stakeholders.
#### Suggestion Effectiveness Across Categories #### Suggestion Effectiveness Across Categories
![Impacted_Suggestion_Score](https://codium.ai/images/pr_agent/impact_by_category.png){width=512} ![Impacted_Suggestion_Score](https://codium.ai/images/pr_agent/impact_by_category.png){width=512}
> Explanation: This chart illustrates the distribution of implemented suggestions across different categories, enabling teams to better understand Qodo Merge's impact on various aspects of code quality and development practices. > Explanation: This chart illustrates the distribution of implemented suggestions across different categories, enabling teams to better understand Qodo Merge's impact on various aspects of code quality and development practices.
#### Suggestion Score Distribution #### Suggestion Score Distribution
![Impacted_Suggestion_Score](https://codium.ai/images/pr_agent/impacted_score_dist.png){width=512} ![Impacted_Suggestion_Score](https://codium.ai/images/pr_agent/impacted_score_dist.png){width=512}
> Explanation: The distribution of the suggestion score for the implemented suggestions, ensuring that higher-scored suggestions truly represent more significant improvements. > Explanation: The distribution of the suggestion score for the implemented suggestions, ensuring that higher-scored suggestions truly represent more significant improvements.

View File

@ -1,8 +1,8 @@
# Core Abilities # Core Abilities
Qodo Merge utilizes a variety of core abilities to provide a comprehensive and efficient code review experience. These abilities include: Qodo Merge utilizes a variety of core abilities to provide a comprehensive and efficient code review experience. These abilities include:
- [Auto best practices](https://qodo-merge-docs.qodo.ai/core-abilities/auto_best_practices/) - [Auto best practices](https://qodo-merge-docs.qodo.ai/core-abilities/auto_best_practices/)
- [Pull request benchmark](https://qodo-merge-docs.qodo.ai/finetuning_benchmark/)
- [Code validation](https://qodo-merge-docs.qodo.ai/core-abilities/code_validation/) - [Code validation](https://qodo-merge-docs.qodo.ai/core-abilities/code_validation/)
- [Compression strategy](https://qodo-merge-docs.qodo.ai/core-abilities/compression_strategy/) - [Compression strategy](https://qodo-merge-docs.qodo.ai/core-abilities/compression_strategy/)
- [Dynamic context](https://qodo-merge-docs.qodo.ai/core-abilities/dynamic_context/) - [Dynamic context](https://qodo-merge-docs.qodo.ai/core-abilities/dynamic_context/)
@ -20,13 +20,16 @@ Here are some additional technical blogs from Qodo, that delve deeper into the c
These resources provide more comprehensive insights into leveraging LLMs for software development. These resources provide more comprehensive insights into leveraging LLMs for software development.
### Code Generation and LLMs ### Code Generation and LLMs
- [Effective AI code suggestions: less is more](https://www.qodo.ai/blog/effective-code-suggestions-llms-less-is-more/) - [Effective AI code suggestions: less is more](https://www.qodo.ai/blog/effective-code-suggestions-llms-less-is-more/)
- [State-of-the-art Code Generation with AlphaCodium From Prompt Engineering to Flow Engineering](https://www.qodo.ai/blog/qodoflow-state-of-the-art-code-generation-for-code-contests/) - [State-of-the-art Code Generation with AlphaCodium From Prompt Engineering to Flow Engineering](https://www.qodo.ai/blog/qodoflow-state-of-the-art-code-generation-for-code-contests/)
- [RAG for a Codebase with 10k Repos](https://www.qodo.ai/blog/rag-for-large-scale-code-repos/) - [RAG for a Codebase with 10k Repos](https://www.qodo.ai/blog/rag-for-large-scale-code-repos/)
### Development Processes ### Development Processes
- [Understanding the Challenges and Pain Points of the Pull Request Cycle](https://www.qodo.ai/blog/understanding-the-challenges-and-pain-points-of-the-pull-request-cycle/) - [Understanding the Challenges and Pain Points of the Pull Request Cycle](https://www.qodo.ai/blog/understanding-the-challenges-and-pain-points-of-the-pull-request-cycle/)
- [Introduction to Code Coverage Testing](https://www.qodo.ai/blog/introduction-to-code-coverage-testing/) - [Introduction to Code Coverage Testing](https://www.qodo.ai/blog/introduction-to-code-coverage-testing/)
### Cost Optimization ### Cost Optimization
- [Reduce Your Costs by 30% When Using GPT for Python Code](https://www.qodo.ai/blog/reduce-your-costs-by-30-when-using-gpt-3-for-python-code/) - [Reduce Your Costs by 30% When Using GPT for Python Code](https://www.qodo.ai/blog/reduce-your-costs-by-30-when-using-gpt-3-for-python-code/)

View File

@ -5,7 +5,7 @@
## Overview ## Overview
Qodo Merge transforms static code reviews into interactive experiences by enabling direct actions from pull request (PR) comments. Qodo Merge transforms static code reviews into interactive experiences by enabling direct actions from pull request (PR) comments.
Developers can immediately trigger actions and apply changes with simple checkbox clicks. Developers can immediately trigger actions and apply changes with simple checkbox clicks.
This focused workflow maintains context while dramatically reducing the time between PR creation and final merge. This focused workflow maintains context while dramatically reducing the time between PR creation and final merge.
The approach eliminates manual steps, provides clear visual indicators, and creates immediate feedback loops all within the same interface. The approach eliminates manual steps, provides clear visual indicators, and creates immediate feedback loops all within the same interface.
@ -24,8 +24,7 @@ The [`/improve`](https://qodo-merge-docs.qodo.ai/tools/improve/) command deliver
- _**Author self-review**_: Interactive acknowledgment that developers have opened and reviewed collapsed suggestions - _**Author self-review**_: Interactive acknowledgment that developers have opened and reviewed collapsed suggestions
### 2\. Interactive `/analyze` Tool
### 2\. Interactive `/analyze` Tool
The [`/analyze`](https://qodo-merge-docs.qodo.ai/tools/analyze/) command provides component-level analysis with interactive options for each identified code component: The [`/analyze`](https://qodo-merge-docs.qodo.ai/tools/analyze/) command provides component-level analysis with interactive options for each identified code component:
@ -35,9 +34,8 @@ The [`/analyze`](https://qodo-merge-docs.qodo.ai/tools/analyze/) command provide
- Component-specific actions that trigger only for the selected elements, providing focused assistance - Component-specific actions that trigger only for the selected elements, providing focused assistance
### 3\. Interactive `/help` Tool
### 3\. Interactive `/help` Tool The [`/help`](https://qodo-merge-docs.qodo.ai/tools/help/) command not only lists available tools and their descriptions but also enables immediate tool invocation through interactive checkboxes.
When a user checks a tool's checkbox, Qodo Merge instantly triggers that tool without requiring additional commands.
The [`/help`](https://qodo-merge-docs.qodo.ai/tools/help/) command not only lists available tools and their descriptions but also enables immediate tool invocation through interactive checkboxes.
When a user checks a tool's checkbox, Qodo Merge instantly triggers that tool without requiring additional commands.
This transforms the standard help menu into an interactive launch pad for all Qodo Merge capabilities, eliminating context switching by keeping developers within their PR workflow. This transforms the standard help menu into an interactive launch pad for all Qodo Merge capabilities, eliminating context switching by keeping developers within their PR workflow.

View File

@ -1,4 +1,5 @@
## Local and global metadata injection with multi-stage analysis ## Local and global metadata injection with multi-stage analysis
1\. 1\.
Qodo Merge initially retrieves for each PR the following data: Qodo Merge initially retrieves for each PR the following data:
@ -23,7 +24,7 @@ This effectively enables multi-stage chain-of-thought analysis, without doing an
For example, when generating code suggestions for different files, Qodo Merge can inject the AI-generated ["Changes walkthrough"](https://github.com/Codium-ai/pr-agent/pull/1202#issue-2511546839) file summary in the prompt: For example, when generating code suggestions for different files, Qodo Merge can inject the AI-generated ["Changes walkthrough"](https://github.com/Codium-ai/pr-agent/pull/1202#issue-2511546839) file summary in the prompt:
``` ```diff
## File: 'src/file1.py' ## File: 'src/file1.py'
### AI-generated file summary: ### AI-generated file summary:
- edited function `func1` that does X - edited function `func1` that does X
@ -51,6 +52,5 @@ __old hunk__
3\. The entire PR files that were retrieved are also used to expand and enhance the PR context (see [Dynamic Context](https://qodo-merge-docs.qodo.ai/core-abilities/dynamic_context/)). 3\. The entire PR files that were retrieved are also used to expand and enhance the PR context (see [Dynamic Context](https://qodo-merge-docs.qodo.ai/core-abilities/dynamic_context/)).
4\. All the metadata described above represents several level of cumulative analysis - ranging from hunk level, to file level, to PR level, to organization level. 4\. All the metadata described above represents several level of cumulative analysis - ranging from hunk level, to file level, to PR level, to organization level.
This comprehensive approach enables Qodo Merge AI models to generate more precise and contextually relevant suggestions and feedback. This comprehensive approach enables Qodo Merge AI models to generate more precise and contextually relevant suggestions and feedback.

View File

@ -1,12 +1,11 @@
# RAG Context Enrichment 💎 # RAG Context Enrichment 💎
`Supported Git Platforms: GitHub` `Supported Git Platforms: GitHub, Bitbucket Data Center`
!!! info "Prerequisites" !!! info "Prerequisites"
- RAG is available only for Qodo enterprise plan users, with single tenant or on-premises setup. - RAG is available only for Qodo enterprise plan users, with single tenant or on-premises setup.
- Database setup and codebase indexing must be completed before proceeding. [Contact support](https://www.qodo.ai/contact/) for more information. - Database setup and codebase indexing must be completed before proceeding. [Contact support](https://www.qodo.ai/contact/) for more information.
## Overview ## Overview
### What is RAG Context Enrichment? ### What is RAG Context Enrichment?
@ -17,13 +16,13 @@ A feature that enhances AI analysis by retrieving and referencing relevant code
Using Retrieval-Augmented Generation (RAG), it searches your configured repositories for contextually relevant code segments, enriching pull request (PR) insights and accelerating review accuracy. Using Retrieval-Augmented Generation (RAG), it searches your configured repositories for contextually relevant code segments, enriching pull request (PR) insights and accelerating review accuracy.
## Getting started ## Getting started
### Configuration options ### Configuration options
In order to enable the RAG feature, add the following lines to your configuration file: In order to enable the RAG feature, add the following lines to your configuration file:
``` toml
```toml
[rag_arguments] [rag_arguments]
enable_rag=true enable_rag=true
``` ```
@ -43,36 +42,36 @@ enable_rag=true
### Applications ### Applications
#### 1\. The `/review` Tool RAG capability is exclusively available in the following tools:
The [`/review`](https://qodo-merge-docs.qodo.ai/tools/review/) tool offers the _Focus area from RAG data_ which contains feedback based on the RAG references analysis. === "`/review`"
The complete list of references found relevant to the PR will be shown in the _References_ section, helping developers understand the broader context by exploring the provided references. The [`/review`](https://qodo-merge-docs.qodo.ai/tools/review/) tool offers the _Focus area from RAG data_ which contains feedback based on the RAG references analysis.
The complete list of references found relevant to the PR will be shown in the _References_ section, helping developers understand the broader context by exploring the provided references.
![References](https://codium.ai/images/pr_agent/rag_review.png){width=640} ![RAGed review tool](https://codium.ai/images/pr_agent/rag_review.png){width=640}
#### 2\. The `/implement` Tool === "`/implement`"
The [`/implement`](https://qodo-merge-docs.qodo.ai/tools/implement/) tool utilizes the RAG feature to provide comprehensive context of the repository codebase, allowing it to generate more refined code output.
The _References_ section contains links to the content used to support the code generation.
The [`/implement`](https://qodo-merge-docs.qodo.ai/tools/implement/) tool utilizes the RAG feature to provide comprehensive context of the repository codebase, allowing it to generate more refined code output. ![RAGed implement tool](https://codium.ai/images/pr_agent/rag_implement.png){width=640}
The _References_ section contains links to the content used to support the code generation.
![References](https://codium.ai/images/pr_agent/rag_implement.png){width=640} === "`/ask`"
The [`/ask`](https://qodo-merge-docs.qodo.ai/tools/ask/) tool can access broader repository context through the RAG feature when answering questions that go beyond the PR scope alone.
#### 3\. The `/ask` Tool The _References_ section displays the additional repository content consulted to formulate the answer.
The [`/ask`](https://qodo-merge-docs.qodo.ai/tools/ask/) tool can access broader repository context through the RAG feature when answering questions that go beyond the PR scope alone.
The _References_ section displays the additional repository content consulted to formulate the answer.
![References](https://codium.ai/images/pr_agent/rag_ask.png){width=640}
![RAGed ask tool](https://codium.ai/images/pr_agent/rag_ask.png){width=640}
## Limitations ## Limitations
### Querying the codebase presents significant challenges ### Querying the codebase presents significant challenges
- **Search Method**: RAG uses natural language queries to find semantically relevant code sections - **Search Method**: RAG uses natural language queries to find semantically relevant code sections
- **Result Quality**: No guarantee that RAG results will be useful for all queries - **Result Quality**: No guarantee that RAG results will be useful for all queries
- **Scope Recommendation**: To reduce noise, focus on the PR repository rather than searching across multiple repositories - **Scope Recommendation**: To reduce noise, focus on the PR repository rather than searching across multiple repositories
### This feature has several requirements and restrictions ### This feature has several requirements and restrictions
- **Codebase**: Must be properly indexed for search functionality - **Codebase**: Must be properly indexed for search functionality
- **Security**: Requires secure and private indexed codebase implementation - **Security**: Requires secure and private indexed codebase implementation
- **Deployment**: Only available for Qodo Merge Enterprise plan using single tenant or on-premises setup - **Deployment**: Only available for Qodo Merge Enterprise plan using single tenant or on-premises setup

View File

@ -6,7 +6,6 @@ Configuration options allow users to set a score threshold for further filtering
## Introduction - Efficient Review with Hierarchical Presentation ## Introduction - Efficient Review with Hierarchical Presentation
Given that not all generated code suggestions will be relevant, it is crucial to enable users to review them in a fast and efficient way, allowing quick identification and filtering of non-applicable ones. Given that not all generated code suggestions will be relevant, it is crucial to enable users to review them in a fast and efficient way, allowing quick identification and filtering of non-applicable ones.
To achieve this goal, Qodo Merge offers a dedicated hierarchical structure when presenting suggestions to users: To achieve this goal, Qodo Merge offers a dedicated hierarchical structure when presenting suggestions to users:
@ -42,9 +41,9 @@ This results in a more refined and valuable set of suggestions for the user, sav
![self_reflection](https://codium.ai/images/pr_agent/self_reflection1.png){width=768} ![self_reflection](https://codium.ai/images/pr_agent/self_reflection1.png){width=768}
![self_reflection](https://codium.ai/images/pr_agent/self_reflection2.png){width=768} ![self_reflection](https://codium.ai/images/pr_agent/self_reflection2.png){width=768}
## Appendix - Relevant Configuration Options ## Appendix - Relevant Configuration Options
```
```toml
[pr_code_suggestions] [pr_code_suggestions]
suggestions_score_threshold = 0 # Filter out suggestions with a score below this threshold (0-10) suggestions_score_threshold = 0 # Filter out suggestions with a score below this threshold (0-10)
``` ```

View File

@ -7,14 +7,13 @@ It scans the PR code changes, finds all the code components (methods, functions,
!!! note "Language that are currently supported:" !!! note "Language that are currently supported:"
Python, Java, C++, JavaScript, TypeScript, C#. Python, Java, C++, JavaScript, TypeScript, C#.
## Capabilities ## Capabilities
### Analyze PR ### Analyze PR
The [`analyze`](https://qodo-merge-docs.qodo.ai/tools/analyze/) tool enables to interactively generate tests, docs, code suggestions and similar code search for each component that changed in the PR. The [`analyze`](https://qodo-merge-docs.qodo.ai/tools/analyze/) tool enables to interactively generate tests, docs, code suggestions and similar code search for each component that changed in the PR.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/analyze /analyze
``` ```
@ -29,9 +28,11 @@ Clicking on each checkbox will trigger the relevant tool for the selected compon
The [`test`](https://qodo-merge-docs.qodo.ai/tools/test/) tool generate tests for a selected component, based on the PR code changes. The [`test`](https://qodo-merge-docs.qodo.ai/tools/test/) tool generate tests for a selected component, based on the PR code changes.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/test component_name /test component_name
``` ```
where 'component_name' is the name of a specific component in the PR, Or be triggered interactively by using the `analyze` tool. where 'component_name' is the name of a specific component in the PR, Or be triggered interactively by using the `analyze` tool.
![test1](https://codium.ai/images/pr_agent/test1.png){width=768} ![test1](https://codium.ai/images/pr_agent/test1.png){width=768}
@ -40,6 +41,7 @@ where 'component_name' is the name of a specific component in the PR, Or be tri
The [`add_docs`](https://qodo-merge-docs.qodo.ai/tools/documentation/) tool scans the PR code changes, and automatically generate docstrings for any code components that changed in the PR. The [`add_docs`](https://qodo-merge-docs.qodo.ai/tools/documentation/) tool scans the PR code changes, and automatically generate docstrings for any code components that changed in the PR.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/add_docs component_name /add_docs component_name
``` ```
@ -49,8 +51,10 @@ Or be triggered interactively by using the `analyze` tool.
![Docs single component](https://codium.ai/images/pr_agent/docs_single_component.png){width=768} ![Docs single component](https://codium.ai/images/pr_agent/docs_single_component.png){width=768}
### Generate Code Suggestions for a Component ### Generate Code Suggestions for a Component
The [`improve_component`](https://qodo-merge-docs.qodo.ai/tools/improve_component/) tool generates code suggestions for a specific code component that changed in the PR. The [`improve_component`](https://qodo-merge-docs.qodo.ai/tools/improve_component/) tool generates code suggestions for a specific code component that changed in the PR.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/improve_component component_name /improve_component component_name
``` ```

View File

@ -1,101 +0,0 @@
# Qodo Merge Pull Request Benchmark
On coding tasks, the gap between open-source models and top closed-source models such as Claude and GPT is significant.
<br>
In practice, open-source models are unsuitable for most real-world code tasks, and require further fine-tuning to produce acceptable results.
_Qodo Merge pull request benchmark_ aims to benchmark models on their ability to be fine-tuned for a coding task.
Specifically, we chose to fine-tune open-source models on the task of analyzing a pull request, and providing useful feedback and code suggestions.
Here are the results:
<br>
<br>
**Model performance:**
| Model name | Model size [B] | Better than gpt-4 rate, after fine-tuning [%] |
|-----------------------------|----------------|----------------------------------------------|
| **DeepSeek 34B-instruct** | **34** | **40.7** |
| DeepSeek 34B-base | 34 | 38.2 |
| Phind-34b | 34 | 38 |
| Granite-34B | 34 | 37.6 |
| Codestral-22B-v0.1 | 22 | 32.7 |
| QWEN-1.5-32B | 32 | 29 |
| | | |
| **CodeQwen1.5-7B** | **7** | **35.4** |
| Llama-3.1-8B-Instruct | 8 | 35.2 |
| Granite-8b-code-instruct | 8 | 34.2 |
| CodeLlama-7b-hf | 7 | 31.8 |
| Gemma-7B | 7 | 27.2 |
| DeepSeek coder-7b-instruct | 7 | 26.8 |
| Llama-3-8B-Instruct | 8 | 26.8 |
| Mistral-7B-v0.1 | 7 | 16.1 |
<br>
**Fine-tuning impact:**
| Model name | Model size [B] | Fine-tuned | Better than gpt-4 rate [%] |
|---------------------------|----------------|------------|----------------------------|
| DeepSeek 34B-instruct | 34 | yes | 40.7 |
| DeepSeek 34B-instruct | 34 | no | 3.6 |
## Results analysis
- **Fine-tuning is a must** - without fine-tuning, open-source models provide poor results on most real-world code tasks, which include complicated prompt and lengthy context. We clearly see that without fine-tuning, deepseek model was 96.4% of the time inferior to GPT-4, while after fine-tuning, it is better 40.7% of the time.
- **Always start from a code-dedicated model** — When fine-tuning, always start from a code-dedicated model, and not from a general-usage model. The gaps in downstream results are very big.
- **Don't believe the hype** —newer models, or models from big-tech companies (Llama3, Gemma, Mistral), are not always better for fine-tuning.
- **The best large model** - For large 34B code-dedicated models, the gaps when doing proper fine-tuning are small. The current top model is **DeepSeek 34B-instruct**
- **The best small model** - For small 7B code-dedicated models, the gaps when fine-tuning are much larger. **CodeQWEN 1.5-7B** is by far the best model for fine-tuning.
- **Base vs. instruct** - For the top model (deepseek), we saw small advantage when starting from the instruct version. However, we recommend testing both versions on each specific task, as the base model is generally considered more suitable for fine-tuning.
## Dataset
### Training dataset
Our training dataset comprises 25,000 pull requests, aggregated from permissive license repos. For each pull request, we generated responses for the three main tools of Qodo Merge:
[Describe](https://qodo-merge-docs.qodo.ai/tools/describe/), [Review](https://qodo-merge-docs.qodo.ai/tools/improve/) and [Improve](https://qodo-merge-docs.qodo.ai/tools/improve/).
On the raw data collected, we employed various automatic and manual cleaning techniques to ensure the outputs were of the highest quality, and suitable for instruct-tuning.
Here are the prompts, and example outputs, used as input-output pairs to fine-tune the models:
| Tool | Prompt | Example output |
|----------|------------------------------------------------------------------------------------------------------------|----------------|
| Describe | [link](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/pr_description_prompts.toml) | [link](https://github.com/Codium-ai/pr-agent/pull/910#issue-2303989601) |
| Review | [link](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/pr_reviewer_prompts.toml) | [link](https://github.com/Codium-ai/pr-agent/pull/910#issuecomment-2118761219) |
| Improve | [link](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/pr_code_suggestions_prompts.toml) | [link](https://github.com/Codium-ai/pr-agent/pull/910#issuecomment-2118761309) |
### Evaluation dataset
- For each tool, we aggregated 200 additional examples to be used for evaluation. These examples were not used in the training dataset, and were manually selected to represent diverse real-world use-cases.
- For each test example, we generated two responses: one from the fine-tuned model, and one from the best code model in the world, `gpt-4-turbo-2024-04-09`.
- We used a third LLM to judge which response better answers the prompt, and will likely be perceived by a human as better response.
<br>
We experimented with three model as judges: `gpt-4-turbo-2024-04-09`, `gpt-4o`, and `claude-3-opus-20240229`. All three produced similar results, with the same ranking order. This strengthens the validity of our testing protocol.
The evaluation prompt can be found [here](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/pr_evaluate_prompt_response.toml)
Here is an example of a judge model feedback:
```
command: improve
model1_score: 9,
model2_score: 6,
why: |
Response 1 is better because it provides more actionable and specific suggestions that directly
enhance the code's maintainability, performance, and best practices. For example, it suggests
using a variable for reusable widget instances and using named routes for navigation, which
are practical improvements. In contrast, Response 2 focuses more on general advice and less
actionable suggestions, such as changing variable names and adding comments, which are less
critical for immediate code improvement."
```
## Comparing Top Closed-Source Models
Another application of the Pull Request Benchmark is comparing leading closed-source models to determine which performs better at analyzing pull request code.
The evaluation methodology resembles the approach used for evaluating fine-tuned models:
- We ran each model across 200 diverse pull requests, asking them to generate code suggestions using Qodo Merge's `improve` tool
- A third top model served as judge to determine which response better fulfilled the prompt and would likely be perceived as superior by human users

View File

@ -1,6 +1,6 @@
# Overview # Overview
[PR-Agent](https://github.com/Codium-ai/pr-agent) is an open-source tool to help efficiently review and handle pull requests. [PR-Agent](https://github.com/Codium-ai/pr-agent) is an open-source tool to help efficiently review and handle pull requests.
Qodo Merge is a hosted version of PR-Agent, designed for companies and teams that require additional features and capabilities Qodo Merge is a hosted version of PR-Agent, designed for companies and teams that require additional features and capabilities
- See the [Installation Guide](./installation/index.md) for instructions on installing and running the tool on different git platforms. - See the [Installation Guide](./installation/index.md) for instructions on installing and running the tool on different git platforms.
@ -22,76 +22,81 @@ To search the documentation site using natural language:
2) The bot will respond with an [answer](https://github.com/Codium-ai/pr-agent/pull/1241#issuecomment-2365259334) that includes relevant documentation links. 2) The bot will respond with an [answer](https://github.com/Codium-ai/pr-agent/pull/1241#issuecomment-2365259334) that includes relevant documentation links.
## Features ## Features
PR-Agent and Qodo Merge offers extensive pull request functionalities across various git providers: PR-Agent and Qodo Merge offers extensive pull request functionalities across various git providers:
| | | GitHub | GitLab | Bitbucket | Azure DevOps | | | | GitHub | GitLab | Bitbucket | Azure DevOps |
|-------|---------------------------------------------------------------------------------------------------------|:--------------------:|:--------------------:|:---------:|:------------:| | ----- | ------------------------------------------------------------------------------------------------------- |:------:|:------:|:---------:|:------------:|
| TOOLS | [Review](https://qodo-merge-docs.qodo.ai/tools/review/) | ✅ | ✅ | ✅ | ✅ | | TOOLS | [Review](https://qodo-merge-docs.qodo.ai/tools/review/) | ✅ | ✅ | ✅ | ✅ |
| | [Describe](https://qodo-merge-docs.qodo.ai/tools/describe/) | ✅ | ✅ | ✅ | ✅ | | | [Describe](https://qodo-merge-docs.qodo.ai/tools/describe/) | ✅ | ✅ | ✅ | ✅ |
| | [Improve](https://qodo-merge-docs.qodo.ai/tools/improve/) | ✅ | ✅ | ✅ | ✅ | | | [Improve](https://qodo-merge-docs.qodo.ai/tools/improve/) | ✅ | ✅ | ✅ | ✅ |
| | [Ask](https://qodo-merge-docs.qodo.ai/tools/ask/) | ✅ | ✅ | ✅ | ✅ | | | [Ask](https://qodo-merge-docs.qodo.ai/tools/ask/) | ✅ | ✅ | ✅ | ✅ |
| | ⮑ [Ask on code lines](https://qodo-merge-docs.qodo.ai/tools/ask/#ask-lines) | ✅ | ✅ | | | | | ⮑ [Ask on code lines](https://qodo-merge-docs.qodo.ai/tools/ask/#ask-lines) | ✅ | ✅ | | |
| | [Update CHANGELOG](https://qodo-merge-docs.qodo.ai/tools/update_changelog/) | ✅ | ✅ | ✅ | ✅ | | | [Update CHANGELOG](https://qodo-merge-docs.qodo.ai/tools/update_changelog/) | ✅ | ✅ | ✅ | ✅ |
| | [Help Docs](https://qodo-merge-docs.qodo.ai/tools/help_docs/?h=auto#auto-approval) | ✅ | ✅ | ✅ | | | | [Help Docs](https://qodo-merge-docs.qodo.ai/tools/help_docs/?h=auto#auto-approval) | ✅ | ✅ | ✅ | |
| | [Ticket Context](https://qodo-merge-docs.qodo.ai/core-abilities/fetching_ticket_context/) 💎 | ✅ | ✅ | ✅ | | | | [Ticket Context](https://qodo-merge-docs.qodo.ai/core-abilities/fetching_ticket_context/) 💎 | ✅ | ✅ | ✅ | |
| | [Utilizing Best Practices](https://qodo-merge-docs.qodo.ai/tools/improve/#best-practices) 💎 | ✅ | ✅ | ✅ | | | | [Utilizing Best Practices](https://qodo-merge-docs.qodo.ai/tools/improve/#best-practices) 💎 | ✅ | ✅ | ✅ | |
| | [PR Chat](https://qodo-merge-docs.qodo.ai/chrome-extension/features/#pr-chat) 💎 | ✅ | | | | | | [PR Chat](https://qodo-merge-docs.qodo.ai/chrome-extension/features/#pr-chat) 💎 | ✅ | | | |
| | [Suggestion Tracking](https://qodo-merge-docs.qodo.ai/tools/improve/#suggestion-tracking) 💎 | ✅ | ✅ | | | | | [Suggestion Tracking](https://qodo-merge-docs.qodo.ai/tools/improve/#suggestion-tracking) 💎 | ✅ | ✅ | | |
| | [CI Feedback](https://qodo-merge-docs.qodo.ai/tools/ci_feedback/) 💎 | ✅ | | | | | | [CI Feedback](https://qodo-merge-docs.qodo.ai/tools/ci_feedback/) 💎 | | | | |
| | [PR Documentation](https://qodo-merge-docs.qodo.ai/tools/documentation/) 💎 | ✅ | ✅ | | | | | [PR Documentation](https://qodo-merge-docs.qodo.ai/tools/documentation/) 💎 | ✅ | ✅ | | |
| | [Custom Labels](https://qodo-merge-docs.qodo.ai/tools/custom_labels/) 💎 | ✅ | ✅ | | | | | [Custom Labels](https://qodo-merge-docs.qodo.ai/tools/custom_labels/) 💎 | ✅ | ✅ | | |
| | [Analyze](https://qodo-merge-docs.qodo.ai/tools/analyze/) 💎 | ✅ | ✅ | | | | | [Analyze](https://qodo-merge-docs.qodo.ai/tools/analyze/) 💎 | ✅ | ✅ | | |
| | [Similar Code](https://qodo-merge-docs.qodo.ai/tools/similar_code/) 💎 | ✅ | | | | | | [Similar Code](https://qodo-merge-docs.qodo.ai/tools/similar_code/) 💎 | | | | |
| | [Custom Prompt](https://qodo-merge-docs.qodo.ai/tools/custom_prompt/) 💎 | ✅ | ✅ | ✅ | | | | [Custom Prompt](https://qodo-merge-docs.qodo.ai/tools/custom_prompt/) 💎 | ✅ | ✅ | ✅ | |
| | [Test](https://qodo-merge-docs.qodo.ai/tools/test/) 💎 | ✅ | ✅ | | | | | [Test](https://qodo-merge-docs.qodo.ai/tools/test/) 💎 | ✅ | ✅ | | |
| | [Implement](https://qodo-merge-docs.qodo.ai/tools/implement/) 💎 | ✅ | ✅ | ✅ | | | | [Implement](https://qodo-merge-docs.qodo.ai/tools/implement/) 💎 | ✅ | ✅ | ✅ | |
| | [Auto-Approve](https://qodo-merge-docs.qodo.ai/tools/improve/?h=auto#auto-approval) 💎 | ✅ | | | | | | [Scan Repo Discussions](https://qodo-merge-docs.qodo.ai/tools/scan_repo_discussions/) 💎 | ✅ | | | |
| | | | | | | | | [Auto-Approve](https://qodo-merge-docs.qodo.ai/tools/improve/?h=auto#auto-approval) 💎 | ✅ | ✅ | | |
| USAGE | [CLI](https://qodo-merge-docs.qodo.ai/usage-guide/automations_and_usage/#local-repo-cli) | ✅ | ✅ | | | | | | | | | |
| | [App / webhook](https://qodo-merge-docs.qodo.ai/usage-guide/automations_and_usage/#github-app) | ✅ | ✅ | ✅ | ✅ | | USAGE | [CLI](https://qodo-merge-docs.qodo.ai/usage-guide/automations_and_usage/#local-repo-cli) | ✅ | ✅ | ✅ | ✅ |
| | [Tagging bot](https://github.com/Codium-ai/pr-agent#try-it-now) | ✅ | | | | | | [App / webhook](https://qodo-merge-docs.qodo.ai/usage-guide/automations_and_usage/#github-app) | | ✅ | | |
| | [Actions](https://qodo-merge-docs.qodo.ai/installation/github/#run-as-a-github-action) | ✅ |✅| || | | [Tagging bot](https://github.com/Codium-ai/pr-agent#try-it-now) | ✅ | | | |
| | | | | | | | | [Actions](https://qodo-merge-docs.qodo.ai/installation/github/#run-as-a-github-action) | ✅ | ✅ | | |
| CORE | [PR compression](https://qodo-merge-docs.qodo.ai/core-abilities/compression_strategy/) | ✅ | ✅ | | | | | | | | | |
| | Adaptive and token-aware file patch fitting | ✅ | ✅ | ✅ | ✅ | | CORE | [PR compression](https://qodo-merge-docs.qodo.ai/core-abilities/compression_strategy/) | ✅ | ✅ | ✅ | ✅ |
| | [Multiple models support](https://qodo-merge-docs.qodo.ai/usage-guide/changing_a_model/) | ✅ | ✅ | ✅ | ✅ | | | Adaptive and token-aware file patch fitting | ✅ | ✅ | ✅ | ✅ |
| | [Local and global metadata](https://qodo-merge-docs.qodo.ai/core-abilities/metadata/) | ✅ || ✅ | | | | [Multiple models support](https://qodo-merge-docs.qodo.ai/usage-guide/changing_a_model/) | ✅ | | ✅ | |
| | [Dynamic context](https://qodo-merge-docs.qodo.ai/core-abilities/dynamic_context/) | ✅ | ✅ | ✅ | | | | [Local and global metadata](https://qodo-merge-docs.qodo.ai/core-abilities/metadata/) | ✅ | | ✅ | |
| | [Self reflection](https://qodo-merge-docs.qodo.ai/core-abilities/self_reflection/) | ✅ ||| ✅ | | | [Dynamic context](https://qodo-merge-docs.qodo.ai/core-abilities/dynamic_context/) | || | |
| | [Static code analysis](https://qodo-merge-docs.qodo.ai/core-abilities/static_code_analysis/) 💎 | ✅ | ✅ | | | | | [Self reflection](https://qodo-merge-docs.qodo.ai/core-abilities/self_reflection/) | | | ✅ | |
| | [Global and wiki configurations](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) 💎 | ✅ | ✅ | | | | | [Static code analysis](https://qodo-merge-docs.qodo.ai/core-abilities/static_code_analysis/) 💎 | ✅ | ✅ | | |
| | [PR interactive actions](https://www.qodo.ai/images/pr_agent/pr-actions.mp4) 💎 | ✅ | | | | | | [Global and wiki configurations](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) 💎 || | | |
| | [Impact Evaluation](https://qodo-merge-docs.qodo.ai/core-abilities/impact_evaluation/) 💎 | ✅ | ✅ | | | | | [PR interactive actions](https://www.qodo.ai/images/pr_agent/pr-actions.mp4) 💎 | ✅ | | | |
| | [Impact Evaluation](https://qodo-merge-docs.qodo.ai/core-abilities/impact_evaluation/) 💎 | ✅ | ✅ | | |
| | [Code Validation 💎](https://qodo-merge-docs.qodo.ai/core-abilities/code_validation/) | ✅ | ✅ | ✅ | ✅ |
| | [Auto Best Practices 💎](https://qodo-merge-docs.qodo.ai/core-abilities/auto_best_practices/) | ✅ | | | |
!!! note "💎 means Qodo Merge only" !!! note "💎 means Qodo Merge only"
All along the documentation, 💎 marks a feature available only in [Qodo Merge](https://www.codium.ai/pricing/){:target="_blank"}, and not in the open-source version. All along the documentation, 💎 marks a feature available only in [Qodo Merge](https://www.codium.ai/pricing/){:target="_blank"}, and not in the open-source version.
## Example Results ## Example Results
<hr> <hr>
#### [/describe](https://github.com/Codium-ai/pr-agent/pull/530) #### [/describe](https://github.com/Codium-ai/pr-agent/pull/530)
<figure markdown="1"> <figure markdown="1">
![/describe](https://www.codium.ai/images/pr_agent/describe_new_short_main.png){width=512} ![/describe](https://www.codium.ai/images/pr_agent/describe_new_short_main.png){width=512}
</figure> </figure>
<hr> <hr>
#### [/review](https://github.com/Codium-ai/pr-agent/pull/732#issuecomment-1975099151) #### [/review](https://github.com/Codium-ai/pr-agent/pull/732#issuecomment-1975099151)
<figure markdown="1"> <figure markdown="1">
![/review](https://www.codium.ai/images/pr_agent/review_new_short_main.png){width=512} ![/review](https://www.codium.ai/images/pr_agent/review_new_short_main.png){width=512}
</figure> </figure>
<hr> <hr>
#### [/improve](https://github.com/Codium-ai/pr-agent/pull/732#issuecomment-1975099159) #### [/improve](https://github.com/Codium-ai/pr-agent/pull/732#issuecomment-1975099159)
<figure markdown="1"> <figure markdown="1">
![/improve](https://www.codium.ai/images/pr_agent/improve_new_short_main.png){width=512} ![/improve](https://www.codium.ai/images/pr_agent/improve_new_short_main.png){width=512}
</figure> </figure>
<hr> <hr>
#### [/generate_labels](https://github.com/Codium-ai/pr-agent/pull/530) #### [/generate_labels](https://github.com/Codium-ai/pr-agent/pull/530)
<figure markdown="1"> <figure markdown="1">
![/generate_labels](https://www.codium.ai/images/pr_agent/geneare_custom_labels_main_short.png){width=300} ![/generate_labels](https://www.codium.ai/images/pr_agent/geneare_custom_labels_main_short.png){width=300}
</figure> </figure>

View File

@ -1,6 +1,8 @@
## Azure DevOps Pipeline ## Azure DevOps Pipeline
You can use a pre-built Action Docker image to run PR-Agent as an Azure devops pipeline. You can use a pre-built Action Docker image to run PR-Agent as an Azure devops pipeline.
add the following file to your repository under `azure-pipelines.yml`: add the following file to your repository under `azure-pipelines.yml`:
```yaml ```yaml
# Opt out of CI triggers # Opt out of CI triggers
trigger: none trigger: none
@ -49,6 +51,7 @@ stages:
openai__key: $(OPENAI_KEY) openai__key: $(OPENAI_KEY)
displayName: 'Run Qodo Merge' displayName: 'Run Qodo Merge'
``` ```
This script will run Qodo Merge on every new merge request, with the `improve`, `review`, and `describe` commands. This script will run Qodo Merge on every new merge request, with the `improve`, `review`, and `describe` commands.
Note that you need to export the `azure_devops__pat` and `OPENAI_KEY` variables in the Azure DevOps pipeline settings (Pipelines -> Library -> + Variable group): Note that you need to export the `azure_devops__pat` and `OPENAI_KEY` variables in the Azure DevOps pipeline settings (Pipelines -> Library -> + Variable group):
@ -61,7 +64,8 @@ Make sure to give pipeline permissions to the `pr_agent` variable group.
## Azure DevOps from CLI ## Azure DevOps from CLI
To use Azure DevOps provider use the following settings in configuration.toml: To use Azure DevOps provider use the following settings in configuration.toml:
```
```toml
[config] [config]
git_provider="azure" git_provider="azure"
``` ```
@ -74,7 +78,8 @@ If PAT was chosen, you can assign the value in .secrets.toml.
If DefaultAzureCredential was chosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly, If DefaultAzureCredential was chosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly,
or use managed identity/az cli (for local development) without any additional configuration. or use managed identity/az cli (for local development) without any additional configuration.
in any case, 'org' value must be assigned in .secrets.toml: in any case, 'org' value must be assigned in .secrets.toml:
```
```toml
[azure_devops] [azure_devops]
org = "https://dev.azure.com/YOUR_ORGANIZATION/" org = "https://dev.azure.com/YOUR_ORGANIZATION/"
# pat = "YOUR_PAT_TOKEN" needed only if using PAT for authentication # pat = "YOUR_PAT_TOKEN" needed only if using PAT for authentication
@ -85,11 +90,12 @@ org = "https://dev.azure.com/YOUR_ORGANIZATION/"
To trigger from an Azure webhook, you need to manually [add a webhook](https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops). To trigger from an Azure webhook, you need to manually [add a webhook](https://learn.microsoft.com/en-us/azure/devops/service-hooks/services/webhooks?view=azure-devops).
Use the "Pull request created" type to trigger a review, or "Pull request commented on" to trigger any supported comment with /<command> <args> comment on the relevant PR. Note that for the "Pull request commented on" trigger, only API v2.0 is supported. Use the "Pull request created" type to trigger a review, or "Pull request commented on" to trigger any supported comment with /<command> <args> comment on the relevant PR. Note that for the "Pull request commented on" trigger, only API v2.0 is supported.
For webhook security, create a sporadic username/password pair and configure the webhook username and password on both the server and Azure DevOps webhook. These will be sent as basic Auth data by the webhook with each request: For webhook security, create a sporadic username/password pair and configure the webhook username and password on both the server and Azure DevOps webhook. These will be sent as basic Auth data by the webhook with each request:
```
```toml
[azure_devops_server] [azure_devops_server]
webhook_username = "<basic auth user>" webhook_username = "<basic auth user>"
webhook_password = "<basic auth password>" webhook_password = "<basic auth password>"
``` ```
> :warning: **Ensure that the webhook endpoint is only accessible over HTTPS** to mitigate the risk of credential interception when using basic authentication. > :warning: **Ensure that the webhook endpoint is only accessible over HTTPS** to mitigate the risk of credential interception when using basic authentication.

View File

@ -6,22 +6,22 @@ You can use the Bitbucket Pipeline system to run PR-Agent on every pull request
```yaml ```yaml
pipelines: pipelines:
pull-requests: pull-requests:
"**": '**':
- step: - step:
name: PR Agent Review name: PR Agent Review
image: python:3.12 image: codiumai/pr-agent:latest
services: script:
- docker - pr-agent --pr_url=https://bitbucket.org/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG/pull-requests/$BITBUCKET_PR_ID review
script:
- docker run -e CONFIG.GIT_PROVIDER=bitbucket -e OPENAI.KEY=$OPENAI_API_KEY -e BITBUCKET.BEARER_TOKEN=$BITBUCKET_BEARER_TOKEN codiumai/pr-agent:latest --pr_url=https://bitbucket.org/$BITBUCKET_WORKSPACE/$BITBUCKET_REPO_SLUG/pull-requests/$BITBUCKET_PR_ID review
``` ```
2. Add the following secure variables to your repository under Repository settings > Pipelines > Repository variables. 2. Add the following secure variables to your repository under Repository settings > Pipelines > Repository variables.
OPENAI_API_KEY: `<your key>`
BITBUCKET.AUTH_TYPE: `basic` or `bearer` (default is `bearer`) - CONFIG__GIT_PROVIDER: `bitbucket`
BITBUCKET.BEARER_TOKEN: `<your token>` (required when auth_type is bearer) - OPENAI__KEY: `<your key>`
BITBUCKET.BASIC_TOKEN: `<your token>` (required when auth_type is basic) - BITBUCKET__AUTH_TYPE: `basic` or `bearer` (default is `bearer`)
- BITBUCKET__BEARER_TOKEN: `<your token>` (required when auth_type is bearer)
- BITBUCKET__BASIC_TOKEN: `<your token>` (required when auth_type is basic)
You can get a Bitbucket token for your repository by following Repository Settings -> Security -> Access Tokens. You can get a Bitbucket token for your repository by following Repository Settings -> Security -> Access Tokens.
For basic auth, you can generate a base64 encoded token from your username:password combination. For basic auth, you can generate a base64 encoded token from your username:password combination.
@ -57,7 +57,7 @@ python cli.py --pr_url https://git.onpreminstanceofbitbucket.com/projects/PROJEC
To run PR-Agent as webhook, build the docker image: To run PR-Agent as webhook, build the docker image:
``` ```bash
docker build . -t codiumai/pr-agent:bitbucket_server_webhook --target bitbucket_server_webhook -f docker/Dockerfile docker build . -t codiumai/pr-agent:bitbucket_server_webhook --target bitbucket_server_webhook -f docker/Dockerfile
docker push codiumai/pr-agent:bitbucket_server_webhook # Push to your Docker repository docker push codiumai/pr-agent:bitbucket_server_webhook # Push to your Docker repository
``` ```

View File

@ -40,6 +40,7 @@ The GITHUB_TOKEN secret is automatically created by GitHub.
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. 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 Qodo Merge by adding environment variables under the env section corresponding to any configurable property in the [configuration](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) file. Some examples: 4) You may configure Qodo Merge by adding environment variables under the env section corresponding to any configurable property in the [configuration](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) file. Some examples:
```yaml ```yaml
env: env:
# ... previous environment values # ... previous environment values
@ -47,9 +48,11 @@ When you open your next PR, you should see a comment from `github-actions` bot w
PR_REVIEWER.REQUIRE_TESTS_REVIEW: "false" # Disable tests review PR_REVIEWER.REQUIRE_TESTS_REVIEW: "false" # Disable tests review
PR_CODE_SUGGESTIONS.NUM_CODE_SUGGESTIONS: 6 # Increase number of code suggestions PR_CODE_SUGGESTIONS.NUM_CODE_SUGGESTIONS: 6 # Increase number of code suggestions
``` ```
See detailed usage instructions in the [USAGE GUIDE](https://qodo-merge-docs.qodo.ai/usage-guide/automations_and_usage/#github-action) See detailed usage instructions in the [USAGE GUIDE](https://qodo-merge-docs.qodo.ai/usage-guide/automations_and_usage/#github-action)
### Using a specific release ### Using a specific release
!!! tip "" !!! tip ""
if you want to pin your action to a specific release (v0.23 for example) for stability reasons, use: if you want to pin your action to a specific release (v0.23 for example) for stability reasons, use:
```yaml ```yaml
@ -72,6 +75,7 @@ See detailed usage instructions in the [USAGE GUIDE](https://qodo-merge-docs.qod
``` ```
### Action for GitHub enterprise server ### Action for GitHub enterprise server
!!! tip "" !!! tip ""
To use the action with a GitHub enterprise server, add an environment variable `GITHUB.BASE_URL` with the API URL of your GitHub server. To use the action with a GitHub enterprise server, add an environment variable `GITHUB.BASE_URL` with the API URL of your GitHub server.
@ -82,10 +86,10 @@ See detailed usage instructions in the [USAGE GUIDE](https://qodo-merge-docs.qod
GITHUB.BASE_URL: "https://github.mycompany.com/api/v3" GITHUB.BASE_URL: "https://github.mycompany.com/api/v3"
``` ```
--- ---
## Run as a GitHub App ## Run as a GitHub App
Allowing you to automate the review process on your private or public repositories. Allowing you to automate the review process on your private or public repositories.
1) Create a GitHub App from the [Github Developer Portal](https://docs.github.com/en/developers/apps/creating-a-github-app). 1) Create a GitHub App from the [Github Developer Portal](https://docs.github.com/en/developers/apps/creating-a-github-app).
@ -102,7 +106,7 @@ Allowing you to automate the review process on your private or public repositori
2) Generate a random secret for your app, and save it for later. For example, you can use: 2) Generate a random secret for your app, and save it for later. For example, you can use:
``` ```bash
WEBHOOK_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))") WEBHOOK_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))")
``` ```
@ -113,28 +117,29 @@ WEBHOOK_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))")
4) Clone this repository: 4) Clone this repository:
``` ```bash
git clone https://github.com/Codium-ai/pr-agent.git git clone https://github.com/Codium-ai/pr-agent.git
``` ```
5) Copy the secrets template file and fill in the following: 5) Copy the secrets template file and fill in the following:
``` ```bash
cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml
# Edit .secrets.toml file # Edit .secrets.toml file
``` ```
- Your OpenAI key. - Your OpenAI key.
- Copy your app's private key to the private_key field. - Copy your app's private key to the private_key field.
- Copy your app's ID to the app_id field. - Copy your app's ID to the app_id field.
- Copy your app's webhook secret to the webhook_secret field. - Copy your app's webhook secret to the webhook_secret field.
- Set deployment_type to 'app' in [configuration.toml](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) - Set deployment_type to 'app' in [configuration.toml](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml)
> The .secrets.toml file is not copied to the Docker image by default, and is only used for local development. > The .secrets.toml file is not copied to the Docker image by default, and is only used for local development.
> If you want to use the .secrets.toml file in your Docker image, you can add remove it from the .dockerignore file. > If you want to use the .secrets.toml file in your Docker image, you can add remove it from the .dockerignore file.
> In most production environments, you would inject the secrets file as environment variables or as mounted volumes. > In most production environments, you would inject the secrets file as environment variables or as mounted volumes.
> For example, in order to inject a secrets file as a volume in a Kubernetes environment you can update your pod spec to include the following, > For example, in order to inject a secrets file as a volume in a Kubernetes environment you can update your pod spec to include the following,
> assuming you have a secret named `pr-agent-settings` with a key named `.secrets.toml`: > assuming you have a secret named `pr-agent-settings` with a key named `.secrets.toml`:
``` ```
volumes: volumes:
- name: settings-volume - name: settings-volume
@ -152,7 +157,7 @@ cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml
6) Build a Docker image for the app and optionally push it to a Docker repository. We'll use Dockerhub as an example: 6) Build a Docker image for the app and optionally push it to a Docker repository. We'll use Dockerhub as an example:
``` ```bash
docker build . -t codiumai/pr-agent:github_app --target github_app -f docker/Dockerfile docker build . -t codiumai/pr-agent:github_app --target github_app -f docker/Dockerfile
docker push codiumai/pr-agent:github_app # Push to your Docker repository docker push codiumai/pr-agent:github_app # Push to your Docker repository
``` ```
@ -180,14 +185,19 @@ For example: `GITHUB.WEBHOOK_SECRET` --> `GITHUB__WEBHOOK_SECRET`
1. Follow steps 1-5 from [here](#run-as-a-github-app). 1. Follow steps 1-5 from [here](#run-as-a-github-app).
2. Build a docker image that can be used as a lambda function 2. Build a docker image that can be used as a lambda function
```shell ```shell
docker buildx build --platform=linux/amd64 . -t codiumai/pr-agent:serverless -f docker/Dockerfile.lambda docker buildx build --platform=linux/amd64 . -t codiumai/pr-agent:serverless -f docker/Dockerfile.lambda
``` ```
3. Push image to ECR 3. Push image to ECR
```shell ```shell
docker tag codiumai/pr-agent:serverless <AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com/codiumai/pr-agent:serverless
docker push <AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com/codiumai/pr-agent:serverless docker tag codiumai/pr-agent:serverless <AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com/codiumai/pr-agent:serverless
docker push <AWS_ACCOUNT>.dkr.ecr.<AWS_REGION>.amazonaws.com/codiumai/pr-agent:serverless
``` ```
4. Create a lambda function that uses the uploaded image. Set the lambda timeout to be at least 3m. 4. Create a lambda function that uses the uploaded image. Set the lambda timeout to be at least 3m.
5. Configure the lambda function to have a Function URL. 5. Configure the lambda function to have a Function URL.
6. In the environment variables of the Lambda function, specify `AZURE_DEVOPS_CACHE_DIR` to a writable location such as /tmp. (see [link](https://github.com/Codium-ai/pr-agent/pull/450#issuecomment-1840242269)) 6. In the environment variables of the Lambda function, specify `AZURE_DEVOPS_CACHE_DIR` to a writable location such as /tmp. (see [link](https://github.com/Codium-ai/pr-agent/pull/450#issuecomment-1840242269))
@ -201,28 +211,27 @@ For example: `GITHUB.WEBHOOK_SECRET` --> `GITHUB__WEBHOOK_SECRET`
Not all features have been added to CodeCommit yet. As of right now, CodeCommit has been implemented to run the Qodo Merge CLI on the command line, using AWS credentials stored in environment variables. (More features will be added in the future.) The following is a set of instructions to have Qodo Merge do a review of your CodeCommit pull request from the command line: Not all features have been added to CodeCommit yet. As of right now, CodeCommit has been implemented to run the Qodo Merge CLI on the command line, using AWS credentials stored in environment variables. (More features will be added in the future.) The following is a set of instructions to have Qodo Merge do a review of your CodeCommit pull request from the command line:
1. Create an IAM user that you will use to read CodeCommit pull requests and post comments 1. Create an IAM user that you will use to read CodeCommit pull requests and post comments
* Note: That user should have CLI access only, not Console access - Note: That user should have CLI access only, not Console access
2. Add IAM permissions to that user, to allow access to CodeCommit (see IAM Role example below) 2. Add IAM permissions to that user, to allow access to CodeCommit (see IAM Role example below)
3. Generate an Access Key for your IAM user 3. Generate an Access Key for your IAM user
4. Set the Access Key and Secret using environment variables (see Access Key example below) 4. Set the Access Key and Secret using environment variables (see Access Key example below)
5. Set the `git_provider` value to `codecommit` in the `pr_agent/settings/configuration.toml` settings file 5. Set the `git_provider` value to `codecommit` in the `pr_agent/settings/configuration.toml` settings file
6. Set the `PYTHONPATH` to include your `pr-agent` project directory 6. Set the `PYTHONPATH` to include your `pr-agent` project directory
* Option A: Add `PYTHONPATH="/PATH/TO/PROJECTS/pr-agent` to your `.env` file - Option A: Add `PYTHONPATH="/PATH/TO/PROJECTS/pr-agent` to your `.env` file
* Option B: Set `PYTHONPATH` and run the CLI in one command, for example: - Option B: Set `PYTHONPATH` and run the CLI in one command, for example:
* `PYTHONPATH="/PATH/TO/PROJECTS/pr-agent python pr_agent/cli.py [--ARGS]` - `PYTHONPATH="/PATH/TO/PROJECTS/pr-agent python pr_agent/cli.py [--ARGS]`
--- ---
#### AWS CodeCommit IAM Role Example #### AWS CodeCommit IAM Role Example
Example IAM permissions to that user to allow access to CodeCommit: Example IAM permissions to that user to allow access to CodeCommit:
* Note: The following is a working example of IAM permissions that has read access to the repositories and write access to allow posting comments - Note: The following is a working example of IAM permissions that has read access to the repositories and write access to allow posting comments
* Note: If you only want pr-agent to review your pull requests, you can tighten the IAM permissions further, however this IAM example will work, and allow the pr-agent to post comments to the PR - Note: If you only want pr-agent to review your pull requests, you can tighten the IAM permissions further, however this IAM example will work, and allow the pr-agent to post comments to the PR
* Note: You may want to replace the `"Resource": "*"` with your list of repos, to limit access to only those repos - Note: You may want to replace the `"Resource": "*"` with your list of repos, to limit access to only those repos
``` ```json
{ {
"Version": "2012-10-17", "Version": "2012-10-17",
"Statement": [ "Statement": [

View File

@ -1,7 +1,9 @@
## Run as a GitLab Pipeline ## Run as a GitLab Pipeline
You can use a pre-built Action Docker image to run PR-Agent as a GitLab pipeline. This is a simple way to get started with Qodo Merge without setting up your own server. You can use a pre-built Action Docker image to run PR-Agent as a GitLab pipeline. This is a simple way to get started with Qodo Merge without setting up your own server.
(1) Add the following file to your repository under `.gitlab-ci.yml`: (1) Add the following file to your repository under `.gitlab-ci.yml`:
```yaml ```yaml
stages: stages:
- pr_agent - pr_agent
@ -26,10 +28,10 @@ pr_agent_job:
rules: rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"' - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
``` ```
This script will run Qodo Merge on every new merge request. You can modify the `rules` section to run Qodo Merge on different events. This script will run Qodo Merge on every new merge request. You can modify the `rules` section to run Qodo Merge on different events.
You can also modify the `script` section to run different Qodo Merge commands, or with different parameters by exporting different environment variables. You can also modify the `script` section to run different Qodo Merge commands, or with different parameters by exporting different environment variables.
(2) Add the following masked variables to your GitLab repository (CI/CD -> Variables): (2) Add the following masked variables to your GitLab repository (CI/CD -> Variables):
- `GITLAB_PERSONAL_ACCESS_TOKEN`: Your GitLab personal access token. - `GITLAB_PERSONAL_ACCESS_TOKEN`: Your GitLab personal access token.
@ -40,7 +42,6 @@ Note that if your base branches are not protected, don't set the variables as `p
> **Note**: The `$CI_SERVER_FQDN` variable is available starting from GitLab version 16.10. If you're using an earlier version, this variable will not be available. However, you can combine `$CI_SERVER_HOST` and `$CI_SERVER_PORT` to achieve the same result. Please ensure you're using a compatible version or adjust your configuration. > **Note**: The `$CI_SERVER_FQDN` variable is available starting from GitLab version 16.10. If you're using an earlier version, this variable will not be available. However, you can combine `$CI_SERVER_HOST` and `$CI_SERVER_PORT` to achieve the same result. Please ensure you're using a compatible version or adjust your configuration.
## Run a GitLab webhook server ## Run a GitLab webhook server
1. In GitLab create a new user and give it "Reporter" role ("Developer" if using Pro version of the agent) for the intended group or project. 1. In GitLab create a new user and give it "Reporter" role ("Developer" if using Pro version of the agent) for the intended group or project.
@ -49,41 +50,41 @@ Note that if your base branches are not protected, don't set the variables as `p
3. Generate a random secret for your app, and save it for later (`shared_secret`). For example, you can use: 3. Generate a random secret for your app, and save it for later (`shared_secret`). For example, you can use:
``` ```bash
SHARED_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))") SHARED_SECRET=$(python -c "import secrets; print(secrets.token_hex(10))")
``` ```
4. Clone this repository: 4. Clone this repository:
``` ```bash
git clone https://github.com/qodo-ai/pr-agent.git git clone https://github.com/qodo-ai/pr-agent.git
``` ```
5. Prepare variables and secrets. Skip this step if you plan on setting these as environment variables when running the agent: 5. Prepare variables and secrets. Skip this step if you plan on setting these as environment variables when running the agent:
1. In the configuration file/variables: 1. In the configuration file/variables:
- Set `config.git_provider` to "gitlab" - Set `config.git_provider` to "gitlab"
2. In the secrets file/variables: 2. In the secrets file/variables:
- Set your AI model key in the respective section - Set your AI model key in the respective section
- In the [gitlab] section, set `personal_access_token` (with token from step 2) and `shared_secret` (with secret from step 3) - In the [gitlab] section, set `personal_access_token` (with token from step 2) and `shared_secret` (with secret from step 3)
6. Build a Docker image for the app and optionally push it to a Docker repository. We'll use Dockerhub as an example: 6. Build a Docker image for the app and optionally push it to a Docker repository. We'll use Dockerhub as an example:
```
```bash
docker build . -t gitlab_pr_agent --target gitlab_webhook -f docker/Dockerfile docker build . -t gitlab_pr_agent --target gitlab_webhook -f docker/Dockerfile
docker push codiumai/pr-agent:gitlab_webhook # Push to your Docker repository docker push codiumai/pr-agent:gitlab_webhook # Push to your Docker repository
``` ```
7. Set the environmental variables, the method depends on your docker runtime. Skip this step if you included your secrets/configuration directly in the Docker image. 7. Set the environmental variables, the method depends on your docker runtime. Skip this step if you included your secrets/configuration directly in the Docker image.
``` ```bash
"CONFIG.GIT_PROVIDER": "gitlab" CONFIG__GIT_PROVIDER=gitlab
"GITLAB.PERSONAL_ACCESS_TOKEN": "<personal_access_token>" GITLAB__PERSONAL_ACCESS_TOKEN=<personal_access_token>
"GITLAB.SHARED_SECRET": "<shared_secret>" GITLAB__SHARED_SECRET=<shared_secret>
"GITLAB.URL": "https://gitlab.com" GITLAB__URL=https://gitlab.com
"OPENAI.KEY": "<your_openai_api_key>" OPENAI__KEY=<your_openai_api_key>
``` ```
8. Create a webhook in your GitLab project. Set the URL to ```http[s]://<PR_AGENT_HOSTNAME>/webhook```, the secret token to the generated secret from step 3, and enable the triggers `push`, `comments` and `merge request events`. 8. Create a webhook in your GitLab project. Set the URL to `http[s]://<PR_AGENT_HOSTNAME>/webhook`, the secret token to the generated secret from step 3, and enable the triggers `push`, `comments` and `merge request events`.
9. Test your installation by opening a merge request or commenting on a merge request using one of PR Agent's commands. 9. Test your installation by opening a merge request or commenting on a merge request using one of PR Agent's commands.

View File

@ -11,6 +11,7 @@ There are several ways to use self-hosted PR-Agent:
- [Azure DevOps integration](./azure.md) - [Azure DevOps integration](./azure.md)
## Qodo Merge 💎 ## Qodo Merge 💎
Qodo Merge, an app hosted by QodoAI for GitHub\GitLab\BitBucket, is also available. Qodo Merge, an app hosted by QodoAI for GitHub\GitLab\BitBucket, is also available.
<br> <br>
With Qodo Merge, installation is as simple as adding the Qodo Merge app to your relevant repositories. With Qodo Merge, installation is as simple as adding the Qodo Merge app to your relevant repositories.

View File

@ -1,9 +1,8 @@
To run PR-Agent locally, you first need to acquire two keys: To run PR-Agent locally, you first need to acquire two keys:
1. An OpenAI key from [here](https://platform.openai.com/api-keys){:target="_blank"}, with access to GPT-4 and o3-mini (or a key for other [language models](https://qodo-merge-docs.qodo.ai/usage-guide/changing_a_model/), if you prefer). 1. An OpenAI key from [here](https://platform.openai.com/api-keys){:target="_blank"}, with access to GPT-4 and o4-mini (or a key for other [language models](https://qodo-merge-docs.qodo.ai/usage-guide/changing_a_model/), if you prefer).
2. A personal access token from your Git platform (GitHub, GitLab, BitBucket) with repo scope. GitHub token, for example, can be issued from [here](https://github.com/settings/tokens){:target="_blank"} 2. A personal access token from your Git platform (GitHub, GitLab, BitBucket) with repo scope. GitHub token, for example, can be issued from [here](https://github.com/settings/tokens){:target="_blank"}
## Using Docker image ## Using Docker image
A list of the relevant tools can be found in the [tools guide](../tools/). A list of the relevant tools can be found in the [tools guide](../tools/).
@ -11,27 +10,33 @@ A list of the relevant tools can be found in the [tools guide](../tools/).
To invoke a tool (for example `review`), you can run PR-Agent directly from the Docker image. Here's how: To invoke a tool (for example `review`), you can run PR-Agent directly from the Docker image. Here's how:
- For GitHub: - For GitHub:
```
```bash
docker run --rm -it -e OPENAI.KEY=<your key> -e GITHUB.USER_TOKEN=<your token> codiumai/pr-agent:latest --pr_url <pr_url> review docker run --rm -it -e OPENAI.KEY=<your key> -e GITHUB.USER_TOKEN=<your token> codiumai/pr-agent:latest --pr_url <pr_url> review
``` ```
If you are using GitHub enterprise server, you need to specify the custom url as variable. If you are using GitHub enterprise server, you need to specify the custom url as variable.
For example, if your GitHub server is at `https://github.mycompany.com`, add the following to the command: For example, if your GitHub server is at `https://github.mycompany.com`, add the following to the command:
```
```bash
-e GITHUB.BASE_URL=https://github.mycompany.com/api/v3 -e GITHUB.BASE_URL=https://github.mycompany.com/api/v3
``` ```
- For GitLab: - For GitLab:
```
```bash
docker run --rm -it -e OPENAI.KEY=<your key> -e CONFIG.GIT_PROVIDER=gitlab -e GITLAB.PERSONAL_ACCESS_TOKEN=<your token> codiumai/pr-agent:latest --pr_url <pr_url> review docker run --rm -it -e OPENAI.KEY=<your key> -e CONFIG.GIT_PROVIDER=gitlab -e GITLAB.PERSONAL_ACCESS_TOKEN=<your token> codiumai/pr-agent:latest --pr_url <pr_url> review
``` ```
If you have a dedicated GitLab instance, you need to specify the custom url as variable: If you have a dedicated GitLab instance, you need to specify the custom url as variable:
```
```bash
-e GITLAB.URL=<your gitlab instance url> -e GITLAB.URL=<your gitlab instance url>
``` ```
- For BitBucket: - For BitBucket:
```
```bash
docker run --rm -it -e CONFIG.GIT_PROVIDER=bitbucket -e OPENAI.KEY=$OPENAI_API_KEY -e BITBUCKET.BEARER_TOKEN=$BITBUCKET_BEARER_TOKEN codiumai/pr-agent:latest --pr_url=<pr_url> review docker run --rm -it -e CONFIG.GIT_PROVIDER=bitbucket -e OPENAI.KEY=$OPENAI_API_KEY -e BITBUCKET.BEARER_TOKEN=$BITBUCKET_BEARER_TOKEN codiumai/pr-agent:latest --pr_url=<pr_url> review
``` ```
@ -46,7 +51,7 @@ The `<TABLE>` refers to a table/section in a configuration file and `<KEY>=<VALU
For example, suppose you want to run `pr_agent` that connects to a self-hosted GitLab instance similar to an example above. For example, suppose you want to run `pr_agent` that connects to a self-hosted GitLab instance similar to an example above.
You can define the environment variables in a plain text file named `.env` with the following content: You can define the environment variables in a plain text file named `.env` with the following content:
``` ```bash
CONFIG__GIT_PROVIDER="gitlab" CONFIG__GIT_PROVIDER="gitlab"
GITLAB__URL="<your url>" GITLAB__URL="<your url>"
GITLAB__PERSONAL_ACCESS_TOKEN="<your token>" GITLAB__PERSONAL_ACCESS_TOKEN="<your token>"
@ -76,7 +81,7 @@ Same goes for other providers, make sure to check the [documentation](https://qo
Install the package: Install the package:
``` ```bash
pip install pr-agent pip install pr-agent
``` ```
@ -109,18 +114,17 @@ if __name__ == '__main__':
main() main()
``` ```
## Run from source ## Run from source
1. Clone this repository: 1. Clone this repository:
``` ```bash
git clone https://github.com/Codium-ai/pr-agent.git git clone https://github.com/Codium-ai/pr-agent.git
``` ```
2. Navigate to the `/pr-agent` folder and install the requirements in your favorite virtual environment: 2. Navigate to the `/pr-agent` folder and install the requirements in your favorite virtual environment:
``` ```bash
pip install -e . pip install -e .
``` ```
@ -128,7 +132,7 @@ pip install -e .
3. Copy the secrets template file and fill in your OpenAI key and your GitHub user token: 3. Copy the secrets template file and fill in your OpenAI key and your GitHub user token:
``` ```bash
cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml cp pr_agent/settings/.secrets_template.toml pr_agent/settings/.secrets.toml
chmod 600 pr_agent/settings/.secrets.toml chmod 600 pr_agent/settings/.secrets.toml
# Edit .secrets.toml file # Edit .secrets.toml file
@ -136,7 +140,7 @@ chmod 600 pr_agent/settings/.secrets.toml
4. Run the cli.py script: 4. Run the cli.py script:
``` ```bash
python3 -m pr_agent.cli --pr_url <pr_url> review python3 -m pr_agent.cli --pr_url <pr_url> review
python3 -m pr_agent.cli --pr_url <pr_url> ask <your question> python3 -m pr_agent.cli --pr_url <pr_url> ask <your question>
python3 -m pr_agent.cli --pr_url <pr_url> describe python3 -m pr_agent.cli --pr_url <pr_url> describe
@ -148,6 +152,7 @@ python3 -m pr_agent.cli --issue_url <issue_url> similar_issue
``` ```
[Optional] Add the pr_agent folder to your PYTHONPATH [Optional] Add the pr_agent folder to your PYTHONPATH
```
```bash
export PYTHONPATH=$PYTHONPATH:<PATH to pr_agent folder> export PYTHONPATH=$PYTHONPATH:<PATH to pr_agent folder>
``` ```

View File

@ -46,4 +46,4 @@ Configure PR-Agent with Azure DevOps as:
- Azure DevOps pipeline job - Azure DevOps pipeline job
- Local Azure DevOps webhook - Local Azure DevOps webhook
[View Azure DevOps Integration Guide →](https://qodo-merge-docs.qodo.ai/installation/azure/) [View Azure DevOps Integration Guide →](https://qodo-merge-docs.qodo.ai/installation/azure/)

View File

@ -1,9 +1,21 @@
Qodo Merge is a versatile application compatible with GitHub, GitLab, and BitBucket, hosted by QodoAI. Qodo Merge is a versatile application compatible with GitHub, GitLab, and BitBucket, hosted by QodoAI.
See [here](https://qodo-merge-docs.qodo.ai/overview/pr_agent_pro/) for more details about the benefits of using Qodo Merge. See [here](https://qodo-merge-docs.qodo.ai/overview/pr_agent_pro/) for more details about the benefits of using Qodo Merge.
A complimentary two-week trial is provided to all new users (with three additional grace usages). Following the trial period, user licenses (seats) are required for continued access. ## Trial Period and Licensing
To purchase user licenses, please visit our [pricing page](https://www.qodo.ai/pricing/).
Once subscribed, users can seamlessly deploy the application across any of their code repositories. ### Cloud Users with Teams Account
A complimentary two-week trial is provided to all new users (with three additional grace usages). When the trial period ends, users will stop receiving feedback from Qodo Merge.
Following the trial period, user licenses (seats) are required for continued access. Each user requires an individual seat license.
After purchasing seats, the team owner can assign them to specific users through the management portal.
With an assigned seat, users can seamlessly deploy the application across any of their code repositories.
### Enterprise Account
For organizations who require an Enterprise account, please [contact](https://www.qodo.ai/contact/#pricing) us to initiate a trial period, and to discuss pricing and licensing options.
## Install Qodo Merge for GitHub ## Install Qodo Merge for GitHub
@ -23,7 +35,7 @@ For open-source projects, Qodo Merge is available for free usage. To install Qod
## Install Qodo Merge for Bitbucket ## Install Qodo Merge for Bitbucket
### Bitbucket Cloud ### Bitbucket Cloud
Qodo Merge for Bitbucket Cloud is available for installation through the following [link](https://bitbucket.org/site/addons/authorize?addon_key=d6df813252c37258) Qodo Merge for Bitbucket Cloud is available for installation through the following [link](https://bitbucket.org/site/addons/authorize?addon_key=d6df813252c37258)
@ -33,8 +45,7 @@ Qodo Merge for Bitbucket Cloud is available for installation through the followi
To use Qodo Merge application on your private Bitbucket Server, you will need to contact us for starting an [Enterprise](https://www.qodo.ai/pricing/) trial. To use Qodo Merge application on your private Bitbucket Server, you will need to contact us for starting an [Enterprise](https://www.qodo.ai/pricing/) trial.
## Install Qodo Merge for GitLab
## Install Qodo Merge for GitLab
### GitLab Cloud ### GitLab Cloud

View File

@ -10,7 +10,6 @@
- No passive collection of Code and Pull Requests data — Qodo Merge will be active only when you invoke it, and it will then extract and analyze only data relevant to the executed command and queried pull request. - No passive collection of Code and Pull Requests data — Qodo Merge will be active only when you invoke it, and it will then extract and analyze only data relevant to the executed command and queried pull request.
## Qodo Merge Chrome extension ## Qodo Merge Chrome extension
- The [Qodo Merge Chrome extension](https://chromewebstore.google.com/detail/pr-agent-chrome-extension/ephlnjeghhogofkifjloamocljapahnl) will not send your code to any external servers. - The [Qodo Merge Chrome extension](https://chromewebstore.google.com/detail/pr-agent-chrome-extension/ephlnjeghhogofkifjloamocljapahnl) will not send your code to any external servers.

View File

@ -15,34 +15,33 @@ Qodo Merge is designed for companies and teams that require additional features
### Additional features ### Additional features
Here are some of the additional features and capabilities that Qodo Merge offers: Here are some of the additional features and capabilities that Qodo Merge offers, and are not available in the open-source version of PR-Agent:
| Feature | Description | | Feature | Description |
|----------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------| | -------------------------------------------------------------------------------------------------------------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------|
| [**Model selection**](https://qodo-merge-docs.qodo.ai/usage-guide/PR_agent_pro_models/) | Choose the model that best fits your needs, among top models like `Claude Sonnet` and `o3-mini` | [**Model selection**](https://qodo-merge-docs.qodo.ai/usage-guide/PR_agent_pro_models/) | Choose the model that best fits your needs, among top models like `Claude Sonnet`, `o4-mini` |
| [**Global and wiki configuration**](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) | Control configurations for many repositories from a single location; <br>Edit configuration of a single repo without committing code | | [**Global and wiki configuration**](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) | Control configurations for many repositories from a single location; <br>Edit configuration of a single repo without committing code |
| [**Apply suggestions**](https://qodo-merge-docs.qodo.ai/tools/improve/#overview) | Generate committable code from the relevant suggestions interactively by clicking on a checkbox | | [**Apply suggestions**](https://qodo-merge-docs.qodo.ai/tools/improve/#overview) | Generate committable code from the relevant suggestions interactively by clicking on a checkbox |
| [**Suggestions impact**](https://qodo-merge-docs.qodo.ai/tools/improve/#assessing-impact) | Automatically mark suggestions that were implemented by the user (either directly in GitHub, or indirectly in the IDE) to enable tracking of the impact of the suggestions | | [**Suggestions impact**](https://qodo-merge-docs.qodo.ai/tools/improve/#assessing-impact) | Automatically mark suggestions that were implemented by the user (either directly in GitHub, or indirectly in the IDE) to enable tracking of the impact of the suggestions |
| [**CI feedback**](https://qodo-merge-docs.qodo.ai/tools/ci_feedback/) | Automatically analyze failed CI checks on GitHub and provide actionable feedback in the PR conversation, helping to resolve issues quickly | | [**CI feedback**](https://qodo-merge-docs.qodo.ai/tools/ci_feedback/) | Automatically analyze failed CI checks on GitHub and provide actionable feedback in the PR conversation, helping to resolve issues quickly |
| [**Advanced usage statistics**](https://www.codium.ai/contact/#/) | Qodo Merge offers detailed statistics at user, repository, and company levels, including metrics about Qodo Merge usage, and also general statistics and insights | | [**Advanced usage statistics**](https://www.codium.ai/contact/#/) | Qodo Merge offers detailed statistics at user, repository, and company levels, including metrics about Qodo Merge usage, and also general statistics and insights |
| [**Incorporating companies' best practices**](https://qodo-merge-docs.qodo.ai/tools/improve/#best-practices) | Use the companies' best practices as reference to increase the effectiveness and the relevance of the code suggestions | | [**Incorporating companies' best practices**](https://qodo-merge-docs.qodo.ai/tools/improve/#best-practices) | Use the companies' best practices as reference to increase the effectiveness and the relevance of the code suggestions |
| [**Interactive triggering**](https://qodo-merge-docs.qodo.ai/tools/analyze/#example-usage) | Interactively apply different tools via the `analyze` command | | [**Interactive triggering**](https://qodo-merge-docs.qodo.ai/tools/analyze/#example-usage) | Interactively apply different tools via the `analyze` command |
| [**Custom labels**](https://qodo-merge-docs.qodo.ai/tools/describe/#handle-custom-labels-from-the-repos-labels-page) | Define custom labels for Qodo Merge to assign to the PR | | [**Custom labels**](https://qodo-merge-docs.qodo.ai/tools/describe/#handle-custom-labels-from-the-repos-labels-page) | Define custom labels for Qodo Merge to assign to the PR |
### Additional tools ### Additional tools
Here are additional tools that are available only for Qodo Merge users: Here are additional tools that are available only for Qodo Merge users:
| Feature | Description | | Feature | Description |
|---------------------------------------------------------------------------------------|-------------| | ------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
| [**Custom Prompt Suggestions**](https://qodo-merge-docs.qodo.ai/tools/custom_prompt/) | Generate code suggestions based on custom prompts from the user | | [**Custom Prompt Suggestions**](https://qodo-merge-docs.qodo.ai/tools/custom_prompt/) | Generate code suggestions based on custom prompts from the user |
| [**Analyze PR components**](https://qodo-merge-docs.qodo.ai/tools/analyze/) | Identify the components that changed in the PR, and enable to interactively apply different tools to them | | [**Analyze PR components**](https://qodo-merge-docs.qodo.ai/tools/analyze/) | Identify the components that changed in the PR, and enable to interactively apply different tools to them |
| [**Tests**](https://qodo-merge-docs.qodo.ai/tools/test/) | Generate tests for code components that changed in the PR | | [**Tests**](https://qodo-merge-docs.qodo.ai/tools/test/) | Generate tests for code components that changed in the PR |
| [**PR documentation**](https://qodo-merge-docs.qodo.ai/tools/documentation/) | Generate docstring for code components that changed in the PR | | [**PR documentation**](https://qodo-merge-docs.qodo.ai/tools/documentation/) | Generate docstring for code components that changed in the PR |
| [**Improve Component**](https://qodo-merge-docs.qodo.ai/tools/improve_component/) | Generate code suggestions for code components that changed in the PR | | [**Improve Component**](https://qodo-merge-docs.qodo.ai/tools/improve_component/) | Generate code suggestions for code components that changed in the PR |
| [**Similar code search**](https://qodo-merge-docs.qodo.ai/tools/similar_code/) | Search for similar code in the repository, organization, or entire GitHub | | [**Similar code search**](https://qodo-merge-docs.qodo.ai/tools/similar_code/) | Search for similar code in the repository, organization, or entire GitHub |
| [**Code implementation**](https://qodo-merge-docs.qodo.ai/tools/implement/) | Generates implementation code from review suggestions | | [**Code implementation**](https://qodo-merge-docs.qodo.ai/tools/implement/) | Generates implementation code from review suggestions |
### Supported languages ### Supported languages

View File

@ -0,0 +1,201 @@
# Qodo Merge Pull Request Benchmark
## Methodology
Qodo Merge PR Benchmark evaluates and compares the performance of two Large Language Models (LLMs) in analyzing pull request code and providing meaningful code suggestions.
Our diverse dataset comprises of 400 pull requests from over 100 repositories, spanning various programming languages and frameworks to reflect real-world scenarios.
- For each pull request, two distinct LLMs process the same prompt using the Qodo Merge `improve` tool, each generating two sets of responses. The prompt for response generation can be found [here](https://github.com/qodo-ai/pr-agent/blob/main/pr_agent/settings/code_suggestions/pr_code_suggestions_prompts_not_decoupled.toml).
- Subsequently, a high-performing third model (an AI judge) evaluates the responses from the initial two models to determine the superior one. We utilize OpenAI's `o3` model as the judge, though other models have yielded consistent results. The prompt for this comparative judgment is available [here](https://github.com/Codium-ai/pr-agent-settings/tree/main/benchmark).
- We aggregate comparison outcomes across all the pull requests, calculating the win rate for each model. We also analyze the qualitative feedback (the "why" explanations from the judge) to identify each model's comparative strengths and weaknesses.
This approach provides not just a quantitative score but also a detailed analysis of each model's strengths and weaknesses.
- For each model we build a "Model Card", comparing it against others. To ensure full transparency and enable community scrutiny, we also share the raw code suggestions generated by each model, and the judge's specific feedback. See example for the full output [here](https://github.com/Codium-ai/pr-agent-settings/blob/main/benchmark/sonnet_37_vs_gemini-2.5-pro-preview-05-06.md)
Note that this benchmark focuses on quality: the ability of an LLM to process complex pull request with multiple files and nuanced task to produce high-quality code suggestions.
Other factors like speed, cost, and availability, while also relevant for model selection, are outside this benchmark's scope.
## TL;DR
Here's a summary of the win rates based on the benchmark:
[//]: # (| Model A | Model B | Model A Win Rate | Model B Win Rate |)
[//]: # (|:-------------------------------|:-------------------------------|:----------------:|:----------------:|)
[//]: # (| Gemini-2.5-pro-preview-05-06 | GPT-4.1 | 70.4% | 29.6% |)
[//]: # (| Gemini-2.5-pro-preview-05-06 | Sonnet 3.7 | 78.1% | 21.9% |)
[//]: # (| GPT-4.1 | Sonnet 3.7 | 61.0% | 39.0% |)
<table>
<thead>
<tr>
<th style="text-align:left;">Model A</th>
<th style="text-align:left;">Model B</th>
<th style="text-align:center;">Model A Win Rate</th> <th style="text-align:center;">Model B Win Rate</th> </tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;">Gemini-2.5-pro-preview-05-06</td>
<td style="text-align:left;">GPT-4.1</td>
<td style="text-align:center; color: #1E8449;"><b>70.4%</b></td> <td style="text-align:center; color: #D8000C;"><b>29.6%</b></td> </tr>
<tr>
<td style="text-align:left;">Gemini-2.5-pro-preview-05-06</td>
<td style="text-align:left;">Sonnet 3.7</td>
<td style="text-align:center; color: #1E8449;"><b>78.1%</b></td> <td style="text-align:center; color: #D8000C;"><b>21.9%</b></td> </tr>
<tr>
<td style="text-align:left;">Gemini-2.5-pro-preview-05-06</td>
<td style="text-align:left;">Gemini-2.5-flash-preview-04-17</td>
<td style="text-align:center; color: #1E8449;"><b>73.0%</b></td> <td style="text-align:center; color: #D8000C;"><b>27.0%</b></td> </tr>
<tr>
<td style="text-align:left;">Gemini-2.5-flash-preview-04-17</td>
<td style="text-align:left;">GPT-4.1</td>
<td style="text-align:center; color: #1E8449;"><b>54.6%</b></td> <td style="text-align:center; color: #D8000C;"><b>45.4%</b></td> </tr>
<tr>
<td style="text-align:left;">Gemini-2.5-flash-preview-04-17</td>
<td style="text-align:left;">Sonnet 3.7</td>
<td style="text-align:center; color: #1E8449;"><b>60.6%</b></td> <td style="text-align:center; color: #D8000C;"><b>39.4%</b></td> </tr>
<tr>
<td style="text-align:left;">GPT-4.1</td>
<td style="text-align:left;">Sonnet 3.7</td>
<td style="text-align:center; color: #1E8449;"><b>61.0%</b></td> <td style="text-align:center; color: #D8000C;"><b>39.0%</b></td> </tr>
</tbody>
</table>
## Gemini-2.5-pro-preview-05-06 - Model Card
### Comparison against GPT-4.1
![Comparison](https://codium.ai/images/qodo_merge_benchmark/gpt-4.1_vs_gemini-2.5-pro-preview-05-06_judge_o3.png){width=768}
#### Analysis Summary
Model 'Gemini-2.5-pro-preview-05-06' is generally more useful thanks to wider and more accurate bug detection and concrete patches, but it sacrifices compliance discipline and sometimes oversteps the task rules. Model 'GPT-4.1' is safer and highly rule-abiding, yet often too timid—missing many genuine issues and providing limited insight. An ideal reviewer would combine 'GPT-4.1 restraint with 'Gemini-2.5-pro-preview-05-06' thoroughness.
#### Detailed Analysis
Gemini-2.5-pro-preview-05-06 strengths:
- better_bug_coverage: Detects and explains more critical issues, winning in ~70 % of comparisons and achieving a higher average score.
- actionable_fixes: Supplies clear code snippets, correct language labels, and often multiple coherent suggestions per diff.
- deeper_reasoning: Shows stronger grasp of logic, edge cases, and cross-file implications, leading to broader, high-impact reviews.
Gemini-2.5-pro-preview-05-06 weaknesses:
- guideline_violations: More prone to over-eager advice—non-critical tweaks, touching unchanged code, suggesting new imports, or minor format errors.
- occasional_overreach: Some fixes are speculative or risky, potentially introducing new bugs.
- redundant_or_duplicate: At times repeats the same point or exceeds the required brevity.
### Comparison against Sonnet 3.7
![Comparison](https://codium.ai/images/qodo_merge_benchmark/sonnet_37_vs_gemini-2.5-pro-preview-05-06_judge_o3.png){width=768}
#### Analysis Summary
Model 'Gemini-2.5-pro-preview-05-06' is the stronger reviewer—more frequently identifies genuine, high-impact bugs and provides well-formed, actionable fixes. Model 'Sonnet 3.7' is safer against false positives and tends to be concise but often misses important defects or offers low-value or incorrect suggestions.
See raw results [here](https://github.com/Codium-ai/pr-agent-settings/blob/main/benchmark/sonnet_37_vs_gemini-2.5-pro-preview-05-06.md)
#### Detailed Analysis
Gemini-2.5-pro-preview-05-06 strengths:
- higher_accuracy_and_coverage: finds real critical bugs and supplies actionable patches in most examples (better in 78 % of cases).
- guideline_awareness: usually respects new-lines-only scope, ≤3 suggestions, proper YAML, and stays silent when no issues exist.
- detailed_reasoning_and_patches: explanations tie directly to the diff and fixes are concrete, often catching multiple related defects that 'Sonnet 3.7' overlooks.
Gemini-2.5-pro-preview-05-06 weaknesses:
- occasional_rule_violations: sometimes proposes new imports, package-version changes, or edits outside the added lines.
- overzealous_suggestions: may add speculative or stylistic fixes that exceed the “critical” scope, or mis-label severity.
- sporadic_technical_slips: a few patches contain minor coding errors, oversized snippets, or duplicate/contradicting advice.
## GPT-4.1 - Model Card
### Comparison against Sonnet 3.7
![Comparison](https://codium.ai/images/qodo_merge_benchmark/gpt-4.1_vs_sonnet_3.7_judge_o3.png){width=768}
#### Analysis Summary
Model 'GPT-4.1' is safer and more compliant, preferring silence over speculation, which yields fewer rule breaches and false positives but misses some real bugs.
Model 'Sonnet 3.7' is more adventurous and often uncovers important issues that 'GPT-4.1' ignores, yet its aggressive style leads to frequent guideline violations and a higher proportion of incorrect or non-critical advice.
See raw results [here](https://github.com/Codium-ai/pr-agent-settings/blob/main/benchmark/gpt-4.1_vs_sonnet_3.7_judge_o3.md)
#### Detailed Analysis
GPT-4.1 strengths:
- Strong guideline adherence: usually stays strictly on `+` lines, avoids non-critical or stylistic advice, and rarely suggests forbidden imports; often outputs an empty list when no real bug exists.
- Lower false-positive rate: suggestions are more accurate and seldom introduce new bugs; fixes compile more reliably.
- Good schema discipline: YAML is almost always well-formed and fields are populated correctly.
GPT-4.1 weaknesses:
- Misses bugs: often returns an empty list even when a clear critical issue is present, so coverage is narrower.
- Sparse feedback: when it does comment, it tends to give fewer suggestions and sometimes lacks depth or completeness.
- Occasional metadata/slip-ups (wrong language tags, overly broad code spans), though less harmful than Sonnet 3.7 errors.
### Comparison against Gemini-2.5-pro-preview-05-06
![Comparison](https://codium.ai/images/qodo_merge_benchmark/gpt-4.1_vs_gemini-2.5-pro-preview-05-06_judge_o3.png){width=768}
#### Analysis Summary
Model 'Gemini-2.5-pro-preview-05-06' is generally more useful thanks to wider and more accurate bug detection and concrete patches, but it sacrifices compliance discipline and sometimes oversteps the task rules. Model 'GPT-4.1' is safer and highly rule-abiding, yet often too timid—missing many genuine issues and providing limited insight. An ideal reviewer would combine 'GPT-4.1 restraint with 'Gemini-2.5-pro-preview-05-06' thoroughness.
#### Detailed Analysis
GPT-4.1 strengths:
- strict_compliance: Usually sticks to the “critical bugs only / new + lines only” rule, so outputs rarely violate task constraints.
- low_risk: Conservative behaviour avoids harmful or speculative fixes; safer when no obvious issue exists.
- concise_formatting: Tends to produce minimal, correctly-structured YAML without extra noise.
GPT-4.1 weaknesses:
- under_detection: Frequently returns an empty list even when real bugs are present, missing ~70 % of the time.
- shallow_analysis: When it does suggest fixes, coverage is narrow and technical depth is limited, sometimes with wrong language tags or minor format slips.
- occasional_inaccuracy: A few suggestions are unfounded or duplicate, and rare guideline breaches (e.g., import advice) still occur.
## Sonnet 3.7 - Model Card
### Comparison against GPT-4.1
![Comparison](https://codium.ai/images/qodo_merge_benchmark/gpt-4.1_vs_sonnet_3.7_judge_o3.png){width=768}
#### Analysis Summary
Model 'GPT-4.1' is safer and more compliant, preferring silence over speculation, which yields fewer rule breaches and false positives but misses some real bugs.
Model 'Sonnet 3.7' is more adventurous and often uncovers important issues that 'GPT-4.1' ignores, yet its aggressive style leads to frequent guideline violations and a higher proportion of incorrect or non-critical advice.
See raw results [here](https://github.com/Codium-ai/pr-agent-settings/blob/main/benchmark/gpt-4.1_vs_sonnet_3.7_judge_o3.md)
#### Detailed Analysis
'Sonnet 3.7' strengths:
- Better bug discovery breadth: more willing to dive into logic and spot critical problems that 'GPT-4.1' overlooks; often supplies multiple, detailed fixes.
- Richer explanations & patches: gives fuller context and, when correct, proposes more functional or user-friendly solutions.
- Generally correct language/context tagging and targeted code snippets.
'Sonnet 3.7' weaknesses:
- Guideline violations: frequently flags non-critical issues, edits untouched code, or recommends adding imports, breaching task rules.
- Higher error rate: suggestions are more speculative and sometimes introduce new defects or duplicate work already done.
- Occasional schema or formatting mistakes (missing list value, duplicated suggestions), reducing reliability.
### Comparison against Gemini-2.5-pro-preview-05-06
![Comparison](https://codium.ai/images/qodo_merge_benchmark/sonnet_37_vs_gemini-2.5-pro-preview-05-06_judge_o3.png){width=768}
#### Analysis Summary
Model 'Gemini-2.5-pro-preview-05-06' is the stronger reviewer—more frequently identifies genuine, high-impact bugs and provides well-formed, actionable fixes. Model 'Sonnet 3.7' is safer against false positives and tends to be concise but often misses important defects or offers low-value or incorrect suggestions.
See raw results [here](https://github.com/Codium-ai/pr-agent-settings/blob/main/benchmark/sonnet_37_vs_gemini-2.5-pro-preview-05-06.md)

View File

@ -0,0 +1,21 @@
# Recent Updates and Future Roadmap
`Page last updated: 2025-05-11`
This page summarizes recent enhancements to Qodo Merge (last three months).
It also outlines our development roadmap for the upcoming three months. Please note that the roadmap is subject to change, and features may be adjusted, added, or reprioritized.
=== "Recent Updates"
- **Chat on Suggestions**: Users can now chat with Qodo Merge code suggestions ([Learn more](https://qodo-merge-docs.qodo.ai/tools/improve/#chat-on-code-suggestions))
- **Scan Repo Discussions Tool**: A new tool that analyzes past code discussions to generate a `best_practices.md` file, distilling key insights and recommendations. ([Learn more](https://qodo-merge-docs.qodo.ai/tools/scan_repo_discussions/))
- **Enhanced Models**: Qodo Merge now defaults to a combination of top models (Claude Sonnet 3.7 and Gemini 2.5 Pro) and incorporates dedicated code validation logic for improved results. ([Details 1](https://qodo-merge-docs.qodo.ai/usage-guide/qodo_merge_models/), [Details 2](https://qodo-merge-docs.qodo.ai/core-abilities/code_validation/))
- **Chrome Extension Update**: Qodo Merge Chrome extension now supports single-tenant users. ([Learn more](https://qodo-merge-docs.qodo.ai/chrome-extension/options/#configuration-options/))
- **Help Docs Tool**: The help_docs tool can answer free-text questions based on any git documentation folder. ([Learn more](https://qodo-merge-docs.qodo.ai/tools/help_docs/))
=== "Future Roadmap"
- **Smart Update**: Upon PR updates, Qodo Merge will offer tailored code suggestions, addressing both the entire PR and the specific incremental changes since the last feedback.
- **CLI Endpoint**: A new Qodo Merge endpoint will accept lists of before/after code changes, execute Qodo Merge commands, and return the results.
- **Simplified Free Tier**: We plan to transition from a two-week free trial to a free tier offering a limited number of suggestions per month per organization.
- **Best Practices Hierarchy**: Introducing support for structured best practices, such as for folders in monorepos or a unified best practice file for a group of repositories.
- **Installation Metrics**: Upon installation, Qodo Merge will analyze past PRs for key metrics (e.g., time to merge, time to first reviewer feedback), enabling pre/post-installation comparison to calculate ROI.

View File

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

View File

@ -2,6 +2,7 @@
The `ask` tool answers questions about the PR, based on the PR code changes. Make sure to be specific and clear in your questions. The `ask` tool answers questions about the PR, based on the PR code changes. Make sure to be specific and clear in your questions.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/ask "..." /ask "..."
``` ```
@ -15,6 +16,7 @@ It can be invoked manually by commenting on any PR:
## Ask lines ## Ask lines
You can run `/ask` on specific lines of code in the PR from the PR's diff view. The tool will answer questions based on the code changes in the selected lines. You can run `/ask` on specific lines of code in the PR from the PR's diff view. The tool will answer questions based on the code changes in the selected lines.
- Click on the '+' sign next to the line number to select the line. - Click on the '+' sign next to the line number to select the line.
- To select multiple lines, click on the '+' sign of the first line and then hold and drag to select the rest of the lines. - To select multiple lines, click on the '+' sign of the first line and then hold and drag to select the rest of the lines.
- write `/ask "..."` in the comment box and press `Add single comment` button. - write `/ask "..."` in the comment box and press `Add single comment` button.
@ -28,11 +30,13 @@ Note that the tool does not have "memory" of previous questions, and answers eac
You can also ask questions about images that appear in the comment, where the entire PR code will be used as context. You can also ask questions about images that appear in the comment, where the entire PR code will be used as context.
<br> <br>
The basic syntax is: The basic syntax is:
``` ```
/ask "..." /ask "..."
[Image](https://real_link_to_image) [Image](https://real_link_to_image)
``` ```
where `https://real_link_to_image` is the direct link to the image. where `https://real_link_to_image` is the direct link to the image.
Note that GitHub has a built-in mechanism of pasting images in comments. However, pasted image does not provide a direct link. Note that GitHub has a built-in mechanism of pasting images in comments. However, pasted image does not provide a direct link.
@ -55,5 +59,4 @@ To get a direct link to an image, we recommend using the following scheme:
![Ask image5](https://codium.ai/images/pr_agent/ask_images5.png){width=512} ![Ask image5](https://codium.ai/images/pr_agent/ask_images5.png){width=512}
See a full video tutorial [here](https://codium.ai/images/pr_agent/ask_image_video.mov) See a full video tutorial [here](https://codium.ai/images/pr_agent/ask_image_video.mov)

View File

@ -18,20 +18,24 @@ The tool analyzes the failed checks and provides several feedbacks:
___ ___
In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR: In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR:
``` ```
/checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}" /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}"
``` ```
where `{repo_name}` is the name of the repository, `{run_number}` is the run number of the failed check, and `{job_number}` is the job number of the failed check. where `{repo_name}` is the name of the repository, `{run_number}` is the run number of the failed check, and `{job_number}` is the job number of the failed check.
## Disabling the tool from running automatically ## Disabling the tool from running automatically
If you wish to disable the tool from running automatically, you can do so by adding the following configuration to the configuration file: If you wish to disable the tool from running automatically, you can do so by adding the following configuration to the configuration file:
``` ```
[checks] [checks]
enable_auto_checks_feedback = false enable_auto_checks_feedback = false
``` ```
## Configuration options ## Configuration options
- `enable_auto_checks_feedback` - if set to true, the tool will automatically provide feedback when a check is failed. Default is true. - `enable_auto_checks_feedback` - if set to true, the tool will automatically provide feedback when a check is failed. Default is true.
- `excluded_checks_list` - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list. - `excluded_checks_list` - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list.
- `persistent_comment` - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true. - `persistent_comment` - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true.

View File

@ -1,7 +1,9 @@
## Overview ## Overview
The `generate_labels` tool scans the PR code changes, and given a list of labels and their descriptions, it automatically suggests labels that match the PR code changes. The `generate_labels` tool scans the PR code changes, and given a list of labels and their descriptions, it automatically suggests labels that match the PR code changes.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/generate_labels /generate_labels
``` ```
@ -19,21 +21,26 @@ When running the `generate_labels` tool on a PR that includes changes in SQL que
Note that in addition to the dedicated tool `generate_labels`, the custom labels will also be used by the `describe` tool. Note that in addition to the dedicated tool `generate_labels`, the custom labels will also be used by the `describe` tool.
### How to enable custom labels ### How to enable custom labels
There are 3 ways to enable custom labels: There are 3 ways to enable custom labels:
#### 1. CLI (local configuration file) #### 1. CLI (local configuration file)
When working from CLI, you need to apply the [configuration changes](#configuration-options) to the [custom_labels file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/custom_labels.toml): When working from CLI, you need to apply the [configuration changes](#configuration-options) to the [custom_labels file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/custom_labels.toml):
#### 2. Repo configuration file #### 2. Repo configuration file
To enable custom labels, you need to apply the [configuration changes](#configuration-options) to the local `.pr_agent.toml` file in your repository. To enable custom labels, you need to apply the [configuration changes](#configuration-options) to the local `.pr_agent.toml` file in your repository.
#### 3. Handle custom labels from the Repo's labels page 💎 #### 3. Handle custom labels from the Repo's labels page 💎
> This feature is available only in Qodo Merge > This feature is available only in Qodo Merge
* GitHub : `https://github.com/{owner}/{repo}/labels`, or click on the "Labels" tab in the issues or PRs page. * GitHub : `https://github.com/{owner}/{repo}/labels`, or click on the "Labels" tab in the issues or PRs page.
* GitLab : `https://gitlab.com/{owner}/{repo}/-/labels`, or click on "Manage" -> "Labels" on the left menu. * GitLab : `https://gitlab.com/{owner}/{repo}/-/labels`, or click on "Manage" -> "Labels" on the left menu.
b. Add/edit the custom labels. It should be formatted as follows: b. Add/edit the custom labels. It should be formatted as follows:
* Label name: The name of the custom label. * Label name: The name of the custom label.
* Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.<br> * Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.<br>
The description should be comprehensive and detailed, indicating when to add the desired label. The description should be comprehensive and detailed, indicating when to add the desired label.
@ -45,8 +52,9 @@ c. Now the custom labels will be included in the `generate_labels` tool.
> This feature is supported in GitHub and GitLab. > This feature is supported in GitHub and GitLab.
## Configuration options ## Configuration options
- Change `enable_custom_labels` to True: This will turn off the default labels and enable the custom labels provided in the custom_labels.toml file.
- Add the custom labels. It should be formatted as follows: * Change `enable_custom_labels` to True: This will turn off the default labels and enable the custom labels provided in the custom_labels.toml file.
* Add the custom labels. It should be formatted as follows:
``` ```
[config] [config]

View File

@ -1,4 +1,5 @@
## Overview ## Overview
The `custom_prompt` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The `custom_prompt` tool scans the PR code changes, and automatically generates suggestions for improving the PR code.
It shares similarities with the `improve` tool, but with one main difference: the `custom_prompt` tool will **only propose suggestions that follow specific guidelines defined by the prompt** in: `pr_custom_prompt.prompt` configuration. It shares similarities with the `improve` tool, but with one main difference: the `custom_prompt` tool will **only propose suggestions that follow specific guidelines defined by the prompt** in: `pr_custom_prompt.prompt` configuration.
@ -17,7 +18,7 @@ The code suggestions should focus only on the following:
With a [configuration file](../usage-guide/automations_and_usage.md#github-app), use the following template: With a [configuration file](../usage-guide/automations_and_usage.md#github-app), use the following template:
``` ```toml
[pr_custom_prompt] [pr_custom_prompt]
prompt="""\ prompt="""\
The suggestions should focus only on the following: The suggestions should focus only on the following:
@ -33,7 +34,8 @@ You might benefit from several trial-and-error iterations, until you get the cor
## Example usage ## Example usage
Here is an example of a possible prompt, defined in the configuration file: Here is an example of a possible prompt, defined in the configuration file:
```
```toml
[pr_custom_prompt] [pr_custom_prompt]
prompt="""\ prompt="""\
The code suggestions should focus only on the following: The code suggestions should focus only on the following:

View File

@ -1,7 +1,9 @@
## Overview ## Overview
The `describe` tool scans the PR code changes, and generates a description for the PR - title, type, summary, walkthrough and labels. The `describe` tool scans the PR code changes, and generates a description for the PR - title, type, summary, walkthrough and labels.
The tool can be triggered automatically every time a new PR is [opened](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened), or it can be invoked manually by commenting on any PR: The tool can be triggered automatically every time a new PR is [opened](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened), or it can be invoked manually by commenting on any PR:
``` ```
/describe /describe
``` ```
@ -19,6 +21,7 @@ After ~30 seconds, the tool will generate a description for the PR:
![Describe New](https://codium.ai/images/pr_agent/describe_new.png){width=512} ![Describe New](https://codium.ai/images/pr_agent/describe_new.png){width=512}
If you want to edit [configurations](#configuration-options), add the relevant ones to the command: If you want to edit [configurations](#configuration-options), add the relevant ones to the command:
``` ```
/describe --pr_description.some_config1=... --pr_description.some_config2=... /describe --pr_description.some_config1=... --pr_description.some_config2=...
``` ```
@ -26,6 +29,7 @@ If you want to edit [configurations](#configuration-options), add the relevant o
### Automatic triggering ### Automatic triggering
To run the `describe` automatically when a PR is opened, define in a [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/#wiki-configuration-file): To run the `describe` automatically when a PR is opened, define in a [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/#wiki-configuration-file):
``` ```
[github_app] [github_app]
pr_commands = [ pr_commands = [
@ -41,6 +45,16 @@ publish_labels = true
- The `pr_commands` lists commands that will be executed automatically when a PR is opened. - The `pr_commands` lists commands that will be executed automatically when a PR is opened.
- The `[pr_description]` section contains the configurations for the `describe` tool you want to edit (if any). - The `[pr_description]` section contains the configurations for the `describe` tool you want to edit (if any).
## Preserving the original user description
By default, Qodo Merge preserves your original PR description by placing it above the generated content.
This requires including your description during the initial PR creation.
Be aware that if you edit the description while the automated tool is running, a race condition may occur, potentially causing your original description to be lost.
When updating PR descriptions, the `/describe` tool considers everything above the "PR Type" field as user content and will preserve it.
Everything below this marker is treated as previously auto-generated content and will be replaced.
![Describe comment](https://codium.ai/images/pr_agent/pr_description_user_description.png){width=512}
## Configuration options ## Configuration options
@ -97,7 +111,6 @@ publish_labels = true
</tr> </tr>
</table> </table>
## Inline file summary 💎 ## Inline file summary 💎
This feature enables you to copy the `changes walkthrough` table to the "Files changed" tab, so you can quickly understand the changes in each file while reviewing the code changes (diff view). This feature enables you to copy the `changes walkthrough` table to the "Files changed" tab, so you can quickly understand the changes in each file while reviewing the code changes (diff view).
@ -120,13 +133,13 @@ If you prefer to have the file summaries appear in the "Files changed" tab on ev
**Note**: that this feature is currently available only for GitHub. **Note**: that this feature is currently available only for GitHub.
## Markers template ## Markers template
To enable markers, set `pr_description.use_description_markers=true`. To enable markers, set `pr_description.use_description_markers=true`.
Markers enable to easily integrate user's content and auto-generated content, with a template-like mechanism. Markers enable to easily integrate user's content and auto-generated content, with a template-like mechanism.
For example, if the PR original description was: For example, if the PR original description was:
``` ```
User content... User content...
@ -139,6 +152,7 @@ pr_agent:summary
## PR Walkthrough: ## PR Walkthrough:
pr_agent:walkthrough pr_agent:walkthrough
``` ```
The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` will be replaced with the PR summary, and `pr_agent:walkthrough` will be replaced with the PR walkthrough. The marker `pr_agent:type` will be replaced with the PR type, `pr_agent:summary` will be replaced with the PR summary, and `pr_agent:walkthrough` will be replaced with the PR walkthrough.
![Describe markers before](https://codium.ai/images/pr_agent/describe_markers_before.png){width=512} ![Describe markers before](https://codium.ai/images/pr_agent/describe_markers_before.png){width=512}
@ -147,13 +161,13 @@ becomes
![Describe markers after](https://codium.ai/images/pr_agent/describe_markers_after.png){width=512} ![Describe markers after](https://codium.ai/images/pr_agent/describe_markers_after.png){width=512}
**Configuration params**: **Configuration params**:
- `use_description_markers`: if set to true, the tool will use markers template. It replaces every marker of the form `pr_agent:marker_name` with the relevant content. Default is false. - `use_description_markers`: if set to true, the tool will use markers template. It replaces every marker of the form `pr_agent:marker_name` with the relevant content. Default is false.
- `include_generated_by_header`: if set to true, the tool will add a dedicated header: 'Generated by PR Agent at ...' to any automatic content. Default is true. - `include_generated_by_header`: if set to true, the tool will add a dedicated header: 'Generated by PR Agent at ...' to any automatic content. Default is true.
## Custom labels ## Custom labels
The default labels of the describe tool are quite generic, since they are meant to be used in any repo: [`Bug fix`, `Tests`, `Enhancement`, `Documentation`, `Other`]. The default labels of the describe tool are quite generic, since they are meant to be used in any repo: [`Bug fix`, `Tests`, `Enhancement`, `Documentation`, `Other`].
You can define custom labels that are relevant for your repo and use cases. You can define custom labels that are relevant for your repo and use cases.
@ -163,7 +177,9 @@ Make sure to provide proper title, and a detailed and well-phrased description f
Each label description should be a **conditional statement**, that indicates if to add the label to the PR or not, according to the PR content. Each label description should be a **conditional statement**, that indicates if to add the label to the PR or not, according to the PR content.
### Handle custom labels from a configuration file ### Handle custom labels from a configuration file
Example for a custom labels configuration setup in a configuration file: Example for a custom labels configuration setup in a configuration file:
``` ```
[config] [config]
enable_custom_labels=true enable_custom_labels=true
@ -182,26 +198,25 @@ description = "use when a PR primarily contains new tests"
You can also control the custom labels that will be suggested by the `describe` tool from the repo's labels page: You can also control the custom labels that will be suggested by the `describe` tool from the repo's labels page:
* GitHub : go to `https://github.com/{owner}/{repo}/labels` (or click on the "Labels" tab in the issues or PRs page) - GitHub : go to `https://github.com/{owner}/{repo}/labels` (or click on the "Labels" tab in the issues or PRs page)
* GitLab : go to `https://gitlab.com/{owner}/{repo}/-/labels` (or click on "Manage" -> "Labels" on the left menu) - GitLab : go to `https://gitlab.com/{owner}/{repo}/-/labels` (or click on "Manage" -> "Labels" on the left menu)
Now add/edit the custom labels. they should be formatted as follows: Now add/edit the custom labels. they should be formatted as follows:
* Label name: The name of the custom label. - Label name: The name of the custom label.
* Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.<br> - Description: Start the description of with prefix `pr_agent:`, for example: `pr_agent: Description of when AI should suggest this label`.<br>
Examples for custom labels: Examples for custom labels:
- `Main topic:performance` - pr_agent:The main topic of this PR is performance - `Main topic:performance` - pr_agent:The main topic of this PR is performance
- `New endpoint` - pr_agent:A new endpoint was added in this PR - `New endpoint` - pr_agent:A new endpoint was added in this PR
- `SQL query` - pr_agent:A new SQL query was added in this PR - `SQL query` - pr_agent:A new SQL query was added in this PR
- `Dockerfile changes` - pr_agent:The PR contains changes in the Dockerfile - `Dockerfile changes` - pr_agent:The PR contains changes in the Dockerfile
- ... - ...
The description should be comprehensive and detailed, indicating when to add the desired label. For example: The description should be comprehensive and detailed, indicating when to add the desired label. For example:
![Add native custom labels](https://codium.ai/images/pr_agent/add_native_custom_labels.png){width=768} ![Add native custom labels](https://codium.ai/images/pr_agent/add_native_custom_labels.png){width=768}
## Usage Tips ## Usage Tips
!!! tip "Automation" !!! tip "Automation"
@ -211,14 +226,15 @@ The description should be comprehensive and detailed, indicating when to add the
``` ```
meaning the `describe` tool will run automatically on every PR, with the default configurations. meaning the `describe` tool will run automatically on every PR, with the default configurations.
- Markers are an alternative way to control the generated description, to give maximal control to the user. If you set:
- Markers are an alternative way to control the generated description, to give maximal control to the user. If you set:
``` ```
pr_commands = ["/describe --pr_description.use_description_markers=true", ...] pr_commands = ["/describe --pr_description.use_description_markers=true", ...]
``` ```
the tool will replace every marker of the form `pr_agent:marker_name` in the PR description with the relevant content, where `marker_name` is one of the following: the tool will replace every marker of the form `pr_agent:marker_name` in the PR description with the relevant content, where `marker_name` is one of the following:
* `type`: the PR type. *`type`: the PR type.
* `summary`: the PR summary. * `summary`: the PR summary.
* `walkthrough`: the PR walkthrough. * `walkthrough`: the PR walkthrough.
- Note that when markers are enabled, if the original PR description does not contain any markers, the tool will not alter the description at all. - Note that when markers are enabled, if the original PR description does not contain any markers, the tool will not alter the description at all.

View File

@ -1,7 +1,9 @@
## Overview ## Overview
The `add_docs` tool scans the PR code changes, and automatically suggests documentation for any code components that changed in the PR (functions, classes, etc.). The `add_docs` tool scans the PR code changes, and automatically suggests documentation for any code components that changed in the PR (functions, classes, etc.).
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/add_docs /add_docs
``` ```
@ -19,13 +21,15 @@ The tool will generate documentation for all the components that changed in the
![Docs single component](https://codium.ai/images/pr_agent/docs_single_component.png){width=768} ![Docs single component](https://codium.ai/images/pr_agent/docs_single_component.png){width=768}
You can state a name of a specific component in the PR to get documentation only for that component: You can state a name of a specific component in the PR to get documentation only for that component:
``` ```
/add_docs component_name /add_docs component_name
``` ```
## Configuration options ## Configuration options
- `docs_style`: The exact style of the documentation (for python docstring). you can choose between: `google`, `numpy`, `sphinx`, `restructuredtext`, `plain`. Default is `sphinx`.
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...". - `docs_style`: The exact style of the documentation (for python docstring). you can choose between: `google`, `numpy`, `sphinx`, `restructuredtext`, `plain`. Default is `sphinx`.
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on the changes in the file X. Ignore change in ...".
!!! note "Notes" !!! note "Notes"
- The following languages are currently supported: Python, Java, C++, JavaScript, TypeScript, C#. - The following languages are currently supported: Python, Java, C++, JavaScript, TypeScript, C#.

View File

@ -1,13 +1,16 @@
## Overview ## Overview
The `help` tool provides a list of all the available tools and their descriptions. The `help` tool provides a list of all the available tools and their descriptions.
For Qodo Merge users, it also enables to trigger each tool by checking the relevant box. For Qodo Merge users, it also enables to trigger each tool by checking the relevant box.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/help /help
``` ```
## Example usage ## Example usage
An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment-1868524805): An example [result](https://github.com/Codium-ai/pr-agent/pull/546#issuecomment-1868524805):
![Help 1](https://codium.ai/images/pr_agent/help1.png){width=750} ![Help 1](https://codium.ai/images/pr_agent/help1.png){width=750}

View File

@ -3,9 +3,11 @@
The `help_docs` tool can answer a free-text question based on a git documentation folder. The `help_docs` tool can answer a free-text question based on a git documentation folder.
It can be invoked manually by commenting on any PR or Issue: It can be invoked manually by commenting on any PR or Issue:
``` ```
/help_docs "..." /help_docs "..."
``` ```
Or configured to be triggered automatically when a [new issue is opened](#run-as-a-github-action). Or configured to be triggered automatically when a [new issue is opened](#run-as-a-github-action).
The tool assumes by default that the documentation is located in the root of the repository, at `/docs` folder. The tool assumes by default that the documentation is located in the root of the repository, at `/docs` folder.
@ -92,8 +94,8 @@ jobs:
3) Following completion of the remaining steps (such as adding secrets and relevant configurations, such as `repo_url` and `docs_path`) merge this change to your main branch. 3) Following completion of the remaining steps (such as adding secrets and relevant configurations, such as `repo_url` and `docs_path`) merge this change to your main branch.
When a new issue is opened, you should see a comment from `github-actions` bot with an auto response, assuming the question is related to the documentation of the repository. When a new issue is opened, you should see a comment from `github-actions` bot with an auto response, assuming the question is related to the documentation of the repository.
---
---
## Configuration options ## Configuration options

View File

@ -7,28 +7,31 @@ It leverages LLM technology to transform PR comments and review suggestions into
## Usage Scenarios ## Usage Scenarios
### For Reviewers ### For Reviewers
Reviewers can request code changes by: Reviewers can request code changes by:
1. Selecting the code block to be modified. 1. Selecting the code block to be modified.
2. Adding a comment with the syntax: 2. Adding a comment with the syntax:
``` ```
/implement <code-change-description> /implement <code-change-description>
``` ```
![implement1](https://codium.ai/images/pr_agent/implement1.png){width=640} ![implement1](https://codium.ai/images/pr_agent/implement1.png){width=640}
### For PR Authors ### For PR Authors
PR authors can implement suggested changes by replying to a review comment using either: <br> PR authors can implement suggested changes by replying to a review comment using either: <br>
1. Add specific implementation details as described above 1. Add specific implementation details as described above
``` ```
/implement <code-change-description> /implement <code-change-description>
``` ```
2. Use the original review comment as instructions 2. Use the original review comment as instructions
``` ```
/implement /implement
``` ```
@ -38,6 +41,7 @@ PR authors can implement suggested changes by replying to a review comment using
### For Referencing Comments ### For Referencing Comments
You can reference and implement changes from any comment by: You can reference and implement changes from any comment by:
``` ```
/implement <link-to-review-comment> /implement <link-to-review-comment>
``` ```
@ -46,7 +50,6 @@ You can reference and implement changes from any comment by:
Note that the implementation will occur within the review discussion thread. Note that the implementation will occur within the review discussion thread.
**Configuration options** **Configuration options**
- Use `/implement` to implement code change within and based on the review discussion. - Use `/implement` to implement code change within and based on the review discussion.

View File

@ -1,17 +1,26 @@
## Overview ## Overview
The `improve` tool scans the PR code changes, and automatically generates [meaningful](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/pr_code_suggestions_prompts.toml#L41) suggestions for improving the PR code.
The `improve` tool scans the PR code changes, and automatically generates meaningful suggestions for improving the PR code.
The tool can be triggered automatically every time a new PR is [opened](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened), or it can be invoked manually by commenting on any PR: The tool can be triggered automatically every time a new PR is [opened](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened), or it can be invoked manually by commenting on any PR:
```toml ```toml
/improve /improve
``` ```
![code_suggestions_as_comment_closed.png](https://codium.ai/images/pr_agent/code_suggestions_as_comment_closed.png){width=512} ## How it looks
![code_suggestions_as_comment_open.png](https://codium.ai/images/pr_agent/code_suggestions_as_comment_open.png){width=512} === "Suggestions Overview"
![code_suggestions_as_comment_closed](https://codium.ai/images/pr_agent/code_suggestions_as_comment_closed.png){width=512}
=== "Selecting a specific suggestion"
![code_suggestions_as_comment_open](https://codium.ai/images/pr_agent/code_suggestions_as_comment_open.png){width=512}
___
!!! note "The following features are available only for Qodo Merge 💎 users:" !!! note "The following features are available only for Qodo Merge 💎 users:"
- The `Apply this suggestion` checkbox, which interactively converts a suggestion into a committable code comment - The `Apply / Chat` checkbox, which interactively converts a suggestion into a committable code comment
- The `More` checkbox to generate additional suggestions - The `More` checkbox to generate additional suggestions
- On Bitbucket (Cloud & Data Center) and GitLab Server (v16 and earlier), you can invoke [More Suggestions manually](#manual-more-suggestions)
## Example usage ## Example usage
@ -19,25 +28,34 @@ The tool can be triggered automatically every time a new PR is [opened](../usage
Invoke the tool manually by commenting `/improve` on any PR. The code suggestions by default are presented as a single comment: Invoke the tool manually by commenting `/improve` on any PR. The code suggestions by default are presented as a single comment:
To edit [configurations](#configuration-options) related to the improve tool, use the following template: To edit [configurations](#configuration-options) related to the `improve` tool, use the following template:
```toml ```toml
/improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=... /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=...
``` ```
For example, you can choose to present all the suggestions as commitable code comments, by running the following command: For example, you can choose to present all the suggestions as committable code comments, by running the following command:
```toml ```toml
/improve --pr_code_suggestions.commitable_code_suggestions=true /improve --pr_code_suggestions.commitable_code_suggestions=true
``` ```
![improve](https://codium.ai/images/pr_agent/improve.png){width=512} ![improve](https://codium.ai/images/pr_agent/improve.png){width=512}
As can be seen, a single table comment has a significantly smaller PR footprint. We recommend this mode for most cases. As can be seen, a single table comment has a significantly smaller PR footprint. We recommend this mode for most cases.
Also note that collapsible are not supported in _Bitbucket_. Hence, the suggestions can only be presented in Bitbucket as code comments. Also note that collapsible are not supported in _Bitbucket_. Hence, the suggestions can only be presented in Bitbucket as code comments.
#### Manual more suggestions
To generate more suggestions (distinct from the ones already generated), for git-providers that don't support interactive checkbox option, you can manually run:
```
/improve --more_suggestions=true
```
### Automatic triggering ### Automatic triggering
To run the `improve` automatically when a PR is opened, define in a [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/#wiki-configuration-file): To run the `improve` automatically when a PR is opened, define in a [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/#wiki-configuration-file):
```toml ```toml
[github_app] [github_app]
pr_commands = [ pr_commands = [
@ -54,6 +72,7 @@ num_code_suggestions_per_chunk = ...
- The `[pr_code_suggestions]` section contains the configurations for the `improve` tool you want to edit (if any) - The `[pr_code_suggestions]` section contains the configurations for the `improve` tool you want to edit (if any)
### Assessing Impact ### Assessing Impact
>`💎 feature` >`💎 feature`
Qodo Merge tracks two types of implementations for tracking implemented suggestions: Qodo Merge tracks two types of implementations for tracking implemented suggestions:
@ -61,15 +80,16 @@ Qodo Merge tracks two types of implementations for tracking implemented suggesti
- Direct implementation - when the user directly applies the suggestion by clicking the `Apply` checkbox. - Direct implementation - when the user directly applies the suggestion by clicking the `Apply` checkbox.
- Indirect implementation - when the user implements the suggestion in their IDE environment. In this case, Qodo Merge will utilize, after each commit, a dedicated logic to identify if a suggestion was implemented, and will mark it as implemented. - Indirect implementation - when the user implements the suggestion in their IDE environment. In this case, Qodo Merge will utilize, after each commit, a dedicated logic to identify if a suggestion was implemented, and will mark it as implemented.
![code_suggestions_asses_impact](https://codium.ai/images/pr_agent/code_suggestions_asses_impact.png){width=512} ![code_suggestions_assess_impact](https://codium.ai/images/pr_agent/code_suggestions_asses_impact.png){width=512}
In post-process, Qodo Merge counts the number of suggestions that were implemented, and provides general statistics and insights about the suggestions' impact on the PR process. In post-process, Qodo Merge counts the number of suggestions that were implemented, and provides general statistics and insights about the suggestions' impact on the PR process.
![code_suggestions_asses_impact_stats_1](https://codium.ai/images/pr_agent/code_suggestions_asses_impact_stats_1.png){width=512} ![code_suggestions_assess_impact_stats_1](https://codium.ai/images/pr_agent/code_suggestions_asses_impact_stats_1.png){width=512}
![code_suggestions_asses_impact_stats_2](https://codium.ai/images/pr_agent/code_suggestions_asses_impact_stats_2.png){width=512} ![code_suggestions_assess_impact_stats_2](https://codium.ai/images/pr_agent/code_suggestions_asses_impact_stats_2.png){width=512}
## Suggestion tracking ## Suggestion tracking
>`💎 feature. Platforms supported: GitHub, GitLab` >`💎 feature. Platforms supported: GitHub, GitLab`
Qodo Merge employs a novel detection system to automatically [identify](https://qodo-merge-docs.qodo.ai/core-abilities/impact_evaluation/) AI code suggestions that PR authors have accepted and implemented. Qodo Merge employs a novel detection system to automatically [identify](https://qodo-merge-docs.qodo.ai/core-abilities/impact_evaluation/) AI code suggestions that PR authors have accepted and implemented.
@ -107,15 +127,17 @@ You can use the `extra_instructions` configuration option to give the AI model a
Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter. Be specific, clear, and concise in the instructions. With extra instructions, you are the prompter.
Examples for possible instructions: Examples for possible instructions:
```toml ```toml
[pr_code_suggestions] [pr_code_suggestions]
extra_instructions="""\ extra_instructions="""\
(1) Answer in japanese (1) Answer in Japanese
(2) Don't suggest to add try-except block (2) Don't suggest to add try-except block
(3) Ignore changes in toml files (3) Ignore changes in toml files
... ...
""" """
``` ```
Use triple quotes to write multi-line instructions. Use bullet points or numbers to make the instructions more readable. Use triple quotes to write multi-line instructions. Use bullet points or numbers to make the instructions more readable.
### Best practices ### Best practices
@ -128,7 +150,8 @@ This page can contain a list of best practices, coding standards, and guidelines
The AI model will use this `best_practices.md` file as a reference, and in case the PR code violates any of the guidelines, it will create additional suggestions, with a dedicated label: `Organization The AI model will use this `best_practices.md` file as a reference, and in case the PR code violates any of the guidelines, it will create additional suggestions, with a dedicated label: `Organization
best practice`. best practice`.
Example for a python `best_practices.md` content: Example for a Python `best_practices.md` content:
```markdown ```markdown
## Project best practices ## Project best practices
- Make sure that I/O operations are encapsulated in a try-except block - Make sure that I/O operations are encapsulated in a try-except block
@ -145,10 +168,18 @@ Tips for writing an effective `best_practices.md` file:
- Include brief code examples when helpful - Include brief code examples when helpful
- Focus on project-specific guidelines, that will result in relevant suggestions you actually want to get - Focus on project-specific guidelines, that will result in relevant suggestions you actually want to get
- Keep the file relatively short, under 800 lines, since: - Keep the file relatively short, under 800 lines, since:
- AI models may not process effectively very long documents - AI models may not process effectively very long documents
- Long files tend to contain generic guidelines already known to AI - Long files tend to contain generic guidelines already known to AI
To control the number of best practices suggestions generated by the `improve` tool, give the following configuration:
```toml
[best_practices]
num_best_practice_suggestions = 2
```
#### Local and global best practices #### Local and global best practices
By default, Qodo Merge will look for a local `best_practices.md` in the root of the relevant local repo. By default, Qodo Merge will look for a local `best_practices.md` in the root of the relevant local repo.
If you want to enable also a global `best_practices.md` file, set first in the global configuration file: If you want to enable also a global `best_practices.md` file, set first in the global configuration file:
@ -161,7 +192,8 @@ enable_global_best_practices = true
Then, create a `best_practices.md` file in the root of [global](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/#global-configuration-file) configuration repository, `pr-agent-settings`. Then, create a `best_practices.md` file in the root of [global](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/#global-configuration-file) configuration repository, `pr-agent-settings`.
#### Best practices for multiple languages #### Best practices for multiple languages
For a git organization working with multiple programming languages, you can maintain a centralized global `best_practices.md` file containing language-specific guidelines.
For a git organization working with multiple programming languages, you can maintain a centralized global `best_practices.md` file containing language-specific guidelines.
When reviewing pull requests, Qodo Merge automatically identifies the programming language and applies the relevant best practices from this file. When reviewing pull requests, Qodo Merge automatically identifies the programming language and applies the relevant best practices from this file.
To do this, structure your `best_practices.md` file using the following format: To do this, structure your `best_practices.md` file using the following format:
@ -176,7 +208,8 @@ To do this, structure your `best_practices.md` file using the following format:
``` ```
#### Dedicated label for best practices suggestions #### Dedicated label for best practices suggestions
Best practice suggestions are labeled as `Organization best practice` by default.
Best practice suggestions are labeled as `Organization best practice` by default.
To customize this label, modify it in your configuration file: To customize this label, modify it in your configuration file:
```toml ```toml
@ -186,7 +219,6 @@ organization_name = "..."
And the label will be: `{organization_name} best practice`. And the label will be: `{organization_name} best practice`.
#### Example results #### Example results
![best_practice](https://codium.ai/images/pr_agent/org_best_practice.png){width=512} ![best_practice](https://codium.ai/images/pr_agent/org_best_practice.png){width=512}
@ -201,7 +233,7 @@ And the label will be: `{organization_name} best practice`.
2. **Automatically** generates [best practices page](https://github.com/qodo-ai/pr-agent/wiki/.pr_agent_auto_best_practices) based on what your team consistently values 2. **Automatically** generates [best practices page](https://github.com/qodo-ai/pr-agent/wiki/.pr_agent_auto_best_practices) based on what your team consistently values
3. Applies these learned patterns to future code reviews 3. Applies these learned patterns to future code reviews
This creates an automatic feedback loop where the system continuously learns from your team's choices to provide increasingly relevant suggestions. This creates an automatic feedback loop where the system continuously learns from your team's choices to provide increasingly relevant suggestions.
The system maintains two analysis phases: The system maintains two analysis phases:
- Open exploration for new issues - Open exploration for new issues
@ -227,8 +259,13 @@ extra_instructions = ""
max_patterns = 5 max_patterns = 5
``` ```
### Multiple best practices sources
The `improve` tool will combine best practices from all available sources - global configuration, local configuration, and auto-generated files - to provide you with comprehensive recommendations.
### Combining 'extra instructions' and 'best practices' ### Combining 'extra instructions' and 'best practices'
> `💎 feature` > `💎 feature`
The `extra instructions` configuration is more related to the `improve` tool prompt. It can be used, for example, to avoid specific suggestions ("Don't suggest to add try-except block", "Ignore changes in toml files", ...) or to emphasize specific aspects or formats ("Answer in Japanese", "Give only short suggestions", ...) The `extra instructions` configuration is more related to the `improve` tool prompt. It can be used, for example, to avoid specific suggestions ("Don't suggest to add try-except block", "Ignore changes in toml files", ...) or to emphasize specific aspects or formats ("Answer in Japanese", "Give only short suggestions", ...)
@ -237,10 +274,10 @@ In contrast, the `best_practices.md` file is a general guideline for the way cod
Using a combination of both can help the AI model to provide relevant and tailored suggestions. Using a combination of both can help the AI model to provide relevant and tailored suggestions.
## Usage Tips ## Usage Tips
### Implementing the proposed code suggestions ### Implementing the proposed code suggestions
Each generated suggestion consists of three key elements: Each generated suggestion consists of three key elements:
1. A single-line summary of the proposed change 1. A single-line summary of the proposed change
@ -248,14 +285,54 @@ Each generated suggestion consists of three key elements:
3. A diff snippet showing the recommended code modification (before and after) 3. A diff snippet showing the recommended code modification (before and after)
We advise users to apply critical analysis and judgment when implementing the proposed suggestions. We advise users to apply critical analysis and judgment when implementing the proposed suggestions.
In addition to mistakes (which may happen, but are rare), sometimes the presented code modification may serve more as an _illustrative example_ than a direct applicable solution. In addition to mistakes (which may happen, but are rare), sometimes the presented code modification may serve more as an _illustrative example_ than a directly applicable solution.
In such cases, we recommend prioritizing the suggestion's detailed description, using the diff snippet primarily as a supporting reference. In such cases, we recommend prioritizing the suggestion's detailed description, using the diff snippet primarily as a supporting reference.
### Chat on code suggestions
> `💎 feature` Platforms supported: GitHub, GitLab
Qodo Merge implements an orchestrator agent that enables interactive code discussions, listening and responding to comments without requiring explicit tool calls.
The orchestrator intelligently analyzes your responses to determine if you want to implement a suggestion, ask a question, or request help, then delegates to the appropriate specialized tool.
#### Setup and Activation
Enable interactive code discussions by adding the following to your configuration file (default is `True`):
```toml
[pr_code_suggestions]
enable_chat_in_code_suggestions = true
```
!!! info "Activating Dynamic Responses"
To obtain dynamic responses, the following steps are required:
1. Run the `/improve` command (mostly automatic)
2. Tick the `/improve` recommendation checkboxes (_Apply this suggestion_) to have Qodo Merge generate a new inline code suggestion discussion
3. The orchestrator agent will then automatically listen and reply to comments within the discussion without requiring additional commands
#### Explore the available interaction patterns:
!!! tip "Tip: Direct the agent with keywords"
Use "implement" or "apply" for code generation. Use "explain", "why", or "how" for information and help.
=== "Asking for Details"
![Chat on code suggestions ask](https://codium.ai/images/pr_agent/improve_chat_on_code_suggestions_ask.png){width=512}
=== "Implementing Suggestions"
![Chat on code suggestions implement](https://codium.ai/images/pr_agent/improve_chat_on_code_suggestions_implement.png){width=512}
=== "Providing Additional Help"
![Chat on code suggestions help](https://codium.ai/images/pr_agent/improve_chat_on_code_suggestions_help.png){width=512}
### Dual publishing mode ### Dual publishing mode
Our recommended approach for presenting code suggestions is through a [table](https://qodo-merge-docs.qodo.ai/tools/improve/#overview) (`--pr_code_suggestions.commitable_code_suggestions=false`). Our recommended approach for presenting code suggestions is through a [table](https://qodo-merge-docs.qodo.ai/tools/improve/#overview) (`--pr_code_suggestions.commitable_code_suggestions=false`).
This method significantly reduces the PR footprint and allows for quick and easy digestion of multiple suggestions. This method significantly reduces the PR footprint and allows for quick and easy digestion of multiple suggestions.
We also offer a complementary **dual publishing mode**. When enabled, suggestions exceeding a certain score threshold are not only displayed in the table, but also presented as commitable PR comments. We also offer a complementary **dual publishing mode**. When enabled, suggestions exceeding a certain score threshold are not only displayed in the table, but also presented as committable PR comments.
This mode helps highlight suggestions deemed more critical. This mode helps highlight suggestions deemed more critical.
To activate dual publishing mode, use the following setting: To activate dual publishing mode, use the following setting:
@ -265,12 +342,14 @@ To activate dual publishing mode, use the following setting:
dual_publishing_score_threshold = x dual_publishing_score_threshold = x
``` ```
Where x represents the minimum score threshold (>=) for suggestions to be presented as commitable PR comments in addition to the table. Default is -1 (disabled). Where x represents the minimum score threshold (>=) for suggestions to be presented as committable PR comments in addition to the table. Default is -1 (disabled).
### Self-review ### Self-review
> `💎 feature` Platforms supported: GitHub, GitLab > `💎 feature` Platforms supported: GitHub, GitLab
If you set in a configuration file: If you set in a configuration file:
```toml ```toml
[pr_code_suggestions] [pr_code_suggestions]
demand_code_suggestions_self_review = true demand_code_suggestions_self_review = true
@ -278,6 +357,7 @@ demand_code_suggestions_self_review = true
The `improve` tool will add a checkbox below the suggestions, prompting user to acknowledge that they have reviewed the suggestions. The `improve` tool will add a checkbox below the suggestions, prompting user to acknowledge that they have reviewed the suggestions.
You can set the content of the checkbox text via: You can set the content of the checkbox text via:
```toml ```toml
[pr_code_suggestions] [pr_code_suggestions]
code_suggestions_self_review_text = "... (your text here) ..." code_suggestions_self_review_text = "... (your text here) ..."
@ -285,7 +365,6 @@ code_suggestions_self_review_text = "... (your text here) ..."
![self_review_1](https://codium.ai/images/pr_agent/self_review_1.png){width=512} ![self_review_1](https://codium.ai/images/pr_agent/self_review_1.png){width=512}
!!! tip "Tip - Reducing visual footprint after self-review 💎" !!! tip "Tip - Reducing visual footprint after self-review 💎"
The configuration parameter `pr_code_suggestions.fold_suggestions_on_self_review` (default is True) The configuration parameter `pr_code_suggestions.fold_suggestions_on_self_review` (default is True)
@ -293,8 +372,6 @@ code_suggestions_self_review_text = "... (your text here) ..."
This reduces the visual footprint of the suggestions, and also indicates to the PR reviewer that the suggestions have been reviewed by the PR author, and don't require further attention. This reduces the visual footprint of the suggestions, and also indicates to the PR reviewer that the suggestions have been reviewed by the PR author, and don't require further attention.
!!! tip "Tip - Demanding self-review from the PR author 💎" !!! tip "Tip - Demanding self-review from the PR author 💎"
By setting: By setting:
@ -314,12 +391,14 @@ code_suggestions_self_review_text = "... (your text here) ..."
To prevent unauthorized approvals, this configuration defaults to false, and cannot be altered through online comments; enabling requires a direct update to the configuration file and a commit to the repository. This ensures that utilizing the feature demands a deliberate documented decision by the repository owner. To prevent unauthorized approvals, this configuration defaults to false, and cannot be altered through online comments; enabling requires a direct update to the configuration file and a commit to the repository. This ensures that utilizing the feature demands a deliberate documented decision by the repository owner.
### Auto-approval ### Auto-approval
> `💎 feature. Platforms supported: GitHub, GitLab, Bitbucket` > `💎 feature. Platforms supported: GitHub, GitLab, Bitbucket`
Under specific conditions, Qodo Merge can auto-approve a PR when a specific comment is invoked, or when the PR meets certain criteria. Under specific conditions, Qodo Merge can auto-approve a PR when a specific comment is invoked, or when the PR meets certain criteria.
**To ensure safety, the auto-approval feature is disabled by default.** **To ensure safety, the auto-approval feature is disabled by default.**
To enable auto-approval features, you need to actively set one or both of the following options in a pre-defined _configuration file_: To enable auto-approval features, you need to actively set one or both of the following options in a pre-defined _configuration file_:
```toml ```toml
[config] [config]
enable_comment_approval = true # For approval via comments enable_comment_approval = true # For approval via comments
@ -333,20 +412,24 @@ enable_auto_approval = true # For criteria-based auto-approval
1\. **Auto-approval by commenting** 1\. **Auto-approval by commenting**
To enable auto-approval by commenting, set in the configuration file: To enable auto-approval by commenting, set in the configuration file:
```toml ```toml
[config] [config]
enable_comment_approval = true enable_comment_approval = true
``` ```
After enabling, by commenting on a PR: After enabling, by commenting on a PR:
``` ```
/review auto_approve /review auto_approve
``` ```
Qodo Merge will automatically approve the PR, and add a comment with the approval. Qodo Merge will automatically approve the PR, and add a comment with the approval.
2\. **Auto-approval when the PR meets certain criteria** 2\. **Auto-approval when the PR meets certain criteria**
To enable auto-approval based on specific criteria, first, you need to enable the top-level flag: To enable auto-approval based on specific criteria, first, you need to enable the top-level flag:
```toml ```toml
[config] [config]
enable_auto_approval = true enable_auto_approval = true
@ -355,39 +438,46 @@ enable_auto_approval = true
There are two criteria that can be set for auto-approval: There are two criteria that can be set for auto-approval:
- **Review effort score** - **Review effort score**
```toml ```toml
[config] [config]
enable_auto_approval = true enable_auto_approval = true
auto_approve_for_low_review_effort = X # X is a number between 1 to 5 auto_approve_for_low_review_effort = X # X is a number between 1 to 5
``` ```
When the [review effort score](https://www.qodo.ai/images/pr_agent/review3.png) is lower or equal to X, the PR will be auto-approved. When the [review effort score](https://www.qodo.ai/images/pr_agent/review3.png) is lower or equal to X, the PR will be auto-approved.
___ ___
- **No code suggestions** - **No code suggestions**
```toml ```toml
[config] [config]
enable_auto_approval = true enable_auto_approval = true
auto_approve_for_no_suggestions = true auto_approve_for_no_suggestions = true
``` ```
When no [code suggestion](https://www.qodo.ai/images/pr_agent/code_suggestions_as_comment_closed.png) were found for the PR, the PR will be auto-approved. When no [code suggestion](https://www.qodo.ai/images/pr_agent/code_suggestions_as_comment_closed.png) were found for the PR, the PR will be auto-approved.
### How many code suggestions are generated? ### How many code suggestions are generated?
Qodo Merge uses a dynamic strategy to generate code suggestions based on the size of the pull request (PR). Here's how it works: Qodo Merge uses a dynamic strategy to generate code suggestions based on the size of the pull request (PR). Here's how it works:
#### 1. Chunking large PRs #### 1. Chunking large PRs
- Qodo Merge divides large PRs into 'chunks'. - Qodo Merge divides large PRs into 'chunks'.
- Each chunk contains up to `pr_code_suggestions.max_context_tokens` tokens (default: 14,000). - Each chunk contains up to `pr_code_suggestions.max_context_tokens` tokens (default: 24,000).
#### 2. Generating suggestions #### 2. Generating suggestions
- For each chunk, Qodo Merge generates up to `pr_code_suggestions.num_code_suggestions_per_chunk` suggestions (default: 3).
- For each chunk, Qodo Merge generates up to `pr_code_suggestions.num_code_suggestions_per_chunk` suggestions (default: 4).
This approach has two main benefits: This approach has two main benefits:
- Scalability: The number of suggestions scales with the PR size, rather than being fixed. - Scalability: The number of suggestions scales with the PR size, rather than being fixed.
- Quality: By processing smaller chunks, the AI can maintain higher quality suggestions, as larger contexts tend to decrease AI performance. - Quality: By processing smaller chunks, the AI can maintain higher quality suggestions, as larger contexts tend to decrease AI performance.
Note: Chunking is primarily relevant for large PRs. For most PRs (up to 500 lines of code), Qodo Merge will be able to process the entire code in a single call. Note: Chunking is primarily relevant for large PRs. For most PRs (up to 600 lines of code), Qodo Merge will be able to process the entire code in a single call.
## Configuration options ## Configuration options
@ -400,11 +490,15 @@ Note: Chunking is primarily relevant for large PRs. For most PRs (up to 500 line
</tr> </tr>
<tr> <tr>
<td><b>commitable_code_suggestions</b></td> <td><b>commitable_code_suggestions</b></td>
<td>If set to true, the tool will display the suggestions as commitable code comments. Default is false.</td> <td>If set to true, the tool will display the suggestions as committable code comments. Default is false.</td>
</tr>
<tr>
<td><b>enable_chat_in_code_suggestions</b></td>
<td>If set to true, QM bot will interact with comments made on code changes it has proposed. Default is true.</td>
</tr> </tr>
<tr> <tr>
<td><b>dual_publishing_score_threshold</b></td> <td><b>dual_publishing_score_threshold</b></td>
<td>Minimum score threshold for suggestions to be presented as commitable PR comments in addition to the table. Default is -1 (disabled).</td> <td>Minimum score threshold for suggestions to be presented as committable PR comments in addition to the table. Default is -1 (disabled).</td>
</tr> </tr>
<tr> <tr>
<td><b>focus_only_on_problems</b></td> <td><b>focus_only_on_problems</b></td>
@ -471,5 +565,6 @@ Note: Chunking is primarily relevant for large PRs. For most PRs (up to 500 line
- **Self-reflection:** The suggestions aim to enable developers to _self-reflect_ and improve their pull requests. This process can help to identify blind spots, uncover missed edge cases, and enhance code readability and coherency. Even when a specific code suggestion isn't suitable, the underlying issue it highlights often reveals something important that might deserve attention. - **Self-reflection:** The suggestions aim to enable developers to _self-reflect_ and improve their pull requests. This process can help to identify blind spots, uncover missed edge cases, and enhance code readability and coherency. Even when a specific code suggestion isn't suitable, the underlying issue it highlights often reveals something important that might deserve attention.
- **Bug detection:** The suggestions also alert on any _critical bugs_ that may have been identified during the analysis. This provides an additional safety net to catch potential issues before they make it into production. It's perfectly acceptable to implement only the suggestions you find valuable for your specific context. - **Bug detection:** The suggestions also alert on any _critical bugs_ that may have been identified during the analysis. This provides an additional safety net to catch potential issues before they make it into production. It's perfectly acceptable to implement only the suggestions you find valuable for your specific context.
- **Hierarchy:** Presenting the suggestions in a structured hierarchical table enables the user to _quickly_ understand them, and to decide which ones are relevant and which are not. - **Hierarchy:** Presenting the suggestions in a structured hierarchical table enables the user to _quickly_ understand them, and to decide which ones are relevant and which are not.
- **Customization:** To guide the model to suggestions that are more relevant to the specific needs of your project, we recommend to use the [`extra_instructions`](https://qodo-merge-docs.qodo.ai/tools/improve/#extra-instructions-and-best-practices) and [`best practices`](https://qodo-merge-docs.qodo.ai/tools/improve/#best-practices) fields. - **Customization:** To guide the model to suggestions that are more relevant to the specific needs of your project, we recommend using the [`extra_instructions`](https://qodo-merge-docs.qodo.ai/tools/improve/#extra-instructions-and-best-practices) and [`best practices`](https://qodo-merge-docs.qodo.ai/tools/improve/#best-practices) fields.
- **Model Selection:** SaaS users can also [choose](https://qodo-merge-docs.qodo.ai/usage-guide/qodo_merge_models/) between different models. For specific programming languages or use cases, some models may perform better than others.
- **Interactive usage:** The interactive [PR chat](https://qodo-merge-docs.qodo.ai/chrome-extension/) also provides an easy way to get more tailored suggestions and feedback from the AI model. - **Interactive usage:** The interactive [PR chat](https://qodo-merge-docs.qodo.ai/chrome-extension/) also provides an easy way to get more tailored suggestions and feedback from the AI model.

View File

@ -1,13 +1,14 @@
## Overview ## Overview
The `improve_component` tool generates code suggestions for a specific code component that changed in the PR. The `improve_component` tool generates code suggestions for a specific code component that changed in the PR.
it can be invoked manually by commenting on any PR: it can be invoked manually by commenting on any PR:
``` ```
/improve_component component_name /improve_component component_name
``` ```
To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool. To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool.
## Example usage ## Example usage
Invoke the tool manually by commenting `/improve_component` on any PR: Invoke the tool manually by commenting `/improve_component` on any PR:
@ -23,6 +24,7 @@ The tool will generate code suggestions for the selected component (if no compon
- This tool can also be triggered interactively by using the [`analyze`](./analyze.md) tool. - This tool can also be triggered interactively by using the [`analyze`](./analyze.md) tool.
## Configuration options ## Configuration options
- `num_code_suggestions`: number of code suggestions to provide. Default is 4 - `num_code_suggestions`: number of code suggestions to provide. Default is 4
- `extra_instructions`: Optional extra instructions to the tool. For example: "focus on ...". - `extra_instructions`: Optional extra instructions to the tool. For example: "focus on ...".
- `file`: in case there are several components with the same name, you can specify the relevant file. - `file`: in case there are several components with the same name, you can specify the relevant file.

View File

@ -2,21 +2,23 @@
Here is a list of Qodo Merge tools, each with a dedicated page that explains how to use it: Here is a list of Qodo Merge tools, each with a dedicated page that explains how to use it:
| Tool | Description | | Tool | Description |
|------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------| | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **[PR Description (`/describe`](./describe.md))** | Automatically generating PR description - title, type, summary, code walkthrough and labels | | **[PR Description (`/describe`](./describe.md))** | Automatically generating PR description - title, type, summary, code walkthrough and labels |
| **[PR Review (`/review`](./review.md))** | Adjustable feedback about the PR, possible issues, security concerns, review effort and more | | **[PR Review (`/review`](./review.md))** | Adjustable feedback about the PR, possible issues, security concerns, review effort and more |
| **[Code Suggestions (`/improve`](./improve.md))** | Code suggestions for improving the PR | | **[Code Suggestions (`/improve`](./improve.md))** | Code suggestions for improving the PR |
| **[Question Answering (`/ask ...`](./ask.md))** | Answering free-text questions about the PR, or on specific code lines | | **[Question Answering (`/ask ...`](./ask.md))** | Answering free-text questions about the PR, or on specific code lines |
| **[Update Changelog (`/update_changelog`](./update_changelog.md))** | Automatically updating the CHANGELOG.md file with the PR changes | | **[Update Changelog (`/update_changelog`](./update_changelog.md))** | Automatically updating the CHANGELOG.md file with the PR changes |
| **[Help (`/help`](./help.md))** | Provides a list of all the available tools. Also enables to trigger them interactively (💎) | | **[Help (`/help`](./help.md))** | Provides a list of all the available tools. Also enables to trigger them interactively (💎) |
| **💎 [Add Documentation (`/add_docs`](./documentation.md))** | Generates documentation to methods/functions/classes that changed in the PR | | **💎 [Add Documentation (`/add_docs`](./documentation.md))** | Generates documentation to methods/functions/classes that changed in the PR |
| **💎 [Generate Custom Labels (`/generate_labels`](./custom_labels.md))** | Generates custom labels for the PR, based on specific guidelines defined by the user | | **💎 [Generate Custom Labels (`/generate_labels`](./custom_labels.md))** | Generates custom labels for the PR, based on specific guidelines defined by the user |
| **💎 [Analyze (`/analyze`](./analyze.md))** | Identify code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component| | **💎 [Analyze (`/analyze`](./analyze.md))** | Identify code components that changed in the PR, and enables to interactively generate tests, docs, and code suggestions for each component |
| **💎 [Test (`/test`](./test.md))** | generate tests for a selected component, based on the PR code changes | | **💎 [Test (`/test`](./test.md))** | generate tests for a selected component, based on the PR code changes |
| **💎 [Custom Prompt (`/custom_prompt`](./custom_prompt.md))** | Automatically generates custom suggestions for improving the PR code, based on specific guidelines defined by the user | | **💎 [Custom Prompt (`/custom_prompt`](./custom_prompt.md))** | Automatically generates custom suggestions for improving the PR code, based on specific guidelines defined by the user |
| **💎 [Generate Tests (`/test component_name`](./test.md))** | Automatically generates unit tests for a selected component, based on the PR code changes | | **💎 [Generate Tests (`/test component_name`](./test.md))** | Automatically generates unit tests for a selected component, based on the PR code changes |
| **💎 [Improve Component (`/improve_component component_name`](./improve_component.md))** | Generates code suggestions for a specific code component that changed in the PR | | **💎 [Improve Component (`/improve_component component_name`](./improve_component.md))** | Generates code suggestions for a specific code component that changed in the PR |
| **💎 [CI Feedback (`/checks ci_job`](./ci_feedback.md))** | Automatically generates feedback and analysis for a failed CI job | | **💎 [CI Feedback (`/checks ci_job`](./ci_feedback.md))** | Automatically generates feedback and analysis for a failed CI job |
| **💎 [Implement (`/implement`](./implement.md))** | Generates implementation code from review suggestions | | **💎 [Implement (`/implement`](./implement.md))** | Generates implementation code from review suggestions |
| **💎 [Scan Repo Discussions (`/scan_repo_discussions`](./scan_repo_discussions.md))** | Generates `best_practices.md` file based on previous discussions in the repository |
Note that the tools marked with 💎 are available only for Qodo Merge users. Note that the tools marked with 💎 are available only for Qodo Merge users.

View File

@ -1,7 +1,9 @@
## Overview ## Overview
The `review` tool scans the PR code changes, and generates a list of feedbacks about the PR, aiming to aid the reviewing process. The `review` tool scans the PR code changes, and generates a list of feedbacks about the PR, aiming to aid the reviewing process.
<br> <br>
The tool can be triggered automatically every time a new PR is [opened](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened), or can be invoked manually by commenting on any PR: The tool can be triggered automatically every time a new PR is [opened](../usage-guide/automations_and_usage.md#github-app-automatic-tools-when-a-new-pr-is-opened), or can be invoked manually by commenting on any PR:
``` ```
/review /review
``` ```
@ -10,7 +12,6 @@ Note that the main purpose of the `review` tool is to provide the **PR reviewer*
(Read more about the different personas in the PR process and how Qodo Merge aims to assist them in our [blog](https://www.codium.ai/blog/understanding-the-challenges-and-pain-points-of-the-pull-request-cycle/)) (Read more about the different personas in the PR process and how Qodo Merge aims to assist them in our [blog](https://www.codium.ai/blog/understanding-the-challenges-and-pain-points-of-the-pull-request-cycle/))
## Example usage ## Example usage
### Manual triggering ### Manual triggering
@ -24,6 +25,7 @@ After ~30 seconds, the tool will generate a review for the PR:
![review](https://codium.ai/images/pr_agent/review3.png){width=512} ![review](https://codium.ai/images/pr_agent/review3.png){width=512}
If you want to edit [configurations](#configuration-options), add the relevant ones to the command: If you want to edit [configurations](#configuration-options), add the relevant ones to the command:
``` ```
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=... /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
``` ```
@ -31,6 +33,7 @@ If you want to edit [configurations](#configuration-options), add the relevant o
### Automatic triggering ### Automatic triggering
To run the `review` automatically when a PR is opened, define in a [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/#wiki-configuration-file): To run the `review` automatically when a PR is opened, define in a [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/#wiki-configuration-file):
``` ```
[github_app] [github_app]
pr_commands = [ pr_commands = [
@ -46,7 +49,6 @@ extra_instructions = "..."
- The `pr_commands` lists commands that will be executed automatically when a PR is opened. - The `pr_commands` lists commands that will be executed automatically when a PR is opened.
- The `[pr_reviewer]` section contains the configurations for the `review` tool you want to edit (if any). - The `[pr_reviewer]` section contains the configurations for the `review` tool you want to edit (if any).
## Configuration options ## Configuration options
!!! example "General options" !!! example "General options"
@ -114,7 +116,6 @@ extra_instructions = "..."
</tr> </tr>
</table> </table>
## Usage Tips ## Usage Tips
!!! tip "General guidelines" !!! tip "General guidelines"
@ -164,11 +165,6 @@ extra_instructions = "..."
``` ```
Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable. Use triple quotes to write multi-line instructions. Use bullet points to make the instructions more readable.
!!! tip "Code suggestions" !!! tip "Code suggestions"
The `review` tool previously included a legacy feature for providing code suggestions (controlled by `--pr_reviewer.num_code_suggestion`). This functionality has been deprecated and replaced by the [`improve`](./improve.md) tool, which offers higher quality and more actionable code suggestions. The `review` tool previously included a legacy feature for providing code suggestions (controlled by `--pr_reviewer.num_code_suggestion`). This functionality has been deprecated and replaced by the [`improve`](./improve.md) tool, which offers higher quality and more actionable code suggestions.

View File

@ -0,0 +1,44 @@
`Platforms supported: GitHub`
## Overview
The `scan_repo_discussions` tool analyzes code discussions (meaning review comments over code lines) from merged pull requests over the past 12 months.
It processes these discussions alongside other PR metadata to identify recurring patterns related to best practices in team feedback and code reviews, generating a comprehensive [`best_practices.md`](https://github.com/qodo-ai/pr-agent/blob/qodo-merge-best-practices_2025-04-16_1018/best_practices.md) document that distills key insights and recommendations.
This file captures repository-specific patterns derived from your team's actual workflow and discussions, rather than more generic best practices.
It will be utilized by Qodo Merge to provide tailored suggestions for improving code quality in future pull requests.
!!! note "Active repositories are needed"
The tool is designed to work with real-life repositories, as it relies on actual discussions to generate meaningful insights.
At least 50 merged PRs are required to generate the `best_practices.md` file.
!!! note "Additional customization"
Teams are encouraged to further customize and refine these insights to better align with their specific development priorities and contexts.
This can be done by editing the `best_practices.md` file directly when the PR is created, or iteratively over time to enhance the 'best practices' suggestions provided by Qodo Merge.
The tool can be invoked manually by commenting on any PR:
```
/scan_repo_discussions
```
As a response, the bot will create a new PR that contains an auto-generated `best_practices.md` file.
Note that the scan can take several minutes to complete, since up to 250 PRs are scanned.
## Example usage
![scan1](https://codium.ai/images/pr_agent/scan_repo_discussions_1.png){width=640}
The PR created by the bot:
![scan1](https://codium.ai/images/pr_agent/scan_repo_discussions_2.png){width=640}
The `best_practices.md` file in the PR:
![scan1](https://codium.ai/images/pr_agent/scan_repo_discussions_3.png){width=640}
### Configuration options
- Use `/scan_repo_discussions --scan_repo_discussions.force_scan=true` to force generating a PR with a new `best_practices.md` file, even if it already exists (by default, the bot will not generate a new file if it already exists).
- Use `/scan_repo_discussions --scan_repo_discussions.days_back=X` to specify the number of days back to scan for discussions. The default is 365 days.
- Use `/scan_repo_discussions --scan_repo_discussions.minimal_number_of_prs=X` to specify the minimum number of merged PRs needed to generate the `best_practices.md` file. The default is 50 PRs.

View File

@ -1,4 +1,5 @@
## Overview ## Overview
The similar code tool retrieves the most similar code components from inside the organization's codebase, or from open-source code. The similar code tool retrieves the most similar code components from inside the organization's codebase, or from open-source code.
For example: For example:
@ -7,7 +8,6 @@ For example:
![similar code global](https://codium.ai/images/pr_agent/similar_code_global2.png){width=768} ![similar code global](https://codium.ai/images/pr_agent/similar_code_global2.png){width=768}
Qodo Merge will examine the code component and will extract the most relevant keywords to search for similar code: Qodo Merge will examine the code component and will extract the most relevant keywords to search for similar code:
- `extracted keywords`: the keywords that were extracted from the code by Qodo Merge. the link will open a search page with the extracted keywords, to allow the user to modify the search if needed. - `extracted keywords`: the keywords that were extracted from the code by Qodo Merge. the link will open a search page with the extracted keywords, to allow the user to modify the search if needed.
@ -19,18 +19,20 @@ Search result link example:
![code search result single](https://codium.ai/images/pr_agent/code_search_result_single.png){width=768} ![code search result single](https://codium.ai/images/pr_agent/code_search_result_single.png){width=768}
`Organization Search`: `Organization Search`:
![similar code org](https://codium.ai/images/pr_agent/similar_code_org.png){width=768} ![similar code org](https://codium.ai/images/pr_agent/similar_code_org.png){width=768}
## How to use ## How to use
### Manually ### Manually
To invoke the `similar code` tool manually, comment on the PR: To invoke the `similar code` tool manually, comment on the PR:
``` ```
/find_similar_component COMPONENT_NAME /find_similar_component COMPONENT_NAME
``` ```
Where `COMPONENT_NAME` should be the name of a code component in the PR (class, method, function). Where `COMPONENT_NAME` should be the name of a code component in the PR (class, method, function).
If there is a name ambiguity, there are two configurations that will help the tool to find the correct component: If there is a name ambiguity, there are two configurations that will help the tool to find the correct component:
@ -39,15 +41,19 @@ If there is a name ambiguity, there are two configurations that will help the to
- `--pr_find_similar_component.class_name`: in case there are several methods with the same name in the same file, you can specify the relevant class name. - `--pr_find_similar_component.class_name`: in case there are several methods with the same name in the same file, you can specify the relevant class name.
example: example:
``` ```
/find_similar_component COMPONENT_NAME --pr_find_similar_component.file=FILE_NAME /find_similar_component COMPONENT_NAME --pr_find_similar_component.file=FILE_NAME
``` ```
### Automatically (via Analyze table) ### Automatically (via Analyze table)
It can be invoked automatically from the analyze table, can be accessed by: It can be invoked automatically from the analyze table, can be accessed by:
``` ```
/analyze /analyze
``` ```
Choose the components you want to find similar code for, and click on the `similar` checkbox. Choose the components you want to find similar code for, and click on the `similar` checkbox.
![analyze similar](https://codium.ai/images/pr_agent/analyze_similar.png){width=768} ![analyze similar](https://codium.ai/images/pr_agent/analyze_similar.png){width=768}
@ -56,7 +62,6 @@ You can search for similar code either within the organization's codebase or glo
![similar code global](https://codium.ai/images/pr_agent/similar_code_global.png){width=768} ![similar code global](https://codium.ai/images/pr_agent/similar_code_global.png){width=768}
## Configuration options ## Configuration options
- `search_from_org`: if set to true, the tool will search for similar code in the organization's codebase. Default is false. - `search_from_org`: if set to true, the tool will search for similar code in the organization's codebase. Default is false.

View File

@ -1,11 +1,12 @@
## Overview ## Overview
The similar issue tool retrieves the most similar issues to the current issue. The similar issue tool retrieves the most similar issues to the current issue.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/similar_issue /similar_issue
``` ```
## Example usage ## Example usage
![similar_issue_original_issue](https://codium.ai/images/pr_agent/similar_issue_original_issue.png){width=768} ![similar_issue_original_issue](https://codium.ai/images/pr_agent/similar_issue_original_issue.png){width=768}
@ -17,15 +18,18 @@ It can be invoked manually by commenting on any PR:
Note that to perform retrieval, the `similar_issue` tool indexes all the repo previous issues (once). Note that to perform retrieval, the `similar_issue` tool indexes all the repo previous issues (once).
### Selecting a Vector Database ### Selecting a Vector Database
Configure your preferred database by changing the `pr_similar_issue` parameter in `configuration.toml` file. Configure your preferred database by changing the `pr_similar_issue` parameter in `configuration.toml` file.
#### Available Options #### Available Options
Choose from the following Vector Databases: Choose from the following Vector Databases:
1. LanceDB 1. LanceDB
2. Pinecone 2. Pinecone
#### Pinecone Configuration #### Pinecone Configuration
To use Pinecone with the `similar issue` tool, add these credentials to `.secrets.toml` (or set as environment variables): To use Pinecone with the `similar issue` tool, add these credentials to `.secrets.toml` (or set as environment variables):
``` ```
@ -33,10 +37,11 @@ To use Pinecone with the `similar issue` tool, add these credentials to `.secret
api_key = "..." api_key = "..."
environment = "..." environment = "..."
``` ```
These parameters can be obtained by registering to [Pinecone](https://app.pinecone.io/?sessionType=signup/). These parameters can be obtained by registering to [Pinecone](https://app.pinecone.io/?sessionType=signup/).
## How to use ## How to use
- To invoke the 'similar issue' tool from **CLI**, run: - To invoke the 'similar issue' tool from **CLI**, run:
`python3 cli.py --issue_url=... similar_issue` `python3 cli.py --issue_url=... similar_issue`

View File

@ -1,9 +1,12 @@
## Overview ## Overview
By combining LLM abilities with static code analysis, the `test` tool generate tests for a selected component, based on the PR code changes. By combining LLM abilities with static code analysis, the `test` tool generate tests for a selected component, based on the PR code changes.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/test component_name /test component_name
``` ```
where 'component_name' is the name of a specific component in the PR. where 'component_name' is the name of a specific component in the PR.
To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool. To get a list of the components that changed in the PR and choose the relevant component interactively, use the [`analyze`](./analyze.md) tool.
@ -14,15 +17,14 @@ The tool will generate tests for the selected component (if no component is stat
![test1](https://codium.ai/images/pr_agent/test1.png){width=768} ![test1](https://codium.ai/images/pr_agent/test1.png){width=768}
(Example taken from [here](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment-1913679429)): (Example taken from [here](https://github.com/Codium-ai/pr-agent/pull/598#issuecomment-1913679429)):
!!! note "Notes" !!! note "Notes"
- The following languages are currently supported: Python, Java, C++, JavaScript, TypeScript, C#. - The following languages are currently supported: Python, Java, C++, JavaScript, TypeScript, C#.
- This tool can also be triggered interactively by using the [`analyze`](./analyze.md) tool. - This tool can also be triggered interactively by using the [`analyze`](./analyze.md) tool.
## Configuration options ## Configuration options
- `num_tests`: number of tests to generate. Default is 3. - `num_tests`: number of tests to generate. Default is 3.
- `testing_framework`: the testing framework to use. If not set, for Python it will use `pytest`, for Java it will use `JUnit`, for C++ it will use `Catch2`, and for JavaScript and TypeScript it will use `jest`. - `testing_framework`: the testing framework to use. If not set, for Python it will use `pytest`, for Java it will use `JUnit`, for C++ it will use `Catch2`, and for JavaScript and TypeScript it will use `jest`.
- `avoid_mocks`: if set to true, the tool will try to avoid using mocks in the generated tests. Note that even if this option is set to true, the tool might still use mocks if it cannot generate a test without them. Default is true. - `avoid_mocks`: if set to true, the tool will try to avoid using mocks in the generated tests. Note that even if this option is set to true, the tool might still use mocks if it cannot generate a test without them. Default is true.

View File

@ -1,6 +1,8 @@
## Overview ## Overview
The `update_changelog` tool automatically updates the CHANGELOG.md file with the PR changes. The `update_changelog` tool automatically updates the CHANGELOG.md file with the PR changes.
It can be invoked manually by commenting on any PR: It can be invoked manually by commenting on any PR:
``` ```
/update_changelog /update_changelog
``` ```
@ -18,4 +20,4 @@ Under the section `pr_update_changelog`, the [configuration file](https://github
- `push_changelog_changes`: whether to push the changes to CHANGELOG.md, or just publish them as a comment. Default is false (publish as comment). - `push_changelog_changes`: whether to push the changes to CHANGELOG.md, or just publish them as a comment. Default is false (publish as comment).
- `extra_instructions`: Optional extra instructions to the tool. For example: "Use the following structure: ..." - `extra_instructions`: Optional extra instructions to the tool. For example: "Use the following structure: ..."
- `add_pr_link`: whether the model should try to add a link to the PR in the changelog. Default is true. - `add_pr_link`: whether the model should try to add a link to the PR in the changelog. Default is true.
- `skip_ci_on_push`: whether the commit message (when `push_changelog_changes` is true) will include the term "[skip ci]", preventing CI tests to be triggered on the changelog commit. Default is true. - `skip_ci_on_push`: whether the commit message (when `push_changelog_changes` is true) will include the term "[skip ci]", preventing CI tests to be triggered on the changelog commit. Default is true.

View File

@ -1,7 +1,8 @@
## Recommend Python Best Practices ## Recommend Python Best Practices
This document outlines a series of recommended best practices for Python development. These guidelines aim to improve code quality, maintainability, and readability. This document outlines a series of recommended best practices for Python development. These guidelines aim to improve code quality, maintainability, and readability.
### Imports ### Imports
Use `import` statements for packages and modules only, not for individual types, classes, or functions. Use `import` statements for packages and modules only, not for individual types, classes, or functions.
@ -9,16 +10,16 @@ Use `import` statements for packages and modules only, not for individual type
Reusability mechanism for sharing code from one module to another. Reusability mechanism for sharing code from one module to another.
#### Decision #### Decision
- Use `import x` for importing packages and modules. - Use `import x` for importing packages and modules.
- Use `from x import y` where `x` is the package prefix and `y` is the module name with no prefix. - Use `from x import y` where `x` is the package prefix and `y` is the module name with no prefix.
- Use `from x import y as z` in any of the following circumstances: - Use `from x import y as z` in any of the following circumstances:
- Two modules named `y` are to be imported. - Two modules named `y` are to be imported.
- `y` conflicts with a top-level name defined in the current module. - `y` conflicts with a top-level name defined in the current module.
- `y` conflicts with a common parameter name that is part of the public API (e.g., `features`). - `y` conflicts with a common parameter name that is part of the public API (e.g., `features`).
- `y` is an inconveniently long name, or too generic in the context of your code - `y` is an inconveniently long name, or too generic in the context of your code
- Use `import y as z` only when `z` is a standard abbreviation (e.g., `import numpy as np`). - Use `import y as z` only when `z` is a standard abbreviation (e.g., `import numpy as np`).
For example the module `sound.effects.echo` may be imported as follows: For example the module `sound.effects.echo` may be imported as follows:
@ -35,13 +36,13 @@ Do not use relative names in imports. Even if the module is in the same package,
Exemptions from this rule: Exemptions from this rule:
- Symbols from the following modules are used to support static analysis and type checking: - Symbols from the following modules are used to support static analysis and type checking:
- [`typing` module](https://google.github.io/styleguide/pyguide.html#typing-imports) - [`typing` module](https://google.github.io/styleguide/pyguide.html#typing-imports)
- [`collections.abc` module](https://google.github.io/styleguide/pyguide.html#typing-imports) - [`collections.abc` module](https://google.github.io/styleguide/pyguide.html#typing-imports)
- [`typing_extensions` module](https://github.com/python/typing_extensions/blob/main/README.md) - [`typing_extensions` module](https://github.com/python/typing_extensions/blob/main/README.md)
- Redirects from the [six.moves module](https://six.readthedocs.io/#module-six.moves). - Redirects from the [six.moves module](https://six.readthedocs.io/#module-six.moves).
### Packages ### Packages
Import each module using the full pathname location of the module. Import each module using the full pathname location of the module.
@ -85,6 +86,7 @@ No:
The directory the main binary is located in should not be assumed to be in `sys.path` despite that happening in some environments. This being the case, code should assume that `import jodie` refers to a third-party or top-level package named `jodie`, not a local `jodie.py`. The directory the main binary is located in should not be assumed to be in `sys.path` despite that happening in some environments. This being the case, code should assume that `import jodie` refers to a third-party or top-level package named `jodie`, not a local `jodie.py`.
### Default Iterators and Operators ### Default Iterators and Operators
Use default iterators and operators for types that support them, like lists, dictionaries, and files. Use default iterators and operators for types that support them, like lists, dictionaries, and files.
#### Definition #### Definition
@ -125,7 +127,7 @@ Okay in most cases.
You can specify values for variables at the end of a functions parameter list, e.g., `def foo(a, b=0):`. If `foo` is called with only one argument, `b` is set to 0. If it is called with two arguments, `b` has the value of the second argument. You can specify values for variables at the end of a functions parameter list, e.g., `def foo(a, b=0):`. If `foo` is called with only one argument, `b` is set to 0. If it is called with two arguments, `b` has the value of the second argument.
#### Decision #### Decision
Okay to use with the following caveat: Okay to use with the following caveat:
@ -158,7 +160,6 @@ No: def foo(a, b: Mapping = {}): # Could still get passed to unchecked code.
### True/False Evaluations ### True/False Evaluations
Use the “implicit” false if possible, e.g., `if foo:` rather than `if foo != []:` Use the “implicit” false if possible, e.g., `if foo:` rather than `if foo != []:`
### Lexical Scoping ### Lexical Scoping
@ -175,11 +176,11 @@ def get_adder(summand1: float) -> Callable[[float], float]:
return adder return adder
``` ```
#### Decision #### Decision
Okay to use. Okay to use.
### Threading ### Threading
Do not rely on the atomicity of built-in types. Do not rely on the atomicity of built-in types.

View File

@ -1,32 +1,35 @@
## Show possible configurations ## Show possible configurations
The possible configurations of Qodo Merge are stored in [here](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml){:target="_blank"}. The possible configurations of Qodo Merge are stored in [here](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml){:target="_blank"}.
In the [tools](https://qodo-merge-docs.qodo.ai/tools/) page you can find explanations on how to use these configurations for each tool. In the [tools](https://qodo-merge-docs.qodo.ai/tools/) page you can find explanations on how to use these configurations for each tool.
To print all the available configurations as a comment on your PR, you can use the following command: To print all the available configurations as a comment on your PR, you can use the following command:
``` ```
/config /config
``` ```
![possible_config1](https://codium.ai/images/pr_agent/possible_config1.png){width=512} ![possible_config1](https://codium.ai/images/pr_agent/possible_config1.png){width=512}
To view the **actual** configurations used for a specific tool, after all the user settings are applied, you can add for each tool a `--config.output_relevant_configurations=true` suffix. To view the **actual** configurations used for a specific tool, after all the user settings are applied, you can add for each tool a `--config.output_relevant_configurations=true` suffix.
For example: For example:
``` ```
/improve --config.output_relevant_configurations=true /improve --config.output_relevant_configurations=true
``` ```
Will output an additional field showing the actual configurations used for the `improve` tool. Will output an additional field showing the actual configurations used for the `improve` tool.
![possible_config2](https://codium.ai/images/pr_agent/possible_config2.png){width=512} ![possible_config2](https://codium.ai/images/pr_agent/possible_config2.png){width=512}
## Ignoring files from analysis ## Ignoring files from analysis
In some cases, you may want to exclude specific files or directories from the analysis performed by Qodo Merge. This can be useful, for example, when you have files that are generated automatically or files that shouldn't be reviewed, like vendor code. In some cases, you may want to exclude specific files or directories from the analysis performed by Qodo Merge. This can be useful, for example, when you have files that are generated automatically or files that shouldn't be reviewed, like vendor code.
You can ignore files or folders using the following methods: You can ignore files or folders using the following methods:
- `IGNORE.GLOB`
- `IGNORE.REGEX` - `IGNORE.GLOB`
- `IGNORE.REGEX`
which you can edit to ignore files or folders based on glob or regex patterns. which you can edit to ignore files or folders based on glob or regex patterns.
@ -37,14 +40,15 @@ Let's look at an example where we want to ignore all files with `.py` extension
To ignore Python files in a PR with online usage, comment on a PR: To ignore Python files in a PR with online usage, comment on a PR:
`/review --ignore.glob="['*.py']"` `/review --ignore.glob="['*.py']"`
To ignore Python files in all PRs using `glob` pattern, set in a configuration file: To ignore Python files in all PRs using `glob` pattern, set in a configuration file:
``` ```
[ignore] [ignore]
glob = ['*.py'] glob = ['*.py']
``` ```
And to ignore Python files in all PRs using `regex` pattern, set in a configuration file: And to ignore Python files in all PRs using `regex` pattern, set in a configuration file:
``` ```
[regex] [regex]
regex = ['.*\.py$'] regex = ['.*\.py$']
@ -53,6 +57,7 @@ regex = ['.*\.py$']
## Extra instructions ## Extra instructions
All Qodo Merge tools have a parameter called `extra_instructions`, that enables to add free-text extra instructions. Example usage: All Qodo Merge 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 ..." /update_changelog --pr_update_changelog.extra_instructions="Make sure to update also the version ..."
``` ```
@ -63,16 +68,16 @@ The default response language for Qodo Merge is **U.S. English**. However, some
To configure this, set the `response_language` parameter in the configuration file. This will prompt the model to respond in the specified language. Use a **standard locale code** based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166) (country codes) and [ISO 639](https://en.wikipedia.org/wiki/ISO_639) (language codes) to define a language-country pair. See this [comprehensive list of locale codes](https://simplelocalize.io/data/locales/). To configure this, set the `response_language` parameter in the configuration file. This will prompt the model to respond in the specified language. Use a **standard locale code** based on [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166) (country codes) and [ISO 639](https://en.wikipedia.org/wiki/ISO_639) (language codes) to define a language-country pair. See this [comprehensive list of locale codes](https://simplelocalize.io/data/locales/).
Example: Example:
```toml ```toml
[config] [config]
response_language: "it-IT" response_language = "it-IT"
``` ```
This will set the response language globally for all the commands to Italian. This will set the response language globally for all the commands to Italian.
> **Important:** Note that only dynamic text generated by the AI model is translated to the configured language. Static text such as labels and table headers that are not part of the AI models response will remain in US English. In addition, the model you are using must have good support for the specified language. > **Important:** Note that only dynamic text generated by the AI model is translated to the configured language. Static text such as labels and table headers that are not part of the AI models response will remain in US English. In addition, the model you are using must have good support for the specified language.
[//]: # (## Working with large PRs) [//]: # (## Working with large PRs)
@ -92,11 +97,10 @@ This will set the response language globally for all the commands to Italian.
[//]: # (which divides the PR into chunks, and processes each chunk separately. With this mode, regardless of the model, no compression will be done &#40;but for large PRs, multiple model calls may occur&#41;) [//]: # (which divides the PR into chunks, and processes each chunk separately. With this mode, regardless of the model, no compression will be done &#40;but for large PRs, multiple model calls may occur&#41;)
## Patch Extra Lines ## Patch Extra Lines
By default, around any change in your PR, git patch provides three lines of context above and below the change. By default, around any change in your PR, git patch provides three lines of context above and below the change.
``` ```
@@ -12,5 +12,5 @@ def func1(): @@ -12,5 +12,5 @@ def func1():
code line that already existed in the file... code line that already existed in the file...
@ -110,6 +114,7 @@ By default, around any change in your PR, git patch provides three lines of cont
``` ```
Qodo Merge will try to increase the number of lines of context, via the parameter: Qodo Merge will try to increase the number of lines of context, via the parameter:
``` ```
[config] [config]
patch_extra_lines_before=3 patch_extra_lines_before=3
@ -136,6 +141,7 @@ The default log level is "DEBUG", which provides detailed output of all operatio
Various logging observability tools can be used out-of-the box when using the default LiteLLM AI Handler. Simply configure the LiteLLM callback settings in `configuration.toml` and set environment variables according to the LiteLLM [documentation](https://docs.litellm.ai/docs/). Various logging observability tools can be used out-of-the box when using the default LiteLLM AI Handler. Simply configure the LiteLLM callback settings in `configuration.toml` and set environment variables according to the LiteLLM [documentation](https://docs.litellm.ai/docs/).
For example, to use [LangSmith](https://www.langchain.com/langsmith) you can add the following to your `configuration.toml` file: For example, to use [LangSmith](https://www.langchain.com/langsmith) you can add the following to your `configuration.toml` file:
``` ```
[litellm] [litellm]
enable_callbacks = true enable_callbacks = true
@ -158,6 +164,7 @@ Qodo Merge allows you to automatically ignore certain PRs based on various crite
- PRs with specific titles (using regex matching) - PRs with specific titles (using regex matching)
- PRs between specific branches (using regex matching) - PRs between specific branches (using regex matching)
- PRs from specific repositories (using regex matching)
- PRs not from specific folders - PRs not from specific folders
- PRs containing specific labels - PRs containing specific labels
- PRs opened by specific users - PRs opened by specific users
@ -166,7 +173,7 @@ Qodo Merge allows you to automatically ignore certain PRs based on various crite
To ignore PRs with a specific title such as "[Bump]: ...", you can add the following to your `configuration.toml` file: To ignore PRs with a specific title such as "[Bump]: ...", you can add the following to your `configuration.toml` file:
``` ```toml
[config] [config]
ignore_pr_title = ["\\[Bump\\]"] ignore_pr_title = ["\\[Bump\\]"]
``` ```
@ -177,7 +184,7 @@ Where the `ignore_pr_title` is a list of regex patterns to match the PR title yo
To ignore PRs from specific source or target branches, you can add the following to your `configuration.toml` file: To ignore PRs from specific source or target branches, you can add the following to your `configuration.toml` file:
``` ```toml
[config] [config]
ignore_pr_source_branches = ['develop', 'main', 'master', 'stage'] ignore_pr_source_branches = ['develop', 'main', 'master', 'stage']
ignore_pr_target_branches = ["qa"] ignore_pr_target_branches = ["qa"]
@ -186,6 +193,18 @@ ignore_pr_target_branches = ["qa"]
Where the `ignore_pr_source_branches` and `ignore_pr_target_branches` are lists of regex patterns to match the source and target branches you want to ignore. Where the `ignore_pr_source_branches` and `ignore_pr_target_branches` are lists of regex patterns to match the source and target branches you want to ignore.
They are not mutually exclusive, you can use them together or separately. They are not mutually exclusive, you can use them together or separately.
### Ignoring PRs from specific repositories
To ignore PRs from specific repositories, you can add the following to your `configuration.toml` file:
```toml
[config]
ignore_repositories = ["my-org/my-repo1", "my-org/my-repo2"]
```
Where the `ignore_repositories` is a list of regex patterns to match the repositories you want to ignore. This is useful when you have multiple repositories and want to exclude certain ones from analysis.
### Ignoring PRs not from specific folders ### Ignoring PRs not from specific folders
To allow only specific folders (often needed in large monorepos), set: To allow only specific folders (often needed in large monorepos), set:
@ -201,7 +220,7 @@ For the configuration above, automatic feedback will only be triggered when the
To ignore PRs containing specific labels, you can add the following to your `configuration.toml` file: To ignore PRs containing specific labels, you can add the following to your `configuration.toml` file:
``` ```
[config] [config]
ignore_pr_labels = ["do-not-merge"] ignore_pr_labels = ["do-not-merge"]
``` ```
@ -210,7 +229,7 @@ Where the `ignore_pr_labels` is a list of labels that when present in the PR, th
### Ignoring PRs from specific users ### Ignoring PRs from specific users
Qodo Merge automatically identifies and ignores pull requests created by bots using: Qodo Merge tries to automatically identify and ignore pull requests created by bots using:
- GitHub's native bot detection system - GitHub's native bot detection system
- Name-based pattern matching - Name-based pattern matching
@ -221,6 +240,7 @@ While this detection is robust, it may not catch all cases, particularly when:
- Bot names don't match common patterns - Bot names don't match common patterns
To supplement the automatic bot detection, you can manually specify users to ignore. Add the following to your `configuration.toml` file to ignore PRs from specific users: To supplement the automatic bot detection, you can manually specify users to ignore. Add the following to your `configuration.toml` file to ignore PRs from specific users:
``` ```
[config] [config]
ignore_pr_authors = ["my-special-bot-user", ...] ignore_pr_authors = ["my-special-bot-user", ...]
@ -228,3 +248,5 @@ ignore_pr_authors = ["my-special-bot-user", ...]
Where the `ignore_pr_authors` is a list of usernames that you want to ignore. Where the `ignore_pr_authors` is a list of usernames that you want to ignore.
!!! note
There is one specific case where bots will receive an automatic response - when they generated a PR with a _failed test_. In that case, the [`ci_feedback`](https://qodo-merge-docs.qodo.ai/tools/ci_feedback/) tool will be invoked.

View File

@ -14,23 +14,26 @@ Examples of invoking the different tools via the CLI:
**Notes:** **Notes:**
1. in addition to editing your local configuration file, you can also change 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 -m pr_agent.cli --pr_url=<pr_url> /review --pr_reviewer.extra_instructions="focus on the file: ..." python -m pr_agent.cli --pr_url=<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`: 2. You can print results locally, without publishing them, by setting in `configuration.toml`:
``` ```
[config] [config]
publish_output=false publish_output=false
verbosity_level=2 verbosity_level=2
``` ```
This is useful for debugging or experimenting with different tools. This is useful for debugging or experimenting with different tools.
3. **git provider**: The [git_provider](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L5) field in a configuration file determines the GIT provider that will be used by Qodo Merge. Currently, the following providers are supported: 3. **git provider**: The [git_provider](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L5) field in a configuration file determines the GIT provider that will be used by Qodo Merge. Currently, the following providers are supported:
`github` **(default)**, `gitlab`, `bitbucket`, `azure`, `codecommit`, `local`, and `gerrit`. `github` **(default)**, `gitlab`, `bitbucket`, `azure`, `codecommit`, `local`, and `gerrit`.
### CLI Health Check ### CLI Health Check
To verify that Qodo Merge has been configured correctly, you can run this health check command from the repository root: To verify that Qodo Merge has been configured correctly, you can run this health check command from the repository root:
```bash ```bash
@ -63,18 +66,17 @@ Commands for invoking the different tools via comments:
- **Ask**: `/ask "..."` - **Ask**: `/ask "..."`
- **Update Changelog**: `/update_changelog` - **Update Changelog**: `/update_changelog`
To edit a specific configuration value, just add `--config_path=<value>` to any command. To edit a specific configuration value, just add `--config_path=<value>` to any command.
For example, if you want to edit the `review` tool configurations, you can run: 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](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) file can be similarly edited. Comment `/config` to see the list of available configurations. Any configuration value in [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) file can be similarly edited. Comment `/config` to see the list of available configurations.
## Qodo Merge Automatic Feedback ## Qodo Merge Automatic Feedback
### Disabling all automatic feedback ### Disabling all automatic feedback
To easily disable all automatic feedback from Qodo Merge (GitHub App, GitLab Webhook, BitBucket App, Azure DevOps Webhook), set in a configuration file: To easily disable all automatic feedback from Qodo Merge (GitHub App, GitLab Webhook, BitBucket App, Azure DevOps Webhook), set in a configuration file:
@ -97,6 +99,7 @@ When this parameter is set to `true`, Qodo Merge will not run any automatic tool
The [github_app](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L220) section defines GitHub app specific configurations. The [github_app](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L220) section defines GitHub app specific configurations.
The configuration parameter `pr_commands` defines the list of tools that will be **run automatically** when a new PR is opened: The configuration parameter `pr_commands` defines the list of tools that will be **run automatically** when a new PR is opened:
```toml ```toml
[github_app] [github_app]
pr_commands = [ pr_commands = [
@ -108,6 +111,17 @@ pr_commands = [
This means that when a new PR is opened/reopened or marked as ready for review, Qodo Merge will run the `describe`, `review` and `improve` tools. This means that when a new PR is opened/reopened or marked as ready for review, Qodo Merge will run the `describe`, `review` and `improve` tools.
**Draft PRs:**
By default, draft PRs are not considered for automatic tools, but you can change this by setting the `feedback_on_draft_pr` parameter to `true` in the configuration file.
```toml
[github_app]
feedback_on_draft_pr = true
```
**Changing default tool parameters:**
You can override the default tool parameters by using one the three options for a [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/): **wiki**, **local**, or **global**. You can override the default tool parameters by using one the three options for a [configuration file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/): **wiki**, **local**, or **global**.
For example, if your configuration file contains: For example, if your configuration file contains:
@ -118,8 +132,12 @@ generate_ai_title = true
Every time you run the `describe` tool (including automatic runs) the PR title will be generated by the AI. Every time you run the `describe` tool (including automatic runs) the PR title will be generated by the AI.
**Parameters for automated runs:**
You can customize configurations specifically for automated runs by using the `--config_path=<value>` parameter. You can customize configurations specifically for automated runs by using the `--config_path=<value>` parameter.
For instance, to modify the `review` tool settings only for newly opened PRs, use: For instance, to modify the `review` tool settings only for newly opened PRs, use:
```toml ```toml
[github_app] [github_app]
pr_commands = [ pr_commands = [
@ -135,6 +153,7 @@ In addition to running automatic tools when a PR is opened, the GitHub app can a
The configuration toggle `handle_push_trigger` can be used to enable this feature. The configuration toggle `handle_push_trigger` can be used to enable this feature.
The configuration parameter `push_commands` defines the list of tools that will be **run automatically** when new code is pushed to the PR. The configuration parameter `push_commands` defines the list of tools that will be **run automatically** when new code is pushed to the PR.
```toml ```toml
[github_app] [github_app]
handle_push_trigger = true handle_push_trigger = true
@ -143,12 +162,15 @@ push_commands = [
"/review", "/review",
] ]
``` ```
This means that when new code is pushed to the PR, the Qodo Merge will run the `describe` and `review` tools, with the specified parameters. This means that when new code is pushed to the PR, the Qodo Merge will run the `describe` and `review` tools, with the specified parameters.
### GitHub Action ### GitHub Action
`GitHub Action` is a different way to trigger Qodo Merge tools, and uses a different configuration mechanism than `GitHub App`.<br> `GitHub Action` is a different way to trigger Qodo Merge tools, and uses a different configuration mechanism than `GitHub App`.<br>
You can configure settings for `GitHub Action` by adding environment variables under the env section in `.github/workflows/pr_agent.yml` file. You can configure settings for `GitHub Action` by adding environment variables under the env section in `.github/workflows/pr_agent.yml` file.
Specifically, start by setting the following environment variables: Specifically, start by setting the following environment variables:
```yaml ```yaml
env: env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }} # Make sure to add your OpenAI key to your repo secrets OPENAI_KEY: ${{ secrets.OPENAI_KEY }} # Make sure to add your OpenAI key to your repo secrets
@ -158,6 +180,7 @@ Specifically, start by setting the following environment variables:
github_action_config.auto_improve: "true" # enable\disable auto improve github_action_config.auto_improve: "true" # enable\disable auto improve
github_action_config.pr_actions: '["opened", "reopened", "ready_for_review", "review_requested"]' github_action_config.pr_actions: '["opened", "reopened", "ready_for_review", "review_requested"]'
``` ```
`github_action_config.auto_review`, `github_action_config.auto_describe` and `github_action_config.auto_improve` are used to enable/disable automatic tools that run when a new PR is opened. `github_action_config.auto_review`, `github_action_config.auto_describe` and `github_action_config.auto_improve` are used to enable/disable automatic tools that run when a new PR is opened.
If not set, the default configuration is for all three tools to run automatically when a new PR is opened. If not set, the default configuration is for all three tools to run automatically when a new PR is opened.
@ -180,6 +203,7 @@ publish_labels = false
to prevent Qodo Merge from publishing labels when running the `describe` tool. to prevent Qodo Merge from publishing labels when running the `describe` tool.
### GitLab Webhook ### GitLab Webhook
After setting up a GitLab webhook, to control which commands will run automatically when a new MR is opened, you can set the `pr_commands` parameter in the configuration file, similar to the GitHub App: After setting up a GitLab webhook, to control which commands will run automatically when a new MR is opened, you can set the `pr_commands` parameter in the configuration file, similar to the GitHub App:
```toml ```toml
@ -194,6 +218,7 @@ pr_commands = [
the GitLab webhook can also respond to new code that is pushed to an open MR. the GitLab webhook can also respond to new code that is pushed to an open MR.
The configuration toggle `handle_push_trigger` can be used to enable this feature. The configuration toggle `handle_push_trigger` can be used to enable this feature.
The configuration parameter `push_commands` defines the list of tools that will be **run automatically** when new code is pushed to the MR. The configuration parameter `push_commands` defines the list of tools that will be **run automatically** when new code is pushed to the MR.
```toml ```toml
[gitlab] [gitlab]
handle_push_trigger = true handle_push_trigger = true
@ -206,11 +231,13 @@ push_commands = [
Note that to use the 'handle_push_trigger' feature, you need to give the gitlab webhook also the "Push events" scope. Note that to use the 'handle_push_trigger' feature, you need to give the gitlab webhook also the "Push events" scope.
### BitBucket App ### BitBucket App
Similar to GitHub app, when running Qodo Merge from BitBucket App, the default [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) will be initially loaded. Similar to GitHub app, when running Qodo Merge from BitBucket App, the default [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml) will be initially loaded.
By uploading a local `.pr_agent.toml` file to the root of the repo's default branch, you can edit and customize any configuration parameter. Note that you need to upload `.pr_agent.toml` prior to creating a PR, in order for the configuration to take effect. By uploading a local `.pr_agent.toml` file to the root of the repo's default branch, you can edit and customize any configuration parameter. Note that you need to upload `.pr_agent.toml` prior to creating a PR, in order for the configuration to take effect.
For example, if your local `.pr_agent.toml` file contains: For example, if your local `.pr_agent.toml` file contains:
```toml ```toml
[pr_reviewer] [pr_reviewer]
extra_instructions = "Answer in japanese" extra_instructions = "Answer in japanese"
@ -218,12 +245,10 @@ extra_instructions = "Answer in japanese"
Each time you invoke a `/review` tool, it will use the extra instructions you set in the local configuration file. Each time you invoke a `/review` tool, it will use the extra instructions you set in the local configuration file.
Note that among other limitations, BitBucket provides relatively low rate-limits for applications (up to 1000 requests per hour), and does not provide an API to track the actual rate-limit usage. Note that among other limitations, BitBucket provides relatively low rate-limits for applications (up to 1000 requests per hour), and does not provide an API to track the actual rate-limit usage.
If you experience a lack of responses from Qodo Merge, you might want to set: `bitbucket_app.avoid_full_files=true` in your configuration file. If you experience a lack of responses from Qodo Merge, you might want to set: `bitbucket_app.avoid_full_files=true` in your configuration file.
This will prevent Qodo Merge from acquiring the full file content, and will only use the diff content. This will reduce the number of requests made to BitBucket, at the cost of small decrease in accuracy, as dynamic context will not be applicable. This will prevent Qodo Merge from acquiring the full file content, and will only use the diff content. This will reduce the number of requests made to BitBucket, at the cost of small decrease in accuracy, as dynamic context will not be applicable.
#### BitBucket Self-Hosted App automatic tools #### BitBucket Self-Hosted App automatic tools
To control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file: To control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file:
@ -236,10 +261,12 @@ pr_commands = [
"/improve --pr_code_suggestions.commitable_code_suggestions=true --pr_code_suggestions.suggestions_score_threshold=7", "/improve --pr_code_suggestions.commitable_code_suggestions=true --pr_code_suggestions.suggestions_score_threshold=7",
] ]
``` ```
Note that we set specifically for bitbucket, we recommend using: `--pr_code_suggestions.suggestions_score_threshold=7` and that is the default value we set for bitbucket. Note that we set specifically for bitbucket, we recommend using: `--pr_code_suggestions.suggestions_score_threshold=7` and that is the default value we set for bitbucket.
Since this platform only supports inline code suggestions, we want to limit the number of suggestions, and only present a limited number. Since this platform only supports inline code suggestions, we want to limit the number of suggestions, and only present a limited number.
To enable BitBucket app to respond to each **push** to the PR, set (for example): To enable BitBucket app to respond to each **push** to the PR, set (for example):
```toml ```toml
[bitbucket_app] [bitbucket_app]
handle_push_trigger = true handle_push_trigger = true
@ -252,6 +279,7 @@ push_commands = [
### Azure DevOps provider ### Azure DevOps provider
To use Azure DevOps provider use the following settings in configuration.toml: To use Azure DevOps provider use the following settings in configuration.toml:
```toml ```toml
[config] [config]
git_provider="azure" git_provider="azure"
@ -265,6 +293,7 @@ If PAT was chosen, you can assign the value in .secrets.toml.
If DefaultAzureCredential was chosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly, If DefaultAzureCredential was chosen, you can assigned the additional env vars like AZURE_CLIENT_SECRET directly,
or use managed identity/az cli (for local development) without any additional configuration. or use managed identity/az cli (for local development) without any additional configuration.
in any case, 'org' value must be assigned in .secrets.toml: in any case, 'org' value must be assigned in .secrets.toml:
``` ```
[azure_devops] [azure_devops]
org = "https://dev.azure.com/YOUR_ORGANIZATION/" org = "https://dev.azure.com/YOUR_ORGANIZATION/"
@ -274,6 +303,7 @@ org = "https://dev.azure.com/YOUR_ORGANIZATION/"
#### Azure DevOps Webhook #### Azure DevOps Webhook
To control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file, similar to the GitHub App: To control which commands will run automatically when a new PR is opened, you can set the `pr_commands` parameter in the configuration file, similar to the GitHub App:
```toml ```toml
[azure_devops_server] [azure_devops_server]
pr_commands = [ pr_commands = [

View File

@ -1,7 +1,7 @@
## Changing a model in PR-Agent ## Changing a model in PR-Agent
See [here](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/__init__.py) for a list of available models. See [here](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/__init__.py) for a list of available models.
To use a different model than the default (o3-mini), you need to edit in the [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L2) the fields: To use a different model than the default (o4-mini), you need to edit in the [configuration file](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L2) the fields:
```toml ```toml
[config] [config]
@ -16,6 +16,23 @@ You can give parameters via a configuration file, or from environment variables.
See [litellm documentation](https://litellm.vercel.app/docs/proxy/quick_start#supported-llms) for the environment variables needed per model, as they may vary and change over time. Our documentation per-model may not always be up-to-date with the latest changes. See [litellm documentation](https://litellm.vercel.app/docs/proxy/quick_start#supported-llms) for the environment variables needed per model, as they may vary and change over time. Our documentation per-model may not always be up-to-date with the latest changes.
Failing to set the needed keys of a specific model will usually result in litellm not identifying the model type, and failing to utilize it. Failing to set the needed keys of a specific model will usually result in litellm not identifying the model type, and failing to utilize it.
### OpenAI like API
To use an OpenAI like API, set the following in your `.secrets.toml` file:
```toml
[openai]
api_base = "https://api.openai.com/v1"
api_key = "sk-..."
```
or use the environment variables (make sure to use double underscores `__`):
```bash
OPENAI__API_BASE=https://api.openai.com/v1
OPENAI__KEY=sk-...
```
### Azure ### Azure
To use Azure, set in your `.secrets.toml` (working from CLI), or in the GitHub `Settings > Secrets and variables` (working from GitHub App or GitHub Action): To use Azure, set in your `.secrets.toml` (working from CLI), or in the GitHub `Settings > Secrets and variables` (working from GitHub App or GitHub Action):
@ -47,7 +64,6 @@ tenant_id = "" # Your Azure AD tenant ID
api_base = "" # Your Azure OpenAI service base URL (e.g., https://openai.xyz.com/) api_base = "" # Your Azure OpenAI service base URL (e.g., https://openai.xyz.com/)
``` ```
Passing custom headers to the underlying LLM Model API can be done by setting extra_headers parameter to litellm. Passing custom headers to the underlying LLM Model API can be done by setting extra_headers parameter to litellm.
```toml ```toml
@ -173,8 +189,8 @@ To use [Google AI Studio](https://aistudio.google.com/) models, set the relevant
```toml ```toml
[config] # in configuration.toml [config] # in configuration.toml
model="google_ai_studio/gemini-1.5-flash" model="gemini/gemini-1.5-flash"
fallback_models=["google_ai_studio/gemini-1.5-flash"] fallback_models=["gemini/gemini-1.5-flash"]
[google_ai_studio] # in .secrets.toml [google_ai_studio] # in .secrets.toml
gemini_api_key = "..." gemini_api_key = "..."
@ -251,6 +267,50 @@ key = ... # your DeepInfra api key
(you can obtain a DeepInfra key from [here](https://deepinfra.com/dash/api_keys)) (you can obtain a DeepInfra key from [here](https://deepinfra.com/dash/api_keys))
### Mistral
To use models like Mistral or Codestral with Mistral, for example, set:
```toml
[config] # in configuration.toml
model = "mistral/mistral-small-latest"
fallback_models = ["mistral/mistral-medium-latest"]
[mistral] # in .secrets.toml
key = "..." # your Mistral api key
```
(you can obtain a Mistral key from [here](https://console.mistral.ai/api-keys))
### Codestral
To use Codestral model with Codestral, for example, set:
```toml
[config] # in configuration.toml
model = "codestral/codestral-latest"
fallback_models = ["codestral/codestral-2405"]
[codestral] # in .secrets.toml
key = "..." # your Codestral api key
```
(you can obtain a Codestral key from [here](https://console.mistral.ai/codestral))
### Openrouter
To use model from Openrouter, for example, set:
```toml
[config] # in configuration.toml
model="openrouter/anthropic/claude-3.7-sonnet"
fallback_models=["openrouter/deepseek/deepseek-chat"]
custom_model_max_tokens=20000
[openrouter] # in .secrets.toml or passed an environment variable openrouter__key
key = "..." # your openrouter api key
```
(you can obtain an Openrouter API key from [here](https://openrouter.ai/settings/keys))
### Custom models ### Custom models
If the relevant model doesn't appear [here](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/__init__.py), you can still use it as a custom model: If the relevant model doesn't appear [here](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/algo/__init__.py), you can still use it as a custom model:
@ -284,7 +344,7 @@ To bypass chat templates and temperature controls, set `config.custom_reasoning_
reasoning_efffort= = "medium" # "low", "medium", "high" reasoning_efffort= = "medium" # "low", "medium", "high"
``` ```
With the OpenAI models that support reasoning effort (eg: o3-mini), you can specify its reasoning effort via `config` section. The default value is `medium`. You can change it to `high` or `low` based on your usage. With the OpenAI models that support reasoning effort (eg: o4-mini), you can specify its reasoning effort via `config` section. The default value is `medium`. You can change it to `high` or `low` based on your usage.
### Anthropic models ### Anthropic models

View File

@ -23,7 +23,6 @@ In terms of precedence, wiki configurations will override local configurations,
With Qodo Merge, you can set configurations by creating a page called `.pr_agent.toml` in the [wiki](https://github.com/Codium-ai/pr-agent/wiki/pr_agent.toml) of the repo. With Qodo Merge, you can set configurations by creating a page called `.pr_agent.toml` in the [wiki](https://github.com/Codium-ai/pr-agent/wiki/pr_agent.toml) of the repo.
The advantage of this method is that it allows to set configurations without needing to commit new content to the repo - just edit the wiki page and **save**. The advantage of this method is that it allows to set configurations without needing to commit new content to the repo - just edit the wiki page and **save**.
![wiki_configuration](https://codium.ai/images/pr_agent/wiki_configuration.png){width=512} ![wiki_configuration](https://codium.ai/images/pr_agent/wiki_configuration.png){width=512}
Click [here](https://codium.ai/images/pr_agent/wiki_configuration_pr_agent.mp4) to see a short instructional video. We recommend surrounding the configuration content with triple-quotes (or \`\`\`toml), to allow better presentation when displayed in the wiki as markdown. Click [here](https://codium.ai/images/pr_agent/wiki_configuration_pr_agent.mp4) to see a short instructional video. We recommend surrounding the configuration content with triple-quotes (or \`\`\`toml), to allow better presentation when displayed in the wiki as markdown.
@ -40,8 +39,7 @@ Qodo Merge will know to remove the surrounding quotes when reading the configura
`Platforms supported: GitHub, GitLab, Bitbucket, Azure DevOps` `Platforms supported: GitHub, GitLab, Bitbucket, Azure DevOps`
By uploading a local `.pr_agent.toml` file to the root of the repo's default branch, you can edit and customize any configuration parameter. Note that you need to upload or update `.pr_agent.toml` before using the PR Agent tools (either at PR creation or via manual trigger) for the configuration to take effect.
By uploading a local `.pr_agent.toml` file to the root of the repo's default branch, you can edit and customize any configuration parameter. Note that you need to upload `.pr_agent.toml` prior to creating a PR, in order for the configuration to take effect.
For example, if you set in `.pr_agent.toml`: For example, if you set in `.pr_agent.toml`:
@ -56,7 +54,6 @@ extra_instructions="""\
Then you can give a list of extra instructions to the `review` tool. Then you can give a list of extra instructions to the `review` tool.
## Global configuration file 💎 ## Global configuration file 💎
`Platforms supported: GitHub, GitLab, Bitbucket` `Platforms supported: GitHub, GitLab, Bitbucket`
@ -71,27 +68,27 @@ For example, in the GitHub organization `Codium-ai`:
- The repo [`https://github.com/Codium-ai/pr-agent`](https://github.com/Codium-ai/pr-agent/blob/main/.pr_agent.toml) inherits the global configuration file from `pr-agent-settings`. - The repo [`https://github.com/Codium-ai/pr-agent`](https://github.com/Codium-ai/pr-agent/blob/main/.pr_agent.toml) inherits the global configuration file from `pr-agent-settings`.
### Bitbucket Organization level configuration file 💎 ### Bitbucket Organization level configuration file 💎
`Relevant platforms: Bitbucket Data Center` `Relevant platforms: Bitbucket Data Center`
In Bitbucket Data Center, there are two levels where you can define a global configuration file: In Bitbucket Data Center, there are two levels where you can define a global configuration file:
* Project-level global configuration: - Project-level global configuration:
Create a repository named `pr-agent-settings` within a specific project. The configuration file in this repository will apply to all repositories under the same project. Create a repository named `pr-agent-settings` within a specific project. The configuration file in this repository will apply to all repositories under the same project.
* Organization-level global configuration: - Organization-level global configuration:
Create a dedicated project to hold a global configuration file that affects all repositories across all projects in your organization. Create a dedicated project to hold a global configuration file that affects all repositories across all projects in your organization.
**Setting up organization-level global configuration:** **Setting up organization-level global configuration:**
1. Create a new project with both the name and key: PR_AGENT_SETTINGS. 1. Create a new project with both the name and key: PR_AGENT_SETTINGS.
2. Inside the PR_AGENT_SETTINGS project, create a repository named pr-agent-settings. 2. Inside the PR_AGENT_SETTINGS project, create a repository named pr-agent-settings.
3. In this repository, add a `.pr_agent.toml` configuration file—structured similarly to the global configuration file described above. 3. In this repository, add a `.pr_agent.toml` configuration file—structured similarly to the global configuration file described above.
4. Optionally, you can add organizational-level [global best practices file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/#global-configuration-file). 4. Optionally, you can add organizational-level [global best practices file](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/#global-configuration-file).
Repositories across your entire Bitbucket organization will inherit the configuration from this file. Repositories across your entire Bitbucket organization will inherit the configuration from this file.
!!! note "Note" !!! note "Note"
If both organization-level and project-level global settings are defined, the project-level settings will take precedence over the organization-level configuration. Additionally, parameters from a repositorys local .pr_agent.toml file will always override both global settings. If both organization-level and project-level global settings are defined, the project-level settings will take precedence over the organization-level configuration. Additionally, parameters from a repositorys local .pr_agent.toml file will always override both global settings.

View File

@ -1,6 +1,5 @@
`Supported Git Platforms: GitHub, GitLab, Bitbucket` `Supported Git Platforms: GitHub, GitLab, Bitbucket`
For optimal functionality of Qodo Merge, we recommend enabling a wiki for each repository where Qodo Merge is installed. The wiki serves several important purposes: For optimal functionality of Qodo Merge, we recommend enabling a wiki for each repository where Qodo Merge is installed. The wiki serves several important purposes:
**Key Wiki Features: 💎** **Key Wiki Features: 💎**
@ -9,7 +8,6 @@ For optimal functionality of Qodo Merge, we recommend enabling a wiki for each r
- Track [accepted suggestions](https://qodo-merge-docs.qodo.ai/tools/improve/#suggestion-tracking) - Track [accepted suggestions](https://qodo-merge-docs.qodo.ai/tools/improve/#suggestion-tracking)
- Facilitates learning over time by creating an [auto_best_practices.md](https://qodo-merge-docs.qodo.ai/core-abilities/auto_best_practices) file - Facilitates learning over time by creating an [auto_best_practices.md](https://qodo-merge-docs.qodo.ai/core-abilities/auto_best_practices) file
**Setup Instructions (GitHub):** **Setup Instructions (GitHub):**
To enable a wiki for your repository: To enable a wiki for your repository:
@ -27,6 +25,6 @@ To enable a wiki for your repository:
- Your code (and its derivatives, including accepted code suggestions) is yours. Qodo Merge will never store it on external servers. - Your code (and its derivatives, including accepted code suggestions) is yours. Qodo Merge will never store it on external servers.
- Repository changes typically require pull requests, which create overhead and are time-consuming. This process is too cumbersome for auto data aggregation, and is not very convenient even for managing frequently updated content like configuration files. - Repository changes typically require pull requests, which create overhead and are time-consuming. This process is too cumbersome for auto data aggregation, and is not very convenient even for managing frequently updated content like configuration files.
- A repository wiki page provides an ideal balance: - A repository wiki page provides an ideal balance:
- It lives within your repository, making it suitable for code-related documentation - It lives within your repository, making it suitable for code-related documentation
- It enables quick updates without the overhead of pull requests - It enables quick updates without the overhead of pull requests
- It maintains full Git version control, allowing you to track changes over time. - It maintains full Git version control, allowing you to track changes over time.

View File

@ -1,9 +1,8 @@
# Usage guide # Usage guide
This page provides a detailed guide on how to use Qodo Merge. This section provides a detailed guide on how to use Qodo Merge.
It includes information on how to adjust Qodo Merge configurations, define which tools will run automatically, and other advanced configurations. It includes information on how to adjust Qodo Merge configurations, define which tools will run automatically, and other advanced configurations.
- [Introduction](./introduction.md) - [Introduction](./introduction.md)
- [Enabling a Wiki](./enabling_a_wiki) - [Enabling a Wiki](./enabling_a_wiki)
- [Configuration File](./configuration_options.md) - [Configuration File](./configuration_options.md)
@ -17,10 +16,11 @@ It includes information on how to adjust Qodo Merge configurations, define which
- [Azure DevOps Provider](./automations_and_usage.md#azure-devops-provider) - [Azure DevOps Provider](./automations_and_usage.md#azure-devops-provider)
- [Managing Mail Notifications](./mail_notifications.md) - [Managing Mail Notifications](./mail_notifications.md)
- [Changing a Model](./changing_a_model.md) - [Changing a Model](./changing_a_model.md)
- [Additional Configurations Walkthrough](./additional_configurations.md) - [Additional Configurations](./additional_configurations.md)
- [Ignoring files from analysis](./additional_configurations.md#ignoring-files-from-analysis) - [Ignoring files from analysis](./additional_configurations.md#ignoring-files-from-analysis)
- [Extra instructions](./additional_configurations.md#extra-instructions) - [Extra instructions](./additional_configurations.md#extra-instructions)
- [Working with large PRs](./additional_configurations.md#working-with-large-prs) - [Working with large PRs](./additional_configurations.md#working-with-large-prs)
- [Changing a model](./additional_configurations.md#changing-a-model) - [Changing a model](https://qodo-merge-docs.qodo.ai/usage-guide/changing_a_model/)
- [Patch Extra Lines](./additional_configurations.md#patch-extra-lines) - [Patch Extra Lines](./additional_configurations.md#patch-extra-lines)
- [FAQ](https://qodo-merge-docs.qodo.ai/faq/)
- [Qodo Merge Models](./qodo_merge_models) - [Qodo Merge Models](./qodo_merge_models)

View File

@ -5,7 +5,6 @@ After [installation](https://qodo-merge-docs.qodo.ai/installation/), there are t
2. Online usage - by [commenting](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901){:target="_blank"} on a PR 2. Online usage - by [commenting](https://github.com/Codium-ai/pr-agent/pull/229#issuecomment-1695021901){:target="_blank"} on a PR
3. Enabling Qodo Merge tools to run automatically when a new PR is opened 3. Enabling Qodo Merge tools to run automatically when a new PR is opened
Specifically, CLI commands can be issued by invoking a pre-built [docker image](https://qodo-merge-docs.qodo.ai/installation/locally/#using-docker-image), or by invoking a [locally cloned repo](https://qodo-merge-docs.qodo.ai/installation/locally/#run-from-source). Specifically, CLI commands can be issued by invoking a pre-built [docker image](https://qodo-merge-docs.qodo.ai/installation/locally/#using-docker-image), or by invoking a [locally cloned repo](https://qodo-merge-docs.qodo.ai/installation/locally/#run-from-source).
For online usage, you will need to setup either a [GitHub App](https://qodo-merge-docs.qodo.ai/installation/github/#run-as-a-github-app) or a [GitHub Action](https://qodo-merge-docs.qodo.ai/installation/github/#run-as-a-github-action) (GitHub), a [GitLab webhook](https://qodo-merge-docs.qodo.ai/installation/gitlab/#run-a-gitlab-webhook-server) (GitLab), or a [BitBucket App](https://qodo-merge-docs.qodo.ai/installation/bitbucket/#run-using-codiumai-hosted-bitbucket-app) (BitBucket). For online usage, you will need to setup either a [GitHub App](https://qodo-merge-docs.qodo.ai/installation/github/#run-as-a-github-app) or a [GitHub Action](https://qodo-merge-docs.qodo.ai/installation/github/#run-as-a-github-action) (GitHub), a [GitLab webhook](https://qodo-merge-docs.qodo.ai/installation/gitlab/#run-a-gitlab-webhook-server) (GitLab), or a [BitBucket App](https://qodo-merge-docs.qodo.ai/installation/bitbucket/#run-using-codiumai-hosted-bitbucket-app) (BitBucket).

View File

@ -8,10 +8,10 @@ As an alternative, you can filter in your mail provider the notifications specif
![filter_mail_notifications](https://codium.ai/images/pr_agent/filter_mail_notifications.png){width=512} ![filter_mail_notifications](https://codium.ai/images/pr_agent/filter_mail_notifications.png){width=512}
Another option to reduce the mail overload, yet still receive notifications on Qodo Merge tools, is to disable the help collapsible section in Qodo Merge bot comments. Another option to reduce the mail overload, yet still receive notifications on Qodo Merge tools, is to disable the help collapsible section in Qodo Merge bot comments.
This can done by setting `enable_help_text=false` for the relevant tool in the configuration file. This can done by setting `enable_help_text=false` for the relevant tool in the configuration file.
For example, to disable the help text for the `pr_reviewer` tool, set: For example, to disable the help text for the `pr_reviewer` tool, set:
``` ```
[pr_reviewer] [pr_reviewer]
enable_help_text = false enable_help_text = false

View File

@ -1,32 +1,42 @@
The default model used by Qodo Merge (March 2025) is Claude Sonnet 3.7. The default models used by Qodo Merge (April 2025) are a combination of Claude Sonnet 3.7 and Gemini 2.5 Pro.
### Selecting a Specific Model ### Selecting a Specific Model
Users can configure Qodo Merge to use a specific model by editing the [configuration](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) file. Users can configure Qodo Merge to use only a specific model by editing the [configuration](https://qodo-merge-docs.qodo.ai/usage-guide/configuration_options/) file.
The models supported by Qodo Merge are: The models supported by Qodo Merge are:
- `claude-3-7-sonnet` (default) - `claude-3-7-sonnet`
- `o3-mini` - `o4-mini`
- `gpt-4.1` - `gpt-4.1`
- `gemini-2.5-pro`
- `deepseek/r1` - `deepseek/r1`
To restrict Qodo Merge to using only `o3-mini`, add this setting: To restrict Qodo Merge to using only `o4-mini`, add this setting:
```
```toml
[config] [config]
model="o3-mini" model="o4-mini"
``` ```
To restrict Qodo Merge to using only `GPT-4.1`, add this setting: To restrict Qodo Merge to using only `GPT-4.1`, add this setting:
```
```toml
[config] [config]
model="gpt-4.1" model="gpt-4.1"
``` ```
To restrict Qodo Merge to using only `deepseek-r1` us-hosted, add this setting: To restrict Qodo Merge to using only `gemini-2.5-pro`, add this setting:
```toml
[config]
model="gemini-2.5-pro"
``` ```
To restrict Qodo Merge to using only `deepseek-r1` us-hosted, add this setting:
```toml
[config] [config]
model="deepseek/r1" model="deepseek/r1"
``` ```

View File

@ -20,6 +20,7 @@ nav:
- Managing Mail Notifications: 'usage-guide/mail_notifications.md' - Managing Mail Notifications: 'usage-guide/mail_notifications.md'
- Changing a Model: 'usage-guide/changing_a_model.md' - Changing a Model: 'usage-guide/changing_a_model.md'
- Additional Configurations: 'usage-guide/additional_configurations.md' - Additional Configurations: 'usage-guide/additional_configurations.md'
- Frequently Asked Questions: 'faq/index.md'
- 💎 Qodo Merge Models: 'usage-guide/qodo_merge_models.md' - 💎 Qodo Merge Models: 'usage-guide/qodo_merge_models.md'
- Tools: - Tools:
- 'tools/index.md' - 'tools/index.md'
@ -39,10 +40,10 @@ nav:
- 💎 CI Feedback: 'tools/ci_feedback.md' - 💎 CI Feedback: 'tools/ci_feedback.md'
- 💎 Similar Code: 'tools/similar_code.md' - 💎 Similar Code: 'tools/similar_code.md'
- 💎 Implement: 'tools/implement.md' - 💎 Implement: 'tools/implement.md'
- 💎 Scan Repo Discussions: 'tools/scan_repo_discussions.md'
- Core Abilities: - Core Abilities:
- 'core-abilities/index.md' - 'core-abilities/index.md'
- Auto best practices: 'core-abilities/auto_best_practices.md' - Auto best practices: 'core-abilities/auto_best_practices.md'
- Pull request benchmark: 'finetuning_benchmark/index.md'
- Code validation: 'core-abilities/code_validation.md' - Code validation: 'core-abilities/code_validation.md'
- Compression strategy: 'core-abilities/compression_strategy.md' - Compression strategy: 'core-abilities/compression_strategy.md'
- Dynamic context: 'core-abilities/dynamic_context.md' - Dynamic context: 'core-abilities/dynamic_context.md'
@ -58,8 +59,10 @@ nav:
- Features: 'chrome-extension/features.md' - Features: 'chrome-extension/features.md'
- Data Privacy: 'chrome-extension/data_privacy.md' - Data Privacy: 'chrome-extension/data_privacy.md'
- Options: 'chrome-extension/options.md' - Options: 'chrome-extension/options.md'
- FAQ: - PR Benchmark:
- FAQ: 'faq/index.md' - PR Benchmark: 'pr_benchmark/index.md'
- Recent Updates:
- Recent Updates: 'recent_updates/index.md'
- AI Docs Search: 'ai_search/index.md' - AI Docs Search: 'ai_search/index.md'
# - Code Fine-tuning Benchmark: 'finetuning_benchmark/index.md' # - Code Fine-tuning Benchmark: 'finetuning_benchmark/index.md'
@ -81,7 +84,6 @@ theme:
- content.tabs.link - content.tabs.link
- content.code.annotation - content.code.annotation
- content.code.copy - content.code.copy
- content.tabs.link
language: en language: en
custom_dir: overrides custom_dir: overrides
@ -149,6 +151,8 @@ markdown_extensions:
- pymdownx.emoji: - pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg emoji_generator: !!python/name:material.extensions.emoji.to_svg
- pymdownx.tabbed:
alternate_style: true
- toc: - toc:
title: On this page title: On this page
toc_depth: 3 toc_depth: 3

View File

@ -84,10 +84,18 @@ class PRAgent:
if str(type(setting)) == "<class 'dynaconf.utils.boxing.DynaBox'>": if str(type(setting)) == "<class 'dynaconf.utils.boxing.DynaBox'>":
if hasattr(setting, 'extra_instructions'): if hasattr(setting, 'extra_instructions'):
current_extra_instructions = setting.extra_instructions current_extra_instructions = setting.extra_instructions
if current_extra_instructions:
setting.extra_instructions = current_extra_instructions+ f"\n======\n\nIn addition, Your response MUST be written in the language corresponding to local code: {response_language}. This is crucial." # Define the language-specific instruction and the separator
else: lang_instruction_text = f"Your response MUST be written in the language corresponding to locale code: '{response_language}'. This is crucial."
setting.extra_instructions = f"Your response MUST be written in the language corresponding to locale code: '{response_language}'. This is crucial." separator_text = "\n======\n\nIn addition, "
# Check if the specific language instruction is already present to avoid duplication
if lang_instruction_text not in str(current_extra_instructions):
if current_extra_instructions: # If there's existing text
setting.extra_instructions = str(current_extra_instructions) + separator_text + lang_instruction_text
else: # If extra_instructions was None or empty
setting.extra_instructions = lang_instruction_text
# If lang_instruction_text is already present, do nothing.
action = action.lstrip("/").lower() action = action.lstrip("/").lower()
if action not in command2class: if action not in command2class:

View File

@ -36,6 +36,10 @@ MAX_TOKENS = {
'o1': 204800, # 200K, but may be limited by config.max_model_tokens 'o1': 204800, # 200K, but may be limited by config.max_model_tokens
'o3-mini': 204800, # 200K, but may be limited by config.max_model_tokens 'o3-mini': 204800, # 200K, but may be limited by config.max_model_tokens
'o3-mini-2025-01-31': 204800, # 200K, but may be limited by config.max_model_tokens 'o3-mini-2025-01-31': 204800, # 200K, but may be limited by config.max_model_tokens
'o3': 200000, # 200K, but may be limited by config.max_model_tokens
'o3-2025-04-16': 200000, # 200K, but may be limited by config.max_model_tokens
'o4-mini': 200000, # 200K, but may be limited by config.max_model_tokens
'o4-mini-2025-04-16': 200000, # 200K, but may be limited by config.max_model_tokens
'claude-instant-1': 100000, 'claude-instant-1': 100000,
'claude-2': 100000, 'claude-2': 100000,
'command-nightly': 4096, 'command-nightly': 4096,
@ -53,13 +57,17 @@ MAX_TOKENS = {
'vertex_ai/claude-3-5-sonnet-v2@20241022': 100000, 'vertex_ai/claude-3-5-sonnet-v2@20241022': 100000,
'vertex_ai/claude-3-7-sonnet@20250219': 200000, 'vertex_ai/claude-3-7-sonnet@20250219': 200000,
'vertex_ai/gemini-1.5-pro': 1048576, 'vertex_ai/gemini-1.5-pro': 1048576,
'vertex_ai/gemini-2.5-pro-preview-03-25': 1048576,
'vertex_ai/gemini-2.5-pro-preview-05-06': 1048576,
'vertex_ai/gemini-1.5-flash': 1048576, 'vertex_ai/gemini-1.5-flash': 1048576,
'vertex_ai/gemini-2.0-flash': 1048576, 'vertex_ai/gemini-2.0-flash': 1048576,
'vertex_ai/gemini-2.5-flash-preview-04-17': 1048576,
'vertex_ai/gemma2': 8200, 'vertex_ai/gemma2': 8200,
'gemini/gemini-1.5-pro': 1048576, 'gemini/gemini-1.5-pro': 1048576,
'gemini/gemini-1.5-flash': 1048576, 'gemini/gemini-1.5-flash': 1048576,
'gemini/gemini-2.0-flash': 1048576, 'gemini/gemini-2.0-flash': 1048576,
'gemini/gemini-2.5-pro-preview-03-25': 1048576, 'gemini/gemini-2.5-pro-preview-03-25': 1048576,
'gemini/gemini-2.5-pro-preview-05-06': 1048576,
'codechat-bison': 6144, 'codechat-bison': 6144,
'codechat-bison-32k': 32000, 'codechat-bison-32k': 32000,
'anthropic.claude-instant-v1': 100000, 'anthropic.claude-instant-v1': 100000,
@ -108,6 +116,20 @@ MAX_TOKENS = {
"deepinfra/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B": 128000, "deepinfra/deepseek-ai/DeepSeek-R1-Distill-Qwen-32B": 128000,
"deepinfra/deepseek-ai/DeepSeek-R1-Distill-Llama-70B": 128000, "deepinfra/deepseek-ai/DeepSeek-R1-Distill-Llama-70B": 128000,
"deepinfra/deepseek-ai/DeepSeek-R1": 128000, "deepinfra/deepseek-ai/DeepSeek-R1": 128000,
"mistral/mistral-small-latest": 8191,
"mistral/mistral-medium-latest": 8191,
"mistral/mistral-large-2407": 128000,
"mistral/mistral-large-latest": 128000,
"mistral/open-mistral-7b": 8191,
"mistral/open-mixtral-8x7b": 8191,
"mistral/open-mixtral-8x22b": 8191,
"mistral/codestral-latest": 8191,
"mistral/open-mistral-nemo": 128000,
"mistral/open-mistral-nemo-2407": 128000,
"mistral/open-codestral-mamba": 256000,
"mistral/codestral-mamba-latest": 256000,
"codestral/codestral-latest": 8191,
"codestral/codestral-2405": 8191,
} }
USER_MESSAGE_ONLY_MODELS = [ USER_MESSAGE_ONLY_MODELS = [
@ -125,12 +147,20 @@ NO_SUPPORT_TEMPERATURE_MODELS = [
"o1-2024-12-17", "o1-2024-12-17",
"o3-mini", "o3-mini",
"o3-mini-2025-01-31", "o3-mini-2025-01-31",
"o1-preview" "o1-preview",
"o3",
"o3-2025-04-16",
"o4-mini",
"o4-mini-2025-04-16",
] ]
SUPPORT_REASONING_EFFORT_MODELS = [ SUPPORT_REASONING_EFFORT_MODELS = [
"o3-mini", "o3-mini",
"o3-mini-2025-01-31" "o3-mini-2025-01-31",
"o3",
"o3-2025-04-16",
"o4-mini",
"o4-mini-2025-04-16",
] ]
CLAUDE_EXTENDED_THINKING_MODELS = [ CLAUDE_EXTENDED_THINKING_MODELS = [

View File

@ -59,6 +59,7 @@ class LiteLLMAIHandler(BaseAiHandler):
litellm.api_version = get_settings().openai.api_version litellm.api_version = get_settings().openai.api_version
if get_settings().get("OPENAI.API_BASE", None): if get_settings().get("OPENAI.API_BASE", None):
litellm.api_base = get_settings().openai.api_base litellm.api_base = get_settings().openai.api_base
self.api_base = get_settings().openai.api_base
if get_settings().get("ANTHROPIC.KEY", None): if get_settings().get("ANTHROPIC.KEY", None):
litellm.anthropic_key = get_settings().anthropic.key litellm.anthropic_key = get_settings().anthropic.key
if get_settings().get("COHERE.KEY", None): if get_settings().get("COHERE.KEY", None):
@ -97,6 +98,14 @@ class LiteLLMAIHandler(BaseAiHandler):
if get_settings().get("DEEPINFRA.KEY", None): if get_settings().get("DEEPINFRA.KEY", None):
os.environ['DEEPINFRA_API_KEY'] = get_settings().get("DEEPINFRA.KEY") os.environ['DEEPINFRA_API_KEY'] = get_settings().get("DEEPINFRA.KEY")
# Support mistral models
if get_settings().get("MISTRAL.KEY", None):
os.environ["MISTRAL_API_KEY"] = get_settings().get("MISTRAL.KEY")
# Support codestral models
if get_settings().get("CODESTRAL.KEY", None):
os.environ["CODESTRAL_API_KEY"] = get_settings().get("CODESTRAL.KEY")
# Check for Azure AD configuration # Check for Azure AD configuration
if get_settings().get("AZURE_AD.CLIENT_ID", None): if get_settings().get("AZURE_AD.CLIENT_ID", None):
self.azure = True self.azure = True
@ -110,6 +119,18 @@ class LiteLLMAIHandler(BaseAiHandler):
litellm.api_base = self.api_base litellm.api_base = self.api_base
openai.api_base = self.api_base openai.api_base = self.api_base
# Support for Openrouter models
if get_settings().get("OPENROUTER.KEY", None):
openrouter_api_key = get_settings().get("OPENROUTER.KEY", None)
os.environ["OPENROUTER_API_KEY"] = openrouter_api_key
litellm.api_key = openrouter_api_key
openai.api_key = openrouter_api_key
openrouter_api_base = get_settings().get("OPENROUTER.API_BASE", "https://openrouter.ai/api/v1")
os.environ["OPENROUTER_API_BASE"] = openrouter_api_base
self.api_base = openrouter_api_base
litellm.api_base = openrouter_api_base
# Models that only use user meessage # Models that only use user meessage
self.user_message_only_models = USER_MESSAGE_ONLY_MODELS self.user_message_only_models = USER_MESSAGE_ONLY_MODELS

View File

@ -102,20 +102,20 @@ def process_patch_lines(patch_str, original_file_str, patch_extra_lines_before,
lines_before_original = file_original_lines[extended_start1 - 1:start1 - 1] lines_before_original = file_original_lines[extended_start1 - 1:start1 - 1]
lines_before_new = file_new_lines[extended_start2 - 1:start2 - 1] lines_before_new = file_new_lines[extended_start2 - 1:start2 - 1]
found_header = False found_header = False
if lines_before_original == lines_before_new: # Making sure no changes from a previous hunk for i, line in enumerate(lines_before_original):
for i, line, in enumerate(lines_before_original): if section_header in line:
if section_header in line: # Update start and size in one line each
extended_start1, extended_start2 = extended_start1 + i, extended_start2 + i
extended_size1, extended_size2 = extended_size1 - i, extended_size2 - i
lines_before_original_dynamic_context = lines_before_original[i:]
lines_before_new_dynamic_context = lines_before_new[i:]
if lines_before_original_dynamic_context == lines_before_new_dynamic_context:
# get_logger().debug(f"found dynamic context match for section header: {section_header}")
found_header = True found_header = True
# Update start and size in one line each
extended_start1, extended_start2 = extended_start1 + i, extended_start2 + i
extended_size1, extended_size2 = extended_size1 - i, extended_size2 - i
# get_logger().debug(f"Found section header in line {i} before the hunk")
section_header = '' section_header = ''
break else:
else: pass # its ok to be here. We cant apply dynamic context if the lines are different if 'old' and 'new' hunks
get_logger().debug(f"Extra lines before hunk are different in original and new file - dynamic context", break
artifact={"lines_before_original": lines_before_original,
"lines_before_new": lines_before_new})
if not found_header: if not found_header:
# get_logger().debug(f"Section header not found in the extra lines before the hunk") # get_logger().debug(f"Section header not found in the extra lines before the hunk")
@ -130,14 +130,26 @@ def process_patch_lines(patch_str, original_file_str, patch_extra_lines_before,
if file_new_lines: if file_new_lines:
delta_lines_new = [f' {line}' for line in file_new_lines[extended_start2 - 1:start2 - 1]] delta_lines_new = [f' {line}' for line in file_new_lines[extended_start2 - 1:start2 - 1]]
if delta_lines_original != delta_lines_new: if delta_lines_original != delta_lines_new:
get_logger().debug(f"Extra lines before hunk are different in original and new file", found_mini_match = False
artifact={"delta_lines_original": delta_lines_original, for i in range(len(delta_lines_original)):
"delta_lines_new": delta_lines_new}) if delta_lines_original[i:] == delta_lines_new[i:]:
extended_start1 = start1 delta_lines_original = delta_lines_original[i:]
extended_size1 = size1 delta_lines_new = delta_lines_new[i:]
extended_start2 = start2 extended_start1 += i
extended_size2 = size2 extended_size1 -= i
delta_lines_original = [] extended_start2 += i
extended_size2 -= i
found_mini_match = True
break
if not found_mini_match:
extended_start1 = start1
extended_size1 = size1
extended_start2 = start2
extended_size2 = size2
delta_lines_original = []
# get_logger().debug(f"Extra lines before hunk are different in original and new file",
# artifact={"delta_lines_original": delta_lines_original,
# "delta_lines_new": delta_lines_new})
# logic to remove section header if its in the extra delta lines (in dynamic context, this is also done) # logic to remove section header if its in the extra delta lines (in dynamic context, this is also done)
if section_header and not allow_dynamic_context: if section_header and not allow_dynamic_context:

View File

@ -12,7 +12,7 @@ from pr_agent.algo.git_patch_processing import (
from pr_agent.algo.language_handler import sort_files_by_main_languages from pr_agent.algo.language_handler import sort_files_by_main_languages
from pr_agent.algo.token_handler import TokenHandler from pr_agent.algo.token_handler import TokenHandler
from pr_agent.algo.types import EDIT_TYPE, FilePatchInfo from pr_agent.algo.types import EDIT_TYPE, FilePatchInfo
from pr_agent.algo.utils import ModelType, clip_tokens, get_max_tokens, get_weak_model from pr_agent.algo.utils import ModelType, clip_tokens, get_max_tokens, get_model
from pr_agent.config_loader import get_settings from pr_agent.config_loader import get_settings
from pr_agent.git_providers.git_provider import GitProvider from pr_agent.git_providers.git_provider import GitProvider
from pr_agent.log import get_logger from pr_agent.log import get_logger
@ -339,7 +339,11 @@ async def retry_with_fallback_models(f: Callable, model_type: ModelType = ModelT
def _get_all_models(model_type: ModelType = ModelType.REGULAR) -> List[str]: def _get_all_models(model_type: ModelType = ModelType.REGULAR) -> List[str]:
if model_type == ModelType.WEAK: if model_type == ModelType.WEAK:
model = get_weak_model() model = get_model('model_weak')
elif model_type == ModelType.REASONING:
model = get_model('model_reasoning')
elif model_type == ModelType.REGULAR:
model = get_settings().config.model
else: else:
model = get_settings().config.model model = get_settings().config.model
fallback_models = get_settings().config.fallback_models fallback_models = get_settings().config.fallback_models

View File

@ -30,12 +30,13 @@ from pr_agent.config_loader import get_settings, global_settings
from pr_agent.log import get_logger from pr_agent.log import get_logger
def get_weak_model() -> str: def get_model(model_type: str = "model_weak") -> str:
if get_settings().get("config.model_weak"): if model_type == "model_weak" and get_settings().get("config.model_weak"):
return get_settings().config.model_weak return get_settings().config.model_weak
elif model_type == "model_reasoning" and get_settings().get("config.model_reasoning"):
return get_settings().config.model_reasoning
return get_settings().config.model return get_settings().config.model
class Range(BaseModel): class Range(BaseModel):
line_start: int # should be 0-indexed line_start: int # should be 0-indexed
line_end: int line_end: int
@ -45,6 +46,7 @@ class Range(BaseModel):
class ModelType(str, Enum): class ModelType(str, Enum):
REGULAR = "regular" REGULAR = "regular"
WEAK = "weak" WEAK = "weak"
REASONING = "reasoning"
class PRReviewHeader(str, Enum): class PRReviewHeader(str, Enum):
REGULAR = "## PR Reviewer Guide" REGULAR = "## PR Reviewer Guide"
@ -729,8 +731,9 @@ def try_fix_yaml(response_text: str,
response_text_original="") -> dict: response_text_original="") -> dict:
response_text_lines = response_text.split('\n') response_text_lines = response_text.split('\n')
keys_yaml = ['relevant line:', 'suggestion content:', 'relevant file:', 'existing code:', 'improved code:'] keys_yaml = ['relevant line:', 'suggestion content:', 'relevant file:', 'existing code:', 'improved code:', 'label:']
keys_yaml = keys_yaml + keys_fix_yaml keys_yaml = keys_yaml + keys_fix_yaml
# first fallback - try to convert 'relevant line: ...' to relevant line: |-\n ...' # first fallback - try to convert 'relevant line: ...' to relevant line: |-\n ...'
response_text_lines_copy = response_text_lines.copy() response_text_lines_copy = response_text_lines.copy()
for i in range(0, len(response_text_lines_copy)): for i in range(0, len(response_text_lines_copy)):
@ -745,8 +748,29 @@ def try_fix_yaml(response_text: str,
except: except:
pass pass
# second fallback - try to extract only range from first ```yaml to ```` # 1.5 fallback - try to convert '|' to '|2'. Will solve cases of indent decreasing during the code
snippet_pattern = r'```(yaml)?[\s\S]*?```' response_text_copy = copy.deepcopy(response_text)
response_text_copy = response_text_copy.replace('|\n', '|2\n')
try:
data = yaml.safe_load(response_text_copy)
get_logger().info(f"Successfully parsed AI prediction after replacing | with |2")
return data
except:
# if it fails, we can try to add spaces to the lines that are not indented properly, and contain '}'.
response_text_lines_copy = response_text_copy.split('\n')
for i in range(0, len(response_text_lines_copy)):
initial_space = len(response_text_lines_copy[i]) - len(response_text_lines_copy[i].lstrip())
if initial_space == 2 and '|2' not in response_text_lines_copy[i] and '}' in response_text_lines_copy[i]:
response_text_lines_copy[i] = ' ' + response_text_lines_copy[i].lstrip()
try:
data = yaml.safe_load('\n'.join(response_text_lines_copy))
get_logger().info(f"Successfully parsed AI prediction after replacing | with |2 and adding spaces")
return data
except:
pass
# second fallback - try to extract only range from first ```yaml to the last ```
snippet_pattern = r'```yaml([\s\S]*?)```(?=\s*$|")'
snippet = re.search(snippet_pattern, '\n'.join(response_text_lines_copy)) snippet = re.search(snippet_pattern, '\n'.join(response_text_lines_copy))
if not snippet: if not snippet:
snippet = re.search(snippet_pattern, response_text_original) # before we removed the "```" snippet = re.search(snippet_pattern, response_text_original) # before we removed the "```"
@ -801,16 +825,47 @@ def try_fix_yaml(response_text: str,
except: except:
pass pass
# sixth fallback - try to remove last lines # sixth fallback - replace tabs with spaces
for i in range(1, len(response_text_lines)): if '\t' in response_text:
response_text_lines_tmp = '\n'.join(response_text_lines[:-i]) response_text_copy = copy.deepcopy(response_text)
response_text_copy = response_text_copy.replace('\t', ' ')
try: try:
data = yaml.safe_load(response_text_lines_tmp) data = yaml.safe_load(response_text_copy)
get_logger().info(f"Successfully parsed AI prediction after removing {i} lines") get_logger().info(f"Successfully parsed AI prediction after replacing tabs with spaces")
return data return data
except: except:
pass pass
# seventh fallback - add indent for sections of code blocks
response_text_copy = copy.deepcopy(response_text)
response_text_copy_lines = response_text_copy.split('\n')
start_line = -1
for i, line in enumerate(response_text_copy_lines):
if 'existing_code:' in line or 'improved_code:' in line:
start_line = i
elif line.endswith(': |') or line.endswith(': |-') or line.endswith(': |2') or line.endswith(':'):
start_line = -1
elif start_line != -1:
response_text_copy_lines[i] = ' ' + line
response_text_copy = '\n'.join(response_text_copy_lines)
try:
data = yaml.safe_load(response_text_copy)
get_logger().info(f"Successfully parsed AI prediction after adding indent for sections of code blocks")
return data
except:
pass
# # sixth fallback - try to remove last lines
# for i in range(1, len(response_text_lines)):
# response_text_lines_tmp = '\n'.join(response_text_lines[:-i])
# try:
# data = yaml.safe_load(response_text_lines_tmp)
# get_logger().info(f"Successfully parsed AI prediction after removing {i} lines")
# return data
# except:
# pass
def set_custom_labels(variables, git_provider=None): def set_custom_labels(variables, git_provider=None):
if not get_settings().config.enable_custom_labels: if not get_settings().config.enable_custom_labels:
@ -878,6 +933,7 @@ def get_max_tokens(model):
elif settings.config.custom_model_max_tokens > 0: elif settings.config.custom_model_max_tokens > 0:
max_tokens_model = settings.config.custom_model_max_tokens max_tokens_model = settings.config.custom_model_max_tokens
else: else:
get_logger().error(f"Model {model} is not defined in MAX_TOKENS in ./pr_agent/algo/__init__.py and no custom_model_max_tokens is set")
raise Exception(f"Ensure {model} is defined in MAX_TOKENS in ./pr_agent/algo/__init__.py or set a positive value for it in config.custom_model_max_tokens") raise Exception(f"Ensure {model} is defined in MAX_TOKENS in ./pr_agent/algo/__init__.py or set a positive value for it in config.custom_model_max_tokens")
if settings.config.max_model_tokens and settings.config.max_model_tokens > 0: if settings.config.max_model_tokens and settings.config.max_model_tokens > 0:

View File

@ -86,7 +86,13 @@ def run(inargs=None, args=None):
if get_settings().litellm.get("enable_callbacks", False): if get_settings().litellm.get("enable_callbacks", False):
# There may be additional events on the event queue from the run above. If there are give them time to complete. # There may be additional events on the event queue from the run above. If there are give them time to complete.
get_logger().debug("Waiting for event queue to complete") get_logger().debug("Waiting for event queue to complete")
await asyncio.wait([task for task in asyncio.all_tasks() if task is not asyncio.current_task()]) tasks = [task for task in asyncio.all_tasks() if task is not asyncio.current_task()]
if tasks:
_, pending = await asyncio.wait(tasks, timeout=30)
if pending:
get_logger().warning(
f"{len(pending)} callback tasks({[task.get_coro() for task in pending]}) did not complete within timeout"
)
return result return result

View File

@ -18,14 +18,10 @@ ADO_APP_CLIENT_DEFAULT_ID = "499b84ac-1321-427f-aa17-267ca6975798/.default"
MAX_PR_DESCRIPTION_AZURE_LENGTH = 4000-1 MAX_PR_DESCRIPTION_AZURE_LENGTH = 4000-1
try: try:
# noinspection PyUnresolvedReferences
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
from azure.devops.connection import Connection from azure.devops.connection import Connection
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
from azure.devops.v7_1.git.models import (Comment, CommentThread, from azure.devops.released.git import (Comment, CommentThread, GitPullRequest, GitVersionDescriptor, GitClient, CommentThreadContext, CommentPosition)
GitPullRequest,
GitPullRequestIterationChanges,
GitVersionDescriptor)
# noinspection PyUnresolvedReferences # noinspection PyUnresolvedReferences
from azure.identity import DefaultAzureCredential from azure.identity import DefaultAzureCredential
from msrest.authentication import BasicAuthentication from msrest.authentication import BasicAuthentication
@ -77,40 +73,13 @@ class AzureDevopsProvider(GitProvider):
f"relevant_lines_start is {relevant_lines_start}") f"relevant_lines_start is {relevant_lines_start}")
continue continue
if relevant_lines_end > relevant_lines_start: thread_context = CommentThreadContext(
post_parameters = { file_path=relevant_file,
"body": body, right_file_start=CommentPosition(offset=1, line=relevant_lines_start),
"path": relevant_file, right_file_end=CommentPosition(offset=1, line=relevant_lines_end))
"line": relevant_lines_end, comment = Comment(content=body, comment_type=1)
"start_line": relevant_lines_start, thread = CommentThread(comments=[comment], thread_context=thread_context)
"start_side": "RIGHT",
}
else: # API is different for single line comments
post_parameters = {
"body": body,
"path": relevant_file,
"line": relevant_lines_start,
"side": "RIGHT",
}
post_parameters_list.append(post_parameters)
if not post_parameters_list:
return False
for post_parameters in post_parameters_list:
try: try:
comment = Comment(content=post_parameters["body"], comment_type=1)
thread = CommentThread(comments=[comment],
thread_context={
"filePath": post_parameters["path"],
"rightFileStart": {
"line": post_parameters["start_line"],
"offset": 1,
},
"rightFileEnd": {
"line": post_parameters["line"],
"offset": 1,
},
})
self.azure_devops_client.create_thread( self.azure_devops_client.create_thread(
comment_thread=thread, comment_thread=thread,
project=self.workspace_slug, project=self.workspace_slug,
@ -118,34 +87,36 @@ class AzureDevopsProvider(GitProvider):
pull_request_id=self.pr_num pull_request_id=self.pr_num
) )
except Exception as e: except Exception as e:
get_logger().warning(f"Azure failed to publish code suggestion, error: {e}") get_logger().error(f"Azure failed to publish code suggestion, error: {e}", suggestion=suggestion)
return True return True
def reply_to_comment_from_comment_id(self, comment_id: int, body: str, is_temporary: bool = False) -> Comment:
# comment_id is actually thread_id
return self.reply_to_thread(comment_id, body, is_temporary)
def get_pr_description_full(self) -> str: def get_pr_description_full(self) -> str:
return self.pr.description return self.pr.description
def edit_comment(self, comment, body: str): def edit_comment(self, comment: Comment, body: str):
try: try:
self.azure_devops_client.update_comment( self.azure_devops_client.update_comment(
repository_id=self.repo_slug, repository_id=self.repo_slug,
pull_request_id=self.pr_num, pull_request_id=self.pr_num,
thread_id=comment["thread_id"], thread_id=comment.thread_id,
comment_id=comment["comment_id"], comment_id=comment.id,
comment=Comment(content=body), comment=Comment(content=body),
project=self.workspace_slug, project=self.workspace_slug,
) )
except Exception as e: except Exception as e:
get_logger().exception(f"Failed to edit comment, error: {e}") get_logger().exception(f"Failed to edit comment, error: {e}")
def remove_comment(self, comment): def remove_comment(self, comment: Comment):
try: try:
self.azure_devops_client.delete_comment( self.azure_devops_client.delete_comment(
repository_id=self.repo_slug, repository_id=self.repo_slug,
pull_request_id=self.pr_num, pull_request_id=self.pr_num,
thread_id=comment["thread_id"], thread_id=comment.thread_id,
comment_id=comment["comment_id"], comment_id=comment.id,
project=self.workspace_slug, project=self.workspace_slug,
) )
except Exception as e: except Exception as e:
@ -176,10 +147,6 @@ class AzureDevopsProvider(GitProvider):
return [] return []
def is_supported(self, capability: str) -> bool: def is_supported(self, capability: str) -> bool:
if capability in [
"get_issue_comments",
]:
return False
return True return True
def set_pr(self, pr_url: str): def set_pr(self, pr_url: str):
@ -378,22 +345,30 @@ class AzureDevopsProvider(GitProvider):
get_logger().exception(f"Failed to get diff files, error: {e}") get_logger().exception(f"Failed to get diff files, error: {e}")
return [] return []
def publish_comment(self, pr_comment: str, is_temporary: bool = False, thread_context=None): def publish_comment(self, pr_comment: str, is_temporary: bool = False, thread_context=None) -> Comment:
if is_temporary and not get_settings().config.publish_output_progress: if is_temporary and not get_settings().config.publish_output_progress:
get_logger().debug(f"Skipping publish_comment for temporary comment: {pr_comment}") get_logger().debug(f"Skipping publish_comment for temporary comment: {pr_comment}")
return None return None
comment = Comment(content=pr_comment) comment = Comment(content=pr_comment)
thread = CommentThread(comments=[comment], thread_context=thread_context, status=1) thread = CommentThread(comments=[comment], thread_context=thread_context, status="closed")
thread_response = self.azure_devops_client.create_thread( thread_response = self.azure_devops_client.create_thread(
comment_thread=thread, comment_thread=thread,
project=self.workspace_slug, project=self.workspace_slug,
repository_id=self.repo_slug, repository_id=self.repo_slug,
pull_request_id=self.pr_num, pull_request_id=self.pr_num,
) )
response = {"thread_id": thread_response.id, "comment_id": thread_response.comments[0].id} created_comment = thread_response.comments[0]
created_comment.thread_id = thread_response.id
if is_temporary: if is_temporary:
self.temp_comments.append(response) self.temp_comments.append(created_comment)
return response return created_comment
def publish_persistent_comment(self, pr_comment: str,
initial_header: str,
update_header: bool = True,
name='review',
final_update_message=True):
return self.publish_persistent_comment_full(pr_comment, initial_header, update_header, name, final_update_message)
def publish_description(self, pr_title: str, pr_body: str): def publish_description(self, pr_title: str, pr_body: str):
if len(pr_body) > MAX_PR_DESCRIPTION_AZURE_LENGTH: if len(pr_body) > MAX_PR_DESCRIPTION_AZURE_LENGTH:
@ -438,7 +413,6 @@ class AzureDevopsProvider(GitProvider):
def publish_inline_comment(self, body: str, relevant_file: str, relevant_line_in_file: str, original_suggestion=None): def publish_inline_comment(self, body: str, relevant_file: str, relevant_line_in_file: str, original_suggestion=None):
self.publish_inline_comments([self.create_inline_comment(body, relevant_file, relevant_line_in_file)]) self.publish_inline_comments([self.create_inline_comment(body, relevant_file, relevant_line_in_file)])
def create_inline_comment(self, body: str, relevant_file: str, relevant_line_in_file: str, def create_inline_comment(self, body: str, relevant_file: str, relevant_line_in_file: str,
absolute_position: int = None): absolute_position: int = None):
position, absolute_position = find_line_number_of_relevant_line_in_file(self.get_diff_files(), position, absolute_position = find_line_number_of_relevant_line_in_file(self.get_diff_files(),
@ -522,7 +496,7 @@ class AzureDevopsProvider(GitProvider):
def get_user_id(self): def get_user_id(self):
return 0 return 0
def get_issue_comments(self): def get_issue_comments(self) -> list[Comment]:
threads = self.azure_devops_client.get_threads(repository_id=self.repo_slug, pull_request_id=self.pr_num, project=self.workspace_slug) threads = self.azure_devops_client.get_threads(repository_id=self.repo_slug, pull_request_id=self.pr_num, project=self.workspace_slug)
threads.reverse() threads.reverse()
comment_list = [] comment_list = []
@ -540,30 +514,59 @@ class AzureDevopsProvider(GitProvider):
def remove_reaction(self, issue_comment_id: int, reaction_id: int) -> bool: def remove_reaction(self, issue_comment_id: int, reaction_id: int) -> bool:
return True return True
def set_like(self, thread_id: int, comment_id: int, create: bool = True):
if create:
self.azure_devops_client.create_like(self.repo_slug, self.pr_num, thread_id, comment_id, project=self.workspace_slug)
else:
self.azure_devops_client.delete_like(self.repo_slug, self.pr_num, thread_id, comment_id, project=self.workspace_slug)
def set_thread_status(self, thread_id: int, status: str):
try:
self.azure_devops_client.update_thread(CommentThread(status=status), self.repo_slug, self.pr_num, thread_id, self.workspace_slug)
except Exception as e:
get_logger().exception(f"Failed to set thread status, error: {e}")
def reply_to_thread(self, thread_id: int, body: str, is_temporary: bool = False) -> Comment:
try:
comment = Comment(content=body)
response = self.azure_devops_client.create_comment(comment, self.repo_slug, self.pr_num, thread_id, self.workspace_slug)
response.thread_id = thread_id
if is_temporary:
self.temp_comments.append(response)
return response
except Exception as e:
get_logger().exception(f"Failed to reply to thread, error: {e}")
def get_thread_context(self, thread_id: int) -> CommentThreadContext:
try:
thread = self.azure_devops_client.get_pull_request_thread(self.repo_slug, self.pr_num, thread_id, self.workspace_slug)
return thread.thread_context
except Exception as e:
get_logger().exception(f"Failed to set thread status, error: {e}")
@staticmethod @staticmethod
def _parse_pr_url(pr_url: str) -> Tuple[str, str, int]: def _parse_pr_url(pr_url: str) -> Tuple[str, str, int]:
parsed_url = urlparse(pr_url) parsed_url = urlparse(pr_url)
path_parts = parsed_url.path.strip("/").split("/") path_parts = parsed_url.path.strip("/").split("/")
if "pullrequest" not in path_parts: num_parts = len(path_parts)
raise ValueError( if num_parts < 5:
"The provided URL does not appear to be a Azure DevOps PR URL" raise ValueError("The provided URL has insufficient path components for an Azure DevOps PR URL")
)
if len(path_parts) == 6: # "https://dev.azure.com/organization/project/_git/repo/pullrequest/1" # Verify that the second-to-last path component is "pullrequest"
workspace_slug = path_parts[1] if path_parts[num_parts - 2] != "pullrequest":
repo_slug = path_parts[3] raise ValueError("The provided URL does not follow the expected Azure DevOps PR URL format")
pr_number = int(path_parts[5])
elif len(path_parts) == 5: # 'https://organization.visualstudio.com/project/_git/repo/pullrequest/1' workspace_slug = path_parts[num_parts - 5]
workspace_slug = path_parts[0] repo_slug = path_parts[num_parts - 3]
repo_slug = path_parts[2] try:
pr_number = int(path_parts[4]) pr_number = int(path_parts[num_parts - 1])
else: except ValueError as e:
raise ValueError("The provided URL does not appear to be a Azure DevOps PR URL") raise ValueError("Cannot parse PR number in the provided URL") from e
return workspace_slug, repo_slug, pr_number return workspace_slug, repo_slug, pr_number
@staticmethod @staticmethod
def _get_azure_devops_client(): def _get_azure_devops_client() -> GitClient:
org = get_settings().azure_devops.get("org", None) org = get_settings().azure_devops.get("org", None)
pat = get_settings().azure_devops.get("pat", None) pat = get_settings().azure_devops.get("pat", None)
@ -623,3 +626,13 @@ class AzureDevopsProvider(GitProvider):
def get_line_link(self, relevant_file: str, relevant_line_start: int, relevant_line_end: int = None) -> str: def get_line_link(self, relevant_file: str, relevant_line_start: int, relevant_line_end: int = None) -> str:
return self.pr_url+f"?_a=files&path={relevant_file}" return self.pr_url+f"?_a=files&path={relevant_file}"
def get_comment_url(self, comment) -> str:
return self.pr_url + "?discussionId=" + str(comment.thread_id)
def get_latest_commit_url(self) -> str:
commits = self.azure_devops_client.get_pull_request_commits(self.repo_slug, self.pr_num, self.workspace_slug)
last = commits[0]
url = self.azure_devops_client.normalized_url + "/" + self.workspace_slug + "/_git/" + self.repo_slug + "/commit/" + last.commit_id
return url

View File

@ -133,7 +133,7 @@ class GitProvider(ABC):
def reply_to_comment_from_comment_id(self, comment_id: int, body: str): def reply_to_comment_from_comment_id(self, comment_id: int, body: str):
pass pass
def get_pr_description(self, full: bool = True, split_changes_walkthrough=False) -> str or tuple: def get_pr_description(self, full: bool = True, split_changes_walkthrough=False) -> str | tuple:
from pr_agent.algo.utils import clip_tokens from pr_agent.algo.utils import clip_tokens
from pr_agent.config_loader import get_settings from pr_agent.config_loader import get_settings
max_tokens_description = get_settings().get("CONFIG.MAX_DESCRIPTION_TOKENS", None) max_tokens_description = get_settings().get("CONFIG.MAX_DESCRIPTION_TOKENS", None)
@ -228,7 +228,7 @@ class GitProvider(ABC):
update_header: bool = True, update_header: bool = True,
name='review', name='review',
final_update_message=True): final_update_message=True):
self.publish_comment(pr_comment) return self.publish_comment(pr_comment)
def publish_persistent_comment_full(self, pr_comment: str, def publish_persistent_comment_full(self, pr_comment: str,
initial_header: str, initial_header: str,
@ -250,14 +250,13 @@ class GitProvider(ABC):
# response = self.mr.notes.update(comment.id, {'body': pr_comment_updated}) # response = self.mr.notes.update(comment.id, {'body': pr_comment_updated})
self.edit_comment(comment, pr_comment_updated) self.edit_comment(comment, pr_comment_updated)
if final_update_message: if final_update_message:
self.publish_comment( return self.publish_comment(
f"**[Persistent {name}]({comment_url})** updated to latest commit {latest_commit_url}") f"**[Persistent {name}]({comment_url})** updated to latest commit {latest_commit_url}")
return return comment
except Exception as e: except Exception as e:
get_logger().exception(f"Failed to update persistent review, error: {e}") get_logger().exception(f"Failed to update persistent review, error: {e}")
pass pass
self.publish_comment(pr_comment) return self.publish_comment(pr_comment)
@abstractmethod @abstractmethod
def publish_inline_comment(self, body: str, relevant_file: str, relevant_line_in_file: str, original_suggestion=None): def publish_inline_comment(self, body: str, relevant_file: str, relevant_line_in_file: str, original_suggestion=None):
@ -286,6 +285,9 @@ class GitProvider(ABC):
def get_comment_url(self, comment) -> str: def get_comment_url(self, comment) -> str:
return "" return ""
def get_review_thread_comments(self, comment_id: int) -> list[dict]:
pass
#### labels operations #### #### labels operations ####
@abstractmethod @abstractmethod
def publish_labels(self, labels): def publish_labels(self, labels):

View File

@ -427,7 +427,41 @@ class GithubProvider(GitProvider):
self._publish_inline_comments_fallback_with_verification(comments) self._publish_inline_comments_fallback_with_verification(comments)
except Exception as e: except Exception as e:
get_logger().error(f"Failed to publish inline code comments fallback, error: {e}") get_logger().error(f"Failed to publish inline code comments fallback, error: {e}")
raise e raise e
def get_review_thread_comments(self, comment_id: int) -> list[dict]:
"""
Retrieves all comments in the same thread as the given comment.
Args:
comment_id: Review comment ID
Returns:
List of comments in the same thread
"""
try:
# Fetch all comments with a single API call
all_comments = list(self.pr.get_comments())
# Find the target comment by ID
target_comment = next((c for c in all_comments if c.id == comment_id), None)
if not target_comment:
return []
# Get root comment id
root_comment_id = target_comment.raw_data.get("in_reply_to_id", target_comment.id)
# Build the thread - include the root comment and all replies to it
thread_comments = [
c for c in all_comments if
c.id == root_comment_id or c.raw_data.get("in_reply_to_id") == root_comment_id
]
return thread_comments
except Exception as e:
get_logger().exception(f"Failed to get review comments for an inline ask command", artifact={"comment_id": comment_id, "error": e})
return []
def _publish_inline_comments_fallback_with_verification(self, comments: list[dict]): def _publish_inline_comments_fallback_with_verification(self, comments: list[dict]):
""" """

View File

@ -6,8 +6,7 @@ from dynaconf import Dynaconf
from starlette_context import context from starlette_context import context
from pr_agent.config_loader import get_settings from pr_agent.config_loader import get_settings
from pr_agent.git_providers import (get_git_provider, from pr_agent.git_providers import get_git_provider_with_context
get_git_provider_with_context)
from pr_agent.log import get_logger from pr_agent.log import get_logger

View File

@ -10,7 +10,7 @@ class Eligibility(Enum):
class IdentityProvider(ABC): class IdentityProvider(ABC):
@abstractmethod @abstractmethod
def verify_eligibility(self, git_provider, git_provier_id, pr_url): def verify_eligibility(self, git_provider, git_provider_id, pr_url):
pass pass
@abstractmethod @abstractmethod

View File

@ -22,40 +22,73 @@ from starlette_context.middleware import RawContextMiddleware
from pr_agent.agent.pr_agent import PRAgent, command2class from pr_agent.agent.pr_agent import PRAgent, command2class
from pr_agent.algo.utils import update_settings_from_args from pr_agent.algo.utils import update_settings_from_args
from pr_agent.config_loader import get_settings from pr_agent.config_loader import get_settings
from pr_agent.git_providers import get_git_provider_with_context
from pr_agent.git_providers.azuredevops_provider import AzureDevopsProvider
from pr_agent.git_providers.utils import apply_repo_settings from pr_agent.git_providers.utils import apply_repo_settings
from pr_agent.log import LoggingFormat, get_logger, setup_logger from pr_agent.log import LoggingFormat, get_logger, setup_logger
setup_logger(fmt=LoggingFormat.JSON, level=get_settings().get("CONFIG.LOG_LEVEL", "DEBUG")) setup_logger(fmt=LoggingFormat.JSON, level=get_settings().get("CONFIG.LOG_LEVEL", "DEBUG"))
security = HTTPBasic() security = HTTPBasic(auto_error=False)
router = APIRouter() router = APIRouter()
available_commands_rgx = re.compile(r"^\/(" + "|".join(command2class.keys()) + r")\s*") available_commands_rgx = re.compile(r"^\/(" + "|".join(command2class.keys()) + r")\s*")
azure_devops_server = get_settings().get("azure_devops_server") azure_devops_server = get_settings().get("azure_devops_server")
WEBHOOK_USERNAME = azure_devops_server.get("webhook_username") WEBHOOK_USERNAME = azure_devops_server.get("webhook_username", None)
WEBHOOK_PASSWORD = azure_devops_server.get("webhook_password") WEBHOOK_PASSWORD = azure_devops_server.get("webhook_password", None)
async def handle_request_comment( url: str, body: str, log_context: dict async def handle_request_comment(url: str, body: str, thread_id: int, comment_id: int, log_context: dict):
):
log_context["action"] = body log_context["action"] = body
log_context["api_url"] = url log_context["api_url"] = url
try: try:
with get_logger().contextualize(**log_context): with get_logger().contextualize(**log_context):
await PRAgent().handle_request(url, body) agent = PRAgent()
provider = get_git_provider_with_context(pr_url=url)
body = handle_line_comment(body, thread_id, provider)
handled = await agent.handle_request(url, body, notify=lambda: provider.reply_to_thread(thread_id, "On it! ⏳", True))
# mark command comment as closed
if handled:
provider.set_thread_status(thread_id, "closed")
provider.remove_initial_comment()
except Exception as e: except Exception as e:
get_logger().exception(f"Failed to handle webhook", artifact={"url": url, "body": body}, error=str(e)) get_logger().exception(f"Failed to handle webhook", artifact={"url": url, "body": body}, error=str(e))
def handle_line_comment(body: str, thread_id: int, provider: AzureDevopsProvider):
body = body.strip()
if not body.startswith('/ask '):
return body
thread_context = provider.get_thread_context(thread_id)
if not thread_context:
return body
path = thread_context.file_path
if thread_context.left_file_end or thread_context.left_file_start:
start_line = thread_context.left_file_start.line
end_line = thread_context.left_file_end.line
side = "left"
elif thread_context.right_file_end or thread_context.right_file_start:
start_line = thread_context.right_file_start.line
end_line = thread_context.right_file_end.line
side = "right"
else:
get_logger().info("No line range found in thread context", artifact={"thread_context": thread_context})
return body
question = body[5:].lstrip() # remove 4 chars: '/ask '
return f"/ask_line --line_start={start_line} --line_end={end_line} --side={side} --file_name={path} --comment_id={thread_id} {question}"
# currently only basic auth is supported with azure webhooks # currently only basic auth is supported with azure webhooks
# for this reason, https must be enabled to ensure the credentials are not sent in clear text # for this reason, https must be enabled to ensure the credentials are not sent in clear text
def authorize(credentials: HTTPBasicCredentials = Depends(security)): def authorize(credentials: HTTPBasicCredentials = Depends(security)):
is_user_ok = secrets.compare_digest(credentials.username, WEBHOOK_USERNAME) if WEBHOOK_USERNAME is None or WEBHOOK_PASSWORD is None:
is_pass_ok = secrets.compare_digest(credentials.password, WEBHOOK_PASSWORD) return
if not (is_user_ok and is_pass_ok):
raise HTTPException( is_user_ok = secrets.compare_digest(credentials.username, WEBHOOK_USERNAME)
status_code=status.HTTP_401_UNAUTHORIZED, is_pass_ok = secrets.compare_digest(credentials.password, WEBHOOK_PASSWORD)
detail='Incorrect username or password.', if not (is_user_ok and is_pass_ok):
headers={'WWW-Authenticate': 'Basic'}, raise HTTPException(
) status_code=status.HTTP_401_UNAUTHORIZED,
detail='Incorrect username or password.',
headers={'WWW-Authenticate': 'Basic'},
)
async def _perform_commands_azure(commands_conf: str, agent: PRAgent, api_url: str, log_context: dict): async def _perform_commands_azure(commands_conf: str, agent: PRAgent, api_url: str, log_context: dict):
@ -83,7 +116,6 @@ async def _perform_commands_azure(commands_conf: str, agent: PRAgent, api_url: s
async def handle_request_azure(data, log_context): async def handle_request_azure(data, log_context):
actions = []
if data["eventType"] == "git.pullrequest.created": if data["eventType"] == "git.pullrequest.created":
# API V1 (latest) # API V1 (latest)
pr_url = unquote(data["resource"]["_links"]["web"]["href"].replace("_apis/git/repositories", "_git")) pr_url = unquote(data["resource"]["_links"]["web"]["href"].replace("_apis/git/repositories", "_git"))
@ -95,11 +127,16 @@ async def handle_request_azure(data, log_context):
content=jsonable_encoder({"message": "webhook triggered successfully"}) content=jsonable_encoder({"message": "webhook triggered successfully"})
) )
elif data["eventType"] == "ms.vss-code.git-pullrequest-comment-event" and "content" in data["resource"]["comment"]: elif data["eventType"] == "ms.vss-code.git-pullrequest-comment-event" and "content" in data["resource"]["comment"]:
if available_commands_rgx.match(data["resource"]["comment"]["content"]): comment = data["resource"]["comment"]
if available_commands_rgx.match(comment["content"]):
if(data["resourceVersion"] == "2.0"): if(data["resourceVersion"] == "2.0"):
repo = data["resource"]["pullRequest"]["repository"]["webUrl"] repo = data["resource"]["pullRequest"]["repository"]["webUrl"]
pr_url = unquote(f'{repo}/pullrequest/{data["resource"]["pullRequest"]["pullRequestId"]}') pr_url = unquote(f'{repo}/pullrequest/{data["resource"]["pullRequest"]["pullRequestId"]}')
actions = [data["resource"]["comment"]["content"]] action = comment["content"]
thread_url = comment["_links"]["threads"]["href"]
thread_id = int(thread_url.split("/")[-1])
comment_id = int(comment["id"])
pass
else: else:
# API V1 not supported as it does not contain the PR URL # API V1 not supported as it does not contain the PR URL
return JSONResponse( return JSONResponse(
@ -119,15 +156,14 @@ async def handle_request_azure(data, log_context):
log_context["event"] = data["eventType"] log_context["event"] = data["eventType"]
log_context["api_url"] = pr_url log_context["api_url"] = pr_url
for action in actions: try:
try: await handle_request_comment(pr_url, action, thread_id, comment_id, log_context)
await handle_request_comment(pr_url, action, log_context) except Exception as e:
except Exception as e: get_logger().error("Azure DevOps Trigger failed. Error:" + str(e))
get_logger().error("Azure DevOps Trigger failed. Error:" + str(e)) return JSONResponse(
return JSONResponse( status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content=json.dumps({"message": "Internal server error"}),
content=json.dumps({"message": "Internal server error"}), )
)
return JSONResponse( return JSONResponse(
status_code=status.HTTP_202_ACCEPTED, content=jsonable_encoder({"message": "webhook triggered successfully"}) status_code=status.HTTP_202_ACCEPTED, content=jsonable_encoder({"message": "webhook triggered successfully"})
) )

View File

@ -127,6 +127,14 @@ def should_process_pr_logic(data) -> bool:
source_branch = pr_data.get("source", {}).get("branch", {}).get("name", "") source_branch = pr_data.get("source", {}).get("branch", {}).get("name", "")
target_branch = pr_data.get("destination", {}).get("branch", {}).get("name", "") target_branch = pr_data.get("destination", {}).get("branch", {}).get("name", "")
sender = _get_username(data) sender = _get_username(data)
repo_full_name = pr_data.get("destination", {}).get("repository", {}).get("full_name", "")
# logic to ignore PRs from specific repositories
ignore_repos = get_settings().get("CONFIG.IGNORE_REPOSITORIES", [])
if repo_full_name and ignore_repos:
if any(re.search(regex, repo_full_name) for regex in ignore_repos):
get_logger().info(f"Ignoring PR from repository '{repo_full_name}' due to 'config.ignore_repositories' setting")
return False
# logic to ignore PRs from specific users # logic to ignore PRs from specific users
ignore_pr_users = get_settings().get("CONFIG.IGNORE_PR_AUTHORS", []) ignore_pr_users = get_settings().get("CONFIG.IGNORE_PR_AUTHORS", [])

View File

@ -258,6 +258,14 @@ def should_process_pr_logic(body) -> bool:
source_branch = pull_request.get("head", {}).get("ref", "") source_branch = pull_request.get("head", {}).get("ref", "")
target_branch = pull_request.get("base", {}).get("ref", "") target_branch = pull_request.get("base", {}).get("ref", "")
sender = body.get("sender", {}).get("login") sender = body.get("sender", {}).get("login")
repo_full_name = body.get("repository", {}).get("full_name", "")
# logic to ignore PRs from specific repositories
ignore_repos = get_settings().get("CONFIG.IGNORE_REPOSITORIES", [])
if ignore_repos and repo_full_name:
if any(re.search(regex, repo_full_name) for regex in ignore_repos):
get_logger().info(f"Ignoring PR from repository '{repo_full_name}' due to 'config.ignore_repositories' setting")
return False
# logic to ignore PRs from specific users # logic to ignore PRs from specific users
ignore_pr_users = get_settings().get("CONFIG.IGNORE_PR_AUTHORS", []) ignore_pr_users = get_settings().get("CONFIG.IGNORE_PR_AUTHORS", [])

View File

@ -86,9 +86,19 @@ def is_draft(data) -> bool:
def is_draft_ready(data) -> bool: def is_draft_ready(data) -> bool:
try: try:
if 'draft' in data.get('changes', {}): if 'draft' in data.get('changes', {}):
if data['changes']['draft']['previous'] == 'true' and data['changes']['draft']['current'] == 'false': # Handle both boolean values and string values for compatibility
previous = data['changes']['draft']['previous']
current = data['changes']['draft']['current']
# Convert to boolean if they're strings
if isinstance(previous, str):
previous = previous.lower() == 'true'
if isinstance(current, str):
current = current.lower() == 'true'
if previous is True and current is False:
return True return True
# for gitlab server version before 16 # for gitlab server version before 16
elif 'title' in data.get('changes', {}): elif 'title' in data.get('changes', {}):
if 'Draft:' in data['changes']['title']['previous'] and 'Draft:' not in data['changes']['title']['current']: if 'Draft:' in data['changes']['title']['previous'] and 'Draft:' not in data['changes']['title']['current']:
@ -103,6 +113,14 @@ def should_process_pr_logic(data) -> bool:
return False return False
title = data['object_attributes'].get('title') title = data['object_attributes'].get('title')
sender = data.get("user", {}).get("username", "") sender = data.get("user", {}).get("username", "")
repo_full_name = data.get('project', {}).get('path_with_namespace', "")
# logic to ignore PRs from specific repositories
ignore_repos = get_settings().get("CONFIG.IGNORE_REPOSITORIES", [])
if ignore_repos and repo_full_name:
if any(re.search(regex, repo_full_name) for regex in ignore_repos):
get_logger().info(f"Ignoring MR from repository '{repo_full_name}' due to 'config.ignore_repositories' setting")
return False
# logic to ignore PRs from specific users # logic to ignore PRs from specific users
ignore_pr_users = get_settings().get("CONFIG.IGNORE_PR_AUTHORS", []) ignore_pr_users = get_settings().get("CONFIG.IGNORE_PR_AUTHORS", [])

View File

@ -107,4 +107,8 @@ key = ""
client_id = "" # Your Azure AD application client ID client_id = "" # Your Azure AD application client ID
client_secret = "" # Your Azure AD application client secret client_secret = "" # Your Azure AD application client secret
tenant_id = "" # Your Azure AD tenant ID tenant_id = "" # Your Azure AD tenant ID
api_base = "" # Your Azure OpenAI service base URL (e.g., https://openai.xyz.com/) api_base = "" # Your Azure OpenAI service base URL (e.g., https://openai.xyz.com/)
[openrouter]
key = ""
api_base = ""

View File

@ -55,11 +55,11 @@ Specific guidelines for generating code suggestions:
- DO NOT suggest the following: - DO NOT suggest the following:
- change packages version - change packages version
- add missing import statement - add missing import statement
- declare undefined variable - declare undefined variable, add missing imports, etc.
- use more specific exception types - use more specific exception types
{%- endif %} {%- endif %}
- When mentioning code elements (variables, names, or files) in your response, surround them with backticks (`). For example: "verify that `user_id` is..." - When mentioning code elements (variables, names, or files) in your response, surround them with markdown backticks (`). For example: "verify that `user_id` is..."
- Note that you will only see partial code segments that were changed (diff hunks in a PR), and not the entire codebase. Avoid suggestions that might duplicate existing functionality or question the existence of code elements like variables, functions, classes, and import statements, that may be defined elsewhere in the codebase. - Note that you will only see partial code segments that were changed (diff hunks in a PR code), and not the entire codebase. Avoid suggestions that might duplicate existing functionality of the outer codebase. In addition, the absence of a definition, declaration, import, or initialization for any entity in the PR code is NEVER a basis for a suggestion.
- Also note that if the code ends at an opening brace or statement that begins a new scope (like 'if', 'for', 'try'), don't treat it as incomplete. Instead, acknowledge the visible scope boundary and analyze only the code shown. - Also note that if the code ends at an opening brace or statement that begins a new scope (like 'if', 'for', 'try'), don't treat it as incomplete. Instead, acknowledge the visible scope boundary and analyze only the code shown.
{%- if extra_instructions %} {%- if extra_instructions %}
@ -77,10 +77,10 @@ The output must be a YAML object equivalent to type $PRCodeSuggestions, accordin
class CodeSuggestion(BaseModel): class CodeSuggestion(BaseModel):
relevant_file: str = Field(description="Full path of the relevant file") relevant_file: str = Field(description="Full path of the relevant file")
language: str = Field(description="Programming language used by the relevant file") language: str = Field(description="Programming language used by the relevant file")
existing_code: str = Field(description="A short code snippet from the final state of the PR diff that the suggestion will address. Select only the span of code that will be modified - without surrounding unchanged code. Preserve all indentation, newlines, and original formatting. Use ellipsis (...) for brevity if needed.") existing_code: str = Field(description="A short code snippet, from the final state of the PR diff, that the suggestion will address. Select only the specific span of code that will be modified - without surrounding unchanged code. Preserve all indentation, newlines, and original formatting. Show the code snippet without the '+'/'-'/' ' prefixes. When providing suggestions for long code sections, shorten the presented code with ellipsis (...) for brevity where possible.")
suggestion_content: str = Field(description="An actionable suggestion to enhance, improve or fix the new code introduced in the PR. Don't present here actual code snippets, just the suggestion. Be short and concise") suggestion_content: str = Field(description="An actionable suggestion to enhance, improve or fix the new code introduced in the PR. Use 2-3 short sentences.")
improved_code: str = Field(description="A refined code snippet that replaces the 'existing_code' snippet after implementing the suggestion.") improved_code: str = Field(description="A refined code snippet that replaces the 'existing_code' snippet after implementing the suggestion.")
one_sentence_summary: str = Field(description="A concise, single-sentence overview (up to 6 words) of the suggested improvement. Focus on the 'what'. Be general, and avoid method or variable names.") one_sentence_summary: str = Field(description="A single-sentence overview (up to 6 words) of the suggestion. Focus on the 'what'. Be general, and avoid mentioning method or variable names.")
{%- if not focus_only_on_problems %} {%- if not focus_only_on_problems %}
label: str = Field(description="A single, descriptive label that best characterizes the suggestion type. Possible labels include 'security', 'possible bug', 'possible issue', 'performance', 'enhancement', 'best practice', 'maintainability', 'typo'. Other relevant labels are also acceptable.") label: str = Field(description="A single, descriptive label that best characterizes the suggestion type. Possible labels include 'security', 'possible bug', 'possible issue', 'performance', 'enhancement', 'best practice', 'maintainability', 'typo'. Other relevant labels are also acceptable.")
{%- else %} {%- else %}

View File

@ -1,26 +1,25 @@
[pr_code_suggestions_reflect_prompt] [pr_code_suggestions_reflect_prompt]
system="""You are an AI language model specialized in reviewing and evaluating code suggestions for a Pull Request (PR). system="""You are an AI language model specialized in reviewing and evaluating code suggestions for a Pull Request (PR).
Your task is to analyze a PR code diff and evaluate a set of AI-generated code suggestions. These suggestions aim to address potential bugs and problems, and enhance the new code introduced in the PR. Your task is to analyze a PR code diff and evaluate the correctness and importance set of AI-generated code suggestions.
In addition to evaluating the suggestion correctness and importance, another sub-task you have is to detect the line numbers in the '__new hunk__' of the PR code diff section that correspond to the 'existing_code' snippet.
Examine each suggestion meticulously, assessing its quality, relevance, and accuracy within the context of PR. Keep in mind that the suggestions may vary in their correctness, accuracy and impact. Examine each suggestion meticulously, assessing its quality, relevance, and accuracy within the context of PR. Keep in mind that the suggestions may vary in their correctness, accuracy and impact.
Consider the following components of each suggestion: Consider the following components of each suggestion:
1. 'one_sentence_summary' - A brief summary of the suggestion's purpose 1. 'one_sentence_summary' - A one-liner summary summary of the suggestion's purpose
2. 'suggestion_content' - The detailed suggestion content, explaining the proposed modification 2. 'suggestion_content' - The suggestion content, explaining the proposed modification
3. 'existing_code' - a code snippet from a __new hunk__ section in the PR code diff that the suggestion addresses 3. 'existing_code' - a code snippet from a __new hunk__ section in the PR code diff that the suggestion addresses
4. 'improved_code' - a code snippet demonstrating how the 'existing_code' should be after the suggestion is applied 4. 'improved_code' - a code snippet demonstrating how the 'existing_code' should be after the suggestion is applied
Be particularly vigilant for suggestions that: Be particularly vigilant for suggestions that:
- Overlook crucial details in the PR - Overlook crucial details in the PR code
- The 'improved_code' section does not accurately reflect the suggested changes, in relation to the 'existing_code' - The 'improved_code' section does not accurately reflect the suggested changes, in relation to the 'existing_code'
- Contradict or ignore parts of the PR's modifications - Contradict or ignore parts of the PR's modifications
In such cases, assign the suggestion a score of 0. In such cases, assign the suggestion a score of 0.
Evaluate each valid suggestion by scoring its potential impact on the PR's correctness, quality and functionality. Evaluate each valid suggestion by scoring its potential impact on the PR's correctness, quality and functionality.
In addition, you should also detect the line numbers in the '__new hunk__' section that correspond to the 'existing_code' snippet.
Key guidelines for evaluation: Key guidelines for evaluation:
- Thoroughly examine both the suggestion content and the corresponding PR code diff. Be vigilant for potential errors in each suggestion, ensuring they are logically sound, accurate, and directly derived from the PR code diff. - Thoroughly examine both the suggestion content and the corresponding PR code diff. Be vigilant for potential errors in each suggestion, ensuring they are logically sound, accurate, and directly derived from the PR code diff.
- Extend your review beyond the specifically mentioned code lines to encompass surrounding context, verifying the suggestions' contextual accuracy. - Extend your review beyond the specifically mentioned code lines to encompass surrounding PR code context, verifying the suggestions' contextual accuracy.
- Validate the 'existing_code' field by confirming it matches or is accurately derived from code lines within a '__new hunk__' section of the PR code diff. - Validate the 'existing_code' field by confirming it matches or is accurately derived from code lines within a '__new hunk__' section of the PR code diff.
- Ensure the 'improved_code' section accurately reflects the 'existing_code' segment after the suggested modification is applied. - Ensure the 'improved_code' section accurately reflects the 'existing_code' segment after the suggested modification is applied.
- Apply a nuanced scoring system: - Apply a nuanced scoring system:
@ -30,13 +29,16 @@ Key guidelines for evaluation:
- Maintain the original order of suggestions in your feedback, corresponding to their input sequence. - Maintain the original order of suggestions in your feedback, corresponding to their input sequence.
Additional scoring considerations: Additional scoring considerations:
- If the suggestion is not actionable, and only asks the user to verify or ensure a change, reduce its score by 1-2 points. - If the suggestion only asks the user to verify or ensure a change done in the PR, it should not receive a score above 7 (and may be lower).
- Error handling or type checking suggestions should not receive a score above 8 (and may be lower). - Error handling or type checking suggestions should not receive a score above 8 (and may be lower).
- If the 'existing_code' snippet is equal to the 'improved_code' snippet, it should not receive a score above 7 (and may be lower).
- Assume each suggestion is independent and is not influenced by the other suggestions.
- Assign a score of 0 to suggestions aiming at: - Assign a score of 0 to suggestions aiming at:
- Adding docstring, type hints, or comments - Adding docstring, type hints, or comments
- Remove unused imports or variables - Remove unused imports or variables
- Add missing import statements - Add missing import statements
- Using more specific exception types. - Using more specific exception types.
- Questions the definition, declaration, import, or initialization of any entity in the PR code, that might be done in the outer codebase.
@ -87,7 +89,7 @@ class CodeSuggestionFeedback(BaseModel):
relevant_lines_start: int = Field(description="The relevant line number, from a '__new hunk__' section, where the suggestion starts (inclusive). Should be derived from the added '__new hunk__' line numbers, and correspond to the first line of the relevant 'existing code' snippet.") relevant_lines_start: int = Field(description="The relevant line number, from a '__new hunk__' section, where the suggestion starts (inclusive). Should be derived from the added '__new hunk__' line numbers, and correspond to the first line of the relevant 'existing code' snippet.")
relevant_lines_end: int = Field(description="The relevant line number, from a '__new hunk__' section, where the suggestion ends (inclusive). Should be derived from the added '__new hunk__' line numbers, and correspond to the end of the relevant 'existing code' snippet") relevant_lines_end: int = Field(description="The relevant line number, from a '__new hunk__' section, where the suggestion ends (inclusive). Should be derived from the added '__new hunk__' line numbers, and correspond to the end of the relevant 'existing code' snippet")
suggestion_score: int = Field(description="Evaluate the suggestion and assign a score from 0 to 10. Give 0 if the suggestion is wrong. For valid suggestions, score from 1 (lowest impact/importance) to 10 (highest impact/importance).") suggestion_score: int = Field(description="Evaluate the suggestion and assign a score from 0 to 10. Give 0 if the suggestion is wrong. For valid suggestions, score from 1 (lowest impact/importance) to 10 (highest impact/importance).")
why: str = Field(description="Briefly explain the score given in 1-2 sentences, focusing on the suggestion's impact, relevance, and accuracy.") why: str = Field(description="Briefly explain the score given in 1-2 short sentences, focusing on the suggestion's impact, relevance, and accuracy. When mentioning code elements (variables, names, or files) in your response, surround them with markdown backticks (`).")
class PRCodeSuggestionsFeedback(BaseModel): class PRCodeSuggestionsFeedback(BaseModel):
code_suggestions: List[CodeSuggestionFeedback] code_suggestions: List[CodeSuggestionFeedback]
@ -118,7 +120,7 @@ user="""You are given a Pull Request (PR) code diff:
====== ======
Below are {{ num_code_suggestions }} AI-generated code suggestions for enhancing the Pull Request: Below are {{ num_code_suggestions }} AI-generated code suggestions for the Pull Request:
====== ======
{{ suggestion_str|trim }} {{ suggestion_str|trim }}
====== ======

View File

@ -6,9 +6,10 @@
[config] [config]
# models # models
model="o3-mini" model="o4-mini"
fallback_models=["gpt-4o-2024-11-20"] fallback_models=["gpt-4.1"]
#model_weak="gpt-4o-mini-2024-07-18" # optional, a weaker model to use for some easier tasks #model_reasoning="o4-mini" # dedictated reasoning model for self-reflection
#model_weak="gpt-4o" # optional, a weaker model to use for some easier tasks
# CLI # CLI
git_provider="github" git_provider="github"
publish_output=true publish_output=true
@ -35,8 +36,8 @@ model_token_count_estimate_factor=0.3 # factor to increase the token count estim
# patch extension logic # patch extension logic
patch_extension_skip_types =[".md",".txt"] patch_extension_skip_types =[".md",".txt"]
allow_dynamic_context=true allow_dynamic_context=true
max_extra_lines_before_dynamic_context = 8 # will try to include up to 10 extra lines before the hunk in the patch, until we reach an enclosing function or class max_extra_lines_before_dynamic_context = 10 # will try to include up to 10 extra lines before the hunk in the patch, until we reach an enclosing function or class
patch_extra_lines_before = 3 # Number of extra lines (+3 default ones) to include before each hunk in the patch patch_extra_lines_before = 5 # Number of extra lines (+3 default ones) to include before each hunk in the patch
patch_extra_lines_after = 1 # Number of extra lines (+3 default ones) to include after each hunk in the patch patch_extra_lines_after = 1 # Number of extra lines (+3 default ones) to include after each hunk in the patch
secret_provider="" secret_provider=""
cli_mode=false cli_mode=false
@ -54,6 +55,7 @@ ignore_pr_target_branches = [] # a list of regular expressions of target branche
ignore_pr_source_branches = [] # a list of regular expressions of source branches to ignore from PR agent when an PR is created ignore_pr_source_branches = [] # a list of regular expressions of source branches to ignore from PR agent when an PR is created
ignore_pr_labels = [] # labels to ignore from PR agent when an PR is created ignore_pr_labels = [] # labels to ignore from PR agent when an PR is created
ignore_pr_authors = [] # authors to ignore from PR agent when an PR is created ignore_pr_authors = [] # authors to ignore from PR agent when an PR is created
ignore_repositories = [] # a list of regular expressions of repository full names (e.g. "org/repo") to ignore from PR agent processing
# #
is_auto_command = false # will be auto-set to true if the command is triggered by an automation is_auto_command = false # will be auto-set to true if the command is triggered by an automation
enable_ai_metadata = false # will enable adding ai metadata enable_ai_metadata = false # will enable adding ai metadata
@ -119,10 +121,11 @@ async_ai_calls=true
[pr_questions] # /ask # [pr_questions] # /ask #
enable_help_text=false enable_help_text=false
use_conversation_history=true
[pr_code_suggestions] # /improve # [pr_code_suggestions] # /improve #
max_context_tokens=16000 max_context_tokens=24000
# #
commitable_code_suggestions = false commitable_code_suggestions = false
dual_publishing_score_threshold=-1 # -1 to disable, [0-10] to set the threshold (>=) for publishing a code suggestion both in a table and as commitable dual_publishing_score_threshold=-1 # -1 to disable, [0-10] to set the threshold (>=) for publishing a code suggestion both in a table and as commitable
@ -143,7 +146,7 @@ new_score_mechanism_th_high=9
new_score_mechanism_th_medium=7 new_score_mechanism_th_medium=7
# params for '/improve --extended' mode # params for '/improve --extended' mode
auto_extended_mode=true auto_extended_mode=true
num_code_suggestions_per_chunk=3 num_code_suggestions_per_chunk=4
max_number_of_calls = 3 max_number_of_calls = 3
parallel_calls = true parallel_calls = true

View File

@ -43,6 +43,19 @@ Now focus on the selected lines from the hunk:
====== ======
Note that lines in the diff body are prefixed with a symbol that represents the type of change: '-' for deletions, '+' for additions, and ' ' (a space) for unchanged lines Note that lines in the diff body are prefixed with a symbol that represents the type of change: '-' for deletions, '+' for additions, and ' ' (a space) for unchanged lines
{%- if conversation_history %}
Previous discussion on this code:
======
{{ conversation_history|trim }}
======
Consider this conversation history (format: "N. Username: Message", where numbers indicate the comment order). When responding:
- Maintain consistency with previous technical explanations
- Address unresolved issues from earlier discussions
- Build upon existing knowledge without contradictions
- Incorporate relevant context while focusing on the current question
{%- endif %}
A question about the selected lines: A question about the selected lines:
====== ======

View File

@ -6,7 +6,7 @@ Your task is to add a brief summary of this PR's changes to CHANGELOG.md file of
- Be general, and avoid specific details, files, etc. The output should be minimal, no more than 3-4 short lines. - Be general, and avoid specific details, files, etc. The output should be minimal, no more than 3-4 short lines.
- Write only the new content to be added to CHANGELOG.md, without any introduction or summary. The content should appear as if it's a natural part of the existing file. - Write only the new content to be added to CHANGELOG.md, without any introduction or summary. The content should appear as if it's a natural part of the existing file.
{%- if pr_link %} {%- if pr_link %}
- If relevant, convert the changelog main header into a clickable link using the PR URL '{{ pr_link }}'. Format: header [*][pr_link] - If relevant, convert the changelog main header into a clickable link using the PR URL '{{ pr_link }}'. Format: header [*](pr_link)
{%- endif %} {%- endif %}

View File

@ -19,7 +19,7 @@ from pr_agent.algo.pr_processing import (add_ai_metadata_to_diff_files,
retry_with_fallback_models) retry_with_fallback_models)
from pr_agent.algo.token_handler import TokenHandler from pr_agent.algo.token_handler import TokenHandler
from pr_agent.algo.utils import (ModelType, load_yaml, replace_code_tags, from pr_agent.algo.utils import (ModelType, load_yaml, replace_code_tags,
show_relevant_configurations, get_max_tokens, clip_tokens) show_relevant_configurations, get_max_tokens, clip_tokens, get_model)
from pr_agent.config_loader import get_settings from pr_agent.config_loader import get_settings
from pr_agent.git_providers import (AzureDevopsProvider, GithubProvider, from pr_agent.git_providers import (AzureDevopsProvider, GithubProvider,
GitLabProvider, get_git_provider, GitLabProvider, get_git_provider,
@ -121,7 +121,7 @@ class PRCodeSuggestions:
# if not self.is_extended: # if not self.is_extended:
# data = await retry_with_fallback_models(self._prepare_prediction, model_type=ModelType.REGULAR) # data = await retry_with_fallback_models(self._prepare_prediction, model_type=ModelType.REGULAR)
# else: # else:
data = await retry_with_fallback_models(self._prepare_prediction_extended, model_type=ModelType.REGULAR) data = await retry_with_fallback_models(self.prepare_prediction_main, model_type=ModelType.REGULAR)
if not data: if not data:
data = {"code_suggestions": []} data = {"code_suggestions": []}
self.data = data self.data = data
@ -267,14 +267,6 @@ class PRCodeSuggestions:
up_to_commit_txt = f" up to commit {match.group(0)[4:-3].strip()}" up_to_commit_txt = f" up to commit {match.group(0)[4:-3].strip()}"
return up_to_commit_txt return up_to_commit_txt
if isinstance(git_provider, AzureDevopsProvider): # get_latest_commit_url is not supported yet
if progress_response:
git_provider.edit_comment(progress_response, pr_comment)
new_comment = progress_response
else:
new_comment = git_provider.publish_comment(pr_comment)
return new_comment
history_header = f"#### Previous suggestions\n" history_header = f"#### Previous suggestions\n"
last_commit_num = git_provider.get_latest_commit_url().split('/')[-1][:7] last_commit_num = git_provider.get_latest_commit_url().split('/')[-1][:7]
if only_fold: # A user clicked on the 'self-review' checkbox if only_fold: # A user clicked on the 'self-review' checkbox
@ -416,9 +408,15 @@ class PRCodeSuggestions:
data = self._prepare_pr_code_suggestions(response) data = self._prepare_pr_code_suggestions(response)
# self-reflect on suggestions (mandatory, since line numbers are generated now here) # self-reflect on suggestions (mandatory, since line numbers are generated now here)
model_reflection = get_settings().config.model model_reflect_with_reasoning = get_model('model_reasoning')
fallbacks = get_settings().config.fallback_models
if model_reflect_with_reasoning == get_settings().config.model and model != get_settings().config.model and fallbacks and model == \
fallbacks[0]:
# we are using a fallback model (should not happen on regular conditions)
get_logger().warning(f"Using the same model for self-reflection as the one used for suggestions")
model_reflect_with_reasoning = model
response_reflect = await self.self_reflect_on_suggestions(data["code_suggestions"], response_reflect = await self.self_reflect_on_suggestions(data["code_suggestions"],
patches_diff, model=model_reflection) patches_diff, model=model_reflect_with_reasoning)
if response_reflect: if response_reflect:
await self.analyze_self_reflection_response(data, response_reflect) await self.analyze_self_reflection_response(data, response_reflect)
else: else:
@ -675,7 +673,7 @@ class PRCodeSuggestions:
get_logger().error(f"Error removing line numbers from patches_diff_list, error: {e}") get_logger().error(f"Error removing line numbers from patches_diff_list, error: {e}")
return patches_diff_list return patches_diff_list
async def _prepare_prediction_extended(self, model: str) -> dict: async def prepare_prediction_main(self, model: str) -> dict:
# get PR diff # get PR diff
if get_settings().pr_code_suggestions.decouple_hunks: if get_settings().pr_code_suggestions.decouple_hunks:
self.patches_diff_list = get_pr_multi_diffs(self.git_provider, self.patches_diff_list = get_pr_multi_diffs(self.git_provider,

View File

@ -95,7 +95,7 @@ class PRDescription:
get_logger().info(f"Generating a PR description for pr_id: {self.pr_id}") get_logger().info(f"Generating a PR description for pr_id: {self.pr_id}")
relevant_configs = {'pr_description': dict(get_settings().pr_description), relevant_configs = {'pr_description': dict(get_settings().pr_description),
'config': dict(get_settings().config)} 'config': dict(get_settings().config)}
get_logger().debug("Relevant configs", artifacts=relevant_configs) get_logger().debug("Relevant configs", artifact=relevant_configs)
if get_settings().config.publish_output and not get_settings().config.get('is_auto_command', False): if get_settings().config.publish_output and not get_settings().config.get('is_auto_command', False):
self.git_provider.publish_comment("Preparing PR description...", is_temporary=True) self.git_provider.publish_comment("Preparing PR description...", is_temporary=True)
@ -507,10 +507,10 @@ class PRDescription:
ai_type = self.data.get('type') ai_type = self.data.get('type')
if ai_type and not re.search(r'<!--\s*pr_agent:type\s*-->', body): if ai_type and not re.search(r'<!--\s*pr_agent:type\s*-->', body):
if isinstance(ai_type, list): if isinstance(ai_type, list):
pr_types = [f"{ai_header}{t}" for t in ai_type] pr_type = ', '.join(str(t) for t in ai_type)
pr_type = ','.join(pr_types)
else: else:
pr_type = f"{ai_header}{ai_type}" pr_type = ai_type
pr_type = f"{ai_header}{pr_type}"
body = body.replace('pr_agent:type', pr_type) body = body.replace('pr_agent:type', pr_type)
ai_summary = self.data.get('description') ai_summary = self.data.get('description')

View File

@ -14,10 +14,10 @@ from pr_agent.algo.utils import ModelType
from pr_agent.config_loader import get_settings from pr_agent.config_loader import get_settings
from pr_agent.git_providers import get_git_provider from pr_agent.git_providers import get_git_provider
from pr_agent.git_providers.git_provider import get_main_pr_language from pr_agent.git_providers.git_provider import get_main_pr_language
from pr_agent.git_providers.github_provider import GithubProvider
from pr_agent.log import get_logger from pr_agent.log import get_logger
from pr_agent.servers.help import HelpMessage from pr_agent.servers.help import HelpMessage
class PR_LineQuestions: class PR_LineQuestions:
def __init__(self, pr_url: str, args=None, ai_handler: partial[BaseAiHandler,] = LiteLLMAIHandler): def __init__(self, pr_url: str, args=None, ai_handler: partial[BaseAiHandler,] = LiteLLMAIHandler):
self.question_str = self.parse_args(args) self.question_str = self.parse_args(args)
@ -35,6 +35,7 @@ class PR_LineQuestions:
"question": self.question_str, "question": self.question_str,
"full_hunk": "", "full_hunk": "",
"selected_lines": "", "selected_lines": "",
"conversation_history": "",
} }
self.token_handler = TokenHandler(self.git_provider.pr, self.token_handler = TokenHandler(self.git_provider.pr,
self.vars, self.vars,
@ -56,6 +57,12 @@ class PR_LineQuestions:
# if get_settings().config.publish_output: # if get_settings().config.publish_output:
# self.git_provider.publish_comment("Preparing answer...", is_temporary=True) # self.git_provider.publish_comment("Preparing answer...", is_temporary=True)
# set conversation history if enabled
# currently only supports GitHub provider
if get_settings().pr_questions.use_conversation_history and isinstance(self.git_provider, GithubProvider):
conversation_history = self._load_conversation_history()
self.vars["conversation_history"] = conversation_history
self.patch_with_lines = "" self.patch_with_lines = ""
ask_diff = get_settings().get('ask_diff_hunk', "") ask_diff = get_settings().get('ask_diff_hunk', "")
line_start = get_settings().get('line_start', '') line_start = get_settings().get('line_start', '')
@ -92,6 +99,54 @@ class PR_LineQuestions:
self.git_provider.publish_comment(model_answer_sanitized) self.git_provider.publish_comment(model_answer_sanitized)
return "" return ""
def _load_conversation_history(self) -> str:
"""Generate conversation history from the code review thread
Returns:
str: The formatted conversation history
"""
comment_id = get_settings().get('comment_id', '')
file_path = get_settings().get('file_name', '')
line_number = get_settings().get('line_end', '')
# early return if any required parameter is missing
if not all([comment_id, file_path, line_number]):
get_logger().error("Missing required parameters for conversation history")
return ""
try:
# retrieve thread comments
thread_comments = self.git_provider.get_review_thread_comments(comment_id)
# filter and prepare comments
filtered_comments = []
for comment in thread_comments:
body = getattr(comment, 'body', '')
# skip empty comments, current comment(will be added as a question at prompt)
if not body or not body.strip() or comment_id == comment.id:
continue
user = comment.user
author = user.login if hasattr(user, 'login') else 'Unknown'
filtered_comments.append((author, body))
# transform conversation history to string using the same pattern as get_commit_messages
if filtered_comments:
comment_count = len(filtered_comments)
get_logger().info(f"Loaded {comment_count} comments from the code review thread")
# Format as numbered list, similar to get_commit_messages
conversation_history_str = "\n".join([f"{i + 1}. {author}: {body}"
for i, (author, body) in enumerate(filtered_comments)])
return conversation_history_str
return ""
except Exception as e:
get_logger().error(f"Error processing conversation history, error: {e}")
return ""
async def _get_prediction(self, model: str): async def _get_prediction(self, model: str):
variables = copy.deepcopy(self.vars) variables = copy.deepcopy(self.vars)

View File

@ -16,7 +16,7 @@ description = "QodoAI PR-Agent aims to help efficiently review and handle pull r
readme = "README.md" readme = "README.md"
requires-python = ">=3.12" requires-python = ">=3.12"
keywords = ["AI", "Agents", "Pull Request", "Automation", "Code Review"] keywords = ["AI", "Agents", "Pull Request", "Automation", "Code Review"]
license = { name = "Apache 2.0", file = "LICENSE" } license = "Apache-2.0"
classifiers = [ classifiers = [
"Intended Audience :: Developers", "Intended Audience :: Developers",

Some files were not shown because too many files have changed in this diff Show More