import { MorphGitConfig, CloneOptions, PushOptions, PullOptions, WaitForEmbeddingsOptions, AddOptions, CommitOptions, StatusOptions, LogOptions, CommitObject, CheckoutOptions, BranchOptions, StatusResult, MorphNotesSchema } from './types.js'; import { MorphAPIClient } from '../core/client.js'; import { APIResource } from '../core/resource.js'; import 'isomorphic-git'; import 'isomorphic-git/http/node'; import '../tools/utils/resilience.js'; /** * Morph Git Client - Simple, high-level Git operations * Built on isomorphic-git with explicit configuration */ /** * MorphGit - Git operations for AI agents with Morph backend * * @example * ```typescript * import { MorphGit } from 'morphsdk/git'; * * const morphGit = new MorphGit({ * apiKey: process.env.MORPH_API_KEY!, * proxyUrl: 'https://repos.morphllm.com' // Optional * }); * * await morphGit.init({ repoId: 'my-project', dir: './my-project' }); * await morphGit.push({ dir: './my-project' }); * ``` * * @deprecated Prefer the unified `MorphClient` (`new MorphClient({ apiKey }).git`). * Standalone clients remain only for backwards compatibility and may be removed in a future * major version — do not use them in new code. */ declare class MorphGit extends APIResource { private readonly apiKey; private readonly proxyUrl; constructor(clientOrConfig: MorphAPIClient | MorphGitConfig); /** * Get auth callback for isomorphic-git operations * @private */ private getAuthCallback; /** * Initialize a new repository * Creates the repo in the database and in the git provider * * @example * ```ts * await morphGit.init({ * repoId: 'my-project', * dir: './my-project', * defaultBranch: 'main' * }); * ``` */ init(options: { repoId: string; dir: string; defaultBranch?: string; }): Promise; /** * Clone a repository from Morph repos * * @example * ```ts * await morphGit.clone({ * repoId: 'my-project', * dir: './my-project' * }); * ``` */ clone(options: CloneOptions): Promise; /** * Push changes to remote repository * * @example * ```ts * await morphGit.push({ * dir: './my-project', * branch: 'main', // Required: explicit branch name * index: true // Optional: generate embeddings for semantic search * }); * ``` */ push(options: PushOptions): Promise; /** * Configure commit settings on the backend after push. * Sets the index flag to control embedding generation. * @private */ private configureCommit; /** * Pull changes from remote repository * * @example * ```ts * await morphGit.pull({ * dir: './my-project', * branch: 'main' // Required: explicit branch name * }); * ``` */ pull(options: PullOptions): Promise; /** * Wait for embeddings to complete after push. * Polls status endpoint until embeddings are done. * * @example * ```ts * await morphGit.push({ dir: './my-project', branch: 'main' }); * await morphGit.waitForEmbeddings({ * repoId: 'my-project', * onProgress: (p) => console.log(`${p.filesProcessed}/${p.totalFiles}`) * }); * ``` */ waitForEmbeddings(options: WaitForEmbeddingsOptions): Promise; /** * Stage a file for commit * * @example * ```ts * await morphGit.add({ * dir: './my-project', * filepath: 'src/app.ts' * }); * ``` */ add(options: AddOptions): Promise; /** * Remove a file from staging * * @example * ```ts * await morphGit.remove({ * dir: './my-project', * filepath: 'src/old-file.ts' * }); * ``` */ remove(options: AddOptions): Promise; /** * Commit staged changes * * @example * ```ts * await morphGit.commit({ * dir: './my-project', * message: 'Add new feature', * author: { * name: 'AI Agent', * email: 'ai@example.com' * }, * metadata: { issueId: 'PROJ-123', source: 'agent' }, * chatHistory: [ * { role: 'user', content: 'Please add a new feature' }, * { role: 'assistant', content: 'I will add that feature' } * ], * recordingId: 'rec_123' * }); * ``` */ commit(options: CommitOptions): Promise; /** * Get status of a file * * @example * ```ts * const status = await morphGit.status({ * dir: './my-project', * filepath: 'src/app.ts' * }); * console.log(status); // 'modified', '*added', etc. * ``` */ status(options: StatusOptions): Promise; /** * Get commit history * * @example * ```ts * const commits = await morphGit.log({ * dir: './my-project', * depth: 10 * }); * ``` */ log(options: LogOptions): Promise; /** * Checkout a branch or commit * * @example * ```ts * await morphGit.checkout({ * dir: './my-project', * ref: 'feature-branch' * }); * ``` */ checkout(options: CheckoutOptions): Promise; /** * Create a new branch * * @example * ```ts * await morphGit.branch({ * dir: './my-project', * name: 'feature-branch', * checkout: true * }); * ``` */ branch(options: BranchOptions): Promise; /** * List all branches * * @example * ```ts * const branches = await morphGit.listBranches({ * dir: './my-project' * }); * ``` */ listBranches(options: { dir: string; }): Promise; /** * Get the current branch name * * @example * ```ts * const branch = await morphGit.currentBranch({ * dir: './my-project' * }); * ``` */ currentBranch(options: { dir: string; }): Promise; /** * Get list of changed files (similar to git diff --name-only) * * @example * ```ts * const changes = await morphGit.statusMatrix({ * dir: './my-project' * }); * ``` */ statusMatrix(options: { dir: string; }): Promise; /** * Get the current commit hash * * @example * ```ts * const hash = await morphGit.resolveRef({ * dir: './my-project', * ref: 'HEAD' * }); * ``` */ resolveRef(options: { dir: string; ref: string; }): Promise; /** * Get notes (metadata, chat history, recording ID) attached to a commit * * @example * ```ts * const notes = await morphGit.getCommitMetadata({ * dir: './my-project', * commitSha: 'abc123...' * }); * * if (notes) { * console.log('Metadata:', notes.metadata); * console.log('Chat history:', notes.chatHistory); * console.log('Recording ID:', notes.recordingId); * } * ``` */ getCommitMetadata(options: { dir: string; commitSha: string; }): Promise; } export { MorphGit };