Derive the relevant-folder set from the user's prompt.
(promptHint: string | undefined)
| 85 | |
| 86 | /** Derive the relevant-folder set from the user's prompt. */ |
| 87 | function inferRelevantFolders(promptHint: string | undefined): Set<string> { |
| 88 | if (!promptHint) return new Set(); |
| 89 | const lower = promptHint.toLowerCase(); |
| 90 | const folders = new Set<string>(); |
| 91 | for (const { keywords, folders: f } of TOPIC_FOLDER_HINTS) { |
| 92 | const hit = keywords.some(kw => { |
| 93 | // Word-boundary match on each side so "api" matches "api/" but not "rapid" |
| 94 | const re = new RegExp(`(^|[^a-z])${kw}([^a-z]|$)`); |
| 95 | return re.test(lower); |
| 96 | }); |
| 97 | if (hit) for (const folder of f) folders.add(folder); |
| 98 | } |
| 99 | return folders; |
| 100 | } |
| 101 | |
| 102 | export async function buildDirectoryTree( |
| 103 | rootDir: string, |
no test coverage detected