Private/Test-KadenOperatorModelFrontmatterValue.ps1
|
function Test-KadenOperatorModelFrontmatterValue { <# .SYNOPSIS True when a model string can sit unquoted on a YAML model line. .DESCRIPTION Allows a Claude bracket form such as name[effort=high,speed=fast]. Rejects breaks in the frontmatter line: newlines, a document marker, a colon-space, a comment mark, wrapping quotes, or surrounding whitespace. #> param( [Parameter(Mandatory = $true)] [string]$Model ) if ($Model -match '[\r\n]' -or $Model.Contains('---')) { return $false } if ($Model.Contains(': ') -or $Model.Contains(' #')) { return $false } if ($Model.StartsWith('"') -or $Model.StartsWith("'")) { return $false } if ($Model -ne $Model.Trim()) { return $false } $first = $Model.Substring(0, 1) foreach ($mark in @('{', '}', '&', '*', '!', '|', '<', '>')) { if ($first -eq $mark) { return $false } } return $true } |