From 0865b12c0f23dd5d85e9fdf13b80d94b20c698df Mon Sep 17 00:00:00 2001 From: gemini-cli-robot Date: Mon, 27 Apr 2026 16:46:02 +0000 Subject: [PATCH] ## Metric Improvement: Accuracy of Open Issues and PR Counts ### What the change is This PR updates the `open_issues.ts` and `open_prs.ts` metric scripts to use the GitHub Search API for retrieving total counts, rather than listing items with a hardcoded limit of 1000. ### Why it is recommended The current implementation caps the number of open issues and PRs at 1000. Repository metrics currently show exactly 1000 open issues, indicating that the true scale of the backlog is being masked. Accurate data is essential for the "Brain" phase to formulate effective strategies for repository health. ### Which metric is expected to be improved `open_issues` and `open_prs`. ### By how much the metric is expected to improve This change improves the **accuracy** of these metrics from a capped value of 1000 to the true total count. Based on current trends, we expect the reported `open_issues` value to increase significantly, providing a more realistic baseline for future triage efforts. --- .../metrics/scripts/open_issues.ts | 17 ++++++++++++++--- .../gemini-cli-bot/metrics/scripts/open_prs.ts | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tools/gemini-cli-bot/metrics/scripts/open_issues.ts b/tools/gemini-cli-bot/metrics/scripts/open_issues.ts index 4996ec7ce4..dd04f3f227 100644 --- a/tools/gemini-cli-bot/metrics/scripts/open_issues.ts +++ b/tools/gemini-cli-bot/metrics/scripts/open_issues.ts @@ -5,16 +5,27 @@ */ import { execSync } from 'node:child_process'; +import { GITHUB_OWNER, GITHUB_REPO } from '../types.js'; try { const count = execSync( - 'gh issue list --state open --limit 1000 --json number --jq length', + `gh api "search/issues?q=repo:${GITHUB_OWNER}/${GITHUB_REPO}+is:issue+is:open" --jq .total_count`, { encoding: 'utf-8', }, ).trim(); console.log(`open_issues,${count}`); } catch { - // Fallback if gh fails or no issues found - console.log('open_issues,0'); + // Fallback if search fails + try { + const count = execSync( + `gh issue list -R ${GITHUB_OWNER}/${GITHUB_REPO} --state open --limit 5000 --json number --jq length`, + { + encoding: 'utf-8', + }, + ).trim(); + console.log(`open_issues,${count}`); + } catch { + console.log('open_issues,0'); + } } diff --git a/tools/gemini-cli-bot/metrics/scripts/open_prs.ts b/tools/gemini-cli-bot/metrics/scripts/open_prs.ts index 35819ef0f9..0618ce93d4 100644 --- a/tools/gemini-cli-bot/metrics/scripts/open_prs.ts +++ b/tools/gemini-cli-bot/metrics/scripts/open_prs.ts @@ -5,16 +5,27 @@ */ import { execSync } from 'node:child_process'; +import { GITHUB_OWNER, GITHUB_REPO } from '../types.js'; try { const count = execSync( - 'gh pr list --state open --limit 1000 --json number --jq length', + `gh api "search/issues?q=repo:${GITHUB_OWNER}/${GITHUB_REPO}+is:pr+is:open" --jq .total_count`, { encoding: 'utf-8', }, ).trim(); console.log(`open_prs,${count}`); } catch { - // Fallback if gh fails or no PRs found - console.log('open_prs,0'); + // Fallback if search fails + try { + const count = execSync( + `gh pr list -R ${GITHUB_OWNER}/${GITHUB_REPO} --state open --limit 5000 --json number --jq length`, + { + encoding: 'utf-8', + }, + ).trim(); + console.log(`open_prs,${count}`); + } catch { + console.log('open_prs,0'); + } }