| File | Role |
|---|---|
teaagent/hooks.py |
All hook types, HookRegistry, HookConfig, built-in hooks |
PreToolUseHookFn—(tool_name, arguments) -> dict | None; raiseHookErrorto vetoPostToolUseHookFn—(tool_name, arguments, result) -> dict | NoneSessionHookFn—(session_id, context) -> NonePreCompactHookFn—(context) -> dict | None
HookConfig— holds lists of all 8 hook types +enabled: boolHookRegistry— wrapsHookConfig, exposesregister_*andrun_*methods
HookError— raised by a pre-hook to veto; caught by the runner
HookEvent— 8 enum values (Claude Code compatible names)HookPermissionMode—AUTO,ASK,ALLOW,DENY
lint_check_hook(root, *, tools)— alias forpost_lint_check_hookpost_lint_check_hook(root, *, tools)— runsruff checkafter write toolsrun_tests_hook(root, *, tools, command)— runs pytest after write toolsformat_check_hook(root, *, tools)— runsruff formatafter write toolsshell_command_hook(command, *, tools, on_tools)— arbitrary shell after write toolspermission_check_hook(mode, *, allow_patterns, deny_patterns, destructive_tools)— PreToolUse vetomcp_tool_filter_hook(allowed_tools, blocked_tools)— PreToolUse MCP allow/block listmcp_sampling_hook(max_tokens, temperature)— PreToolUse sampling injectioncontext_file_loader_hook(root)— SessionStart loader for CLAUDE.md/AGENTS.md
hooks.py
├── stdlib: subprocess, dataclasses, enum, pathlib
└── (lazy) teaagent.prompt.load_project_instructions [context_file_loader_hook]
runner/_core.py— createsHookRegistry, callsrun_pre_hooks/run_post_hooksaround each tool callchat_session_controller.py— firesrun_session_start_hooks,run_session_end_hooks- CLI
teaagent run --hookflags would configureHookRegistrybefore hand-off
runner._core: per tool call
HookRegistry.run_pre_hooks(tool_name, arguments)
└── for fn in config.pre_hooks: fn(tool_name, arguments) # may raise HookError
[tool executes]
HookRegistry.run_post_hooks(tool_name, arguments, result)
└── for fn in config.post_hooks: fn(tool_name, arguments, result)
runner._core: session lifecycle
HookRegistry.run_session_start_hooks(session_id, context)
HookRegistry.run_session_end_hooks(session_id, context)