@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
68 lines • 2.62 kB
TypeScript
/**
* A single Git commit entry parsed from `git log` output.
*/
export interface GitCommit {
/** Full commit SHA */
hash: string;
/** Commit author date as a Date object */
date: Date;
/** Author name */
author: string;
/** Commit subject line */
message: string;
}
/**
* Read-only utility for reading Git history of filesystem-stored JSON files.
*
* All operations are performed by shelling out to the `git` CLI via
* `child_process.execFile` (no third-party dependencies). This class never
* writes to Git — the user manages their own commits.
*
* Designed as a singleton shared across all domain helpers via a static field
* on `FilesystemVersionedHelpers`.
*/
export declare class GitHistory {
/** Cache: dir → repo root (string) or `false` if not a repo. */
private repoRootCache;
/** Cache: `dir:filename:limit` → ordered commits (newest first). */
private commitCache;
/** Cache: `dir:commitHash:filename` → parsed JSON. */
private snapshotCache;
/**
* Returns `true` if `dir` is inside a Git repository.
* Result is cached after the first call per directory.
*/
isGitRepo(dir: string): Promise<boolean>;
/**
* Get the list of commits that touched a specific file, newest first.
* Returns an empty array if Git is unavailable or the file has no history.
*
* @param dir Absolute path to the storage directory
* @param filename The JSON filename relative to `dir` (e.g., 'agents.json')
* @param limit Maximum number of commits to retrieve
*/
getFileHistory(dir: string, filename: string, limit?: number): Promise<GitCommit[]>;
/**
* Read and parse a JSON file at a specific Git commit.
* Returns the parsed entity map, or `null` if the file didn't exist at that commit.
*
* @param dir Absolute path to the storage directory
* @param commitHash Full or abbreviated commit SHA
* @param filename The JSON filename relative to `dir` (e.g., 'agents.json')
*/
getFileAtCommit<T = Record<string, Record<string, unknown>>>(dir: string, commitHash: string, filename: string): Promise<T | null>;
/**
* Invalidate all caches. Call after external operations that change Git state
* (e.g., the user commits or pulls).
*/
invalidateCache(): void;
/**
* Get the relative path from the Git repo root to a file in the storage directory.
*/
private relativeToRepo;
/**
* Execute a git command and return stdout.
*/
private exec;
}
//# sourceMappingURL=git-history.d.ts.map