diff --git a/README.md b/README.md index 3c3a28c27..e08c0eb7d 100644 --- a/README.md +++ b/README.md @@ -722,6 +722,12 @@ gitnexus wiki --base-url https://api.anthropic.com/v1 # Force full regeneration gitnexus wiki --force + + +# Increase the timeout or retries for large codebase or slow LLM providers +gitnexus wiki --timeout # Per-attempt LLM request timeout in seconds (default: 60) +gitnexus wiki --retries # Max LLM retry attempts per request (default: 3) + ``` The wiki generator reads the indexed graph structure, groups files into modules via LLM, generates per-module documentation pages, and creates an overview page — all with cross-references to the knowledge graph. diff --git a/gitnexus-claude-plugin/skills/gitnexus-cli/SKILL.md b/gitnexus-claude-plugin/skills/gitnexus-cli/SKILL.md index 1c38face4..11945b8cc 100644 --- a/gitnexus-claude-plugin/skills/gitnexus-cli/SKILL.md +++ b/gitnexus-claude-plugin/skills/gitnexus-cli/SKILL.md @@ -62,6 +62,8 @@ Generates repository documentation from the knowledge graph using an LLM. Requir | `--api-key ` | LLM API key | | `--concurrency ` | Parallel LLM calls (default: 3) | | `--gist` | Publish wiki as a public GitHub Gist | +| `--timeout ` | Per-attempt LLM request timeout in seconds (default: 60) | +| `--retries ` | Max LLM retry attempts per request (default: 3) | ### list — Show all indexed repos diff --git a/gitnexus/src/cli/index.ts b/gitnexus/src/cli/index.ts index d38675f03..4b009e4aa 100644 --- a/gitnexus/src/cli/index.ts +++ b/gitnexus/src/cli/index.ts @@ -161,6 +161,8 @@ program ) .option('--no-reasoning-model', 'Disable reasoning model mode (overrides saved config)') .option('--concurrency ', 'Parallel LLM calls (default: 3)', '3') + .option('--timeout ', 'Per-attempt LLM request timeout in seconds (default: 60)') + .option('--retries ', 'Max LLM retry attempts per request (default: 3)') .option('--gist', 'Publish wiki as a public GitHub Gist after generation') .option('-v, --verbose', 'Enable verbose output (show LLM commands and responses)') .option('--review', 'Stop after grouping to review module structure before generating pages') diff --git a/gitnexus/src/cli/wiki.ts b/gitnexus/src/cli/wiki.ts index 38a0f82a6..8d9da9572 100644 --- a/gitnexus/src/cli/wiki.ts +++ b/gitnexus/src/cli/wiki.ts @@ -33,6 +33,8 @@ export interface WikiCommandOptions { provider?: LLMProvider; verbose?: boolean; review?: boolean; + timeout?: string; + retries?: string; } /** @@ -347,6 +349,16 @@ export const wikiCommand = async (inputPath?: string, options?: WikiCommandOptio } } + // ── Apply per-run overrides not saved to config ──────────────────── + if (options?.timeout) { + const secs = parseInt(options.timeout, 10); + if (!isNaN(secs) && secs > 0) llmConfig.requestTimeoutMs = secs * 1000; + } + if (options?.retries) { + const n = parseInt(options.retries, 10); + if (!isNaN(n) && n > 0) llmConfig.maxAttempts = n; + } + // ── Setup progress bar with elapsed timer ────────────────────────── const bar = new cliProgress.SingleBar( { diff --git a/gitnexus/src/core/wiki/llm-client.ts b/gitnexus/src/core/wiki/llm-client.ts index 37fe7a9f2..40ef831bf 100644 --- a/gitnexus/src/core/wiki/llm-client.ts +++ b/gitnexus/src/core/wiki/llm-client.ts @@ -23,6 +23,10 @@ export interface LLMConfig { apiVersion?: string; /** When true, strips sampling params and uses max_completion_tokens instead of max_tokens */ isReasoningModel?: boolean; + /** Per-attempt fetch timeout in ms (default: 60_000). */ + requestTimeoutMs?: number; + /** Max fetch attempts before giving up (default: 3). */ + maxAttempts?: number; } export interface LLMResponse { @@ -237,12 +241,12 @@ export async function callLLM( // indefinitely on a frozen TCP connection — the per-call // signal is the only timeout `resilientFetch` honors; // `capDelayMs` only bounds the *backoff* between attempts. - // 60s matches typical LLM completion budgets. - signal: AbortSignal.timeout(60_000), + // Default 60s; raise via --timeout for slow models or large pages. + signal: AbortSignal.timeout(config.requestTimeoutMs ?? 60_000), }, { breakerKey: `wiki-llm-${new URL(url).host}`, - retry: { maxAttempts: 3, baseDelayMs: 2_000, capDelayMs: 30_000 }, + retry: { maxAttempts: config.maxAttempts ?? 3, baseDelayMs: 2_000, capDelayMs: 30_000 }, }, ); } catch (err) {