{"modulePath":"github.com/thewei/solco-gitkit","version":"v0.3.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package gitworkbench\n\n\\[INPUT]: Git refs/heads and refs/remotes via Runner.Read; Git's branch validation and mutation semantics. \\[OUTPUT]: Branch/RemoteBranch models, local and remote-tracking ref discovery, safe switch/create. \\[POS]: Git domain reference boundary, read-only remote enumeration never contacts network. \\[PROTOCOL]: 变更时更新此头部，然后检查 CLAUDE.md\n\nPackage gitworkbench owns Solco's local Git review model: one command runner, repository facts, working-tree change snapshots, a clean-room patch parser, word diff, changed-file trees, commit transactions and branch switching. It supersedes internal/gitintel as the single Git cache.\n\nHard rules:\n\n  - every Git invocation is argv-based through exec.CommandContext; never a shell string;\n  - reads carry bounded time/output and never mutate;\n  - mutations (add/commit/switch) are single-flight per repository root and run only on explicit user intent;\n  - no automatic network fetch, no force, no reset --hard, no clean;\n  - errors classify by operation class; stderr text stays in the returned error for the UI but is never logged with file/commit content by this package.\n\n## Constants\n\n```go\nconst (\n\tRefHeadsPrefix   = \"refs/heads/\"\n\tRefRemotesPrefix = \"refs/remotes/\"\n\tRefTagsPrefix    = \"refs/tags/\"\n)\n```\nRef namespaces the graph reads. A hidden ref is always a full name.\n\n```go\nconst (\n\tOpKindDiscard         = \"discard\"\n\tOpKindDeleteUntracked = \"delete-untracked\"\n\tOpKindBranchDelete    = \"branch-delete\"\n\tOpKindStashDrop       = \"stash-drop\"\n\tOpKindStashClear      = \"stash-clear\"\n\tOpKindApplyPatch      = \"apply-patch\"\n\tOpKindResolveConflict = \"resolve-conflict\"\n\n\tOpStatusPending     = \"pending\"\n\tOpStatusSucceeded   = \"succeeded\"\n\tOpStatusFailed      = \"failed\"\n\tOpStatusInterrupted = \"interrupted\"\n)\n```\nOperation kinds and states.\n\n```go\nconst (\n\t// ReadTimeout is the hard deadline for one read command.\n\tReadTimeout = 5 * time.Second\n\t// MutateTimeout bounds one mutation (commit hooks may be slow).\n\tMutateTimeout = 30 * time.Second\n\t// MaxReadOutput bounds captured stdout of one read command.\n\tMaxReadOutput = 32 \u003c\u003c 20 // 32 MiB\n\t// MaxSnapshotBytes is the whole-snapshot memory budget; a snapshot that\n\t// would exceed it degrades (TooLarge / Truncated), never freezes.\n\tMaxSnapshotBytes = 64 \u003c\u003c 20 // 64 MiB\n\t// MaxPatchBytesPerFile bounds the rendered patch retained per file.\n\tMaxPatchBytesPerFile = 4 \u003c\u003c 20 // 4 MiB\n\t// MaxUntrackedFiles bounds individually listed untracked entries.\n\tMaxUntrackedFiles = 1000\n\t// LargeDiffLines is the changed-line count (additions plus deletions)\n\t// past which a file's diff waits behind a Show button instead of being\n\t// read, parsed and drawn with the rest of the review.\n\tLargeDiffLines = 5000\n\t// MaxOnDemandPatchBytes bounds the diff of one file read when the user\n\t// opens it; past it the file is too large for the review.\n\tMaxOnDemandPatchBytes = 16 \u003c\u003c 20 // 16 MiB\n\t// OnDemandTimeout is the deadline of that read.\n\tOnDemandTimeout = 20 * time.Second\n)\n```\nPolicy bounds for Git subprocess work (plan §13/§15/§35).\n\n```go\nconst (\n\t// MaxWordDiffRunes caps one input line's participation in word diffing.\n\tMaxWordDiffRunes = 2000\n\t// MaxWordDiffProduct caps tokensOld*tokensNew against pathological cost.\n\tMaxWordDiffProduct = 250000\n\t// MaxWordDiffRewriteRatio suppresses marks when lines are mostly\n\t// rewritten (noisy word marks on unrelated lines hurt review).\n\tMaxWordDiffRewriteRatio = 0.72\n)\n```\nWord diff bounds (plan §18): presentation-only ranges, never Git authority.\n\n```go\nconst AutostashMessage = \"Solco autostash\"\n```\nAutostashMessage labels the temporary stash so a kept one is recognisable.\n\n```go\nconst MaxBlameLines = 5000\n```\nMaxBlameLines bounds one blame read.\n\n```go\nconst MaxCommitPromptBytes = maxCommitPreviewBytes\n```\nMaxCommitPromptBytes remains exported for callers that bound the legacy prompt. The canonical Preview path is always at or below this limit.\n\n```go\nconst MaxConflictBytes = 2 \u003c\u003c 20\n```\nMaxConflictBytes bounds each version read for the conflict editor, and the result it writes back.\n\n```go\nconst MaxContextWindowBytes = 1 \u003c\u003c 20 // 1 MiB\n\n```\nMaxContextWindowBytes bounds one context-expansion read.\n\n```go\nconst MaxGraphLimit = 20000\n```\nMaxGraphLimit is the largest window a graph read may ask for.\n\n```go\nconst MaxHistoryMove = 100\n```\nMaxHistoryMove bounds how far one move shifts a run.\n\n```go\nconst MaxPatchFileBytes = 8 \u003c\u003c 20\n```\nMaxPatchFileBytes bounds a patch file Solco will apply.\n\n```go\nconst MaxPatchFiles = 500\n```\nMaxPatchFiles bounds how many files one operation selects from.\n\n```go\nconst MaxPushRefs = 200\n```\nMaxPushRefs bounds one multi-ref push.\n\n```go\nconst MaxRebaseCommits = 100\n```\nMaxRebaseCommits bounds a plan.\n\n```go\nconst (\n\n\t// MaxRecoveryBytes bounds what one recovery point keeps: past it the\n\t// destructive operation is refused instead of running with nothing to\n\t// come back to.\n\tMaxRecoveryBytes = 128 \u003c\u003c 20\n)\n```\n\n```go\nconst MaxReflogEntries = 300\n```\nMaxReflogEntries bounds the reflog list.\n\n```go\nconst NetworkTimeout = 120 * time.Second\n```\nNetworkTimeout bounds one explicit network operation (fetch/pull/push).\n\n```go\nconst StaleAfter = 30 * time.Second\n```\nStaleAfter is the stale-while-refresh threshold.\n\n## Variables\n\n```go\nvar ErrStale = errors.New(\"review snapshot is stale: repository changed since review\")\n```\nErrStale is returned when the repository moved between review and commit; the UI must re-review, never auto-commit.\n\n## Functions\n\n```go\nfunc BuildConflictResult(segs []ConflictSegment, choices []HunkChoice) string\n```\nBuildConflictResult joins the segments with one choice per hunk (a missing choice is ChoiceNone). Undecided hunks keep readable seven-character markers, which ResolveWith refuses to stage.\n\n```go\nfunc CommitMessagePrompt(snap *ChangesSnapshot, selected []string) string\n```\nCommitMessagePrompt returns a privacy-preserving, metadata-only prompt. For explicitly approved code snippets, use PrepareCommitPrompt with opt-in. Deprecated: prefer PrepareCommitPrompt, which exposes privacy exclusions.\n\n```go\nfunc EnsureAncestorsOpen(collapsed map[string]bool, path string)\n```\nEnsureAncestorsOpen clears the collapsed marks on every directory above path so a freshly selected file's row is visible.\n\n```go\nfunc Explain(err error) string\n```\nExplain says in one sentence why a Git network or merge command failed. It returns \"\" when err is not a Git failure with output to read.\n\n```go\nfunc HasConflictMarkers(text string) bool\n```\nHasConflictMarkers reports whether text still holds a conflict block (the check ResolveWith applies, for a button that should wait for it).\n\n```go\nfunc IsGenerated(path string) bool\n```\nIsGenerated reports whether the path looks like generated/dependency output by the table above.\n\n```go\nfunc LinePatch(path string, h Hunk, selected map[int]bool, unstage bool) (string, bool)\n```\nLinePatch builds the patch that stages — or, with unstage, takes back out of the index — only the selected lines of one hunk of a tracked file's text change. It is \\`git add -p\\`'s edit: lines outside the selection stay as they are on the side the patch is applied to.\n\nStage: h is a hunk of index→worktree and the patch is applied to the index as it is. An unselected addition is left out; an unselected deletion stays as context (the index keeps the line).\n\nUnstage: h is a hunk of HEAD→index and the patch is applied in reverse to the index. An unselected addition stays as context (the index keeps it); an unselected deletion is left out (the index stays without it).\n\nselected holds indices into h.Lines; only additions and deletions count. It returns false when the selection holds no change line.\n\n```go\nfunc LocalChangesBlocked(err error) bool\n```\nLocalChangesBlocked reports whether a Git failure is the refusal to touch the working tree because of local changes — the case \"Stash and reapply\" answers.\n\n```go\nfunc MovedLines(hunks []Hunk) map[[2]int]MovedLine\n```\nMovedLines finds the deleted lines of the hunks whose text, ignoring the surrounding whitespace, reappears as an added line elsewhere in the same file. A text counts only when it is unique among the deleted lines and among the added ones, so a repeated line is never guessed at; and the two ends must sit in different blocks of change (a deleted line directly followed by the same text added is an edit of the indentation, not a move). The keys are {hunk index, line index in Hunk.Lines}, like a pick in the diff.\n\n```go\nfunc PatchLinesFor(src []PatchSourceLine, hunks []Hunk, picks map[[2]int]bool) ([]int, error)\n```\nPatchLinesFor turns a selection made on the diff the user sees (picks are {hunk, line index in Hunk.Lines}) into the PatchSourceLine indices RewriteWithPatch takes. The two diffs are read by different code, so every line is matched by kind and text first: a file whose two readings differ is refused (select it whole instead) rather than patched on a guess.\n\n## Types\n\n```go\ntype AmendBackend interface {\n\tAmendTo(ctx context.Context, root, commit string) error\n}\n```\nAmendBackend implements AmendTo: the staged changes become part of the commit, and the commits above it are replayed. Runner has validated the operation, required staged changes only and an attached branch and holds the repository's lock; the Runner rolls a failure back.\n\n```go\ntype AutostashResult struct {\n\t// Stashed is false when there was nothing to put away.\n\tStashed bool\n\t// Kept is true when the changes could not be reapplied (conflicts with the\n\t// action's result, or the action left the repository mid-operation) and\n\t// stay in the stash.\n\tKept bool\n}\n```\nAutostashResult says what became of the stashed changes.\n\n```go\ntype Backend interface {\n\t// Name says which implementation this is, for logs and tests.\n\tName() string\n}\n```\nBackend is the marker of a second implementation of some Runner capabilities. A capability is a small interface below; the Runner method that owns it type-asserts Backend to that interface and, when the backend does not implement it, keeps running on the argv \\`git\\` path in this package. That is how capabilities move to the backend one group at a time (2026-11-12 decision) without a signature changing for the callers.\n\nA backend is held to this package's policy, not to its own: argv only, GIT\\_TERMINAL\\_PROMPT=0, no pager, reads bounded by ReadTimeout and writes by MutateTimeout, output bounded by MaxReadOutput, failures returned as \\*Error (build one with NewError), no automatic fetch, no force, no clean. Single-flight per repository root stays with the Runner method that calls the backend (LockRepo), so a backend must not lock again.\n\n```go\ntype BlameLine struct {\n\tLine    int\n\tHash    string\n\tShort   string\n\tAuthor  string\n\tTime    time.Time\n\tSummary string\n\tText    string\n}\n```\nBlameLine is one line of a file with the commit that last wrote it.\n\n```go\ntype Branch struct {\n\tName      string\n\tCurrent   bool\n\tHeadShort string\n\tUpstream  string // what it tracks, \"origin/main\"; \"\" when nothing\n}\n```\nBranch is one local branch of the repository (plan §23.1: local only in core 0.10; no remote management, no ahead/behind network calls).\n\n```go\ntype BranchBackend interface {\n\tListBranches(ctx context.Context, root string) ([]Branch, error)\n}\n```\nBranchBackend implements ListBranches. It returns the local branches sorted by name, without a detached HEAD pseudo-branch, exactly as the argv path does.\n\n```go\ntype Cache struct {\n\t// contains filtered or unexported fields\n}\n```\nCache is the single per-process Git change cache, keyed by repo root. It supersedes internal/gitintel; no second Git cache may exist alongside.\n\n```go\nfunc NewCache(runner *Runner) *Cache\n```\nNewCache builds the cache over one runner.\n\n```go\nfunc (c *Cache) Get(root string) (*ChangesSnapshot, bool)\n```\nGet returns the cached snapshot and whether it is fresh enough to show without a refresh banner (StaleAfter since generation).\n\n```go\nfunc (c *Cache) Invalidate(root string)\n```\nInvalidate drops one root (after mutations the caller refreshes directly).\n\n```go\nfunc (c *Cache) NeedsRefresh(root string) bool\n```\nNeedsRefresh reports whether a background refresh is worth starting.\n\n```go\nfunc (c *Cache) Refresh(ctx context.Context, root string) (*ChangesSnapshot, error)\n```\nRefresh acquires a new snapshot for root. Concurrent refreshes of one root share one call; the loser waits and receives the same result. The snapshot always lands in the cache; callers must still verify Root/Signature match their current context before swapping visible state.\n\n```go\ntype ChangeFile struct {\n\tPath        string\n\tOldPath     string // rename/copy source\n\tStatus      ChangeStatus\n\tAdditions   int\n\tDeletions   int\n\tBinary      bool\n\tGenerated   bool\n\tDeferred    bool // diff held back for its size: counts known, Patch/Hunks empty until ReadFileDiff\n\tTooLarge    bool // cannot be shown even on demand (untracked, past MaxOnDemandPatchBytes)\n\tUntracked   bool\n\tFingerprint string\n\tPatch       []byte // parsed-model source; nil when Deferred/TooLarge/Binary\n\tHunks       []Hunk\n\tTruncated   bool // patch retained below full size\n\t// Staged/Unstaged mark which sides of git's status carry the change,\n\t// driving the Stage/Unstage file actions. Both false for untracked.\n\tStaged   bool\n\tUnstaged bool\n\t// StagedHunks and UnstagedHunks are the per-side parses (HEAD vs index,\n\t// index vs worktree) behind the staged/unstaged split views; each nil\n\t// when that side carries no change or the side patch failed.\n\tStagedHunks   []Hunk\n\tUnstagedHunks []Hunk\n}\n```\nChangeFile models one changed path in the working tree (plan §16 model).\n\n```go\ntype ChangeStatus string\n```\nChangeStatus is the coarse working-tree change kind for one path.\n\n```go\nconst (\n\tStatusModified   ChangeStatus = \"modified\"\n\tStatusAdded      ChangeStatus = \"added\"\n\tStatusDeleted    ChangeStatus = \"deleted\"\n\tStatusRenamed    ChangeStatus = \"renamed\"\n\tStatusCopied     ChangeStatus = \"copied\"\n\tStatusTypeChange ChangeStatus = \"typechange\"\n\tStatusConflicted ChangeStatus = \"conflicted\"\n\tStatusUntracked  ChangeStatus = \"untracked\"\n)\n```\n\n```go\nfunc (s ChangeStatus) Letter() string\n```\nLetter is the one-character status code used in tree rows (M/A/D/R/C/T/U/X).\n\n```go\ntype ChangesSnapshot struct {\n\tRoot      string\n\tHead      string\n\tBranch    string\n\tNoHead    bool\n\tSignature string\n\tFiles     []ChangeFile\n\tDiffBase  string // revision the combined diffs compare: HEAD, the empty tree, or from..to of a commit\n\n\tTotalAdditions int\n\tTotalDeletions int\n\n\t// Truncated marks whole-snapshot degradation (untracked \u003e 1000 or the\n\t// memory budget overflow); UI shows an explicit degraded note.\n\tTruncated          bool\n\tTruncatedUntracked int\n\n\tGeneratedAt time.Time\n\tErr         string\n}\n```\nChangesSnapshot is the immutable fact set for one repository root at one moment (plan §14/§21). Renders never recompute it; the cache owns refresh.\n\n```go\nfunc (s *ChangesSnapshot) ByPath(path string) (ChangeFile, bool)\n```\nByPath returns the change record for path, if present.\n\n```go\ntype CherryPickBackend interface {\n\tCherryPickCommits(ctx context.Context, root string, hashes []string) error\n}\n```\nCherryPickBackend applies the commits to HEAD, oldest first. Runner has validated them (full hashes, no merges), required a clean tree and holds the lock. A stop on conflicts stays in progress, as with \\`git cherry-pick\\`.\n\n```go\ntype CommandEntry struct {\n\tSeq      uint64\n\tTime     int64 // unix nanoseconds, when the command finished\n\tRoot     string\n\tArgs     []string\n\tClass    OpClass\n\tDuration time.Duration\n\tExitCode int      // 0 on success\n\tFailure  ErrClass // empty on success\n}\n```\nCommandEntry is one finished Git command. Args is the argv after the executable, as run. The message of a commit and other stdin never appear: they travel by pipe, not by argv.\n\n```go\nfunc (e CommandEntry) Created() time.Time\n```\nCreated is the finish time.\n\n```go\nfunc (e CommandEntry) Failed() bool\n```\nFailed reports whether the command did not succeed.\n\n```go\nfunc (e CommandEntry) Line() string\n```\nLine is the command as one shell-looking line, \\`git\\` first. It is for reading and copying; words with spaces are single-quoted.\n\n```go\ntype CommandLog struct {\n\t// contains filtered or unexported fields\n}\n```\nCommandLog keeps the last commands the Runner (and a Backend) ran. The zero value is not usable; make one with NewCommandLog. Safe for concurrent use.\n\n```go\nfunc NewCommandLog() *CommandLog\n```\nNewCommandLog returns an empty log. Install it with \\`runner.Commands = log\\` (and give the same one to the engine).\n\n```go\nfunc (l *CommandLog) Clear(root string)\n```\nClear forgets every command of root.\n\n```go\nfunc (l *CommandLog) Entries(root string, withReads bool) []CommandEntry\n```\nEntries returns the commands run in root, newest first. Reads are left out unless withReads.\n\n```go\nfunc (l *CommandLog) Record(e CommandEntry)\n```\nRecord adds one finished command. A nil log ignores it, so call sites need no check. Seq is assigned here; Time defaults to now.\n\n```go\ntype CommitDraft struct {\n\tSubject string\n\tBody    string\n\tPaths   []string\n\tAmend   bool\n\t// NoVerify skips the pre-commit and commit-msg hooks (--no-verify);\n\t// SignOff appends a Signed-off-by trailer (-s). Both are per commit.\n\tNoVerify bool\n\tSignOff  bool\n\t// CoAuthors are \"Name \u003cemail\u003e\" people who share the commit: each becomes a\n\t// Co-authored-by trailer. ResetAuthor (with Amend only) makes the amended\n\t// commit's author the current user and the time now (--reset-author).\n\tCoAuthors   []string\n\tResetAuthor bool\n}\n```\nCommitDraft is the user-authored commit intent (plan §22): subject required, body optional, selected paths only. No AI generation in 0.10. Amend replaces the last commit instead of adding one; the caller prefills the message from LastCommitMessage.\n\n```go\ntype CommitFilter struct {\n\t// Path keeps the commits that touched this file or folder (relative to the\n\t// repository root, taken literally).\n\tPath string\n\t// Since and Until are whole days, YYYY-MM-DD, both ends included; either may\n\t// be empty. They compare the commit date.\n\tSince, Until string\n\t// CurrentBranchOnly reads HEAD's history instead of every branch, remote and\n\t// tag the graph shows.\n\tCurrentBranchOnly bool\n\t// Hidden are the refs the graph hides; they stay hidden here too.\n\tHidden []string\n\tLimit  int\n}\n```\nCommitFilter is the Git-side query of the Commits list. The zero value asks for nothing but the graph's own scope.\n\n```go\nfunc (f CommitFilter) Active() bool\n```\nActive says whether the filter narrows anything.\n\n```go\ntype CommitInfo struct {\n\tHash    string // full hash\n\tShort   string\n\tSubject string\n\tAuthor  string\n\tTime    time.Time\n\tParents []string // real Git ancestry for native graph projection\n\t// Refs are the refs that point at this commit (graph reads only).\n\tRefs []CommitRef\n}\n```\nCommitInfo is one entry of the commit history.\n\n```go\ntype CommitPreflight struct {\n\tRoot      string\n\tHead      string\n\tBranch    string\n\tSignature string\n\t// Fingerprints maps each selected path to the ChangeFile fingerprint the\n\t// user reviewed (presentation cache identity).\n\tFingerprints map[string]string\n\t// ContentIDs maps each selected path to its authoritative live content/object\n\t// identity (blob hash via git hash-object, \"deleted\", or symlink target).\n\tContentIDs map[string]string\n\t// Untracked marks paths that must be `git add`ed before the pathspec\n\t// commit (untracked paths are invisible to `git commit -- \u003cpath\u003e`).\n\tUntracked map[string]bool\n}\n```\nCommitPreflight is the stale-state fence captured at Commit-surface open and revalidated immediately before mutation (plan §22.3).\n\n```go\ntype CommitPromptPreview struct {\n\tText          string\n\tIncludedFiles int\n\tExcludedFiles int\n\tTruncated     bool\n}\n```\n\n```go\nfunc PrepareCommitPrompt(snapshot *ChangesSnapshot, selected []string, includeExcerpt bool) CommitPromptPreview\n```\nPrepareCommitPrompt defaults to statistics, not source code. The user may explicitly allow excerpts, but secrets/credentials/config paths are always excluded; sensitive entries never appear in the copied prompt.\n\n```go\ntype CommitRef struct {\n\tKind CommitRefKind\n\tName string\n\tFull string\n\tHead bool // the checked-out branch (\"HEAD -\u003e name\")\n}\n```\nCommitRef is one ref pointing at a commit. Full is the whole name (the key a hide list uses); Name is the short form chips show.\n\n```go\ntype CommitRefKind string\n```\nCommitRefKind says which namespace a decoration came from.\n\n```go\nconst (\n\tRefBranch CommitRefKind = \"branch\"\n\tRefRemote CommitRefKind = \"remote\"\n\tRefTag    CommitRefKind = \"tag\"\n)\n```\n\n```go\ntype CommitResult struct {\n\tHash      string\n\tBranch    string\n\tCommitted []string\n}\n```\nCommitResult is the verified outcome of one transaction.\n\n```go\ntype ConflictHunk struct {\n\tOurs, Base, Theirs string\n}\n```\nConflictHunk is one region both sides changed. Each text keeps its line endings (a side that has no lines is \"\").\n\n```go\ntype ConflictSegment struct {\n\tText string\n\tHunk *ConflictHunk\n}\n```\nConflictSegment is either text both sides agree on (Hunk nil) or a hunk.\n\n```go\nfunc ParseConflictMarkers(merged string) ([]ConflictSegment, error)\n```\nParseConflictMarkers cuts merge-file's --diff3 output (markers of conflictMarkerSize characters, labelled Current / Base / Incoming) into segments. Text that merely resembles a marker is kept as text.\n\n```go\ntype ConflictSide string\n```\nConflictSide is which version of a conflicted file to keep.\n\n```go\nconst (\n\t// ConflictOurs keeps the current branch's version.\n\tConflictOurs ConflictSide = \"ours\"\n\t// ConflictTheirs takes the incoming version.\n\tConflictTheirs ConflictSide = \"theirs\"\n\t// ConflictMarked accepts the file as it is on disk (the user edited it).\n\tConflictMarked ConflictSide = \"marked\"\n)\n```\n\n```go\ntype ConflictSides struct {\n\tPath               string\n\tOurs, Base, Theirs string\n\tSegments           []ConflictSegment\n\t// Editable is false when the file cannot be merged line by line; Reason\n\t// then says why, and the whole-file choices stay.\n\tEditable bool\n\tReason   string\n}\n```\nConflictSides is what the editor shows for one unmerged file.\n\n```go\ntype CourierFile struct {\n\tPath    string\n\tAdded   int\n\tRemoved int\n}\n```\nCourierFile is one file a patch touches, with its line counts.\n\n```go\ntype CourierPreview struct {\n\tClean   bool\n\tFiles   []CourierFile\n\tProblem string\n}\n```\nCourierPreview is what \\`git apply --check\\` says about a patch on a destination worktree. Clean is the only state that may be delivered; otherwise Problem says why, in Git's own words trimmed to the first lines.\n\n```go\ntype CourierSource struct {\n\tPath    string\n\tOldPath string // a rename's source\n\tCommit  string // full hash; empty = the working tree\n\tHunks   []Hunk\n\tPicks   map[[2]int]bool\n}\n```\nCourierSource names what to send: one file's whole change or just the picked lines of it, from the working tree (Commit empty) or from one commit.\n\nPicks are {hunk index, line index in Hunk.Lines} over Hunks, the diff the user picked on: for the working tree that is the side shown (index→worktree or HEAD→index), for a commit its own diff. A nil Picks is the whole file.\n\n```go\ntype DiffLine struct {\n\tKind      LineKind\n\tOldLine   int // 1-based; 0 for pure additions\n\tNewLine   int // 1-based; 0 for pure deletions\n\tText      string\n\tNoNewline bool // \"\\ No newline at end of file\" follows this line\n}\n```\nDiffLine is one parsed line of a hunk (plan §16).\n\n```go\ntype ErrClass string\n```\nErrClass is a coarse, UI-safe classification of a Git failure.\n\n```go\nconst (\n\tErrGitMissing     ErrClass = \"git_missing\"\n\tErrNotARepo       ErrClass = \"not_a_repo\"\n\tErrStaleState     ErrClass = \"stale_state\"\n\tErrHookFailed     ErrClass = \"hook_failed\"\n\tErrConflict       ErrClass = \"conflict\"\n\tErrMergeInProgess ErrClass = \"merge_in_progress\"\n\tErrRefusal        ErrClass = \"git_refusal\"\n\tErrLocked         ErrClass = \"index_locked\"\n\tErrTimeout        ErrClass = \"timeout\"\n\tErrTooLarge       ErrClass = \"too_large\"\n\tErrCancelled      ErrClass = \"cancelled\"\n\tErrOther          ErrClass = \"other\"\n)\n```\n\n```go\nfunc ClassifyStderr(stderr string) ErrClass\n```\nClassifyStderr is the argv path's own stderr classifier: a backend that has Git's words in hand classes the failure the same way.\n\n```go\ntype Error struct {\n\tClass    ErrClass\n\tOpClass  OpClass\n\tOp       string // git subcommand, e.g. \"diff\", \"commit\"\n\tExitCode int\n\tStderr   string   // truncated; UI display only, never logged by this package\n\tPaths    []string // conflicting files of a stopped merge/rebase; UI display only\n\t// contains filtered or unexported fields\n}\n```\nError is a structured Git failure: it keeps the operation class and the raw stderr for surfacing in the UI, and a coarse class for branching.\n\n```go\nfunc GitError(err error) (*Error, bool)\n```\nGitError extracts the structured \\*Error from err, if any.\n\n```go\nfunc NewError(class ErrClass, op OpClass, sub string, exitCode int, stderr string, cause error) *Error\n```\nNewError builds the structured failure a Backend returns, so a caller branches on the same classes whichever path ran. stderr is truncated like the argv path's; cause may be nil.\n\n```go\nfunc (e *Error) Error() string\n```\n\n```go\nfunc (e *Error) Unwrap() error\n```\n\n```go\ntype FileDiff struct {\n\tHunks         []Hunk\n\tStagedHunks   []Hunk\n\tUnstagedHunks []Hunk\n}\n```\nFileDiff is what an on-demand read of one deferred file produced: its combined hunks, and each side's when changes sit staged and unstaged at once (otherwise the combined hunks are the side).\n\n```go\ntype FlatRow struct {\n\tNode  *TreeNode\n\tDepth int\n}\n```\nFlatRow is one visible row of the expanded-tree projection.\n\n```go\nfunc Flatten(node *TreeNode, collapsed map[string]bool) []FlatRow\n```\nFlatten projects the tree into visible rows given the collapsed-dir set. Directories default to expanded (changes trees are small); a key present with value true marks a user-collapsed directory.\n\n```go\ntype GraphQuery struct {\n\tLimit  int\n\tHidden []string\n}\n```\nGraphQuery bounds a graph read. Hidden holds full ref names left out of the graph: a commit only they reach disappears, a commit shared with a visible ref stays.\n\n```go\ntype HistoryAction string\n```\nHistoryAction is what RewriteHistory does to the selected run of commits.\n\n```go\nconst (\n\tHistoryReword HistoryAction = \"reword\" // new message for exactly one commit\n\tHistorySquash HistoryAction = \"squash\" // into the commit just below the run, messages joined\n\tHistoryFixup  HistoryAction = \"fixup\"  // into the commit just below the run, messages dropped\n\tHistoryDrop   HistoryAction = \"drop\"   // remove the commits\n\tHistoryMove   HistoryAction = \"move\"   // Offset places toward older (\u003e0) or newer (\u003c0) commits\n)\n```\n\n```go\ntype HistoryBackend interface {\n\tRewriteHistory(ctx context.Context, root string, op HistoryOp) error\n}\n```\nHistoryBackend implements RewriteHistory's rewrite step on one run of commits of the checked-out branch. Runner.RewriteHistory has already validated the operation, required a clean tree and an attached branch and holds the repository's lock; the backend only rewrites. It may leave a rebase stopped (conflict or failure): the Runner aborts it, so the repository is never left half-done.\n\n```go\ntype HistoryChange string\n```\nHistoryChange says what a rewrite does to one row of the preview.\n\n```go\nconst (\n\tChangeNone     HistoryChange = \"\"\n\tChangeMoved    HistoryChange = \"moved\"\n\tChangeReworded HistoryChange = \"reworded\"\n\tChangeDropped  HistoryChange = \"dropped\"\n\tChangeSquashed HistoryChange = \"squashed\" // folded into Into, message kept as part of it\n\tChangeFixedUp  HistoryChange = \"fixed up\" // folded into Into, message dropped\n\tChangeAbsorbs  HistoryChange = \"absorbs\"  // the commit that takes the others in; Absorbed counts them\n)\n```\n\n```go\ntype HistoryOp struct {\n\tAction  HistoryAction\n\tHashes  []string\n\tMessage string // reword only\n\tOffset  int    // move only\n}\n```\nHistoryOp is one rewrite. Hashes are full hashes of commits that sit next to each other on the checked-out branch, in any order.\n\n```go\ntype HistoryPreview struct {\n\t// Above is how many newer commits are not listed: they keep their order\n\t// and are replayed on top, so they get new hashes.\n\tAbove int\n\tRows  []HistoryPreviewRow\n}\n```\nHistoryPreview is the part of the branch a rewrite touches, in the order it will have afterwards (removed commits stay in the list, marked).\n\n```go\nfunc PreviewHistory(commits []CommitInfo, op HistoryOp) (HistoryPreview, error)\n```\nPreviewHistory computes what op would do to the branch whose commits are given (newest first, the first one is HEAD). It changes nothing. It refuses what RewriteHistory would refuse for reasons visible in the list: a commit off the branch's first-parent line, a run that is not adjacent, a merge in the replayed range, nothing below to squash into, an empty branch, a move past either end.\n\n```go\ntype HistoryPreviewRow struct {\n\tHash, Short string\n\tSubject     string // the new subject for a reworded commit\n\tChange      HistoryChange\n\tRemoved     bool   // gone after the rewrite: shown struck through at its old place\n\tInto        string // short hash of the commit a squashed or fixed-up commit goes into\n\tAbsorbed    int    // for ChangeAbsorbs\n}\n```\nHistoryPreviewRow is one commit of the preview.\n\n```go\ntype Hunk struct {\n\tOldStart int\n\tOldLines int\n\tNewStart int\n\tNewLines int\n\tSection  string // trailing @@ context\n\tLines    []DiffLine\n}\n```\nHunk is one @@ region of a file patch.\n\n```go\ntype HunkChoice int\n```\nHunkChoice is what to put where a hunk was.\n\n```go\nconst (\n\tChoiceNone   HunkChoice = iota // not decided: the markers stay in the result\n\tChoiceOurs                     // the current branch's lines\n\tChoiceTheirs                   // the incoming lines\n\tChoiceBoth                     // current, then incoming\n\tChoiceBase                     // the common ancestor's lines\n)\n```\n\n```go\ntype IgnoreScope string\n```\nIgnoreScope is where an ignore rule is written.\n\n```go\nconst (\n\t// IgnoreInRepository writes \u003croot\u003e/.gitignore: the rule travels with the\n\t// repository when it is committed.\n\tIgnoreInRepository IgnoreScope = \"gitignore\"\n\t// IgnoreLocally writes the repository's info/exclude: only this clone sees it.\n\tIgnoreLocally IgnoreScope = \"exclude\"\n)\n```\n\n```go\ntype LineKind uint8\n```\nLineKind is the role of one diff line in a hunk.\n\n```go\nconst (\n\tKindContext LineKind = iota\n\tKindAdd\n\tKindDelete\n)\n```\n\n```go\ntype MovedLine struct {\n\tRemoved bool\n\tOther   int\n}\n```\nMovedLine says a changed line was moved rather than rewritten. For a deleted line Other is the line number the text has in the new file; for an added line, the number it had in the old file.\n\n```go\ntype OpClass string\n```\nOpClass separates read policy from mutation policy.\n\n```go\nconst (\n\tOpRead   OpClass = \"read\"\n\tOpMutate OpClass = \"mutate\"\n)\n```\n\n```go\ntype Operation struct {\n\tVersion    int      `json:\"version\"`\n\tID         string   `json:\"id\"`\n\tKind       string   `json:\"kind\"`\n\tStatus     string   `json:\"status\"`\n\tCreatedAt  int64    `json:\"created_at_ns\"` // Unix nanoseconds: two operations in one second still sort\n\tFinishedAt int64    `json:\"finished_at_ns,omitempty\"`\n\tUndoneAt   int64    `json:\"undone_at_ns,omitempty\"`\n\tPaths      []string `json:\"paths,omitempty\"`\n\t// Removed are tracked paths that were already deleted in the working tree\n\t// when a discard brought them back: recovering takes them away again.\n\tRemoved []string `json:\"removed,omitempty\"`\n\t// Snapshot is the pinned commit that holds what the operation destroyed\n\t// (a tree of the affected paths; for a branch, its tip; for a stash, the\n\t// stash commit).\n\tSnapshot string `json:\"snapshot,omitempty\"`\n\t// After is the tree the touched paths had once the operation finished\n\t// (apply-patch): recovery refuses when they are no longer that.\n\tAfter string `json:\"after_tree,omitempty\"`\n\t// Name is the branch's or stash's own name, for the kinds that have one.\n\tName  string `json:\"name,omitempty\"`\n\tError string `json:\"error,omitempty\"`\n}\n```\nOperation is one destructive action and what a later recovery must revalidate. It holds names and object ids, never file content.\n\n```go\nfunc (o Operation) CanUndo() bool\n```\nCanUndo is a hint for the UI: the preflight in UndoOperation is the authority.\n\n```go\nfunc (o Operation) Created() time.Time\n```\nCreated is when the operation started.\n\n```go\ntype PatchAction string\n```\nPatchAction is what RewriteWithPatch does with the selected changes.\n\n```go\nconst (\n\tPatchRemove PatchAction = \"remove\" // delete the changes from the commit; they are gone\n\tPatchSplit  PatchAction = \"split\"  // pull them into a new commit right after the commit\n\tPatchMove   PatchAction = \"move\"   // move them into another commit of the branch (Dest)\n\tPatchUndo   PatchAction = \"undo\"   // take them out of the commit and back into the work tree, staged\n)\n```\n\n```go\ntype PatchBackend interface {\n\tPatchSource(ctx context.Context, root, commit, path, previousPath string) ([]PatchSourceLine, error)\n\tRewriteWithPatch(ctx context.Context, root string, op PatchOp) error\n}\n```\nPatchBackend implements Custom Patch. Runner has validated the operation, required a clean tree and an attached branch and holds the repository's lock; a rebase it leaves stopped is aborted by the Runner.\n\n```go\ntype PatchFile struct {\n\tPath         string\n\tPreviousPath string // the old path of a renamed file\n\tWhole        bool\n\tLines        []int\n}\n```\nPatchFile is the part of one file's diff in the commit that is selected: all of it (Whole, also a rename, a deletion or an added file) or the lines whose PatchSourceLine.Index is listed.\n\n```go\ntype PatchOp struct {\n\tAction  PatchAction\n\tCommit  string\n\tDest    string\n\tMessage string\n\tFiles   []PatchFile\n}\n```\nPatchOp is one Custom Patch operation on the checked-out branch. Commit is the full hash the changes come from; Dest the one they move into (move only); Message the new commit's message (split only).\n\n```go\ntype PatchSourceLine struct {\n\tIndex      int\n\tText       string\n\tSelectable bool\n}\n```\nPatchSourceLine is one line of the diff a selection is made from. Index is what PatchFile.Lines refers to; Selectable lines are the added and removed ones (headers, hunk markers and context cannot be picked).\n\n```go\ntype PullMode string\n```\nPullMode is how a pull integrates what it fetched.\n\n```go\nconst (\n\tPullFastForward PullMode = \"ff\"\n\tPullMerge       PullMode = \"merge\"\n\tPullRebase      PullMode = \"rebase\"\n)\n```\n\n```go\ntype PushKind string\n```\nPushKind says what a PushRef is.\n\n```go\nconst (\n\tPushBranch PushKind = \"branch\"\n\tPushTag    PushKind = \"tag\"\n)\n```\n\n```go\ntype PushOffer struct {\n\tRemote   string\n\tBranches []PushRef // the current branch first, then by name\n\tTags     []PushRef // newest first, as ListTags orders them\n}\n```\nPushOffer is what the dialog lists for one remote.\n\n```go\ntype PushRef struct {\n\tKind PushKind\n\tName string // the local branch or tag\n\tDest string // the branch's name on the remote (== Name for a tag)\n\n\tAhead, Behind int  // against the upstream, or the fetched same-name remote branch\n\tNew           bool // the remote has no such branch (as far as the last fetch knows)\n\tTracked       bool // the branch has an upstream on this remote\n\tCurrent       bool // the branch checked out here\n\n\t// Blocked is why the ref cannot be pushed without force (\"\" when it can).\n\t// There is no force push here; a diverged branch is pulled first.\n\tBlocked string\n}\n```\nPushRef is one ref the multi-push dialog offers: a local branch with something to send (or none of it on the remote yet), or a local tag.\n\n```go\ntype RebaseAction string\n```\nRebaseAction is one line of an interactive rebase todo.\n\n```go\nconst (\n\tRebasePick   RebaseAction = \"pick\"\n\tRebaseReword RebaseAction = \"reword\"\n\tRebaseSquash RebaseAction = \"squash\"\n\tRebaseFixup  RebaseAction = \"fixup\"\n\tRebaseDrop   RebaseAction = \"drop\"\n)\n```\n\n```go\ntype RebaseCommit struct {\n\tCommitInfo\n\tPublished bool   // reachable from a remote-tracking ref: rewriting it needs a force push\n\tMessage   string // the full message, what a reword starts from\n}\n```\nRebaseCommit is a commit the plan can rewrite.\n\n```go\ntype RebaseStep struct {\n\tHash    string\n\tAction  RebaseAction\n\tMessage string\n}\n```\nRebaseStep is one planned commit: its action and, for reword, the new message.\n\n```go\nfunc PlanAutosquash(plan []RebaseCommit) (steps []RebaseStep, moved int)\n```\nPlanAutosquash orders a plan (oldest first) the way \\`rebase --autosquash\\` does: each \"fixup! X\" commit moves to just after the nearest older commit whose subject is X (else starts with X) and becomes a fixup; one with no target stays where it was, picked. moved counts the fixups that found one.\n\n```go\ntype ReflogEntry struct {\n\tHash     string\n\tSelector string // HEAD@{n}\n\tAction   string // \"commit: fix typo\", \"checkout: moving from a to b\"\n\tSubject  string // the commit's own subject\n\tTime     time.Time\n}\n```\nReflogEntry is one move of HEAD.\n\n```go\ntype Remote struct {\n\tName     string\n\tFetchURL string\n\tPushURL  string // \"\" when it equals FetchURL\n}\n```\nRemote is one configured remote.\n\n```go\ntype RemoteBranch struct {\n\tRemote    string\n\tName      string\n\tHeadShort string\n}\n```\nRemoteBranch is one locally cached remote-tracking ref. Listing refs does not fetch, mutate or infer whether the remote is reachable.\n\n```go\ntype ReplayKind string\n```\nReplayKind is the sort of reflog action a plan replays.\n\n```go\nconst (\n\tReplayCheckout ReplayKind = \"checkout\"\n\tReplayCommit   ReplayKind = \"commit\"\n\tReplayRebase   ReplayKind = \"rebase\"\n)\n```\n\n```go\ntype ReplayPlan struct {\n\tRedo        bool\n\tKind        ReplayKind\n\tFrom, To    string\n\tIdentity    string\n\tDescription string\n}\n```\nReplayPlan is the one action an undo (or redo) would take now. Identity binds a confirmation to exactly this action: both endpoint hashes and the kind must still be the next replay when it is accepted, so another Git client moving HEAD in between makes the confirmation refuse rather than undo something the user never approved.\n\n```go\ntype RepoFacts struct {\n\tRoot      string\n\tBranch    string\n\tHead      string // empty when the repository has no commits yet\n\tSignature string\n\t// NoHead marks an unborn branch (repository without any commit).\n\tNoHead bool\n}\n```\nRepoFacts is the identity set of one repository at one moment: root, current branch, HEAD hash, and a status signature covering the full working-tree/index state. It is the stale-state fence input (plan §22.3).\n\n```go\nfunc (f RepoFacts) HeadByte() []byte\n```\nHeadByte returns the HEAD hash bytes for signature hashing, with a stable marker for the unborn-branch case.\n\n```go\ntype ResetMode string\n```\nResetMode is one of Git's three reset depths.\n\n```go\nconst (\n\tResetSoft  ResetMode = \"soft\"  // move the branch only; changes stay staged\n\tResetMixed ResetMode = \"mixed\" // move the branch and unstage; files untouched\n\tResetHard  ResetMode = \"hard\"  // move the branch and rewrite the files\n)\n```\n\n```go\ntype Runner struct {\n\t// GitBinary defaults to \"git\".\n\tGitBinary string\n\t// Now overrides the clock for tests.\n\tNow func() time.Time\n\t// Backend, when set, serves the capabilities it implements (see\n\t// backend.go); the rest run on the argv path below.\n\tBackend Backend\n\t// Journal turns on the Safety Journal (journal.go): Discard, DeleteUntracked,\n\t// DeleteBranch and StashDrop keep a recovery point first. Off by default.\n\tJournal bool\n\t// Commands, when set, keeps the Git commands this Runner runs (command_log.go).\n\tCommands *CommandLog\n\t// contains filtered or unexported fields\n}\n```\nRunner owns every Git subprocess this package spawns. The zero value is usable; GitBinary overrides the executable in tests.\n\n```go\nfunc (r *Runner) AddRemote(ctx context.Context, root, name, url string) error\n```\nAddRemote registers a new remote.\n\n```go\nfunc (r *Runner) AddSubmodule(ctx context.Context, root, address, rel string) error\n```\nAddSubmodule clones url into rel and records it (staged: .gitmodules and the gitlink). It contacts the network.\n\n```go\nfunc (r *Runner) AddWorktree(ctx context.Context, root, path string) error\n```\nAddWorktree checks out a new work tree at path on a branch named after the path's folder, created from HEAD.\n\n```go\nfunc (r *Runner) AmendTo(ctx context.Context, root, commit string) error\n```\nAmendTo amends the commit with whatever is staged. Only staged changes may exist (untracked files do not count): anything unstaged would have to be carried through the rebase. A failure, a conflict included, leaves the repository as it was, the changes staged again.\n\n```go\nfunc (r *Runner) ApplyLines(ctx context.Context, root, path string, h Hunk, selected map[int]bool, unstage bool) error\n```\nApplyLines stages (or unstages) the selected lines of one hunk of path's change in the index; the worktree is never touched. Tracked files only: the caller offers it for modified text files shown on one side.\n\n```go\nfunc (r *Runner) ApplyPatch(ctx context.Context, root, file string) error\n```\nApplyPatch applies a patch file (a diff, or a format-patch mailbox) to the working tree only — never the index, never a commit. The patch is checked first, so a patch that does not fit changes nothing.\n\n```go\nfunc (r *Runner) Blame(ctx context.Context, root, rev, rel string) ([]BlameLine, error)\n```\nBlame annotates a file at HEAD (or rev) line by line.\n\n```go\nfunc (r *Runner) BlobSize(ctx context.Context, root, spec string) (int64, error)\n```\nBlobSize returns the byte size of the blob named by spec (\"\\\u003crev\u003e:\\\u003cpath\u003e\", \":0:\\\u003cpath\u003e\" for the index) without reading it.\n\n```go\nfunc (r *Runner) BranchUpstream(ctx context.Context, root, branch string) string\n```\nBranchUpstream reads what a local branch tracks (\"\" when nothing).\n\n```go\nfunc (r *Runner) CapturePreflight(ctx context.Context, root string, snap *ChangesSnapshot, selected []string) (CommitPreflight, error)\n```\nCapturePreflight snapshots HEAD/branch/status signature plus per-file fingerprints and live object identities for the selected paths.\n\n```go\nfunc (r *Runner) CheckoutDetached(ctx context.Context, root, hash string) error\n```\nCheckoutDetached moves HEAD to one exact commit (detached). Git itself refuses when local changes would be overwritten.\n\n```go\nfunc (r *Runner) CheckoutRemoteBranch(ctx context.Context, root, ref string) (SwitchResult, error)\n```\nCheckoutRemoteBranch checks out a remote-tracking branch: the local branch of the same name when one exists, otherwise a new one that tracks it (what Fork's \"Check Out…\" on a remote branch does).\n\n```go\nfunc (r *Runner) CherryPickCommit(ctx context.Context, root, hash string) error\n```\nCherryPickCommit applies one verified full commit ID to current HEAD. Selecting a merge commit without mainline is deliberately refused.\n\n```go\nfunc (r *Runner) CherryPickCommits(ctx context.Context, root string, hashes []string) error\n```\nCherryPickCommits applies the commits to HEAD in the order given (oldest first), as one operation. Merge commits are refused. A conflict leaves the cherry-pick in progress for the sequencer's continue / skip / abort.\n\n```go\nfunc (r *Runner) Commit(ctx context.Context, root string, draft CommitDraft, pre CommitPreflight, snap *ChangesSnapshot) (CommitResult, error)\n```\nCommit executes the index-preserving selected-file transaction (plan §22.4). Holds the single-flight repository lock for the entire transaction.\n\n```go\nfunc (r *Runner) CommitByHash(ctx context.Context, root, hash string) (*CommitInfo, error)\n```\nCommitByHash reads one commit's list metadata (no decorations).\n\n```go\nfunc (r *Runner) CommitMessage(ctx context.Context, root, hash string) (string, error)\n```\nCommitMessage reads the full message (subject, blank line, body) of one commit, trailing whitespace trimmed. The hash must name a commit; a non-commit is refused before the log runs.\n\n```go\nfunc (r *Runner) CommitSnapshot(ctx context.Context, root, hash string) (*ChangesSnapshot, error)\n```\nCommitSnapshot builds the change set of one commit: its diff against the first parent (or the empty tree for a root commit). Review-only: the staged/unstaged sides and the worktree do not apply.\n\n```go\nfunc (r *Runner) CompareCommits(ctx context.Context, root, base, hash string) (*ChangesSnapshot, error)\n```\nCompareCommits is the review of two commits against each other: what a change from base to hash would be (\\`git diff base hash\\`), as one snapshot whose DiffBase is base..hash, the shape a single commit's review has.\n\n```go\nfunc (r *Runner) CompareToWorktree(ctx context.Context, root, hash string) (*ChangesSnapshot, error)\n```\nCompareToWorktree is the review of one commit against the working tree (staged and unstaged changes included, untracked files not): what changed between that commit and what is on disk now.\n\n```go\nfunc (r *Runner) CourierPatch(ctx context.Context, root string, srcs ...CourierSource) (string, error)\n```\nCourierPatch makes the patch of the sources, one after the other. A whole file keeps what Git itself writes (binary data, modes, renames); picked lines are cut against the side they were picked on, so a destination that does not hold that side refuses them in the preview.\n\n```go\nfunc (r *Runner) CreateBranch(ctx context.Context, root, name string) (SwitchResult, error)\n```\nCreateBranch creates and checks out a new local branch (\\`git switch -c\\`). No tracking setup, no start-point customization in core 0.10. The name is validated by check-ref-format first, so it cannot start with '-' and the option-value form is injection-safe.\n\n```go\nfunc (r *Runner) CreateBranchAt(ctx context.Context, root, name, hash string) (SwitchResult, error)\n```\nCreateBranchAt creates and checks out a branch at one exact commit.\n\n```go\nfunc (r *Runner) CreateFixup(ctx context.Context, root, hash string) error\n```\nCreateFixup commits the staged changes as \"fixup! \\\u003csubject\u003e\" of hash, a commit on the current history. Nothing staged, or a merge or rebase in progress, is refused.\n\n```go\nfunc (r *Runner) CreateTag(ctx context.Context, root, name string) error\n```\nCreateTag creates a lightweight tag at HEAD.\n\n```go\nfunc (r *Runner) CreateTagAnnotated(ctx context.Context, root, name, hash, message string) error\n```\nCreateTagAnnotated creates a tag at hash (HEAD when empty). A message makes it an annotated tag (travels by stdin, never argv); without one it is the lightweight tag CreateTag makes.\n\n```go\nfunc (r *Runner) CreateTagAt(ctx context.Context, root, name, hash string) error\n```\nCreateTagAt tags one exact commit.\n\n```go\nfunc (r *Runner) CurrentBranch(ctx context.Context, root string) string\n```\nCurrentBranch returns the checked-out branch, \"\" on a detached HEAD.\n\n```go\nfunc (r *Runner) DefaultRemote(ctx context.Context, root string) string\n```\nDefaultRemote returns the repository's remote to act against: the first configured remote, or \"origin\" when none is configured yet.\n\n```go\nfunc (r *Runner) DeleteBranch(ctx context.Context, root, name string) error\n```\nDeleteBranch deletes a local branch with Git's safe -d: unmerged branches are refused, never forced away.\n\n```go\nfunc (r *Runner) DeleteRemoteBranch(ctx context.Context, root, remote, name string) error\n```\nDeleteRemoteBranch removes one branch from its remote (\\`git push \\\u003cremote\u003e :refs/heads/\\\u003cname\u003e\\`). The branch must be one Git lists as remote-tracking.\n\n```go\nfunc (r *Runner) DeleteRemoteTag(ctx context.Context, root, remote, name string) error\n```\nDeleteRemoteTag removes one tag from a configured remote's server.\n\n```go\nfunc (r *Runner) DeleteTag(ctx context.Context, root, name string) error\n```\nDeleteTag removes one tag.\n\n```go\nfunc (r *Runner) DeleteUntracked(root string, paths []string) error\n```\nDeleteUntracked removes untracked paths from the worktree directly — the sanctioned replacement for \\`git clean -f\\`, which stays banned. The UI must confirm before calling: the files are deleted, not stashed.\n\n```go\nfunc (r *Runner) DeliverCourier(ctx context.Context, dest, patch string) error\n```\nDeliverCourier applies a patch that PreviewCourier called clean to the destination's working tree: unstaged, the index and every ref untouched, and under that repository's Safety Journal (Undo Git Action there takes it back). The check runs again right before, so a destination that changed since the preview is refused.\n\n```go\nfunc (r *Runner) Discard(ctx context.Context, root string, paths []string) error\n```\nDiscard throws away the worktree changes of tracked paths (\\`git restore --\\`). The UI must confirm before calling: the content is unrecoverable.\n\n```go\nfunc (r *Runner) DiscardCourierLines(ctx context.Context, root string, src CourierSource) error\n```\nDiscardCourierLines takes the picked lines of a working-tree source out of its working tree again (Move): the reverse of what CourierPatch cut, under the Safety Journal. The lines must still be there as they were read.\n\n```go\nfunc (r *Runner) Facts(ctx context.Context, root string) (RepoFacts, error)\n```\nFacts captures root/branch/HEAD plus the status signature in as few Git calls as possible. The signature hashes \\`status --porcelain=v1 -z\\` output (index + worktree + untracked), so any index/worktree mutation changes it.\n\n```go\nfunc (r *Runner) Fetch(ctx context.Context, root, remote string) error\n```\nFetch refreshes one remote (explicit user intent; never automatic).\n\n```go\nfunc (r *Runner) FetchAll(ctx context.Context, root string, prune bool) error\n```\nFetchAll fetches every configured remote, optionally dropping remote-tracking branches the servers no longer have.\n\n```go\nfunc (r *Runner) FetchedAt(ctx context.Context, root string) (at time.Time, ok bool)\n```\nFetchedAt reports when the repository's remotes were last fetched: the newest modification time of FETCH\\_HEAD, the file every fetch rewrites, in the worktree's own git dir and in the repository's common one (a fetch run from any linked worktree updates the shared remote refs, but writes only its own FETCH\\_HEAD). ok is false when nothing was ever fetched — a repository with no remote included.\n\n```go\nfunc (r *Runner) FileHistory(ctx context.Context, root, rel string, limit int) ([]CommitInfo, error)\n```\nFileHistory lists the commits that touched one path, following renames, newest first.\n\n```go\nfunc (r *Runner) FileLines(ctx context.Context, root, relPath string, start, count int) ([]string, error)\n```\nFileLines reads a bounded window of working-tree file lines for unchanged-context expansion (plan §19.4). Read-only and bounded; callers run it on background lanes only — never from a render pass. start is 1-based; count lines from there.\n\n```go\nfunc (r *Runner) FilterCommits(ctx context.Context, root string, f CommitFilter) ([]CommitInfo, error)\n```\nFilterCommits asks Git for the commits that pass the filter, newest first. A malformed date, a range that ends before it begins and a path outside the repository are refused before Git runs.\n\n```go\nfunc (r *Runner) FinishSequencer(ctx context.Context, root string, expected SequencerKind, abort bool) error\n```\nFinishSequencer revalidates live state before any Git mutation. Abort is explicit and may throw away conflict-resolution edits, so the UI confirms first. Continue refuses to operate while any index entry is unresolved.\n\n```go\nfunc (r *Runner) FormatPatch(ctx context.Context, root, hash string) ([]byte, error)\n```\nFormatPatch is one commit as an mbox patch (\\`git format-patch -1 --stdout\\`), the text \"Save as Patch\" writes.\n\n```go\nfunc (r *Runner) GraphPosition(ctx context.Context, root string, q GraphQuery, hash string) (int, error)\n```\nGraphPosition is the 0-based row a commit has in the graph ListCommitGraph draws for q (without a limit), or -1 when the graph never reaches it — the size the window must grow to for the commit to be a row.\n\n```go\nfunc (r *Runner) IgnorePaths(ctx context.Context, root string, paths []string, scope IgnoreScope) (int, error)\n```\nIgnorePaths adds one anchored rule per untracked path (a folder gets a trailing slash) to the scope's file and returns how many lines it added; a rule already there is not written again. A tracked path is refused: ignoring it would not untrack it, and Solco Git never untracks for you.\n\n```go\nfunc (r *Runner) InteractiveRebase(ctx context.Context, root, base string, steps []RebaseStep) error\n```\nInteractiveRebase replays base..HEAD as the steps say. The todo is handed to Git through GIT\\_SEQUENCE\\_EDITOR (a copy of a file we wrote), rewords become an \\`exec git commit --amend -F\\` line, and a rebase that stops is aborted at once like RebaseOnto: the repository is never left half-done.\n\n```go\nfunc (r *Runner) LastCommitMessage(ctx context.Context, root string) (subject, body string, err error)\n```\nLastCommitMessage returns the subject and body of HEAD, for the Amend prefill. It fails on an unborn branch.\n\n```go\nfunc (r *Runner) ListBranches(ctx context.Context, root string) ([]Branch, error)\n```\nListBranches enumerates local branches cheaply (no network).\n\n```go\nfunc (r *Runner) ListCommitGraph(ctx context.Context, root string, q GraphQuery) ([]CommitInfo, error)\n```\nListCommitGraph reads every branch, remote-tracking branch and tag, plus HEAD, newest first in date order (a parent never precedes its children, which the lane projection relies on). Stashes and notes stay out.\n\n```go\nfunc (r *Runner) ListCommits(ctx context.Context, root string, limit int) ([]CommitInfo, error)\n```\nListCommits reads the history of HEAD, newest first, bounded.\n\n```go\nfunc (r *Runner) ListRemoteBranches(ctx context.Context, root string) ([]RemoteBranch, error)\n```\nListRemoteBranches reads refs/remotes without network activity. Symbolic HEAD pointers are excluded; only actual branch refs belong in the tree.\n\n```go\nfunc (r *Runner) ListRemotes(ctx context.Context, root string) ([]Remote, error)\n```\nListRemotes reads the configured remotes (no network).\n\n```go\nfunc (r *Runner) ListSubmodules(ctx context.Context, root string) ([]Submodule, error)\n```\nListSubmodules reads \\`git submodule status\\` (no network, not recursive).\n\n```go\nfunc (r *Runner) ListTags(ctx context.Context, root string) ([]Tag, error)\n```\nListTags enumerates tags, newest creation first, bounded.\n\n```go\nfunc (r *Runner) ListTree(ctx context.Context, root, rev, dir string) ([]TreeEntry, error)\n```\nListTree lists the direct children of dir (\"\" is the repository root) in rev's tree: directories first, then by name, case-insensitively. rev is anything Git resolves to a commit or tree (a hash, a branch, a tag); a revision starting with \"-\" or a dir that climbs out of the tree is refused before Git is asked. A directory that did not exist at rev is an empty list, not an error.\n\n```go\nfunc (r *Runner) ListWorktrees(ctx context.Context, root string) ([]Worktree, error)\n```\nListWorktrees enumerates the repository's work trees (no network).\n\n```go\nfunc (r *Runner) LockRepo(root, op string) (func(), error)\n```\nLockRepo serializes mutations per canonical repository root.\n\n```go\nfunc (r *Runner) MergeFastForward(ctx context.Context, root, target string) error\n```\nMergeFastForward updates the checked-out branch to a selected EXISTING local branch, only if the current HEAD is its ancestor. A divergent history is refused: no conflict markers, no surprise merge commits. Users can decide separately whether they want a no-ff merge in a later explicitly designed conflict-resolution workflow.\n\n```go\nfunc (r *Runner) MergeInProgress(ctx context.Context, root string) bool\n```\nMergeInProgress reports an in-progress merge/revert/cherry-pick state, where Git refuses partial commits (fail-closed input for Commit).\n\n```go\nfunc (r *Runner) MergeNoFastForward(ctx context.Context, root, target string) error\n```\nMergeNoFastForward performs an explicitly confirmed merge. It cannot silently merge a dirty tree; conflicts may leave MERGE\\_HEAD for the user to resolve in the inspector or Terminal.\n\n```go\nfunc (r *Runner) MergeSquash(ctx context.Context, root, target string) error\n```\nMergeSquash folds every change of target into the index without committing, so the user reviews the result and commits it as one. It needs a clean working tree; if it stops on conflicts it is rolled back (\\`reset --merge\\`) because a squash leaves no MERGE\\_HEAD for a Continue/Abort banner to hold.\n\n```go\nfunc (r *Runner) Mutate(ctx context.Context, root string, args ...string) ([]byte, error)\n```\nMutate runs one explicit mutation command single-flight per repo root. Callers must have already revalidated state; the runner only serializes.\n\n```go\nfunc (r *Runner) Operations(ctx context.Context, root string) ([]Operation, error)\n```\nOperations lists the journal, newest first. A pending record that has been pending far longer than any operation runs is shown as interrupted. Records past the keep count or lifetime are pruned (with their pinned commits).\n\n```go\nfunc (r *Runner) PatchSource(ctx context.Context, root, commit, path, previousPath string) ([]PatchSourceLine, error)\n```\nPatchSource lists the lines of a file's diff in a commit that a selection can name. Reading only: no state changes.\n\n```go\nfunc (r *Runner) PlanReplay(ctx context.Context, root string, redo bool) (plan ReplayPlan, ok bool, err error)\n```\nPlanReplay reads the whole HEAD reflog and says what an undo (or redo) would replay; ok is false when there is nothing eligible.\n\n```go\nfunc (r *Runner) PreviewCourier(ctx context.Context, dest, patch string) (CourierPreview, error)\n```\nPreviewCourier checks the patch against the destination worktree without changing anything. A destination with a merge, rebase, revert or cherry-pick in progress is refused: its working tree is not the quiet one a patch fits.\n\n```go\nfunc (r *Runner) PublishedCommits(ctx context.Context, root string, hashes []string) ([]string, error)\n```\nPublishedCommits returns those of hashes that a remote-tracking ref already holds: rewriting them means the branch can only be pushed by force. A repository without remotes publishes nothing. Read only.\n\n```go\nfunc (r *Runner) Pull(ctx context.Context, root, remote, branch string, mode PullMode) error\n```\nPull fetches branch from remote and integrates it into the current branch. Fast-forward refuses a diverged history; merge may pause on conflicts (the merge banner then offers Continue/Abort); a rebase that stops on conflicts is aborted at once and reported with the paths, like RebaseOnto.\n\n```go\nfunc (r *Runner) PullFFOnly(ctx context.Context, root, remote, branch string) error\n```\nPullFFOnly pulls with --ff-only: Git refuses a diverged history instead of creating surprise merges, and the UI surfaces the refusal.\n\n```go\nfunc (r *Runner) Push(ctx context.Context, root, remote, branch string, setUpstream bool) error\n```\nPush publishes the branch to the remote; setUpstream sets tracking the first time a branch is published.\n\n```go\nfunc (r *Runner) PushMany(ctx context.Context, root, remote string, refs []PushRef, setUpstream bool) error\n```\nPushMany publishes the given refs to remote in one \\`git push\\`: each branch lands on its Dest, each tag on itself. setUpstream (-u) records tracking for the pushed branches that have none. There is never a force: every refspec is fully qualified and carries no \"+\", a ref that is Blocked is refused, and a branch or tag that no longer exists locally is refused before Git is asked.\n\n```go\nfunc (r *Runner) PushTag(ctx context.Context, root, remote, name string) error\n```\nPushTag publishes one existing tag (explicit; plain Push never sends tags).\n\n```go\nfunc (r *Runner) PushTo(ctx context.Context, root, remote, src, dst string, setUpstream bool) error\n```\nPushTo publishes local branch src as dst on the remote: a branch whose upstream has another name (or lives on a second remote) must land on that upstream, not on a same-named branch of the first remote.\n\n```go\nfunc (r *Runner) Read(ctx context.Context, root string, args ...string) ([]byte, error)\n```\nRead runs one bounded, read-only Git command in root. It never mutates worktree or index state (GIT\\_OPTIONAL\\_LOCKS=0 keeps even refreshes lockless).\n\n```go\nfunc (r *Runner) ReadBlob(ctx context.Context, root, spec string, max int64) ([]byte, error)\n```\nReadBlob returns the blob named by spec when it is at most max bytes; a larger one is refused with ErrTooLarge before any of it is read.\n\n```go\nfunc (r *Runner) ReadConflict(ctx context.Context, root, rel string) (ConflictSides, error)\n```\nReadConflict reads the three versions of an unmerged file and the merge Git would make of them, cut into hunks. A file that cannot be edited line by line (a side deleted it, binary, too large, a link or submodule) comes back with Editable false and the reason.\n\n```go\nfunc (r *Runner) ReadFileDiff(ctx context.Context, root, base string, cf ChangeFile) (FileDiff, error)\n```\nReadFileDiff reads the diff of one deferred file: through Git for a tracked path, against base (the DiffBase of its snapshot), and from the disk for an untracked one. The output is bounded by MaxOnDemandPatchBytes; past it the error is ErrTooLarge.\n\n```go\nfunc (r *Runner) ReadPushOffer(ctx context.Context, root, remote string) (PushOffer, error)\n```\nReadPushOffer lists, for remote, the local branches that have commits to send (or are not on the remote yet) and the local tags. It reads only what the last fetch recorded; no network. A branch tracking another remote is not offered here.\n\n```go\nfunc (r *Runner) RebaseOnto(ctx context.Context, root, target string) error\n```\nRebaseOnto replays the current branch on top of a local or remote-tracking branch. A rebase that stops on conflicts is aborted at once and reported with the conflicting paths: Solco has no rebase continue/skip workflow, so it never leaves one half-done (the user resolves it in the Terminal or merges instead).\n\n```go\nfunc (r *Runner) RebaseOntoFrom(ctx context.Context, root, target, upstream string) error\n```\nRebaseOntoFrom is \\`git rebase --onto target upstream\\`: the commits after upstream (a full hash on the current branch, exclusive) are replayed on top of target, and upstream and everything before it stay behind. Merge commits in that run are refused (a plain rebase would flatten them); a conflict aborts as in RebaseOnto.\n\n```go\nfunc (r *Runner) RebasePlan(ctx context.Context, root, base string) ([]RebaseCommit, error)\n```\nRebasePlan lists base..HEAD oldest first. Merge commits in the range are refused (a linear rebase would flatten them silently).\n\n```go\nfunc (r *Runner) Reflog(ctx context.Context, root string, limit int) ([]ReflogEntry, error)\n```\nReflog lists where HEAD has been, newest first.\n\n```go\nfunc (r *Runner) RemoveRemote(ctx context.Context, root, name string) error\n```\nRemoveRemote deletes a remote and its tracking branches.\n\n```go\nfunc (r *Runner) RemoveSubmodule(ctx context.Context, root, rel string) error\n```\nRemoveSubmodule unregisters one listed submodule and stages its removal (\\`submodule deinit\\` then \\`rm\\`); Git's own modules folder stays for a later re-add.\n\n```go\nfunc (r *Runner) RemoveWorktree(ctx context.Context, root, path string) error\n```\nRemoveWorktree deletes one linked work tree. The main work tree is never a target, and Git itself refuses one with changes or a lock.\n\n```go\nfunc (r *Runner) RenameBranch(ctx context.Context, root, name, to string) error\n```\nRenameBranch renames a local branch (\\`git branch -m\\`); the new name is checked by check-ref-format first.\n\n```go\nfunc (r *Runner) RenameRemote(ctx context.Context, root, name, to string) error\n```\nRenameRemote renames a remote; Git moves its tracking refs along.\n\n```go\nfunc (r *Runner) Replay(ctx context.Context, root string, redo bool, expected string) error\n```\nReplay undoes (or redoes) the action PlanReplay reported. expected is that plan's Identity, or empty to take whatever is next. A merge, revert, cherry-pick or rebase in progress refuses, as does a history that moved since the plan was read.\n\n```go\nfunc (r *Runner) RequireCleanWorktree(ctx context.Context, root string) error\n```\nRequireCleanWorktree prevents history mutations from silently combining pending local edits with merge/revert. This checks both staged and unstaged files and untracked files; a failed status read fails closed.\n\n```go\nfunc (r *Runner) ResetTo(ctx context.Context, root, hash string, mode ResetMode) (previous string, err error)\n```\nResetTo moves the current branch to one commit. Hard additionally demands a clean working tree, so no uncommitted work can be lost; the commits it drops stay reachable through the reflog and the previous HEAD is returned so the UI can say how to get back.\n\n```go\nfunc (r *Runner) ResolveCommit(ctx context.Context, root, fullRef string) (string, error)\n```\nResolveCommit names the commit a full ref points at (an annotated tag is peeled). Anything but a refs/ name is refused.\n\n```go\nfunc (r *Runner) ResolveConflict(ctx context.Context, root, rel string, side ConflictSide) error\n```\nResolveConflict resolves one unmerged file: keep a side, or accept the file as the user edited it (refused while conflict markers remain).\n\n```go\nfunc (r *Runner) ResolveRoot(ctx context.Context, dir string) (string, error)\n```\nResolveRoot walks up from dir to the enclosing worktree top-level. The empty string means \"not inside a repository\".\n\n```go\nfunc (r *Runner) ResolveWith(ctx context.Context, root, rel, content string) error\n```\nResolveWith settles one unmerged text file with the given result: it is written to the working tree and staged. Refused while the result still holds conflict markers, is too large, or the file is no longer in conflict. With the journal on, the working-tree file it replaces (the markers, or edits made elsewhere) is kept first, and Recovery can reopen the conflict.\n\n```go\nfunc (r *Runner) RestoreFile(ctx context.Context, root, hash, rel string) error\n```\nRestoreFile writes one file as it was in a commit into the working tree (unstaged, so it shows up as a change to review or discard).\n\n```go\nfunc (r *Runner) RevertCommit(ctx context.Context, root, hash string) error\n```\nRevertCommit creates an inverse commit for an exact full Git commit ID, preserving public history. The UI must confirm the selected commit and explain that conflicts may require manual resolution in the Terminal.\n\n```go\nfunc (r *Runner) RewriteHistory(ctx context.Context, root string, op HistoryOp) error\n```\nRewriteHistory applies op to the checked-out branch. It needs a HistoryBackend (the LazyGit engine); without one it refuses and InteractiveRebase remains the way. A conflict or any other failure aborts the rebase: nothing changes, and a conflict is reported as ErrConflict with the files that clashed.\n\n```go\nfunc (r *Runner) RewriteWithPatch(ctx context.Context, root string, op PatchOp) error\n```\nRewriteWithPatch applies op to the checked-out branch. Any failure, including a conflict, aborts the rebase and leaves the repository as it was.\n\n```go\nfunc (r *Runner) SequencerState(ctx context.Context, root string) (SequencerStatus, error)\n```\nSequencerState asks Git for \\*this worktree's\\* state. It fails closed if any marker lookup fails and never trusts a stale UI snapshot.\n\n```go\nfunc (r *Runner) SetRemoteURL(ctx context.Context, root, name, url string) error\n```\nSetRemoteURL repoints an existing remote's fetch (and push) address.\n\n```go\nfunc (r *Runner) SetUpstream(ctx context.Context, root, branch, upstream string) error\n```\nSetUpstream makes a local branch track a listed remote-tracking branch (\"origin/main\").\n\n```go\nfunc (r *Runner) Snapshot(ctx context.Context, root string) (*ChangesSnapshot, error)\n```\nSnapshot acquires the working-tree change snapshot for root: working tree + index vs HEAD, plus untracked files (plan §14). Repository without HEAD compares to the empty tree.\n\n```go\nfunc (r *Runner) SquashFixups(ctx context.Context, root, hash string) (int, error)\n```\nSquashFixups folds the \"fixup!\" commits of hash and everything after it into their targets (one rebase onto hash's parent) and returns how many it folded. No fixup with a target in that range is a refusal; a conflict aborts the rebase like every other history rewrite.\n\n```go\nfunc (r *Runner) Stage(ctx context.Context, root string, paths []string) error\n```\nStage moves worktree changes of paths into the index (\\`git add --\\`).\n\n```go\nfunc (r *Runner) StashApply(ctx context.Context, root, ref string) error\n```\nStashApply re-applies one stash entry and keeps it (Pop applies and drops).\n\n```go\nfunc (r *Runner) StashClear(ctx context.Context, root string) error\n```\nStashClear drops every stash entry.\n\n```go\nfunc (r *Runner) StashDrop(ctx context.Context, root, ref string) error\n```\nStashDrop deletes one stash entry.\n\n```go\nfunc (r *Runner) StashLines(ctx context.Context, root string, src CourierSource, message string) error\n```\nStashLines saves the picked lines of one working-tree file as a stash entry and takes them out of the working tree. The stash is the native kind (HEAD plus only those lines, with an index parent), so pop, apply, drop and the Stashes list treat it like any other. Picks are over src.Hunks, the unstaged diff the user picked on.\n\nThe file must be tracked and must have nothing staged: the patch is cut against HEAD, and a staged change would make the stash and the working tree disagree about what the lines were. Everything that can refuse does so before the stash is stored, and the removal is \\`git apply --reverse\\`, all or nothing; if it still fails the stash just stored is dropped again.\n\n```go\nfunc (r *Runner) StashList(ctx context.Context, root string) ([]Stash, error)\n```\nStashList enumerates the stash entries, newest first.\n\n```go\nfunc (r *Runner) StashPatch(ctx context.Context, root, ref string) ([]byte, error)\n```\nStashPatch is one stash entry as a plain diff patch, untracked files included (\\`git stash show -p --include-untracked\\`), for \"Save as Patch\".\n\n```go\nfunc (r *Runner) StashPop(ctx context.Context, root, ref string) error\n```\nStashPop applies a stash entry and drops it on success.\n\n```go\nfunc (r *Runner) StashPush(ctx context.Context, root, message string) error\n```\nStashPush stashes the worktree and index; untracked files join with -u so \"stash\" puts the whole change set away, as the Changes list shows it.\n\n```go\nfunc (r *Runner) StashPushMode(ctx context.Context, root string, mode StashMode, message string) error\n```\nStashPushMode saves the changes StashMode names, with an optional message.\n\n```go\nfunc (r *Runner) StashPushPaths(ctx context.Context, root, message string, paths []string) error\n```\nStashPushPaths stashes only the listed files (untracked ones included).\n\n```go\nfunc (r *Runner) StashRename(ctx context.Context, root, hash, message string) error\n```\nStashRename gives one stash a new message. The stash is found by its commit hash (its stash@{n} index moves whenever another stash is made), rebuilt under the new message — it lands on top of the list, as in Fork — and the old entry is dropped only once the new one exists.\n\n```go\nfunc (r *Runner) StashSnapshot(ctx context.Context, root, hash string) (*ChangesSnapshot, error)\n```\nStashSnapshot is a stash as one review: the tracked changes it holds (against the commit it was made on) plus, when it was made with -u, the untracked files Git keeps on the stash commit's third parent.\n\n```go\nfunc (r *Runner) Stdin(ctx context.Context, root, stdin string, args ...string) ([]byte, error)\n```\nStdin runs one mutation with stdin content (commit message transport). The message travels by pipe, never by argv, avoiding argv length limits and keeping message text out of process listings.\n\n```go\nfunc (r *Runner) SwitchBranch(ctx context.Context, root, name string) (SwitchResult, error)\n```\nSwitchBranch moves to an existing local branch via \\`git switch\\` (plan §23.2): no force, no checkout --; Git's refusal is returned, not fought.\n\n```go\nfunc (r *Runner) UndoLastCommit(ctx context.Context, root string) error\n```\nUndoLastCommit soft-resets a LOCAL unpushed non-root HEAD commit: changes remain staged. Never silently rewrite a commit referenced by a known remote-tracking ref; published history should use Revert instead.\n\n```go\nfunc (r *Runner) UndoOperation(ctx context.Context, root, id string) error\n```\nUndoOperation recovers what a journaled operation destroyed. It revalidates the repository first and refuses when it has changed since.\n\n```go\nfunc (r *Runner) UnmergedPaths(ctx context.Context, root string) ([]string, error)\n```\nUnmergedPaths lists the files that still have unresolved conflicts.\n\n```go\nfunc (r *Runner) UnsetUpstream(ctx context.Context, root, branch string) error\n```\nUnsetUpstream stops a local branch tracking anything.\n\n```go\nfunc (r *Runner) Unstage(ctx context.Context, root string, noHead bool, paths []string) error\n```\nUnstage moves index changes of paths back out of the index. On an unborn branch the staged files are simply unlinked from the index (\\`git rm --cached\\`), since there is no HEAD to restore from.\n\n```go\nfunc (r *Runner) UpdateSubmodule(ctx context.Context, root, rel string) error\n```\nUpdateSubmodule initialises (when needed) and checks out the commit the superproject records for one listed submodule. It may contact the network.\n\n```go\nfunc (r *Runner) Upstream(ctx context.Context, root string) (UpstreamStatus, error)\n```\nUpstream reads the tracking status of the current branch: no network.\n\n```go\nfunc (r *Runner) ValidateBranchName(ctx context.Context, root, name string) error\n```\nValidateBranchName checks a candidate name through Git's own ref rules (\\`check-ref-format --branch\\`), the authority for New Branch.\n\n```go\nfunc (r *Runner) WithAutostash(ctx context.Context, root string, action func() error) (AutostashResult, error)\n```\nWithAutostash stashes the local changes, runs action and reapplies them. A failing action restores the changes at once unless it left a merge/rebase half way; a reapply that conflicts leaves the stash in place (Kept).\n\n```go\nfunc (r *Runner) WorkingPatch(ctx context.Context, root string) ([]byte, error)\n```\nWorkingPatch is everything that differs from HEAD right now — staged, unstaged and untracked (ignored files stay out) — as one diff patch. It is built in a throw-away index, so the repository's own index, working tree and refs are never touched (only unreferenced blob objects may be written, which \\`git gc\\` prunes).\n\n```go\ntype SequencerKind string\n```\nSequencerKind identifies Git's active conflict-resolution transaction. Only operations explicitly supported by this package can be continued or aborted; an unknown/rebase state must not be interpreted as clean.\n\n```go\nconst (\n\tSequencerNone        SequencerKind = \"\"\n\tSequencerMerge       SequencerKind = \"merge\"\n\tSequencerRevert      SequencerKind = \"revert\"\n\tSequencerCherryPick  SequencerKind = \"cherry-pick\"\n\tSequencerUnsupported SequencerKind = \"unsupported\"\n)\n```\n\n```go\ntype SequencerStatus struct {\n\tKind     SequencerKind\n\tUnmerged int\n\t// UnmergedPaths is a bounded, sorted subset of actual unmerged index\n\t// entries; Unmerged remains the exact total even when the list is long.\n\tUnmergedPaths []string\n}\n```\nSequencerStatus contains no file bodies, commit messages, or credentials.\n\n```go\nfunc (s SequencerStatus) Active() bool\n```\n\n```go\ntype Stash struct {\n\tRef     string // e.g. stash@{0}\n\tHash    string // the stash commit itself (what a review of the stash reads)\n\tBase    string // the commit the stash was made on (its first parent); \"\" if unknown\n\tSubject string\n}\n```\nStash is one entry of the stash list.\n\n```go\ntype StashBackend interface {\n\tStashList(ctx context.Context, root string) ([]Stash, error)\n}\n```\nStashBackend implements StashList: the entries newest first, each with its base commit (the first parent of the stash commit), as the argv path returns them.\n\n```go\ntype StashMode string\n```\nStashMode picks what a stash takes.\n\n```go\nconst (\n\t// StashStaged stashes only what is staged; the rest stays in the work tree.\n\tStashStaged StashMode = \"staged\"\n\t// StashKeepIndex stashes everything, tracked and untracked, and leaves the\n\t// staged changes in the index and the work tree as well.\n\tStashKeepIndex StashMode = \"keep-index\"\n)\n```\n\n```go\ntype Submodule struct {\n\tPath     string\n\tCommit   string\n\tState    SubmoduleState\n\tDescribe string\n}\n```\nSubmodule is one submodule of the repository.\n\n```go\ntype SubmoduleState string\n```\nSubmoduleState is \\`git submodule status\\`'s one-character state.\n\n```go\nconst (\n\tSubmoduleClean         SubmoduleState = \"clean\"\n\tSubmoduleUninitialized SubmoduleState = \"uninitialized\"\n\tSubmoduleModified      SubmoduleState = \"modified\" // checked out at another commit than recorded\n\tSubmoduleConflict      SubmoduleState = \"conflict\"\n)\n```\n\n```go\ntype SwitchResult struct {\n\tBranch string\n\t// Carried notes Git's dirty-compatible carry of working changes.\n\tCreated bool\n}\n```\nSwitchResult reports the outcome of a branch switch.\n\n```go\ntype Tag struct{ Name string }\n```\nTag is one lightweight tag of the repository.\n\n```go\ntype TagBackend interface {\n\tListTags(ctx context.Context, root string) ([]Tag, error)\n}\n```\nTagBackend implements ListTags: tag names, newest creation first, at most 500, exactly as the argv path returns them.\n\n```go\ntype TreeEntry struct {\n\tName string // base name\n\tPath string // slash path from the repository root\n\tMode string // octal mode as Git prints it (\"100644\", \"040000\", \"160000\", …)\n\t// Dir marks a sub-directory; Submodule a gitlink (a commit of another\n\t// repository, which has no file content here).\n\tDir, Submodule bool\n\t// Size is the blob's byte size; -1 for directories and submodules.\n\tSize int64\n}\n```\nTreeEntry is one child of a directory as it stood at a commit.\n\n```go\ntype TreeNode struct {\n\tName     string // display segment\n\tPath     string // full repo-relative path\n\tDir      bool\n\tFile     *ChangeFile // leaf only\n\tChildren []*TreeNode\n}\n```\nTreeNode is one node of the changed-path tree: a directory aggregate or a changed file leaf (plan §11.1: tree projection is separate from parsing).\n\n```go\nfunc BuildTree(files []ChangeFile, compactOneChild bool) *TreeNode\n```\nBuildTree projects changed files into a dirs-first tree. compactOneChild collapses single-child directory chains (\"a/b/c.txt\" under one row).\n\n```go\nfunc FilterTree(node *TreeNode, query string) *TreeNode\n```\nFilterTree recursively keeps nodes whose own text or a descendant matches the query (case-insensitive substring). Returns nil when nothing matches.\n\n```go\nfunc (n *TreeNode) Additions() int\n```\nAdditions/Deletions aggregate the subtree totals for directory rows.\n\n```go\nfunc (n *TreeNode) Deletions() int\n```\n\n```go\nfunc (n *TreeNode) FileCount() int\n```\nFileCount counts leaves under the node.\n\n```go\ntype UpstreamStatus struct {\n\tRemote string // the remote the branch tracks, \"\" when none\n\tBranch string // the upstream branch name\n\tAhead  int\n\tBehind int\n\tOK     bool\n}\n```\nUpstreamStatus is the tracking state of the current branch.\n\n```go\nfunc (u UpstreamStatus) Diverged() bool\n```\nDiverged reports history on both sides of the upstream: Git refuses a plain push and a fast-forward pull for it.\n\n```go\ntype WebRepo struct {\n\tHost string // \"github.com\"\n\tBase string // \"https://github.com/owner/repo\"\n}\n```\nWebRepo is a remote read as a web repository page.\n\n```go\nfunc ParseWebRepo(address string) (WebRepo, bool)\n```\nParseWebRepo reads a remote address (https, ssh://, git://, scp-like) as the repository's web page. Local paths and anything unparsable are refused.\n\n```go\nfunc (w WebRepo) CommitURL(hash string) string\n```\nCommitURL is the commit's page on the hosting site.\n\n```go\nfunc (w WebRepo) Name() string\n```\nName is the site's friendly name for menus (\"GitHub\"), else the host.\n\n```go\ntype WordRange struct {\n\tStart int\n\tEnd   int\n}\n```\nWordRange is a rune-index \\[Start,End) span inside one line's text.\n\n```go\nfunc WordDiff(oldLine, newLine string) (oldRanges, newRanges []WordRange, ok bool)\n```\nWordDiff pairs one delete line with its adjacent add line and returns the changed rune ranges on each side. ok is false when the pairing is unhelpful (length caps, pathological size, or a mostly-rewritten pair).\n\n```go\ntype Worktree struct {\n\tPath     string\n\tHead     string\n\tBranch   string // \"main\" for refs/heads/main; \"\" when bare or detached\n\tBare     bool\n\tDetached bool\n}\n```\nWorktree is one checked-out work tree of the repository.\n\n```go\ntype WorktreeBackend interface {\n\tListWorktrees(ctx context.Context, root string) ([]Worktree, error)\n}\n```\nWorktreeBackend implements ListWorktrees: the main work tree first, then the linked ones in the order Git lists them; a work tree stopped in a rebase counts as detached, as \\`git worktree list\\` reports it.\n\n```go\ntype WriteBackend interface {\n\t// SwitchBranch checks out an existing local branch; Git's refusal to carry\n\t// conflicting local changes is returned, never forced.\n\tSwitchBranch(ctx context.Context, root, name string) error\n\t// CreateBranch creates a branch at base (a full ref or hash) and checks it out.\n\tCreateBranch(ctx context.Context, root, name, base string) error\n\tRenameBranch(ctx context.Context, root, name, to string) error\n\t// DeleteBranch is the safe delete: an unmerged branch is refused.\n\tDeleteBranch(ctx context.Context, root, name string) error\n\t// StashPush stashes with untracked files and a message (never empty).\n\tStashPush(ctx context.Context, root, message string) error\n\tStashPop(ctx context.Context, root string, index int) error\n\tStashApply(ctx context.Context, root string, index int) error\n\tStashDrop(ctx context.Context, root string, index int) error\n\t// CreateTag makes a lightweight tag at ref (HEAD when empty).\n\tCreateTag(ctx context.Context, root, name, ref string) error\n\tDeleteTag(ctx context.Context, root, name string) error\n}\n```\nWriteBackend runs the last step of the simple write operations. Runner has validated every argument (branch names by check-ref-format, full hashes, stash references) and holds the repository's lock; a backend only executes. Each method does what the argv path's one command does, and a failure is reported like it (classified Error).\n\n","path":"github.com/thewei/solco-gitkit/gitworkbench","name":"gitworkbench","synopsis":"[INPUT]: Git refs/heads and refs/remotes via Runner.Read; Git's branch validation and mutation semantics.","isRedistributable":true}
