sessionhook

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
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

func Install(root string, h vcs.Hooks) (Outcome, error)

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.

Jump to

Keyboard shortcuts

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