/**
 * install/legacy-paths.mjs — shared registry of legacy install topologies
 * the framework once wrote to but no longer owns. Single source of truth
 * for both:
 *
 *   - BUG-021: `runLegacyCleanup` in `install/runtime-migrate.mjs` knows
 *     which files under a legacy root are framework-owned (safe to
 *     remove) vs user-added (preserve).
 *   - BUG-022: `readSkillInstallState` in `util/skill-installs.mjs` falls
 *     back to `version_file` here when no manifest is present, so a
 *     pre-manifest install still surfaces as "installed" rather than
 *     "missing-skills".
 *
 * Codex evolution: v0.7/v0.8 retargeted the codex transform to write
 * markdown skills under `.codex/agents/` + `.codex/commands/` (with the
 * apt-file-manifest.json next to them). Codex CLI 0.132.0 does not
 * discover skills at either path — its documented surface is
 * `.agents/skills/<folder>/SKILL.md` (per
 * https://developers.openai.com/codex/skills). The v0.8.2 fix inverts
 * this registry: the dead `.codex/` markdown tree becomes the legacy
 * target so `runLegacyCleanup` GCs it on the next `apt-tools init`.
 *
 * Schema:
 *   { [runtimeId]: {
 *       install_root:     relative path the runtime once wrote into,
 *       version_file:     relative path of the legacy `.apt-version` stamp
 *                         (or a path known to never exist, when no version
 *                         stamp was ever written for the legacy topology),
 *       honor_manifest:   when true (default), a present apt-file-manifest.json
 *                         at install_root signals a managed install and the
 *                         cleanup no-ops (`reason: 'managed'`). When false,
 *                         the legacy root is known-dead so the manifest is
 *                         removed alongside framework files (used for surfaces
 *                         like the v0.7/v0.8 codex misdirect that will never
 *                         again be a managed install root).
 *       framework_files:  array of relative paths the installer once owned
 *                         (under install_root).
 *   } }
 *
 * Frozen via Object.freeze so callers cannot mutate the shared registry.
 */

/**
 * @typedef {Object} LegacyInstallPath
 * @property {string} install_root
 * @property {string} version_file
 * @property {boolean} [honor_manifest]  default true; false for known-dead surfaces
 * @property {ReadonlyArray<string>} framework_files
 */

