Skip to content

Commit 51c27b2

Browse files
damianmomotgooglecopybara-github
authored andcommitted
fix: scope ADK Java docs release analyzer to a single language
find_doc_issues filters open docs issues by code repository, and the agent only documents Java, so the analyzer no longer mixes languages. PiperOrigin-RevId: 939747285
1 parent cefd978 commit 51c27b2

5 files changed

Lines changed: 43 additions & 16 deletions

File tree

contrib/samples/github/adkreleasedocs/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ The agent (`AdkDocsReleaseAnalyzerAgent`) is equipped with function tools
1717
hand-rolled REST code, no local cloning):
1818

1919
1. `list_releases` — find the two most recent release tags to compare.
20-
2. `find_doc_issues` — list open `docs updates` issues to avoid duplicates.
20+
2. `find_doc_issues` — list open `docs updates` issues for this code repo (one
21+
language) to avoid duplicates.
2122
3. `find_pull_requests_for_issue` — check whether an issue already has PRs.
2223
4. `get_changed_files` — list files changed between the two tags (compare API).
2324
5. `get_file_diff` — fetch the patch for an individual file.
@@ -83,6 +84,7 @@ Variable | Required | Default | Description
8384
`CODE_OWNER` | no | `google` | Owner of the code repository.
8485
`DOC_REPO` | no | `adk-docs` | Docs repository name.
8586
`CODE_REPO` | no | `adk-java` | Code repository name.
87+
`CODE_LANGUAGE` | no | `Java` | Implementation language documented (docs stay single-language).
8688
`CODE_SOURCE_PATH_FILTER` | no | `core/src/main/java/` | Only analyze changes under this path.
8789
`MODEL` | no | `gemini-pro-latest` | Model to use (a Pro model helps with deeper code understanding).
8890

