hikma-engine
Version:
Code Knowledge Graph Indexer - A sophisticated TypeScript-based indexer that transforms Git repositories into multi-dimensional knowledge stores for AI agents
128 lines (127 loc) • 5.29 kB
JavaScript
;
// Compatibility layer for old db-clients imports
// This provides the old interface using the new SQLiteClient
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SQLiteClient = void 0;
const connection_1 = require("./db/connection");
/**
* Legacy SQLiteClient wrapper that provides backward compatibility
* while using the new architecture underneath
*/
class SQLiteClient extends connection_1.SQLiteClient {
// Add any legacy methods that are still needed
// Batch operations for backward compatibility
async batchInsertFiles(files) {
let success = 0;
let failed = 0;
const errors = [];
this.transaction(() => {
for (const file of files) {
try {
this.run(`INSERT OR REPLACE INTO files (id, repo_id, file_path, file_name, file_extension, language, size_kb, content_hash, file_type, ai_summary, imports, exports, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)`, [
file.id,
file.repoId,
file.filePath,
file.fileName,
file.fileExtension || null,
file.language || null,
file.sizeKb || null,
file.contentHash || null,
file.fileType || null,
file.aiSummary || null,
file.imports ? JSON.stringify(file.imports) : null,
file.exports ? JSON.stringify(file.exports) : null
]);
success++;
}
catch (error) {
failed++;
errors.push(`Failed to insert file ${file.id}: ${error}`);
}
}
});
return { success, failed, errors };
}
// Add other batch methods as needed
async batchInsertRepositories(repos) {
let success = 0;
let failed = 0;
const errors = [];
this.transaction(() => {
for (const repo of repos) {
try {
this.run(`INSERT OR REPLACE INTO repositories (id, repo_path, repo_name, created_at, updated_at)
VALUES (?, ?, ?, ?, ?)`, [repo.id, repo.repoPath, repo.repoName, repo.createdAt || new Date().toISOString(), repo.lastUpdated || new Date().toISOString()]);
success++;
}
catch (error) {
failed++;
errors.push(`Failed to insert repository ${repo.id}: ${error}`);
}
}
});
return { success, failed, errors };
}
// Add other legacy methods as needed for compatibility
async batchInsertCodeNodes(nodes) {
return { success: 0, failed: 0, errors: [] }; // Stub for now
}
async batchInsertTestNodes(nodes) {
return { success: 0, failed: 0, errors: [] }; // Stub for now
}
async batchInsertFunctions(funcs) {
return { success: 0, failed: 0, errors: [] }; // Stub for now
}
async batchInsertCommits(commits) {
return { success: 0, failed: 0, errors: [] }; // Stub for now
}
async batchInsertPullRequests(prs) {
return { success: 0, failed: 0, errors: [] }; // Stub for now
}
async batchInsertEnhancedGraphNodes(nodes) {
return { success: 0, failed: 0, errors: [] }; // Stub for now
}
async batchInsertEnhancedGraphEdges(edges) {
return { success: 0, failed: 0, errors: [] }; // Stub for now
}
async getEnhancedGraphStats() {
return {
nodeCount: 0,
edgeCount: 0,
nodeTypes: {},
edgeTypes: {},
repoBreakdown: {},
fileLanguages: {},
functionComplexity: { avgLoc: 0, maxLoc: 0, totalFunctions: 0 }
};
}
// Override getIndexingStats to include missing properties
async getIndexingStats() {
const baseStats = await super.getIndexingStats();
return {
...baseStats,
totalCodeNodes: 0, // TODO: Implement when we have code nodes
totalTestNodes: 0, // TODO: Implement when we have test nodes
totalPullRequests: 0, // TODO: Implement when we have pull requests
};
}
}
exports.SQLiteClient = SQLiteClient;
// Re-export other commonly used items
__exportStar(require("./db/vector"), exports);
__exportStar(require("./db/stats"), exports);