From fe79087d7a35c6f9e627d05cb965bf0e2d7adef0 Mon Sep 17 00:00:00 2001 From: mkorwel Date: Wed, 18 Mar 2026 11:38:39 -0700 Subject: [PATCH] perf(workspaces): use GraphQL for instantaneous fork discovery --- .gemini/skills/workspaces/scripts/setup.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.gemini/skills/workspaces/scripts/setup.ts b/.gemini/skills/workspaces/scripts/setup.ts index 8bea819eea..a491918a78 100644 --- a/.gemini/skills/workspaces/scripts/setup.ts +++ b/.gemini/skills/workspaces/scripts/setup.ts @@ -93,13 +93,22 @@ and full builds) to a dedicated, high-performance GCP worker. console.log(` - Upstream identified: ${upstreamRepo}`); console.log(` - Searching for your forks of ${upstreamRepo}...`); - // Use gh api to find forks specifically linked to the upstream, which is much more accurate const upstreamOwner = upstreamRepo.split('/')[0]; const upstreamName = upstreamRepo.split('/')[1]; - const userRes = spawnSync('gh', ['api', 'user', '-q', '.login'], { stdio: 'pipe' }); - const currentUser = userRes.stdout.toString().trim(); - const forksRes = spawnSync('gh', ['api', `/repos/${upstreamOwner}/${upstreamName}/forks`, '--paginate', '-q', `.[] | select(.owner.login == "${currentUser}") | .full_name`], { stdio: 'pipe' }); + // Use GraphQL to find your forks specifically. This is much faster than REST pagination. + const gqlQuery = `query { + viewer { + repositories(first: 100, isFork: true, affiliations: OWNER) { + nodes { + nameWithOwner + parent { nameWithOwner } + } + } + } + }`; + + const forksRes = spawnSync('gh', ['api', 'graphql', '-f', `query=${gqlQuery}`, '--jq', `.data.viewer.repositories.nodes[] | select(.parent.nameWithOwner == "${upstreamRepo}") | .nameWithOwner`], { stdio: 'pipe' }); const myForks = forksRes.stdout.toString().trim().split('\n').filter(Boolean); if (myForks.length > 0) {