Sync third-party and MCP marketplace plugins
Constraint: Public skills are published only by explicit administrator action unless they are tracked third-party market sources. Confidence: high Scope-risk: narrow Directive: Keep private/internal skills out of the public marketplace and preserve normal incremental market Git history. Tested: Marketplace validation passed.
This commit is contained in:
@@ -585,6 +585,60 @@ function Set-SkillFrontmatterValue {
|
||||
Write-Utf8NoBomText -Path $SkillFile -Text (($lines -join "`n") + "`n")
|
||||
}
|
||||
|
||||
function Remove-SkillFrontmatterFields {
|
||||
param(
|
||||
[string]$SkillFile,
|
||||
[object]$Fields
|
||||
)
|
||||
$fieldNames = @($Fields | ForEach-Object { ([string]$_).Trim() } | Where-Object { $_ })
|
||||
if ($fieldNames.Count -eq 0) {
|
||||
return
|
||||
}
|
||||
foreach ($fieldName in $fieldNames) {
|
||||
if ($fieldName -notmatch '^[A-Za-z0-9_-]+$') {
|
||||
throw "skillFrontmatterRemovals contains invalid field name: $fieldName"
|
||||
}
|
||||
}
|
||||
$lines = @(Get-Content -LiteralPath $SkillFile)
|
||||
if ($lines.Count -lt 3 -or $lines[0] -ne "---") {
|
||||
return
|
||||
}
|
||||
$endIndex = -1
|
||||
for ($i = 1; $i -lt $lines.Count; $i++) {
|
||||
if ($lines[$i] -eq "---") {
|
||||
$endIndex = $i
|
||||
break
|
||||
}
|
||||
}
|
||||
if ($endIndex -lt 0) {
|
||||
return
|
||||
}
|
||||
$kept = @($lines[0])
|
||||
$skipContinuation = $false
|
||||
for ($i = 1; $i -lt $endIndex; $i++) {
|
||||
$line = $lines[$i]
|
||||
if ($skipContinuation) {
|
||||
if (-not $line.Trim() -or $line -match '^\s') {
|
||||
continue
|
||||
}
|
||||
$skipContinuation = $false
|
||||
}
|
||||
$remove = $false
|
||||
foreach ($fieldName in $fieldNames) {
|
||||
if ($line -match "^$([regex]::Escape($fieldName))\s*:") {
|
||||
$remove = $true
|
||||
$skipContinuation = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (-not $remove) {
|
||||
$kept += $line
|
||||
}
|
||||
}
|
||||
$kept += $lines[$endIndex..($lines.Count - 1)]
|
||||
Write-Utf8NoBomText -Path $SkillFile -Text (($kept -join "`n") + "`n")
|
||||
}
|
||||
|
||||
function Apply-LocalOverrides {
|
||||
param(
|
||||
[string]$PluginDir,
|
||||
@@ -611,6 +665,16 @@ function Apply-LocalOverrides {
|
||||
Set-SkillFrontmatterValue -SkillFile $skillFile -Key "description" -Value $property.Value
|
||||
}
|
||||
}
|
||||
if ($Source.PSObject.Properties.Name -contains "skillFrontmatterRemovals" -and $Source.skillFrontmatterRemovals) {
|
||||
$skillsRoot = Join-Path $PluginDir "skills"
|
||||
foreach ($property in $Source.skillFrontmatterRemovals.PSObject.Properties) {
|
||||
$skillFile = Join-Path (Join-Path $skillsRoot $property.Name) "SKILL.md"
|
||||
if (-not (Test-Path -LiteralPath $skillFile)) {
|
||||
throw "skillFrontmatterRemovals references missing skill: $skillFile"
|
||||
}
|
||||
Remove-SkillFrontmatterFields -SkillFile $skillFile -Fields $property.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-Clone {
|
||||
|
||||
Reference in New Issue
Block a user