@@ -36,8 +36,6 @@ def ensure_claude_hook() -> bool:
3636 CLAUDE_CONFIG_DIR .mkdir (exist_ok = True )
3737
3838 # Build the shell command that will create session via API and write session data
39- start_hook_script_path = Path (__file__ ).parent / "config" / "claude_session_hook.py"
40- start_hook_command = f"python3 { start_hook_script_path } > { SESSION_FILE } "
4139
4240 # Build the stop hook command to mark session COMPLETE
4341 stop_hook_script_path = Path (__file__ ).parent / "config" / "claude_session_stop_hook.py"
@@ -63,28 +61,23 @@ def ensure_claude_hook() -> bool:
6361 # Ensure proper structure exists
6462 if "hooks" not in hooks_config :
6563 hooks_config ["hooks" ] = {}
66- if "SessionStart" not in hooks_config ["hooks" ]:
67- hooks_config ["hooks" ]["SessionStart" ] = []
6864 if "Stop" not in hooks_config ["hooks" ]:
6965 hooks_config ["hooks" ]["Stop" ] = []
7066 if "UserPromptSubmit" not in hooks_config ["hooks" ]:
7167 hooks_config ["hooks" ]["UserPromptSubmit" ] = []
7268
7369 # Get existing hooks
74- session_start_hooks = hooks_config ["hooks" ]["SessionStart" ]
7570 stop_hooks = hooks_config ["hooks" ]["Stop" ]
7671 active_hooks = hooks_config ["hooks" ]["UserPromptSubmit" ]
7772
7873 # Check if we're replacing existing hooks
79- replaced_existing = (len (session_start_hooks ) > 0 ) or ( len ( stop_hooks ) > 0 ) or (len (active_hooks ) > 0 )
74+ replaced_existing = (len (stop_hooks ) > 0 ) or (len (active_hooks ) > 0 )
8075
8176 # Create the new hook structures (following Claude's format)
82- new_start_hook_group = {"hooks" : [{"type" : "command" , "command" : start_hook_command }]}
8377 new_stop_hook_group = {"hooks" : [{"type" : "command" , "command" : stop_hook_command }]}
8478 new_active_hook_group = {"hooks" : [{"type" : "command" , "command" : active_hook_command }]}
8579
8680 # Replace all existing hooks with our single hook per event
87- hooks_config ["hooks" ]["SessionStart" ] = [new_start_hook_group ]
8881 hooks_config ["hooks" ]["Stop" ] = [new_stop_hook_group ]
8982 hooks_config ["hooks" ]["UserPromptSubmit" ] = [new_active_hook_group ]
9083
@@ -97,7 +90,6 @@ def ensure_claude_hook() -> bool:
9790 console .print ("✅ Replaced existing Claude hooks (SessionStart, Stop)" , style = "green" )
9891 else :
9992 console .print ("✅ Registered new Claude hooks (SessionStart, Stop)" , style = "green" )
100- console .print (f" Start hook: { start_hook_command } " , style = "dim" )
10193 console .print (f" Stop hook: { stop_hook_command } " , style = "dim" )
10294 console .print (f" Active hook:{ ' ' if len ('Active hook:' ) < 1 else '' } { active_hook_command } " , style = "dim" )
10395
@@ -106,13 +98,6 @@ def ensure_claude_hook() -> bool:
10698 with open (HOOKS_CONFIG_FILE ) as f :
10799 verify_config = json .load (f )
108100
109- # Check that our hooks are in the config
110- found_start_hook = False
111- for hook_group in verify_config .get ("hooks" , {}).get ("SessionStart" , []):
112- for hook in hook_group .get ("hooks" , []):
113- if SESSION_FILE .name in hook .get ("command" , "" ):
114- found_start_hook = True
115- break
116101 found_stop_hook = False
117102 for hook_group in verify_config .get ("hooks" , {}).get ("Stop" , []):
118103 for hook in hook_group .get ("hooks" , []):
@@ -126,7 +111,7 @@ def ensure_claude_hook() -> bool:
126111 found_active_hook = True
127112 break
128113
129- if found_start_hook and found_stop_hook and found_active_hook :
114+ if found_stop_hook and found_active_hook :
130115 console .print ("✅ Hook configuration verified" , style = "dim" )
131116 else :
132117 console .print ("⚠️ Hook was written but verification failed" , style = "yellow" )
0 commit comments