Help us shape the future of Go! Take the 2026 Go Developer Survey

gitwt

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package gitwt holds the Git plumbing for worker subagents: snapshotting a working tree into a commit without touching the index, creating a linked worktree on its own branch, committing a worker's changes, and applying them back to the parent's working tree atomically.

Every command runs with -C <dir> and an environment stripped of the variables that would redirect git to another repository.

Index

Constants

View Source
const (
	FallbackName  = "tinyagent"
	FallbackEmail = "tinyagent@localhost"
)

FallbackName and FallbackEmail are the identity used for tinyagent's branch-local commits when the repository has no user.name/user.email.

View Source
const BranchPrefix = "tinyagent/"

BranchPrefix prefixes every worker branch.

View Source
const Dir = ".tinyagent/worktrees"

Dir is where worker worktrees go, relative to the repository root. It is shared with --worktree.

Variables

This section is empty.

Functions

func Apply

func Apply(top, base, commit string) (conflicts []string, err error)

Apply applies base..commit to the working tree at top (not the index). It is atomic: when any hunk fails, nothing is changed and conflicts lists the affected paths.

func BranchExists

func BranchExists(top, branch string) bool

BranchExists reports whether refs/heads/<branch> exists.

func ChangedFiles

func ChangedFiles(top, base, commit string) ([]string, error)

ChangedFiles lists the paths, relative to top and slash separated, that base..commit adds, changes or deletes (renames count as both paths).

func Commit

func Commit(path, message string) (commit string, changed bool, err error)

Commit stages every change in the worktree at path (respecting .gitignore) and commits it with message, with repository hooks disabled. changed is false, and no commit is made, when there is nothing to commit.

func Create

func Create(top, name, commit string) (path, branch string, err error)

Create adds a linked worktree at <top>/.tinyagent/worktrees/<name> on a new branch tinyagent/<name> at commit, with repository hooks disabled. On error nothing new is left behind except the ignored parent directory.

func DiffStat

func DiffStat(top, base, commit string) (stat, short string)

DiffStat returns `git diff --stat base commit` and its one-line summary.

func Env

func Env(extra ...string) []string

Env is the environment for tinyagent's own git commands: variables that would point git at a different repository are dropped. extra is appended.

func Head(top string) (string, error)

Head returns the commit at HEAD, or an error when the repository has no commits.

func Remove

func Remove(top, path, branch string)

Remove deletes a worktree and its branch, ignoring errors.

func Snapshot

func Snapshot(top string) (string, error)

Snapshot records the working tree of the repository at top (tracked changes plus untracked, non-ignored files, excluding .tinyagent/worktrees) as a commit whose parent is HEAD. It uses a temporary index, so the repository's index, HEAD and refs are untouched.

func Top

func Top(dir string) (string, error)

Top returns the root of the Git work tree containing dir, with symlinks resolved.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL