playbook/scripts/sync_playbook.ps1

42 lines
1.3 KiB
PowerShell

# Sync TSL Playbook snapshot to project root.
# - Copies docs/standards/tsl_playbook/.agents -> .agents
# - Copies docs/standards/tsl_playbook/.gitattributes -> .gitattributes
# Existing targets are backed up before overwrite.
$ErrorActionPreference = "Stop"
$Root = (git rev-parse --show-toplevel 2>$null)
if (-not $Root) { $Root = (Get-Location).Path }
$Src = Join-Path $Root "docs/standards/tsl_playbook"
$AgentsSrc = Join-Path $Src ".agents"
$GitAttrSrc = Join-Path $Src ".gitattributes"
if (-not (Test-Path $AgentsSrc)) {
throw "Playbook snapshot not found at $AgentsSrc. Run git subtree add first."
}
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
$AgentsDst = Join-Path $Root ".agents"
if (Test-Path $AgentsDst) {
$bak = "$AgentsDst.bak.$timestamp"
Move-Item $AgentsDst $bak
Write-Host "Backed up existing .agents -> $bak"
}
Copy-Item $AgentsSrc $AgentsDst -Recurse -Force
Write-Host "Synced .agents from Playbook."
$GitAttrDst = Join-Path $Root ".gitattributes"
if (Test-Path $GitAttrSrc) {
if (Test-Path $GitAttrDst) {
$bak = "$GitAttrDst.bak.$timestamp"
Move-Item $GitAttrDst $bak
Write-Host "Backed up existing .gitattributes -> $bak"
}
Copy-Item $GitAttrSrc $GitAttrDst -Force
Write-Host "Synced .gitattributes from Playbook."
}
Write-Host "Done."