Repository: dotnet/runtime
File: .github/skills/vmr-codeflow-status/scripts/Get-CodeflowStatus.ps1 (PowerShell)

Code before:
# The agent should use SKILL.md guidance to synthesize contextual recommendations.

$summary = [ordered]@{
    prNumber        = $PRNumber
    repository      = $Repository
    prState         = $pr.state
    currentState    = $currentState
    isCodeflowPR    = ($isMaestroPR -or $isBackflow -or $isForwardFlow)
    flowDirection   = if ($isForwardFlow) { "forward" } elseif ($isBackflow) { "backflow" } else { "unknown" }
    isEmptyDiff     = $isEmptyDiff
    changedFiles    = [int]$pr.changedFiles
    additions       = [int]$pr.additions
    deletions       = [int]$pr.deletions
    subscriptionId  = $subscriptionId
    vmrCommit       = if ($vmrCommit) { Get-ShortSha $vmrCommit } else { $null }
    vmrBranch       = $vmrBranch
}

# Freshness
$hasFresnessData = ($null -ne $vmrCommit -and $null -ne $sourceHeadSha)
$summary.freshness = [ordered]@{
    sourceHeadSha   = if ($sourceHeadSha) { Get-ShortSha $sourceHeadSha } else { $null }
    compareStatus   = $compareStatus
    aheadBy         = $aheadBy
    behindBy        = $behindBy
    isUpToDate      = if ($hasFresnessData) { ($vmrCommit -eq $sourceHeadSha -or $compareStatus -eq 'identical') } else { $null }
}

# Force pushes
$summary.forcePushes = [ordered]@{
    count           = $forcePushEvents.Count
    lastActor       = if ($lastForcePushActor) { $lastForcePushActor } else { $null }
    lastTime        = if ($lastForcePushTime) { $lastForcePushTime.ToString("o") } else { $null }
}

# Warnings
$summary.warnings = [ordered]@{
    conflictCount           = $conflictWarnings.Count
    conflictFiles           = $conflictFiles
    conflictMayBeResolved   = $conflictMayBeResolved
    stalenessCount          = $stalenessWarnings.Count
    stalenessMayBeResolved  = $stalenessMayBeResolved
}

# Commits
$manualCommitCount = if ($manualCommits) { $manualCommits.Count } else { 0 }
$codeflowLikeCount = if ($codeflowLikeManualCommits) { $codeflowLikeManualCommits.Count } else { 0 }
$summary.commits = [ordered]@{
    total                   = if ($prCommits) { $prCommits.Count } else { 0 }
    manual                  = $manualCommitCount
    codeflowLikeManual      = $codeflowLikeCount

Review comment (suggestion):
Typo in variable name: `$hasFresnessData` is misspelled (missing 'h' in "Freshness"). While it works, it makes the summary logic harder to read/search. Rename to `$hasFreshnessData` (and update the single reference) for clarity.
```suggestion
$hasFreshnessData = ($null -ne $vmrCommit -and $null -ne $sourceHeadSha)
$summary.freshness = [ordered]@{
    sourceHeadSha   = if ($sourceHeadSha) { Get-ShortSha $sourceHeadSha } else { $null }
    compareStatus   = $compareStatus
    aheadBy         = $aheadBy
    behindBy        = $behindBy
    isUpToDate      = if ($hasFreshnessData) { ($vmrCommit -eq $sourceHeadSha -or $compareStatus -eq 'identical') } else { $null }
```

Code after:
                                }
                            }
                        }
                    }
                }
                else {
                    Write-Warning "Could not find $traceRepo in VMR source-manifest.json"
                }
            }
        }
    }
}

# --- Step 9: Structured Summary ---
# Emit a JSON summary for the agent to reason over when generating recommendations.
# The agent should use SKILL.md guidance to synthesize contextual recommendations.

$summary = [ordered]@{
    prNumber        = $PRNumber
    repository      = $Repository
    prState         = $pr.state
    currentState    = $currentState
    isCodeflowPR    = ($isBackflow -or $isForwardFlow)
    isMaestroAuthored = $isMaestroPR
    flowDirection   = if ($isForwardFlow) { "forward" } elseif ($isBackflow) { "backflow" } else { "unknown" }
    isEmptyDiff     = $isEmptyDiff
    changedFiles    = [int]$pr.changedFiles
    additions       = [int]$pr.additions
    deletions       = [int]$pr.deletions
    subscriptionId  = $subscriptionId
    vmrCommit       = if ($vmrCommit) { Get-ShortSha $vmrCommit } else { $null }
    vmrBranch       = $vmrBranch
}

# Freshness
$hasFreshnessData = ($null -ne $vmrCommit -and $null -ne $sourceHeadSha)
$summary.freshness = [ordered]@{
    sourceHeadSha   = if ($sourceHeadSha) { Get-ShortSha $sourceHeadSha } else { $null }
    compareStatus   = $compareStatus
    aheadBy         = $aheadBy
    behindBy        = $behindBy
    isUpToDate      = if ($hasFreshnessData) { ($vmrCommit -eq $sourceHeadSha -or $compareStatus -eq 'identical') } else { $null }
}

# Force pushes
$summary.forcePushes = [ordered]@{
    count           = $forcePushEvents.Count
    fetchSucceeded  = $forcePushFetchSucceeded
    lastActor       = if ($lastForcePushActor) { $lastForcePushActor } else { $null }
    lastTime        = if ($lastForcePushTime) { $lastForcePushTime.ToString("o") } else { $null }
}