(cg: CodeGraph, projectRoot: string)
| 93 | } |
| 94 | |
| 95 | export function buildStats(cg: CodeGraph, projectRoot: string): unknown { |
| 96 | const stats = cg.getStats(); |
| 97 | const build = cg.getIndexBuildInfo(); |
| 98 | |
| 99 | return { |
| 100 | project: { |
| 101 | root: projectRoot, |
| 102 | name: path.basename(projectRoot) || projectRoot, |
| 103 | }, |
| 104 | index: { |
| 105 | /** |
| 106 | * `complete` is the only good value. `indexing` means a run was killed |
| 107 | * part-way and the graph on disk is a truncated one; `partial`/`failed` |
| 108 | * mean the run finished but dropped files. `null` predates the marker. |
| 109 | */ |
| 110 | state: cg.getIndexState(), |
| 111 | lastIndexedAt: cg.getLastIndexedAt(), |
| 112 | /** Built by an older extractor — a re-index would add data no migration can. */ |
| 113 | stale: cg.isIndexStale(), |
| 114 | version: build.version, |
| 115 | extractionVersion: build.extractionVersion, |
| 116 | backend: cg.getBackend(), |
| 117 | journalMode: cg.getJournalMode(), |
| 118 | /** References still waiting to resolve; > 0 means edges are still missing. */ |
| 119 | pendingReferences: cg.getPendingReferenceCount(), |
| 120 | generatedFiles: cg.getGeneratedFileCount(), |
| 121 | watching: cg.isWatching(), |
| 122 | watcherDegraded: cg.isWatcherDegraded(), |
| 123 | }, |
| 124 | graph: { |
| 125 | nodes: stats.nodeCount, |
| 126 | edges: stats.edgeCount, |
| 127 | files: stats.fileCount, |
| 128 | nodesByKind: stats.nodesByKind, |
| 129 | edgesByKind: stats.edgesByKind, |
| 130 | filesByLanguage: stats.filesByLanguage, |
| 131 | dbSizeBytes: stats.dbSizeBytes, |
| 132 | walSizeBytes: stats.walSizeBytes, |
| 133 | }, |
| 134 | frameworks: cg.getDetectedFrameworks(), |
| 135 | /** |
| 136 | * The thresholds the API itself applied, so the viewer's copy ("hub · N", |
| 137 | * "confidence < 0.6") stays in step with the data instead of hard-coding a |
| 138 | * second copy of the same numbers. |
| 139 | */ |
| 140 | thresholds: { hub: HUB_THRESHOLD, uncertainBelow: UNCERTAIN_BELOW }, |
| 141 | /** |
| 142 | * The denominator the Symbol view's blast bar is drawn against, so one |
| 143 | * symbol's radius reads as wide or narrow *for this repo* instead of as a |
| 144 | * bare number. See {@link blastScaleFor} for what "sampled" costs and |
| 145 | * concedes. |
| 146 | */ |
| 147 | blastScale: blastScaleFor(cg, projectRoot, stats.edgeCount), |
| 148 | }; |
| 149 | } |
no test coverage detected