✨ feat(playbook): support multi-language standards layout
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
@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
|
||||
@@ -1,41 +0,0 @@
|
||||
# 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."
|
||||
@@ -1,41 +0,0 @@
|
||||
#!/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."
|
||||
@@ -0,0 +1,87 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
rem Sync standards snapshot to project root.
|
||||
rem - Copies <snapshot>\.agents -> <project-root>\.agents\tsl
|
||||
rem - Copies <snapshot>\.gitattributes -> <project-root>\.gitattributes
|
||||
rem Existing targets are backed up before overwrite.
|
||||
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
for /f "delims=" %%R in ('git -C "%SCRIPT_DIR%" rev-parse --show-toplevel 2^>nul') do set "ROOT=%%R"
|
||||
if "%ROOT%"=="" set "ROOT=%cd%"
|
||||
for %%I in ("%ROOT%") do set "ROOT=%%~fI"
|
||||
|
||||
for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
|
||||
set "AGENTS_SRC=%SRC%\.agents"
|
||||
set "GITATTR_SRC=%SRC%\.gitattributes"
|
||||
set "AGENTS_NS=%AGENTS_NS%"
|
||||
if "%AGENTS_NS%"=="" set "AGENTS_NS=tsl"
|
||||
set "AGENTS_ROOT=%ROOT%\.agents"
|
||||
set "AGENTS_DST=%AGENTS_ROOT%\%AGENTS_NS%"
|
||||
set "GITATTR_DST=%ROOT%\.gitattributes"
|
||||
|
||||
if not exist "%AGENTS_SRC%" (
|
||||
echo ERROR: Standards snapshot not found at "%AGENTS_SRC%".
|
||||
echo Run: git subtree add --prefix ^<your-prefix^> ^<standards-url^> ^<branch^> --squash
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if /I "%SRC%"=="%ROOT%" (
|
||||
echo Skip: snapshot root equals project root.
|
||||
goto AfterGitAttr
|
||||
)
|
||||
|
||||
if not exist "%AGENTS_ROOT%" mkdir "%AGENTS_ROOT%"
|
||||
|
||||
if exist "%AGENTS_DST%" (
|
||||
set "RAND=%RANDOM%"
|
||||
pushd "%AGENTS_ROOT%"
|
||||
ren "%AGENTS_NS%" "%AGENTS_NS%.bak.!RAND!"
|
||||
popd
|
||||
echo Backed up existing %AGENTS_NS% agents -> %AGENTS_NS%.bak.!RAND!
|
||||
)
|
||||
|
||||
xcopy "%AGENTS_SRC%\\*" "%AGENTS_DST%\\" /e /i /y >nul
|
||||
if errorlevel 1 (
|
||||
echo ERROR: failed to copy .agents
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Synced .agents\%AGENTS_NS% from standards.
|
||||
|
||||
if not exist "%AGENTS_ROOT%\index.md" (
|
||||
> "%AGENTS_ROOT%\index.md" echo # .agents(多语言)
|
||||
>> "%AGENTS_ROOT%\index.md" echo.
|
||||
>> "%AGENTS_ROOT%\index.md" echo 本目录用于存放仓库级/语言级的代理规则集。
|
||||
>> "%AGENTS_ROOT%\index.md" echo.
|
||||
>> "%AGENTS_ROOT%\index.md" echo 建议约定:
|
||||
>> "%AGENTS_ROOT%\index.md" echo.
|
||||
>> "%AGENTS_ROOT%\index.md" echo - `.agents/tsl/`:TSL 相关标准(由 `sync_standards.*` 同步)
|
||||
>> "%AGENTS_ROOT%\index.md" echo - `.agents/cpp/`、`.agents/python/` 等:其他语言的规则集(按需增加)
|
||||
>> "%AGENTS_ROOT%\index.md" echo.
|
||||
>> "%AGENTS_ROOT%\index.md" echo 规则发生冲突时,建议以“更靠近代码的目录规则更具体”为准。
|
||||
echo Created .agents\index.md
|
||||
)
|
||||
|
||||
:SyncGitAttr
|
||||
if exist "%GITATTR_SRC%" (
|
||||
for %%I in ("%GITATTR_SRC%") do set "GITATTR_SRC_F=%%~fI"
|
||||
for %%I in ("%GITATTR_DST%") do set "GITATTR_DST_F=%%~fI"
|
||||
if /I "!GITATTR_SRC_F!"=="!GITATTR_DST_F!" (
|
||||
echo Skip: .gitattributes source equals destination.
|
||||
goto AfterGitAttr
|
||||
)
|
||||
|
||||
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 standards.
|
||||
)
|
||||
|
||||
:AfterGitAttr
|
||||
echo Done.
|
||||
endlocal
|
||||
@@ -0,0 +1,82 @@
|
||||
# Sync standards snapshot to project root.
|
||||
# - Copies <snapshot>/.agents -> <project-root>/.agents/tsl
|
||||
# - Copies <snapshot>/.gitattributes -> <project-root>/.gitattributes
|
||||
# Existing targets are backed up before overwrite.
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
|
||||
|
||||
$Root = (git -C $ScriptDir rev-parse --show-toplevel 2>$null)
|
||||
if (-not $Root) { $Root = (Get-Location).Path }
|
||||
$Root = (Resolve-Path $Root).Path
|
||||
|
||||
$AgentsSrc = Join-Path $Src ".agents"
|
||||
$GitAttrSrc = Join-Path $Src ".gitattributes"
|
||||
|
||||
if (-not (Test-Path $AgentsSrc)) {
|
||||
throw "Standards snapshot not found at $AgentsSrc. Run git subtree add first (choose any prefix)."
|
||||
}
|
||||
|
||||
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
|
||||
|
||||
$AgentsNs = $env:AGENTS_NS
|
||||
if (-not $AgentsNs) { $AgentsNs = "tsl" }
|
||||
if ($AgentsNs -match '[\\/]' -or $AgentsNs -match '\.\.') {
|
||||
throw "Invalid AGENTS_NS=$AgentsNs"
|
||||
}
|
||||
$AgentsRoot = Join-Path $Root ".agents"
|
||||
$AgentsDst = Join-Path $AgentsRoot $AgentsNs
|
||||
|
||||
if ($Src -ieq $Root) {
|
||||
Write-Host "Skip: snapshot root equals project root."
|
||||
Write-Host "Done."
|
||||
exit 0
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Path $AgentsRoot -Force | Out-Null
|
||||
|
||||
if (Test-Path $AgentsDst) {
|
||||
$bak = (Join-Path $AgentsRoot "$AgentsNs.bak.$timestamp")
|
||||
Move-Item $AgentsDst $bak
|
||||
Write-Host "Backed up existing $AgentsNs agents -> $(Split-Path -Leaf $bak)"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Path $AgentsDst -Force | Out-Null
|
||||
Copy-Item (Join-Path $AgentsSrc "*") $AgentsDst -Recurse -Force
|
||||
Write-Host "Synced .agents/$AgentsNs from standards."
|
||||
|
||||
$AgentsIndex = Join-Path $AgentsRoot "index.md"
|
||||
if (-not (Test-Path $AgentsIndex)) {
|
||||
@"
|
||||
# .agents(多语言)
|
||||
|
||||
本目录用于存放仓库级/语言级的代理规则集。
|
||||
|
||||
建议约定:
|
||||
|
||||
- `.agents/tsl/`:TSL 相关标准(由 `sync_standards.*` 同步)
|
||||
- `.agents/cpp/`、`.agents/python/` 等:其他语言的规则集(按需增加)
|
||||
|
||||
规则发生冲突时,建议以“更靠近代码的目录规则更具体”为准。
|
||||
"@ | Set-Content -Path $AgentsIndex -Encoding UTF8
|
||||
Write-Host "Created .agents/index.md"
|
||||
}
|
||||
|
||||
$GitAttrDst = Join-Path $Root ".gitattributes"
|
||||
if (Test-Path $GitAttrSrc) {
|
||||
if ($GitAttrSrc -ieq $GitAttrDst) {
|
||||
Write-Host "Skip: .gitattributes source equals destination."
|
||||
Write-Host "Done."
|
||||
exit 0
|
||||
}
|
||||
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 standards."
|
||||
}
|
||||
|
||||
Write-Host "Done."
|
||||
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
# Sync standards snapshot to project root.
|
||||
# - Copies <snapshot>/.agents -> <project-root>/.agents/tsl
|
||||
# - Copies <snapshot>/.gitattributes -> <project-root>/.gitattributes
|
||||
# Existing targets are backed up before overwrite.
|
||||
|
||||
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
|
||||
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
|
||||
ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null || pwd)"
|
||||
ROOT="$(CDPATH= cd -- "$ROOT" && pwd -P)"
|
||||
AGENTS_SRC="$SRC/.agents"
|
||||
GITATTR_SRC="$SRC/.gitattributes"
|
||||
|
||||
if [ ! -d "$AGENTS_SRC" ]; then
|
||||
echo "ERROR: Standards snapshot not found at $AGENTS_SRC" >&2
|
||||
echo "Run: git subtree add --prefix <your-prefix> <standards-url> <branch> --squash" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
timestamp="$(date +%Y%m%d%H%M%S 2>/dev/null || echo bak)"
|
||||
|
||||
if [ "$SRC" = "$ROOT" ]; then
|
||||
echo "Skip: snapshot root equals project root."
|
||||
echo "Done."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
: "${AGENTS_NS:=tsl}"
|
||||
case "$AGENTS_NS" in
|
||||
""|*/*|*\\*|*..*)
|
||||
echo "ERROR: invalid AGENTS_NS=$AGENTS_NS" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
AGENTS_ROOT="$ROOT/.agents"
|
||||
AGENTS_DST="$AGENTS_ROOT/$AGENTS_NS"
|
||||
mkdir -p "$AGENTS_ROOT"
|
||||
|
||||
if [ -e "$AGENTS_DST" ]; then
|
||||
mv "$AGENTS_DST" "$AGENTS_ROOT/$AGENTS_NS.bak.$timestamp"
|
||||
echo "Backed up existing $AGENTS_NS agents -> $AGENTS_NS.bak.$timestamp"
|
||||
fi
|
||||
|
||||
cp -R "$AGENTS_SRC" "$AGENTS_DST"
|
||||
echo "Synced .agents/$AGENTS_NS from standards."
|
||||
|
||||
AGENTS_INDEX="$AGENTS_ROOT/index.md"
|
||||
if [ ! -f "$AGENTS_INDEX" ]; then
|
||||
cat >"$AGENTS_INDEX" <<'EOF'
|
||||
# .agents(多语言)
|
||||
|
||||
本目录用于存放仓库级/语言级的代理规则集。
|
||||
|
||||
建议约定:
|
||||
|
||||
- `.agents/tsl/`:TSL 相关标准(由 `sync_standards.*` 同步)
|
||||
- `.agents/cpp/`、`.agents/python/` 等:其他语言的规则集(按需增加)
|
||||
|
||||
规则发生冲突时,建议以“更靠近代码的目录规则更具体”为准。
|
||||
EOF
|
||||
echo "Created .agents/index.md"
|
||||
fi
|
||||
|
||||
echo "Synced agents ruleset to $AGENTS_DST."
|
||||
|
||||
GITATTR_DST="$ROOT/.gitattributes"
|
||||
if [ -f "$GITATTR_SRC" ]; then
|
||||
if [ "$(CDPATH= cd -- "$(dirname -- "$GITATTR_SRC")" && pwd -P)/$(basename -- "$GITATTR_SRC")" = "$GITATTR_DST" ]; then
|
||||
echo "Skip: .gitattributes source equals destination."
|
||||
else
|
||||
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 standards."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
Reference in New Issue
Block a user