Documentation
¶
Overview ¶
Package hookconfig owns the install/uninstall/check logic for Confab hooks in Claude Code's settings.json and Codex's config.toml. Provider methods delegate here so pkg/provider doesn't carry the configuration-file detail.
Index ¶
- func InstallCodexHooks(configPath string) (string, error)
- func InstallCursorHooks(hooksPath string) (string, error)
- func InstallPostToolUseHooks(settingsPath string) error
- func InstallPreToolUseHooks(settingsPath string) error
- func InstallSyncHooks(settingsPath string) error
- func InstallUserPromptSubmitHook(settingsPath string) error
- func IsCodexHooksInstalled(configPath string) (bool, error)
- func IsCursorHooksInstalled(hooksPath string) (bool, error)
- func IsPostToolUseHooksInstalled(settingsPath string) (bool, error)
- func IsPreToolUseHooksInstalled(settingsPath string) (bool, error)
- func IsSyncHooksInstalled(settingsPath string) (bool, error)
- func IsUserPromptSubmitHookInstalled(settingsPath string) (bool, error)
- func UninstallCodexHooks(configPath string) (string, error)
- func UninstallCursorHooks(hooksPath string) (string, error)
- func UninstallPostToolUseHooks(settingsPath string) error
- func UninstallPreToolUseHooks(settingsPath string) error
- func UninstallSyncHooks(settingsPath string) error
- func UninstallUserPromptSubmitHook(settingsPath string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstallCodexHooks ¶
InstallCodexHooks writes the managed Confab hook block into Codex's config.toml at configPath, preserving user content and creating a backup. Returns the configPath that was written.
func InstallCursorHooks ¶ added in v0.17.3
InstallCursorHooks writes Confab's sessionStart + sessionEnd + preToolUse + postToolUse command hooks into Cursor's hooks.json at hooksPath, preserving any user-authored hooks (and unknown top-level keys), backing the file up first, and writing atomically. The tool-use events carry matcher "Shell" (commit/PR linking; 65aq). Re-installing is idempotent: an existing confab command for an event is not duplicated. Returns the hooksPath written.
func InstallPostToolUseHooks ¶
InstallPostToolUseHooks installs the PostToolUse hook for GitHub link tracking.
func InstallPreToolUseHooks ¶
InstallPreToolUseHooks installs the PreToolUse hook for git commit validation. Installs with a "Bash" matcher to intercept git commits.
func InstallSyncHooks ¶
InstallSyncHooks installs SessionStart + SessionEnd hooks for the incremental sync daemon.
func InstallUserPromptSubmitHook ¶
InstallUserPromptSubmitHook installs the UserPromptSubmit hook. Unlike other hooks, UserPromptSubmit doesn't use matchers.
func IsCodexHooksInstalled ¶
IsCodexHooksInstalled parses configPath and returns true only when all three Confab hook events (SessionStart, PreToolUse, PostToolUse) carry a confab command. Existing SessionStart-only installs (pre-CF-492) read as "not installed" so `confab setup` re-emits the managed block and transparently upgrades them.
func IsCursorHooksInstalled ¶ added in v0.17.3
IsCursorHooksInstalled reports true only when all four managed events (sessionStart, sessionEnd, preToolUse, postToolUse) carry a confab command. A legacy two-event install (pre-65aq, lifecycle only) reads as "not installed" so `confab setup` re-emits the managed block and transparently upgrades it. A missing or unparseable file reads as not installed.
func IsPostToolUseHooksInstalled ¶
IsPostToolUseHooksInstalled checks if the PostToolUse hook is installed.
func IsPreToolUseHooksInstalled ¶
IsPreToolUseHooksInstalled checks if the PreToolUse hook is installed.
func IsSyncHooksInstalled ¶
IsSyncHooksInstalled checks whether sync daemon hooks are installed. Recognizes both old ("sync start/stop") and new ("hook session-start/end").
func IsUserPromptSubmitHookInstalled ¶
IsUserPromptSubmitHookInstalled checks if the UserPromptSubmit hook is installed.
func UninstallCodexHooks ¶
UninstallCodexHooks removes the managed Confab hook block from Codex's config.toml, preserving the rest of the file. Returns the configPath even if no block was present.
func UninstallCursorHooks ¶ added in v0.17.3
UninstallCursorHooks removes Confab's managed hook entries from Cursor's hooks.json, preserving every other hook and top-level key. A missing file is a no-op. Returns the hooksPath.
func UninstallPostToolUseHooks ¶
UninstallPostToolUseHooks removes the PostToolUse hook.
func UninstallPreToolUseHooks ¶
UninstallPreToolUseHooks removes the PreToolUse hook.
func UninstallSyncHooks ¶
UninstallSyncHooks removes the sync daemon hooks. Handles both old ("sync start/stop") and new ("hook session-start/end") patterns.
func UninstallUserPromptSubmitHook ¶
UninstallUserPromptSubmitHook removes the UserPromptSubmit hook.
Types ¶
This section is empty.