MCPcopy Create free account
hub / github.com/PatrickSys/codebase-context / ensureValidIndexOrAutoHeal

Function ensureValidIndexOrAutoHeal

src/index.ts:678–709  ·  view source on GitHub ↗
(project: ProjectState)

Source from the content-addressed store, hash-verified

676}
677
678async function ensureValidIndexOrAutoHeal(project: ProjectState): Promise<IndexSignal> {
679 if (project.indexState.status === 'indexing') {
680 return {
681 status: 'indexing',
682 confidence: 'low',
683 action: 'served',
684 reason: 'Indexing in progress'
685 };
686 }
687
688 try {
689 return await requireValidIndex(project.rootPath, project.paths);
690 } catch (error) {
691 if (error instanceof IndexCorruptedError) {
692 const reason = error.message;
693 console.error(`[Index] ${reason}`);
694 console.error('[Auto-Heal] Triggering background re-index...');
695
696 // Fire-and-forget: don't block the tool call
697 void performIndexing(project);
698
699 return {
700 status: 'indexing',
701 confidence: 'low',
702 action: 'rebuild-started',
703 reason: `Auto-heal triggered: ${reason}`
704 };
705 }
706
707 throw error;
708 }
709}
710
711async function validateResolvedProjectPath(rootPath: string): Promise<ToolResponse | undefined> {
712 try {

Callers 1

registerHandlersFunction · 0.85

Calls 2

requireValidIndexFunction · 0.85
performIndexingFunction · 0.70

Tested by

no test coverage detected