Documentation
¶
Overview ¶
Package skillhook is Physa's session hook in Claude Code's settings.json: one SessionStart entry that runs "physa skill session" at the start of every session, and whether the entry at a path is current, stale, missing or not safe to edit. It writes and removes only Physa's entry. Every other key, hook event and SessionStart entry keeps its value and its order, and is never decoded into Go values; only whitespace may change. It never follows a symlinked settings file, and never edits JSON it cannot read.
Index ¶
Constants ¶
const Command = "physa skill session"
Command is the command Physa's entry runs. An entry is recognised as Physa's by it, since Claude Code's settings carry no marker.
Variables ¶
var ErrUnsafe = errors.New("settings file Physa cannot edit safely")
ErrUnsafe is returned when the settings file is a symlink, not a regular file, not valid JSON, or holds a hooks or SessionStart of another JSON type, so it is left alone.
Functions ¶
func Remove ¶
Remove takes every Physa entry out of the settings file at path, then an emptied SessionStart, then an emptied hooks. The file stays, even as {}. With no Physa entry, the file's bytes are left as they are; a file Physa cannot edit safely returns ErrUnsafe.
func Write ¶
Write puts Physa's current entry in the settings file at path. It replaces a stale entry where it stands, dropping any second one, or appends the entry at the end of SessionStart, creating SessionStart, hooks or the file when absent. A current entry leaves the file's bytes as they are; a file Physa cannot edit safely returns ErrUnsafe.