[CmdletBinding()] param( [string]$ProjectRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path ) $ErrorActionPreference = 'Stop' $agentsDir = Join-Path $ProjectRoot '.agents' $skillDir = Join-Path $agentsDir 'skills\telecom-rd-standards' $sourceDir = Join-Path $skillDir 'references\source-documents' $mapPath = Join-Path $skillDir 'references\standards-map.md' $guideDir = Join-Path $agentsDir 'references\quick-guides' $functionalReferenceNames = @( '01-project-init-and-architecture.md', '02-requirements-and-traceability.md', '03-code-standards.md', '04-database-and-data-model.md', '05-api-and-rd-cloud-integration.md', '06-security-and-secrets.md', '07-repository-and-change-management.md', '08-ci-artifacts-and-release.md', '09-testing-and-deployment.md' ) $requiredPaths = @( (Join-Path $ProjectRoot 'AGENTS.md'), (Join-Path $agentsDir 'INDEX.md'), (Join-Path $skillDir 'SKILL.md'), $mapPath, $sourceDir, $guideDir ) $missing = $requiredPaths | Where-Object { -not (Test-Path -LiteralPath $_) } if ($missing) { throw "Missing required paths: $($missing -join '; ')" } $sourceFiles = Get-ChildItem -LiteralPath $sourceDir -File -Filter '*.md' if ($sourceFiles.Count -ne 19) { throw "Expected 19 source documents; found $($sourceFiles.Count)." } $invalidSourceNames = $sourceFiles | Where-Object { $_.Name -notmatch '^[0-9]{2}-[a-z0-9-]+\.md$' } if ($invalidSourceNames) { throw "Non-standard source filenames: $($invalidSourceNames.Name -join ', ')" } $legacyTextFiles = Get-ChildItem -LiteralPath $sourceDir -File -Filter '*.txt' if ($legacyTextFiles) { throw "Legacy TXT source documents remain: $($legacyTextFiles.Name -join ', ')" } $standardsMap = Get-Content -LiteralPath $mapPath -Raw $unindexedSources = $sourceFiles | Where-Object { $standardsMap -notmatch [regex]::Escape($_.Name) } if ($unindexedSources) { throw "Source documents missing from standards map: $($unindexedSources.Name -join ', ')" } $guideFiles = Get-ChildItem -LiteralPath $guideDir -File -Filter '*.md' if ($guideFiles.Count -ne 13) { throw "Expected 13 quick guides; found $($guideFiles.Count)." } $index = Get-Content -LiteralPath (Join-Path $agentsDir 'INDEX.md') -Raw $unindexedGuides = $guideFiles | Where-Object { $index -notmatch [regex]::Escape($_.Name) } if ($unindexedGuides) { throw "Quick guides missing from index: $($unindexedGuides.Name -join ', ')" } $missingFunctionalReferences = $functionalReferenceNames | Where-Object { -not (Test-Path -LiteralPath (Join-Path $skillDir "references\$_")) } if ($missingFunctionalReferences) { throw "Missing functional references: $($missingFunctionalReferences -join ', ')" } $skill = Get-Content -LiteralPath (Join-Path $skillDir 'SKILL.md') -Raw $unlinkedFunctionalReferences = $functionalReferenceNames | Where-Object { $skill -notmatch [regex]::Escape($_) -or $index -notmatch [regex]::Escape($_) } if ($unlinkedFunctionalReferences) { throw "Functional references missing from SKILL.md or INDEX.md: $($unlinkedFunctionalReferences -join ', ')" } Write-Output "Agent starter is valid: 19 source documents, 13 quick guides, and 9 functional references are indexed."