* fix(wiki): group files again on --force and when many new files arrive buildModuleTree reads module_tree.json first, as the tree a user edited during --review, but every completed generation also writes that file for the HTML viewer. --force and the "significant new files" path only deleted first_module_tree.json, so since --review came in (#381) both reused the previous tree instead of grouping again. On the new-files path, fullGeneration then skipped every page already on disk and wrote only the overview: the new files, and the files changed in the same commits, were not documented. discardSavedGrouping now drops module_tree.json as well when it still holds the tree meta.json records, that is, the last generation's output. A tree edited since then, or written before any generation, is kept, so --review --force still generates the tree as reviewed. On the new-files path, removeStalePages deletes the pages of modules whose files changed, their parent pages and the pages of modules that are gone. The generation writes the missing pages and keeps the rest. * test(wiki): size the sub-module fixture so any split gives one page per version * fix(wiki): ignore key order when telling an edited module tree from a saved one A module_tree.json whose keys a tool only reordered is the tree the last generation saved, so --force and a regrouping run drop it as well. * test(wiki): turn commit signing off in the regroup fixture and mark its copied helper * fix(wiki): make a regrouping safe to resume and limit it to new indexed files A run that groups an existing wiki's files again now records the regrouping in meta.json (commit, tree, pages kept) before it deletes any page. The next run at that commit completes it from the recorded tree; a run at another commit deletes the pages it may have written and writes those modules again. module_tree.json is skipped in memory rather than deleted, so a failed run leaves it and the viewer as they were. Only changed paths the graph indexes, at paths that did not exist at the last generation, count as new files. Diffs are read with -z, so paths with non-ASCII names match the graph. The run that follows --review generates the approved tree as it is, even when it equals the previous one. Stale pages are judged against the previous tree (slug, name, files, sub-modules), and only pages of the two trees are deleted. A review-only run leaves index.html alone. --------- Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
5.9 KiB
Wiki generation
Generate LLM-powered documentation from your knowledge graph:
# Requires an LLM API key (MINIMAX_API_KEY, ANTHROPIC_API_KEY, GITNEXUS_API_KEY or OPENAI_API_KEY)
gitnexus wiki
gitnexus wiki --api-key <key> # or pass the key on the command line
# Use a custom model or provider (default model: MiniMax-M3)
gitnexus wiki --model gpt-4o
gitnexus wiki --base-url https://api.anthropic.com/v1
gitnexus wiki --provider anthropic # Anthropic Messages API (default model: claude-opus-5-5)
gitnexus wiki --provider grok # local Grok Build CLI (uses `grok login`, no API key)
# Providers: minimax, anthropic, openai, openrouter, azure, custom,
# and the local agent CLIs cursor, claude, codex, opencode and grok
# Azure OpenAI with a legacy deployment URL also needs an api-version
gitnexus wiki --provider azure --api-version 2024-10-21 \
--base-url https://<resource>.openai.azure.com/openai/deployments/<deployment>
# Turn reasoning mode on or off. MiniMax-M3 uses adaptive thinking unless
# --no-reasoning-model is set; o1, o3 and their -mini or -preview models are detected.
gitnexus wiki --reasoning-model
gitnexus wiki --no-reasoning-model
# Force full regeneration
gitnexus wiki --force
# Run more LLM calls in parallel (default: 3)
gitnexus wiki --concurrency 6
# Increase the timeout or retries for large codebases or slow LLM providers
gitnexus wiki --timeout <seconds> # LLM request timeout in seconds (default: disabled)
gitnexus wiki --retries <n> # Max LLM retry attempts per request (default: 3)
# Raise the completion-token limit (default: 16384)
gitnexus wiki --max-completion-tokens 131072
GITNEXUS_MAX_COMPLETION_TOKENS=131072 gitnexus wiki
# Or set "maxCompletionTokens": 131072 in ~/.gitnexus/config.json
# Precedence: flag, then the environment variable, then the config file.
# Allow a specific LAN/self-hosted HTTP LLM host (HTTPS is preferred for remote endpoints)
gitnexus wiki --base-url http://llama-box.local:8080/v1 --allow-insecure-connection llama-box.local
# Or set a comma-separated host allowlist:
GITNEXUS_ALLOW_INSECURE_CONNECTION=llama-box.local,192.168.1.23
# Change the output language
gitnexus wiki --lang <lang> # e.g. english, chinese, spanish, japanese
# Review the module structure before any page is generated
gitnexus wiki --review
# Print the commands and responses of a local agent CLI provider
gitnexus wiki --provider claude --verbose
# Publish the wiki as a public GitHub Gist after generation (needs the GitHub CLI, `gh`)
gitnexus wiki --gist
--provider, --model, --base-url, --api-key, --api-version and --reasoning-model
are saved to ~/.gitnexus/config.json, so later runs reuse them without the flags. The API
key is stored there as plain text. Switching to another --provider clears the saved key,
base URL, model, api-version and reasoning setting. --api-version is appended to requests
only for Azure: --provider azure or an Azure OpenAI base URL.
--review stops after modules are grouped. It prints the module tree, saves it as
module_tree.json in the wiki output folder, and asks whether to continue. Answer edit to
open the file in $EDITOR (or $VISUAL, else vi) and generate pages from the edited tree,
or n to stop. In a non-interactive shell, generation continues without asking.
--force groups the files into modules again before regenerating every page, unless
module_tree.json was edited since the last generation; an edit is used for the next
generation only. A run that finds more than five new source files since the last generation
(files the knowledge graph indexes, at paths that did not exist then) also groups the files
again, or uses an edited tree the same way. It then rewrites only the pages of modules whose
files changed and deletes the pages of modules that are gone; other .md files in the wiki
folder are left alone. If such a run stops before the end, the next run at the same commit
completes it, and a run at another commit writes again the pages it changed.
The completion limit must be a positive integer supported by your model. It applies to
OpenAI-compatible HTTP providers; local agent CLI providers manage their own limits.
For reasoning models, the limit includes reasoning tokens as well as the visible answer.
When a provider reports finish_reason: "length", GitNexus rejects the incomplete response
instead of saving it as a finished page. Failed modules are listed, the command exits with
status 1, and a normal rerun retries them even if the repository commit has not changed.
Increase --max-completion-tokens within your model's supported limit before retrying.
Truncated grouping or overview responses also fail the run; batched grouping retains its
directory-based fallback. Incomplete runs are not published with --gist.
Use --force to replace incomplete pages already saved by an older version.
For safety, http:// LLM base URLs are allowed by default only for loopback hosts (localhost, 127.0.0.1, ::1). --allow-insecure-connection and GITNEXUS_ALLOW_INSECURE_CONNECTION accept exact hostnames or IP addresses only; do not include schemes, ports, paths, credentials, or wildcards.
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.
A module whose source does not fit one page (30,000 tokens) is split by directory, below the
directory its files share, so a Gradle or Maven module is split at its packages
(src — main/entity). Small neighbouring directories share a page up to the same size, and so
do the files sitting directly in a directory (top-level files (1 of 2)), so only a single file
larger than a page is cut. A module of three files or fewer stays on one page. IntelliJ project
files (.iml, .ipr, .iws) and Gradle lockfiles are not indexed, so they get no page.