#!/usr/bin/env nu
# Fix layout_conventions.md violations
# Part 1: Move session files to .coder/

def main [] {
    print "🔧 Fixing layout_conventions.md violations..."
    print ""

    # Session files to move
    let session_files = [
        # AI Service
        {src: "platform/crates/ai-service/PHASE4_API.md", dst: ".coder/platform/ai-service/2026-01-10-phase4-api.info.md"},

        # Control Center UI
        {src: "platform/crates/control-center-ui/LEPTOS_0.8_MIGRATION_COMPLETE.md", dst: ".coder/platform/control-center-ui/2025-12-XX-leptos-migration-complete.done.md"},
        {src: "platform/crates/control-center-ui/LEPTOS_MIGRATION_INDEX.md", dst: ".coder/platform/control-center-ui/2025-12-XX-leptos-migration-index.info.md"},
        {src: "platform/crates/control-center-ui/MIGRATION_VERIFICATION_FINAL.md", dst: ".coder/platform/control-center-ui/2025-12-XX-migration-verification.done.md"},
        {src: "platform/crates/control-center-ui/UI_MOCKUPS.md", dst: ".coder/platform/control-center-ui/2025-12-XX-ui-mockups.info.md"},

        # Orchestrator
        {src: "platform/crates/orchestrator/docs/what_is_next_info.md", dst: ".coder/platform/orchestrator/2025-12-XX-what-is-next.info.md"},

        # Infrastructure
        {src: "platform/infrastructure/oci-registry/IMPLEMENTATION_SUMMARY.md", dst: ".coder/platform/oci-registry/2025-12-XX-implementation.done.md"},

        # Tests
        {src: "tests/integration/IMPLEMENTATION_SUMMARY.md", dst: ".coder/tests/integration/2025-12-XX-implementation.done.md"},

        # Core
        {src: "core/nulib/lib_provisioning/extensions/QUICKSTART.md", dst: ".coder/core/extensions/2025-12-XX-quickstart.info.md"},
        {src: "core/nulib/lib_provisioning/secrets/info_README.md", dst: ".coder/core/secrets/2025-12-XX-info-readme.info.md"},
        {src: "core/nulib/lib_provisioning/ai/kcl_build_ai.md", dst: ".coder/core/ai/2025-12-XX-kcl-build-ai.info.md"},
        {src: "core/nulib/lib_provisioning/ai/info_about.md", dst: ".coder/core/ai/2025-12-XX-info-about.info.md"},
        {src: "core/nulib/lib_provisioning/ai/info_ai.md", dst: ".coder/core/ai/2025-12-XX-info-ai.info.md"},

        # Extensions wrks
        {src: "extensions/wrks/EXTENSIONS.md", dst: ".coder/extensions/2025-12-XX-extensions.info.md"},
        {src: "extensions/wrks/EXTENSION_DEMO.md", dst: ".coder/extensions/2025-12-XX-extension-demo.info.md"},
    ]

    print "📦 Moving session files to .coder/..."
    for file in $session_files {
        if ($file.src | path exists) {
            let dst_dir = ($file.dst | path dirname)
            mkdir $dst_dir
            print $"  - ($file.src) → ($file.dst)"
            mv $file.src $file.dst
        } else {
            print $"  ⚠️  File not found: ($file.src)"
        }
    }

    print "\n✅ Session files moved to .coder/"
    print "\n⚡ Run fix-layout-rename.nu to rename product docs to lowercase"
}
