(project: ProjectState)
| 676 | } |
| 677 | |
| 678 | async 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 | |
| 711 | async function validateResolvedProjectPath(rootPath: string): Promise<ToolResponse | undefined> { |
| 712 | try { |
no test coverage detected