Documentation
¶
Overview ¶
Package store resolves where dibs keeps its files and provides small, safe filesystem primitives (atomic writes, an advisory lock, JSON helpers).
dibs state lives in two places, on purpose:
State: <git-common-dir>/dibs — coordination state (leases, presence, notes, journal). Every git worktree of a repository shares the same common dir, so leases taken in one worktree are visible in all others instantly, without commits, daemons, or databases. It never shows up in `git status`.
Shared: <repo-root>/.dibs — durable knowledge (lessons). These are plain files meant to be committed, reviewed in PRs, and shared with your team and CI through git itself.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotRepo = errors.New("not inside a git repository (dibs coordinates agents through the repo's .git dir)")
ErrNotRepo is returned when the current directory is not inside a git repo.
Functions ¶
func AppendLine ¶
AppendLine appends one line to path (creating it if needed).
func ListJSON ¶
ListJSON decodes every *.json file in dir into T, skipping files that fail to parse (a crashed writer must never brick coordination).
func WriteAtomic ¶
WriteAtomic writes data to path via a temp file in the same directory, so readers never observe a partial file.
Types ¶
type Store ¶
type Store struct {
State string // <git-common-dir>/dibs — machine-local coordination state
Repo string // repo root of the current worktree
Worktree string // same as Repo; named for clarity at call sites
}
Store locates the dibs directories for one repository.
func Open ¶
Open resolves the store for the repository containing dir (usually "."). DIBS_STATE_DIR overrides the coordination dir, mainly for tests and unusual setups.
func (*Store) Branch ¶
Branch reports the current branch of the worktree ("HEAD" when detached, "" outside git).
func (*Store) EnsureState ¶
EnsureState creates the coordination directories.
func (*Store) WithLock ¶
WithLock runs fn while holding an exclusive lock on the store. The lock is a kernel file lock (flock on Unix, LockFileEx on Windows), so it is released automatically when the holding process exits or crashes — there are no stale lockfiles to detect and no stealing heuristics to get wrong. Critical sections in dibs are a few milliseconds, so contention is short-lived.