| 8346 | |
| 8347 | const LIST_CAP = 20; |
| 8348 | const compose = (bodies: Body[], rest: Node[]): string => { |
| 8349 | const restInCapOrder = capOrderOf(rest); |
| 8350 | const listed = inIndexOrder(restInCapOrder.slice(0, LIST_CAP), (n) => n); |
| 8351 | const omitted = restInCapOrder.slice(LIST_CAP); |
| 8352 | const out: string[] = [ |
| 8353 | header, |
| 8354 | `Returning ${bodies.length} in full${rest.length ? `; ${rest.length} more listed below` : ''} — pick the one you need (no Read required).`, |
| 8355 | '', |
| 8356 | inIndexOrder(bodies, (b) => b.node).map((b) => b.section).join('\n\n---\n\n'), |
| 8357 | ]; |
| 8358 | if (listed.length) { |
| 8359 | out.push( |
| 8360 | '', |
| 8361 | '**Other definitions**', |
| 8362 | ...listed.map(listLine), |
| 8363 | ); |
| 8364 | if (omitted.length) out.push(omittedLine(omitted)); |
| 8365 | out.push( |
| 8366 | '', |
| 8367 | `> Need one of these in full? Call codegraph_node again with \`file\` (e.g. \`"${listed[0]!.filePath.split('/').pop()}"\`) or \`line\` — do NOT Read it.`, |
| 8368 | ); |
| 8369 | } |
| 8370 | return out.join('\n'); |
| 8371 | }; |
| 8372 | |
| 8373 | // Each language still without a body gets its first hand-written |
| 8374 | // definition rendered on top, while the whole answer stays under the |