abhigyanpatwari/GitNexus · error · Error

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

Error message

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

What it means

Thrown at the start of `fullGeneration` when, after querying the knowledge graph for all files and filtering out ignored paths, zero source files remain. The wiki generator has nothing to document — no file exports, no module tree, no symbol pages. This indicates the graph is empty, contains only non-source files, or all files were filtered by `shouldIgnorePath`.

Source

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

    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 d540b00184)

Solutions

  1. Run `gitnexus analyze` first to populate the knowledge graph, then retry `gitnexus wiki`.
  2. Run `gitnexus status` to verify the graph has symbols and files indexed.
  3. If the graph appears populated but all files are filtered, check `.gitnexusignore` or the `shouldIgnorePath` rules — your source directories may be excluded.
  4. If the graph is corrupt, run `gitnexus analyze --force` for a full rebuild.

Example fix

# before
gitnexus wiki
# error: No source files found in the knowledge graph. Nothing to document.
# after
gitnexus analyze    # populate the graph first
gitnexus status     # verify files are indexed
gitnexus wiki       # now has source files to document
Defensive patterns

Strategy: validation

Validate before calling

// Before wiki generation, verify the graph has source files:
const allFiles = await getAllFiles();
const sourceFiles = allFiles.filter((f) => !shouldIgnorePath(f));
if (sourceFiles.length === 0) {
  console.error('No source files in the graph. Run `gitnexus analyze` first.');
  process.exit(1);
}

Type guard

const hasSourceFilesInGraph = async (): Promise<boolean> => {
  const files = await getAllFiles();
  return files.some((f) => !shouldIgnorePath(f));
};

Try / catch

try {
  await generator.generate();
} catch (err) {
  if (err instanceof Error && err.message.includes('No source files found in the knowledge graph')) {
    console.error('Run `gitnexus analyze` to populate the graph, then retry `gitnexus wiki`.');
  }
  throw err;
}

Prevention

When it happens

Trigger: `getAllFiles()` returns files, but `allFiles.filter((f) => !shouldIgnorePath(f))` results in an empty array. Or `getAllFiles()` itself returns an empty array because the graph was never populated or was corrupted.

Common situations: Running `gitnexus wiki` on a repository that was never analyzed (empty graph); analyzing a repo where all files are in ignored directories (e.g., everything under `node_modules` or `vendor/`); a corrupt or partially-written graph where the files table is empty; analyzing a non-code repository (documentation-only, binary-only).

Related errors


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