import { Octokit } from "@octokit/rest"; let octokit: Octokit | null = null; export function initGitHub(token?: string) { octokit = new Octokit({ auth: token || process.env.GITHUB_TOKEN }); } export async function getRendererFile(path: string) { if (!octokit) throw new Error("GitHub not initialized"); const { data } = await octokit.repos.getContent({ owner: "NishikantaRay", repo: "renderer", path, ref: "main" }); if (!("content" in data)) { throw new Error("Not a file"); } const content = Buffer.from(data.content, "base64").toString(); return { content: [{ type: "text" as const, text: `# ${path}\n\n\`\`\`\n${content}\n\`\`\`` }] }; }