Skip to content

Commit e8d0a95

Browse files
fix: scope argument-hint injection to YAML frontmatter only
Addresses Copilot review: the awk/regex matched description: anywhere in the file. Now both bash and PowerShell track frontmatter boundaries (--- delimiters) and only inject argument-hint after the first description: inside the frontmatter block. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent e8b21fe commit e8d0a95

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

.github/workflows/scripts/create-release-packages.ps1

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,28 @@ function Generate-Commands {
169169
default { '' }
170170
}
171171
if (-not [string]::IsNullOrEmpty($hint)) {
172-
$body = $body -replace '(?m)^(description:.*)$', "`$1`nargument-hint: $hint"
172+
# Scope injection to YAML frontmatter only (between first pair of ---)
173+
$bodyLines = $body -split "`n"
174+
$resultLines = @()
175+
$fmDashCount = 0
176+
$inFm = $false
177+
$hintInjected = $false
178+
foreach ($ln in $bodyLines) {
179+
if ($ln -match '^---$') {
180+
$resultLines += $ln
181+
$fmDashCount++
182+
$inFm = ($fmDashCount -eq 1)
183+
continue
184+
}
185+
if ($inFm -and -not $hintInjected -and $ln -match '^description:') {
186+
$resultLines += $ln
187+
$resultLines += "argument-hint: $hint"
188+
$hintInjected = $true
189+
continue
190+
}
191+
$resultLines += $ln
192+
}
193+
$body = $resultLines -join "`n"
173194
}
174195
}
175196

.github/workflows/scripts/create-release-packages.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,14 @@ generate_commands() {
121121
esac
122122
if [[ -n "$hint" ]]; then
123123
body=$(printf '%s\n' "$body" | awk -v hint="$hint" '
124-
/^description:/ { print; print "argument-hint: " hint; next }
124+
/^---$/ {
125+
print
126+
if (++dash_count == 1) { in_fm = 1 } else { in_fm = 0 }
127+
next
128+
}
129+
in_fm && !injected && /^description:/ {
130+
print; print "argument-hint: " hint; injected = 1; next
131+
}
125132
{ print }
126133
')
127134
fi

0 commit comments

Comments
 (0)