| 19 | 'Use this tool instead of chromium for all GitHub repo access — it has authenticated access to private repos and gists.'; |
| 20 | |
| 21 | async function ghApi(...args: string[]): Promise<any> { |
| 22 | debug('gh api', args); |
| 23 | try { |
| 24 | const { stdout } = await execFileAsync('gh', ['api', ...args], { |
| 25 | timeout: 30_000, |
| 26 | maxBuffer: 10 * 1024 * 1024 |
| 27 | }); |
| 28 | debug('gh api response:', stdout.slice(0, 200) + (stdout.length > 200 ? '...' : '')); |
| 29 | return JSON.parse(stdout); |
| 30 | } catch (err: any) { |
| 31 | const msg = err.stderr?.trim() || err.message; |
| 32 | debug('gh api error:', msg); |
| 33 | throw new Error(`gh api failed: ${msg}`); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | export default { |
| 38 | definition: { |