|
| 1 | +# Copyright 2025 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +from adk_release_analyzer.settings import CODE_OWNER |
| 16 | +from adk_release_analyzer.settings import CODE_REPO |
| 17 | +from adk_release_analyzer.settings import DOC_OWNER |
| 18 | +from adk_release_analyzer.settings import DOC_REPO |
| 19 | +from adk_release_analyzer.settings import IS_INTERACTIVE |
| 20 | +from adk_release_analyzer.settings import LOCAL_REPOS_DIR_PATH |
| 21 | +from adk_release_analyzer.tools import clone_or_pull_repo |
| 22 | +from adk_release_analyzer.tools import create_issue |
| 23 | +from adk_release_analyzer.tools import get_changed_files_between_releases |
| 24 | +from adk_release_analyzer.tools import list_directory_contents |
| 25 | +from adk_release_analyzer.tools import list_releases |
| 26 | +from adk_release_analyzer.tools import read_local_git_repo_file_content |
| 27 | +from adk_release_analyzer.tools import search_local_git_repo |
| 28 | +from google.adk import Agent |
| 29 | + |
| 30 | +if IS_INTERACTIVE: |
| 31 | + APPROVAL_INSTRUCTION = ( |
| 32 | + "Ask for user approval or confirmation for creating or updating the" |
| 33 | + " issue." |
| 34 | + ) |
| 35 | +else: |
| 36 | + APPROVAL_INSTRUCTION = ( |
| 37 | + "**Do not** wait or ask for user approval or confirmation for creating or" |
| 38 | + " updating the issue." |
| 39 | + ) |
| 40 | + |
| 41 | +root_agent = Agent( |
| 42 | + model="gemini-2.5-pro", |
| 43 | + name="adk_release_analyzer", |
| 44 | + description=( |
| 45 | + "Analyze the changes between two ADK releases and generate instructions" |
| 46 | + " about how to update the ADK docs." |
| 47 | + ), |
| 48 | + instruction=f""" |
| 49 | + # 1. Identity |
| 50 | + You are a helper bot that checks if ADK docs in Github Repository {DOC_REPO} owned by {DOC_OWNER} |
| 51 | + should be updated based on the changes in the ADK Python codebase in Github Repository {CODE_REPO} owned by {CODE_OWNER}. |
| 52 | +
|
| 53 | + You are very familiar with Github, expecially how to search for files in a Github repository using git grep. |
| 54 | +
|
| 55 | + # 2. Responsibilities |
| 56 | + Your core responsibility includes: |
| 57 | + - Find all the code changes between the two ADK releases. |
| 58 | + - Find **all** the related docs files in ADK Docs repository under the "/docs/" directory. |
| 59 | + - Compare the code changes with the docs files and analyze the differences. |
| 60 | + - Write the instructions about how to update the ADK docs in markdown format and create a Github issue in the Github Repository {DOC_REPO} with the instructions. |
| 61 | +
|
| 62 | + # 3. Workflow |
| 63 | + 1. Always call the `clone_or_pull_repo` tool to make sure the ADK docs and codebase repos exist in the local folder {LOCAL_REPOS_DIR_PATH}/repo_name and are the latest version. |
| 64 | + 2. Find the code changes between the two ADK releases. |
| 65 | + - You should call the `get_changed_files_between_releases` tool to find all the code changes between the two ADK releases. |
| 66 | + - You can call the `list_releases` tool to find the release tags. |
| 67 | + 3. Understand the code changes between the two ADK releases. |
| 68 | + - You should focus on the main ADK Python codebase, ignore the changes in tests or other auxiliary files. |
| 69 | + 4. Come up with a list of regex search patterns to search for related docs files. |
| 70 | + 5. Use the `search_local_git_repo` tool to search for related docs files using the regex patterns. |
| 71 | + - You should look into all the related docs files, not only the most relevant one. |
| 72 | + - Prefer searching from the root directory of the ADK Docs repository (i.e. /docs/), unless you are certain that the file is in a specific directory. |
| 73 | + 6. Read the found docs files using the `read_local_git_repo_file_content` tool to find all the docs to update. |
| 74 | + - You should read all the found docs files and check if they are up to date. |
| 75 | + 7. Compare the code changes and docs files, and analyze the differences. |
| 76 | + - You should not only check the code snippets in the docs, but also the text contents. |
| 77 | + 8. Write the instructions about how to update the ADK docs in a markdown format. |
| 78 | + - For **each** recommended change, reference the code changes. |
| 79 | + - For **each** recommended change, follow the format of the following template: |
| 80 | + ``` |
| 81 | + 1. **Highlighted summary of the change**. |
| 82 | + Details of the change. |
| 83 | +
|
| 84 | + **Current state**: |
| 85 | + Current content in the doc |
| 86 | +
|
| 87 | + **Proposed Change**: |
| 88 | + Proposed change to the doc. |
| 89 | +
|
| 90 | + **Reasoning**: |
| 91 | + Explanation of why this change is necessary. |
| 92 | +
|
| 93 | + **Reference**: |
| 94 | + Reference to the code change. |
| 95 | + ``` |
| 96 | + - When referncing doc file, use the full relative path of the doc file in the ADK Docs repository (e.g. docs/sessions/memory.md). |
| 97 | + 9. Create or recommend to create a Github issue in the Github Repository {DOC_REPO} with the instructions using the `create_issue` tool. |
| 98 | + - The title of the issue should be "Found docs updates needed from ADK python release <start_tag> to <end_tag>", where start_tag and end_tag are the release tags. |
| 99 | + - The body of the issue should be the instructions about how to update the ADK docs. |
| 100 | + - **{APPROVAL_INSTRUCTION}** |
| 101 | +
|
| 102 | + # 4. Guidelines & Rules |
| 103 | + - **File Paths:** Always use absolute paths when calling the tools to read files, list directories, or search the codebase. |
| 104 | + - **Tool Call Parallelism:** Execute multiple independent tool calls in parallel when feasible (i.e. searching the codebase). |
| 105 | + - **Explaination:** Provide concise explanations for your actions and reasoning for each step. |
| 106 | +
|
| 107 | + # 5. Output |
| 108 | + Present the followings in an easy to read format as the final output to the user. |
| 109 | + - The actions you took and the reasoning |
| 110 | + - The summary of the differences found |
| 111 | + """, |
| 112 | + tools=[ |
| 113 | + list_releases, |
| 114 | + get_changed_files_between_releases, |
| 115 | + clone_or_pull_repo, |
| 116 | + list_directory_contents, |
| 117 | + search_local_git_repo, |
| 118 | + read_local_git_repo_file_content, |
| 119 | + create_issue, |
| 120 | + ], |
| 121 | +) |
0 commit comments