/**
 * conductor-view.mjs — read-only roadmap surface for the Aperant
 * Conductor's `getRoadmap` tool.
 *
 * Wraps `loadRoadmapForScope` + `listRoadmapScopes` so the Conductor sees
 * the same overlay-aware view every framework command sees. Direct reads
 * of `.aperant/roadmap/*\/phases/*.json` or `milestones.json` would miss
 * the dual-write overlay (seed_id from legacy blob, etc.) — Codex
 * roundtable correction #3.
 *
 * Step 5 of Conductor v2 ship order.
 */

import { loadRoadmapForScope } from './io.mjs'
import { listRoadmapScopes } from './paths.mjs'

/**
 * Build a flat per-scope roadmap snapshot for the Conductor.
 *
 * @param {string} projectRoot
 * @returns {{ scopes: Array<{ scope: string, roadmap: unknown }> }}
 */
export function buildConductorRoadmapView(projectRoot) {
	const scopes = listRoadmapScopes(projectRoot)
	const out = []
	for (const scope of scopes) {
		const roadmap = loadRoadmapForScope(projectRoot, scope)
		if (roadmap !== null) out.push({ scope, roadmap })
	}
	return { scopes: out }
}
