Skip to main content

Module tool_hooks

Module tool_hooks 

Source

Structs§

PostToolUseTarget
A successful Bash result the Claude Code PostToolUse hook may shrink.
ToolHookConfig
A tool hook configuration for a specific AI coding tool.

Enums§

HookPlatform
Which AI tool platform is invoking the hook. Each platform has a different JSON output format.
HookScope
InstallScope
Where hooks should be written.
IntegrationTier
How sqz reaches a client’s tool output.
ToolFilter
Which tools sqz init should configure.

Constants§

CLAUDE_ALLOW_RULES
Allow rules sqz init adds to Claude Code settings so the two parts the ungrouped rewrite adds never need approval of their own. Neither runs anything: one sets a shell option, the other reads stdin.
SUPPORTED_TOOL_NAMES
Every canonical tool name sqz knows about, in the same order generate_hook_configs emits them. Used by the CLI to list valid options in --only/--skip error messages, and by tests that need to enumerate the supported set.

Functions§

canonicalize_tool_name
Normalise a tool name or alias to its canonical form.
ci_hook_content
CI hook config for Copilot cloud agent + repo-scoped Copilot CLI.
ci_hooks_path
Path of the repo-level CI hook file, read by both local Copilot CLI sessions in this repo and Copilot cloud agent jobs (the sandbox loads only .github/hooks/*.json from the clone).
claude_hooks_compress
Whether sqz’s Claude Code hooks, as sqz init installs them, compress a Bash command’s output in a default-mode session: the PreToolUse rewrite takes it, or it exits 0 and the PostToolUse hook does. Followers and background jobs never finish with output to replace.
claude_post_tool_use_target
Decide whether a Claude Code PostToolUse payload is worth compressing: a Bash call the PreToolUse hook didn’t already pipe through sqz, with text output that Claude Code hasn’t truncated. Claude Code only runs PostToolUse after a command exits 0; a failure goes to PostToolUseFailure, which can’t replace output.
claude_project_settings_needs_update
Dry-run probe for sqz init’s plan phase: would merging sqz’s hook entries change the Claude Code settings file at path?
claude_settings_have_sqz
Whether uninstall would take sqz’s hooks or allow rules out of the settings file at path.
claude_settings_have_sqz_hooks
Whether the Claude Code settings file at path holds any of sqz’s hooks.
claude_settings_stale
Whether a Claude Code settings file has sqz’s PreToolUse hook but not the allow rules or PostToolUse hook sqz init now writes, as an install from an older sqz does. Without the rules the hook leaves every command alone outside bypass mode.
claude_user_hooks_installed
Whether ~/.claude/settings.json holds sqz’s hooks, which run in every project.
claude_user_settings_path
Resolve ~/.claude/settings.json for the current user.
copilot_hook_content
The Copilot CLI hook config sqz installs (v1 camelCase format).
copilot_hooks_path
Path of the user-level Copilot CLI hooks file sqz manages. Honors COPILOT_HOME the same way the CLI does.
gemini_settings_has_sqz
Whether the Gemini CLI settings at path hold sqz’s hook (by its text when not plain JSON).
gemini_settings_needs_update
Whether sqz init would create or change the Gemini CLI settings at path.
generate_hook_configs
Generate hook configuration files for all supported AI tools.
has_sqz_rules
install_ci_hook
Install the repo-level CI hook file. Skip-if-exists unless the existing file is sqz-authored and stale.
install_copilot_hook
Install the Copilot CLI hook file. Returns Ok(None) when Copilot CLI is not installed (no ~/.copilot directory), Ok(Some(changed)) otherwise. Refreshes the file in place when the content is stale.
install_tool_hooks
Install hook configs for detected AI tools in the given project directory.
install_tool_hooks_scoped
Like install_tool_hooks but lets the caller choose between project-local and user-global scope. This is the function sqz init and sqz init --global both call.
install_tool_hooks_scoped_filtered
Like install_tool_hooks_scoped but honours a ToolFilter so callers can restrict sqz init to a subset of the supported tools.
integration_tier
Which tier sqz’s integration for tool_name falls in. Keep in step with what generate_hook_configs actually installs.
legacy_sqz_hook_files
Hook files an older sqz wrote that still hold its hooks.
merge_sqz_gemini_hook
Merge sqz’s hook into existing Gemini CLI settings, keeping everything else.
parse_tool_list
Parse a user-supplied tool list (comma-separated, whitespace-tolerant) into a vector of canonical names.
process_hook
Process a PreToolUse hook invocation from an AI tool.
process_hook_copilot
Process a hook invocation for GitHub Copilot CLI.
process_hook_cursor
Process a hook invocation for Cursor: always an error, so Cursor’s own approval applies.
process_hook_gemini
Process a hook invocation for Gemini CLI.
process_hook_kiro
Process a hook invocation for Kiro (IDE and CLI).
process_hook_windsurf
Process a hook invocation for Windsurf.
refresh_claude_settings
Bring a stale settings file (see claude_settings_stale) up to date, keeping the sqz binary its hook already runs when that still exists.
refresh_sqz_rules
remove_ci_hook
Remove the CI hook file when sqz-authored.
remove_claude_global_hook
Remove sqz’s hook entries from ~/.claude/settings.json without touching any other keys. Symmetric with install_claude_global_at.
remove_claude_project_hook
Remove sqz’s entries from a project’s .claude/settings.local.json, keeping whatever else is in it, such as the permissions Claude Code saves there when you pick “don’t ask again”. Same results as remove_claude_global_hook.
remove_claude_project_hooks_only
Remove sqz’s hooks from the project’s .claude/settings.local.json, keeping every permission.
remove_copilot_hook
Remove the sqz-managed Copilot hook file if present.
remove_legacy_sqz_hooks
Remove sqz’s hooks from those files, deleting emptied ones; returns each changed file and if it went.
remove_sqz_from_gemini_settings
Remove sqz’s hook from .gemini/settings.json, as remove_claude_global_hook does.
remove_sqz_rules
resolve_sqz_binary
The file a config’s sqz binary names: a bare name is looked up on PATH, nothing is run.
sqz_hook_binaries
The sqz binaries the hooks in a hook config or OpenCode plugin file run.
sqz_rules_change
sqz_rules_content
sqz_rules_path
sqz_rules_state