MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / printIndexResult

Function printIndexResult

src/bin/codegraph.ts:469–592  ·  view source on GitHub ↗

* Print indexing results using clack log methods

(clack: typeof import('@clack/prompts'), result: IndexResult, projectPath?: string)

Source from the content-addressed store, hash-verified

467 * Print indexing results using clack log methods
468 */
469function printIndexResult(clack: typeof import('@clack/prompts'), result: IndexResult, projectPath?: string): void {
470 const hasErrors = result.filesErrored > 0;
471 const parseWarnings = result.errors.filter((e) => e.code === 'parse_error' && e.severity === 'warning');
472
473 // Surface non-file-level failures (e.g. lock-acquisition failure
474 // when another indexer is running) before the file-count branches.
475 // Without this the CLI falls through to "No files found to index",
476 // which is actively misleading — the index DID run, it just couldn't
477 // get the lock.
478 //
479 // If success is false but no severity:'error' entry exists in
480 // `result.errors` (degenerate case — shouldn't happen in practice
481 // but worth guarding because the result shape is plumbed through
482 // multiple call sites), fall back to a generic message rather than
483 // continuing to the misleading "No files found" branch or throwing.
484 if (!result.success && !hasErrors && result.filesIndexed === 0) {
485 const generic = result.errors.find((e) => e.severity === 'error');
486 clack.log.error(generic?.message ?? `Indexing failed ${getGlyphs().dash} no further details available`);
487 return;
488 }
489
490 if (result.filesIndexed > 0) {
491 if (hasErrors) {
492 clack.log.success(`Indexed ${formatNumber(result.filesIndexed)} files (${formatNumber(result.filesErrored)} could not be parsed)`);
493 } else {
494 clack.log.success(`Indexed ${formatNumber(result.filesIndexed)} files`);
495 }
496 clack.log.info(`${formatNumber(result.nodesCreated)} nodes, ${formatNumber(result.edgesCreated)} edges in ${formatDuration(result.durationMs)}`);
497 // Warning-only parse failures keep indexing successful, but must be visible.
498 for (const warning of parseWarnings) {
499 clack.log.warn(warning.message);
500 }
501 // A PARTIAL index (files silently dropped mid-pipeline) must not pass
502 // as a clean run — it's the difference between "indexed the repo" and
503 // "indexed most of the repo, quietly". Only the completeness
504 // reconciliation warning; per-file extractor warnings stay in the
505 // error-code summary below.
506 for (const w of result.errors.filter((e) => e.code === 'index_partial')) {
507 clack.log.warn(w.message);
508 }
509 // Files salvaged from comment-stripped source after repeated parser
510 // failures are indexed but possibly incomplete — say so here, or the run
511 // reads as fully clean and the index quietly disagrees with a later
512 // re-parse of the same bytes (#1565).
513 // Files over the size limit are stored without being parsed. That is on
514 // purpose, and it used to be silent: "Indexed 1,678 files" with one of
515 // them, 37,000 lines of hand-written source, holding no symbol at all.
516 const oversize = describeOversizeFiles(
517 result.errors
518 .filter((e) => e.code === 'size_exceeded' && e.filePath)
519 .map((e) => ({ path: e.filePath!, size: Number(/\((\d+) > \d+\)/.exec(e.message)?.[1] ?? 0) })),
520 );
521 if (oversize) clack.log.warn(oversize);
522 const salvaged = result.errors.filter((e) => e.code === 'salvaged_stripped');
523 if (salvaged.length > 0) {
524 const sample = salvaged.slice(0, 3).map((e) => e.filePath).filter(Boolean).join(', ');
525 const more = salvaged.length > 3 ? ', ...' : '';
526 clack.log.warn(`${formatNumber(salvaged.length)} file(s) indexed from comment-stripped source after repeated parse failures ${getGlyphs().dash} symbols may be incomplete (${sample}${more})`);

Callers 3

offerIndexIgnoredReposFunction · 0.85
runInitFunction · 0.85
mainFunction · 0.85

Calls 15

getGlyphsFunction · 0.90
getCodeGraphDirFunction · 0.90
formatDurationFunction · 0.85
describeOversizeFilesFunction · 0.85
NumberInterface · 0.85
writeErrorLogFunction · 0.85
infoMethod · 0.80
warnMethod · 0.80
mapMethod · 0.80
fromMethod · 0.80
formatNumberFunction · 0.70
errorMethod · 0.65

Tested by

no test coverage detected