Coverage for src / infra / hooks / __init__.py: 100%

7 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-01-04 04:43 +0000

1"""Hook logic for Claude Agent SDK. 

2 

3Contains PreToolUse hooks and related constants for blocking dangerous commands 

4and managing tool restrictions. 

5 

6This package provides: 

7- Security hooks: block_dangerous_commands 

8- File caching: FileReadCache, make_file_read_cache_hook 

9- Lint caching: LintCache, make_lint_cache_hook 

10- Locking: make_lock_enforcement_hook, make_stop_hook 

11""" 

12 

13from __future__ import annotations 

14 

15# Re-export all public symbols for backward compatibility 

16from .dangerous_commands import ( 

17 BASH_TOOL_NAMES, 

18 DANGEROUS_PATTERNS, 

19 DESTRUCTIVE_GIT_PATTERNS, 

20 PostToolUseHook, 

21 PreToolUseHook, 

22 SAFE_GIT_ALTERNATIVES, 

23 block_dangerous_commands, 

24 block_mala_disallowed_tools, 

25) 

26from .file_cache import ( 

27 FILE_PATH_KEYS, 

28 FILE_WRITE_TOOLS, 

29 CachedFileInfo, 

30 FileReadCache, 

31 make_file_read_cache_hook, 

32) 

33from .lint_cache import ( 

34 DEFAULT_LINT_TOOLS, 

35 LintCache, 

36 LintCacheEntry, 

37 _detect_lint_command, 

38 _get_git_state, 

39 make_lint_cache_hook, 

40) 

41from .deadlock import ( 

42 make_lock_event_hook, 

43 make_lock_wait_hook, 

44) 

45from .locking import ( 

46 StopHook, 

47 get_lock_holder, 

48 make_lock_enforcement_hook, 

49 make_stop_hook, 

50 run_command, 

51) 

52 

53__all__ = [ 

54 "BASH_TOOL_NAMES", 

55 "DANGEROUS_PATTERNS", 

56 "DEFAULT_LINT_TOOLS", 

57 "DESTRUCTIVE_GIT_PATTERNS", 

58 "FILE_PATH_KEYS", 

59 "FILE_WRITE_TOOLS", 

60 "SAFE_GIT_ALTERNATIVES", 

61 "CachedFileInfo", 

62 "FileReadCache", 

63 "LintCache", 

64 "LintCacheEntry", 

65 "PostToolUseHook", 

66 "PreToolUseHook", 

67 "StopHook", 

68 "_detect_lint_command", 

69 "_get_git_state", 

70 "block_dangerous_commands", 

71 "block_mala_disallowed_tools", 

72 "get_lock_holder", 

73 "make_file_read_cache_hook", 

74 "make_lint_cache_hook", 

75 "make_lock_enforcement_hook", 

76 "make_lock_event_hook", 

77 "make_lock_wait_hook", 

78 "make_stop_hook", 

79 "run_command", 

80]