mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-09 01:27:41 -07:00
Agent generated files.
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
try {
|
||||
const query = `
|
||||
query($owner: String!, $repo: String!) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
pullRequests(last: 100, states: MERGED) {
|
||||
nodes {
|
||||
authorAssociation
|
||||
createdAt
|
||||
mergedAt
|
||||
}
|
||||
}
|
||||
issues(last: 100, states: CLOSED) {
|
||||
nodes {
|
||||
authorAssociation
|
||||
createdAt
|
||||
closedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = execSync(`gh api graphql -F owner=google-gemini -F repo=gemini-cli -f query='${query}'`, { encoding: 'utf-8' });
|
||||
const data = JSON.parse(output).data.repository;
|
||||
|
||||
const prs = data.pullRequests.nodes.map(p => ({
|
||||
association: p.authorAssociation,
|
||||
latencyHours: (new Date(p.mergedAt).getTime() - new Date(p.createdAt).getTime()) / (1000 * 60 * 60)
|
||||
}));
|
||||
const issues = data.issues.nodes.map(i => ({
|
||||
association: i.authorAssociation,
|
||||
latencyHours: (new Date(i.closedAt).getTime() - new Date(i.createdAt).getTime()) / (1000 * 60 * 60)
|
||||
}));
|
||||
|
||||
const isMaintainer = (assoc) => ['MEMBER', 'OWNER', 'COLLABORATOR'].includes(assoc);
|
||||
const calculateAvg = (items) => items.length ? items.reduce((a, b) => a + b.latencyHours, 0) / items.length : 0;
|
||||
|
||||
const prMaintainers = calculateAvg(prs.filter(i => isMaintainer(i.association)));
|
||||
const prCommunity = calculateAvg(prs.filter(i => !isMaintainer(i.association)));
|
||||
const prOverall = calculateAvg(prs);
|
||||
|
||||
const issueMaintainers = calculateAvg(issues.filter(i => isMaintainer(i.association)));
|
||||
const issueCommunity = calculateAvg(issues.filter(i => !isMaintainer(i.association)));
|
||||
const issueOverall = calculateAvg(issues);
|
||||
|
||||
const timestamp = new Date().toISOString();
|
||||
|
||||
const metrics = [
|
||||
{ metric: 'latency_pr_overall_hours', value: Math.round(prOverall * 100) / 100, timestamp },
|
||||
{ metric: 'latency_pr_maintainers_hours', value: Math.round(prMaintainers * 100) / 100, timestamp },
|
||||
{ metric: 'latency_pr_community_hours', value: Math.round(prCommunity * 100) / 100, timestamp },
|
||||
{ metric: 'latency_issue_overall_hours', value: Math.round(issueOverall * 100) / 100, timestamp },
|
||||
{ metric: 'latency_issue_maintainers_hours', value: Math.round(issueMaintainers * 100) / 100, timestamp },
|
||||
{ metric: 'latency_issue_community_hours', value: Math.round(issueCommunity * 100) / 100, timestamp }
|
||||
];
|
||||
|
||||
metrics.forEach(m => process.stdout.write(JSON.stringify(m) + '\n'));
|
||||
} catch (err) {
|
||||
process.stderr.write(err instanceof Error ? err.message : String(err));
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
try {
|
||||
const query = `
|
||||
query($owner: String!, $repo: String!) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
pullRequests(last: 100) {
|
||||
nodes {
|
||||
reviews(first: 50) {
|
||||
nodes {
|
||||
author { login }
|
||||
authorAssociation
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = execSync(`gh api graphql -F owner=google-gemini -F repo=gemini-cli -f query='${query}'`, { encoding: 'utf-8' });
|
||||
const data = JSON.parse(output).data.repository;
|
||||
|
||||
const reviewCounts = {};
|
||||
|
||||
for (const pr of data.pullRequests.nodes) {
|
||||
if (!pr.reviews?.nodes) continue;
|
||||
// We only count one review per author per PR to avoid counting multiple review comments as multiple reviews
|
||||
const reviewersOnPR = new Set();
|
||||
|
||||
for (const review of pr.reviews.nodes) {
|
||||
if (['MEMBER', 'OWNER'].includes(review.authorAssociation) && review.author?.login) {
|
||||
const login = review.author.login.toLowerCase();
|
||||
if (login.endsWith('[bot]') || login.includes('bot')) {
|
||||
continue; // Ignore bots
|
||||
}
|
||||
reviewersOnPR.add(review.author.login);
|
||||
}
|
||||
}
|
||||
|
||||
for (const reviewer of reviewersOnPR) {
|
||||
reviewCounts[reviewer] = (reviewCounts[reviewer] || 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
const counts = Object.values(reviewCounts);
|
||||
|
||||
let variance = 0;
|
||||
if (counts.length > 0) {
|
||||
const mean = counts.reduce((a, b) => a + b, 0) / counts.length;
|
||||
variance = counts.reduce((a, b) => a + Math.pow(b - mean, 2), 0) / counts.length;
|
||||
}
|
||||
|
||||
const timestamp = new Date().toISOString();
|
||||
|
||||
process.stdout.write(JSON.stringify({
|
||||
metric: 'review_distribution_variance',
|
||||
value: Math.round(variance * 100) / 100,
|
||||
timestamp,
|
||||
details: reviewCounts
|
||||
}) + '\n');
|
||||
} catch (err) {
|
||||
process.stderr.write(err instanceof Error ? err.message : String(err));
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
try {
|
||||
const query = `
|
||||
query($owner: String!, $repo: String!) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
pullRequests(last: 100, states: MERGED) {
|
||||
nodes {
|
||||
authorAssociation
|
||||
mergedAt
|
||||
}
|
||||
}
|
||||
issues(last: 100, states: CLOSED) {
|
||||
nodes {
|
||||
authorAssociation
|
||||
closedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = execSync(`gh api graphql -F owner=google-gemini -F repo=gemini-cli -f query='${query}'`, { encoding: 'utf-8' });
|
||||
const data = JSON.parse(output).data.repository;
|
||||
|
||||
const prs = data.pullRequests.nodes.map(p => ({
|
||||
association: p.authorAssociation,
|
||||
date: new Date(p.mergedAt).getTime()
|
||||
})).sort((a, b) => a.date - b.date);
|
||||
|
||||
const issues = data.issues.nodes.map(i => ({
|
||||
association: i.authorAssociation,
|
||||
date: new Date(i.closedAt).getTime()
|
||||
})).sort((a, b) => a.date - b.date);
|
||||
|
||||
const isMaintainer = (assoc) => ['MEMBER', 'OWNER', 'COLLABORATOR'].includes(assoc);
|
||||
|
||||
const calculateThroughput = (items) => {
|
||||
if (items.length < 2) return 0;
|
||||
const first = items[0].date;
|
||||
const last = items[items.length - 1].date;
|
||||
const days = (last - first) / (1000 * 60 * 60 * 24);
|
||||
return days > 0 ? items.length / days : items.length; // items per day
|
||||
};
|
||||
|
||||
const prOverall = calculateThroughput(prs);
|
||||
const prMaintainers = calculateThroughput(prs.filter(i => isMaintainer(i.association)));
|
||||
const prCommunity = calculateThroughput(prs.filter(i => !isMaintainer(i.association)));
|
||||
|
||||
const issueOverall = calculateThroughput(issues);
|
||||
const issueMaintainers = calculateThroughput(issues.filter(i => isMaintainer(i.association)));
|
||||
const issueCommunity = calculateThroughput(issues.filter(i => !isMaintainer(i.association)));
|
||||
|
||||
const timestamp = new Date().toISOString();
|
||||
|
||||
const metrics = [
|
||||
{ metric: 'throughput_pr_overall_per_day', value: Math.round(prOverall * 100) / 100, timestamp },
|
||||
{ metric: 'throughput_pr_maintainers_per_day', value: Math.round(prMaintainers * 100) / 100, timestamp },
|
||||
{ metric: 'throughput_pr_community_per_day', value: Math.round(prCommunity * 100) / 100, timestamp },
|
||||
{ metric: 'throughput_issue_overall_per_day', value: Math.round(issueOverall * 100) / 100, timestamp },
|
||||
{ metric: 'throughput_issue_maintainers_per_day', value: Math.round(issueMaintainers * 100) / 100, timestamp },
|
||||
{ metric: 'throughput_issue_community_per_day', value: Math.round(issueCommunity * 100) / 100, timestamp },
|
||||
{ metric: 'throughput_issue_overall_days_per_issue', value: issueOverall > 0 ? Math.round((1/issueOverall) * 100) / 100 : 0, timestamp },
|
||||
{ metric: 'throughput_issue_maintainers_days_per_issue', value: issueMaintainers > 0 ? Math.round((1/issueMaintainers) * 100) / 100 : 0, timestamp },
|
||||
{ metric: 'throughput_issue_community_days_per_issue', value: issueCommunity > 0 ? Math.round((1/issueCommunity) * 100) / 100 : 0, timestamp }
|
||||
];
|
||||
|
||||
metrics.forEach(m => process.stdout.write(JSON.stringify(m) + '\n'));
|
||||
} catch (err) {
|
||||
process.stderr.write(err instanceof Error ? err.message : String(err));
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
try {
|
||||
const query = `
|
||||
query($owner: String!, $repo: String!) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
pullRequests(last: 100) {
|
||||
nodes {
|
||||
authorAssociation
|
||||
author { login }
|
||||
createdAt
|
||||
comments(first: 20) {
|
||||
nodes {
|
||||
author { login }
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
reviews(first: 20) {
|
||||
nodes {
|
||||
author { login }
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
issues(last: 100) {
|
||||
nodes {
|
||||
authorAssociation
|
||||
author { login }
|
||||
createdAt
|
||||
comments(first: 20) {
|
||||
nodes {
|
||||
author { login }
|
||||
createdAt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = execSync(`gh api graphql -F owner=google-gemini -F repo=gemini-cli -f query='${query}'`, { encoding: 'utf-8' });
|
||||
const data = JSON.parse(output).data.repository;
|
||||
|
||||
const getFirstResponseTime = (item) => {
|
||||
const authorLogin = item.author?.login;
|
||||
let earliestResponse = null;
|
||||
|
||||
const checkNodes = (nodes) => {
|
||||
for (const node of nodes) {
|
||||
if (node.author?.login && node.author.login !== authorLogin) {
|
||||
const login = node.author.login.toLowerCase();
|
||||
if (login.endsWith('[bot]') || login.includes('bot')) {
|
||||
continue; // Ignore bots
|
||||
}
|
||||
const time = new Date(node.createdAt).getTime();
|
||||
if (!earliestResponse || time < earliestResponse) {
|
||||
earliestResponse = time;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (item.comments?.nodes) checkNodes(item.comments.nodes);
|
||||
if (item.reviews?.nodes) checkNodes(item.reviews.nodes);
|
||||
|
||||
if (earliestResponse) {
|
||||
return (earliestResponse - new Date(item.createdAt).getTime()) / (1000 * 60 * 60);
|
||||
}
|
||||
return null; // No response yet
|
||||
};
|
||||
|
||||
const processItems = (items) => {
|
||||
return items.map(item => ({
|
||||
association: item.authorAssociation,
|
||||
ttfr: getFirstResponseTime(item)
|
||||
})).filter(i => i.ttfr !== null);
|
||||
};
|
||||
|
||||
const prs = processItems(data.pullRequests.nodes);
|
||||
const issues = processItems(data.issues.nodes);
|
||||
const allItems = [...prs, ...issues];
|
||||
|
||||
const isMaintainer = (assoc) => ['MEMBER', 'OWNER'].includes(assoc);
|
||||
const is1P = (assoc) => ['COLLABORATOR'].includes(assoc);
|
||||
|
||||
const calculateAvg = (items) => items.length ? items.reduce((a, b) => a + b.ttfr, 0) / items.length : 0;
|
||||
|
||||
const maintainers = calculateAvg(allItems.filter(i => isMaintainer(i.association)));
|
||||
const firstParty = calculateAvg(allItems.filter(i => is1P(i.association)));
|
||||
const overall = calculateAvg(allItems);
|
||||
|
||||
const timestamp = new Date().toISOString();
|
||||
|
||||
const metrics = [
|
||||
{ metric: 'time_to_first_response_overall_hours', value: Math.round(overall * 100) / 100, timestamp },
|
||||
{ metric: 'time_to_first_response_maintainers_hours', value: Math.round(maintainers * 100) / 100, timestamp },
|
||||
{ metric: 'time_to_first_response_1p_hours', value: Math.round(firstParty * 100) / 100, timestamp }
|
||||
];
|
||||
|
||||
metrics.forEach(m => process.stdout.write(JSON.stringify(m) + '\n'));
|
||||
} catch (err) {
|
||||
process.stderr.write(err instanceof Error ? err.message : String(err));
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2026 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { execSync } from 'node:child_process';
|
||||
|
||||
try {
|
||||
const query = `
|
||||
query($owner: String!, $repo: String!) {
|
||||
repository(owner: $owner, name: $repo) {
|
||||
pullRequests(last: 100, states: MERGED) {
|
||||
nodes {
|
||||
authorAssociation
|
||||
comments { totalCount }
|
||||
reviews { totalCount }
|
||||
}
|
||||
}
|
||||
issues(last: 100, states: CLOSED) {
|
||||
nodes {
|
||||
authorAssociation
|
||||
comments { totalCount }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`;
|
||||
const output = execSync(`gh api graphql -F owner=google-gemini -F repo=gemini-cli -f query='${query}'`, { encoding: 'utf-8' });
|
||||
const data = JSON.parse(output).data.repository;
|
||||
|
||||
const prs = data.pullRequests.nodes;
|
||||
const issues = data.issues.nodes;
|
||||
|
||||
const allItems = [...prs.map(p => ({
|
||||
association: p.authorAssociation,
|
||||
touches: p.comments.totalCount + (p.reviews ? p.reviews.totalCount : 0)
|
||||
})), ...issues.map(i => ({
|
||||
association: i.authorAssociation,
|
||||
touches: i.comments.totalCount
|
||||
}))];
|
||||
|
||||
const isMaintainer = (assoc) => ['MEMBER', 'OWNER', 'COLLABORATOR'].includes(assoc);
|
||||
|
||||
const calculateAvg = (items) => items.length ? items.reduce((a, b) => a + b.touches, 0) / items.length : 0;
|
||||
|
||||
const overall = calculateAvg(allItems);
|
||||
const maintainers = calculateAvg(allItems.filter(i => isMaintainer(i.association)));
|
||||
const community = calculateAvg(allItems.filter(i => !isMaintainer(i.association)));
|
||||
|
||||
const timestamp = new Date().toISOString();
|
||||
|
||||
process.stdout.write(JSON.stringify({ metric: 'user_touches_overall', value: Math.round(overall * 100) / 100, timestamp }) + '\n');
|
||||
process.stdout.write(JSON.stringify({ metric: 'user_touches_maintainers', value: Math.round(maintainers * 100) / 100, timestamp }) + '\n');
|
||||
process.stdout.write(JSON.stringify({ metric: 'user_touches_community', value: Math.round(community * 100) / 100, timestamp }) + '\n');
|
||||
} catch (err) {
|
||||
process.stderr.write(err instanceof Error ? err.message : String(err));
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user