hikma-engine
Version:
Code Knowledge Graph Indexer - A sophisticated TypeScript-based indexer that transforms Git repositories into multi-dimensional knowledge stores for AI agents
114 lines • 4.37 kB
TypeScript
/**
* @file Analyzes Git repository history to extract commit information and track file evolution.
* Creates CommitNodes and PullRequestNodes with their relationships to files and other commits.
* Supports incremental analysis by processing only new commits since the last indexed state.
*/
import { CommitNode, PullRequestNode, Edge, FileNode } from '../types';
import { ConfigManager } from '../config';
/**
* Analyzes Git repository history and extracts commit-related information.
*/
export declare class GitAnalyzer {
private projectRoot;
private config;
private logger;
private git;
private nodes;
private edges;
private sqliteClient;
/**
* @param {string} projectRoot - The absolute path to the root of the project.
* @param {ConfigManager} config - Configuration manager instance.
*/
constructor(projectRoot: string, config: ConfigManager);
/**
* Returns the list of extracted nodes.
* @returns {(CommitNode | PullRequestNode)[]} An array of nodes.
*/
getNodes(): (CommitNode | PullRequestNode)[];
/**
* Returns the list of extracted edges.
* @returns {Edge[]} An array of edges.
*/
getEdges(): Edge[];
/**
* Gets the current HEAD commit hash.
* @returns {Promise<string | null>} The current commit hash or null if not found.
*/
getCurrentCommitHash(): Promise<string | null>;
/**
* Gets the last indexed commit hash from the database.
* @returns {Promise<string | null>} The last indexed commit hash or null if not found.
*/
getLastIndexedCommit(): Promise<string | null>;
/**
* Sets the last indexed commit hash in the database.
* @param {string} commitHash - The commit hash to store.
* @returns {Promise<void>}
*/
setLastIndexedCommit(commitHash: string): Promise<void>;
/**
* Gets the list of files that have changed between two commits.
* @param {string} fromCommit - The starting commit hash.
* @param {string} toCommit - The ending commit hash.
* @returns {Promise<string[]>} Array of changed file paths.
*/
getChangedFiles(fromCommit: string, toCommit: string): Promise<string[]>;
/**
* Creates a unique ID for a commit node.
* @param {string} hash - The commit hash.
* @returns {string} A unique identifier.
*/
private createCommitNodeId;
/**
* Creates a unique ID for a pull request node.
* @param {string} prId - The pull request ID.
* @returns {string} A unique identifier.
*/
private createPullRequestNodeId;
/**
* Extracts commit information and creates CommitNodes.
* @param {string | null} sinceCommit - Optional commit hash to start from (for incremental analysis).
* @returns {Promise<void>}
*/
private extractCommits;
/**
* Gets a summary of changes in a commit.
* @param {string} commitHash - The commit hash.
* @returns {Promise<string>} A summary of the changes.
*/
private getCommitDiffSummary;
/**
* Creates edges between commits and the files they modified.
* @param {FileNode[]} fileNodes - Array of file nodes to link with commits.
* @returns {Promise<void>}
*/
private createCommitFileEdges;
/**
* Creates mock pull request nodes (placeholder for future GitHub/GitLab integration).
* @returns {Promise<void>}
*/
private createMockPullRequests;
/**
* Analyzes the Git repository and extracts commit and pull request information.
* @param {FileNode[]} fileNodes - Array of file nodes to link with commits.
* @param {string | null} lastIndexedCommit - The last indexed commit hash for incremental analysis.
* @returns {Promise<void>}
*/
analyzeRepo(fileNodes: FileNode[], lastIndexedCommit?: string | null): Promise<void>;
/**
* Gets statistics about the analyzed nodes by type.
* @returns {Record<string, number>} Node type statistics.
*/
private getNodeTypeStats;
/**
* Gets repository statistics.
* @returns {Promise<{totalCommits: number, authors: string[], latestCommit: string | null}>}
*/
getRepoStats(): Promise<{
totalCommits: number;
authors: string[];
latestCommit: string | null;
}>;
}
//# sourceMappingURL=git-analyzer.d.ts.map