/** @type {Record<string, LegacyInstallPath>} */
export const LEGACY_INSTALL_PATHS = Object.freeze({
	codex: Object.freeze({
		// The v0.7/v0.8 misdirect lived under `.codex/agents/` + `.codex/commands/`
		// (with the orphan apt-file-manifest.json at `.codex/apt-file-manifest.json`).
		// Codex CLI 0.132.0 does not consume any of those paths — see header.
		install_root: '.codex',
		// No `.apt-version` was ever written under `.codex/`; point at a path
		// that doesn't exist so `existsSync` returns false in
		// skill-installs.mjs:67-68 (legacy version_file fallback). The bare
		// apt-file-manifest.json (handled by framework_files) is enough to
		// signal the legacy install.
		version_file: '.codex/.apt-version',
		// Known-dead surface: this `.codex/` topology will never again be
		// a managed Aperant install root, so a manifest sitting here is
		// always stale. Skip the no-op-on-manifest safety and remove the
		// manifest alongside framework_files. Default-true elsewhere
		// preserves the safety for legacy roots that could legitimately
		// re-host a managed install.
		honor_manifest: false,
		// Enumerated from BOTH canonical sources (drift-checked at test time
		// by legacy-cleanup-codex.test.ts):
		//   - For each `packages/framework/skills/apt-*/` directory: the v0.7/v0.8
		//     transform emitted BOTH `agents/<dir>.md` AND `commands/<dir>.md`.
		//   - For each top-level `packages/framework/skills/apt-*.md` file
		//     (fileType=agent in the pipeline): the transform emitted
		//     `agents/<basename>.md`.
		//   - For each `packages/framework/agents/apt-*.md` file: the transform
		//     emitted `agents/<basename>.md` (last-write-wins de-dupe applied
		//     by the pipeline for overlapping outputs).
		//   - Plus the orphan apt-file-manifest.json the install pipeline
		//     stamps at install_root.
		// TODO: follow-up — derive this programmatically per spec ID-06 so
		// new apt-* skills auto-extend the legacy set without an edit here.
		framework_files: Object.freeze([
			'apt-file-manifest.json',
			// agents/<dir>.md — one per skill directory (39 dirs)
			'agents/apt.md',
			'agents/apt-author-skill.md',
			'agents/apt-bootstrap.md',
			'agents/apt-caveman.md',
			'agents/apt-classify.md',
			'agents/apt-close-task.md',
			'agents/apt-create-docs.md',
			'agents/apt-debug.md',
			'agents/apt-design.md',
			'agents/apt-diagram.md',
			'agents/apt-discuss.md',
			'agents/apt-docs.md',
			'agents/apt-execute.md',
			'agents/apt-fan-out.md',
			'agents/apt-handoff.md',
			'agents/apt-improve.md',
			'agents/apt-mockup.md',
			'agents/apt-pause.md',
			'agents/apt-personas.md',
			'agents/apt-plan.md',
			'agents/apt-pr-review.md',
			'agents/apt-prototype.md',
			'agents/apt-quick.md',
			'agents/apt-release-notes.md',
			'agents/apt-research.md',
			'agents/apt-resume.md',
			'agents/apt-review.md',
			'agents/apt-roadmap.md',
			'agents/apt-roundtable.md',
			'agents/apt-run.md',
			'agents/apt-scan.md',
			'agents/apt-setup.md',
			'agents/apt-ship.md',
			'agents/apt-spar.md',
			'agents/apt-stress-test.md',
			'agents/apt-terminal.md',
			'agents/apt-triage.md',
			'agents/apt-update.md',
			'agents/apt-verify.md',
			'agents/apt-verify-proof.md',
			'agents/apt-watch-ci.md',
			'agents/apt-zoom-out.md',
			// commands/<dir>.md — one per skill directory (mirrors agents/)
			'commands/apt.md',
			'commands/apt-author-skill.md',
			'commands/apt-bootstrap.md',
			'commands/apt-caveman.md',
			'commands/apt-classify.md',
			'commands/apt-close-task.md',
			'commands/apt-create-docs.md',
			'commands/apt-debug.md',
			'commands/apt-design.md',
			'commands/apt-diagram.md',
			'commands/apt-discuss.md',
			'commands/apt-docs.md',
			'commands/apt-execute.md',
			'commands/apt-fan-out.md',
			'commands/apt-handoff.md',
			'commands/apt-improve.md',
			'commands/apt-mockup.md',
			'commands/apt-pause.md',
			'commands/apt-personas.md',
			'commands/apt-plan.md',
			'commands/apt-pr-review.md',
			'commands/apt-prototype.md',
			'commands/apt-quick.md',
			'commands/apt-release-notes.md',
			'commands/apt-research.md',
			'commands/apt-resume.md',
			'commands/apt-review.md',
			'commands/apt-roadmap.md',
			'commands/apt-roundtable.md',
			'commands/apt-run.md',
			'commands/apt-scan.md',
			'commands/apt-setup.md',
			'commands/apt-ship.md',
			'commands/apt-spar.md',
			'commands/apt-stress-test.md',
			'commands/apt-terminal.md',
			'commands/apt-triage.md',
			'commands/apt-update.md',
			'commands/apt-verify.md',
			'commands/apt-verify-proof.md',
			'commands/apt-watch-ci.md',
			'commands/apt-zoom-out.md',
			// agents/<basename>.md — packages/framework/agents/apt-*.md (17 files)
			// (overlap with skills/apt-*.md top-level — same outputPath, de-dupe)
			'agents/apt-docs-author.md',
			'agents/apt-executor.md',
			'agents/apt-improver.md',
			'agents/apt-planner.md',
			'agents/apt-pr-review-codebase-fit.md',
			'agents/apt-pr-review-fixer.md',
			'agents/apt-pr-review-logic.md',
			'agents/apt-pr-review-performance.md',
			'agents/apt-pr-review-quality.md',
			'agents/apt-pr-review-security.md',
			'agents/apt-pr-review-self-reviewer.md',
			'agents/apt-pr-review-test-integrity.md',
			'agents/apt-pr-review-validator.md',
			'agents/apt-researcher.md',
			'agents/apt-reviewer.md',
			'agents/apt-team-docs-narrator.md',
			'agents/apt-verifier.md',
		]),
	}),
})
