abhigyanpatwari/GitNexus · error · Error

No source files found in the knowledge graph. Nothing to…

Error message

No source files found in the knowledge graph. Nothing to document.

What it means

During full wiki generation the generator queries the LadybugDB knowledge graph for all files, filters out ignored paths via shouldIgnorePath, and throws if zero source files remain. It is a precondition failure: the wiki pipeline documents source files, so an empty (or all-ignored) graph means there is nothing to document and continuing would produce an empty wiki.

Solutions

  1. Index the repo first: `gitnexus analyze` from the repo root, then rerun `gitnexus wiki`
  2. Verify the index actually has files: `gitnexus status` (or `gitnexus query` for any symbol) to confirm the graph is non-empty
  3. Check that you are running in the same directory that was indexed and that ignore rules are not excluding every source file
  4. If the index is corrupt/empty, rebuild it (`gitnexus clean` then `gitnexus analyze`)

Example fix

# before
gitnexus wiki   # ERROR: No source files found

# after
gitnexus analyze
gitnexus wiki
Defensive patterns

Strategy: validation

Validate before calling

// Run before wiki generation:
import { execFileSync } from 'child_process';
const status = JSON.parse(execFileSync('gitnexus', ['status', '--json'], { encoding: 'utf8' }));
if (!status.symbols || status.symbols === 0) {
  throw new Error('Index empty — run `gitnexus analyze` before generating the wiki');
}

Try / catch

try {
  await generator.generate();
} catch (err) {
  if (err instanceof Error && err.message.includes('No source files found')) {
    await runAnalyze(); // build the index, then retry once
    return generator.generate();
  }
  throw err;
}

Prevention

When it happens

Trigger: Running `gitnexus wiki` before `gitnexus analyze` has indexed the repo; running it against the wrong working directory (no index there); the index only contains files excluded by shouldIgnorePath (build output, vendored dirs, docs-only trees); a corrupt or wiped LadybugDB database.

Common situations: Fresh clone where the user runs the wiki command first; running from a subdirectory that is not the indexed repo root; index built in a previous CI job but not present locally; path-ignore rules (or a .gitnexus ignore config) that exclude the whole tree.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@52924ef12c (2026-08-20). Data as JSON: /api/errors/bb0192827509a36b. Report an issue: GitHub.

Appendix: source

Thrown at gitnexus/src/core/wiki/generator.ts:359

    this.onProgress('html', 98, 'Building HTML viewer...');
    const repoName = path.basename(this.repoPath);
    await generateHTMLViewer(this.wikiDir, repoName);
  }

  // ─── Full Generation ────────────────────────────────────────────────

  private async fullGeneration(currentCommit: string): Promise<WikiRunResult> {
    let pagesGenerated = 0;

    // Phase 0: Gather structure
    this.onProgress('gather', 5, 'Querying graph for file structure...');
    const filesWithExports = await getFilesWithExports();
    const allFiles = await getAllFiles();

    // Filter to source files only
    const sourceFiles = allFiles.filter((f) => !shouldIgnorePath(f));
    if (sourceFiles.length === 0) {
      throw new Error('No source files found in the knowledge graph. Nothing to document.');
    }

    // Build enriched file list (merge exports into all source files)
    const exportMap = new Map(filesWithExports.map((f) => [f.filePath, f]));
    const enrichedFiles: FileWithExports[] = sourceFiles.map((fp) => {
      return exportMap.get(fp) || { filePath: fp, symbols: [] };
    });

    this.onProgress('gather', 10, `Found ${sourceFiles.length} source files`);

    // Phase 1: Build module tree
    const moduleTree = await this.buildModuleTree(enrichedFiles);
    pagesGenerated = 0;

    // If reviewOnly mode, save tree and stop for user to review/edit
    if (this.options.reviewOnly) {
      await this.saveModuleTree(moduleTree);
      this.onProgress('review', 30, 'Module tree ready for review');

View on GitHub (pinned to 52924ef12c)