| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- import type { Locale } from "./protocol.js";
- export type GitHeadRefType = "branch" | "detached";
- export type GitChangeKind = "modified" | "added" | "deleted" | "renamed";
- export type GitChangeSourceId = "unstaged" | "staged" | "branch" | "last-turn";
- export type GitRepositoryChangeSourceId = Extract<
- GitChangeSourceId,
- "unstaged" | "staged" | "branch"
- >;
- export type GitChangeSectionId =
- | "staged"
- | "unstaged"
- | "untracked"
- | "conflicted"
- | "branch"
- | "last-turn";
- export type GitDiffAvailability = "patch" | "binary" | "truncated" | "unavailable";
- export type GitBranchMutationAction = "switch" | "create-and-switch";
- export type GitBranchMutationIssueCode =
- | "invalid-branch-name"
- | "branch-already-exists"
- | "target-branch-not-found"
- | "tracked-changes-would-be-overwritten"
- | "untracked-changes-would-be-overwritten"
- | "conflicts-present"
- | "operation-in-progress"
- | "branch-in-other-worktree"
- | "unknown";
- export interface GitRepositorySummary {
- workspacePath: string;
- repoRoot: string;
- workspaceInRepoPath: string;
- /** Git 元数据 watcher 边界;workspace 内容 watcher 由 UI 按 workspace Host 平台决定。 */
- autoRefreshWatchPaths: GitRepositoryAutoRefreshWatchPath[];
- branchName: string | null;
- trackingBranchName: string | null;
- headRefType: GitHeadRefType;
- ahead: number;
- behind: number;
- isDirty: boolean;
- isGitAvailable: boolean;
- isRepository: boolean;
- }
- export interface GitRepositoryAutoRefreshWatchPath {
- path: string;
- recursive: boolean;
- }
- export interface GitFileChange {
- path: string;
- repoRelativePath: string;
- workspaceRelativePath: string;
- x?: string;
- y?: string;
- kind: GitChangeKind;
- section: GitChangeSectionId;
- added: number;
- removed: number;
- isStaged: boolean;
- isUntracked: boolean;
- isConflicted: boolean;
- }
- export interface GitDiffRequest {
- path: string;
- staged?: boolean;
- sourceId?: GitChangeSourceId;
- }
- export interface GitDiffResult {
- path: string;
- availability: GitDiffAvailability;
- patch: string | null;
- beforeContent: string | null;
- afterContent: string | null;
- summary?: string | null;
- }
- export interface GitIdentity {
- userName: string | null;
- userEmail: string | null;
- nameSource: string | null;
- emailSource: string | null;
- scopeLabel?: string | null;
- }
- export interface GitRepositoryRequest {
- workspacePath: string;
- }
- export type GitCommitGraphRefKind = "branch" | "remote" | "tag" | "head";
- export interface GitCommitGraphRef {
- name: string;
- kind: GitCommitGraphRefKind;
- }
- export interface GitCommitGraphCommit {
- hash: string;
- parents: string[];
- refs: GitCommitGraphRef[];
- subject: string;
- authorName: string | null;
- authoredAtMs: number | null;
- }
- export interface GitCommitGraphRequest extends GitRepositoryRequest {
- maxCount?: number;
- skip?: number;
- }
- export interface GitCommitGraphResult {
- commits: GitCommitGraphCommit[];
- hasMore: boolean;
- }
- export interface GitRefreshRequest extends GitRepositoryRequest {
- includeIdentity?: boolean;
- includeBranchComparison?: boolean;
- }
- export type GitWorkspaceRepositoryKind = "not-repository" | "main-tree" | "linked-worktree";
- export interface GitWorkspaceRepositoryInfo {
- workspacePath: string;
- kind: GitWorkspaceRepositoryKind;
- isGitAvailable: boolean;
- }
- export interface GitSwitchBranchRequest extends GitRepositoryRequest {
- targetBranchName: string;
- }
- export interface GitCreateBranchRequest extends GitRepositoryRequest {
- branchName: string;
- startPoint?: string;
- }
- export interface GitChangesRequest extends GitRepositoryRequest {
- sourceId: Extract<GitRepositoryChangeSourceId, "unstaged" | "staged">;
- }
- export interface GitIgnoredPathsRequest extends GitRepositoryRequest {
- paths: string[];
- }
- export interface GitDiffQuery extends GitRepositoryRequest, GitDiffRequest {}
- export interface GitBranchComparison {
- baseRef: string | null;
- headRef: string | null;
- comparisonLabel: string | null;
- changes: GitFileChange[];
- }
- export interface GitLocalBranch {
- name: string;
- isCurrent: boolean;
- upstreamName: string | null;
- commitHash: string | null;
- commitTimestampMs: number | null;
- }
- export interface GitLocalBranchListResult {
- headRefType: GitHeadRefType;
- currentBranchName: string | null;
- branches: GitLocalBranch[];
- }
- export interface GitBranchMutationIssue {
- code: GitBranchMutationIssueCode;
- message: string;
- paths?: string[];
- detail?: string | null;
- }
- export interface GitBranchMutationResult {
- ok: boolean;
- action: GitBranchMutationAction;
- branchName: string | null;
- didChange: boolean;
- created: boolean;
- summary: GitRepositorySummary;
- issues: GitBranchMutationIssue[];
- }
- export interface GitPathMutationRequest extends GitRepositoryRequest {
- paths: string[];
- }
- export interface GitDiscardPathsRequest extends GitPathMutationRequest {
- staged?: boolean;
- }
- export interface GitCommitRequest extends GitRepositoryRequest {
- message: string;
- paths?: string[];
- stagedOnly?: boolean;
- }
- export interface GitCommitResult {
- commitHash: string;
- summary: GitRepositorySummary;
- }
- export interface GitGenerateCommitMessageRequest extends GitRepositoryRequest {
- workspaceIdentity?: string;
- locale?: Locale;
- includeUnstaged?: boolean;
- currentSessionFilePaths?: string[];
- conversationContext?: GitCommitMessageConversationContext;
- }
- export interface GitCommitMessageConversationContext {
- sessionId?: string;
- omittedMessageCount?: number;
- messages: GitCommitMessageConversationMessage[];
- }
- export interface GitCommitMessageConversationMessage {
- role: "user" | "assistant";
- content: string;
- }
- export interface GitGenerateCommitMessageResult {
- message: string;
- providerId: string;
- model: string;
- }
- export interface GitPushRequest extends GitRepositoryRequest {}
- export interface GitPushResult {
- branchName: string | null;
- trackingBranchName: string | null;
- remoteName: string | null;
- setUpstream: boolean;
- summary: GitRepositorySummary;
- }
- export interface GitRefreshResult {
- summary: GitRepositorySummary;
- identity: GitIdentity | null;
- unstagedChanges: GitFileChange[];
- stagedChanges: GitFileChange[];
- branchComparison: GitBranchComparison | null;
- }
- export type GitCheckpointScope = "workspace";
- export type GitCheckpointConflictReason =
- | "content-mismatch"
- | "missing-in-worktree"
- | "unexpected-file-in-worktree"
- | "type-mismatch";
- export interface GitCheckpointMeta {
- checkpointId: string;
- workspacePath: string;
- repoRoot: string;
- workspaceInRepoPath: string;
- createdAt: number;
- refName: string;
- commitOid: string;
- scope: GitCheckpointScope;
- }
- export interface GitCheckpointRequest extends GitRepositoryRequest {
- checkpointId: string;
- }
- export interface GitCheckpointDiffQuery extends GitRepositoryRequest {
- fromCheckpointId: string;
- toCheckpointId: string;
- }
- export interface GitCheckpointFileDiff {
- path: string;
- repoRelativePath: string;
- workspaceRelativePath: string;
- originalPath?: string | null;
- kind: GitChangeKind;
- added: number;
- removed: number;
- }
- export interface GitCheckpointDiff {
- fromCheckpointId: string;
- toCheckpointId: string;
- files: GitCheckpointFileDiff[];
- }
- export interface GitCheckpointRestoreQuery extends GitCheckpointDiffQuery {
- force?: boolean;
- }
- export interface GitCheckpointConflict {
- path: string;
- repoRelativePath: string;
- workspaceRelativePath: string;
- reason: GitCheckpointConflictReason;
- }
- export interface GitCheckpointRestoreResult {
- success: boolean;
- conflicts?: GitCheckpointConflict[];
- restoredPaths?: string[];
- }
|