Documentation
¶
Overview ¶
Package sessionhook installs the hook that stamps Session: on changes made in a Claude Code session, so that learning can join each change to the session that made it (design 07 section 4.1), and it never disables a hook. A repo that ships the hook gets its hooks path pointed at the shipped directory, only when no active hook would be turned off. Any other repo gets Physa's embedded copy written into its default hooks directory, where every hook already there keeps running and the hooks path stays as it was. It never overwrites a hooks path or a hook file: it says instead what it found and how to add the hook by hand.
Index ¶
Constants ¶
const Dir = "tools/hooks"
Dir is where a repo may ship its hooks, relative to its root, and the hooks path Install sets for such a repo.
const Hook = Dir + "/prepare-commit-msg"
Hook is the shipped hook that stamps Session:, relative to the root.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Outcome ¶
type Outcome struct {
Set bool // the hooks path now points at Dir; it was unset
Already bool // the hook was already in place; nothing changed
Written bool // the embedded hook was written to Path
Path string // the hook file, when Written or when found there Already
}
Outcome says what Install did.
func Install ¶
Install makes the repo at root stamp Session:, through h, changing nothing when it refuses. In order: when the hooks path is set, it is Already when it names Dir and the repo ships the hook, and an error otherwise. When the repo ships an executable Hook, the hooks path is set to Dir, unless active hooks in the default hooks directory would be turned off, which is an error. For any other repo the embedded hook is written, executable, to the default hooks directory, leaving the hooks path alone; it is Already when the file holds exactly that hook, and an error, leaving the file, when it holds anything else.