( config: Config, )
| 15 | * @returns {Promise<string>} A promise that resolves to the directory context string. |
| 16 | */ |
| 17 | export async function getDirectoryContextString( |
| 18 | config: Config, |
| 19 | ): Promise<string> { |
| 20 | const workspaceContext = config.getWorkspaceContext(); |
| 21 | const workspaceDirectories = workspaceContext.getDirectories(); |
| 22 | |
| 23 | const folderStructures = await Promise.all( |
| 24 | workspaceDirectories.map((dir) => |
| 25 | getFolderStructure(dir, { |
| 26 | fileService: config.getFileService(), |
| 27 | }), |
| 28 | ), |
| 29 | ); |
| 30 | |
| 31 | const folderStructure = folderStructures.join('\n'); |
| 32 | |
| 33 | let workingDirPreamble: string; |
| 34 | if (workspaceDirectories.length === 1) { |
| 35 | workingDirPreamble = `I'm currently working in the directory: ${workspaceDirectories[0]}`; |
| 36 | } else { |
| 37 | const dirList = workspaceDirectories.map((dir) => ` - ${dir}`).join('\n'); |
| 38 | workingDirPreamble = `I'm currently working in the following directories:\n${dirList}`; |
| 39 | } |
| 40 | |
| 41 | return `${workingDirPreamble} |
| 42 | Here is the folder structure of the current working directories: |
| 43 | |
| 44 | ${folderStructure}`; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Retrieves environment-related information to be included in the chat context. |
no test coverage detected