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

Function getKernel

src/extraction/kernel/loader.ts:144–167  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

142 * `kernelAvailable()` / `tryKernelExtract()` which check it per call.
143 */
144export function getKernel(): KernelModule | null {
145 if (cached !== undefined) return cached;
146 cached = null;
147 for (const candidate of candidatePaths()) {
148 try {
149 if (!fs.existsSync(candidate)) continue;
150 // createRequire: works identically from CJS output and future ESM.
151 const req = createRequire(__filename);
152 const mod = req(candidate) as KernelModule;
153 if (typeof mod.extractFile !== 'function' || typeof mod.contractInfo !== 'function') {
154 debug(`${candidate}: missing expected exports — ignoring`);
155 continue;
156 }
157 if (!verifyContract(mod, candidate)) continue;
158 kernelLanguages = new Set(mod.contractInfo().languages);
159 debug(`loaded ${candidate} (languages: ${[...kernelLanguages].join(', ')})`);
160 cached = mod;
161 break;
162 } catch (err) {
163 debug(`${candidate}: failed to load — ${err instanceof Error ? err.message : String(err)}`);
164 }
165 }
166 return cached;
167}
168
169/** True when the kill switch is off, a verified binary is loaded, and it supports `language`. */
170export function kernelSupports(language: string): boolean {

Calls 5

candidatePathsFunction · 0.85
verifyContractFunction · 0.85
contractInfoMethod · 0.80
debugFunction · 0.70
joinMethod · 0.45

Tested by

no test coverage detected