@@ -121,6 +121,17 @@ describe('buildSyncPlan', () => {
121121
122122 expect ( skillsItem ) . toBeTruthy ( ) ;
123123 expect ( skillsItem ?. type ) . toBe ( 'dir' ) ;
124+
125+ const disabledPlan = buildSyncPlan (
126+ normalizeSyncConfig ( { ...config , includeOpencodeSkills : false } ) ,
127+ locations ,
128+ '/repo' ,
129+ 'linux'
130+ ) ;
131+ const disabledSkillsItem = disabledPlan . items . find ( ( item ) =>
132+ item . localPath . endsWith ( '/.config/opencode/skills' )
133+ ) ;
134+ expect ( disabledSkillsItem ) . toBeUndefined ( ) ;
124135 } ) ;
125136
126137 it ( 'filters skills path from extra config paths' , ( ) => {
@@ -152,6 +163,60 @@ describe('buildSyncPlan', () => {
152163 expect ( plan . extraConfigs . allowlist ) . toEqual ( [ customConfigPath ] ) ;
153164 } ) ;
154165
166+ it ( 'includes home .agents directory by default and allows disabling' , ( ) => {
167+ const env = { HOME : '/home/test' } as NodeJS . ProcessEnv ;
168+ const locations = resolveSyncLocations ( env , 'linux' ) ;
169+ const config : SyncConfig = {
170+ repo : { owner : 'acme' , name : 'config' } ,
171+ includeSecrets : false ,
172+ } ;
173+
174+ const plan = buildSyncPlan ( normalizeSyncConfig ( config ) , locations , '/repo' , 'linux' ) ;
175+ const agentsItem = plan . items . find ( ( item ) => item . localPath . endsWith ( '/.agents' ) ) ;
176+
177+ expect ( agentsItem ) . toBeTruthy ( ) ;
178+ expect ( agentsItem ?. repoPath . endsWith ( '/config/.agents' ) ) . toBe ( true ) ;
179+ expect ( agentsItem ?. type ) . toBe ( 'dir' ) ;
180+
181+ const disabledPlan = buildSyncPlan (
182+ normalizeSyncConfig ( { ...config , includeAgentsDir : false } ) ,
183+ locations ,
184+ '/repo' ,
185+ 'linux'
186+ ) ;
187+ const disabledAgentsItem = disabledPlan . items . find ( ( item ) =>
188+ item . localPath . endsWith ( '/.agents' )
189+ ) ;
190+ expect ( disabledAgentsItem ) . toBeUndefined ( ) ;
191+ } ) ;
192+
193+ it ( 'filters home .agents path from extra config paths' , ( ) => {
194+ const env = { HOME : '/home/test' } as NodeJS . ProcessEnv ;
195+ const locations = resolveSyncLocations ( env , 'linux' ) ;
196+ const config : SyncConfig = {
197+ repo : { owner : 'acme' , name : 'config' } ,
198+ includeSecrets : false ,
199+ extraConfigPaths : [ '~/.agents' ] ,
200+ } ;
201+
202+ const plan = buildSyncPlan ( normalizeSyncConfig ( config ) , locations , '/repo' , 'linux' ) ;
203+ expect ( plan . extraConfigs . allowlist . length ) . toBe ( 0 ) ;
204+ } ) ;
205+
206+ it ( 'keeps non-default extra config paths when home .agents is also listed' , ( ) => {
207+ const env = { HOME : '/home/test' } as NodeJS . ProcessEnv ;
208+ const locations = resolveSyncLocations ( env , 'linux' ) ;
209+ const customConfigPath = `${ locations . configRoot } /custom.json` ;
210+ const config : SyncConfig = {
211+ repo : { owner : 'acme' , name : 'config' } ,
212+ includeSecrets : false ,
213+ extraConfigPaths : [ '~/.agents' , customConfigPath ] ,
214+ } ;
215+
216+ const plan = buildSyncPlan ( normalizeSyncConfig ( config ) , locations , '/repo' , 'linux' ) ;
217+ expect ( plan . extraConfigs . allowlist ) . toEqual ( [ customConfigPath ] ) ;
218+ } ) ;
219+
155220 it ( 'includes secrets when includeSecrets is true' , ( ) => {
156221 const env = { HOME : '/home/test' } as NodeJS . ProcessEnv ;
157222 const locations = resolveSyncLocations ( env , 'linux' ) ;
0 commit comments