Compare commits

..

No commits in common. "c44b9aa4bb8adacd457792fdfd00a7cbacff836b" and "b2eb475a6da4c2b420f5e359d3d68175fd566afd" have entirely different histories.

20 changed files with 324 additions and 631 deletions

View File

@ -56,21 +56,21 @@ PlaybookTSL`.tsl`/`.tsf`+ C++ + Python + Markdown代码格式化
```bash
# Linux/macOS
sh scripts/sync_templates.sh -project-root /path/to/project
sh scripts/sync_templates.sh /path/to/project
# PowerShell
.\scripts\sync_templates.ps1 -ProjectRoot C:\path\to\project
# Windows CMD
scripts\sync_templates.bat -project-root C:\path\to\project
scripts\sync_templates.bat C:\path\to\project
```
**部署行为**
- **新项目**:创建完整的 `AGENTS.md`、`AGENT_RULES.md`、`memory-bank/`、`docs/prompts/`、`TODO.md`、`CONFIRM.md`
- **已有 AGENTS.md**:追加路由链接(使用 `<!-- playbook:templates:start/end -->` 标记)
- **-full 参数**:追加完整框架(规则优先级 + 新会话开始时)到已有 AGENTS.md
- **其他文件**:如果已存在则跳过(使用 `-force` 覆盖)
- **--full 参数**:追加完整框架(规则优先级 + 新会话开始时)到已有 AGENTS.md
- **其他文件**:如果已存在则跳过(使用 `--force` 覆盖)
详见:`templates/README.md`
@ -140,13 +140,12 @@ Layer 3: docs/ (权威静态文档)
| 你的情况 | 推荐方式 | 优势 |
| -------------------------------- | ------------------------------- | ------------------------------- |
| 新项目,需要持续同步更新 | 方式一git subtree | 可随时拉取最新标准,版本可追溯 |
| 新项目,需要持续同步更新 | **方式一git subtree(推荐)** | 可随时拉取最新标准,版本可追溯 |
| 只需要一次性引入,不常更新 | 方式二:手动复制快照 | 简单直接,无需 git subtree 知识 |
| 只需要部分语言(且希望快照也裁剪) | 方式三:脚本裁剪复制 | 快照只包含所需语言(更小) |
| 只需要部分语言(如只要 TSL+C++ | 方式三:脚本裁剪复制 | 自动裁剪,只包含所需语言 |
| **不确定?** | **方式一git subtree推荐** | 最灵活,后续可随时同步更新 |
**大部分情况推荐使用方式一git subtree。**
说明:方式一可选择同步哪些语言规则到 `.agents/`,但 `docs/standards/playbook/` 快照仍是全量;方式三会裁剪快照本身。
---
@ -160,7 +159,7 @@ git subtree add --prefix docs/standards/playbook \
https://git.mytsl.cn/csh/playbook.git main --squash
# 2. 同步规则到项目根目录
sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl
sh docs/standards/playbook/scripts/sync_standards.sh tsl
# 3. 提交
git add .
@ -202,19 +201,19 @@ git commit -m ":package: deps(playbook): add tsl standards"
2. **同步到项目根目录**(生成/更新 `.agents/<lang>/`、更新 `.gitattributes`
```bash
sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl
sh docs/standards/playbook/scripts/sync_standards.sh
```
同步 C++ 规则集(同一份快照,不同规则集):
```bash
sh docs/standards/playbook/scripts/sync_standards.sh -langs cpp
sh docs/standards/playbook/scripts/sync_standards.sh cpp
```
一次同步多个规则集(推荐,减少重复备份 `.gitattributes`
```bash
sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl,cpp
sh docs/standards/playbook/scripts/sync_standards.sh tsl cpp
```
> 说明:若项目根目录没有 `AGENTS.md``sync_standards.*`
@ -240,14 +239,14 @@ git commit -m ":package: deps(playbook): add tsl standards"
```bash
git subtree add --prefix docs/standards/playbook https://git.mytsl.cn/csh/playbook.git main --squash
sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl
sh docs/standards/playbook/scripts/sync_standards.sh tsl
```
**旧项目**(已有 `AGENTS.md`
```bash
git subtree pull --prefix docs/standards/playbook https://git.mytsl.cn/csh/playbook.git main --squash
sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl
sh docs/standards/playbook/scripts/sync_standards.sh tsl
```
旧项目的 `AGENTS.md` 不会被覆盖;如需指向 `.agents/`,请手动对齐内容。
@ -260,14 +259,14 @@ sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl
#!/usr/bin/env sh
set -eu
sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl,cpp
sh docs/standards/playbook/scripts/sync_standards.sh tsl cpp
# sh docs/standards/python/scripts/sync_standards.sh
```
也可以直接一次同步多个规则集:
```sh
sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl,cpp
sh docs/standards/playbook/scripts/sync_standards.sh tsl cpp
```
#### 目录约定(建议)
@ -304,15 +303,16 @@ sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl,cpp
- 脚本会从快照目录同步到项目根目录,并先备份旧文件(`.bak.*`
建议固定使用 `--prefix docs/standards/playbook`,因为同步后的 `.agents/*/`
会引用该路径下的标准快照文档(`docs/standards/playbook/docs/...`)。同步时需显式指定
语言参数(`-langs`),如需同步 C++ 规则集,推荐直接运行:
`sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl,cpp`
会引用该路径下的标准快照文档(`docs/standards/playbook/docs/...`)。无参数时若已存在
`.agents/<lang>/`,将按现有语言同步;否则默认 `.agents/tsl/`。如需同步 C++ 规则集,
推荐直接运行:`sh docs/standards/playbook/scripts/sync_standards.sh tsl cpp`
这样 clone 任意项目时都能直接读取规范文件,不依赖外部访问权限。
**同步脚本行为**(目标项目内的最终落地内容):
- 覆盖/更新:`.agents/<AGENTS_NS>/`(由 `-langs``AGENTS_NS` 指定)
- 覆盖/更新:`.agents/<AGENTS_NS>/`(默认 `.agents/tsl/`
- 自动识别:未传语言参数且已存在 `.agents/<lang>/` 时,按现有语言同步
- 更新 `.gitattributes`:默认追加缺失规则(可用
`SYNC_GITATTR_MODE=append|block|overwrite|skip` 控制)
- 缺省创建:`.agents/index.md`
@ -362,19 +362,19 @@ sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl,cpp
- macOS/Linux
```bash
sh <PLAYBOOK_ROOT>/scripts/vendor_playbook.sh -project-root <target-project-root> -langs tsl,cpp
sh <PLAYBOOK_ROOT>/scripts/vendor_playbook.sh <target-project-root> tsl cpp
```
- PowerShell
```powershell
powershell -File <PLAYBOOK_ROOT>\\scripts\\vendor_playbook.ps1 -ProjectRoot <target-project-root> -Langs tsl,cpp
powershell -File <PLAYBOOK_ROOT>\\scripts\\vendor_playbook.ps1 -DestRoot <target-project-root> -Langs tsl,cpp
```
- Windows bat
```bat
<PLAYBOOK_ROOT>\\scripts\\vendor_playbook.bat -project-root <target-project-root> -langs tsl,cpp
<PLAYBOOK_ROOT>\\scripts\\vendor_playbook.bat <target-project-root> --langs tsl,cpp
```
**脚本会**
@ -456,7 +456,7 @@ macOS/Linux 示例(目标项目的 `scripts/sync_standards.sh`
#!/usr/bin/env sh
set -eu
sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl,cpp
sh docs/standards/playbook/scripts/sync_standards.sh tsl cpp
OVERLAY="docs/project/agents_overlay"
if [ -d "$OVERLAY" ]; then
@ -490,7 +490,7 @@ if (Test-Path $overlay) {
- 若新增"本 Playbook 未覆盖的语言"再引入对应语言的标准仓库subtree/vendoring 到
`docs/standards/<lang>/`
- **代理规则**
- C++:运行 `sh docs/standards/playbook/scripts/sync_standards.sh -langs cpp`(或
- C++:运行 `sh docs/standards/playbook/scripts/sync_standards.sh cpp`(或
`& "docs/standards/playbook/scripts/sync_standards.ps1" -Langs cpp`),落地到
`.agents/cpp/`(与 `.agents/tsl/` 并行)。
- 其他语言:在目标项目增加 `.agents/<lang>/`(与 `.agents/tsl/`

View File

@ -49,38 +49,38 @@ $CODEX_HOME/skills/<skill-name>/SKILL.md
本仓库已提供跨平台安装脚本(会把 `codex/skills/*` 复制到
`$CODEX_HOME/skills/`
- macOS/Linux`sh scripts/install_codex_skills.sh -all`
- PowerShell`powershell -File scripts/install_codex_skills.ps1 -All`
- Windows bat`scripts/install_codex_skills.bat -all`
- macOS/Linux`sh scripts/install_codex_skills.sh`
- PowerShell`powershell -File scripts/install_codex_skills.ps1`
- Windows bat`scripts/install_codex_skills.bat`
用法示例:
```bash
# 安装全部 skills
sh scripts/install_codex_skills.sh -all
sh scripts/install_codex_skills.sh
# 只安装指定 skills
sh scripts/install_codex_skills.sh -skills style-cleanup,code-review-workflow
sh scripts/install_codex_skills.sh style-cleanup code-review-workflow
```
如果希望“项目内本地安装”(不污染全局),可用以下方式:
```bash
# 安装到当前目录的 .codex/skills/
sh scripts/install_codex_skills.sh -local -all
sh scripts/install_codex_skills.sh --local
# 或手动指定 CODEX_HOME
CODEX_HOME="$(pwd)/.codex" sh scripts/install_codex_skills.sh -all
CODEX_HOME="$(pwd)/.codex" sh scripts/install_codex_skills.sh
```
PowerShell / Windows
```powershell
powershell -File scripts/install_codex_skills.ps1 -Local -All
powershell -File scripts/install_codex_skills.ps1 -Local
```
```bat
scripts\install_codex_skills.bat -local -all
scripts\install_codex_skills.bat --local
```
> 注意Codex 只会从 `CODEX_HOME` 加载 skills使用本地安装时启动 Codex 需设置同样的 `CODEX_HOME`
@ -89,7 +89,7 @@ scripts\install_codex_skills.bat -local -all
`docs/standards/playbook`),则在目标项目里执行:
```bash
sh docs/standards/playbook/scripts/install_codex_skills.sh -all
sh docs/standards/playbook/scripts/install_codex_skills.sh
```
安装后重启 `codex`,即可在运行时看到 `## Skills` 列表。

View File

@ -6,9 +6,9 @@ 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 -all
rem install_codex_skills.bat -skills style-cleanup,code-review-workflow
rem install_codex_skills.bat -local -all
rem install_codex_skills.bat
rem install_codex_skills.bat style-cleanup code-review-workflow
rem install_codex_skills.bat --local
rem
rem Notes:
rem - Codex loads skills at startup; restart `codex` after installation.
@ -19,42 +19,10 @@ for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
set "SKILLS_SRC_ROOT=%SRC%\\codex\\skills"
set "LOCAL_MODE=0"
set "INSTALL_ALL=0"
set "SKILLS="
:parse_opts
if "%~1"=="" goto opts_done
if /I "%~1"=="-help" goto show_help
if /I "%~1"=="-h" goto show_help
if /I "%~1"=="-local" (
set "LOCAL_MODE=1"
shift
goto parse_opts
)
if /I "%~1"=="-l" (
set "LOCAL_MODE=1"
shift
goto parse_opts
)
if /I "%~1"=="-all" (
set "INSTALL_ALL=1"
shift
goto parse_opts
)
if /I "%~1"=="-skills" (
if "%~2"=="" (
echo ERROR: -skills requires a value.
exit /b 1
)
set "SKILLS=%~2"
shift
shift
goto parse_opts
)
echo ERROR: Unknown option: %~1
exit /b 1
goto opts_done
if /I "%~1"=="--local" set "LOCAL_MODE=1"
if /I "%~1"=="-l" set "LOCAL_MODE=1"
if "%LOCAL_MODE%"=="1" shift
:opts_done
set "CODEX_HOME=%CODEX_HOME%"
if "%LOCAL_MODE%"=="1" if "%CODEX_HOME%"=="" set "CODEX_HOME=%CD%\\.codex"
if "%CODEX_HOME%"=="" set "CODEX_HOME=%USERPROFILE%\\.codex"
@ -67,23 +35,17 @@ if not exist "%SKILLS_SRC_ROOT%" (
if not exist "%SKILLS_DST_ROOT%" mkdir "%SKILLS_DST_ROOT%"
if "%INSTALL_ALL%"=="1" if not "%SKILLS%"=="" (
echo ERROR: use either -all or -skills, not both.
exit /b 1
)
if "%INSTALL_ALL%"=="0" if "%SKILLS%"=="" (
echo ERROR: -all or -skills is required.
exit /b 1
set "HAS_ARGS=0"
if not "%~1"=="" set "HAS_ARGS=1"
if "%HAS_ARGS%"=="1" (
for %%S in (%*) do call :InstallOne "%%~S"
goto Done
)
if "%INSTALL_ALL%"=="1" (
for /d %%D in ("%SKILLS_SRC_ROOT%\\*") do (
set "NAME=%%~nD"
if not "!NAME!"=="" if not "!NAME:~0,1!"=="." call :InstallOne "!NAME!"
)
) else (
set "SKILLS=%SKILLS:,= %"
for %%S in (%SKILLS%) do call :InstallOne "%%~S"
for /d %%D in ("%SKILLS_SRC_ROOT%\\*") do (
set "NAME=%%~nD"
if not "!NAME!"=="" if not "!NAME:~0,1!"=="." call :InstallOne "!NAME!"
)
:Done
@ -91,21 +53,6 @@ echo Done. Skills installed to: "%SKILLS_DST_ROOT%"
endlocal
exit /b 0
:show_help
echo Usage:
echo install_codex_skills.bat -all
echo install_codex_skills.bat -skills style-cleanup,code-review-workflow
echo.
echo Options:
echo -local, -l Install to .\\.codex ^(or CODEX_HOME if set^)
echo -skills LIST Comma/space-separated skill names
echo -all Install all skills
echo -help, -h Show this help
echo.
echo Env:
echo CODEX_HOME Target Codex home ^(default: %%USERPROFILE%%\\.codex^)
exit /b 0
:InstallOne
set "NAME=%~1"
set "SRC_DIR=%SKILLS_SRC_ROOT%\\%NAME%"

View File

@ -13,39 +13,12 @@
[CmdletBinding()]
param(
[Alias('h', 'help', '?')]
[switch]$Help,
[switch]$Local,
[switch]$All,
[Parameter(Mandatory = $false)]
[Parameter(Mandatory = $false, ValueFromRemainingArguments = $true)]
[string[]]$Skills
)
$ErrorActionPreference = "Stop"
if ($Help) {
Write-Host "Usage:"
Write-Host " powershell -File scripts/install_codex_skills.ps1 -All"
Write-Host " powershell -File scripts/install_codex_skills.ps1 -Skills style-cleanup,code-review-workflow"
Write-Host ""
Write-Host "Options:"
Write-Host " -Local Install to ./.codex (or CODEX_HOME if set)."
Write-Host " -Skills Comma/space-separated skill names."
Write-Host " -All Install all skills."
Write-Host " -Help Show this help."
Write-Host ""
Write-Host "Env:"
Write-Host " CODEX_HOME Target Codex home (default: ~/.codex)."
exit 0
}
if ($All -and $Skills -and $Skills.Count -gt 0) {
throw "Use either -All or -Skills, not both."
}
if (-not $All -and (-not $Skills -or $Skills.Count -eq 0)) {
throw "Missing -All or -Skills. Use -Help for usage."
}
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
$SkillsSrcRoot = Join-Path $Src "codex/skills"
@ -87,19 +60,16 @@ function Install-One([string]$Name) {
Write-Host "Installed: $Name"
}
if ($All) {
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
}
} else {
foreach ($item in $Skills) {
if (-not $item) { continue }
foreach ($part in $item.Split(@(',', ' '), [System.StringSplitOptions]::RemoveEmptyEntries)) {
if (-not $part) { continue }
Install-One $part
}
}
}
Write-Host "Done. Skills installed to: $SkillsDstRoot"

View File

@ -6,9 +6,9 @@ set -eu
# - Dest: $CODEX_HOME/skills/<skill-name>/ (default CODEX_HOME=~/.codex)
#
# Usage:
# sh scripts/install_codex_skills.sh -all
# sh scripts/install_codex_skills.sh -skills style-cleanup,code-review-workflow
# sh scripts/install_codex_skills.sh -local -all # install to <cwd>/.codex
# sh scripts/install_codex_skills.sh # install all skills
# sh scripts/install_codex_skills.sh style-cleanup code-review-workflow
# sh scripts/install_codex_skills.sh --local # install to <cwd>/.codex
#
# Notes:
# - Codex loads skills at startup; restart `codex` after installation.
@ -18,72 +18,10 @@ SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
SKILLS_SRC_ROOT="$SRC/codex/skills"
usage() {
cat <<'EOF' >&2
Usage:
sh scripts/install_codex_skills.sh [options]
sh scripts/install_codex_skills.sh -skills style-cleanup,code-review-workflow
sh scripts/install_codex_skills.sh -all
Options:
-local, -l Install to ./.codex (or CODEX_HOME if set).
-skills LIST Comma/space-separated skill names.
-all Install all skills.
-h, -help Show this help.
Env:
CODEX_HOME Target Codex home (default: ~/.codex).
EOF
}
LOCAL_MODE=0
INSTALL_ALL=0
SKILLS=""
while [ $# -gt 0 ]; do
case "$1" in
-local|-l)
LOCAL_MODE=1
shift
;;
-skills)
if [ $# -lt 2 ] || [ -z "${2:-}" ]; then
echo "ERROR: -skills requires a value." >&2
usage
exit 1
fi
SKILLS="$2"
shift 2
;;
-all)
INSTALL_ALL=1
shift
;;
-h|-help)
usage
exit 0
;;
-*)
echo "ERROR: Unknown option: $1" >&2
usage
exit 1
;;
*)
echo "ERROR: positional args are not supported; use -skills/-all." >&2
usage
exit 1
;;
esac
done
if [ "$INSTALL_ALL" -eq 1 ] && [ -n "$SKILLS" ]; then
echo "ERROR: use either -all or -skills, not both." >&2
usage
exit 1
fi
if [ "$INSTALL_ALL" -eq 0 ] && [ -z "$SKILLS" ]; then
echo "ERROR: -all or -skills is required." >&2
usage
exit 1
if [ "${1:-}" = "--local" ] || [ "${1:-}" = "-l" ]; then
LOCAL_MODE=1
shift
fi
if [ "$LOCAL_MODE" -eq 1 ]; then
@ -119,7 +57,11 @@ install_one() {
echo "Installed: $name"
}
if [ "$INSTALL_ALL" -eq 1 ]; then
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")"
@ -128,15 +70,6 @@ if [ "$INSTALL_ALL" -eq 1 ]; then
esac
install_one "$name"
done
else
old_ifs="${IFS}"
IFS=', '
set -- $SKILLS
IFS="${old_ifs}"
for name in "$@"; do
[ -n "$name" ] || continue
install_one "$name"
done
fi
echo "Done. Skills installed to: $SKILLS_DST_ROOT"

View File

@ -7,13 +7,10 @@ rem - Updates <project-root>\.gitattributes (append missing rules by default)
rem Existing targets are backed up before overwrite.
rem
rem Multi rulesets:
rem sync_standards.bat -langs tsl,cpp
rem sync_standards.bat tsl cpp
rem Notes:
rem - When syncing multiple rulesets, .gitattributes is synced only once (first ruleset).
if /I "%~1"=="-h" goto show_help
if /I "%~1"=="-help" goto show_help
set "SCRIPT_DIR=%~dp0"
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"
@ -35,49 +32,20 @@ set "GITATTR_DST=%ROOT%\.gitattributes"
set "SYNC_GITATTR_MODE=%SYNC_GITATTR_MODE%"
if "%SYNC_GITATTR_MODE%"=="" set "SYNC_GITATTR_MODE=append"
:show_help
echo Usage:
echo sync_standards.bat
echo sync_standards.bat -langs tsl,cpp
echo.
echo Options:
echo -langs Comma/space-separated list of languages ^(required^).
echo -h, -help Show this help.
echo.
echo Env:
echo SYNC_ROOT Target project root ^(default: git root^).
echo AGENTS_NS Single ruleset name ^(default: tsl^).
echo SYNC_GITATTR_MODE append^|overwrite^|block^|skip ^(default: append^).
exit /b 0
set "LANG_LIST="
:parse_args
if "%~1"=="" goto args_done
if /I "%~1"=="-h" goto show_help
if /I "%~1"=="-help" goto show_help
if /I "%~1"=="-langs" (
if "%~2"=="" goto missing_langs
set "LANG_LIST=%~2"
shift /1
shift /1
goto parse_args
)
echo ERROR: Unknown option: %~1
exit /b 1
:missing_langs
echo ERROR: -langs requires a value.
exit /b 1
:args_done
if not "%LANG_LIST%"=="" set "LANG_LIST=%LANG_LIST:,= %"
rem Multi rulesets: only on outer invocation.
if "%SYNC_STANDARDS_INNER%"=="" (
set "LANG_LIST="
if not "%~1"=="" set "LANG_LIST=%*"
if "%LANG_LIST%"=="" (
if "%AGENTS_NS%"=="" (
echo ERROR: -langs is required.
exit /b 1
if exist "%ROOT%\.agents" (
for /d %%D in ("%ROOT%\.agents\*") do (
set "CAND=%%~nxD"
if exist "%AGENTS_SRC_ROOT%\!CAND!\" (
if defined LANG_LIST (set "LANG_LIST=!LANG_LIST! !CAND!") else set "LANG_LIST=!CAND!"
)
)
)
)
)
if not "%LANG_LIST%"=="" (
@ -89,12 +57,12 @@ if "%SYNC_STANDARDS_INNER%"=="" (
set "SYNC_STANDARDS_INNER=1"
set "AGENTS_NS=%%~L"
set "SYNC_GITATTR_MODE=!SYNC_FIRST!"
call "%~f0" -langs %%~L
call "%~f0"
) else (
set "SYNC_STANDARDS_INNER=1"
set "AGENTS_NS=%%~L"
set "SYNC_GITATTR_MODE=skip"
call "%~f0" -langs %%~L
call "%~f0"
)
)
exit /b 0

View File

@ -4,10 +4,6 @@
# Existing targets are backed up before overwrite.
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[Alias('h', 'help', '?')]
[switch]$Help,
# Sync multiple rulesets in one run:
# -Langs tsl,cpp
# -Langs @("tsl","cpp")
@ -16,21 +12,6 @@ param(
)
$ErrorActionPreference = "Stop"
if ($Help) {
Write-Host "Usage:"
Write-Host " powershell -File scripts/sync_standards.ps1 -Langs tsl,cpp"
Write-Host ""
Write-Host "Options:"
Write-Host " -Langs <list> Comma/space-separated list or array (required)."
Write-Host " -Help Show this help."
Write-Host ""
Write-Host "Env:"
Write-Host " SYNC_ROOT Target project root (default: git root)."
Write-Host " AGENTS_NS Single ruleset name (default: tsl)."
Write-Host " SYNC_GITATTR_MODE append|overwrite|block|skip (default: append)."
exit 0
}
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
@ -50,9 +31,15 @@ if (-not (Test-Path $AgentsSrcRoot)) {
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
# Require explicit -Langs on outer invocation unless AGENTS_NS is provided.
# Auto-detect languages from existing .agents when no args are provided.
if (-not $env:SYNC_STANDARDS_INNER -and (-not $Langs -or $Langs.Count -eq 0) -and -not $env:AGENTS_NS) {
throw "Missing -Langs. Use -Help for usage."
$agentsRoot = Join-Path $Root ".agents"
if (Test-Path $agentsRoot) {
$autoLangs = @(Get-ChildItem -Path $agentsRoot -Directory | ForEach-Object { $_.Name } | Where-Object { Test-Path (Join-Path $AgentsSrcRoot $_) })
if ($autoLangs.Count -gt 0) {
$Langs = $autoLangs
}
}
}
# Multi rulesets: only on the outer invocation.

View File

@ -7,7 +7,8 @@ set -eu
# Existing targets are backed up before overwrite.
#
# Multi rulesets:
# sh .../sync_standards.sh -langs tsl,cpp
# sh .../sync_standards.sh tsl cpp
# sh .../sync_standards.sh --langs tsl,cpp
# Notes:
# - When syncing multiple rulesets, .gitattributes is synced only once (first ruleset).
@ -20,53 +21,6 @@ else
fi
ROOT="$(CDPATH= cd -- "$ROOT" && pwd -P)"
usage() {
cat <<'EOF' >&2
Usage:
sh scripts/sync_standards.sh -langs tsl
sh scripts/sync_standards.sh -langs tsl,cpp
Options:
-langs L1,L2 Comma/space-separated list of languages (required).
-h, -help Show this help.
Env:
SYNC_ROOT Target project root (default: git root).
AGENTS_NS Single ruleset name (default: tsl).
SYNC_GITATTR_MODE append|overwrite|block|skip (default: append).
EOF
}
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "-help" ]; then
usage
exit 0
fi
langs=""
while [ $# -gt 0 ]; do
case "$1" in
-langs)
if [ $# -lt 2 ] || [ -z "${2:-}" ]; then
echo "ERROR: -langs requires a value." >&2
usage
exit 1
fi
langs="$2"
shift 2
;;
-*)
echo "ERROR: Unknown option: $1" >&2
usage
exit 1
;;
*)
echo "ERROR: positional args are not supported; use -langs." >&2
usage
exit 1
;;
esac
done
AGENTS_SRC_ROOT="$SRC/rulesets"
GITATTR_SRC="$SRC/.gitattributes"
@ -86,10 +40,28 @@ fi
# Parse multi rulesets only on the outer invocation.
if [ "${SYNC_STANDARDS_INNER:-}" != "1" ]; then
if [ -z "${langs:-}" ] && [ -z "${AGENTS_NS:-}" ]; then
echo "ERROR: -langs is required." >&2
usage
exit 1
langs=""
if [ "${1:-}" = "--langs" ]; then
langs="${2:-}"
shift 2
fi
if [ -z "${langs:-}" ] && [ "$#" -gt 0 ]; then
langs="$*"
fi
if [ -z "${langs:-}" ] && [ "$#" -eq 0 ] && [ -z "${AGENTS_NS:-}" ]; then
auto_langs=""
if [ -d "$ROOT/.agents" ]; then
for dir in "$ROOT/.agents"/*; do
[ -d "$dir" ] || continue
ns="$(basename "$dir")"
if [ -d "$AGENTS_SRC_ROOT/$ns" ]; then
auto_langs="${auto_langs:+$auto_langs }$ns"
fi
done
fi
if [ -n "$auto_langs" ]; then
langs="$auto_langs"
fi
fi
if [ -n "${langs:-}" ]; then
sync_mode_first="${SYNC_GITATTR_MODE:-append}"
@ -104,9 +76,9 @@ if [ "${SYNC_STANDARDS_INNER:-}" != "1" ]; then
[ -n "$ns" ] || continue
if [ "$first" -eq 1 ]; then
first=0
SYNC_STANDARDS_INNER=1 AGENTS_NS="$ns" SYNC_GITATTR_MODE="$sync_mode_first" sh "$0" -langs "$ns"
SYNC_STANDARDS_INNER=1 AGENTS_NS="$ns" SYNC_GITATTR_MODE="$sync_mode_first" sh "$0"
else
SYNC_STANDARDS_INNER=1 AGENTS_NS="$ns" SYNC_GITATTR_MODE=skip sh "$0" -langs "$ns"
SYNC_STANDARDS_INNER=1 AGENTS_NS="$ns" SYNC_GITATTR_MODE=skip sh "$0"
fi
done
exit 0

View File

@ -10,9 +10,9 @@ rem Existing targets are NOT overwritten (skip if exists).
rem
rem Usage:
rem sync_templates.bat # sync to current git root
rem sync_templates.bat -project-root <path> # sync to specified project
rem sync_templates.bat -force # overwrite existing files
rem sync_templates.bat -full # append full framework to existing AGENTS.md
rem sync_templates.bat <project-root> # sync to specified project
rem sync_templates.bat --force # overwrite existing files
rem sync_templates.bat --full # append full framework to existing AGENTS.md
set "SCRIPT_DIR=%~dp0"
for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
@ -23,41 +23,30 @@ set "PROJECT_ROOT="
:parse_args
if "%~1"=="" goto args_done
if /I "%~1"=="-force" (
if /I "%~1"=="--force" (
set "FORCE=1"
shift
goto parse_args
)
if /I "%~1"=="-full" (
if /I "%~1"=="--full" (
set "FULL=1"
shift
goto parse_args
)
if /I "%~1"=="-project-root" (
if "%~2"=="" (
echo ERROR: -project-root requires a path.
exit /b 1
)
set "PROJECT_ROOT=%~2"
shift
shift
goto parse_args
)
if /I "%~1"=="-h" goto show_help
if /I "%~1"=="-help" goto show_help
echo ERROR: positional args are not supported. Use -project-root.
exit /b 1
if /I "%~1"=="--help" goto show_help
set "PROJECT_ROOT=%~1"
shift
goto parse_args
:show_help
echo Usage:
echo sync_templates.bat [options]
echo sync_templates.bat -project-root ^<path^>
echo sync_templates.bat [options] [project-root]
echo.
echo Options:
echo -project-root PATH Target project root ^(default: git root^)
echo -force Overwrite existing files
echo -full Append full framework (规则优先级 + 新会话开始时) to existing AGENTS.md
echo -h, -help Show this help
echo --force Overwrite existing files
echo --full Append full framework (规则优先级 + 新会话开始时) to existing AGENTS.md
echo -h, --help Show this help
exit /b 0
:args_done
@ -100,7 +89,7 @@ set "MEMORY_BANK_DST=%PROJECT_ROOT%\memory-bank"
if exist "%MEMORY_BANK_SRC%" (
if exist "%MEMORY_BANK_DST%" (
if "%FORCE%"=="0" (
echo memory-bank/ already exists. Skip. Use -force to overwrite.
echo memory-bank/ already exists. Skip. Use --force to overwrite.
goto sync_prompts
)
)
@ -129,7 +118,7 @@ set "PROMPTS_DST=%PROJECT_ROOT%\docs\prompts"
if exist "%PROMPTS_SRC%" (
if exist "%PROMPTS_DST%" (
if "%FORCE%"=="0" (
echo docs/prompts/ already exists. Skip. Use -force to overwrite.
echo docs/prompts/ already exists. Skip. Use --force to overwrite.
goto sync_agents
)
)
@ -157,7 +146,7 @@ if exist "%PROMPTS_SRC%" (
rem 3. Sync AGENTS.md
set "AGENTS_DST=%PROJECT_ROOT%\AGENTS.md"
rem Choose markers based on -full flag
rem Choose markers based on --full flag
if "%FULL%"=="1" (
set "MARKER_START=<!-- playbook:framework:start -->"
set "MARKER_END=<!-- playbook:framework:end -->"
@ -210,7 +199,7 @@ set "AGENT_RULES_DST=%PROJECT_ROOT%\AGENT_RULES.md"
if exist "%AGENT_RULES_SRC%" (
if exist "%AGENT_RULES_DST%" (
if "%FORCE%"=="0" (
echo AGENT_RULES.md already exists. Skip. Use -force to overwrite.
echo AGENT_RULES.md already exists. Skip. Use --force to overwrite.
goto sync_todo
)
)

View File

@ -6,11 +6,7 @@
# Existing targets are backed up before overwrite.
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[Alias('h', 'help', '?')]
[switch]$Help,
[Parameter(Mandatory = $false)]
[Parameter(Mandatory = $false, Position = 0)]
[string]$ProjectRoot,
[Parameter(Mandatory = $false)]
@ -30,22 +26,6 @@ param(
)
$ErrorActionPreference = "Stop"
if ($Help) {
Write-Host "Usage:"
Write-Host " powershell -File scripts/sync_templates.ps1 [options]"
Write-Host " powershell -File scripts/sync_templates.ps1 -ProjectRoot C:\\path\\to\\project"
Write-Host ""
Write-Host "Options:"
Write-Host " -ProjectRoot PATH Target project root (default: git root)."
Write-Host " -ProjectName NAME Replace {{PROJECT_NAME}} placeholder."
Write-Host " -Date DATE Replace {{DATE}} placeholder (default: today)."
Write-Host " -NoBackup Skip backup of existing files."
Write-Host " -Force Overwrite without prompting."
Write-Host " -Full Append full framework section to AGENTS.md."
Write-Host " -Help Show this help."
exit 0
}
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path

View File

@ -10,16 +10,14 @@ set -eu
#
# Usage:
# sh scripts/sync_templates.sh # sync to current git root
# sh scripts/sync_templates.sh -project-root /path/to/project
# sh scripts/sync_templates.sh -project-root /path/to/project -project-name "MyProject" -date "2026-01-20"
# sh scripts/sync_templates.sh <project-root> # sync to specified project
# sh scripts/sync_templates.sh --project-name "MyProject" --date "2026-01-20"
#
# Options:
# -project-root PATH Target project root (default: git root)
# -project-name NAME Replace {{PROJECT_NAME}} placeholder
# -date DATE Replace {{DATE}} placeholder (default: today)
# -no-backup Skip backup of existing files
# -force Overwrite without prompting
# -full Append full framework (规则优先级 + 新会话开始时) to existing AGENTS.md
# --project-name NAME Replace {{PROJECT_NAME}} placeholder
# --date DATE Replace {{DATE}} placeholder (default: today)
# --no-backup Skip backup of existing files
# --force Overwrite without prompting
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
@ -35,61 +33,43 @@ PROJECT_ROOT=""
# Parse arguments
while [ $# -gt 0 ]; do
case "$1" in
-project-root)
if [ $# -lt 2 ] || [ -z "${2:-}" ]; then
echo "ERROR: -project-root requires a path." >&2
exit 1
fi
PROJECT_ROOT="$2"
shift 2
;;
-project-name)
if [ $# -lt 2 ] || [ -z "${2:-}" ]; then
echo "ERROR: -project-name requires a value." >&2
exit 1
fi
--project-name)
PROJECT_NAME="$2"
shift 2
;;
-date)
if [ $# -lt 2 ] || [ -z "${2:-}" ]; then
echo "ERROR: -date requires a value." >&2
exit 1
fi
--date)
SYNC_DATE="$2"
shift 2
;;
-no-backup)
--no-backup)
NO_BACKUP=1
shift
;;
-force)
--force)
FORCE=1
shift
;;
-full)
--full)
FULL=1
shift
;;
-h|-help)
-h|--help)
cat <<'EOF'
Usage:
sh scripts/sync_templates.sh [options]
sh scripts/sync_templates.sh -project-root /path/to/project
sh scripts/sync_templates.sh [options] [project-root]
Options:
-project-root PATH Target project root (default: git root)
-project-name NAME Replace {{PROJECT_NAME}} placeholder
-date DATE Replace {{DATE}} placeholder (default: today)
-no-backup Skip backup of existing files
-force Overwrite without prompting
-full Append full framework (规则优先级 + 新会话开始时) to existing AGENTS.md
-h, -help Show this help
--project-name NAME Replace {{PROJECT_NAME}} placeholder
--date DATE Replace {{DATE}} placeholder (default: today)
--no-backup Skip backup of existing files
--force Overwrite without prompting
--full Append full framework (规则优先级 + 新会话开始时) to existing AGENTS.md
-h, --help Show this help
Examples:
sh scripts/sync_templates.sh
sh scripts/sync_templates.sh -project-root /path/to/project
sh scripts/sync_templates.sh -project-root /path/to/project -full
sh scripts/sync_templates.sh /path/to/project
sh scripts/sync_templates.sh --full /path/to/project
EOF
exit 0
;;
@ -98,8 +78,8 @@ EOF
exit 1
;;
*)
echo "ERROR: positional args are not supported; use -project-root." >&2
exit 1
PROJECT_ROOT="$1"
shift
;;
esac
done
@ -180,7 +160,7 @@ if [ -d "$MEMORY_BANK_SRC" ]; then
MEMORY_BANK_DST="$PROJECT_ROOT/memory-bank"
if [ -e "$MEMORY_BANK_DST" ] && [ "$FORCE" -eq 0 ]; then
echo "memory-bank/ already exists. Use -force to overwrite."
echo "memory-bank/ already exists. Use --force to overwrite."
else
backup_if_exists "$MEMORY_BANK_DST"
mkdir -p "$MEMORY_BANK_DST"
@ -205,7 +185,7 @@ if [ -d "$PROMPTS_SRC" ]; then
PROMPTS_DST="$PROJECT_ROOT/docs/prompts"
if [ -e "$PROMPTS_DST" ] && [ "$FORCE" -eq 0 ]; then
echo "docs/prompts/ already exists. Use -force to overwrite."
echo "docs/prompts/ already exists. Use --force to overwrite."
else
backup_if_exists "$PROMPTS_DST"
mkdir -p "$PROJECT_ROOT/docs"
@ -226,7 +206,7 @@ else
fi
# 3. Sync AGENTS.md
# Choose markers based on -full flag
# Choose markers based on --full flag
if [ "$FULL" -eq 1 ]; then
MARKER_START="<!-- playbook:framework:start -->"
MARKER_END="<!-- playbook:framework:end -->"
@ -303,7 +283,7 @@ if [ -f "$AGENT_RULES_SRC" ]; then
AGENT_RULES_DST="$PROJECT_ROOT/AGENT_RULES.md"
if [ -e "$AGENT_RULES_DST" ] && [ "$FORCE" -eq 0 ]; then
echo "AGENT_RULES.md already exists. Use -force to overwrite."
echo "AGENT_RULES.md already exists. Use --force to overwrite."
else
backup_if_exists "$AGENT_RULES_DST"
cp "$AGENT_RULES_SRC" "$AGENT_RULES_DST"
@ -366,4 +346,4 @@ echo ""
echo "Next steps:"
echo " 1. Edit memory-bank/*.md to fill in project-specific content"
echo " 2. Replace remaining {{PLACEHOLDER}} values"
echo " 3. Run sync_standards.sh -langs <lang> to sync .agents/ rules"
echo " 3. Run sync_standards.sh to sync .agents/ rules"

View File

@ -6,66 +6,54 @@ 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 <path> (default: tsl)
rem scripts\vendor_playbook.bat -project-root <path> -langs tsl,cpp
rem scripts\vendor_playbook.bat -project-root <path> -langs tsl,cpp -apply-templates
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 scripts\vendor_playbook.bat <project-root> tsl cpp --apply-templates
rem
rem Options:
rem -project-root Target project root (required)
rem -apply-templates Apply CI/lang templates to project root (skip if exists)
rem --apply-templates Apply CI/lang templates to project root (skip if exists)
rem
rem Notes:
rem - Snapshot is written to: <project-root>\docs\standards\playbook\
rem - Existing snapshot is backed up before overwrite.
rem - With -apply-templates, CI and lang templates are copied to project root.
rem - With --apply-templates, CI and lang templates are copied to project root.
set "SCRIPT_DIR=%~dp0"
for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
if "%~1"=="" goto Usage
if "%~1"=="-h" goto Usage
if "%~1"=="-help" goto Usage
if "%~1"=="--help" goto Usage
set "DEST_ROOT=%~1"
shift /1
set "DEST_ROOT="
set "LANGS="
set "APPLY_TEMPLATES=0"
rem Parse arguments
:parse_args
if "%~1"=="" goto args_done
if "%~1"=="-project-root" (
if "%~2"=="" (
echo ERROR: -project-root requires a path.
exit /b 1
)
set "DEST_ROOT=%~2"
shift /1
shift /1
goto parse_args
)
if "%~1"=="-langs" (
if "%~2"=="" (
echo ERROR: -langs requires a value.
exit /b 1
)
if "%~1"=="--langs" (
set "LANGS=%~2"
shift /1
shift /1
goto parse_args
)
if "%~1"=="-apply-templates" (
if "%~1"=="--apply-templates" (
set "APPLY_TEMPLATES=1"
shift /1
goto parse_args
)
echo ERROR: positional args are not supported. Use -project-root/-langs.
exit /b 1
:args_done
if "%DEST_ROOT%"=="" (
echo ERROR: -project-root is required.
exit /b 1
if "%LANGS%"=="" (
set "LANGS=%~1"
) else (
set "LANGS=%LANGS% %~1"
)
shift /1
goto parse_args
:args_done
if "%LANGS%"=="" set "LANGS=tsl"
set "LANGS=%LANGS:,= %"
@ -194,7 +182,7 @@ set "README=%DEST_PREFIX%\\README.md"
>> "%README%" echo 在目标项目根目录执行(多语言一次同步):
>> "%README%" echo.
>> "%README%" echo ```sh
>> "%README%" echo sh docs/standards/playbook/scripts/sync_standards.sh -langs %LANGS_CSV%
>> "%README%" echo sh docs/standards/playbook/scripts/sync_standards.sh %LANGS_CSV%
>> "%README%" echo ```
>> "%README%" echo.
>> "%README%" echo 查看规范入口:
@ -207,7 +195,7 @@ set "README=%DEST_PREFIX%\\README.md"
>> "%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 -all
>> "%README%" echo sh docs/standards/playbook/scripts/install_codex_skills.sh
>> "%README%" echo ```
>> "%README%" echo.
>> "%README%" echo ## CI templates可选
@ -252,7 +240,7 @@ if not exist "%PROJECT_AGENTS_INDEX%" (
set "OLD_SYNC_ROOT=%SYNC_ROOT%"
set "SYNC_ROOT=%DEST_ROOT_ABS%"
pushd "%DEST_ROOT_ABS%"
call "%DEST_PREFIX%\\scripts\\sync_standards.bat" -langs %LANGS_CSV%
call "%DEST_PREFIX%\\scripts\\sync_standards.bat" %LANGS%
popd
set "SYNC_ROOT=%OLD_SYNC_ROOT%"
@ -368,12 +356,11 @@ exit /b 0
:Usage
echo Usage:
echo scripts\vendor_playbook.bat -project-root ^<path^> ^(default: tsl^)
echo scripts\vendor_playbook.bat -project-root ^<path^> -langs tsl,cpp
echo scripts\vendor_playbook.bat -project-root ^<path^> -langs tsl,cpp -apply-templates
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
echo scripts\vendor_playbook.bat ^<project-root^> tsl cpp --apply-templates
echo.
echo Options:
echo -project-root Target project root ^(required^)
echo -langs Comma/space-separated list of languages ^(default: tsl^)
echo -apply-templates Apply CI/lang templates to project root ^(skip if exists^)
echo --apply-templates Apply CI/lang templates to project root ^(skip if exists^)
exit /b 1

View File

@ -3,9 +3,9 @@
# the target project root.
#
# Usage:
# powershell -File scripts/vendor_playbook.ps1 -ProjectRoot <path>
# powershell -File scripts/vendor_playbook.ps1 -ProjectRoot <path> -Langs tsl,cpp
# powershell -File scripts/vendor_playbook.ps1 -ProjectRoot <path> -Langs @("tsl","cpp") -ApplyTemplates
# 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") -ApplyTemplates
#
# Options:
# -ApplyTemplates Apply CI/lang templates to project root (skip if exists)
@ -17,12 +17,8 @@
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[Alias('h', 'help', '?')]
[switch]$Help,
[Parameter(Mandatory = $false)]
[string]$ProjectRoot,
[Parameter(Mandatory = $true)]
[string]$DestRoot,
[Parameter(Mandatory = $false)]
[string[]]$Langs,
@ -33,24 +29,6 @@ param(
$ErrorActionPreference = "Stop"
if ($Help) {
Write-Host "Usage:"
Write-Host " powershell -File scripts/vendor_playbook.ps1 -ProjectRoot <path>"
Write-Host " powershell -File scripts/vendor_playbook.ps1 -ProjectRoot <path> -Langs tsl,cpp"
Write-Host " powershell -File scripts/vendor_playbook.ps1 -ProjectRoot <path> -Langs @('tsl','cpp') -ApplyTemplates"
Write-Host ""
Write-Host "Options:"
Write-Host " -ProjectRoot Target project root (required)."
Write-Host " -Langs Comma/space-separated list or array (default: tsl)."
Write-Host " -ApplyTemplates Apply CI/lang templates to project root."
Write-Host " -Help Show this help."
exit 0
}
if (-not $ProjectRoot) {
throw "ProjectRoot is required. Use -Help for usage."
}
function Normalize-Langs([string[]]$InputLangs) {
if (-not $InputLangs -or $InputLangs.Count -eq 0) { return @("tsl") }
@ -77,8 +55,8 @@ foreach ($lang in $Langs) {
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
New-Item -ItemType Directory -Path $ProjectRoot -Force | Out-Null
$DestRootAbs = (Resolve-Path $ProjectRoot).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"
@ -207,7 +185,7 @@ if (-not $commit) { $commit = "N/A" }
在目标项目根目录执行多语言一次同步
```sh
sh docs/standards/playbook/scripts/sync_standards.sh -langs $langsCsv
sh docs/standards/playbook/scripts/sync_standards.sh $langsCsv
```
查看规范入口
@ -220,7 +198,7 @@ sh docs/standards/playbook/scripts/sync_standards.sh -langs $langsCsv
安装到本机需要先在 `~/.codex/config.toml` 启用 skills `docs/standards/playbook/SKILLS.md`
```sh
sh docs/standards/playbook/scripts/install_codex_skills.sh -all
sh docs/standards/playbook/scripts/install_codex_skills.sh
```
## CI templates可选

View File

@ -6,20 +6,19 @@ set -eu
# the target project root.
#
# Usage:
# sh scripts/vendor_playbook.sh -project-root <path> # default: tsl
# sh scripts/vendor_playbook.sh -project-root <path> -langs tsl,cpp
# sh scripts/vendor_playbook.sh -project-root <path> -langs tsl,cpp -apply-templates
# 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
# sh scripts/vendor_playbook.sh <project-root> tsl cpp --apply-templates
#
# Options:
# -project-root PATH Target project root (required)
# -langs L1,L2 Comma/space-separated list of languages (default: tsl)
# -apply-templates Apply CI/lang templates to project root (skip if exists)
# --apply-templates Apply CI/lang templates to project root (skip if exists)
#
# Notes:
# - Snapshot is written to: <project-root>/docs/standards/playbook/
# - Existing snapshot is backed up before overwrite.
# - Ruleset templates from rulesets/ will be copied to snapshot for sync_standards use.
# - With -apply-templates, CI and lang templates are copied to project root.
# - With --apply-templates, CI and lang templates are copied to project root.
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
@ -27,49 +26,41 @@ SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
usage() {
cat <<'EOF' >&2
Usage:
sh scripts/vendor_playbook.sh -project-root <path> # default: tsl
sh scripts/vendor_playbook.sh -project-root <path> -langs tsl,cpp
sh scripts/vendor_playbook.sh -project-root <path> -langs tsl,cpp -apply-templates
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
sh scripts/vendor_playbook.sh <project-root> tsl cpp --apply-templates
Options:
-project-root PATH Target project root (required)
-langs L1,L2 Comma/space-separated list of languages (default: tsl)
-apply-templates Apply CI/lang templates to project root (skip if exists)
-h, -help Show this help
--apply-templates Apply CI/lang templates to project root (skip if exists)
-h, --help Show this help
EOF
}
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "-help" ]; then
if [ "$#" -lt 1 ]; then
usage
exit 1
fi
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
usage
exit 0
fi
PROJECT_ROOT=""
PROJECT_ROOT="$1"
shift
langs=""
APPLY_TEMPLATES=0
# Parse arguments
while [ $# -gt 0 ]; do
case "$1" in
-project-root)
if [ $# -lt 2 ] || [ -z "${2:-}" ]; then
echo "ERROR: -project-root requires a path." >&2
usage
exit 1
fi
PROJECT_ROOT="$2"
shift 2
--langs)
langs="${2:-}"
shift 2 || true
;;
-langs)
if [ $# -lt 2 ] || [ -z "${2:-}" ]; then
echo "ERROR: -langs requires a value." >&2
usage
exit 1
fi
langs="$2"
shift 2
;;
-apply-templates)
--apply-templates)
APPLY_TEMPLATES=1
shift
;;
@ -78,18 +69,16 @@ while [ $# -gt 0 ]; do
exit 1
;;
*)
echo "ERROR: positional args are not supported; use -project-root/-langs." >&2
exit 1
if [ -z "$langs" ]; then
langs="$1"
else
langs="$langs $1"
fi
shift
;;
esac
done
if [ -z "$PROJECT_ROOT" ]; then
echo "ERROR: -project-root is required." >&2
usage
exit 1
fi
if [ -z "${langs:-}" ]; then
langs="tsl"
fi
@ -247,7 +236,7 @@ cat >"$DEST_PREFIX/README.md" <<EOF
在目标项目根目录执行(多语言一次同步):
\`\`\`sh
sh docs/standards/playbook/scripts/sync_standards.sh -langs ${langs_csv}
sh docs/standards/playbook/scripts/sync_standards.sh ${langs_csv}
\`\`\`
查看规范入口:
@ -260,7 +249,7 @@ sh docs/standards/playbook/scripts/sync_standards.sh -langs ${langs_csv}
安装到本机(需要先在 \`~/.codex/config.toml\` 启用 skills\`docs/standards/playbook/SKILLS.md\`
\`\`\`sh
sh docs/standards/playbook/scripts/install_codex_skills.sh -all
sh docs/standards/playbook/scripts/install_codex_skills.sh
\`\`\`
## CI templates可选
@ -318,7 +307,7 @@ EOF
EOF
fi
SYNC_ROOT="$PROJECT_ROOT_ABS" sh "$DEST_PREFIX/scripts/sync_standards.sh" -langs "$langs_csv"
SYNC_ROOT="$PROJECT_ROOT_ABS" sh "$DEST_PREFIX/scripts/sync_standards.sh" "$@"
# Apply templates to project root if requested
if [ "$APPLY_TEMPLATES" -eq 1 ]; then

View File

@ -44,10 +44,10 @@ templates/
```bash
# 基础部署
sh scripts/sync_templates.sh -project-root /path/to/project
sh scripts/sync_templates.sh /path/to/project
# 追加完整框架到已有 AGENTS.md
sh scripts/sync_templates.sh -project-root /path/to/project -full
sh scripts/sync_templates.sh --full /path/to/project
```
**Windows PowerShell**
@ -63,8 +63,8 @@ sh scripts/sync_templates.sh -project-root /path/to/project -full
**Windows CMD**
```cmd
scripts\sync_templates.bat -project-root C:\path\to\project
scripts\sync_templates.bat -project-root C:\path\to\project -full
scripts\sync_templates.bat C:\path\to\project
scripts\sync_templates.bat --full C:\path\to\project
```
### 部署行为
@ -72,8 +72,8 @@ scripts\sync_templates.bat -project-root C:\path\to\project -full
- **新项目**:创建完整的 AGENTS.md、AGENT_RULES.md、memory-bank/、docs/prompts/
- **已有 AGENTS.md**
- 默认:追加路由链接(`<!-- playbook:templates:start/end -->`
- `-full`:追加完整框架(规则优先级 + 路由 + 新会话开始时)
- **其他文件**:如果已存在则跳过(使用 `-force` 覆盖)
- `--full`:追加完整框架(规则优先级 + 路由 + 新会话开始时)
- **其他文件**:如果已存在则跳过(使用 `--force` 覆盖)
- **自动创建**TODO.md 和 CONFIRM.md如果不存在
- **占位符替换**:自动替换 `{{DATE}}` 为当前日期
@ -157,11 +157,11 @@ project/
| --------------------------------------- | ----------------------- | -------------- |
| `<!-- playbook:agents:start/end -->` | 语言规则链接 | sync_standards |
| `<!-- playbook:templates:start/end -->` | 路由链接(默认追加) | sync_templates |
| `<!-- playbook:framework:start/end -->` | 完整框架(-full 追加) | sync_templates |
| `<!-- playbook:framework:start/end -->` | 完整框架(--full 追加) | sync_templates |
### ci/、cpp/、python/
语言和 CI 配置模板。通过 `vendor_playbook -apply-templates` 部署:
语言和 CI 配置模板。通过 `vendor_playbook --apply-templates` 部署:
| 目录 | 内容 | 部署位置 |
| ----------- | ----------------------------------------- | ---------- |
@ -173,7 +173,7 @@ project/
```bash
# vendor_playbook 时一并部署
sh scripts/vendor_playbook.sh -project-root /path/to/project -langs tsl,cpp -apply-templates
sh scripts/vendor_playbook.sh /path/to/project tsl cpp --apply-templates
```
## 与 playbook 其他部分的关系
@ -193,10 +193,10 @@ playbook/
```bash
# 1. 部署项目架构模板
sh scripts/sync_templates.sh -project-root /path/to/project
sh scripts/sync_templates.sh /path/to/project
# 2. 部署语言规则
sh scripts/sync_standards.sh -langs tsl # 或其他语言
sh scripts/sync_standards.sh tsl # 或其他语言
# 3. 编辑 memory-bank/*.md 填写项目信息

View File

@ -72,8 +72,9 @@ sh check_doc_links.sh
- **基础功能**
- 脚本存在且可执行
- 单语言同步(`-langs tsl`/`-langs cpp`
- 多语言同步(`-langs tsl,cpp`
- 无参数时默认同步 tsl已有 `.agents/<lang>/` 则自动识别)
- 单语言同步tsl/cpp
- 多语言同步tsl cpp
- **.gitattributes 同步**
- 默认模式追加缺失规则
- 保留现有内容
@ -101,18 +102,18 @@ sh check_doc_links.sh
- **占位符替换**
- `{{PROJECT_NAME}}``{{DATE}}`
- **目录覆盖策略**
- 无 `-force` 时不覆盖已有目录
- `-force` 时覆盖并备份
- 无 `--force` 时不覆盖已有目录
- `--force` 时覆盖并备份
- **AGENTS.md 更新**
- `-full` 更新 framework 区块
- `--full` 更新 framework 区块
#### test_vendor_playbook.bats
测试 `scripts/vendor_playbook.sh` 脚本的功能:
- **基础功能**
- 单语言 vendoring`-langs tsl`
- 多语言 vendoring`-langs tsl,cpp`
- 单语言 vendoring
- 多语言 vendoring
- **自动同步**
- 自动执行 sync_standards
- **SOURCE.md 生成**
@ -144,12 +145,10 @@ sh check_doc_links.sh
- **安装功能**
- 创建 skills 目录
- 复制 skill 目录(包含 `SKILL.md`
- 支持 `-skills` 指定单个 skill 安装
- 支持 `-all` 安装全部 skills
- 支持指定单个 skill 安装
- 同名目录安装前创建备份
- **错误处理**
- 指定不存在的 skill 报错
- 未传 `-all/-skills` 报错
- **幂等性**
- 多次安装结果一致

View File

@ -49,7 +49,7 @@ first_skill_name() {
[ ! -d "$SKILLS_DST_ROOT" ]
sh "$SCRIPT_PATH" -all
sh "$SCRIPT_PATH"
[ -d "$SKILLS_DST_ROOT" ]
}
@ -57,7 +57,7 @@ first_skill_name() {
@test "安装 - 复制 skill 目录" {
skip_if_no_skills
sh "$SCRIPT_PATH" -all
sh "$SCRIPT_PATH"
SKILL_DIRS=$(find "$SKILLS_DST_ROOT" -mindepth 1 -maxdepth 1 -type d)
[ -n "$SKILL_DIRS" ]
@ -73,7 +73,7 @@ first_skill_name() {
SKILL_NAME="$(first_skill_name)"
[ -n "$SKILL_NAME" ]
sh "$SCRIPT_PATH" -skills "$SKILL_NAME"
sh "$SCRIPT_PATH" "$SKILL_NAME"
[ -d "$SKILLS_DST_ROOT/$SKILL_NAME" ]
COUNT=$(find "$SKILLS_DST_ROOT" -mindepth 1 -maxdepth 1 -type d | wc -l)
@ -89,7 +89,7 @@ first_skill_name() {
mkdir -p "$SKILLS_DST_ROOT/$SKILL_NAME"
echo "marker" > "$SKILLS_DST_ROOT/$SKILL_NAME/marker.txt"
sh "$SCRIPT_PATH" -skills "$SKILL_NAME"
sh "$SCRIPT_PATH" "$SKILL_NAME"
BACKUP_DIRS=$(find "$SKILLS_DST_ROOT" -maxdepth 1 -type d -name "$SKILL_NAME.bak.*")
[ -n "$BACKUP_DIRS" ]
@ -98,7 +98,7 @@ first_skill_name() {
@test "错误处理 - 指定不存在 skill 报错" {
skip_if_no_skills
run sh "$SCRIPT_PATH" -skills nonexistent-skill
run sh "$SCRIPT_PATH" nonexistent-skill
[ "$status" -ne 0 ]
}
@ -106,10 +106,10 @@ first_skill_name() {
@test "幂等性 - 多次安装结果一致" {
skip_if_no_skills
sh "$SCRIPT_PATH" -all
sh "$SCRIPT_PATH"
CHECKSUM1=$(find "$SKILLS_DST_ROOT" -type f -name "SKILL.md" ! -path "$SKILLS_DST_ROOT"'/*.bak.*/*' -exec md5sum {} \; | sort | md5sum)
sh "$SCRIPT_PATH" -all
sh "$SCRIPT_PATH"
CHECKSUM2=$(find "$SKILLS_DST_ROOT" -type f -name "SKILL.md" ! -path "$SKILLS_DST_ROOT"'/*.bak.*/*' -exec md5sum {} \; | sort | md5sum)
[ "$CHECKSUM1" = "$CHECKSUM2" ]

View File

@ -35,16 +35,30 @@ teardown() {
[ -f "$SCRIPT_PATH" ]
}
@test "sync_standards.sh - 未传 -langs 报错" {
@test "sync_standards.sh 无参数时同步 tsl 规则集" {
cd "$TEST_DIR"
run sh "$SCRIPT_PATH"
sh "$SCRIPT_PATH"
[ "$status" -ne 0 ]
# 验证输出目录
[ -d ".agents/tsl" ]
[ -f ".agents/tsl/index.md" ]
}
@test "sync_standards.sh 无参数时自动识别已有语言" {
cd "$TEST_DIR"
mkdir -p .agents/cpp
echo "# placeholder" > .agents/cpp/index.md
sh "$SCRIPT_PATH"
[ -d ".agents/cpp" ]
[ -f ".agents/cpp/index.md" ]
[ ! -d ".agents/tsl" ]
}
@test "sync_standards.sh tsl - 同步 TSL 规则集" {
cd "$TEST_DIR"
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
# 验证必须文件
[ -d ".agents/tsl" ]
@ -57,7 +71,7 @@ teardown() {
@test "sync_standards.sh cpp - 同步 C++ 规则集" {
cd "$TEST_DIR"
sh "$SCRIPT_PATH" -langs cpp
sh "$SCRIPT_PATH" cpp
# 验证必须文件
[ -d ".agents/cpp" ]
@ -70,7 +84,7 @@ teardown() {
@test "sync_standards.sh tsl cpp - 同步多个规则集" {
cd "$TEST_DIR"
sh "$SCRIPT_PATH" -langs tsl,cpp
sh "$SCRIPT_PATH" tsl cpp
# 验证两个规则集都存在
[ -d ".agents/tsl" ]
@ -86,7 +100,7 @@ teardown() {
cd "$TEST_DIR"
[ ! -f ".gitattributes" ]
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
[ -f ".gitattributes" ]
grep -q "Added from playbook .gitattributes" .gitattributes
@ -98,7 +112,7 @@ teardown() {
echo "# My custom rules" > .gitattributes
echo "*.custom binary" >> .gitattributes
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
grep -q "# My custom rules" .gitattributes
grep -q "*.custom binary" .gitattributes
@ -113,7 +127,7 @@ teardown() {
EOF
export SYNC_GITATTR_MODE=block
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
# 验证 block 已更新(不再包含 "Old content"
! grep -q "Old content" .gitattributes
@ -127,7 +141,7 @@ EOF
cd "$TEST_DIR"
[ ! -f "AGENTS.md" ]
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
[ -f "AGENTS.md" ]
grep -q ".agents/" AGENTS.md
@ -137,7 +151,7 @@ EOF
cd "$TEST_DIR"
echo "# My custom AGENTS.md" > AGENTS.md
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
grep -q "# My custom AGENTS.md" AGENTS.md
}
@ -150,7 +164,7 @@ EOF
cd "$TEST_DIR"
echo "# Original content" > .gitattributes
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
# 验证备份文件存在
[ -f ".gitattributes.bak."* ] || [ -f ".gitattributes.bak" ]
@ -161,7 +175,7 @@ EOF
mkdir -p .agents/tsl
echo "# Old index" > .agents/tsl/index.md
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
# 验证备份目录存在
[ -d ".agents/tsl.bak."* ] || [ -d ".agents/tsl.bak" ]
@ -179,7 +193,7 @@ EOF
cp -r "$PLAYBOOK_ROOT/rulesets/python" docs/standards/playbook/rulesets/
fi
sh "$SCRIPT_PATH" -langs tsl,cpp
sh "$SCRIPT_PATH" tsl cpp
# 验证规则集不互相覆盖
[ -d ".agents/tsl" ]
@ -197,7 +211,7 @@ EOF
cd "$TEST_DIR"
rm -rf docs/standards/playbook/rulesets
run sh "$SCRIPT_PATH" -langs tsl
run sh "$SCRIPT_PATH" tsl
[ "$status" -ne 0 ]
}
@ -205,7 +219,7 @@ EOF
@test "错误处理 - 无效语言参数时报错" {
cd "$TEST_DIR"
run sh "$SCRIPT_PATH" -langs invalid_lang
run sh "$SCRIPT_PATH" invalid_lang
[ "$status" -ne 0 ]
}
@ -218,7 +232,7 @@ EOF
cd "$TEST_DIR"
export SYNC_GITATTR_MODE=skip
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
[ ! -f ".gitattributes" ]
}
@ -228,7 +242,7 @@ EOF
echo "# Custom content" > .gitattributes
export SYNC_GITATTR_MODE=overwrite
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
# 验证自定义内容被覆盖
! grep -q "# Custom content" .gitattributes
@ -239,7 +253,7 @@ EOF
echo "# Custom rules only" > .gitattributes
export SYNC_GITATTR_MODE=append
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
grep -q "Added from playbook .gitattributes" .gitattributes
grep -q "\\*.tsl" .gitattributes
@ -250,7 +264,7 @@ EOF
cp "$PLAYBOOK_ROOT/.gitattributes" .gitattributes
export SYNC_GITATTR_MODE=append
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
! grep -q "Added from playbook .gitattributes" .gitattributes
}
@ -263,11 +277,11 @@ EOF
cd "$TEST_DIR"
# 第一次同步
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
CHECKSUM1=$(find rulesets/tsl -type f -exec md5sum {} \; | sort | md5sum)
# 第二次同步
sh "$SCRIPT_PATH" -langs tsl
sh "$SCRIPT_PATH" tsl
CHECKSUM2=$(find rulesets/tsl -type f -exec md5sum {} \; | sort | md5sum)
[ "$CHECKSUM1" = "$CHECKSUM2" ]

View File

@ -23,7 +23,7 @@ teardown() {
}
@test "sync_templates.sh - 基础同步与占位符替换" {
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -project-name "DemoProject" -date "2026-02-03"
sh "$SCRIPT_PATH" --project-name "DemoProject" --date "2026-02-03" "$TARGET_DIR"
[ -d "$TARGET_DIR/memory-bank" ]
[ -f "$TARGET_DIR/memory-bank/project-brief.md" ]
@ -39,13 +39,13 @@ teardown() {
[ -z "$(find "$TARGET_DIR" -name '*.template.md' -print -quit)" ]
}
@test "sync_templates.sh - 已存在目录不覆盖 (无 -force)" {
@test "sync_templates.sh - 已存在目录不覆盖 (无 --force)" {
mkdir -p "$TARGET_DIR/memory-bank"
mkdir -p "$TARGET_DIR/docs/prompts"
echo "keep" > "$TARGET_DIR/memory-bank/keep.md"
echo "keep" > "$TARGET_DIR/docs/prompts/keep.md"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR"
sh "$SCRIPT_PATH" "$TARGET_DIR"
[ -f "$TARGET_DIR/memory-bank/keep.md" ]
[ ! -f "$TARGET_DIR/memory-bank/project-brief.md" ]
@ -53,11 +53,11 @@ teardown() {
[ ! -f "$TARGET_DIR/docs/prompts/README.md" ]
}
@test "sync_templates.sh - -force 覆盖并备份" {
@test "sync_templates.sh - --force 覆盖并备份" {
mkdir -p "$TARGET_DIR/memory-bank"
echo "marker" > "$TARGET_DIR/memory-bank/marker.txt"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -force
sh "$SCRIPT_PATH" --force "$TARGET_DIR"
[ -f "$TARGET_DIR/memory-bank/project-brief.md" ]
[ ! -f "$TARGET_DIR/memory-bank/marker.txt" ]
@ -67,7 +67,7 @@ teardown() {
[ -f "$backup_dir/marker.txt" ]
}
@test "sync_templates.sh - -full 更新 framework 区块" {
@test "sync_templates.sh - --full 更新 framework 区块" {
cat > "$TARGET_DIR/AGENTS.md" << 'EOF'
# Agent Instructions
@ -78,7 +78,7 @@ OLD_FRAMEWORK
Footer
EOF
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -full
sh "$SCRIPT_PATH" --full "$TARGET_DIR"
! grep -q "OLD_FRAMEWORK" "$TARGET_DIR/AGENTS.md"
grep -q "<!-- playbook:framework:start -->" "$TARGET_DIR/AGENTS.md"

View File

@ -47,7 +47,7 @@ teardown() {
@test "vendor_playbook.sh - 单语言 vendoring (tsl)" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
# 验证快照目录结构
[ -d "docs/standards/playbook" ]
@ -60,7 +60,7 @@ teardown() {
@test "vendor_playbook.sh - 多语言 vendoring (tsl cpp)" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl,cpp
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl cpp
# 验证包含两种语言的文档
[ -d "docs/standards/playbook/docs/tsl" ]
@ -76,7 +76,7 @@ teardown() {
@test "vendor_playbook.sh - 自动执行 sync_standards" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
# 验证根目录已同步规则集
[ -d ".agents/tsl" ]
@ -87,7 +87,7 @@ teardown() {
@test "vendor_playbook.sh - 多语言自动同步" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl,cpp
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl cpp
# 验证两个规则集都已同步
[ -d ".agents/tsl" ]
@ -102,7 +102,7 @@ teardown() {
@test "vendor_playbook.sh - 生成 SOURCE.md" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
[ -f "docs/standards/playbook/SOURCE.md" ]
grep -q "Source:" docs/standards/playbook/SOURCE.md
@ -112,7 +112,7 @@ teardown() {
@test "vendor_playbook.sh - SOURCE.md 包含 commit hash" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
# 验证包含 commit hash40个十六进制字符
grep -E "[0-9a-f]{40}" docs/standards/playbook/SOURCE.md
@ -121,7 +121,7 @@ teardown() {
@test "vendor_playbook.sh - SOURCE.md 包含时间戳" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
# 验证包含日期格式 YYYY-MM-DD
grep -E "[0-9]{4}-[0-9]{2}-[0-9]{2}" docs/standards/playbook/SOURCE.md
@ -134,7 +134,7 @@ teardown() {
@test "裁剪 - 仅包含指定语言的文档" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
# 验证包含 TSL 文档
[ -d "docs/standards/playbook/docs/tsl" ]
@ -148,7 +148,7 @@ teardown() {
@test "裁剪 - 始终包含 common 目录" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
[ -d "docs/standards/playbook/docs/common" ]
[ -f "docs/standards/playbook/docs/common/commit_message.md" ]
@ -157,7 +157,7 @@ teardown() {
@test "裁剪 - 包含对应的模板文件" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs cpp
sh "$SCRIPT_PATH" "$TARGET_DIR" cpp
# 验证包含 C++ 模板
[ -d "docs/standards/playbook/templates/cpp" ]
@ -171,15 +171,15 @@ teardown() {
@test "裁剪 - 包含通用 CI 模板" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
[ -d "docs/standards/playbook/templates/ci" ]
}
@test "vendor_playbook.sh - -apply-templates 应用模板到项目根目录" {
@test "vendor_playbook.sh - --apply-templates 应用模板到项目根目录" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs cpp -apply-templates
sh "$SCRIPT_PATH" "$TARGET_DIR" cpp --apply-templates
if [ -f "$PLAYBOOK_ROOT/templates/cpp/.clang-format" ]; then
[ -f ".clang-format" ]
@ -198,13 +198,13 @@ teardown() {
cd "$TARGET_DIR"
# 首次 vendor
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
# 在快照中添加标记文件
touch docs/standards/playbook/OLD_MARKER
# 再次 vendor
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
# 验证旧标记不存在(已被覆盖)
[ ! -f "docs/standards/playbook/OLD_MARKER" ]
@ -216,7 +216,7 @@ teardown() {
# 确保 docs/standards 不存在
[ ! -d "docs/standards" ]
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
[ -d "docs/standards/playbook" ]
}
@ -231,7 +231,7 @@ teardown() {
missing_dir="$TEST_DIR/missing-project"
rm -rf "$missing_dir"
run sh "$SCRIPT_PATH" -project-root "$missing_dir" -langs tsl
run sh "$SCRIPT_PATH" "$missing_dir" tsl
[ "$status" -ne 0 ]
}
@ -239,7 +239,7 @@ teardown() {
@test "错误处理 - 无效语言参数时报错" {
cd "$TARGET_DIR"
run sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs invalid_lang
run sh "$SCRIPT_PATH" "$TARGET_DIR" invalid_lang
[ "$status" -ne 0 ]
}
@ -248,7 +248,7 @@ teardown() {
cd "$TARGET_DIR"
rm -rf .git
run sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
run sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
# 应该给出警告但不失败
[ "$status" -eq 0 ]
@ -261,7 +261,7 @@ teardown() {
@test "完整性 - 验证所有必要文件已复制" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
# 验证关键文件
[ -f "docs/standards/playbook/README.md" ]
@ -274,10 +274,10 @@ teardown() {
@test "完整性 - 验证脚本可执行性" {
cd "$TARGET_DIR"
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
# 验证同步脚本可执行
run sh docs/standards/playbook/scripts/sync_standards.sh -langs tsl
run sh docs/standards/playbook/scripts/sync_standards.sh tsl
[ "$status" -eq 0 ]
}
@ -290,11 +290,11 @@ teardown() {
cd "$TARGET_DIR"
# 第一次 vendor
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
CHECKSUM1=$(find docs/standards/playbook -type f -name "*.md" ! -name "SOURCE.md" -exec md5sum {} \; | sort | md5sum)
# 第二次 vendor
sh "$SCRIPT_PATH" -project-root "$TARGET_DIR" -langs tsl
sh "$SCRIPT_PATH" "$TARGET_DIR" tsl
CHECKSUM2=$(find docs/standards/playbook -type f -name "*.md" ! -name "SOURCE.md" -exec md5sum {} \; | sort | md5sum)
[ "$CHECKSUM1" = "$CHECKSUM2" ]