🔧 chore(playbook): add vendoring guide and sync scripts

This commit is contained in:
csh
2025-12-13 19:15:53 +08:00
parent e6fd15fcac
commit 5311f33802
4 changed files with 202 additions and 0 deletions
+51
View File
@@ -0,0 +1,51 @@
@echo off
setlocal enabledelayedexpansion
rem Sync TSL Playbook snapshot to project root.
rem - Copies docs\standards\tsl_playbook\.agents -> .agents
rem - Copies docs\standards\tsl_playbook\.gitattributes -> .gitattributes
rem Existing targets are backed up before overwrite.
for /f "delims=" %%R in ('git rev-parse --show-toplevel 2^>nul') do set "ROOT=%%R"
if "%ROOT%"=="" set "ROOT=%cd%"
set "SRC=%ROOT%\docs\standards\tsl_playbook"
set "AGENTS_SRC=%SRC%\.agents"
set "GITATTR_SRC=%SRC%\.gitattributes"
set "AGENTS_DST=%ROOT%\.agents"
set "GITATTR_DST=%ROOT%\.gitattributes"
if not exist "%AGENTS_SRC%" (
echo ERROR: Playbook snapshot not found at "%AGENTS_SRC%".
echo Run: git subtree add --prefix docs/standards/tsl_playbook ^<playbook-url^> main --squash
exit /b 1
)
if exist "%AGENTS_DST%" (
set "RAND=%RANDOM%"
set "BAK_NAME=.agents.bak.!RAND!"
ren "%AGENTS_DST%" "!BAK_NAME!"
echo Backed up existing .agents -> !BAK_NAME!
)
xcopy "%AGENTS_SRC%" "%AGENTS_DST%\" /e /i /y >nul
if errorlevel 1 (
echo ERROR: failed to copy .agents
exit /b 1
)
echo Synced .agents from Playbook.
if exist "%GITATTR_SRC%" (
if exist "%GITATTR_DST%" (
set "RAND=%RANDOM%"
set "BAK_NAME=.gitattributes.bak.!RAND!"
ren "%GITATTR_DST%" "!BAK_NAME!"
echo Backed up existing .gitattributes -> !BAK_NAME!
)
copy /y "%GITATTR_SRC%" "%GITATTR_DST%" >nul
echo Synced .gitattributes from Playbook.
)
echo Done.
endlocal
+41
View File
@@ -0,0 +1,41 @@
# 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."
+41
View File
@@ -0,0 +1,41 @@
#!/usr/bin/env sh
set -eu
# 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.
ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
SRC="$ROOT/docs/standards/tsl_playbook"
AGENTS_SRC="$SRC/.agents"
GITATTR_SRC="$SRC/.gitattributes"
if [ ! -d "$AGENTS_SRC" ]; then
echo "ERROR: Playbook snapshot not found at $AGENTS_SRC" >&2
echo "Run: git subtree add --prefix docs/standards/tsl_playbook <playbook-url> main --squash" >&2
exit 1
fi
timestamp="$(date +%Y%m%d%H%M%S 2>/dev/null || echo bak)"
AGENTS_DST="$ROOT/.agents"
if [ -e "$AGENTS_DST" ]; then
mv "$AGENTS_DST" "$ROOT/.agents.bak.$timestamp"
echo "Backed up existing .agents -> .agents.bak.$timestamp"
fi
cp -R "$AGENTS_SRC" "$AGENTS_DST"
echo "Synced .agents from Playbook."
if [ -f "$GITATTR_SRC" ]; then
GITATTR_DST="$ROOT/.gitattributes"
if [ -e "$GITATTR_DST" ]; then
mv "$GITATTR_DST" "$ROOT/.gitattributes.bak.$timestamp"
echo "Backed up existing .gitattributes -> .gitattributes.bak.$timestamp"
fi
cp "$GITATTR_SRC" "$GITATTR_DST"
echo "Synced .gitattributes from Playbook."
fi
echo "Done."