MCPcopy
hub / github.com/anomalyco/opencode / pick

Function pick

packages/core/src/catalog.ts:268–277  ·  view source on GitHub ↗
(items: typeof candidates)

Source from the content-addressed store, hash-verified

266 )
267
268 const pick = (items: typeof candidates) => {
269 const maxCost = Math.max(...items.map((item) => item.cost), 0.01)
270 const maxAge = Math.max(...items.map((item) => item.age), 0.01)
271 return pipe(
272 items,
273 Array.sortWith((item) => (item.cost / maxCost) * 0.8 + (item.age / maxAge) * 0.2, Order.Number),
274 Array.map((item) => projectModel(item.model, provider)),
275 Array.head,
276 )
277 }
278
279 return Option.getOrUndefined(
280 pipe(

Callers 2

catalog.tsFile · 0.70
npm.tsFile · 0.70

Calls 2

pipeFunction · 0.85
projectModelFunction · 0.85

Tested by

no test coverage detected