@@ -55,7 +55,7 @@ describe('handleInitializationFlowLocally', () => {
5555
5656 describe ( 'knowledge file creation' , ( ) => {
5757 test ( 'creates knowledge.md when it does not exist' , ( ) => {
58- existsSyncSpy . mockImplementation ( ( p : string ) => false )
58+ existsSyncSpy . mockImplementation ( ( _p : string ) => false )
5959
6060 const { postUserMessage } = handleInitializationFlowLocally ( )
6161
@@ -71,15 +71,15 @@ describe('handleInitializationFlowLocally', () => {
7171 } )
7272
7373 test ( 'skips knowledge.md creation when it already exists' , ( ) => {
74- existsSyncSpy . mockImplementation ( ( p : string ) =>
74+ existsSyncSpy . mockImplementation ( ( p : unknown ) =>
7575 p === path . join ( TEST_PROJECT_ROOT , KNOWLEDGE_FILE_NAME ) ,
7676 )
7777
7878 const { postUserMessage } = handleInitializationFlowLocally ( )
7979
8080 // writeFileSync should not be called for knowledge.md
8181 const knowledgeWriteCalls = writeFileSyncSpy . mock . calls . filter (
82- ( call ) => call [ 0 ] === path . join ( TEST_PROJECT_ROOT , KNOWLEDGE_FILE_NAME ) ,
82+ ( call : unknown [ ] ) => call [ 0 ] === path . join ( TEST_PROJECT_ROOT , KNOWLEDGE_FILE_NAME ) ,
8383 )
8484 expect ( knowledgeWriteCalls . length ) . toBe ( 0 )
8585
@@ -105,15 +105,15 @@ describe('handleInitializationFlowLocally', () => {
105105 } )
106106
107107 test ( 'skips .agents directory creation when it already exists' , ( ) => {
108- existsSyncSpy . mockImplementation ( ( p : string ) =>
108+ existsSyncSpy . mockImplementation ( ( p : unknown ) =>
109109 p === path . join ( TEST_PROJECT_ROOT , '.agents' ) ,
110110 )
111111
112112 const { postUserMessage } = handleInitializationFlowLocally ( )
113113
114114 // mkdirSync should not be called for .agents directory
115115 const agentsDirCalls = mkdirSyncSpy . mock . calls . filter (
116- ( call ) => call [ 0 ] === path . join ( TEST_PROJECT_ROOT , '.agents' ) ,
116+ ( call : unknown [ ] ) => call [ 0 ] === path . join ( TEST_PROJECT_ROOT , '.agents' ) ,
117117 )
118118 expect ( agentsDirCalls . length ) . toBe ( 0 )
119119
@@ -138,7 +138,7 @@ describe('handleInitializationFlowLocally', () => {
138138 } )
139139
140140 test ( 'skips .agents/types directory creation when it already exists' , ( ) => {
141- existsSyncSpy . mockImplementation ( ( p : string ) => {
141+ existsSyncSpy . mockImplementation ( ( p : unknown ) => {
142142 // .agents exists, .agents/types exists
143143 return (
144144 p === path . join ( TEST_PROJECT_ROOT , '.agents' ) ||
@@ -150,7 +150,7 @@ describe('handleInitializationFlowLocally', () => {
150150
151151 // mkdirSync should not be called for .agents/types directory
152152 const typesDirCalls = mkdirSyncSpy . mock . calls . filter (
153- ( call ) => call [ 0 ] === path . join ( TEST_PROJECT_ROOT , '.agents' , 'types' ) ,
153+ ( call : unknown [ ] ) => call [ 0 ] === path . join ( TEST_PROJECT_ROOT , '.agents' , 'types' ) ,
154154 )
155155 expect ( typesDirCalls . length ) . toBe ( 0 )
156156
@@ -168,7 +168,7 @@ describe('handleInitializationFlowLocally', () => {
168168 // Check that writeFileSync was called for type files
169169 const typeFiles = [ 'agent-definition.ts' , 'tools.ts' , 'util-types.ts' ]
170170 for ( const fileName of typeFiles ) {
171- const fileCalls = writeFileSyncSpy . mock . calls . filter ( ( call ) =>
171+ const fileCalls = writeFileSyncSpy . mock . calls . filter ( ( call : unknown [ ] ) =>
172172 ( call [ 0 ] as string ) . endsWith ( fileName ) ,
173173 )
174174 expect ( fileCalls . length ) . toBe ( 1 )
@@ -185,7 +185,7 @@ describe('handleInitializationFlowLocally', () => {
185185
186186 test ( 'skips type files that already exist' , ( ) => {
187187 const typesDir = path . join ( TEST_PROJECT_ROOT , '.agents' , 'types' )
188- existsSyncSpy . mockImplementation ( ( p : string ) => {
188+ existsSyncSpy . mockImplementation ( ( p : unknown ) => {
189189 // Only agent-definition.ts exists
190190 return p === path . join ( typesDir , 'agent-definition.ts' )
191191 } )
@@ -194,17 +194,17 @@ describe('handleInitializationFlowLocally', () => {
194194
195195 // agent-definition.ts should NOT be written
196196 const agentDefCalls = writeFileSyncSpy . mock . calls . filter (
197- ( call ) => ( call [ 0 ] as string ) . endsWith ( 'agent-definition.ts' ) ,
197+ ( call : unknown [ ] ) => ( call [ 0 ] as string ) . endsWith ( 'agent-definition.ts' ) ,
198198 )
199199 expect ( agentDefCalls . length ) . toBe ( 0 )
200200
201201 // tools.ts and util-types.ts should be written
202- const toolsCalls = writeFileSyncSpy . mock . calls . filter ( ( call ) =>
202+ const toolsCalls = writeFileSyncSpy . mock . calls . filter ( ( call : unknown [ ] ) =>
203203 ( call [ 0 ] as string ) . endsWith ( 'tools.ts' ) ,
204204 )
205205 expect ( toolsCalls . length ) . toBe ( 1 )
206206
207- const utilTypesCalls = writeFileSyncSpy . mock . calls . filter ( ( call ) =>
207+ const utilTypesCalls = writeFileSyncSpy . mock . calls . filter ( ( call : unknown [ ] ) =>
208208 ( call [ 0 ] as string ) . endsWith ( 'util-types.ts' ) ,
209209 )
210210 expect ( utilTypesCalls . length ) . toBe ( 1 )
@@ -259,7 +259,7 @@ describe('handleInitializationFlowLocally', () => {
259259 describe ( 'error handling' , ( ) => {
260260 test ( 'handles writeFileSync errors for type files gracefully' , ( ) => {
261261 existsSyncSpy . mockReturnValue ( false )
262- writeFileSyncSpy . mockImplementation ( ( p : string ) => {
262+ writeFileSyncSpy . mockImplementation ( ( p : unknown ) => {
263263 if ( ( p as string ) . endsWith ( 'tools.ts' ) ) {
264264 throw new Error ( 'Permission denied' )
265265 }
@@ -277,7 +277,7 @@ describe('handleInitializationFlowLocally', () => {
277277
278278 test ( 'handles writeFileSync errors for knowledge.md gracefully' , ( ) => {
279279 existsSyncSpy . mockReturnValue ( false )
280- writeFileSyncSpy . mockImplementation ( ( p : string ) => {
280+ writeFileSyncSpy . mockImplementation ( ( p : unknown ) => {
281281 if ( ( p as string ) . endsWith ( KNOWLEDGE_FILE_NAME ) ) {
282282 throw new Error ( 'Disk full' )
283283 }
@@ -290,7 +290,7 @@ describe('handleInitializationFlowLocally', () => {
290290
291291 test ( 'handles mkdirSync errors for .agents directory gracefully' , ( ) => {
292292 existsSyncSpy . mockReturnValue ( false )
293- mkdirSyncSpy . mockImplementation ( ( p : string ) => {
293+ mkdirSyncSpy . mockImplementation ( ( p : unknown ) => {
294294 if ( ( p as string ) . endsWith ( '.agents' ) ) {
295295 throw new Error ( 'Cannot create directory' )
296296 }
@@ -303,11 +303,11 @@ describe('handleInitializationFlowLocally', () => {
303303 } )
304304
305305 test ( 'handles mkdirSync errors for .agents/types directory gracefully' , ( ) => {
306- existsSyncSpy . mockImplementation ( ( p : string ) => {
306+ existsSyncSpy . mockImplementation ( ( p : unknown ) => {
307307 // .agents exists but .agents/types doesn't
308308 return p === path . join ( TEST_PROJECT_ROOT , '.agents' )
309309 } )
310- mkdirSyncSpy . mockImplementation ( ( p : string ) => {
310+ mkdirSyncSpy . mockImplementation ( ( p : unknown ) => {
311311 if ( ( p as string ) . endsWith ( 'types' ) ) {
312312 throw new Error ( 'Permission denied for types dir' )
313313 }
@@ -320,7 +320,7 @@ describe('handleInitializationFlowLocally', () => {
320320
321321 test ( 'continues copying other files when one type file fails' , ( ) => {
322322 existsSyncSpy . mockReturnValue ( false )
323- writeFileSyncSpy . mockImplementation ( ( p : string ) => {
323+ writeFileSyncSpy . mockImplementation ( ( p : unknown ) => {
324324 // Only fail for agent-definition.ts
325325 if ( ( p as string ) . endsWith ( 'agent-definition.ts' ) ) {
326326 throw new Error ( 'File locked' )
@@ -342,7 +342,7 @@ describe('handleInitializationFlowLocally', () => {
342342
343343 test ( 'handles non-Error exceptions in type file copying' , ( ) => {
344344 existsSyncSpy . mockReturnValue ( false )
345- writeFileSyncSpy . mockImplementation ( ( p : string ) => {
345+ writeFileSyncSpy . mockImplementation ( ( p : unknown ) => {
346346 if ( ( p as string ) . endsWith ( 'util-types.ts' ) ) {
347347 // Throw a non-Error value
348348 throw 'string error'
@@ -360,7 +360,7 @@ describe('handleInitializationFlowLocally', () => {
360360
361361 test ( 'handles null/undefined exceptions in type file copying' , ( ) => {
362362 existsSyncSpy . mockReturnValue ( false )
363- writeFileSyncSpy . mockImplementation ( ( p : string ) => {
363+ writeFileSyncSpy . mockImplementation ( ( p : unknown ) => {
364364 if ( ( p as string ) . endsWith ( 'tools.ts' ) ) {
365365 // Throw null
366366 throw null
@@ -383,7 +383,7 @@ describe('handleInitializationFlowLocally', () => {
383383 const typesDir = path . join ( agentsDir , 'types' )
384384
385385 // Scenario: knowledge.md exists, .agents exists, but .agents/types and type files don't exist
386- existsSyncSpy . mockImplementation ( ( p : string ) => {
386+ existsSyncSpy . mockImplementation ( ( p : unknown ) => {
387387 return (
388388 p === path . join ( TEST_PROJECT_ROOT , KNOWLEDGE_FILE_NAME ) ||
389389 p === agentsDir
@@ -394,24 +394,24 @@ describe('handleInitializationFlowLocally', () => {
394394
395395 // Should NOT create knowledge.md
396396 const knowledgeWriteCalls = writeFileSyncSpy . mock . calls . filter (
397- ( call ) => call [ 0 ] === path . join ( TEST_PROJECT_ROOT , KNOWLEDGE_FILE_NAME ) ,
397+ ( call : unknown [ ] ) => call [ 0 ] === path . join ( TEST_PROJECT_ROOT , KNOWLEDGE_FILE_NAME ) ,
398398 )
399399 expect ( knowledgeWriteCalls . length ) . toBe ( 0 )
400400
401401 // Should NOT create .agents directory
402402 const agentsDirCalls = mkdirSyncSpy . mock . calls . filter (
403- ( call ) => call [ 0 ] === agentsDir ,
403+ ( call : unknown [ ] ) => call [ 0 ] === agentsDir ,
404404 )
405405 expect ( agentsDirCalls . length ) . toBe ( 0 )
406406
407407 // Should create .agents/types directory
408408 const typesDirCalls = mkdirSyncSpy . mock . calls . filter (
409- ( call ) => call [ 0 ] === typesDir ,
409+ ( call : unknown [ ] ) => call [ 0 ] === typesDir ,
410410 )
411411 expect ( typesDirCalls . length ) . toBe ( 1 )
412412
413413 // Should copy type files
414- const typeFileCalls = writeFileSyncSpy . mock . calls . filter ( ( call ) =>
414+ const typeFileCalls = writeFileSyncSpy . mock . calls . filter ( ( call : unknown [ ] ) =>
415415 ( call [ 0 ] as string ) . startsWith ( typesDir ) ,
416416 )
417417 expect ( typeFileCalls . length ) . toBe ( 3 )
0 commit comments