✨ feat(playbook): add syntax book and codex skills tooling
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
rem Install Codex skills from this Playbook snapshot into CODEX_HOME.
|
||||
rem - Source: <snapshot>\codex\skills\<skill-name>\
|
||||
rem - Dest: %CODEX_HOME%\skills\<skill-name>\ (default CODEX_HOME=%USERPROFILE%\.codex)
|
||||
rem
|
||||
rem Usage:
|
||||
rem install_codex_skills.bat
|
||||
rem install_codex_skills.bat style-cleanup code-review-workflow
|
||||
rem
|
||||
rem Notes:
|
||||
rem - Codex loads skills at startup; restart `codex` after installation.
|
||||
rem - Existing destination skill dirs are backed up with a random suffix.
|
||||
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
|
||||
set "SKILLS_SRC_ROOT=%SRC%\\codex\\skills"
|
||||
|
||||
set "CODEX_HOME=%CODEX_HOME%"
|
||||
if "%CODEX_HOME%"=="" set "CODEX_HOME=%USERPROFILE%\\.codex"
|
||||
set "SKILLS_DST_ROOT=%CODEX_HOME%\\skills"
|
||||
|
||||
if not exist "%SKILLS_SRC_ROOT%" (
|
||||
echo ERROR: skills source dir not found: "%SKILLS_SRC_ROOT%"
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "%SKILLS_DST_ROOT%" mkdir "%SKILLS_DST_ROOT%"
|
||||
|
||||
set "HAS_ARGS=0"
|
||||
if not "%~1"=="" set "HAS_ARGS=1"
|
||||
|
||||
if "%HAS_ARGS%"=="1" (
|
||||
for %%S in (%*) do call :InstallOne "%%~S"
|
||||
goto Done
|
||||
)
|
||||
|
||||
for /d %%D in ("%SKILLS_SRC_ROOT%\\*") do (
|
||||
set "NAME=%%~nD"
|
||||
if not "!NAME!"=="" if not "!NAME:~0,1!"=="." call :InstallOne "!NAME!"
|
||||
)
|
||||
|
||||
:Done
|
||||
echo Done. Skills installed to: "%SKILLS_DST_ROOT%"
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
:InstallOne
|
||||
set "NAME=%~1"
|
||||
set "SRC_DIR=%SKILLS_SRC_ROOT%\\%NAME%"
|
||||
set "DST_DIR=%SKILLS_DST_ROOT%\\%NAME%"
|
||||
|
||||
if not exist "%SRC_DIR%" (
|
||||
echo ERROR: skill not found: %NAME% "%SRC_DIR%"
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if exist "%DST_DIR%" (
|
||||
set "RAND=%RANDOM%"
|
||||
pushd "%SKILLS_DST_ROOT%"
|
||||
ren "%NAME%" "%NAME%.bak.!RAND!"
|
||||
popd
|
||||
echo Backed up existing skill: %NAME% -> %NAME%.bak.!RAND!
|
||||
)
|
||||
|
||||
xcopy "%SRC_DIR%\\*" "%DST_DIR%\\" /e /i /y >nul
|
||||
if errorlevel 1 (
|
||||
echo ERROR: failed to copy skill: %NAME%
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Installed: %NAME%
|
||||
exit /b 0
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
# Install Codex skills from this Playbook snapshot into CODEX_HOME.
|
||||
# - Source: <snapshot>\codex\skills\<skill-name>\
|
||||
# - Dest: $env:CODEX_HOME\skills\<skill-name>\ (default CODEX_HOME=$HOME\.codex)
|
||||
#
|
||||
# Usage:
|
||||
# powershell -File scripts/install_codex_skills.ps1
|
||||
# powershell -File scripts/install_codex_skills.ps1 style-cleanup code-review-workflow
|
||||
#
|
||||
# Notes:
|
||||
# - Codex loads skills at startup; restart `codex` after installation.
|
||||
# - Existing destination skill dirs are backed up with a timestamp suffix.
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $false, ValueFromRemainingArguments = $true)]
|
||||
[string[]]$Skills
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
|
||||
$SkillsSrcRoot = Join-Path $Src "codex/skills"
|
||||
|
||||
if (-not (Test-Path $SkillsSrcRoot)) {
|
||||
throw "Skills source dir not found: $SkillsSrcRoot"
|
||||
}
|
||||
|
||||
$CodexHome = $env:CODEX_HOME
|
||||
if (-not $CodexHome) {
|
||||
$homeDir = $HOME
|
||||
if (-not $homeDir) { $homeDir = $env:USERPROFILE }
|
||||
$CodexHome = (Join-Path $homeDir ".codex")
|
||||
}
|
||||
$SkillsDstRoot = Join-Path $CodexHome "skills"
|
||||
New-Item -ItemType Directory -Path $SkillsDstRoot -Force | Out-Null
|
||||
|
||||
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
|
||||
|
||||
function Install-One([string]$Name) {
|
||||
$srcDir = Join-Path $SkillsSrcRoot $Name
|
||||
$dstDir = Join-Path $SkillsDstRoot $Name
|
||||
|
||||
if (-not (Test-Path $srcDir)) {
|
||||
throw "Skill not found: $Name ($srcDir)"
|
||||
}
|
||||
|
||||
if (Test-Path $dstDir) {
|
||||
$bak = Join-Path $SkillsDstRoot "$Name.bak.$timestamp"
|
||||
Move-Item $dstDir $bak
|
||||
Write-Host "Backed up existing skill: $Name -> $(Split-Path -Leaf $bak)"
|
||||
}
|
||||
|
||||
Copy-Item $srcDir $dstDir -Recurse -Force
|
||||
Write-Host "Installed: $Name"
|
||||
}
|
||||
|
||||
if ($Skills -and $Skills.Count -gt 0) {
|
||||
foreach ($name in $Skills) {
|
||||
if (-not $name) { continue }
|
||||
Install-One $name
|
||||
}
|
||||
} else {
|
||||
foreach ($dir in (Get-ChildItem -Path $SkillsSrcRoot -Directory)) {
|
||||
if ($dir.Name.StartsWith(".")) { continue }
|
||||
Install-One $dir.Name
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Done. Skills installed to: $SkillsDstRoot"
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
# Install Codex skills from this Playbook snapshot into CODEX_HOME.
|
||||
# - Source: <snapshot>/codex/skills/<skill-name>/
|
||||
# - Dest: $CODEX_HOME/skills/<skill-name>/ (default CODEX_HOME=~/.codex)
|
||||
#
|
||||
# Usage:
|
||||
# sh scripts/install_codex_skills.sh # install all skills
|
||||
# sh scripts/install_codex_skills.sh style-cleanup code-review-workflow
|
||||
#
|
||||
# Notes:
|
||||
# - Codex loads skills at startup; restart `codex` after installation.
|
||||
# - Existing destination skill dirs are backed up with a timestamp suffix.
|
||||
|
||||
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
|
||||
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
|
||||
SKILLS_SRC_ROOT="$SRC/codex/skills"
|
||||
|
||||
CODEX_HOME="${CODEX_HOME:-$HOME/.codex}"
|
||||
SKILLS_DST_ROOT="$CODEX_HOME/skills"
|
||||
|
||||
if [ ! -d "$SKILLS_SRC_ROOT" ]; then
|
||||
echo "ERROR: skills source dir not found: $SKILLS_SRC_ROOT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "$SKILLS_DST_ROOT"
|
||||
timestamp="$(date +%Y%m%d%H%M%S 2>/dev/null || echo bak)"
|
||||
|
||||
install_one() {
|
||||
name="$1"
|
||||
src_dir="$SKILLS_SRC_ROOT/$name"
|
||||
dst_dir="$SKILLS_DST_ROOT/$name"
|
||||
|
||||
if [ ! -d "$src_dir" ]; then
|
||||
echo "ERROR: skill not found: $name ($src_dir)" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -e "$dst_dir" ]; then
|
||||
mv "$dst_dir" "$SKILLS_DST_ROOT/$name.bak.$timestamp"
|
||||
echo "Backed up existing skill: $name -> $name.bak.$timestamp"
|
||||
fi
|
||||
cp -R "$src_dir" "$dst_dir"
|
||||
echo "Installed: $name"
|
||||
}
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
for name in "$@"; do
|
||||
install_one "$name"
|
||||
done
|
||||
else
|
||||
for dir in "$SKILLS_SRC_ROOT"/*; do
|
||||
[ -d "$dir" ] || continue
|
||||
name="$(basename -- "$dir")"
|
||||
case "$name" in
|
||||
""|.*) continue ;;
|
||||
esac
|
||||
install_one "$name"
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Done. Skills installed to: $SKILLS_DST_ROOT"
|
||||
|
||||
@@ -12,7 +12,8 @@ rem Notes:
|
||||
rem - When syncing multiple rulesets, .gitattributes is synced only once (first ruleset).
|
||||
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
for /f "delims=" %%R in ('git -C "%SCRIPT_DIR%" rev-parse --show-toplevel 2^>nul') do set "ROOT=%%R"
|
||||
set "ROOT=%SYNC_ROOT%"
|
||||
if "%ROOT%"=="" 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"
|
||||
|
||||
|
||||
@@ -15,8 +15,11 @@ $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 = $env:SYNC_ROOT
|
||||
if (-not $Root) {
|
||||
$Root = (git -C $ScriptDir rev-parse --show-toplevel 2>$null)
|
||||
if (-not $Root) { $Root = (Get-Location).Path }
|
||||
}
|
||||
$Root = (Resolve-Path $Root).Path
|
||||
|
||||
$AgentsSrcRoot = Join-Path $Src ".agents"
|
||||
|
||||
@@ -14,7 +14,11 @@ set -eu
|
||||
|
||||
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)"
|
||||
if [ -n "${SYNC_ROOT:-}" ]; then
|
||||
ROOT="$SYNC_ROOT"
|
||||
else
|
||||
ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null || pwd)"
|
||||
fi
|
||||
ROOT="$(CDPATH= cd -- "$ROOT" && pwd -P)"
|
||||
AGENTS_SRC_ROOT="$SRC/.agents"
|
||||
GITATTR_SRC="$SRC/.gitattributes"
|
||||
|
||||
@@ -0,0 +1,252 @@
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
rem Vendor a trimmed Playbook snapshot into a target project (offline copy),
|
||||
rem then run sync_standards to materialize .agents\<lang>\ and .gitattributes in
|
||||
rem the target project root.
|
||||
rem
|
||||
rem Usage:
|
||||
rem scripts\vendor_playbook.bat <project-root> (default: tsl)
|
||||
rem scripts\vendor_playbook.bat <project-root> tsl cpp
|
||||
rem scripts\vendor_playbook.bat <project-root> --langs tsl,cpp
|
||||
rem
|
||||
rem Notes:
|
||||
rem - Snapshot is written to: <project-root>\docs\standards\playbook\
|
||||
rem - Existing snapshot is backed up before overwrite.
|
||||
|
||||
if "%~1"=="" goto Usage
|
||||
if "%~1"=="-h" goto Usage
|
||||
if "%~1"=="--help" goto Usage
|
||||
|
||||
set "DEST_ROOT=%~1"
|
||||
shift
|
||||
|
||||
set "LANGS="
|
||||
if "%~1"=="--langs" (
|
||||
set "LANGS=%~2"
|
||||
shift
|
||||
shift
|
||||
) else (
|
||||
set "LANGS=%*"
|
||||
)
|
||||
|
||||
if "%LANGS%"=="" set "LANGS=tsl"
|
||||
set "LANGS=%LANGS:,= %"
|
||||
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
|
||||
|
||||
if not exist "%DEST_ROOT%" mkdir "%DEST_ROOT%"
|
||||
for %%I in ("%DEST_ROOT%") do set "DEST_ROOT_ABS=%%~fI"
|
||||
|
||||
set "STANDARDS_DIR=%DEST_ROOT_ABS%\\docs\\standards"
|
||||
set "DEST_PREFIX=%STANDARDS_DIR%\\playbook"
|
||||
|
||||
if not exist "%STANDARDS_DIR%" mkdir "%STANDARDS_DIR%"
|
||||
|
||||
if exist "%DEST_PREFIX%" (
|
||||
set "RAND=%RANDOM%"
|
||||
pushd "%STANDARDS_DIR%"
|
||||
ren "playbook" "playbook.bak.!RAND!"
|
||||
popd
|
||||
echo Backed up existing snapshot -^> docs\\standards\\playbook.bak.!RAND!
|
||||
)
|
||||
|
||||
if not exist "%DEST_PREFIX%" mkdir "%DEST_PREFIX%"
|
||||
|
||||
copy /y "%SRC%\\.gitattributes" "%DEST_PREFIX%\\.gitattributes" >nul
|
||||
copy /y "%SRC%\\SKILLS.md" "%DEST_PREFIX%\\SKILLS.md" >nul
|
||||
|
||||
xcopy "%SRC%\\scripts\\*" "%DEST_PREFIX%\\scripts\\" /e /i /y >nul
|
||||
if errorlevel 1 (
|
||||
echo ERROR: failed to copy scripts
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
xcopy "%SRC%\\codex\\*" "%DEST_PREFIX%\\codex\\" /e /i /y >nul
|
||||
if errorlevel 1 (
|
||||
echo ERROR: failed to copy codex
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
xcopy "%SRC%\\docs\\common\\*" "%DEST_PREFIX%\\docs\\common\\" /e /i /y >nul
|
||||
if errorlevel 1 (
|
||||
echo ERROR: failed to copy docs\\common
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "%DEST_PREFIX%\\.agents" mkdir "%DEST_PREFIX%\\.agents"
|
||||
copy /y "%SRC%\\.agents\\index.md" "%DEST_PREFIX%\\.agents\\index.md" >nul
|
||||
|
||||
if not exist "%DEST_PREFIX%\\templates" mkdir "%DEST_PREFIX%\\templates"
|
||||
|
||||
set "LANGS_CSV="
|
||||
for %%L in (%LANGS%) do (
|
||||
echo %%~L| findstr /r "[\\/]" >nul && (
|
||||
echo ERROR: invalid lang=%%~L
|
||||
exit /b 1
|
||||
)
|
||||
echo %%~L| findstr /c:".." >nul && (
|
||||
echo ERROR: invalid lang=%%~L
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if not exist "%SRC%\\docs\\%%~L" (
|
||||
echo ERROR: docs not found for lang=%%~L "%SRC%\\docs\\%%~L"
|
||||
exit /b 1
|
||||
)
|
||||
if not exist "%SRC%\\.agents\\%%~L" (
|
||||
echo ERROR: agents ruleset not found for lang=%%~L "%SRC%\\.agents\\%%~L"
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
xcopy "%SRC%\\docs\\%%~L\\*" "%DEST_PREFIX%\\docs\\%%~L\\" /e /i /y >nul
|
||||
if errorlevel 1 (
|
||||
echo ERROR: failed to copy docs for lang=%%~L
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
xcopy "%SRC%\\.agents\\%%~L\\*" "%DEST_PREFIX%\\.agents\\%%~L\\" /e /i /y >nul
|
||||
if errorlevel 1 (
|
||||
echo ERROR: failed to copy agents for lang=%%~L
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
if exist "%SRC%\\templates\\%%~L" (
|
||||
xcopy "%SRC%\\templates\\%%~L\\*" "%DEST_PREFIX%\\templates\\%%~L\\" /e /i /y >nul
|
||||
if errorlevel 1 (
|
||||
echo ERROR: failed to copy templates for lang=%%~L
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
if "!LANGS_CSV!"=="" (
|
||||
set "LANGS_CSV=%%~L"
|
||||
) else (
|
||||
set "LANGS_CSV=!LANGS_CSV!,%%~L"
|
||||
)
|
||||
)
|
||||
|
||||
set "DOC_INDEX=%DEST_PREFIX%\\docs\\index.md"
|
||||
> "%DOC_INDEX%" echo # 文档导航(Docs Index)
|
||||
>> "%DOC_INDEX%" echo.
|
||||
>> "%DOC_INDEX%" echo 本快照为裁剪版 Playbook(langs: %LANGS_CSV%)。
|
||||
>> "%DOC_INDEX%" echo.
|
||||
>> "%DOC_INDEX%" echo ## 跨语言(common)
|
||||
>> "%DOC_INDEX%" echo.
|
||||
>> "%DOC_INDEX%" echo - 提交信息与版本号:`common/commit_message.md`
|
||||
|
||||
for %%L in (%LANGS%) do call :AppendDocsSection "%%~L"
|
||||
|
||||
set "COMMIT="
|
||||
for /f "delims=" %%H in ('git -C "%SRC%" rev-parse HEAD 2^>nul') do set "COMMIT=%%H"
|
||||
if "%COMMIT%"=="" set "COMMIT=N/A"
|
||||
|
||||
set "README=%DEST_PREFIX%\\README.md"
|
||||
> "%README%" echo # Playbook(裁剪快照)
|
||||
>> "%README%" echo.
|
||||
>> "%README%" echo 本目录为从 Playbook vendoring 的裁剪快照(langs: %LANGS_CSV%)。
|
||||
>> "%README%" echo.
|
||||
>> "%README%" echo ## 使用
|
||||
>> "%README%" echo.
|
||||
>> "%README%" echo 在目标项目根目录执行(多语言一次同步):
|
||||
>> "%README%" echo.
|
||||
>> "%README%" echo ```sh
|
||||
>> "%README%" echo sh docs/standards/playbook/scripts/sync_standards.sh %LANGS_CSV%
|
||||
>> "%README%" echo ```
|
||||
>> "%README%" echo.
|
||||
>> "%README%" echo 查看规范入口:
|
||||
>> "%README%" echo.
|
||||
>> "%README%" echo - `docs/standards/playbook/docs/index.md`
|
||||
>> "%README%" echo - `.agents/index.md`
|
||||
>> "%README%" echo.
|
||||
>> "%README%" echo ## Codex skills(可选)
|
||||
>> "%README%" echo.
|
||||
>> "%README%" echo 安装到本机(需要先在 `~/.codex/config.toml` 启用 skills;见 `docs/standards/playbook/SKILLS.md`):
|
||||
>> "%README%" echo.
|
||||
>> "%README%" echo ```sh
|
||||
>> "%README%" echo sh docs/standards/playbook/scripts/install_codex_skills.sh
|
||||
>> "%README%" echo ```
|
||||
|
||||
set "SOURCE=%DEST_PREFIX%\\SOURCE.md"
|
||||
> "%SOURCE%" echo # SOURCE
|
||||
>> "%SOURCE%" echo.
|
||||
>> "%SOURCE%" echo - Source: %SRC%
|
||||
>> "%SOURCE%" echo - Commit: %COMMIT%
|
||||
>> "%SOURCE%" echo - Date: %DATE% %TIME%
|
||||
>> "%SOURCE%" echo - Langs: %LANGS_CSV%
|
||||
>> "%SOURCE%" echo - Generated-by: scripts/vendor_playbook.bat
|
||||
|
||||
echo Vendored snapshot -^> %DEST_PREFIX%
|
||||
|
||||
set "PROJECT_AGENTS_ROOT=%DEST_ROOT_ABS%\\.agents"
|
||||
set "PROJECT_AGENTS_INDEX=%PROJECT_AGENTS_ROOT%\\index.md"
|
||||
if not exist "%PROJECT_AGENTS_ROOT%" mkdir "%PROJECT_AGENTS_ROOT%"
|
||||
if not exist "%PROJECT_AGENTS_INDEX%" (
|
||||
> "%PROJECT_AGENTS_INDEX%" echo # .agents(多语言)
|
||||
>> "%PROJECT_AGENTS_INDEX%" echo.
|
||||
>> "%PROJECT_AGENTS_INDEX%" echo 本目录用于存放仓库级/语言级的代理规则集。
|
||||
>> "%PROJECT_AGENTS_INDEX%" echo.
|
||||
>> "%PROJECT_AGENTS_INDEX%" echo 本项目已启用的规则集:
|
||||
for %%L in (%LANGS%) do (
|
||||
if /I "%%~L"=="tsl" >> "%PROJECT_AGENTS_INDEX%" echo - .agents/tsl/:TSL 相关规则集(适用于 .tsl/.tsf)
|
||||
if /I "%%~L"=="cpp" >> "%PROJECT_AGENTS_INDEX%" echo - .agents/cpp/:C++ 相关规则集(C++23,含 Modules)
|
||||
if /I "%%~L"=="python" >> "%PROJECT_AGENTS_INDEX%" echo - .agents/python/:Python 相关规则集
|
||||
)
|
||||
>> "%PROJECT_AGENTS_INDEX%" echo.
|
||||
>> "%PROJECT_AGENTS_INDEX%" echo 入口建议从:
|
||||
for %%L in (%LANGS%) do >> "%PROJECT_AGENTS_INDEX%" echo - .agents/%%~L/index.md
|
||||
>> "%PROJECT_AGENTS_INDEX%" echo.
|
||||
>> "%PROJECT_AGENTS_INDEX%" echo 标准快照文档入口:
|
||||
>> "%PROJECT_AGENTS_INDEX%" echo.
|
||||
>> "%PROJECT_AGENTS_INDEX%" echo - docs/standards/playbook/docs/index.md
|
||||
)
|
||||
|
||||
set "OLD_SYNC_ROOT=%SYNC_ROOT%"
|
||||
set "SYNC_ROOT=%DEST_ROOT_ABS%"
|
||||
pushd "%DEST_ROOT_ABS%"
|
||||
call "%DEST_PREFIX%\\scripts\\sync_standards.bat" %LANGS%
|
||||
popd
|
||||
set "SYNC_ROOT=%OLD_SYNC_ROOT%"
|
||||
|
||||
echo Done.
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
:AppendDocsSection
|
||||
set "LANG=%~1"
|
||||
if /I "%LANG%"=="tsl" (
|
||||
>> "%DOC_INDEX%" echo.
|
||||
>> "%DOC_INDEX%" echo ## TSL(tsl)
|
||||
>> "%DOC_INDEX%" echo.
|
||||
>> "%DOC_INDEX%" echo - 代码风格:`tsl/code_style.md`
|
||||
>> "%DOC_INDEX%" echo - 命名规范:`tsl/naming.md`
|
||||
>> "%DOC_INDEX%" echo - 语法手册:`tsl/syntax_book/index.md`
|
||||
>> "%DOC_INDEX%" echo - 工具链与验证命令(模板):`tsl/toolchain.md`
|
||||
)
|
||||
if /I "%LANG%"=="cpp" (
|
||||
>> "%DOC_INDEX%" echo.
|
||||
>> "%DOC_INDEX%" echo ## C++(cpp)
|
||||
>> "%DOC_INDEX%" echo.
|
||||
>> "%DOC_INDEX%" echo - 代码风格:`cpp/code_style.md`
|
||||
>> "%DOC_INDEX%" echo - 命名规范:`cpp/naming.md`
|
||||
>> "%DOC_INDEX%" echo - 工具链与验证命令(模板):`cpp/toolchain.md`
|
||||
>> "%DOC_INDEX%" echo - 第三方依赖(Conan):`cpp/dependencies_conan.md`
|
||||
>> "%DOC_INDEX%" echo - clangd 配置:`cpp/clangd.md`
|
||||
)
|
||||
if /I "%LANG%"=="python" (
|
||||
>> "%DOC_INDEX%" echo.
|
||||
>> "%DOC_INDEX%" echo ## Python(python)
|
||||
>> "%DOC_INDEX%" echo.
|
||||
>> "%DOC_INDEX%" echo - 代码风格:`python/style_guide.md`
|
||||
>> "%DOC_INDEX%" echo - 工具链:`python/tooling.md`
|
||||
>> "%DOC_INDEX%" echo - 配置清单:`python/configuration.md`
|
||||
)
|
||||
exit /b 0
|
||||
|
||||
:Usage
|
||||
echo Usage:
|
||||
echo scripts\vendor_playbook.bat ^<project-root^> ^(default: tsl^)
|
||||
echo scripts\vendor_playbook.bat ^<project-root^> tsl cpp
|
||||
echo scripts\vendor_playbook.bat ^<project-root^> --langs tsl,cpp
|
||||
exit /b 1
|
||||
@@ -0,0 +1,233 @@
|
||||
# Vendor a trimmed Playbook snapshot into a target project (offline copy),
|
||||
# then run sync_standards to materialize .agents\<lang>\ and .gitattributes in
|
||||
# the target project root.
|
||||
#
|
||||
# Usage:
|
||||
# powershell -File scripts/vendor_playbook.ps1 -DestRoot <project-root>
|
||||
# powershell -File scripts/vendor_playbook.ps1 -DestRoot <project-root> -Langs tsl,cpp
|
||||
# powershell -File scripts/vendor_playbook.ps1 -DestRoot <project-root> -Langs @("tsl","cpp")
|
||||
#
|
||||
# Notes:
|
||||
# - Snapshot is written to: <project-root>\docs\standards\playbook\
|
||||
# - Existing snapshot is backed up before overwrite.
|
||||
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$DestRoot,
|
||||
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string[]]$Langs
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Normalize-Langs([string[]]$InputLangs) {
|
||||
if (-not $InputLangs -or $InputLangs.Count -eq 0) { return @("tsl") }
|
||||
|
||||
$result = New-Object System.Collections.Generic.List[string]
|
||||
foreach ($item in $InputLangs) {
|
||||
if (-not $item) { continue }
|
||||
foreach ($part in $item.Split(@(',', ' '), [System.StringSplitOptions]::RemoveEmptyEntries)) {
|
||||
if (-not $part) { continue }
|
||||
$result.Add($part)
|
||||
}
|
||||
}
|
||||
if ($result.Count -eq 0) { return @("tsl") }
|
||||
return $result.ToArray()
|
||||
}
|
||||
|
||||
$Langs = Normalize-Langs $Langs
|
||||
|
||||
foreach ($lang in $Langs) {
|
||||
if ($lang -match '[\\/]' -or $lang -match '\.\.') {
|
||||
throw "Invalid lang=$lang"
|
||||
}
|
||||
}
|
||||
|
||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
|
||||
|
||||
New-Item -ItemType Directory -Path $DestRoot -Force | Out-Null
|
||||
$DestRootAbs = (Resolve-Path $DestRoot).Path
|
||||
|
||||
$StandardsDir = Join-Path $DestRootAbs "docs/standards"
|
||||
$DestPrefix = Join-Path $StandardsDir "playbook"
|
||||
|
||||
New-Item -ItemType Directory -Path $StandardsDir -Force | Out-Null
|
||||
|
||||
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
|
||||
if (Test-Path $DestPrefix) {
|
||||
$bak = Join-Path $StandardsDir "playbook.bak.$timestamp"
|
||||
Move-Item $DestPrefix $bak
|
||||
Write-Host "Backed up existing snapshot -> docs\\standards\\$(Split-Path -Leaf $bak)"
|
||||
}
|
||||
|
||||
New-Item -ItemType Directory -Path $DestPrefix -Force | Out-Null
|
||||
|
||||
Copy-Item (Join-Path $Src ".gitattributes") (Join-Path $DestPrefix ".gitattributes") -Force
|
||||
Copy-Item (Join-Path $Src "scripts") $DestPrefix -Recurse -Force
|
||||
Copy-Item (Join-Path $Src "codex") $DestPrefix -Recurse -Force
|
||||
Copy-Item (Join-Path $Src "SKILLS.md") (Join-Path $DestPrefix "SKILLS.md") -Force
|
||||
|
||||
$DocsDir = Join-Path $DestPrefix "docs"
|
||||
New-Item -ItemType Directory -Path $DocsDir -Force | Out-Null
|
||||
Copy-Item (Join-Path $Src "docs/common") $DocsDir -Recurse -Force
|
||||
|
||||
$AgentsDir = Join-Path $DestPrefix ".agents"
|
||||
New-Item -ItemType Directory -Path $AgentsDir -Force | Out-Null
|
||||
Copy-Item (Join-Path $Src ".agents/index.md") (Join-Path $AgentsDir "index.md") -Force
|
||||
|
||||
$TemplatesDir = Join-Path $DestPrefix "templates"
|
||||
New-Item -ItemType Directory -Path $TemplatesDir -Force | Out-Null
|
||||
|
||||
foreach ($lang in $Langs) {
|
||||
$docsSrc = Join-Path (Join-Path $Src "docs") $lang
|
||||
if (-not (Test-Path $docsSrc)) { throw "Docs not found for lang=$lang ($docsSrc)" }
|
||||
Copy-Item $docsSrc $DocsDir -Recurse -Force
|
||||
|
||||
$agentsSrc = Join-Path (Join-Path $Src ".agents") $lang
|
||||
if (-not (Test-Path $agentsSrc)) { throw "Agents ruleset not found for lang=$lang ($agentsSrc)" }
|
||||
Copy-Item $agentsSrc $AgentsDir -Recurse -Force
|
||||
|
||||
$tplSrc = Join-Path (Join-Path $Src "templates") $lang
|
||||
if (Test-Path $tplSrc) {
|
||||
Copy-Item $tplSrc $TemplatesDir -Recurse -Force
|
||||
}
|
||||
}
|
||||
|
||||
$langsCsv = ($Langs -join ",")
|
||||
|
||||
$docLines = New-Object System.Collections.Generic.List[string]
|
||||
$docLines.Add("# 文档导航(Docs Index)")
|
||||
$docLines.Add("")
|
||||
$docLines.Add("本快照为裁剪版 Playbook(langs: $langsCsv)。")
|
||||
$docLines.Add("")
|
||||
$docLines.Add("## 跨语言(common)")
|
||||
$docLines.Add("")
|
||||
$docLines.Add("- 提交信息与版本号:`common/commit_message.md`")
|
||||
|
||||
function Append-DocsSection([string]$Lang) {
|
||||
switch ($Lang) {
|
||||
"tsl" {
|
||||
$docLines.Add("")
|
||||
$docLines.Add("## TSL(tsl)")
|
||||
$docLines.Add("")
|
||||
$docLines.Add("- 代码风格:`tsl/code_style.md`")
|
||||
$docLines.Add("- 命名规范:`tsl/naming.md`")
|
||||
$docLines.Add("- 语法手册:`tsl/syntax_book/index.md`")
|
||||
$docLines.Add("- 工具链与验证命令(模板):`tsl/toolchain.md`")
|
||||
break
|
||||
}
|
||||
"cpp" {
|
||||
$docLines.Add("")
|
||||
$docLines.Add("## C++(cpp)")
|
||||
$docLines.Add("")
|
||||
$docLines.Add("- 代码风格:`cpp/code_style.md`")
|
||||
$docLines.Add("- 命名规范:`cpp/naming.md`")
|
||||
$docLines.Add("- 工具链与验证命令(模板):`cpp/toolchain.md`")
|
||||
$docLines.Add("- 第三方依赖(Conan):`cpp/dependencies_conan.md`")
|
||||
$docLines.Add("- clangd 配置:`cpp/clangd.md`")
|
||||
break
|
||||
}
|
||||
"python" {
|
||||
$docLines.Add("")
|
||||
$docLines.Add("## Python(python)")
|
||||
$docLines.Add("")
|
||||
$docLines.Add("- 代码风格:`python/style_guide.md`")
|
||||
$docLines.Add("- 工具链:`python/tooling.md`")
|
||||
$docLines.Add("- 配置清单:`python/configuration.md`")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($lang in $Langs) {
|
||||
Append-DocsSection $lang
|
||||
}
|
||||
|
||||
($docLines -join "`n") | Set-Content -Path (Join-Path $DocsDir "index.md") -Encoding UTF8
|
||||
|
||||
$commit = ""
|
||||
try {
|
||||
$commit = (git -C $Src rev-parse HEAD 2>$null)
|
||||
} catch {
|
||||
$commit = ""
|
||||
}
|
||||
if (-not $commit) { $commit = "N/A" }
|
||||
|
||||
@"
|
||||
# Playbook(裁剪快照)
|
||||
|
||||
本目录为从 Playbook vendoring 的裁剪快照(langs: $langsCsv)。
|
||||
|
||||
## 使用
|
||||
|
||||
在目标项目根目录执行(多语言一次同步):
|
||||
|
||||
```sh
|
||||
sh docs/standards/playbook/scripts/sync_standards.sh $langsCsv
|
||||
```
|
||||
|
||||
查看规范入口:
|
||||
|
||||
- `docs/standards/playbook/docs/index.md`
|
||||
- `.agents/index.md`
|
||||
|
||||
## Codex skills(可选)
|
||||
|
||||
安装到本机(需要先在 `~/.codex/config.toml` 启用 skills;见 `docs/standards/playbook/SKILLS.md`):
|
||||
|
||||
```sh
|
||||
sh docs/standards/playbook/scripts/install_codex_skills.sh
|
||||
```
|
||||
"@ | Set-Content -Path (Join-Path $DestPrefix "README.md") -Encoding UTF8
|
||||
|
||||
@"
|
||||
# SOURCE
|
||||
|
||||
- Source: $Src
|
||||
- Commit: $commit
|
||||
- Date: $(Get-Date).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
|
||||
- Langs: $langsCsv
|
||||
- Generated-by: scripts/vendor_playbook.ps1
|
||||
"@ | Set-Content -Path (Join-Path $DestPrefix "SOURCE.md") -Encoding UTF8
|
||||
|
||||
Write-Host "Vendored snapshot -> $DestPrefix"
|
||||
|
||||
$ProjectAgentsRoot = Join-Path $DestRootAbs ".agents"
|
||||
$ProjectAgentsIndex = Join-Path $ProjectAgentsRoot "index.md"
|
||||
New-Item -ItemType Directory -Path $ProjectAgentsRoot -Force | Out-Null
|
||||
if (-not (Test-Path $ProjectAgentsIndex)) {
|
||||
$agentLines = New-Object System.Collections.Generic.List[string]
|
||||
$agentLines.Add("# .agents(多语言)")
|
||||
$agentLines.Add("")
|
||||
$agentLines.Add("本目录用于存放仓库级/语言级的代理规则集。")
|
||||
$agentLines.Add("")
|
||||
$agentLines.Add("本项目已启用的规则集:")
|
||||
foreach ($lang in $Langs) {
|
||||
switch ($lang) {
|
||||
"tsl" { $agentLines.Add("- .agents/tsl/:TSL 相关规则集(适用于 .tsl/.tsf)"); break }
|
||||
"cpp" { $agentLines.Add("- .agents/cpp/:C++ 相关规则集(C++23,含 Modules)"); break }
|
||||
"python" { $agentLines.Add("- .agents/python/:Python 相关规则集"); break }
|
||||
}
|
||||
}
|
||||
$agentLines.Add("")
|
||||
$agentLines.Add("入口建议从:")
|
||||
foreach ($lang in $Langs) { $agentLines.Add("- .agents/$lang/index.md") }
|
||||
$agentLines.Add("")
|
||||
$agentLines.Add("标准快照文档入口:")
|
||||
$agentLines.Add("")
|
||||
$agentLines.Add("- docs/standards/playbook/docs/index.md")
|
||||
($agentLines -join "`n") | Set-Content -Path $ProjectAgentsIndex -Encoding UTF8
|
||||
}
|
||||
|
||||
$oldSyncRoot = $env:SYNC_ROOT
|
||||
$env:SYNC_ROOT = $DestRootAbs
|
||||
try {
|
||||
& (Join-Path $DestPrefix "scripts/sync_standards.ps1") -Langs $Langs
|
||||
} finally {
|
||||
$env:SYNC_ROOT = $oldSyncRoot
|
||||
}
|
||||
|
||||
Write-Host "Done."
|
||||
@@ -0,0 +1,259 @@
|
||||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
|
||||
# Vendor a trimmed Playbook snapshot into a target project (offline copy),
|
||||
# then run sync_standards to materialize .agents/<lang>/ and .gitattributes in
|
||||
# the target project root.
|
||||
#
|
||||
# Usage:
|
||||
# sh scripts/vendor_playbook.sh <project-root> # default: tsl
|
||||
# sh scripts/vendor_playbook.sh <project-root> tsl cpp
|
||||
# sh scripts/vendor_playbook.sh <project-root> --langs tsl,cpp
|
||||
#
|
||||
# Notes:
|
||||
# - Snapshot is written to: <project-root>/docs/standards/playbook/
|
||||
# - Existing snapshot is backed up before overwrite.
|
||||
|
||||
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
|
||||
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
|
||||
|
||||
usage() {
|
||||
cat <<'EOF' >&2
|
||||
Usage:
|
||||
sh scripts/vendor_playbook.sh <project-root> # default: tsl
|
||||
sh scripts/vendor_playbook.sh <project-root> tsl cpp
|
||||
sh scripts/vendor_playbook.sh <project-root> --langs tsl,cpp
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PROJECT_ROOT="$1"
|
||||
shift
|
||||
|
||||
langs=""
|
||||
if [ "${1:-}" = "--langs" ]; then
|
||||
langs="${2:-}"
|
||||
shift 2 || true
|
||||
fi
|
||||
if [ -z "${langs:-}" ] && [ "$#" -gt 0 ]; then
|
||||
langs="$*"
|
||||
fi
|
||||
|
||||
if [ -z "${langs:-}" ]; then
|
||||
langs="tsl"
|
||||
fi
|
||||
|
||||
timestamp="$(date +%Y%m%d%H%M%S 2>/dev/null || echo bak)"
|
||||
|
||||
mkdir -p "$PROJECT_ROOT"
|
||||
PROJECT_ROOT_ABS="$(CDPATH= cd -- "$PROJECT_ROOT" && pwd -P)"
|
||||
DEST_PREFIX="$PROJECT_ROOT_ABS/docs/standards/playbook"
|
||||
DEST_STANDARDS="$PROJECT_ROOT_ABS/docs/standards"
|
||||
|
||||
mkdir -p "$DEST_STANDARDS"
|
||||
|
||||
if [ -e "$DEST_PREFIX" ]; then
|
||||
mv "$DEST_PREFIX" "$DEST_STANDARDS/playbook.bak.$timestamp"
|
||||
echo "Backed up existing snapshot -> docs/standards/playbook.bak.$timestamp"
|
||||
fi
|
||||
|
||||
mkdir -p "$DEST_PREFIX"
|
||||
|
||||
# Always include: scripts + gitattributes + docs/common + codex/skills
|
||||
cp "$SRC/.gitattributes" "$DEST_PREFIX/.gitattributes"
|
||||
cp -R "$SRC/scripts" "$DEST_PREFIX/"
|
||||
cp -R "$SRC/codex" "$DEST_PREFIX/"
|
||||
cp "$SRC/SKILLS.md" "$DEST_PREFIX/SKILLS.md"
|
||||
|
||||
mkdir -p "$DEST_PREFIX/docs"
|
||||
cp -R "$SRC/docs/common" "$DEST_PREFIX/docs/"
|
||||
|
||||
mkdir -p "$DEST_PREFIX/.agents"
|
||||
cp "$SRC/.agents/index.md" "$DEST_PREFIX/.agents/index.md"
|
||||
|
||||
mkdir -p "$DEST_PREFIX/templates"
|
||||
|
||||
old_ifs="${IFS}"
|
||||
IFS=', '
|
||||
set -- $langs
|
||||
IFS="${old_ifs}"
|
||||
|
||||
langs_csv=""
|
||||
for lang in "$@"; do
|
||||
[ -n "$lang" ] || continue
|
||||
|
||||
case "$lang" in
|
||||
""|*/*|*\\*|*..*)
|
||||
echo "ERROR: invalid lang=$lang" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -d "$SRC/docs/$lang" ]; then
|
||||
echo "ERROR: docs not found for lang=$lang ($SRC/docs/$lang)" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -d "$SRC/.agents/$lang" ]; then
|
||||
echo "ERROR: agents ruleset not found for lang=$lang ($SRC/.agents/$lang)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp -R "$SRC/docs/$lang" "$DEST_PREFIX/docs/"
|
||||
cp -R "$SRC/.agents/$lang" "$DEST_PREFIX/.agents/"
|
||||
if [ -d "$SRC/templates/$lang" ]; then
|
||||
cp -R "$SRC/templates/$lang" "$DEST_PREFIX/templates/"
|
||||
fi
|
||||
|
||||
if [ -n "$langs_csv" ]; then
|
||||
langs_csv="$langs_csv,$lang"
|
||||
else
|
||||
langs_csv="$lang"
|
||||
fi
|
||||
done
|
||||
|
||||
cat >"$DEST_PREFIX/docs/index.md" <<EOF
|
||||
# 文档导航(Docs Index)
|
||||
|
||||
本快照为裁剪版 Playbook(langs: ${langs_csv})。
|
||||
|
||||
## 跨语言(common)
|
||||
|
||||
- 提交信息与版本号:\`common/commit_message.md\`
|
||||
EOF
|
||||
|
||||
append_docs_section() {
|
||||
lang="$1"
|
||||
case "$lang" in
|
||||
tsl)
|
||||
cat >>"$DEST_PREFIX/docs/index.md" <<'EOF'
|
||||
|
||||
## TSL(tsl)
|
||||
|
||||
- 代码风格:`tsl/code_style.md`
|
||||
- 命名规范:`tsl/naming.md`
|
||||
- 语法手册:`tsl/syntax_book/index.md`
|
||||
- 工具链与验证命令(模板):`tsl/toolchain.md`
|
||||
EOF
|
||||
;;
|
||||
cpp)
|
||||
cat >>"$DEST_PREFIX/docs/index.md" <<'EOF'
|
||||
|
||||
## C++(cpp)
|
||||
|
||||
- 代码风格:`cpp/code_style.md`
|
||||
- 命名规范:`cpp/naming.md`
|
||||
- 工具链与验证命令(模板):`cpp/toolchain.md`
|
||||
- 第三方依赖(Conan):`cpp/dependencies_conan.md`
|
||||
- clangd 配置:`cpp/clangd.md`
|
||||
EOF
|
||||
;;
|
||||
python)
|
||||
cat >>"$DEST_PREFIX/docs/index.md" <<'EOF'
|
||||
|
||||
## Python(python)
|
||||
|
||||
- 代码风格:`python/style_guide.md`
|
||||
- 工具链:`python/tooling.md`
|
||||
- 配置清单:`python/configuration.md`
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
for lang in "$@"; do
|
||||
[ -n "$lang" ] || continue
|
||||
append_docs_section "$lang"
|
||||
done
|
||||
|
||||
commit=""
|
||||
if command -v git >/dev/null 2>&1; then
|
||||
commit="$(git -C "$SRC" rev-parse HEAD 2>/dev/null || true)"
|
||||
fi
|
||||
|
||||
cat >"$DEST_PREFIX/README.md" <<EOF
|
||||
# Playbook(裁剪快照)
|
||||
|
||||
本目录为从 Playbook vendoring 的裁剪快照(langs: ${langs_csv})。
|
||||
|
||||
## 使用
|
||||
|
||||
在目标项目根目录执行(多语言一次同步):
|
||||
|
||||
\`\`\`sh
|
||||
sh docs/standards/playbook/scripts/sync_standards.sh ${langs_csv}
|
||||
\`\`\`
|
||||
|
||||
查看规范入口:
|
||||
|
||||
- \`docs/standards/playbook/docs/index.md\`
|
||||
- \`.agents/index.md\`
|
||||
|
||||
## Codex skills(可选)
|
||||
|
||||
安装到本机(需要先在 \`~/.codex/config.toml\` 启用 skills;见 \`docs/standards/playbook/SKILLS.md\`):
|
||||
|
||||
\`\`\`sh
|
||||
sh docs/standards/playbook/scripts/install_codex_skills.sh
|
||||
\`\`\`
|
||||
EOF
|
||||
|
||||
cat >"$DEST_PREFIX/SOURCE.md" <<EOF
|
||||
# SOURCE
|
||||
|
||||
- Source: $SRC
|
||||
- Commit: ${commit:-N/A}
|
||||
- Date: $(date -u +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date)
|
||||
- Langs: ${langs_csv}
|
||||
- Generated-by: scripts/vendor_playbook.sh
|
||||
EOF
|
||||
|
||||
echo "Vendored snapshot -> $DEST_PREFIX"
|
||||
|
||||
PROJECT_AGENTS_ROOT="$PROJECT_ROOT_ABS/.agents"
|
||||
PROJECT_AGENTS_INDEX="$PROJECT_AGENTS_ROOT/index.md"
|
||||
mkdir -p "$PROJECT_AGENTS_ROOT"
|
||||
if [ ! -f "$PROJECT_AGENTS_INDEX" ]; then
|
||||
cat >"$PROJECT_AGENTS_INDEX" <<EOF
|
||||
# .agents(多语言)
|
||||
|
||||
本目录用于存放仓库级/语言级的代理规则集。
|
||||
|
||||
本项目已启用的规则集:
|
||||
EOF
|
||||
|
||||
for lang in "$@"; do
|
||||
case "$lang" in
|
||||
tsl) printf '%s\n' "- .agents/tsl/:TSL 相关规则集(适用于 .tsl/.tsf)" >>"$PROJECT_AGENTS_INDEX" ;;
|
||||
cpp) printf '%s\n' "- .agents/cpp/:C++ 相关规则集(C++23,含 Modules)" >>"$PROJECT_AGENTS_INDEX" ;;
|
||||
python) printf '%s\n' "- .agents/python/:Python 相关规则集" >>"$PROJECT_AGENTS_INDEX" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
cat >>"$PROJECT_AGENTS_INDEX" <<'EOF'
|
||||
|
||||
入口建议从:
|
||||
EOF
|
||||
|
||||
for lang in "$@"; do
|
||||
printf '%s\n' "- .agents/$lang/index.md" >>"$PROJECT_AGENTS_INDEX"
|
||||
done
|
||||
|
||||
cat >>"$PROJECT_AGENTS_INDEX" <<'EOF'
|
||||
|
||||
标准快照文档入口:
|
||||
|
||||
- docs/standards/playbook/docs/index.md
|
||||
EOF
|
||||
fi
|
||||
|
||||
SYNC_ROOT="$PROJECT_ROOT_ABS" sh "$DEST_PREFIX/scripts/sync_standards.sh" "$@"
|
||||
echo "Done."
|
||||
Reference in New Issue
Block a user