@debugg-ai/cli
Version:
CLI tool for running DebuggAI tests in CI/CD environments
201 lines • 5.93 kB
TypeScript
import { CodebaseContext } from '../repo-handlers/types/codebaseContext';
export interface WorkingChange {
status: string;
file: string;
diff?: string;
}
export interface CommitInfo {
hash: string;
message: string;
author: string;
date: string;
files: string[];
diff: string;
}
export interface BranchInfo {
branch: string;
commitHash: string;
}
export interface WorkingChanges {
changes: WorkingChange[];
branchInfo: BranchInfo;
}
export interface GitAnalyzerOptions {
repoPath: string;
ignoredFolders?: string[];
}
export interface PRCommitInfo {
hash: string;
message: string;
author: string;
date: string;
changes: WorkingChange[];
order: number;
}
export interface PRCommitSequence {
baseBranch: string;
headBranch: string;
commits: PRCommitInfo[];
totalCommits: number;
prNumber?: number;
}
/**
* Git analyzer for CI/CD environments like GitHub Actions
* Simplified version of the commitTester.ts logic
*/
export declare class GitAnalyzer {
private git;
private repoPath;
private ignoredFolders;
private contextExtractor;
constructor(options: GitAnalyzerOptions);
/**
* Enhanced file filtering - excludes non-code project files
* Only includes files that actually affect the UI/application behavior
*/
private isUIRelevantFile;
/**
* Get current branch information
*/
getCurrentBranchInfo(): Promise<BranchInfo>;
/**
* Get working changes (uncommitted changes)
*/
getWorkingChanges(): Promise<WorkingChanges>;
/**
* Get changes for a specific commit
*/
getCommitChanges(commitHash: string): Promise<WorkingChanges>;
/**
* Get list of commits from a range specification
*/
getCommitsFromRange(range: string): Promise<string[]>;
/**
* Get commits since a specific date
*/
getCommitsSince(since: string): Promise<string[]>;
/**
* Get last N commits
*/
getLastCommits(count: number): Promise<string[]>;
/**
* Combine changes from multiple commits
*/
getCombinedCommitChanges(commitHashes: string[]): Promise<WorkingChanges>;
/**
* Get detailed information about a commit
*/
getCommitInfo(commitHash: string): Promise<CommitInfo | null>;
/**
* Get the latest commit hash
*/
getLatestCommitHash(): Promise<string>;
/**
* Get repository name in GitHub format (owner/repo)
* Falls back to directory name if remote is not available
*/
getRepoName(): string;
/**
* Get the remote URL for origin
*/
private getRemoteUrl;
/**
* Extract owner/repo from various git URL formats
*/
private extractRepoNameFromUrl;
/**
* Check if we should ignore a file based on ignored folders and UI relevance
*/
private shouldIgnoreFile;
/**
* Get recent commits (useful for understanding recent changes)
*/
getRecentCommits(count?: number): Promise<CommitInfo[]>;
/**
* Validate that we're in a git repository
*/
validateGitRepo(): Promise<boolean>;
/**
* Get enhanced codebase context for better test generation
* Integrates the proven repo-handlers workflow
*/
getEnhancedContext(workingChanges: WorkingChanges): Promise<CodebaseContext | null>;
/**
* Get minimal context for performance-critical scenarios
*/
getMinimalContext(workingChanges: WorkingChanges): Promise<CodebaseContext | null>;
/**
* Get context extraction statistics
*/
getContextStats(context: CodebaseContext | null): {
filesAnalyzed: number;
totalSizeKB: number;
architecturalPatterns: number;
focusAreas: number;
};
/**
* Get changes between two commits or branches
*/
getChangesBetween(from: string, to: string): Promise<WorkingChange[]>;
/**
* Enhanced context analysis inspired by CodebaseAnalyzer patterns
* Analyzes changes to provide better insights for test generation
*/
analyzeChangesWithContext(changes: WorkingChange[]): Promise<{
totalFiles: number;
fileTypes: Record<string, number>;
componentChanges: string[];
routingChanges: string[];
configChanges: string[];
testChanges: string[];
affectedLanguages: string[];
changeComplexity: 'low' | 'medium' | 'high';
suggestedFocusAreas: string[];
}>;
/**
* Check if file is a component (similar to CodebaseAnalyzer patterns)
*/
private isComponentFile;
/**
* Check if file is related to routing
*/
private isRoutingFile;
/**
* Check if file is a configuration file
*/
private isConfigFile;
/**
* Check if file is a test file
*/
private isTestFile;
/**
* Get language name from file extension
*/
private getLanguageFromExtension;
/**
* Analyze PR commits for sequential testing
* Detects GitHub PR context from environment variables or commit range
*/
analyzePRCommitSequence(baseBranch?: string | undefined, headBranch?: string | undefined): Promise<PRCommitSequence | null>;
/**
* Detect PR context from GitHub Actions environment variables
*/
private detectPRContext;
/**
* Extract PR number from GitHub environment variables
*/
private extractPRNumber;
/**
* Get PR number from current context (useful for external callers)
*/
getPRNumber(): number | null;
/**
* Get commits that exist in head branch but not in base branch
*/
private getUniqueCommitsInBranch;
/**
* Check if current context is a PR (has unique commits to analyze)
*/
isPRContext(baseBranch?: string | undefined, headBranch?: string | undefined): Promise<boolean>;
}
//# sourceMappingURL=git-analyzer.d.ts.map