(strategy: OpenADEHyperPlanStrategy)
| 308 | } |
| 309 | |
| 310 | export 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 | |
| 336 | export function buildOpenADEHyperPlanStepPrompt( |
| 337 | taskDescription: string, |
no test coverage detected