MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / createDiscoveredProjectReader

Function createDiscoveredProjectReader

sdk/src/run-state.ts:203–226  ·  view source on GitHub ↗
(params: {
  cwd: string
  fs: CodebuffFileSystem
  logger: Logger
})

Source from the content-addressed store, hash-verified

201}
202
203function createDiscoveredProjectReader(params: {
204 cwd: string
205 fs: CodebuffFileSystem
206 logger: Logger
207}): (filePath: string) => Promise<string | null> {
208 const { cwd, fs, logger } = params
209
210 return async (filePath: string) => {
211 const fullPath = path.join(cwd, filePath)
212 try {
213 const stats = await fs.stat(fullPath)
214 if (getFileSize(stats) > MAX_DISCOVERED_PROJECT_READ_BYTES) {
215 return null
216 }
217 return await fs.readFile(fullPath, 'utf8')
218 } catch (error) {
219 logger.debug?.(
220 { filePath, error: getErrorObject(error) },
221 'Failed to read discovered project file for symbol scoring',
222 )
223 return null
224 }
225 }
226}
227
228function getFileSize(stats: Awaited<ReturnType<CodebuffFileSystem['stat']>>) {
229 return typeof stats.size === 'number' ? stats.size : 0

Callers 1

getProjectIndexInputFunction · 0.85

Calls 3

getErrorObjectFunction · 0.90
getFileSizeFunction · 0.85
readFileMethod · 0.80

Tested by

no test coverage detected