# API Contract The frontend calls Tauri commands with `@tauri-apps/api/core.invoke`. ## Shared payloads ```ts type FileStatusKind = "modified" | "added" | "deleted" | "renamed" | "untracked" | "conflicted" | "unknown"; interface GitStatus { repo_path: string; current_branch: string | null; upstream: string | null; ahead: number; behind: number; files: GitFileStatus[]; clean: boolean; rebase_in_progress: boolean; cherry_pick_in_progress: boolean; merge_in_progress: boolean; } interface GitFileStatus { path: string; old_path: string | null; staged: FileStatusKind | null; unstaged: FileStatusKind | null; } interface GitBranch { name: string; current: boolean; remote: boolean; } interface GitWorktree { path: string; head: string | null; short_head: string | null; branch: string | null; bare: boolean; detached: boolean; locked: boolean; lock_reason: string | null; prunable: boolean; prune_reason: string | null; missing: boolean; is_main: boolean; is_current: boolean; clean: boolean; changed_files: number; } interface GitCommit { hash: string; short_hash: string; summary: string; author_name: string; author_email: string; date: string; refs: string[]; files: GitCommitFile[]; } interface GitCommitFile { path: string; old_path: string | null; status: FileStatusKind; } interface GitRepositoryFile { path: string; tracked: boolean; status: FileStatusKind | null; } ``` ## Commands The command list below includes the repository-management and synchronization API. The TypeScript wrappers in `src/lib/git.ts` are the authoritative full list. - `open_repository(path: string): Promise` - `init_repository(path: string, initialBranch?: string): Promise` - `clone_repository(...): Promise` - `get_status(path: string): Promise` - `list_branches(path: string): Promise` - `list_remotes(path: string): Promise` - `add_remote(path: string, name: string, url: string): Promise` - `update_remote(path: string, name: string, url: string): Promise` - `remove_remote(path: string, name: string): Promise` - `set_branch_upstream(path: string, branch: string, upstream?: string): Promise` - `delete_remote_branch(path: string, remote: string, branch: string): Promise` - `checkout_branch(path: string, branch: string): Promise` - `list_worktrees(path: string): Promise` - `add_worktree(path: string, worktreePath: string, ...): Promise` - `remove_worktree(path: string, worktreePath: string, force?: boolean): Promise` - `move_worktree(path: string, worktreePath: string, destination: string): Promise` - `lock_worktree(path: string, worktreePath: string, reason?: string): Promise` - `unlock_worktree(path: string, worktreePath: string): Promise` - `prune_worktrees(path: string): Promise` - `repair_worktree(path: string, worktreePath: string): Promise` - `stage_files(path: string, files: string[]): Promise` - `unstage_files(path: string, files: string[]): Promise` - `restore_files(path: string, files: string[], staged: boolean): Promise` - `commit(path: string, message: string): Promise` - `fetch(path: string, prune?: boolean, remote?: string): Promise` - `pull(path: string, strategy?: "merge" | "rebase" | "ff-only", remote?: string, branch?: string): Promise` - `push(path: string, forceWithLease?: boolean, remote?: string): Promise` - `list_commits(path: string, limit?: number, skip?: number): Promise` - `restore_to_commit(path: string, commit: string): Promise` - `restore_file_from_commit(path: string, commit: string, file: string): Promise` (the `file` argument can also be a folder path) - `merge_branch(path: string, branch: string, strategy?: "default" | "squash" | "ff-only" | "no-ff"): Promise` - `merge_continue(path: string): Promise` - `merge_abort(path: string): Promise` - `revert_commit(path: string, commit: string): Promise` - `list_repository_files(path: string): Promise` - `list_file_history(path: string, file: string, limit?: number): Promise` (the `file` argument can also be a folder path)