@@ -389,22 +389,29 @@ fn assert_codex_plugin_bundle(
389389 plugin_dir : & Path ,
390390 expected_command : & str ,
391391 expected_args : serde_json:: Value ,
392- expected_global_env : bool ,
392+ expected_global_bundle : bool ,
393393) {
394394 let manifest = read_json ( & plugin_dir. join ( ".codex-plugin/plugin.json" ) ) ;
395395 assert_eq ! ( manifest[ "name" ] , "tracedecay" ) ;
396396 assert_eq ! ( manifest[ "version" ] , env!( "CARGO_PKG_VERSION" ) ) ;
397397 assert_eq ! ( manifest[ "license" ] , "MIT" ) ;
398398 assert_eq ! ( manifest[ "skills" ] , "./skills/" ) ;
399399 assert_eq ! ( manifest[ "mcpServers" ] , "./.mcp.json" ) ;
400- assert_eq ! ( manifest[ "hooks" ] , "./hooks/hooks.json" ) ;
400+ if expected_global_bundle {
401+ assert_eq ! ( manifest[ "hooks" ] , "./hooks/hooks.json" ) ;
402+ } else {
403+ assert ! (
404+ manifest. get( "hooks" ) . is_none( ) ,
405+ "repo-local Codex plugin should not declare lifecycle hooks"
406+ ) ;
407+ }
401408
402409 let mcp = read_json ( & plugin_dir. join ( ".mcp.json" ) ) ;
403410 let server = & mcp[ "mcpServers" ] [ "tracedecay" ] ;
404411 assert_eq ! ( server[ "type" ] , "stdio" ) ;
405412 assert_eq ! ( server[ "command" ] , expected_command) ;
406413 assert_eq ! ( server[ "args" ] , expected_args) ;
407- if expected_global_env {
414+ if expected_global_bundle {
408415 assert_eq ! ( server[ "env" ] [ "TRACEDECAY_ENABLE_GLOBAL_DB" ] , "1" ) ;
409416 } else {
410417 assert ! (
@@ -413,14 +420,22 @@ fn assert_codex_plugin_bundle(
413420 ) ;
414421 }
415422
416- let hooks = read_json ( & plugin_dir. join ( "hooks/hooks.json" ) ) ;
417- assert_codex_hooks_registered ( & hooks) ;
418- assert_command_contains_expected_bin (
419- & hooks,
420- "SessionStart" ,
421- "hook-codex-session-start" ,
422- expected_command,
423- ) ;
423+ let hooks_path = plugin_dir. join ( "hooks/hooks.json" ) ;
424+ if expected_global_bundle {
425+ let hooks = read_json ( & hooks_path) ;
426+ assert_codex_hooks_registered ( & hooks) ;
427+ assert_command_contains_expected_bin (
428+ & hooks,
429+ "SessionStart" ,
430+ "hook-codex-session-start" ,
431+ expected_command,
432+ ) ;
433+ } else {
434+ assert ! (
435+ !hooks_path. exists( ) ,
436+ "repo-local Codex plugin should not ship lifecycle hooks"
437+ ) ;
438+ }
424439
425440 let skill = std:: fs:: read_to_string ( plugin_dir. join ( "skills/exploring-code/SKILL.md" ) )
426441 . expect ( "Codex plugin should ship tracedecay steering skills" ) ;
@@ -3463,7 +3478,7 @@ fn test_codex_local_install_creates_repo_plugin_bundle_and_marketplace() {
34633478 ) ;
34643479 assert ! (
34653480 !project. path( ) . join( ".codex/hooks.json" ) . exists( ) ,
3466- "local Codex install should bundle hooks in the repo plugin "
3481+ "local Codex install should not write project Codex hooks "
34673482 ) ;
34683483 assert ! (
34693484 !project. path( ) . join( "AGENTS.md" ) . exists( ) ,
@@ -3628,22 +3643,17 @@ fn test_codex_global_install_bundles_hooks_in_plugin() {
36283643}
36293644
36303645#[ test]
3631- fn test_codex_local_install_bundles_hooks_in_plugin ( ) {
3646+ fn test_codex_local_install_does_not_bundle_hooks ( ) {
36323647 let home = TempDir :: new ( ) . unwrap ( ) ;
36333648 let project = TempDir :: new ( ) . unwrap ( ) ;
36343649
36353650 assert_local_install_success ( "codex" , project. path ( ) , home. path ( ) ) ;
36363651
36373652 let hooks_path = codex_project_plugin_install_dir ( project. path ( ) ) . join ( "hooks/hooks.json" ) ;
36383653 assert ! (
3639- hooks_path. exists( ) ,
3640- "local Codex install should bundle hooks in the repo plugin "
3654+ ! hooks_path. exists( ) ,
3655+ "local Codex install should not bundle project-local hooks "
36413656 ) ;
3642- let hooks = read_json ( & hooks_path) ;
3643- assert_codex_hooks_registered ( & hooks) ;
3644- // Local install must use the resolved absolute tracedecay binary path.
3645- assert_command_contains_bin ( & hooks, "SessionStart" , "hook-codex-session-start" ) ;
3646-
36473657 assert ! (
36483658 !home. path( ) . join( ".codex/hooks.json" ) . exists( ) ,
36493659 "local install must not write the global Codex hooks config"
@@ -3654,11 +3664,6 @@ fn test_codex_local_install_bundles_hooks_in_plugin() {
36543664 ) ;
36553665}
36563666
3657- fn assert_command_contains_bin ( hooks : & serde_json:: Value , event : & str , needle : & str ) {
3658- let expected = expected_tracedecay_bin ( ) ;
3659- assert_command_contains_expected_bin ( hooks, event, needle, & expected) ;
3660- }
3661-
36623667fn assert_command_contains_expected_bin (
36633668 hooks : & serde_json:: Value ,
36643669 event : & str ,
0 commit comments