@@ -484,14 +484,20 @@ bool install_claude(const std::wstring& exePath) {
484484 }
485485 }
486486
487- // Build hook object (directly in Stop array, no nested "hooks" )
488- JsonObject hookObj ;
489- hookObj .SetNamedValue (L" type" , JsonValue::CreateStringValue (L" command" ));
487+ // Build hook structure with nested "hooks" array (required by Claude Code )
488+ JsonObject innerHook ;
489+ innerHook .SetNamedValue (L" type" , JsonValue::CreateStringValue (L" command" ));
490490
491491 std::wstring escapedPath = escape_json_string (exePath);
492492 std::wstring command = escapedPath + L" \" Claude needs attention\" -t \" Claude Code\" " ;
493- hookObj.SetNamedValue (L" command" , JsonValue::CreateStringValue (command));
494- hookObj.SetNamedValue (L" timeout" , JsonValue::CreateNumberValue (5000 ));
493+ innerHook.SetNamedValue (L" command" , JsonValue::CreateStringValue (command));
494+ innerHook.SetNamedValue (L" timeout" , JsonValue::CreateNumberValue (5000 ));
495+
496+ JsonArray innerHooks;
497+ innerHooks.Append (innerHook);
498+
499+ JsonObject hookItem;
500+ hookItem.SetNamedValue (L" hooks" , innerHooks);
495501
496502 // Get or create hooks object
497503 JsonObject hooksObj;
@@ -508,7 +514,7 @@ bool install_claude(const std::wstring& exePath) {
508514 }
509515 }
510516
511- stopArray.Append (hookObj );
517+ stopArray.Append (hookItem );
512518 hooksObj.SetNamedValue (L" Stop" , stopArray);
513519 rootObj.SetNamedValue (L" hooks" , hooksObj);
514520
@@ -534,14 +540,20 @@ bool install_gemini(const std::wstring& exePath) {
534540 }
535541 }
536542
537- // Build hook object (directly in AfterAgent array, no nested "hooks" )
538- JsonObject hookObj ;
539- hookObj .SetNamedValue (L" type" , JsonValue::CreateStringValue (L" command" ));
543+ // Build hook structure with nested "hooks" array (required by Gemini CLI )
544+ JsonObject innerHook ;
545+ innerHook .SetNamedValue (L" type" , JsonValue::CreateStringValue (L" command" ));
540546
541547 std::wstring escapedPath = escape_json_string (exePath);
542548 std::wstring command = escapedPath + L" \" Gemini finished\" -t \" Gemini\" " ;
543- hookObj.SetNamedValue (L" command" , JsonValue::CreateStringValue (command));
544- hookObj.SetNamedValue (L" timeout" , JsonValue::CreateNumberValue (5000 ));
549+ innerHook.SetNamedValue (L" command" , JsonValue::CreateStringValue (command));
550+ innerHook.SetNamedValue (L" timeout" , JsonValue::CreateNumberValue (5000 ));
551+
552+ JsonArray innerHooks;
553+ innerHooks.Append (innerHook);
554+
555+ JsonObject hookItem;
556+ hookItem.SetNamedValue (L" hooks" , innerHooks);
545557
546558 // Get or create hooks object
547559 JsonObject hooksObj;
@@ -558,7 +570,7 @@ bool install_gemini(const std::wstring& exePath) {
558570 }
559571 }
560572
561- afterAgentArray.Append (hookObj );
573+ afterAgentArray.Append (hookItem );
562574 hooksObj.SetNamedValue (L" AfterAgent" , afterAgentArray);
563575 rootObj.SetNamedValue (L" hooks" , hooksObj);
564576
0 commit comments