????param([string]$Root="\\DS-918\chatgpt\ChatGPT-Gouvernance-Projets") $ErrorActionPreference="Stop" if([string]::IsNullOrWhiteSpace($Root)){ $Root="\\DS-918\chatgpt\ChatGPT-Gouvernance-Projets" } $reg = Join-Path $Root "_registry" $outDir = Join-Path $reg "bootpack" $outFile= Join-Path $outDir "BOOTPACK.TXT" $bugKbRoot = Join-Path $reg "BUG_KB.json" $bugKbJsonl= Join-Path (Join-Path $reg "bug_kb") "BUG_KB.json.txt" $patchHist = Join-Path (Join-Path $reg "_patches") "SCRIPT_PATCH_HISTORY.txt" $verFile = Join-Path $reg "VERSIONS_REGISTRY.txt" $rulesDir = Join-Path $reg "rules" $indicesDir= Join-Path $reg "indices" $snapDir = Join-Path $reg "snapshots" if(-not (Test-Path $rulesDir)){ throw "rules missing" } if(-not (Test-Path $indicesDir)){ throw "indices missing" } if(-not (Test-Path $snapDir)){ throw "snapshots missing" } if(-not ((Test-Path $bugKbJsonl) -or (Test-Path $bugKbRoot))){ throw "BUG_KB missing (jsonl or root json)" } if(-not (Test-Path $patchHist)){ throw "SCRIPT_PATCH_HISTORY.txt missing" } if(-not (Test-Path $verFile)){ throw "VERSIONS_REGISTRY.txt missing" } $ruleFiles = Get-ChildItem $rulesDir -File | Where-Object { $_.Name -notmatch "\\.bak(\.|$)" -and ( $_.Name -match "RULE|ENFORCER" -or $_.Name -match "^(SAFE-|MEM-)" ) } $indexFiles = Get-ChildItem $indicesDir -File | Where-Object { $_.Name -notmatch "\\.bak(\.|$)" -and $_.Name -match "^(INDEX_|CHANGELOG_|TODO_)" } $snapshot = Get-ChildItem $snapDir -Filter "snapshot_*.json" -File | Sort-Object LastWriteTime -Descending | Select-Object -First 1 if(-not $snapshot){ throw "No snapshot_*.json" } $files=@() if(Test-Path $bugKbJsonl){ $files += $bugKbJsonl } elseif(Test-Path $bugKbRoot){ $files += $bugKbRoot } $files += $patchHist $files += $verFile $files += $ruleFiles.FullName $files += $indexFiles.FullName $files += $snapshot.FullName $ts=Get-Date -Format "yyyy-MM-dd_HH-mm-ss" if(Test-Path $outFile){ Copy-Item $outFile ($outFile+".bak."+$ts) -Force } $nl=[Environment]::NewLine $hdr=@("# BOOTPACK.TXT",("# Generated: {0}" -f $ts),("# Root: {0}" -f $Root),"# Format: BEGIN/END FILE with Path/Name/Size/SHA256",$nl) -join $nl Set-Content -Path $outFile -Value $hdr -Encoding UTF8 foreach($p in $files){ if(-not (Test-Path $p)){ Write-Warning ("skip missing: {0}" -f $p); continue } $fi=Get-Item $p $rel=$fi.FullName.Replace($Root+[IO.Path]::DirectorySeparatorChar,"") $sha=(Get-FileHash $fi.FullName -Algorithm SHA256).Hash Add-Content -Path $outFile -Value "===== BEGIN FILE =====" -Encoding UTF8 Add-Content -Path $outFile -Value ("Path: {0}" -f $rel) -Encoding UTF8 Add-Content -Path $outFile -Value ("Name: {0}" -f $fi.Name) -Encoding UTF8 Add-Content -Path $outFile -Value ("Size: {0} bytes" -f $fi.Length) -Encoding UTF8 Add-Content -Path $outFile -Value ("SHA256: {0}" -f $sha) -Encoding UTF8 Add-Content -Path $outFile -Value "----- CONTENT START -----" -Encoding UTF8 Get-Content -Raw -Path $fi.FullName | Add-Content -Path $outFile -Encoding UTF8 Add-Content -Path $outFile -Value "----- CONTENT END -----" -Encoding UTF8 Add-Content -Path $outFile -Value "===== END FILE =====" -Encoding UTF8 Add-Content -Path $outFile -Value "" -Encoding UTF8 } Write-Host ("[OK] BOOTPACK.TXT created: {0}" -f $outFile)