Public/Install-CCReleaseWorkflow.ps1

function Install-CCReleaseWorkflow {
    <#
    .SYNOPSIS
        Generates CI and release workflow files for the detected technology into the repository.
    .DESCRIPTION
        Writes .github/workflows/*.yml from the technology provider's templates (PowerShell or .NET),
        recording them in .codecompass/manifest.yml. Idempotent and safe to re-run.

        -Adopt enrols existing workflow files as governed-but-unchanged ('adopted') instead of writing.
        -AdoptFile enrols specific repo-owned files (any relative path) into the manifest as
        'adopted' — reviewed, kept, drift-visible, never overwritten — and performs only that.
        -PullRequest converges the workflows on a new branch and opens a pull request (requires gh)
        rather than writing to the working tree. Supports -WhatIf and -Force.
    .EXAMPLE
        Install-CCReleaseWorkflow -Path .
    .EXAMPLE
        Install-CCReleaseWorkflow -Path . -Adopt
    .EXAMPLE
        Install-CCReleaseWorkflow -Path . -AdoptFile '.github/workflows/e2e.yml'
    .EXAMPLE
        Install-CCReleaseWorkflow -Path . -PullRequest
    #>

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

        [switch]$Force,
        [switch]$Adopt,
        [string[]]$AdoptFile,
        [switch]$PullRequest,
        [string]$Branch = 'codecompass/adopt-release-workflows'
    )

    if ($PullRequest) {
        return Invoke-CCWorkflowPullRequest -Path $Path -Branch $Branch -Cmdlet $PSCmdlet
    }

    if ($AdoptFile) {
        $full = (Resolve-Path -LiteralPath $Path).Path
        $service = [CodeCompass.Core.Workflows.WorkflowService]::new()
        foreach ($relative in $AdoptFile) {
            if (-not $PSCmdlet.ShouldProcess($full, "Adopt repo-owned file '$relative' into the CodeCompass manifest")) {
                [pscustomobject]@{ Path = $relative; Action = 'WouldAdopt'; Detail = 'Enrol as adopted (repo-owned).' }
                continue
            }
            $outcome = $service.AdoptFile($full, $relative, 'CodeCompass.Release')
            [pscustomobject]@{ Path = $outcome.RelativePath; Action = "$($outcome.Action)"; Detail = $outcome.Message }
        }
        return
    }

    Invoke-CCWorkflowSync -Path $Path -Force:$Force -Adopt:$Adopt -Cmdlet $PSCmdlet
}