Private/Get-KadenLegacyProjectId.ps1

function Get-KadenLegacyProjectId {
    <#
    .SYNOPSIS
        Read a valid legacy project identity without changing the legacy file.
    .DESCRIPTION
        A valid `.sync-project-id` is one trimmed line of at most 64 characters:
        lowercase letters, digits, and single hyphens. Anything else is ignored so
        initialization keeps the requested project identity and leaves the file in place.
    #>

    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$ChildRoot
    )

    $path = Join-Path $ChildRoot '.sync-project-id'
    if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
        return $null
    }
    $raw = Get-Content -LiteralPath $path -Raw
    if ([string]::IsNullOrWhiteSpace($raw)) {
        return $null
    }
    $id = $raw.Trim()
    if ($id.Length -gt 64 -or $id -notmatch '^[a-z0-9]+(-[a-z0-9]+)*$') {
        return $null
    }
    return $id
}