costgrep-cli 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "costgrep-cli",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "GitHub Actions cost breakdown: human vs AI agent vs bot. Zero-dependency CLI + composite action.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -22,7 +22,7 @@ import { parseArgs } from 'node:util';
22
22
 
23
23
  const API = process.env.COSTGREP_API || 'https://api.github.com'; // env override exists for local-mock verification only
24
24
  const HTTP_TIMEOUT = Math.max(1_000, parseInt(process.env.COSTGREP_TIMEOUT_MS, 10) || 30_000);
25
- const VERSION = '0.7.6'; // keep in sync with package.json
25
+ const VERSION = '0.7.7'; // keep in sync with package.json
26
26
 
27
27
  // ---------------------------------------------------------------------------
28
28
  // Rate matrix — GitHub-hosted runners, list prices effective 2026-01-01.
@@ -183,7 +183,14 @@ async function gh(path, token) {
183
183
  throw new Error(`GitHub API rate limited on ${path} (403/429). Pass --token or narrow --days/--max-runs.`);
184
184
  }
185
185
  if (!res.ok) throw new Error(`GitHub API ${res.status} on ${path}: ${(await res.text()).slice(0, 300)}`);
186
- return res.json();
186
+ try {
187
+ return await res.json();
188
+ } catch (e) {
189
+ if (e.name === 'TimeoutError' || e.name === 'AbortError') {
190
+ throw new Error(`GitHub API timeout reading body of ${path} after ${HTTP_TIMEOUT / 1000}s (set COSTGREP_TIMEOUT_MS to override)`);
191
+ }
192
+ throw new Error(`invalid JSON from ${path}: ${e.message}`);
193
+ }
187
194
  }
188
195
  }
189
196