claudesettings

package
v0.182.7 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const AgentMatcher = "Bash|Write|Edit|MultiEdit|NotebookEdit|Agent|Task"

Variables

This section is empty.

Functions

func Encode

func Encode(settings map[string]any) ([]byte, error)

func EntryPresent

func EntryPresent(entry any, shellCommand string) bool

EntryPresent reports whether one hooks-list entry already carries a handler running shellCommand. It only inspects the "hooks" handlers, not "matcher", so it applies to any hook event's entry shape — SessionStart's entries carry no matcher at all (see skills_hook_install.go).

func MergeAgentHook

func MergeAgentHook(path, shellCommand string) ([]byte, bool, error)

MergeAgentHook returns the settings document with the guard registered, and reports whether anything changed.

The document is decoded into generic maps rather than a typed struct so an unrelated key WB has never heard of survives the round trip untouched. A settings file is the user's, not WB's.

func MergeSessionStart

func MergeSessionStart(path, shellCommand string) ([]byte, bool, error)

MergeSessionStart returns the settings document with the SessionStart hook registered, and reports whether anything changed.

Decoded into generic maps, the same as mergeAgentHookSettings, so any key this command has never heard of -- including every other hook event -- survives the round trip untouched.

func WriteAtomically

func WriteAtomically(path string, document []byte) error

WriteAtomically replaces the settings file through a temporary file in the same directory, so an interrupted write can never leave the user without a settings file.

func WriteAtomicallyInjected

func WriteAtomicallyInjected(path string, document []byte, inj *filewrite.Injector) error

WriteAtomicallyInjected is WriteAtomically's test seam (task-9 PR-2): every production call site reaches it only through WriteAtomically, which always passes a nil *filewrite.Injector, so production behaviour is unchanged; a test passes its own Injector directly to reach a create/write/close/chmod/rename failure branch deterministically. The chmod runs path-based, after close, exactly as before -- unlike this PR's other sites, which chmod the still-open fd -- so it uses filewrite.ChmodPath rather than filewrite.Chmod.

Types

This section is empty.

Jump to

Keyboard shortcuts

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