hook

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallClaude

func InstallClaude(settingsPath string) (changed bool, err error)

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

func InstallPreCommit(st *store.Store) (string, error)

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

func RunClaude(m *coord.Manager, stdin io.Reader, stderr io.Writer) int

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

func RunPreCommit(m *coord.Manager, stderr io.Writer) int

RunPreCommit implements `dibs hook pre-commit`: it blocks a commit when staged files intersect another agent's lease.

func UninstallClaude

func UninstallClaude(settingsPath string) (changed bool, err error)

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.

Jump to

Keyboard shortcuts

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