| 8199 | |
| 8200 | const LIST_CAP = 20; |
| 8201 | const compose = (bodies: Body[], rest: Node[]): string => { |
| 8202 | const restInCapOrder = capOrderOf(rest); |
| 8203 | const listed = inIndexOrder(restInCapOrder.slice(0, LIST_CAP), (n) => n); |
| 8204 | const omitted = restInCapOrder.slice(LIST_CAP); |
| 8205 | const out: string[] = [ |
| 8206 | header, |
| 8207 | `Returning ${bodies.length} in full${rest.length ? `; ${rest.length} more listed below` : ''} — pick the one you need (no Read required).`, |
| 8208 | '', |
| 8209 | inIndexOrder(bodies, (b) => b.node).map((b) => b.section).join('\n\n---\n\n'), |
| 8210 | ]; |
| 8211 | if (listed.length) { |
| 8212 | out.push( |
| 8213 | '', |
| 8214 | '**Other definitions**', |
| 8215 | ...listed.map(listLine), |
| 8216 | ); |
| 8217 | if (omitted.length) out.push(omittedLine(omitted)); |
| 8218 | out.push( |
| 8219 | '', |
| 8220 | `> 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.`, |
| 8221 | ); |
| 8222 | } |
| 8223 | return out.join('\n'); |
| 8224 | }; |
| 8225 | |
| 8226 | // Each language still without a body gets its first hand-written |
| 8227 | // definition rendered on top, while the whole answer stays under the |