@@ -108,6 +108,60 @@ describe('syncWidgetHooks', () => {
108108 }
109109 } ) ;
110110
111+ it ( 'syncs hooks to an explicit target instead of an overriding local statusLine' , async ( ) => {
112+ const globalPath = path . join ( testClaudeConfigDir , 'settings.json' ) ;
113+ const localPath = path . join ( testClaudeConfigDir , 'settings.local.json' ) ;
114+ fs . writeFileSync ( globalPath , JSON . stringify ( {
115+ statusLine : {
116+ type : 'command' ,
117+ command : CCSTATUSLINE_COMMANDS . NPM ,
118+ padding : 0
119+ }
120+ } , null , 2 ) , 'utf-8' ) ;
121+ fs . writeFileSync ( localPath , JSON . stringify ( {
122+ statusLine : {
123+ type : 'command' ,
124+ command : 'user-custom-tool' ,
125+ padding : 0
126+ }
127+ } , null , 2 ) , 'utf-8' ) ;
128+
129+ const settingsWithSkills = {
130+ ...DEFAULT_SETTINGS ,
131+ lines : [ [ { id : 'skills-1' , type : 'skills' } ] , [ ] , [ ] ]
132+ } ;
133+
134+ await syncWidgetHooks ( settingsWithSkills , { targetPath : globalPath } ) ;
135+
136+ const globalSaved = JSON . parse ( fs . readFileSync ( globalPath , 'utf-8' ) ) as { hooks ?: Record < string , { hooks ?: { command ?: string } [ ] } [ ] > } ;
137+ expect ( globalSaved . hooks ?. PreToolUse ?. [ 0 ] ?. hooks ?. [ 0 ] ?. command ) . toBe ( `${ CCSTATUSLINE_COMMANDS . NPM } --hook` ) ;
138+
139+ const localSaved = JSON . parse ( fs . readFileSync ( localPath , 'utf-8' ) ) as { hooks ?: Record < string , unknown [ ] > ; statusLine ?: { command ?: string } } ;
140+ expect ( localSaved . statusLine ?. command ) . toBe ( 'user-custom-tool' ) ;
141+ expect ( localSaved . hooks ) . toBeUndefined ( ) ;
142+ } ) ;
143+
144+ it ( 'does not create hooks for a non-ccstatusline statusLine command' , async ( ) => {
145+ const localPath = path . join ( testClaudeConfigDir , 'settings.local.json' ) ;
146+ fs . writeFileSync ( localPath , JSON . stringify ( {
147+ statusLine : {
148+ type : 'command' ,
149+ command : 'user-custom-tool' ,
150+ padding : 0
151+ }
152+ } , null , 2 ) , 'utf-8' ) ;
153+
154+ const settingsWithSkills = {
155+ ...DEFAULT_SETTINGS ,
156+ lines : [ [ { id : 'skills-1' , type : 'skills' } ] , [ ] , [ ] ]
157+ } ;
158+
159+ await syncWidgetHooks ( settingsWithSkills ) ;
160+
161+ const localSaved = JSON . parse ( fs . readFileSync ( localPath , 'utf-8' ) ) as { hooks ?: Record < string , unknown [ ] > } ;
162+ expect ( localSaved . hooks ) . toBeUndefined ( ) ;
163+ } ) ;
164+
111165 it ( 'subsequent sync does not recreate hooks in old file' , async ( ) => {
112166 const localPath = path . join ( testClaudeConfigDir , 'settings.local.json' ) ;
113167 fs . writeFileSync ( localPath , JSON . stringify ( {
0 commit comments