Param( [string]$TargetDir='.', [string]$OutputDir='tests/reports/agents', [string]$Agent='all' ) $bashOk = $false try { & bash -lc 'echo ok' | Out-Null if ($LASTEXITCODE -eq 0) { $bashOk = $true } } catch {} if ($bashOk) { & bash "scripts/agents/run.sh" $TargetDir $OutputDir $Agent exit $LASTEXITCODE } # Fallback PowerShell (best-effort) lorsque bash n'est pas disponible New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null function Write-Report($name, $lines) { $file = Join-Path $OutputDir $name $lines | Out-File -FilePath $file -Encoding UTF8 -Force Write-Host "Rapport: $file" } Set-Location $TargetDir switch ($Agent) { 'documentation' { $missing = @() $required = @('docs/INDEX.md','docs/project/INDEX.md','docs/templates/INDEX.md') foreach ($f in $required) { if (-not (Test-Path $f)) { $missing += $f } } $content = @('# Agent Documentation', '', '## Résultats (fallback PowerShell)') if ($missing.Count -eq 0) { $content += '- Documentation essentielle présente.' } else { $content += '- Fichiers manquants:'; $missing | ForEach-Object { $content += " - $_" } } Write-Report 'documentation_agent.md' $content } 'tests' { $need = @('tests/unit','tests/integration','tests/connectivity','tests/external','tests/performance','tests/logs','tests/reports') $missing = @(); foreach ($d in $need) { if (-not (Test-Path $d)) { $missing += $d } } $content = @('# Agent Tests', '', '## Résultats (fallback PowerShell)') if ($missing.Count -eq 0) { $content += '- Structure de tests conforme.' } else { $content += '- Dossiers manquants:'; $missing | ForEach-Object { $content += " - $_" } } Write-Report 'tests_agent.md' $content } 'performance' { $content = @('# Agent Performance', '', '## Résultats (fallback PowerShell)') if (Test-Path 'tests/performance') { $content += '- tests/performance présent.' } else { $content += '- tests/performance manquant.' } Write-Report 'performance_agent.md' $content } 'quality-technique' { $missing = @() $required = @('README.md','LICENSE','CONTRIBUTING.md','CODE_OF_CONDUCT.md','CHANGELOG.md','.gitea/workflows/ci.yml') foreach ($f in $required) { if (-not (Test-Path $f)) { $missing += $f } } $content = @('# Agent Qualité technique', '', '## Résultats (fallback PowerShell)') if ($missing.Count -eq 0) { $content += '- Fichiers de base présents.' } else { $content += '- Fichiers manquants:'; $missing | ForEach-Object { $content += " - $_" } } Write-Report 'quality_tech.md' $content } 'open-source' { $missing = @() $required = @('LICENSE','CONTRIBUTING.md','CODE_OF_CONDUCT.md','docs/OPEN_SOURCE_CHECKLIST.md') foreach ($f in $required) { if (-not (Test-Path $f)) { $missing += $f } } $content = @('# Agent Open Source', '', '## Résultats (fallback PowerShell)') if ($missing.Count -eq 0) { $content += '- Pre-requis open source présents.' } else { $content += '- Manquants:'; $missing | ForEach-Object { $content += " - $_" } } Write-Report 'open_source_agent.md' $content } 'securite' { $missing = @(); foreach ($f in @('docs/SECURITY_AUDIT.md','.gitea/workflows/ci.yml')) { if (-not (Test-Path $f)) { $missing += $f } } $content = @('# Agent Sécurité', '', '## Résultats (fallback PowerShell)') if ($missing.Count -eq 0) { $content += '- Socle sécurité et CI présents.' } else { $content += '- Manquants:'; $missing | ForEach-Object { $content += " - $_" } } Write-Report 'security_agent.md' $content } 'deploiement' { $missing = @(); foreach ($f in @('docs/DEPLOYMENT.md','.gitea/workflows/ci.yml')) { if (-not (Test-Path $f)) { $missing += $f } } $content = @('# Agent Déploiement', '', '## Résultats (fallback PowerShell)') if ($missing.Count -eq 0) { $content += '- Documentation et CI de déploiement présentes (à valider).' } else { $content += '- Manquants:'; $missing | ForEach-Object { $content += " - $_" } } Write-Report 'deployment_agent.md' $content } 'dependances' { $content = @('# Agent Dépendances', '', '## Résultats (fallback PowerShell)','- Politique à documenter dans ARCHITECTURE/CONFIGURATION/CHANGELOG') Write-Report 'dependances_agent.md' $content } 'compilation' { $content = @('# Agent Compilation', '', '## Résultats (fallback PowerShell)') if (Test-Path '.gitea/workflows/ci.yml') { $content += '- Étapes de build à vérifier dans la CI.' } else { $content += '- CI absente.' } Write-Report 'compilation_agent.md' $content } 'resolution' { $content = @('# Agent Résolution', '', '## Résultats (fallback PowerShell)') if (Test-Path 'archive') { $content += '- Dossier archive/ présent pour REX.' } else { $content += '- Dossier archive/ manquant.' } Write-Report 'resolution_agent.md' $content } 'ssh-scripts' { $found = @(); $paths = @('scripts/auto-ssh-push.sh','scripts/init-ssh-env.sh','scripts/setup-ssh-ci.sh','scripts/scripts/auto-ssh-push.sh','scripts/scripts/init-ssh-env.sh','scripts/scripts/setup-ssh-ci.sh') foreach ($p in $paths) { if (Test-Path $p) { $found += $p } } $content = @('# Agent SSH et scripts', '', '## Résultats (fallback PowerShell)') if ($found.Count -gt 0) { $content += '- Scripts trouvés:'; $found | ForEach-Object { $content += " - $_" } } else { $content += '- Aucun script standard détecté.' } if (Test-Path 'docs/SSH_UPDATE.md') { $content += '- docs/SSH_UPDATE.md présent.' } Write-Report 'ssh_scripts_agent.md' $content } 'frontend' { $content = @('# Agent Frontend', '', '## Résultats (fallback PowerShell)','- Vérifier code splitting, état centralisé, abstraction services (si frontend présent).') Write-Report 'frontend_agent.md' $content } 'gitea' { $need = @('.gitea/ISSUE_TEMPLATE/bug_report.md','.gitea/ISSUE_TEMPLATE/feature_request.md','.gitea/PULL_REQUEST_TEMPLATE.md','.gitea/workflows/ci.yml') $missing = @(); foreach ($f in $need) { if (-not (Test-Path $f)) { $missing += $f } } $content = @('# Agent Gitea', '', '## Résultats (fallback PowerShell)') if ($missing.Count -eq 0) { $content += '- Configuration Gitea présente.' } else { $content += '- Manquants:'; $missing | ForEach-Object { $content += " - $_" } } Write-Report 'gitea_agent.md' $content } 'versionnage' { $missing = @(); foreach ($f in @('CHANGELOG.md','TEMPLATE_VERSION')) { if (-not (Test-Path $f)) { $missing += $f } } $content = @('# Agent Versionnage', '', '## Résultats (fallback PowerShell)') if ($missing.Count -eq 0) { $content += '- CHANGELOG et TEMPLATE_VERSION présents.' } else { $content += '- Manquants:'; $missing | ForEach-Object { $content += " - $_" } } Write-Report 'versionnage_agent.md' $content } 'sync-template' { $content = @('# Agent Synchronisation de template', '', '## Résultats (fallback PowerShell)') if (Test-Path '.gitea/workflows/template-sync.yml') { $content += '- Workflow template-sync présent.' } else { $content += '- Workflow template-sync manquant.' } if (Test-Path '.4nk-sync.yml') { $content += '- Manifeste .4nk-sync.yml présent.' } else { $content += '- Manifeste .4nk-sync.yml manquant.' } Write-Report 'sync_template_agent.md' $content } 'derogations-locales' { $content = @('# Agent Dérogations locales', '', '## Résultats (fallback PowerShell)') if ((Test-Path 'LOCAL_OVERRIDES.yml') -or (Test-Path '.gitea/workflows/LOCAL_OVERRIDES.yml')) { $content += '- Fichier de dérogations détecté.' } else { $content += '- Aucun fichier de dérogations détecté.' } Write-Report 'derogations_locales_agent.md' $content } 'all' { foreach ($a in @('documentation','tests','performance','quality-technique','open-source','securite','deploiement','dependances','compilation','resolution','ssh-scripts','frontend','gitea','versionnage','sync-template','derogations-locales')) { & $PSCommandPath -TargetDir $TargetDir -OutputDir $OutputDir -Agent $a } } default { Write-Error "Agent inconnu (fallback): $Agent"; exit 2 } } exit 0