skillhook

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: Apache-2.0 Imports: 6 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 skillhook is Physa's session hook in a hooks file of Claude Code's settings shape, which Claude Code's settings.json and Codex's hooks.json share: 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

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

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

func Remove(path string) error

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

func Write(path string) error

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.

Types

type State

type State int

State is what a settings file holds of Physa's entry.

const (
	// Missing means no file, no hooks, no SessionStart, or no Physa entry.
	Missing State = iota
	// Current means one Physa entry, exactly as this Physa writes it.
	Current
	// Stale means a Physa entry that differs, or more than one.
	Stale
	// Other means a file Physa cannot edit safely.
	Other
)

func Read

func Read(path string) (State, error)

Read says what the settings file at path holds of Physa's entry. It never follows a symlink at path.

func (State) String

func (s State) String() string

String names the state as the commands print it.

Jump to

Keyboard shortcuts

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