GitNexus/gitnexus/src/cli
Copilot 9d015164a5
fix: actionable HF_ENDPOINT guidance, retries, timeout and circuit breaker when embedding model download fails (#1419)
* Initial plan

* fix: surface actionable HF_ENDPOINT guidance on embedding model download failure

When `gitnexus analyze --embeddings` fails because huggingface.co is
unreachable (e.g. the GFW, corporate proxies), the error was shown as a
raw `TypeError: fetch failed` with no actionable guidance.

Changes:
- `hf-env.ts`: add and export `isNetworkFetchError()` helper that
  detects network-level fetch errors (fetch failed, ECONNREFUSED,
  ENOTFOUND, ETIMEDOUT, ECONNRESET)
- `core/embeddings/embedder.ts`: in the device-fallback loop, detect
  network errors and rethrow immediately with a message telling the user
  to set HF_ENDPOINT to a mirror (hf-mirror.com) — device fallback is
  meaningless for network errors that will fail on every device
- `mcp/core/embedder.ts`: same fix for the MCP embedder entry point
- `cli/analyze.ts`: add a new error branch that detects fetch/network
  failures and prints a concrete 3-step remediation hint (HF_ENDPOINT,
  proxy/VPN, offline caching)
- `test/unit/hf-env.test.ts`: add 8 unit tests covering all five
  network error patterns and three negative cases

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/3e314b1c-ca74-44d5-9913-c1418d4e160a

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* refactor: use isNetworkFetchError helper in analyze.ts to eliminate duplication

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/3e314b1c-ca74-44d5-9913-c1418d4e160a

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* feat: add retry, timeout and circuit breaker for HF model download

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/6e6f509a-e4d5-4d1f-b0de-b2d30e0a0dce

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* style: apply prettier formatting to changed files

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/cda38cc4-1c18-4be8-8d7b-e5f00dceaa22

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix: address all adversarial review findings (duplicate output, env overrides, tests, Windows note)

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/eb1b4f9a-79da-4084-8f7b-dc056d2f7e5a

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* refactor: extract resolved env-var defaults to named variables for clarity

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/eb1b4f9a-79da-4084-8f7b-dc056d2f7e5a

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix: add upper bound clamping and unit tests for HF env override parsing

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/198700cc-4191-4ac1-94ec-33d61f2a99f7

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* style: use consistent 99_999 threshold notation in env override tests

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/198700cc-4191-4ac1-94ec-33d61f2a99f7

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix: remove pipeline as any cast; type progress callback with ProgressInfo; remove unused HF_DOWNLOAD_TIMEOUT_MS import

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/43e60ccd-6f01-4cec-8ee3-c22e8b000efe

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix: add safe fallback for progress_total status mapping in typed progress callback

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/43e60ccd-6f01-4cec-8ee3-c22e8b000efe

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
2026-05-08 08:53:13 +01:00
..
ai-context.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
analyze.ts fix: actionable HF_ENDPOINT guidance, retries, timeout and circuit breaker when embedding model download fails (#1419) 2026-05-08 08:53:13 +01:00
augment.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
clean.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
cli-message.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
doctor.ts fix: add platform-aware semantic fallback (#1150) 2026-04-28 12:21:25 +01:00
eval-server.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
group.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
index-repo.ts fix(cli): keep GitNexus ignores inside .gitnexus (#1248) 2026-05-01 16:46:05 +01:00
index.ts feat: add optional limit arg to --embeddings flag (closes #382) (#1375) 2026-05-06 16:31:28 +01:00
lazy-action.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
list.ts feat(cli): analyze --name <alias> + duplicate-name guard for the repo registry (#955) 2026-04-19 07:23:48 +01:00
mcp.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
optional-grammars.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
remove.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
serve.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
setup.ts fix(security): close URL/regex/tag-filter sanitization cluster (U7) (#1330) 2026-05-08 07:11:29 +01:00
skill-gen.ts feat: configure eslint with unused import removal (#564) 2026-03-28 15:28:09 +00:00
status.ts feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
tool.ts feat(core): adopt pino structured logger (#1336) 2026-05-07 20:56:25 +01:00
wiki.ts fix(security): close URL/regex/tag-filter sanitization cluster (U7) (#1330) 2026-05-08 07:11:29 +01:00