ComposioHQ / composio

Composio equip's your AI agents & LLMs with 100+ high-quality integrations via function calling
https://docs.composio.dev
Other
7.47k stars 2.33k forks source link

Add scaffold of pr agent #359

Closed kaavee315 closed 1 month ago

kaavee315 commented 1 month ago

PR Type

Enhancement, Other


Description


Changes walkthrough ๐Ÿ“

Relevant files
Enhancement
cli.py
Add agent type option to CLI scaffolding command                 

python/swe/swekit/cli.py
  • Added AgentType option to CLI for scaffolding different agent types.
  • Updated _scaffold function to accept and use agent_type.
  • +11/-1   
    __init__.py
    Include AgentType in scaffold module exports                         

    python/swe/swekit/scaffold/__init__.py
  • Imported AgentType in the module.
  • Added AgentType to __all__.
  • +2/-1     
    _scaffold.py
    Extend scaffold function to support multiple agent types 

    python/swe/swekit/scaffold/_scaffold.py
  • Defined AgentType enum with SWE and PR_REVIEW values.
  • Updated AgenticFramework.load_templates to handle different agent
    types.
  • Modified scaffold function to accept and use agent_type.
  • +17/-4   
    Other
    main.template
    Add PR review agent template for CrewAI                                   

    python/swe/swekit/scaffold/templates/pr_review/crewai/main.template
  • Created a new template for PR review agent using CrewAI and
    ComposioToolSet.
  • Defined tools and tasks for the PR review agent.
  • Implemented a trigger listener for GitHub pull request events.
  • +100/-0 

    ๐Ÿ’ก PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    codiumai-pr-agent-pro[bot] commented 1 month ago

    PR Reviewer Guide ๐Ÿ”

    โฑ๏ธ Estimated effort to review: 3 ๐Ÿ”ต๐Ÿ”ต๐Ÿ”ตโšชโšช
    ๐Ÿงช No relevant tests
    ๐Ÿ”’ No security concerns identified
    โšก Key issues to review

    Typo
    There is a typo in the method documentation: "tempalte" should be corrected to "template". Hardcoded Logic
    The code directly concatenates channel_id into a string which could lead to runtime errors if the channel_id is not properly formatted as expected. Consider validating or formatting the channel_id before using it.
    codiumai-pr-agent-pro[bot] commented 1 month ago

    PR Code Suggestions โœจ

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Add error handling to prevent unhandled exceptions when file reading fails ___ **Add error handling for potential failures when reading template files.** [python/swe/swekit/scaffold/_scaffold.py [26-28]](https://github.com/ComposioHQ/composio/pull/359/files#diff-0a837dbf0fcdbe8c94526e4d4459043ac0b17b4f88a8ddfcf967de1fb05227d1R26-R28) ```diff -return { - file.name.replace(".template", ".py"): file.read_text(encoding="utf-8") - for file in (TEMPLATES_PATH / self.value).glob("*.template") -} +try: + return { + file.name.replace(".template", ".py"): file.read_text(encoding="utf-8") + for file in (TEMPLATES_PATH / self.value).glob("*.template") + } +except Exception as e: + raise SWEKitError(f"Failed to read template files: {str(e)}") ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: Adding error handling for file reading operations is crucial to prevent the application from crashing due to unhandled exceptions. This significantly improves the robustness of the code.
    9
    Possible issue
    Validate the output directory before performing file operations ___ **Ensure the outdir parameter is validated to check if it's a valid directory path
    before proceeding with file operations.** [python/swe/swekit/cli.py [44]](https://github.com/ComposioHQ/composio/pull/359/files#diff-82e98c671cd58b739deadbc714511c1276d9b49fc8873cf6c843e20f34aaa0e5R44-R44) ```diff outdir: t.Optional[Path] = None, +if outdir is not None and not outdir.exists(): + raise ValueError("The specified output directory does not exist.") ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: Validating the output directory ensures that the directory exists before performing file operations, preventing potential runtime errors. This is an important validation step to ensure the reliability of the code.
    8
    Validate agent_type to ensure it is a valid enum value ___ **Add a validation check for `agent_type` to ensure it receives a valid enum value.** [python/swe/swekit/cli.py [45]](https://github.com/ComposioHQ/composio/pull/359/files#diff-82e98c671cd58b739deadbc714511c1276d9b49fc8873cf6c843e20f34aaa0e5R45-R45) ```diff agent_type: AgentType = AgentType.SWE, +if not isinstance(agent_type, AgentType): + raise ValueError("Invalid agent type provided.") ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: Ensuring that `agent_type` is a valid enum value prevents invalid values from causing unexpected behavior or errors. This validation step is important for maintaining the integrity of the input parameters.
    8
    Enhancement
    Improve string formatting by using f-string ___ **Replace the string concatenation with f-string for better readability and
    performance.** [python/swe/swekit/scaffold/_scaffold.py [39-43]](https://github.com/ComposioHQ/composio/pull/359/files#diff-0a837dbf0fcdbe8c94526e4d4459043ac0b17b4f88a8ddfcf967de1fb05227d1R39-R43) ```diff -code_review_assistant_prompt = ( - """ - You are an experienced code reviewer. - Your task is to review the provided file diff and give constructive feedback. +code_review_assistant_prompt = f""" + You are an experienced code reviewer. + Your task is to review the provided file diff and give constructive feedback. - Follow these steps: - 1. Identify if the file contains significant logic changes. - 2. Summarize the changes in the diff in clear and concise English, within 100 words. - 3. Provide actionable suggestions if there are any issues in the code. + Follow these steps: + 1. Identify if the file contains significant logic changes. + 2. Summarize the changes in the diff in clear and concise English, within 100 words. + 3. Provide actionable suggestions if there are any issues in the code. - Once you have decided on the changes, for any TODOs, create a Github issue. - And send the summary of the PR review to """ - + channel_id - + """ channel on slack. Slack doesn't have markdown and so send a plain text message. - Also add the comprehensive review to the PR as a comment. - """ -) + Once you have decided on the changes, for any TODOs, create a Github issue. + And send the summary of the PR review to {channel_id} channel on slack. Slack doesn't have markdown and so send a plain text message. + Also add the comprehensive review to the PR as a comment. +""" ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: The suggestion improves readability and performance by using f-strings, which are more modern and efficient than concatenation. However, the improvement is minor and does not address a critical issue.
    7
    codiumai-pr-agent-pro[bot] commented 1 month ago

    CI Failure Feedback ๐Ÿง

    (Checks updated until commit https://github.com/ComposioHQ/composio/commit/c772291cede5203dd85051930975d992d3f43855)

    **Action:** test (ubuntu-latest, 3.11)
    **Failed stage:** [Unittests](https://github.com/ComposioHQ/composio/actions/runs/10040990778/job/27748212777) [โŒ]
    **Failed test name:** test_action_enum
    **Failure summary:** The action failed because the test test_action_enum failed. The test failed due to a ValueError
    being raised in the Action class constructor. Specifically:
  • The value GITHUB_ISSUES_LIST was not recognized as a valid value for the Action enum.
  • The error occurred in the file composio/client/enums/base.py at line 112.
  • Relevant error logs: ```yaml 1: ##[group]Operating System 2: Ubuntu ... 505: * [new branch] fix/readme -> origin/fix/readme 506: * [new branch] fix/readme-logo -> origin/fix/readme-logo 507: * [new branch] fix/swe-agent -> origin/fix/swe-agent 508: * [new branch] ft-add-better-help-text -> origin/ft-add-better-help-text 509: * [new branch] ft-add-js-example -> origin/ft-add-js-example 510: * [new branch] ft-apps-id -> origin/ft-apps-id 511: * [new branch] ft-bring-back-core-sdk -> origin/ft-bring-back-core-sdk 512: * [new branch] ft-did-you-mean -> origin/ft-did-you-mean 513: * [new branch] ft-error-tracking -> origin/ft-error-tracking ... 929: tests/test_cli/test_actions.py::TestListActions::test_list_all[arguments3-exptected_outputs3-unexptected_outputs3] PASSED [ 17%] 930: tests/test_cli/test_actions.py::TestListActions::test_tag_not_found PASSED [ 19%] 931: tests/test_cli/test_actions.py::TestListActions::test_limit SKIPPED [ 21%] 932: tests/test_cli/test_actions.py::TestListActions::test_copy PASSED [ 23%] 933: tests/test_cli/test_add.py::TestComposioAdd::test_no_auth PASSED [ 25%] 934: tests/test_cli/test_apps.py::TestList::test_list PASSED [ 27%] 935: tests/test_cli/test_apps.py::TestUpdate::test_update_not_required PASSED [ 29%] 936: tests/test_cli/test_apps.py::TestUpdate::test_update SKIPPED (Needs 937: investigation, this test fails in CI) [ 31%] ... 945: tests/test_client/test_client.py::test_raise_invalid_api_key PASSED [ 48%] 946: tests/test_client/test_collections.py::TestTriggerNamesSerialization::test_converts_trigger_objects_to_comma_separated_string PASSED [ 51%] 947: tests/test_client/test_collections.py::TestTriggerNamesSerialization::test_converts_trigger_strings_to_comma_separated_string PASSED [ 53%] 948: tests/test_client/test_collections.py::TestTriggerNamesSerialization::test_converts_mix_of_trigger_objects_and_strings PASSED [ 55%] 949: tests/test_client/test_collections.py::test_trigger_subscription PASSED [ 57%] 950: tests/test_client/test_endpoints.py::test_endpoint PASSED [ 59%] 951: tests/test_client/test_enum.py::test_tag_enum PASSED [ 61%] 952: tests/test_client/test_enum.py::test_app_enum PASSED [ 63%] 953: tests/test_client/test_enum.py::test_action_enum FAILED [ 65%] ... 962: tests/test_tools/test_local/test_workspace.py::test_stderr PASSED [ 85%] 963: tests/test_tools/test_local/test_workspace.py::test_workspace PASSED [ 87%] 964: tests/test_utils/test_decorators.py::test_deprecated PASSED [ 89%] 965: tests/test_utils/test_git.py::test_get_git_user_info PASSED [ 91%] 966: tests/test_utils/test_shared.py::test_get_pydantic_signature_format_from_schema_params PASSED [ 93%] 967: tests/test_utils/test_shared.py::test_json_schema_to_pydantic_field PASSED [ 95%] 968: tests/test_utils/test_shared.py::test_json_schema_to_fields_dict PASSED [ 97%] 969: tests/test_utils/test_url.py::test_get_web_url PASSED [100%] 970: =================================== FAILURES =================================== ... 980: self = 981: value = 'GITHUB_ISSUES_LIST' 982: def __init__(self, value: t.Union[str, te.Self]) -> None: 983: """Create an Enum""" 984: if isinstance(value, _AnnotatedEnum): 985: value = value._slug 986: value = t.cast(str, value).upper() 987: if value not in self.__annotations__ and value not in _runtime_actions: 988: > raise ValueError(f"Invalid value `{value}` for `{self.__class__.__name__}`") 989: E ValueError: Invalid value `GITHUB_ISSUES_LIST` for `Action` 990: composio/client/enums/base.py:112: ValueError ... 995: .tox/unittests/lib/python3.11/site-packages/paramiko/pkey.py:100 996: /home/runner/work/composio/composio/python/.tox/unittests/lib/python3.11/site-packages/paramiko/pkey.py:100: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0. 997: "cipher": algorithms.TripleDES, 998: .tox/unittests/lib/python3.11/site-packages/paramiko/transport.py:259 999: /home/runner/work/composio/composio/python/.tox/unittests/lib/python3.11/site-packages/paramiko/transport.py:259: CryptographyDeprecationWarning: TripleDES has been moved to cryptography.hazmat.decrepit.ciphers.algorithms.TripleDES and will be removed from this module in 48.0.0. 1000: "class": algorithms.TripleDES, 1001: .tox/unittests/lib/python3.11/site-packages/pydantic/_internal/_config.py:291 1002: .tox/unittests/lib/python3.11/site-packages/pydantic/_internal/_config.py:291 1003: /home/runner/work/composio/composio/python/.tox/unittests/lib/python3.11/site-packages/pydantic/_internal/_config.py:291: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.8/migration/ ... 1198: examples/Podcast_summarizer_Agents/Tools/composio_slack.py 4 4 0% 1-5 1199: examples/Podcast_summarizer_Agents/__init__.py 0 0 100% 1200: examples/Podcast_summarizer_Agents/main.py 15 15 0% 1-21 1201: -------------------------------------------------------------------------------------------------------------- 1202: TOTAL 9992 2324 77% 1203: Coverage HTML written to dir htmlcov 1204: Coverage XML written to file coverage.xml 1205: =========================== short test summary info ============================ 1206: FAILED tests/test_client/test_enum.py::test_action_enum - ValueError: Invalid value `GITHUB_ISSUES_LIST` for `Action` 1207: ============= 1 failed, 41 passed, 5 skipped, 5 warnings in 36.45s ============= 1208: unittests: exit 1 (37.46 seconds) /home/runner/work/composio/composio/python> pytest -vvv -rfE --doctest-modules composio/ tests/ --cov=composio --cov=examples --cov-report=html --cov-report=xml --cov-report=term --cov-report=term-missing --cov-config=.coveragerc pid=5632 1209: .pkg: _exit> python /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__ 1210: unittests: FAIL code 1 (83.69=setup[41.18]+cmd[5.05,37.46] seconds) 1211: evaluation failed :( (83.83 seconds) 1212: ##[error]Process completed with exit code 1. ```

    โœจ CI feedback usage guide:
    The CI feedback tool (`/checks)` automatically triggers when a PR has a failed check. The tool analyzes the failed checks and provides several feedbacks: - Failed stage - Failed test name - Failure summary - Relevant error logs 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}" ``` 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. #### Configuration options - `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. - `enable_help_text` - if set to true, the tool will provide a help message with the 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. - `final_update_message` - if `persistent_comment` is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true. See more information about the `checks` tool in the [docs](https://pr-agent-docs.codium.ai/tools/ci_feedback/).