(params: {
cwd: string
filePaths: string[]
fs: CodebuffFileSystem
logger: Logger
})
| 453 | } |
| 454 | |
| 455 | async function loadKnowledgeFilesFromPaths(params: { |
| 456 | cwd: string |
| 457 | filePaths: string[] |
| 458 | fs: CodebuffFileSystem |
| 459 | logger: Logger |
| 460 | }): Promise<Record<string, string>> { |
| 461 | const { cwd, filePaths, fs, logger } = params |
| 462 | const selectedFilePaths = selectKnowledgeFilePaths(filePaths) |
| 463 | |
| 464 | const knowledgeFiles: Record<string, string> = {} |
| 465 | for (const filePath of selectedFilePaths) { |
| 466 | try { |
| 467 | knowledgeFiles[filePath] = await fs.readFile( |
| 468 | path.join(cwd, filePath), |
| 469 | 'utf8', |
| 470 | ) |
| 471 | } catch (error) { |
| 472 | logger.debug?.( |
| 473 | { filePath, error: getErrorObject(error) }, |
| 474 | 'Failed to read project knowledge file', |
| 475 | ) |
| 476 | } |
| 477 | } |
| 478 | return knowledgeFiles |
| 479 | } |
| 480 | |
| 481 | export async function initialSessionState( |
| 482 | params: InitialSessionStateOptions, |
no test coverage detected