@@ -86,18 +86,62 @@ test("scanFileMentionItems returns relative slash-separated files and directorie
8686 try {
8787 fs . mkdirSync ( path . join ( root , "src" ) ) ;
8888 fs . writeFileSync ( path . join ( root , "src" , "index.ts" ) , "" ) ;
89- fs . mkdirSync ( path . join ( root , "node_modules " ) ) ;
90- fs . writeFileSync ( path . join ( root , "node_modules " , "ignored .js" ) , "" ) ;
89+ fs . mkdirSync ( path . join ( root , "vendor " ) ) ;
90+ fs . writeFileSync ( path . join ( root , "vendor " , "dep .js" ) , "" ) ;
9191
9292 assert . deepEqual (
9393 scanFileMentionItems ( root ) . map ( ( item ) => item . path ) ,
94- [ "node_modules /" , "node_modules/ignored.js " , "src /" , "src/index.ts " ]
94+ [ "src /" , "src/index.ts " , "vendor /" , "vendor/dep.js " ]
9595 ) ;
9696 } finally {
9797 fs . rmSync ( root , { recursive : true , force : true } ) ;
9898 }
9999} ) ;
100100
101+ test ( "scanFileMentionItems applies default noisy-directory ignores when no gitignore is applicable" , ( ) => {
102+ const root = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "deepcode-file-mentions-" ) ) ;
103+ try {
104+ for ( const directory of [
105+ ".next" ,
106+ ".pytest_cache" ,
107+ ".ruff_cache" ,
108+ "__pycache__" ,
109+ "build" ,
110+ "dist" ,
111+ "node_modules" ,
112+ "out" ,
113+ "target" ,
114+ ] ) {
115+ fs . mkdirSync ( path . join ( root , directory ) ) ;
116+ fs . writeFileSync ( path . join ( root , directory , "ignored.txt" ) , "" ) ;
117+ }
118+ fs . mkdirSync ( path . join ( root , ".config" ) ) ;
119+ fs . writeFileSync ( path . join ( root , ".config" , "settings.json" ) , "" ) ;
120+ fs . mkdirSync ( path . join ( root , "src" ) ) ;
121+ fs . writeFileSync ( path . join ( root , "src" , "index.ts" ) , "" ) ;
122+
123+ assert . deepEqual (
124+ scanFileMentionItems ( root ) . map ( ( item ) => item . path ) ,
125+ [ ".config/" , ".config/settings.json" , "src/" , "src/index.ts" ]
126+ ) ;
127+ } finally {
128+ fs . rmSync ( root , { recursive : true , force : true } ) ;
129+ }
130+ } ) ;
131+
132+ test ( "scanFileMentionItems default max item cap is above 2000" , ( ) => {
133+ const root = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "deepcode-file-mentions-" ) ) ;
134+ try {
135+ for ( let index = 0 ; index < 2001 ; index ++ ) {
136+ fs . writeFileSync ( path . join ( root , `file-${ index . toString ( ) . padStart ( 4 , "0" ) } .txt` ) , "" ) ;
137+ }
138+
139+ assert . equal ( scanFileMentionItems ( root ) . length , 2001 ) ;
140+ } finally {
141+ fs . rmSync ( root , { recursive : true , force : true } ) ;
142+ }
143+ } ) ;
144+
101145test ( "scanFileMentionItems respects project gitignore patterns inside git repositories" , ( ) => {
102146 const root = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "deepcode-file-mentions-" ) ) ;
103147 try {
0 commit comments