Repository navigation
Merge CLI scripts - #4
Conversation
…into feature/improve_instructions
Merge CLI scripts
PR Code Suggestions ✨
|
feat: add add_diagram configuration option to PR description
…-count-for-todo-section todo section의 내용이 10줄 이하이면 기본적으로 펼쳐져 있도록 수정
…view - Extract loader into pr_agent/algo/best_practices.py and reuse it from /improve and /review so OSS behavior is symmetric (closes Qodo The-PR-Agent#1). - Guard int(max_lines_allowed) with TypeError/ValueError fallback to 800 plus a targeted warning (Qodo The-PR-Agent#2). - Bitbucket get_pr_agent_repo_custom_file: only accept HTTP 200, log non-404 failures, add 10s timeout, and use the repo default branch via get_repo_default_branch (Qodo The-PR-Agent#3, The-PR-Agent#5, The-PR-Agent#6). - LocalGitProvider get_pr_agent_repo_custom_file: resolve and verify the candidate path stays inside the repo root before reading (Qodo The-PR-Agent#7). - Soften prompt wording in code-suggestions templates and add a parallel block in pr_reviewer_prompts.toml so the model treats the section as guidance, ignoring obvious non-guideline content. - Drop unused _FakeContext test helper, retarget patches to the new module, add coverage for the invalid max_lines fallback (Qodo The-PR-Agent#4). - Update docs/improve.md and docs/review.md to reflect that both tools now consume best_practices.md in OSS. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Use compiled Asana patterns (_ASANA_TASK_URL_PATTERN, _ASANA_TASK_SHORT_PATTERN) in find_asana_tickets() instead of inline regex (CodeQL unused-variable, comments The-PR-Agent#5/The-PR-Agent#6). - Add re.IGNORECASE flag to _ASANA_TASK_SHORT_PATTERN for proper case-insensitive matching. - Replace substring match ('app.asana.com' in ticket) with prefix check (ticket.startswith()) to fix CodeQL URL sanitization warning (comment The-PR-Agent#4). - Reserve at least one slot for Asana tickets during truncation when there are 3+ GitHub/branch tickets (comment The-PR-Agent#8). - Dedent only actual leading whitespace instead of blindly slicing dline[remove_count:] to avoid deleting real code on lines with less indentation (comments The-PR-Agent#3/The-PR-Agent#9). - Remove unused 'import pytest' from test file (comments The-PR-Agent#10/The-PR-Agent#20). - Add test_shorthand_mixed_case_asana and test_shorthand_respects_word_boundary test cases.
- Use compiled Asana patterns (_ASANA_TASK_URL_PATTERN, _ASANA_TASK_SHORT_PATTERN) in find_asana_tickets() instead of inline regex (CodeQL unused-variable, comments The-PR-Agent#5/The-PR-Agent#6). - Add re.IGNORECASE flag to _ASANA_TASK_SHORT_PATTERN for proper case-insensitive matching. - Replace substring match ('app.asana.com' in ticket) with prefix check (ticket.startswith()) to fix CodeQL URL sanitization warning (comment The-PR-Agent#4). - Reserve at least one slot for Asana tickets during truncation when there are 3+ GitHub/branch tickets (comment The-PR-Agent#8). - Dedent only actual leading whitespace instead of blindly slicing dline[remove_count:] to avoid deleting real code on lines with less indentation (comments The-PR-Agent#3/The-PR-Agent#9). - Remove unused 'import pytest' from test file (comments The-PR-Agent#10/The-PR-Agent#20). - Add test_shorthand_mixed_case_asana and test_shorthand_respects_word_boundary test cases.
…h failures via typed exception Addresses Qodo review items The-PR-Agent#2, The-PR-Agent#3, The-PR-Agent#4 on PR The-PR-Agent#2483. The-PR-Agent#2 Hardcoded managed_default label set - Add is_describe_managed_label() and _describe_managed_label_names() in pr_agent.algo.utils as the single source of truth for the /describe-managed namespace. - Rewrite get_user_labels() to defer to the same helper so the inclusion and exclusion rules can never drift. The-PR-Agent#3 Default label not managed (Bug fix with tests) - When enable_custom_labels=True and no custom_labels are configured, set_custom_labels injects defaults that include 'Bug fix with tests'. is_describe_managed_label now classifies that label as managed so /describe can remove it once it is no longer recommended. - This also fixes a pre-existing bug in get_user_labels where 'Bug fix with tests' was misclassified as a user label. The-PR-Agent#4 Refresh failure misreported - Add LabelRefreshError in pr_agent.git_providers.git_provider so callers can distinguish a refresh failure from a genuine no-op. - GitProvider.publish_managed_labels (default impl) and GitLabProvider.publish_managed_labels now raise LabelRefreshError on pre-write refresh failure instead of returning None. - PRDescription._safe_publish_labels and PRReviewer.set_review_labels catch LabelRefreshError specifically and log a warning that names the failure, instead of mis-logging it as 'labels unchanged' / 'already set'. #1, The-PR-Agent#5, The-PR-Agent#6, The-PR-Agent#7 from Qodo's review are already addressed in earlier commits on this branch (36ec454, a7a8cad); Qodo's review listing is pinned to PR-level diff hunks so they appear in the report against older revisions. Tests: - New TestDescribeManagedLabelNamespace locks the predicate behavior: default-set always managed, Bug fix with tests managed under the custom-labels default-injection path, and is_describe_managed_label / get_user_labels stay disjoint. - TestSafePublishLabels gains test_predicate_includes_bug_fix_with_tests_when_custom_labels_default and test_logs_distinctly_on_refresh_failure. - test_pr_reviewer_core gains test_set_review_labels_logs_distinctly_on_refresh_failure. - test_publish_managed_labels_aborts_when_refresh_fails replaced with test_publish_managed_labels_raises_when_refresh_fails. - Full unit suite: 1066 passed, 1 skipped, 3 xfailed (was 1060). Signed-off-by: Allen Shearin <allen.p.shearin@gmail.com>
…in restricted mode Address Qodo review on The-PR-Agent#2491: - #4 (skip path drops changelog output): when a changelog push is requested but not possible — provider lacks push support, or restricted_mode disables push_code — the tool no longer returns early with only an error. It now still generates the changelog and publishes it as a comment (which only needs pull-requests: write), with a note that the changes were not pushed. commit_changelog is set to False in that case. - #5 (skip path still initializes): removes the special early-return init path; the normal flow builds only what's needed to generate the changelog. - #6 (contents default note misleading): clarify that unlisted scopes default to none only within an explicit permissions: block; without one, defaults follow repo/org settings. Update the "no push support" test to assert the comment fallback, and add a restricted_mode test (push API present but is_supported('push_code') False) asserting it comments, not pushes.
* fix: scope ticket cache per-PR and fix Dynaconf list merge leaks in tests - Cache key is now 'related_tickets_<md5(pr_url)>' instead of global 'related_tickets', preventing stale tickets leaking between unrelated PRs - Added cache_tickets=true config flag under [pr_reviewer] to allow disabling - Fixed Dynaconf merge_enabled=True list append bug in both production code (env_bridge.py uses case-insensitive pop before set) and test helpers (restore_settings now calls _remove_key before every set) - Added azure-identity dependency for Azure DevOps provider availability - 1043 tests pass, 0 failures * Revert "fix: scope ticket cache per-PR and fix Dynaconf list merge leaks in tests" This reverts commit 7f0d154. * feat: add restricted mode for reduced GitHub permissions (#2279) Add a `config.restricted_mode` option that gates operations requiring elevated permissions (e.g. pushing code to the repository). When enabled, `is_supported("push_code")` returns `False` on GitHub, GitLab, and Bitbucket providers, and `/update_changelog --push_changelog_changes=true` gracefully skips with a clear message instead of failing. Users can set `restricted_mode = true` and use only `issues: write` and `pull-requests: write` permissions, without `contents: write`. * docs: document restricted_mode for reduced GitHub permissions * docs: clarify minimal permissions for restricted mode * fix: move restricted-mode check to __init__ to avoid unnecessary provider reads PRUpdateChangelog.__init__() was fetching languages, files, and CHANGELOG.md content before run() checked push_code support. In restricted mode, these reads were wasted and could fail if contents access is also restricted. Move the capability check into __init__() before the expensive provider calls, and store the result in self._skip_push so run() can return early. * fix: remove full-config logging from run() and use mock AI handler in test - Remove relevant_configs logging that dumps full settings dicts (potential secret leak in logs) - Pass ai_handler mock in test_run_without_push_support to avoid instantiating a real LiteLLMAIHandler * fix: use spec'd mock for push-support test and fix docs permissions note - Use MagicMock(spec=[...]) in test_run_without_push_support so hasattr() correctly returns False for missing attributes instead of brittle delattr on bare MagicMock - Remove misleading 'contents: read (defaults to read)' comment from restricted mode docs; contents is simply not needed * fix: skip __init__ provider reads when _skip_push is set Move all provider-dependent initialization (vars dict, token handler, ai_handler binding, language/file/changelog reads) behind the _skip_push guard so the skip path avoids hitting the git provider at all during construction. * fix(update_changelog): degrade to comment instead of dropping output in restricted mode Address Qodo review on #2491: - #4 (skip path drops changelog output): when a changelog push is requested but not possible — provider lacks push support, or restricted_mode disables push_code — the tool no longer returns early with only an error. It now still generates the changelog and publishes it as a comment (which only needs pull-requests: write), with a note that the changes were not pushed. commit_changelog is set to False in that case. - #5 (skip path still initializes): removes the special early-return init path; the normal flow builds only what's needed to generate the changelog. - #6 (contents default note misleading): clarify that unlisted scopes default to none only within an explicit permissions: block; without one, defaults follow repo/org settings. Update the "no push support" test to assert the comment fallback, and add a restricted_mode test (push API present but is_supported('push_code') False) asserting it comments, not pushes. * fix: generate changelog preview instead of silent skip when push is restricted When restricted_mode is active and push_changelog_changes=true, the tool now generates the changelog output via AI and publishes it as a comment with a '(push restricted by configuration)' label, instead of returning silently. This ensures users see the changelog even when they don't have contents: write permissions. For the 'not supported' case (provider lacks create_or_update_pr_file entirely), the existing early-return behavior is preserved. --------- Co-authored-by: Utsab <utsab@pr-agent.dev> Co-authored-by: naorpeled <me@naor.dev>
…e fix - Regenerate the config reference so the documented no_temperature_models default includes the GLM-5 entries added in the previous commit (the docs build guard would otherwise catch this drift, per Qodo finding #1). - Extend the Kimi K3 completion test to also cover the GLM-5 bare, regional, and Converse spellings, since the model list added a second model with no matching coverage (Qodo finding #2). - Reword the test docstring to imperative phrasing (Qodo finding The-PR-Agent#4). Qodo finding #3 (import order) is a false positive: `ruff check` against this repo's actual pyproject.toml config passes the original tomllib-then-pathlib order unchanged (straight imports sort before from-imports within a section by default); left as-is. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…e fix - Regenerate the config reference so the documented no_temperature_models default includes the GLM-5 entries added in the previous commit (the docs build guard would otherwise catch this drift, per Qodo finding #1). - Extend the Kimi K3 completion test to also cover the GLM-5 bare, regional, and Converse spellings, since the model list added a second model with no matching coverage (Qodo finding #2). - Reword the test docstring to imperative phrasing (Qodo finding The-PR-Agent#4). Qodo finding #3 (import order) is a false positive: `ruff check` against this repo's actual pyproject.toml config passes the original tomllib-then-pathlib order unchanged (straight imports sort before from-imports within a section by default); left as-is. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…e fix - Regenerate the config reference so the documented no_temperature_models default includes the GLM-5 entries added in the previous commit (the docs build guard would otherwise catch this drift, per Qodo finding #1). - Extend the Kimi K3 completion test to also cover the GLM-5 bare, regional, and Converse spellings, since the model list added a second model with no matching coverage (Qodo finding #2). - Reword the test docstring to imperative phrasing (Qodo finding The-PR-Agent#4). Qodo finding #3 (import order) is a false positive: `ruff check` against this repo's actual pyproject.toml config passes the original tomllib-then-pathlib order unchanged (straight imports sort before from-imports within a section by default); left as-is. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
No description provided.