Documentation
¶
Overview ¶
Package hook makes dibs leases enforceable instead of advisory.
Claude Code: a PreToolUse hook runs `dibs hook claude` before every Edit/Write; if the target file is covered by another agent's lease, the hook exits with code 2, which blocks the tool call and feeds the reason back to the model — the agent sees who holds the file and why, and can wait, renegotiate, or work elsewhere.
Any other agent: a git pre-commit hook (`dibs hook pre-commit`) refuses commits that touch files someone else has claimed.
Index ¶
- func InstallClaude(settingsPath string) (changed bool, err error)
- func InstallPreCommit(st *store.Store) (string, error)
- func RunClaude(m *coord.Manager, stdin io.Reader, stderr io.Writer) int
- func RunPreCommit(m *coord.Manager, stderr io.Writer) int
- func UninstallClaude(settingsPath string) (changed bool, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstallClaude ¶
InstallClaude adds the dibs PreToolUse hook to a Claude Code settings file (default: .claude/settings.json in the repo). The merge is additive and idempotent: existing settings and hooks are preserved, and a second install is a no-op.
func InstallPreCommit ¶
InstallPreCommit writes a git pre-commit hook that runs dibs. If a pre-commit hook already exists and isn't ours, it is left untouched and instructions are returned in the error.
func RunClaude ¶
RunClaude implements `dibs hook claude`. It reads the PreToolUse JSON on stdin and exits 2 (block) when the edited file is leased by another agent. Anything unexpected fails open: a broken hook must never lock a developer out of their own repository.
func RunPreCommit ¶
RunPreCommit implements `dibs hook pre-commit`: it blocks a commit when staged files intersect another agent's lease.
func UninstallClaude ¶
UninstallClaude removes the dibs hook command, leaving everything else as it was — including user hooks that share a PreToolUse entry with the dibs one.
Types ¶
This section is empty.