MCPcopy Create free account
hub / github.com/cortexkit/magic-context / loadPiConfigDetailed

Function loadPiConfigDetailed

packages/pi-plugin/src/config/index.ts:443–566  ·  view source on GitHub ↗
(
	opts: LoadPiConfigOptions = {},
)

Source from the content-addressed store, hash-verified

441}
442
443export function loadPiConfigDetailed(
444 opts: LoadPiConfigOptions = {},
445): LoadPiConfigResultDetailed {
446 const cwd = opts.cwd ?? process.cwd();
447 const loadedFiles: LoadedConfigFile[] = [];
448 const warnings: string[] = [];
449 const legacySources = resolveLegacyConfigSources(cwd);
450 const harnessLegacy = resolveLegacyConfigSourcesForHarness(cwd, "pi");
451
452 const projectPath = resolveFirstExisting(getProjectConfigPaths(cwd));
453 const projectLegacyFallback = projectPath
454 ? null
455 : resolvePiLegacyFallback(harnessLegacy.project);
456 const projectReadPath = projectPath ?? projectLegacyFallback?.path;
457 if (projectReadPath) {
458 const loaded = loadConfigFile(projectReadPath, "project");
459 if (loaded) loadedFiles.push(loaded);
460 }
461 const legacyProjectUnmigrated =
462 !projectPath &&
463 !projectLegacyFallback &&
464 legacySources.project.some((source) => existsSync(source.path));
465
466 const userPath = resolveFirstExisting(getUserConfigPaths());
467 const userLegacyFallback = userPath
468 ? null
469 : resolvePiLegacyFallback(harnessLegacy.user);
470 const userReadPath = userPath ?? userLegacyFallback?.path;
471 if (userReadPath) {
472 const loaded = loadConfigFile(userReadPath, "user");
473 if (loaded) loadedFiles.push(loaded);
474 }
475 const legacyUserUnmigrated =
476 !userPath &&
477 !userLegacyFallback &&
478 legacySources.user.some((source) => existsSync(source.path));
479
480 if (userLegacyFallback) {
481 warnings.push(
482 `[user config] reading legacy config from ${userLegacyFallback.path} until migration completes; run \`npx @cortexkit/magic-context doctor\` to consolidate into the shared CortexKit location.`,
483 );
484 } else if (legacyUserUnmigrated) {
485 warnings.push(
486 "[user config] legacy Magic Context config exists but the shared CortexKit config is absent; embedding registration is paused until config migration completes.",
487 );
488 }
489
490 if (projectLegacyFallback) {
491 warnings.push(
492 `[project config] reading legacy config from ${projectLegacyFallback.path} until migration completes; run \`npx @cortexkit/magic-context doctor\` to consolidate into the shared CortexKit location.`,
493 );
494 } else if (legacyProjectUnmigrated) {
495 warnings.push(
496 "[project config] legacy Magic Context config exists but the shared CortexKit config is absent; embedding registration is paused until config migration completes.",
497 );
498 }
499
500 let rawConfig: Record<string, unknown> = {};

Callers 2

index.test.tsFile · 0.90

Calls 12

resolveFirstExistingFunction · 0.85
getProjectConfigPathsFunction · 0.85
resolvePiLegacyFallbackFunction · 0.85
loadConfigFileFunction · 0.85
getUserConfigPathsFunction · 0.85
mergeRawConfigsFunction · 0.85
parsePiConfigFunction · 0.85
combinedOutcomeFunction · 0.70

Tested by

no test coverage detected