MCPcopy Create free account
hub / github.com/bearlyai/OpenADE / groupOpenADEHyperPlanByDepth

Function groupOpenADEHyperPlanByDepth

projects/openade-module/src/hyperplan.ts:310–334  ·  view source on GitHub ↗
(strategy: OpenADEHyperPlanStrategy)

Source from the content-addressed store, hash-verified

308}
309
310export function groupOpenADEHyperPlanByDepth(strategy: OpenADEHyperPlanStrategy): OpenADEHyperPlanStep[][] {
311 const stepMap = new Map(strategy.steps.map((step) => [step.id, step]))
312 const depthMap = new Map<string, number>()
313 function depth(id: string): number {
314 const existing = depthMap.get(id)
315 if (existing !== undefined) return existing
316 const step = stepMap.get(id)
317 if (!step || step.inputs.length === 0) {
318 depthMap.set(id, 0)
319 return 0
320 }
321 const value = Math.max(...step.inputs.map(depth)) + 1
322 depthMap.set(id, value)
323 return value
324 }
325
326 const groups = new Map<number, OpenADEHyperPlanStep[]>()
327 for (const step of strategy.steps) {
328 const value = depth(step.id)
329 groups.set(value, [...(groups.get(value) ?? []), step])
330 }
331 return Array.from(groups.entries())
332 .sort(([a], [b]) => a - b)
333 .map(([, steps]) => steps)
334}
335
336export function buildOpenADEHyperPlanStepPrompt(
337 taskDescription: string,

Callers 2

runHeadlessHyperPlanTurnFunction · 0.90

Calls 4

depthFunction · 0.85
entriesMethod · 0.80
setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected