From ec684033e87d1c3cae3a75b9bcf9e2b4cfef529d Mon Sep 17 00:00:00 2001 From: Ayo Ayibiowu Date: Fri, 27 Dec 2024 15:04:41 +0000 Subject: [PATCH] remove unneeded files --- examples/agents/agent_creator_crew.yaml | 2 - examples/agents/code_analysis_crew.yaml | 30 --- .../agents/complexity_assessment_crew.yaml | 32 --- examples/agents/impact_assessment_crew.yaml | 92 -------- examples/agents/impact_evaluator_crew.yaml | 54 ----- examples/agents/mr_processing_crew.yaml | 40 ---- examples/agents/mr_publication_crew.yaml | 72 ------- examples/agents/refactor_crew.yaml | 33 --- examples/agents/risk_assessment_crew.yaml | 33 --- examples/agents/test_coverage_crew.yaml | 34 --- .../agents_bak/impact_assessment_crew.yaml | 66 ------ .../mr_decision_execution_crew.yaml | 42 ---- examples/agents_bak/mr_processing_crew.yaml | 130 ----------- mergebot_flow.html | 202 ------------------ sage/flows/mergebot.py | 148 ------------- sage/tools/gitlab_tool.py | 15 +- 16 files changed, 1 insertion(+), 1024 deletions(-) delete mode 100644 examples/agents/code_analysis_crew.yaml delete mode 100644 examples/agents/complexity_assessment_crew.yaml delete mode 100644 examples/agents/impact_assessment_crew.yaml delete mode 100644 examples/agents/impact_evaluator_crew.yaml delete mode 100644 examples/agents/mr_processing_crew.yaml delete mode 100644 examples/agents/mr_publication_crew.yaml delete mode 100644 examples/agents/refactor_crew.yaml delete mode 100644 examples/agents/risk_assessment_crew.yaml delete mode 100644 examples/agents/test_coverage_crew.yaml delete mode 100644 examples/agents_bak/impact_assessment_crew.yaml delete mode 100644 examples/agents_bak/mr_decision_execution_crew.yaml delete mode 100644 examples/agents_bak/mr_processing_crew.yaml delete mode 100644 mergebot_flow.html delete mode 100644 sage/flows/mergebot.py diff --git a/examples/agents/agent_creator_crew.yaml b/examples/agents/agent_creator_crew.yaml index befebb6..0f7ee22 100644 --- a/examples/agents/agent_creator_crew.yaml +++ b/examples/agents/agent_creator_crew.yaml @@ -5,7 +5,6 @@ memory: True agents: - role: Requirements Analyst goal: Gather and define the requirements for the new crew, with specific attention to the chosen process type. - llm: azure/gpt4-128k backstory: | An experienced analyst with a deep understanding of various domains and the ability to translate user needs into clear, actionable requirements. @@ -81,7 +80,6 @@ agents: - role: Configuration Formatter goal: Format the gathered information into a complete YAML configuration file that defines the crew, ensuring compatibility with the selected process. - llm: azure/gpt4-128k backstory: | A detail-oriented specialist with expertise in YAML and configuration file formats. diff --git a/examples/agents/code_analysis_crew.yaml b/examples/agents/code_analysis_crew.yaml deleted file mode 100644 index 2417ce9..0000000 --- a/examples/agents/code_analysis_crew.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: Code Analysis Assessment Crew -cache: True -planning: True -planning_llm: azure/gpt4-128k -process: sequential -memory: False - -agents: - - role: Code Analysis Agent - goal: | - Analyze the code changes in the Merge Request (MR), regardless of programming language or project type. - Assess the significance, potential risks, and impact of these changes on the overall codebase. Assign an impact score based on factors such as complexity, criticality of modified components, and potential for introducing bugs or affecting existing functionality, on a scale from 0 to 10. - backstory: | - A versatile code analyst with deep understanding of software development across various languages and domains. Capable of interpreting code changes in any language, identifying critical modifications, and evaluating their implications for the project. This agent leverages advanced analytical techniques to provide meaningful insights into the codebase's health and stability. - -tasks: - - description: | - Analyze the code changes in the MR. Evaluate the significance, potential risks, and impact on the codebase. Consider all programming languages and project types. Provide insights into how the changes might affect the project's stability and maintainability. - - **Merge Request Details**: - {input} - - agent: Code Analysis Agent - expected_output: | - - An impact score between 0 and 10, reflecting the significance and potential risk of the code changes. - - A detailed analysis explaining the reasoning behind the score, including: - - Identification of critical components or modules affected. - - Assessment of code complexity introduced or modified. - - Potential risks or issues that may arise from the changes. - - Recommendations for mitigating identified risks or improving the code. diff --git a/examples/agents/complexity_assessment_crew.yaml b/examples/agents/complexity_assessment_crew.yaml deleted file mode 100644 index 1d2d606..0000000 --- a/examples/agents/complexity_assessment_crew.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: Complexity Assessment Crew -process: sequential - -agents: - - role: Complexity Assessment Agent - goal: | - Evaluate the complexity of the merge request (MR) changes using language-agnostic methods. Assess the difficulty, potential risks, and impact associated with the changes on a scale from 0 to 10. Consider factors such as the extent of code modifications, structural changes, dependencies affected, and introduction of complex algorithms or patterns. - - backstory: | - A seasoned software engineer with a broad understanding of various programming paradigms and architectures. Possesses the ability to analyze code changes without relying on specific language syntax. Utilizes reasoning and deduction to estimate complexity through universal software development principles and best practices. - -tasks: - - description: | - Analyze the changes made in the MR to evaluate their complexity. Use language-agnostic methods, considering aspects such as: - - - **Lines of Code Changed**: Total additions and deletions. - - **Structural Modifications**: Changes to the architecture or design patterns. - - **Introduction of Complex Algorithms**: Incorporation of advanced algorithms or data structures. - - **Dependencies Affected**: Impact on external libraries, modules, or services. - - **Refactoring Efforts**: Simplification or complication of existing code. - - **Merge Request Details**: - {input} - - agent: Complexity Assessment Agent - expected_output: | - - A **complexity impact score** between 0 and 10, where higher scores indicate greater complexity and potential risk. - - A detailed analysis explaining the reasoning behind the score, including: - - Summary of key changes contributing to the complexity. - - Identification of any complex algorithms or patterns introduced. - - Assessment of potential challenges in testing, integration, or maintenance. - - Recommendations for simplifying complex areas, if applicable. diff --git a/examples/agents/impact_assessment_crew.yaml b/examples/agents/impact_assessment_crew.yaml deleted file mode 100644 index 252464a..0000000 --- a/examples/agents/impact_assessment_crew.yaml +++ /dev/null @@ -1,92 +0,0 @@ -name: Impact Assessment Crew -process: hierarchical -memory: False -cache: True -planning: True -manager_agent: Orchestrator -planning_llm: azure/gpt4-128k - - -agents: - - role: MR Retriever - goal: Retrieve all data about the merge request for further processing from the GitLab API - backstory: An adept communicator with GitLab, retrieving and presenting all information efficiently. - tools: - - name: GitlabMergeRequestTool - args: - result_as_answer: true - - - role: Content Analysis Agent - goal: Categorize the changed files (e.g., code, documentation, configuration, assets) and assign an impact score based on content type significance on a scale from 0 to 10. - backstory: An expert in file content who can quickly identify the nature of file changes. Capable of reasoning and deduction to understand file types and their impact. - - - role: Complexity Assessment Agent - goal: Assess the complexity of the merge request changes, estimating difficulty and risk associated with them on a scale from 0 to 10. - backstory: A complexity guru who can gauge the intricacy of changes without language constraints. Uses reasoning to estimate code complexity through language-agnostic methods. - - - role: Test Coverage Agent - goal: | - Assess the impact of changes on test coverage - Determine the degree to which the changes affect test coverage, assigning an impact score from 0 to 10, and provide recommendations if coverage is inadequate. - backstory: A quality assurance specialist focused on maintaining robust test coverage and is capable of identifying test-related changes and assessing their impact on overall test coverage. - - - role: Risk Assessment Agent - goal: | - Identify potential risks introduced by the changes. Evaluate the severity of any potential risks in the MR, such as modifications to critical files or configurations, assigning a risk score from 0 to 10. - backstory: A risk management expert who ensures the stability and security of the codebase. Able to reason about the impact of changes on stability and security, identifying high-risk areas. - - - role: Compliance Check Agent - goal: | - Verify that changes adhere to coding standards and organizational policies. Assess compliance with standards and policies, assigning a compliance impact score from 0 to 10. - backstory: A stickler for rules who ensures that all code meets quality standards. Capable of assessing compliance through reasoning and deduction. - - - role: Impact Evaluator Agent - goal: | - Integrate the assessments from all other agents, applying configured weights to each score, to compute an overall impact score on a scale from 0 to 10, and provide a comprehensive impact assessment report. - backstory: A methodical analyst who integrates various inputs to produce a comprehensive impact evaluation. Capable of reasoning to aggregate results, apply weights, and produce an overall impact score and detailed report. - - - role: Orchestrator - goal: | - Facilitate seamless collaboration among specialized agents by managing the shared context, sequencing agent tasks dynamically, and preserving rich contextual information. - This ensures that each agent has the relevant data to perform its task and that their outputs collectively enable an accurate and comprehensive assessment of the merge request (MR). In order to ensure accurate evaluation by the agents, you always provide unsummarised MR changes diffs and summarize description to the all the agents so they get the full context of the MR to make a more reflective deciesion. - backstory: | - A resourceful and adaptable coordinator, the Orchestrator was designed to streamline complex workflows by fostering efficient communication and collaboration. - As a digital maestro, it ensures every agent's output is not only utilized effectively but also enriched with insights from other agents. - The Orchestrator values transparency, maintaining a detailed audit trail of all interactions while balancing efficiency and precision in decision-making. - allow_delegation: True - -tasks: - - description: | - Retrieve MR details using the GitLab API. User Input: {input} - agent: MR Retriever - expected_output: | - Obtain complete MR details, including metadata (e.g., title, author, status) and diffs. Ensure the full MR changes/diffs are included - - - description: Analyze the content of the changed files in the MR. Categorize them (e.g., code, documentation, configuration, assets) and assess their significance based on content type. - agent: Content Analysis Agent - expected_output: Categorization of file changes with an initial impact score between 0 and 10 based on content types. - - - description: | - Evaluate the complexity of the changes made in the MR. Use language-agnostic methods to estimate complexity, such as lines of code changed, structural modifications, or introduction of complex algorithms. - agent: Complexity Assessment Agent - expected_output: A complexity impact score between 0 and 10, reflecting the difficulty and risk associated with the changes. - - - description: Assess whether the MR includes changes to test files or impacts test coverage. Determine if new tests are added or existing tests are modified, and provide recommendations if coverage is inadequate. - agent: Test Coverage Agent - expected_output: | - A test coverage impact score between 0 and 10, reflecting the changes' effect on test coverage. - Recommendations if test coverage is inadequate. - - - description: Identify any potential risks introduced by the changes, such as modifications to critical files or configurations. Evaluate the severity of these risks. - agent: Risk Assessment Agent - expected_output: | - A risk impact score between 0 and 10, highlighting any critical changes. Higher scores indicate higher levels of risk. - - - description: Check for compliance with coding standards, style guides, and organizational policies. Identify any deviations or violations in the code changes. - agent: Compliance Check Agent - expected_output: | - A compliance impact score between 0 and 10, where higher scores indicate significant compliance issues. A detailed report of any compliance issues found. - - - description: Aggregate the assessments from all other agents. Apply weights to each score to compute an overall impact score on a scale from 0 to 10. Provide a comprehensive impact assessment report compiling all assessments. - agent: Impact Evaluator Agent - expected_output: | - An overall impact score between 0 and 10. A detailed impact assessment report compiling all individual assessments, ready for posting to the MR. diff --git a/examples/agents/impact_evaluator_crew.yaml b/examples/agents/impact_evaluator_crew.yaml deleted file mode 100644 index b7c5e63..0000000 --- a/examples/agents/impact_evaluator_crew.yaml +++ /dev/null @@ -1,54 +0,0 @@ -name: Impact Evaluator Crew -process: sequential -memory: False - -agents: - - role: Impact Evaluator Agent - goal: | - Integrate the assessments from all other agents, applying configured weights to each score, to compute an overall impact score on a scale from 0 to 10 for a Merge Request (MR). Based on the overall impact score and predefined thresholds, decide whether the MR qualifies for auto-approval and merging without human intervention. Provide a comprehensive impact assessment report and a clear recommendation. - - backstory: | - A methodical analyst who integrates various inputs to produce a comprehensive impact evaluation. Capable of reasoning to aggregate results, apply weights, and make decisions based on organizational policies regarding auto-approvals. Ensures that only MRs with acceptable risk levels are auto-approved to maintain codebase integrity. - -tasks: - - description: | - Aggregate the assessments from all agents. Apply weights to each score to compute an overall impact score on a scale from 0 to 10. Based on the overall impact score and predefined thresholds, determine whether the MR should be auto-approved and merged without human approval. Provide a comprehensive impact assessment report compiling all assessments, along with a clear recommendation. - - **Merge Request ID**: {input} - - **Agent Assessments**: - - **Code Analysis Agent**: {code_analysis_assessment} - - **Complexity Assessment Agent**: {complexity_assessment} - - **Test Coverage Agent**: {test_coverage} - - **Risk Assessment Agent**: {risk_assessment} - - agent: Impact Evaluator Agent - expected_output: | - - **Overall Impact Score**: A number between 0 and 10. - - **Recommendation**: A clear statement indicating whether the MR should be auto-approved and merged without human intervention. - - **Justification**: A detailed and formatted impact assessment report justifying the score and recommendation, ready for posting as a comment on the Merge Request. - - **Output Format (Markdown ready for MR comment):** - - ~~~ - # Impact Assessment Report for MR # - - **Overall Impact Score**: X.X - - **Recommendation**: [Auto-approve and merge] or [Requires human review] - - ## Detailed Assessments - - - **Code Analysis Agent**: Score X.X - - **Findings**: [Summary of code analysis] - - **Complexity Assessment Agent**: Score X.X - - **Findings**: [Summary of complexity assessment] - - **Test Coverage Agent**: Score X.X - - **Findings**: [Summary of test coverage] - - **Risk Assessment Agent**: Score X.X - - **Findings**: [Summary of risk assessment] - - ## Justification - - [Detailed reasoning behind the overall score and recommendation.] - ~~~ diff --git a/examples/agents/mr_processing_crew.yaml b/examples/agents/mr_processing_crew.yaml deleted file mode 100644 index 0a692ed..0000000 --- a/examples/agents/mr_processing_crew.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: MR Input Processing Crew -process: sequential -memory: False -cache: True - -agents: - - role: Input Handler - goal: Validate MR input (URL or ID) provided by the user ensurig the MR input is correct and extract necessary identifiers - backstory: A meticulous gatekeeper who verifies inputs before processing begins. - - - role: MR Retriever - goal: Retrieve all data about the merge request for further processing from the GitLab API - backstory: An adept communicator with GitLab, retrieving and presenting all information efficiently. - tools: - - name: GitlabMergeRequestTool - args: - result_as_answer: true - - - role: Pipeline Retriever - goal: Retrieve all data about the merge request pipeline from the GitLab API for further processing. - backstory: A skilled communicator with GitLab, adept at retrieving and presenting pipeline information efficiently. - tools: - - name: GitlabPipelineTool - args: - result_as_answer: true - -tasks: - - description: | - Validate the provided MR input and extract identifiers. User Input: {input} - agent: Input Handler - expected_output: | - A structured object containing: - - mr_id: The ID of the merge request. - - project_name: The name of the project associated with the MR. - - - description: | - Retrieve MR details using the GitLab API. - agent: MR Retriever - expected_output: | - Obtain complete MR details, including metadata (e.g., title, author, status) and diffs. Ensure the full MR changes/diffs are included diff --git a/examples/agents/mr_publication_crew.yaml b/examples/agents/mr_publication_crew.yaml deleted file mode 100644 index 3b34a02..0000000 --- a/examples/agents/mr_publication_crew.yaml +++ /dev/null @@ -1,72 +0,0 @@ -name: MR Publication Crew -process: sequential -memory: True - -agents: - - role: Publication Agent - goal: | - Publish the impact assessment report to the MR, ensuring that all stakeholders are informed of the evaluation results. - Format the report using Markdown for readability. - backstory: | - A diligent communicator who values transparency and clarity. - Skilled in formatting and presenting information effectively, making sure the assessment is accessible and understandable to all MR participants. - tools: - - GitlabMergeCommentTool - - - role: Execution Agent - goal: | - Execute the approval and merge actions based on the recommendation from the impact assessment report. - If the recommendation is to auto-approve and merge, proceed to approve and merge the MR using the GitLab API. - If the recommendation is for manual review, then do nothing. - backstory: | - A responsible executor who follows decisions. - Prioritizes adherence to established policies and procedures, ensuring that actions are carried out accurately and efficiently. - tools: - - GitlabMergeApprovalTool - - GitlabMergeCommentTool - -tasks: - - description: | - Receive the impact assessment report and the recommendation from the Impact Evaluator Crew. - - **Tasks**: - - Format the impact assessment report using Markdown for readability and consistency. - - Post the formatted report as a comment on the MR, making it available to all stakeholders. - - **Inputs**: - - **MR ID**: {input} - - **Impact Assessment Report**: - {impact_assessment_report} - - agent: Publication Agent - expected_output: | - - The impact assessment report is posted on the MR as a comment, properly formatted in Markdown. - - The comment is visible to all MR participants and stakeholders. - - Confirmation that the posting was successful, or an error message if it failed. - - - description: | - Based on the recommendation from the Impact Evaluator Crew, execute the following: - - **If the recommendation is to "Auto-approve and merge"**: - - Approve the MR using the GitLab API. - - Post a confirmation comment on the MR indicating that it has been approved. - - **If the recommendation is "Requires human review"**: - - Leave the MR open for manual review. - - Post a comment on the MR indicating that it requires further review due to its impact assessment. - - **Inputs**: - - **MR ID**: {input} - - **Impact Assessment Report**: - {impact_assessment_report} - agent: Execution Agent - expected_output: | - - **If auto-approved and merged**: - - The MR is approved. - - The MR is merged into the target branch. - - A confirmation comment is posted on the MR indicating successful approval and merge. - - Confirmation messages or logs indicating the actions were successful, or error messages if any actions failed. - - - **If not auto-approved**: - - The MR remains open for manual review. - - A comment is posted on the MR indicating that the MR requires further review due to its impact assessment. diff --git a/examples/agents/refactor_crew.yaml b/examples/agents/refactor_crew.yaml deleted file mode 100644 index 14f70d6..0000000 --- a/examples/agents/refactor_crew.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: PythonRefactorCrew - -memory: True - -agents: - - role: Code Analyzer - goal: Analyze the existing codebase and identify areas for improvement - backstory: An expert in static code analysis with years of experience in identifying code smells and technical debt in Python projects. - - - role: Refactoring Specialist - goal: Refactor the codebase to improve readability, performance, and maintainability - backstory: A seasoned developer with deep knowledge of Python best practices and design patterns, focusing on writing clean, efficient, and maintainable code. - - - role: Quality Assurance Engineer - goal: Ensure that the refactored code is functional and meets quality standards - backstory: | - A meticulous engineer dedicated to verifying that all code changes meet the highest standards of quality and functionality. - You feel that programmers always do only half the job, so you are super dedicate to make high quality code. - allow_delegation: true - -tasks: - - description: "Perform a comprehensive analysis of the existing codebase to identify areas that require refactoring. Code details: {input}" - agent: Code Analyzer - expected_output: A detailed report outlining the areas of the codebase that need improvement, including potential code smells, technical debt, and inefficiencies. - - - description: "Refactor the identified areas of the codebase to enhance readability, performance, and maintainability. Code details: {input}" - agent: Refactoring Specialist - expected_output: A refactored codebase that adheres to best practices, including improved code structure, reduced complexity, and optimized performance. - - - description: | - Verify that the refactored code is functional, complete, and meets quality standards. User code details: {input} - agent: Quality Assurance Engineer - expected_output: A validated and fully functional codebase, ensuring that all refactored changes are correct and efficient. diff --git a/examples/agents/risk_assessment_crew.yaml b/examples/agents/risk_assessment_crew.yaml deleted file mode 100644 index 183bac0..0000000 --- a/examples/agents/risk_assessment_crew.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: Risk Assessment Crew -process: sequential - -agents: - - role: Risk Assessment Agent - goal: | - Evaluate the Merge Request (MR) changes to identify potential risks introduced by the modifications. Risks may include changes to critical files or configurations, security vulnerabilities, performance impacts, and compatibility issues. Assess the severity of these risks and assign a risk impact score from 0 to 10, where higher scores indicate higher levels of risk. Provide recommendations for mitigating identified risks. - - backstory: | - A seasoned risk management expert dedicated to ensuring the stability, security, and performance of the codebase. Possesses deep knowledge of software development practices and the ability to foresee potential issues arising from code changes. Uses analytical skills and experience to identify high-risk areas and suggest preventive measures. - -tasks: - - description: | - Analyze the MR changes to identify any potential risks introduced. Consider factors such as: - - - **Modifications to Critical Files or Configurations**: Changes to core modules, system configurations, or foundational code. - - **Security Vulnerabilities**: Introduction of code that may expose the system to security threats, such as injection vulnerabilities, improper authentication mechanisms, or insecure data handling. - - **Performance Impacts**: Changes that could degrade system performance, including inefficient algorithms or resource-intensive operations. - - **Compatibility Issues**: Modifications that might cause integration problems with existing systems, APIs, or dependencies. - - **Stability and Reliability**: Potential for crashes, data corruption, or other stability issues. - - Evaluate the severity of these risks and provide recommendations for mitigation. - - **Merge Request Details**: - {input} - - agent: Risk Assessment Agent - expected_output: | - - A **risk impact score** between 0 and 10, where higher scores indicate higher levels of risk. - - A detailed risk assessment report including: - - **Summary of Identified Risks**: Description of each potential risk found. - - **Severity Evaluation**: Explanation of why each risk is significant. - - **Recommendations**: Suggested actions to mitigate or address the identified risks. diff --git a/examples/agents/test_coverage_crew.yaml b/examples/agents/test_coverage_crew.yaml deleted file mode 100644 index 9208818..0000000 --- a/examples/agents/test_coverage_crew.yaml +++ /dev/null @@ -1,34 +0,0 @@ -name: Test Coverage Assessment Crew -process: sequential - -agents: - - role: Test Coverage Assessment Agent - goal: | - Evaluate the Merge Request (MR) changes to determine their impact on test coverage. Assess whether the changes negatively affect test coverage by reducing it or failing to include necessary tests. Assign a test coverage impact score from 0 to 10, where higher scores indicate a greater negative impact on coverage. Identify areas lacking adequate test coverage and provide recommendations to improve it. - - backstory: | - A dedicated quality assurance specialist committed to ensuring robust test coverage across the codebase. Possesses extensive experience in software testing methodologies and understands the importance of comprehensive testing for code reliability. Skilled at identifying gaps in test coverage and suggesting effective strategies to address them. - -tasks: - - description: | - Analyze the MR to assess its impact on test coverage. Specifically: - - - Determine if code changes lack corresponding tests or if existing tests are removed or insufficient. - - Evaluate whether the changes affect critical functionalities that require additional testing. - - Identify any reduction in test coverage due to code deletions, modifications, or lack of new tests. - - Provide recommendations to improve test coverage where it is inadequate. - - **Merge Request Details**: - {input} - - agent: Test Coverage Assessment Agent - expected_output: | - - A **test coverage impact score** between 0 and 10, where: - - Scores >7 indicate a significant negative impact on test coverage (e.g., decreased coverage, missing tests for new features). - - Scores 4-7 indicate some negative impact (e.g., insufficient tests, minor reductions in coverage). - - Scores <4 indicate minimal or no negative impact on test coverage. - - - A detailed report including: - - **Summary of Findings**: Overview of how the MR negatively affects test coverage. - - **Areas Lacking Coverage**: Specific code changes that are not adequately tested. - - **Recommendations**: Suggestions to add or improve tests to enhance coverage. diff --git a/examples/agents_bak/impact_assessment_crew.yaml b/examples/agents_bak/impact_assessment_crew.yaml deleted file mode 100644 index 895f315..0000000 --- a/examples/agents_bak/impact_assessment_crew.yaml +++ /dev/null @@ -1,66 +0,0 @@ -name: Impact Assessment Crew -process: hierarchical -memory: True - -agents: - - role: Content Analysis Agent - goal: Categorize the changed files (e.g., code, documentation, configuration, assets) and assign an impact score based on content type significance on a scale from 0 to 10. - backstory: An expert in file content who can quickly identify the nature of file changes. Capable of reasoning and deduction to understand file types and their impact. - - - role: Complexity Assessment Agent - goal: Assess the complexity of the merge request changes, estimating difficulty and risk associated with them on a scale from 0 to 10. - backstory: A complexity guru who can gauge the intricacy of changes without language constraints. Uses reasoning to estimate code complexity through language-agnostic methods. - - - role: Test Coverage Agent - goal: | - Assess the impact of changes on test coverage - Determine the degree to which the changes affect test coverage, assigning an impact score from 0 to 10, and provide recommendations if coverage is inadequate. - backstory: A quality assurance specialist focused on maintaining robust test coverage and is capable of identifying test-related changes and assessing their impact on overall test coverage. - - - role: Risk Assessment Agent - goal: | - Identify potential risks introduced by the changes. Evaluate the severity of any potential risks in the MR, such as modifications to critical files or configurations, assigning a risk score from 0 to 10. - backstory: A risk management expert who ensures the stability and security of the codebase. Able to reason about the impact of changes on stability and security, identifying high-risk areas. - - - role: Compliance Check Agent - goal: | - Verify that changes adhere to coding standards and organizational policies. Assess compliance with standards and policies, assigning a compliance impact score from 0 to 10. - backstory: A stickler for rules who ensures that all code meets quality standards. Capable of assessing compliance through reasoning and deduction. - - - role: Impact Evaluator Agent - goal: | - Integrate the assessments from all other agents, applying configured weights to each score, to compute an overall impact score on a scale from 0 to 10, and provide a comprehensive impact assessment report. - backstory: A methodical analyst who integrates various inputs to produce a comprehensive impact evaluation. Capable of reasoning to aggregate results, apply weights, and produce an overall impact score and detailed report. - -tasks: - - description: Analyze the content of the changed files in the MR. Categorize them (e.g., code, documentation, configuration, assets) and assess their significance based on content type. - agent: Content Analysis Agent - expected_output: Categorization of file changes with an initial impact score between 0 and 10 based on content types. - - - description: | - Evaluate the complexity of the changes made in the MR. Use language-agnostic methods to estimate complexity, such as lines of code changed, structural modifications, or introduction of complex algorithms. - agent: Complexity Assessment Agent - expected_output: A complexity impact score between 0 and 10, reflecting the difficulty and risk associated with the changes. - - - description: Assess whether the MR includes changes to test files or impacts test coverage. Determine if new tests are added or existing tests are modified, and provide recommendations if coverage is inadequate. - agent: Test Coverage Agent - expected_output: Categorization of file changes with an initial impact score between 0 and 10 based on content types. - - - description: Identify any potential risks introduced by the changes, such as modifications to critical files or configurations. Evaluate the severity of these risks. - agent: Risk Assessment Agent - expected_output: | - A risk impact score between 0 and 10, highlighting any critical changes. Higher scores indicate higher levels of risk. - - - description: Identify any potential risks introduced by the changes, such as modifications to critical files or configurations. Evaluate the severity of these risks. - agent: Risk Assessment Agent - expected_output: | - A risk impact score between 0 and 10, highlighting any critical changes. Higher scores indicate higher levels of risk. - - - description: Check for compliance with coding standards, style guides, and organizational policies. Identify any deviations or violations in the code changes. - agent: Compliance Check Agent - expected_output: | - A compliance impact score between 0 and 10, where higher scores indicate significant compliance issues. A detailed report of any compliance issues found. - - - description: Aggregate the assessments from all other agents. Apply weights to each score to compute an overall impact score on a scale from 0 to 10. Provide a comprehensive impact assessment report compiling all assessments. - agent: Impact Evaluator Agent - expected_output: | - An overall impact score between 0 and 10. A detailed impact assessment report compiling all individual assessments, ready for posting to the MR. diff --git a/examples/agents_bak/mr_decision_execution_crew.yaml b/examples/agents_bak/mr_decision_execution_crew.yaml deleted file mode 100644 index e992867..0000000 --- a/examples/agents_bak/mr_decision_execution_crew.yaml +++ /dev/null @@ -1,42 +0,0 @@ -name: MR Decision and Execution Crew -process: sequential - -agents: - - role: Commenter Agent - goal: Communicate the assessment results to stakeholders clearly and effectively. Post the impact assessment report to the MR. - backstory: An articulate messenger who ensures clear communication and keeps all parties informed. Capable of formatting and posting messages in the MR, ensuring the information is accessible and well-presented. - tools: - - GitlabAPITool - - - role: Approval Agent - goal: Automate MR approval and merging when the impact assessment deems it appropriate, ensuring that only MRs meeting quality criteria are merged and approved - backstory: | - A responsible overseer who enforces quality gates and ensures that the codebase integrity is maintained. Able to interpret the impact assessment results, compare the overall impact score against predefined thresholds, and execute actions accordingly. - tools: - - GitlabAPITool - -tasks: - - description: | - Analyze the impact assessment report, and format the report using Markdown to ensure readability. - Post the formatted impact assessment report as a comment on the MR, making the assessment results available to all stakeholders. - agent: Commenter Agent - expected_output: The impact assessment report is posted on the MR as a comment, properly formatted, and accessible to all MR participants. - - - description: | - Analyze the overall impact score from the impact assessment report of the Merge request changes. Compare the impact score against the updated approval threshold (less than or equal to 4) - If the MR meets the criteria: - - Approve the MR using the GitLab API. - - Merge the MR into the target branch. - - Provide a confirmation comment on the MR indicating that it has been approved and merged. - If the MR does not meet the criteria: - - Leave the MR for manual review. - - Optionally, post a comment indicating that the MR requires further review due to its impact score. - agent: Approval Agent - expected_output: | - If approved and merged: - - The MR is approved. - - The MR is merged into the target branch. - - A comment is posted on the MR confirming the approval and merge. - If not approved: - - The MR remains open for manual review. - - An optional comment is posted indicating that the MR requires further review. diff --git a/examples/agents_bak/mr_processing_crew.yaml b/examples/agents_bak/mr_processing_crew.yaml deleted file mode 100644 index c98383f..0000000 --- a/examples/agents_bak/mr_processing_crew.yaml +++ /dev/null @@ -1,130 +0,0 @@ -name: MR Input Processing Crew -process: sequential -memory: True - -agents: - - role: Input Handler - goal: Validate MR input (URL or ID) provided by the user ensurig the MR input is correct and extract necessary identifiers - backstory: A meticulous gatekeeper who verifies inputs before processing begins. - - - role: MR Retriever - goal: Retrieve all necessary data about the merge request for further processing from the GitLab API - backstory: An adept communicator with GitLab, retrieving information efficiently. - tools: - - GitlabMergeRequestTool - - - role: Change Extractor - goal: Prepare structured and enriched change data of a Merge request, including detailed annotations and categorizations, for an Impact Assessment evaluation. - backstory: A diligent analyst who dissects changes for clarity. - -tasks: - - description: | - Validate the provided MR input and extract identifiers. User Input: {input} - agent: Input Handler - expected_output: Valid MR identifiers or error message. - - - description: | - Retrieve MR details using the GitLab API. User Input: {input} - agent: MR Retriever - expected_output: | - MR details including metadata and diffs.. - - Suggestion on expected output: - { - 'mr': { - 'id': , # MR ID - 'iid': , # MR internal ID within the project - 'project_id': , - 'title': , - 'description': , - 'state': , - 'created_at': , # ISO 8601 timestamp - 'updated_at': , # ISO 8601 timestamp - 'author': { - 'id': , - 'username': , - 'name': , - 'email': , # May require additional API call - }, - 'assignees': [ - { - 'id': , - 'username': , - 'name': , - 'email': , # May require additional API call - }, - # ... more assignees - ], - 'source_branch': , - 'target_branch': , - 'labels': [, , ...], - 'web_url': , - 'merge_status': , - 'pipeline_status': , # Custom field added after fetching pipeline info - 'approvals_required': , - 'approvals_received': , - 'discussion_unresolved_count': , # Optional - }, - 'changes': [ - { - 'old_path': , - 'new_path': , - 'a_mode': , # File mode before change - 'b_mode': , # File mode after change - 'new_file': , - 'renamed_file': , - 'deleted_file': , - 'diff': , # Diff content in unified diff format - 'lines_added': , - 'lines_removed': , - }, - # ... more file changes - ], - 'stats': { - 'total_files_changed': , - 'total_lines_added': , - 'total_lines_removed': , - }, - } - - - description: | - Extract change information from the MR diffs and preprocess it. User Input: {input} - For each file change: - - Determine the file type (code, documentation, configuration, etc.) based on file extension and path. - - Detect the programming language or file format. - - Classify the change type (added, modified, deleted, renamed). - - Identify critical files by comparing file paths with a predefined list. - - Detect test files based on naming conventions and directory structure. - - Parse the diff content to extract meaningful information and structure it for further analysis. - - Calculate preliminary code complexity metrics where applicable. - - Compile all extracted and enriched data into a structured format as per the expected output. - - Provide an enriched response that is finally used for an Impact Assessment of the overall MR change. - - Suggestion on expected ouput: - [ - { - 'file_path': , - 'file_type': , # 'code', 'documentation', 'configuration', 'test', 'asset', etc. - 'language': , # 'Python', 'JavaScript', 'Markdown', etc. - 'change_type': , # 'added', 'modified', 'deleted', 'renamed' - 'is_critical': , # True if in critical files list - 'is_test_file': , # True if identified as a test file - 'lines_added': , - 'lines_removed': , - 'complexity_metrics': { - # Language-specific metrics - 'functions_added': , - 'functions_removed': , - 'classes_added': , - 'classes_removed': , - # Additional metrics if available - }, - 'diff_parsed': { - # Structured representation of the diff, e.g., list of hunks - # Could include added/removed lines with line numbers - } - }, - # ... more file change entries - ] - agent: Change Extractor - expected_output: Structured change data ready for impact assessment. diff --git a/mergebot_flow.html b/mergebot_flow.html deleted file mode 100644 index 9b23a0c..0000000 --- a/mergebot_flow.html +++ /dev/null @@ -1,202 +0,0 @@ - - - - - Flow Plot - - - - - -
-
-
-
-
- - -
-
-
Start Method
-
- -
-
-
Method
-
- -
-
-
Crew Method
-
- -
-
-
Router
-
- -
-
-
Trigger
-
- -
-
-
AND Trigger
-
- -
-
-
Router Trigger
-
- -
-
- -
- - -
-
- - - - - - - - diff --git a/sage/flows/mergebot.py b/sage/flows/mergebot.py deleted file mode 100644 index 4e60784..0000000 --- a/sage/flows/mergebot.py +++ /dev/null @@ -1,148 +0,0 @@ -import random -from crewai.flow.flow import Flow, listen, router, start, and_ -from crewai import Crew -from pydantic import BaseModel -from sage.constants import agents_crew -import re - - -# Get al Crew Instances -all_instances = {crew.name: crew for crew in agents_crew} - -# Get the MR Processing Crew -mr_processing_crew: Crew = all_instances.get("MR Input Processing Crew") - -# Get all Impact Assessment Crews -code_analysis_crew: Crew = all_instances.get("Code Analysis Assessment Crew") -complexity_assessment_crew: Crew = all_instances.get("Complexity Assessment Crew") -risk_assessment_crew: Crew = all_instances.get("Risk Assessment Crew") -test_coverage_crew: Crew = all_instances.get("Test Coverage Assessment Crew") - -# Get the Impact Evaluator Crew -impact_evaluator_crew: Crew = all_instances.get("Impact Evaluator Crew") - -# Get the MR Decision and Execution Crew -mr_decision_crew: Crew = all_instances.get("MR Publication Crew") - - -# Sample Input -bot_input = "MR https://gitlab.its.getingecloud.net/dts/lestrade/aide-recorder/-/merge_requests/53" - - -def extract_merge_request_id(output_string): - pattern = r"https://.+/merge_requests/(\d+)" - - # Search the output string for the pattern - match = re.search(pattern, output_string) - - # Extract and return the Merge Request ID if found - if match: - return int(match.group(1)) - else: - return None - - -class MergeBotState(BaseModel): - """Defines the bot data state""" - - mr_details: str = "" - mr_id: int = None - code_analysis_assessment: str = "" - complexity_assessment: str = "" - test_coverage_assessment: str = "" - risk_assessment: str = "" - impact_assessment: str = "" - - -class MergeBotFlow(Flow[MergeBotState]): - initial_state = MergeBotState - - @start() - def begin(self): - print("Commencing and starting the MergeBot") - - @listen(begin) - def mr_retriever(self): - """Runs a Crew to extract Merge Request Details""" - mr_details = mr_processing_crew.kickoff(inputs={"input": bot_input}).raw - self.state.mr_details = mr_details - self.state.mr_id = extract_merge_request_id(mr_details) - - @listen(mr_retriever) - def code_analysis_assessment(self): - """Runs the Code Analysis Assessment on the MR details""" - - self.state.code_analysis_assessment = code_analysis_crew.kickoff( - inputs={"input": self.state.mr_details} - ).raw - - @listen(mr_retriever) - def complexity_assessment(self): - """Runs the complexity_assessment on the MR details""" - - self.state.complexity_assessment = complexity_assessment_crew.kickoff( - inputs={"input": self.state.mr_details} - ).raw - - @listen(mr_retriever) - def test_coverage_assessment(self): - """Runs the Test Coverage Assessement on the MR details""" - - self.state.test_coverage_assessment = test_coverage_crew.kickoff( - inputs={"input": self.state.mr_details} - ).raw - - @listen(mr_retriever) - def risk_assessment(self): - """Runs the Risk Analysis Assessement on the MR details""" - - self.state.risk_assessment = risk_assessment_crew.kickoff( - inputs={"input": self.state.mr_details} - ).raw - - @listen( - and_( - code_analysis_assessment, - complexity_assessment, - test_coverage_assessment, - risk_assessment, - ) - ) - def impact_evaluator(self): - """Runs the Impact Evaluator Analysis Assessement on the MR details""" - - self.state.impact_assessment = impact_evaluator_crew.kickoff( - inputs={ - "input": self.state.mr_id, - "code_analysis_assessment": self.state.code_analysis_assessment, - "complexity_assessment": self.state.complexity_assessment, - "test_coverage": self.state.test_coverage_assessment, - "risk_assessment": self.state.risk_assessment, - } - ).raw - print("\nFinal Impact Assessment Report:") - print(self.state.impact_assessment) - - @listen(impact_evaluator) - def mr_decision(self): - """Runs the MR decision crew on the impact assessment report""" - - result = mr_decision_crew.kickoff( - inputs={ - "input": self.state.mr_id, - "impact_assessment_report": self.state.impact_assessment, - } - ).raw - - print("\nFinal Response:") - print(result) - - @listen(mr_decision) - def finish(self): - print("MergeBot Processing Completed") - -mergebot = MergeBotFlow() - -if __name__ == "__main__": - mergebot.kickoff() - mergebot.plot("mergebot_flow") diff --git a/sage/tools/gitlab_tool.py b/sage/tools/gitlab_tool.py index 38fe255..83757c6 100644 --- a/sage/tools/gitlab_tool.py +++ b/sage/tools/gitlab_tool.py @@ -1,5 +1,5 @@ import re -from typing import Any, Dict, List, Optional, Type +from typing import Any, Dict, List, Type import json from langchain_community.utilities.gitlab import GitLabAPIWrapper @@ -720,16 +720,3 @@ def _run( return "The Merge Request IID are required." return self.api_wrapper.run(self.mode, body={"mr_iid": int(mr_iid)}) - - -# # Example usage -if __name__ == "__main__": - mr_iid = 51 # Replace with your MR IID - api_wrapper = GitLabAPIWrapperExtra( - gitlab_branch="main", - ) - # print(api_wrapper.approve_merge_request(mr_iid)) - # Replace '12345' with your actual pipeline ID - pipeline_tool = GitlabPipelineTool() - result = pipeline_tool._run(pipeline_id="110292") - print(result)