Stop shipping html-ppt README preview payloads
Constraint: README preview media and pre-rendered verification screenshots are nonessential for installed skills. Rejected: WebP recompression | GIF conversion increased size and static compression leaves unnecessary package payload. Confidence: high Scope-risk: moderate Directive: Use external source pruning fields instead of hand-editing generated plugin assets. Tested: python scripts/validate_marketplace.py; validate_plugin.py plugins/codex/plugins/html-ppt; uv run python -m pytest backend/tests/test_skill_market_publish.py backend/tests/test_skill_market_scheduler.py -q; node web/tests/skills-market-ui.test.mjs; git diff --check Not-tested: PowerShell execution because pwsh/powershell is not installed locally.
This commit is contained in:
@@ -89,6 +89,132 @@ function Copy-DirectoryFiltered {
|
||||
}
|
||||
}
|
||||
|
||||
function Assert-RelativePathValue {
|
||||
param([string]$Path)
|
||||
$trimmed = $Path.Trim()
|
||||
if ([string]::IsNullOrWhiteSpace($Path) -or $trimmed -eq "." -or [System.IO.Path]::IsPathRooted($Path)) {
|
||||
throw "Invalid external source exclude path: $Path"
|
||||
}
|
||||
$parts = $trimmed -split '[\\/]'
|
||||
if ($parts -contains "..") {
|
||||
throw "Invalid external source exclude path: $Path"
|
||||
}
|
||||
}
|
||||
|
||||
function Remove-ConfiguredExcludes {
|
||||
param(
|
||||
[string]$Root,
|
||||
[object]$ExcludePaths,
|
||||
[string]$Within
|
||||
)
|
||||
if ($null -eq $ExcludePaths) {
|
||||
return
|
||||
}
|
||||
foreach ($exclude in @($ExcludePaths)) {
|
||||
$relative = [string]$exclude
|
||||
Assert-RelativePathValue -Path $relative
|
||||
Remove-PathIfExists -Path (Join-Path $Root $relative) -Within $Within
|
||||
}
|
||||
}
|
||||
|
||||
function Get-MarkdownImageTarget {
|
||||
param([string]$Line)
|
||||
$match = [regex]::Match($Line, '^\s*!\[[^\]]*\]\(([^)\s]+)(?:\s+"[^"]*")?\)\s*$')
|
||||
if (-not $match.Success) {
|
||||
return $null
|
||||
}
|
||||
return $match.Groups[1].Value.Trim().Trim("<", ">").Replace("\", "/").TrimStart([char[]]@(".", "/"))
|
||||
}
|
||||
|
||||
function Remove-ReadmeImageReferences {
|
||||
param(
|
||||
[string]$Root,
|
||||
[object]$ImagePathPrefixes
|
||||
)
|
||||
if ($null -eq $ImagePathPrefixes) {
|
||||
return
|
||||
}
|
||||
$prefixes = @(
|
||||
foreach ($prefix in @($ImagePathPrefixes)) {
|
||||
$normalized = ([string]$prefix).Trim().Replace("\", "/").Trim("/")
|
||||
if ($normalized) {
|
||||
$normalized
|
||||
}
|
||||
}
|
||||
)
|
||||
if ($prefixes.Count -eq 0) {
|
||||
return
|
||||
}
|
||||
foreach ($readme in Get-ChildItem -LiteralPath $Root -Recurse -Filter "README*.md" | Where-Object { -not $_.PSIsContainer }) {
|
||||
$lines = @([System.IO.File]::ReadAllLines($readme.FullName, [System.Text.Encoding]::UTF8))
|
||||
$updated = New-Object System.Collections.Generic.List[string]
|
||||
$changed = $false
|
||||
foreach ($line in $lines) {
|
||||
$target = Get-MarkdownImageTarget -Line $line
|
||||
$strip = $false
|
||||
if ($target) {
|
||||
foreach ($prefix in $prefixes) {
|
||||
if ($target -eq $prefix -or $target.StartsWith("$prefix/")) {
|
||||
$strip = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($strip) {
|
||||
$changed = $true
|
||||
} else {
|
||||
$updated.Add($line)
|
||||
}
|
||||
}
|
||||
if ($changed) {
|
||||
Write-Utf8NoBomText -Path $readme.FullName -Text (($updated -join "`n").TrimEnd() + "`n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Remove-ReadmeLines {
|
||||
param(
|
||||
[string]$Root,
|
||||
[object]$LineExcludes
|
||||
)
|
||||
if ($null -eq $LineExcludes) {
|
||||
return
|
||||
}
|
||||
$needles = @(
|
||||
foreach ($lineExclude in @($LineExcludes)) {
|
||||
$needle = [string]$lineExclude
|
||||
if ($needle) {
|
||||
$needle
|
||||
}
|
||||
}
|
||||
)
|
||||
if ($needles.Count -eq 0) {
|
||||
return
|
||||
}
|
||||
foreach ($readme in Get-ChildItem -LiteralPath $Root -Recurse -Filter "README*.md" | Where-Object { -not $_.PSIsContainer }) {
|
||||
$lines = @([System.IO.File]::ReadAllLines($readme.FullName, [System.Text.Encoding]::UTF8))
|
||||
$updated = New-Object System.Collections.Generic.List[string]
|
||||
$changed = $false
|
||||
foreach ($line in $lines) {
|
||||
$strip = $false
|
||||
foreach ($needle in $needles) {
|
||||
if ($line.Contains($needle)) {
|
||||
$strip = $true
|
||||
break
|
||||
}
|
||||
}
|
||||
if ($strip) {
|
||||
$changed = $true
|
||||
} else {
|
||||
$updated.Add($line)
|
||||
}
|
||||
}
|
||||
if ($changed) {
|
||||
Write-Utf8NoBomText -Path $readme.FullName -Text (($updated -join "`n").TrimEnd() + "`n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Read-JsonFile {
|
||||
param([string]$Path)
|
||||
$resolvedPath = (Resolve-Path -LiteralPath $Path).Path
|
||||
@@ -350,6 +476,9 @@ function Sync-CodexPlugin {
|
||||
$dst = Join-Path $pluginDir $include
|
||||
Copy-PathIfExists -Source $src -Destination $dst -Within $RepoRoot
|
||||
}
|
||||
Remove-ConfiguredExcludes -Root $pluginDir -ExcludePaths $Source.excludePaths -Within $RepoRoot
|
||||
Remove-ReadmeImageReferences -Root $pluginDir -ImagePathPrefixes $Source.readmeImageExcludes
|
||||
Remove-ReadmeLines -Root $pluginDir -LineExcludes $Source.readmeLineExcludes
|
||||
Apply-LocalOverrides -PluginDir $pluginDir -Source $Source
|
||||
Write-Provenance -PluginDir $pluginDir -Source $Source -Commit $Commit -SyncedAt $SyncedAt -SourcePath $relativeSourcePath
|
||||
}
|
||||
@@ -407,6 +536,9 @@ function Sync-ClaudeSkill {
|
||||
foreach ($rootFile in $includeRootFiles) {
|
||||
Copy-PathIfExists -Source (Join-Path $ClonePath $rootFile) -Destination (Join-Path $pluginDir $rootFile) -Within $RepoRoot
|
||||
}
|
||||
Remove-ConfiguredExcludes -Root $skillDest -ExcludePaths $Source.excludePaths -Within $RepoRoot
|
||||
Remove-ReadmeImageReferences -Root $pluginDir -ImagePathPrefixes $Source.readmeImageExcludes
|
||||
Remove-ReadmeLines -Root $pluginDir -LineExcludes $Source.readmeLineExcludes
|
||||
|
||||
$description = $metadata.description
|
||||
if (-not $description) {
|
||||
|
||||
Reference in New Issue
Block a user