UNPKG

scai

Version:

> **A local-first AI CLI for understanding, querying, and iterating on large codebases.** > **100% local • No token costs • No cloud • No prompt injection • Private by design**

44 lines (43 loc) 1.38 kB
export async function fetchOpenPullRequests(token, owner, repo) { const url = `https://api.github.com/repos/${owner}/${repo}/pulls`; const res = await fetch(url, { headers: { Authorization: `token ${token}`, Accept: "application/vnd.github.v3+json", }, }); if (!res.ok) { throw new Error(`GitHub API error: ${res.status} ${res.statusText}`); } const prs = await res.json(); return prs.map((pr) => ({ number: pr.number, title: pr.title, diff_url: pr.diff_url, })); } export async function fetchPullRequestDiff(pr, token) { const res = await fetch(pr.diff_url, { headers: { Authorization: `token ${token}`, Accept: "application/vnd.github.v3.diff", }, }); if (!res.ok) { throw new Error(`Error fetching PR diff: ${res.status} ${res.statusText}`); } return await res.text(); } export async function getGitHubUsername(token) { const res = await fetch('https://api.github.com/user', { headers: { Authorization: `token ${token}`, Accept: "application/vnd.github.v3+json", }, }); if (!res.ok) { throw new Error(`Error fetching user info: ${res.status} ${res.statusText}`); } const user = await res.json(); return user.login; // GitHub username }