hooks

package
v1.38.5 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AntigravityInstall added in v1.25.0

func AntigravityInstall(version string)

AntigravityInstall registers the chop hook in ~/.antigravity/settings.json.

func AntigravityIsInstalled added in v1.25.0

func AntigravityIsInstalled() (bool, string)

AntigravityIsInstalled checks whether the chop hook is registered in ~/.antigravity/settings.json.

func AntigravityUninstall added in v1.25.0

func AntigravityUninstall()

AntigravityUninstall removes the chop hook from ~/.antigravity/settings.json.

func ApplyConflictFix added in v1.38.2

func ApplyConflictFix(wrapperPath string) error

ApplyConflictFix replaces all Bash PreToolUse hooks in settings.json with a single wrapper hook pointing to wrapperPath.

func AuditLogPath added in v0.6.0

func AuditLogPath() (string, error)

AuditLogPath returns the path to the hook audit log file.

func CodexInstall added in v1.22.0

func CodexInstall(version string)

CodexInstall registers the chop hook in .codex/settings.json.

func CodexIsInstalled added in v1.22.0

func CodexIsInstalled() (bool, string)

CodexIsInstalled checks whether the chop hook is registered in .codex/settings.json.

func CodexUninstall added in v1.22.0

func CodexUninstall()

CodexUninstall removes the chop hook from .codex/settings.json.

func Disable added in v1.10.4

func Disable() error

Disable creates the flag file to stop hook wrapping.

func Enable added in v1.10.4

func Enable() error

Enable removes the flag file to resume hook wrapping.

func ExtractWrappedHooks added in v1.38.4

func ExtractWrappedHooks(scriptPath string) ([]string, error)

ExtractWrappedHooks parses a chop-generated wrapper script and returns the competing hook commands that were embedded in it via _run_hook lines. Returns nil if the file does not exist or contains no _run_hook lines.

func GeminiInstall added in v1.20.0

func GeminiInstall(version string)

GeminiInstall registers the chop hook in .gemini/settings.json.

func GeminiIsInstalled added in v1.20.0

func GeminiIsInstalled() (bool, string)

GeminiIsInstalled checks whether the chop hook is registered in .gemini/settings.json.

func GeminiUninstall added in v1.20.0

func GeminiUninstall()

GeminiUninstall removes the chop hook from .gemini/settings.json.

func GenerateConflictFixScript added in v1.38.2

func GenerateConflictFixScript(conflicts ConflictingBashHooks, chopBinPath string) (string, error)

GenerateConflictFixScript writes a combined Bash PreToolUse wrapper script to ~/.claude/hooks/chop-wrapper.sh. The script runs each competing hook first (forwarding any denial), then invokes chop for command rewriting. Only settings.json conflicts can be auto-fixed; plugin conflicts require manual intervention.

func GetHookCommand added in v1.0.4

func GetHookCommand() string

GetHookCommand returns the command string currently registered in the hook, or "" if not found.

func HasChopAwareHook added in v1.38.2

func HasChopAwareHook() bool

HasChopAwareHook returns true if a Bash PreToolUse hook that is either a direct chop invocation or a chop wrapper script is registered in settings.json. Unlike IsInstalled, this does not require the strict `"<binary>" hook` form.

func Install

func Install(version string)

Install registers the chop hook in ~/.claude/settings.json.

func IsDisabledGlobally added in v1.10.4

func IsDisabledGlobally() bool

IsDisabledGlobally reports whether chop hook wrapping is disabled.

func IsInstalled added in v0.12.0

func IsInstalled() (bool, string)

IsInstalled checks whether the chop hook is registered in ~/.claude/settings.json.

func RunAntigravityHook added in v1.25.0

func RunAntigravityHook()

RunAntigravityHook reads an Antigravity IDE PreToolUse hook payload from stdin, checks if the command should be wrapped with chop, and outputs modified JSON on stdout. Always exits 0.

func RunCodexHook added in v1.22.0

func RunCodexHook()

RunCodexHook reads a Codex CLI PreToolUse hook payload from stdin, checks if the command should be wrapped with chop, and outputs modified JSON on stdout. Always exits 0.

func RunGeminiHook added in v1.20.0

func RunGeminiHook()

RunGeminiHook reads a Gemini CLI BeforeTool hook payload from stdin, checks if the command should be wrapped with chop, and outputs modified JSON on stdout. Always exits 0.

func RunHook

func RunHook()

RunHook reads a Claude Code PreToolUse hook payload from stdin, checks if the command should be wrapped with chop, and outputs modified JSON on stdout. Always exits 0.

func Uninstall

func Uninstall()

Uninstall removes the chop hook from ~/.claude/settings.json.

func UnwrapHooks added in v1.38.4

func UnwrapHooks(version string) ([]string, error)

UnwrapHooks reverses fix-hooks: reinstalls the direct chop hook in settings.json and removes chop-wrapper.sh. Returns the list of commands that were in the wrapper so the caller can inform the user what to re-enable elsewhere.

func WrapperScriptPath added in v1.38.2

func WrapperScriptPath() (string, error)

WrapperScriptPath returns the canonical path for the chop-generated wrapper script.

Types

type ConflictingBashHooks added in v1.38.2

type ConflictingBashHooks struct {
	// SettingsConflicts are non-chop hook commands found in the Bash PreToolUse
	// section of ~/.claude/settings.json.
	SettingsConflicts []string
	// PluginConflicts are plugin hooks.json file paths that declare a Bash
	// PreToolUse hook, adding a competing hook matcher at the Claude Code level.
	PluginConflicts []string
}

ConflictingBashHooks describes hooks that compete with chop's updatedInput output. When multiple Bash PreToolUse hooks are active, Claude Code silently drops updatedInput from all of them (https://github.com/anthropics/claude-code/issues/15897).

func FindConflictingBashHooks added in v1.38.2

func FindConflictingBashHooks() (ConflictingBashHooks, error)

FindConflictingBashHooks scans settings.json and plugin hooks.json files for Bash PreToolUse hooks that would compete with chop's updatedInput output.

func (ConflictingBashHooks) HasConflict added in v1.38.2

func (c ConflictingBashHooks) HasConflict() bool

HasConflict returns true if any conflicting hooks were found.

Jump to

Keyboard shortcuts

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