Public/Test-CCReleaseWorkflow.ps1

function Test-CCReleaseWorkflow {
    <#
    .SYNOPSIS
        Reports the state of CodeCompass-managed workflows in a repository — without changing anything.
    .DESCRIPTION
        Read-only adoption assessment. For each workflow CodeCompass.Release would manage, reports
        Absent / Matches / Differs, and lists other (unmanaged) workflow files present so you can spot
        overlap before adopting. With -Diff, shows the actual delta (current vs. what would be written).
    .EXAMPLE
        Test-CCReleaseWorkflow -Path .
    .EXAMPLE
        Test-CCReleaseWorkflow -Path . -Diff
    #>

    [CmdletBinding()]
    [OutputType([pscustomobject])]
    param(
        [Parameter(Position = 0)]
        [string]$Path = '.',

        [switch]$Diff
    )

    $full = (Resolve-Path -LiteralPath $Path).Path
    $service = [CodeCompass.Core.Workflows.WorkflowService]::new()

    if (-not $Diff) {
        $report = $service.Assess($full, 'CodeCompass.Release')
        foreach ($workflow in $report.Workflows) {
            [pscustomobject]@{
                Path   = $workflow.TargetRelativePath
                Status = $workflow.Status.ToString()
                Detail = $workflow.Detail
            }
        }
        foreach ($other in $report.OtherWorkflows) {
            [pscustomobject]@{
                Path   = $other
                Status = 'Unmanaged'
                Detail = 'Not managed by CodeCompass; review for overlap.'
            }
        }
        return
    }

    # -Diff: show the delta between what exists and what CodeCompass would generate.
    foreach ($file in $service.Preview($full, 'CodeCompass.Release')) {
        $target = Join-Path $full $file.RelativePath
        $current = if (Test-Path -LiteralPath $target) { (Get-Content -LiteralPath $target -Raw) } else { '' }
        if ($null -eq $current) { $current = '' }

        $normalizedCurrent = $current -replace "`r`n", "`n" -replace "`r", "`n"
        $normalizedProposed = $file.Content -replace "`r`n", "`n" -replace "`r", "`n"
        if ($normalizedCurrent -eq $normalizedProposed) { continue }

        $verb = if ($normalizedCurrent -eq '') { 'would create' } else { 'would update' }
        "=== $($file.RelativePath) ($verb) ==="
        Get-CCTextDiff -Current $normalizedCurrent -Proposed $normalizedProposed
        ''
    }
}