UNPKG

@ace-sdk/cli

Version:

ACE CLI - Command-line tool for intelligent pattern learning and playbook management

106 lines 3.27 kB
/** * Git Context Service for AI-Trail Pattern Correlation * * Detects git context from the current working directory for * correlating execution traces with commits. * * @package @ace-sdk/cli * @since v2.2.0 * @see https://github.com/ce-dot-net/ace-sdk/issues/16 */ import type { GitContext } from '@ace-sdk/core'; /** * Service for detecting git context from the current working directory. * * Provides graceful fallback when not in a git repository. * All git commands use child_process.execSync for consistency * with existing patterns in the codebase. */ export declare class GitContextService { private cwd; private cachedContext; private cacheTimestamp; private readonly cacheTtlMs; /** * Create a new GitContextService * * @param cwd Working directory (defaults to process.cwd()) * @param cacheTtlMs Cache TTL in milliseconds (defaults to 60000 = 1 minute) */ constructor(cwd?: string, cacheTtlMs?: number); /** * Check if current directory is a git repository */ isGitRepository(): boolean; /** * Get current HEAD commit hash */ getCurrentHead(): string | null; /** * Get current branch name */ getBranch(): string | null; /** * Get commit message for a given commit (first line) */ getCommitMessage(commitHash?: string): string | null; /** * Get commit timestamp in ISO 8601 format */ getCommitTimestamp(commitHash?: string): string | null; /** * Get commit author name */ getCommitAuthor(commitHash?: string): string | null; /** * Get commit author email */ getCommitAuthorEmail(commitHash?: string): string | null; /** * Get files changed in a commit */ getChangedFiles(commitHash?: string): string[]; /** * Get parent commit hashes */ getParentCommits(commitHash?: string): string[]; /** * Get insertions and deletions for a commit */ getCommitStats(commitHash?: string): { insertions: number; deletions: number; } | null; /** * Detect full git context from current working directory. * * Returns null if not in a git repository. * Caches result for cacheTtlMs to avoid repeated git calls. * * @param commitHash Optional specific commit (defaults to HEAD) * @param includePrivate Include author email (default: false for privacy) */ detectContext(commitHash?: string, includePrivate?: boolean): GitContext | null; /** * Get commits made since a specific time. * Useful for finding commits made during a session. * * @param since Date to search from * @param limit Maximum commits to return (default: 10) */ getCommitsSince(since: Date, limit?: number): GitContext[]; /** * Clear the cached context */ clearCache(): void; } /** * Create a GitContextService for the current directory */ export declare function createGitContextService(cwd?: string): GitContextService; /** * Convenience function to detect git context from cwd. * Returns null if not in a git repository. */ export declare function detectGitContext(cwd?: string): GitContext | null; //# sourceMappingURL=git-context.d.ts.map