get_index_status
Verify if a codebase is indexed for AI search. Returns file count, chunk count, and indexed languages to confirm readiness.
Instructions
Check if a codebase is indexed and ready for search. USE THIS to verify index exists before searching. Returns file count, chunk count, and indexed languages.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | No | Path to the directory to check (defaults to current directory) | . |
Implementation Reference
- Main handler function that validates the directory, checks if an index exists, connects to the vector store, retrieves status (file count, chunk count, language breakdown), and returns a formatted result.
export async function execute( input: GetIndexStatusInput, ): Promise<FeatureResult> { const { directory } = input; // Validate directory exists if (!fs.existsSync(directory)) { return { success: false, error: `Directory not found: ${directory}`, }; } const absoluteDir = path.resolve(directory); const indexPath = getIndexPath(absoluteDir); // Check if index exists if (!fs.existsSync(indexPath)) { const status: IndexStatus = { directory: absoluteDir, indexPath, exists: false, totalChunks: 0, totalFiles: 0, languages: {}, }; return { success: true, message: `No index found for ${absoluteDir}. Run index_codebase to create one.`, data: status, }; } try { const vectorStore = createVectorStore(absoluteDir, EMBEDDING_CONFIG); await vectorStore.connect(); const status = await vectorStore.getStatus(absoluteDir); vectorStore.close(); // Format language breakdown const languageLines = Object.entries(status.languages) .sort(([, a], [, b]) => b - a) .map(([lang, count]) => ` - ${lang}: ${String(count)} chunks`); const message = [ `Index Status for ${absoluteDir}`, ``, `Index Path: ${status.indexPath}`, `Total Files: ${String(status.totalFiles)}`, `Total Chunks: ${String(status.totalChunks)}`, ``, `Languages:`, ...languageLines, ].join("\n"); return { success: true, message, data: status, }; } catch (err) { const errorMsg = err instanceof Error ? err.message : String(err); return { success: false, error: `Failed to read index status: ${errorMsg}`, }; } } - Zod schema defining the input: an optional directory string defaulting to '.'.
export const getIndexStatusSchema = z.object({ directory: z .string() .optional() .default(".") .describe("Path to the directory to check (defaults to current directory)"), }); - src/features/get-index-status/index.ts:105-111 (registration)Feature registration object: name 'get_index_status', description, schema reference, and execute function reference.
export const getIndexStatusFeature: Feature<typeof getIndexStatusSchema> = { name: "get_index_status", description: "Check if a codebase is indexed and ready for search. USE THIS to verify index exists before searching. Returns file count, chunk count, and indexed languages.", schema: getIndexStatusSchema, execute, }; - src/features/index.ts:23-29 (registration)Feature registry array listing getIndexStatusFeature as one of five exposed features.
export const features: Feature[] = [ infoFeature, indexCodebaseFeature, searchCodeFeature, getIndexStatusFeature, updateIndexFeature, ]; - src/core/embeddings/store.ts:401-404 (helper)Helper function that constructs the .src-index path for a given directory.
*/ export function getIndexPath(directory: string): string { return path.join(directory, INDEX_DIR_NAME); }