UNPKG

hikma-engine

Version:

Code Knowledge Graph Indexer - A sophisticated TypeScript-based indexer that transforms Git repositories into multi-dimensional knowledge stores for AI agents

68 lines (67 loc) 2.55 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Indexer = void 0; const logger_1 = require("../utils/logger"); const error_handling_1 = require("../utils/error-handling"); const PhaseManager_1 = require("./PhaseManager"); class Indexer { constructor(projectRoot, config) { this.errors = []; this.projectRoot = projectRoot; this.config = config; this.logger = (0, logger_1.getLogger)('Indexer'); this.phaseManager = new PhaseManager_1.PhaseManager(projectRoot, config); } async run(options = {}) { const startTime = Date.now(); this.logger.info('Starting hikma-engine indexing pipeline', { projectRoot: this.projectRoot, options, startTime, }); try { // Initialize phase manager await this.phaseManager.initialize(); // Convert indexing options to phase manager options const phaseOptions = { runPhases: options.runPhases, fromPhase: options.fromPhase, forcePhases: options.forcePhases, inspectPhase: options.inspectPhase, showStatus: options.showStatus, skipAISummary: options.skipAISummary, skipEmbeddings: options.skipEmbeddings, dryRun: options.dryRun }; // Execute phases const result = await this.phaseManager.executePhases(phaseOptions); // Create a sanitized result for logging, removing the verbose 'data' field const resultForLogging = { ...result, phases: result.phases.map(({ data, ...phase }) => phase), }; this.logger.info('Indexing pipeline completed successfully', resultForLogging); return result; } catch (error) { (0, error_handling_1.logError)(this.logger, 'Indexing pipeline failed', error); this.errors.push((0, error_handling_1.getErrorMessage)(error)); throw error; } finally { await this.phaseManager.cleanup(); } } createResult(startTime, totalNodes, totalEdges, processedFiles, isIncremental) { return { totalNodes, totalEdges, processedFiles, isIncremental, duration: Date.now() - startTime, phases: [], errors: [...this.errors], }; } } exports.Indexer = Indexer;