contrib/samples/github/adkreleasedocs/src/main/java/com/example/adkdocs/AdkDocsReleaseAnalyzerAgent.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,18 @@ private static String buildInstruction() {
6262
rejection - report it instead.
6363
6464
# 1. Identity
65-
You are the ADK Docs Release Analyzer. You compare two releases of the ADK code repository and,
66-
when documentation needs updating, file ONE GitHub issue and open a pull request per
67-
recommendation that applies a SUBSTANTIVE documentation update. A substantive update means real
68-
content: conceptual prose AND a complete, idiomatic %CODE_REPO% code example, or a brand new page
69-
when a feature is undocumented for this language. Merely toggling a language-support label/pill
70-
(e.g. adding a `<span class="lst-...">` tag) is NOT acceptable on its own. All access is through
71-
GitHub tools; you never clone repositories locally.
65+
You are the ADK Docs Release Analyzer for the %CODE_LANGUAGE% implementation of ADK (the
66+
%CODE_REPO% repository). You compare two releases of that repository and, when documentation
67+
needs updating, file ONE GitHub issue and open a pull request per recommendation that applies a
68+
SUBSTANTIVE documentation update. A substantive update means real content: conceptual prose AND a
69+
complete, idiomatic %CODE_LANGUAGE% code example, or a brand new page when a feature is
70+
undocumented for %CODE_LANGUAGE%. Merely toggling a language-support label/pill (e.g. adding a
71+
`<span class="lst-...">` tag) is NOT acceptable on its own. All access is through GitHub tools;
72+
you never clone repositories locally.
73+
74+
SINGLE LANGUAGE: you document ONLY %CODE_LANGUAGE%. Never add, edit, or remove code examples or
75+
sections for any other language (e.g. Python, TypeScript, Go, or the other JVM language). Read
76+
other languages' docs only as a structural reference and leave their content untouched.
7277
7378
# 2. Repositories
7479
- Code repository: %CODE_OWNER%/%CODE_REPO% (source of truth for APIs and real example code)
@@ -78,8 +83,9 @@ private static String buildInstruction() {
7883
1. Call `list_releases` for %CODE_OWNER%/%CODE_REPO%.
7984
- By default compare the two most recent releases (newest = end_tag, second newest =
8085
start_tag). If the user specifies tags, use those instead.
81-
2. DEDUPE: call `find_doc_issues` for %DOC_OWNER%/%DOC_REPO% and look for an open issue titled
82-
"Found docs updates needed from %CODE_REPO% release <start_tag> to <end_tag>".
86+
2. DEDUPE: call `find_doc_issues` for %DOC_OWNER%/%DOC_REPO% with code_repo="%CODE_REPO%" (this
87+
returns only %CODE_REPO% release issues, never other languages'). Look for an open issue
88+
titled "Found docs updates needed from %CODE_REPO% release <start_tag> to <end_tag>".
8389
- If it exists, note its issue number and call `find_pull_requests_for_issue` for it. If that
8490
issue ALREADY has pull requests, STOP and report that it is already handled (issue + PR
8591
URLs). If the issue exists but has NO pull requests, reuse it (skip step 8) and continue.
@@ -98,9 +104,10 @@ API precisely (classes, functions, parameters, defaults, return types).
98104
(tabbed code blocks / per-language sections). Skip docs/api-reference/ (auto-generated).
99105
7. Decide the real documentation work for each change. Every recommendation must add real content,
100106
for example:
101-
- Add a complete %CODE_REPO% code example to the relevant page, mirroring the existing
102-
Python/Java tabs or sections (add the language tab/section WITH working code).
103-
- Add or expand conceptual prose explaining the feature and how to use it in this language.
107+
- Add a complete %CODE_LANGUAGE% code example to the relevant page, mirroring how other
108+
languages are already presented (add the %CODE_LANGUAGE% tab/section WITH working code;
109+
leave the other languages' tabs untouched).
110+
- Add or expand conceptual prose explaining the feature and how to use it in %CODE_LANGUAGE%.
104111
- If the feature has NO page, CREATE a new page (full prose + example) at a sensible docs path.
105112
- Update the language-support label/pill too, but ALWAYS together with the content above.
106113
If NO documentation changes are warranted, create nothing and report that.
@@ -138,6 +145,7 @@ API precisely (classes, functions, parameters, defaults, return types).
138145
"""
139146
.replace("%CODE_OWNER%", Settings.CODE_OWNER)
140147
.replace("%CODE_REPO%", Settings.CODE_REPO)
148+
.replace("%CODE_LANGUAGE%", Settings.CODE_LANGUAGE)
141149
.replace("%DOC_OWNER%", Settings.DOC_OWNER)
142150
.replace("%DOC_REPO%", Settings.DOC_REPO)
143151
.replace("%CODE_SOURCE_PATH_FILTER%", Settings.CODE_SOURCE_PATH_FILTER);

contrib/samples/github/adkreleasedocs/src/main/java/com/example/adkdocs/AdkDocsReleaseAnalyzerRun.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ public final class AdkDocsReleaseAnalyzerRun implements Runnable {
5151
names = "--dry-run",
5252
negatable = true,
5353
defaultValue = "true",
54+
// Keeps "--dry-run" = true; without it picocli assigns the opposite of defaultValue.
55+
fallbackValue = "true",
5456
description =
5557
"Preview the issue without creating it (default). Use --no-dry-run to file it for real.")
5658
private boolean dryRun;

contrib/samples/github/adkreleasedocs/src/main/java/com/example/adkdocs/Settings.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ final class Settings {
2424
static final String DOC_REPO = envOrDefault("DOC_REPO", "adk-docs");
2525
static final String CODE_REPO = envOrDefault("CODE_REPO", "adk-java");
2626

27+
/** Implementation language documented by this analyzer; docs stay single-language. */
28+
static final String CODE_LANGUAGE = envOrDefault("CODE_LANGUAGE", "Java");
29+
2730
/** Only changes under this path in the code repo are analyzed. */
2831
static final String CODE_SOURCE_PATH_FILTER =
2932
envOrDefault("CODE_SOURCE_PATH_FILTER", "core/src/main/java/");

contrib/samples/github/githubtools/src/main/java/com/example/github/GitHubTools.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,30 @@ public static Map<String, Object> createIssue(
334334
@Schema(
335335
name = "find_doc_issues",
336336
description =
337-
"Lists OPEN issues in a repository that carry the 'docs updates' label. Call this before"
338-
+ " creating an issue to avoid filing a duplicate for the same release range.")
337+
"Lists OPEN issues in a repository that carry the 'docs updates' label, restricted to a"
338+
+ " single code repository's release issues. Call this before creating an issue to"
339+
+ " avoid filing a duplicate for the same release range.")
339340
public static Map<String, Object> findDocIssues(
340341
@Schema(name = "repo_owner", description = "The repository owner.") String repoOwner,
341-
@Schema(name = "repo_name", description = "The repository name.") String repoName) {
342+
@Schema(name = "repo_name", description = "The repository name.") String repoName,
343+
@Schema(
344+
name = "code_repo",
345+
description =
346+
"Only return issues whose title mentions this code repository (e.g."
347+
+ " \"adk-java\"), so results stay scoped to one language. Pass an empty"
348+
+ " string for no filter.")
349+
String codeRepo) {
342350
try {
343351
GHRepository repo = connect().getRepository(repoOwner + "/" + repoName);
352+
String filter = codeRepo == null ? "" : codeRepo.trim().toLowerCase(Locale.ROOT);
344353
List<Map<String, Object>> issues = new ArrayList<>();
345354
for (GHIssue issue : repo.getIssues(GHIssueState.OPEN)) {
346355
if (issue.isPullRequest() || !hasDocsLabel(issue)) {
347356
continue;
348357
}
358+
if (!issue.getTitle().toLowerCase(Locale.ROOT).contains(filter)) {
359+
continue;
360+
}
349361
Map<String, Object> info = new LinkedHashMap<>();
350362
info.put("number", issue.getNumber());
351363
info.put("title", issue.getTitle());

0 commit comments

Comments
 (0)