* Get a ranked file listing for injection into the model. * * @param {string} rootDir - Directory to list * @param {string} taskHint - User task for bonus scoring * @param {object} opts * @param {number} opts.max - Max files to return (default SMALLCODE_FILETREE_MAX)
(rootDir, taskHint, opts = {})
| 161 | * @param {number} opts.max - Max files to return (default SMALLCODE_FILETREE_MAX) |
| 162 | */ |
| 163 | function getSmartListing(rootDir, taskHint, opts = {}) { |
| 164 | const max = opts.max || MAX_FILES; |
| 165 | const entries = scoredFileListing(rootDir, taskHint, opts); |
| 166 | |
| 167 | let sorted; |
| 168 | if (SORT_MODE === 'mtime') { |
| 169 | sorted = entries.sort((a, b) => b.mtime - a.mtime); |
| 170 | } else { |
| 171 | // score desc, then mtime desc as tiebreaker |
| 172 | sorted = entries.sort((a, b) => b.score !== a.score ? b.score - a.score : b.mtime - a.mtime); |
| 173 | } |
| 174 | |
| 175 | return sorted.slice(0, max); |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Format a file listing for the model. Returns a compact string. |
nothing calls this directly
no test coverage detected