🔧 chore(scripts): unify single-dash options
This commit is contained in:
parent
b2eb475a6d
commit
e4e1d14182
|
|
@ -69,8 +69,8 @@ scripts\sync_templates.bat C:\path\to\project
|
||||||
|
|
||||||
- **新项目**:创建完整的 `AGENTS.md`、`AGENT_RULES.md`、`memory-bank/`、`docs/prompts/`、`TODO.md`、`CONFIRM.md`
|
- **新项目**:创建完整的 `AGENTS.md`、`AGENT_RULES.md`、`memory-bank/`、`docs/prompts/`、`TODO.md`、`CONFIRM.md`
|
||||||
- **已有 AGENTS.md**:追加路由链接(使用 `<!-- playbook:templates:start/end -->` 标记)
|
- **已有 AGENTS.md**:追加路由链接(使用 `<!-- playbook:templates:start/end -->` 标记)
|
||||||
- **--full 参数**:追加完整框架(规则优先级 + 新会话开始时)到已有 AGENTS.md
|
- **-full 参数**:追加完整框架(规则优先级 + 新会话开始时)到已有 AGENTS.md
|
||||||
- **其他文件**:如果已存在则跳过(使用 `--force` 覆盖)
|
- **其他文件**:如果已存在则跳过(使用 `-force` 覆盖)
|
||||||
|
|
||||||
详见:`templates/README.md`
|
详见:`templates/README.md`
|
||||||
|
|
||||||
|
|
@ -374,7 +374,7 @@ sh docs/standards/playbook/scripts/sync_standards.sh tsl cpp
|
||||||
- Windows bat:
|
- Windows bat:
|
||||||
|
|
||||||
```bat
|
```bat
|
||||||
<PLAYBOOK_ROOT>\\scripts\\vendor_playbook.bat <target-project-root> --langs tsl,cpp
|
<PLAYBOOK_ROOT>\\scripts\\vendor_playbook.bat <target-project-root> -langs tsl,cpp
|
||||||
```
|
```
|
||||||
|
|
||||||
**脚本会**:
|
**脚本会**:
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ sh scripts/install_codex_skills.sh style-cleanup code-review-workflow
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# 安装到当前目录的 .codex/skills/
|
# 安装到当前目录的 .codex/skills/
|
||||||
sh scripts/install_codex_skills.sh --local
|
sh scripts/install_codex_skills.sh -local
|
||||||
|
|
||||||
# 或手动指定 CODEX_HOME
|
# 或手动指定 CODEX_HOME
|
||||||
CODEX_HOME="$(pwd)/.codex" sh scripts/install_codex_skills.sh
|
CODEX_HOME="$(pwd)/.codex" sh scripts/install_codex_skills.sh
|
||||||
|
|
@ -80,7 +80,7 @@ powershell -File scripts/install_codex_skills.ps1 -Local
|
||||||
```
|
```
|
||||||
|
|
||||||
```bat
|
```bat
|
||||||
scripts\install_codex_skills.bat --local
|
scripts\install_codex_skills.bat -local
|
||||||
```
|
```
|
||||||
|
|
||||||
> 注意:Codex 只会从 `CODEX_HOME` 加载 skills;使用本地安装时,启动 Codex 需设置同样的 `CODEX_HOME`。
|
> 注意:Codex 只会从 `CODEX_HOME` 加载 skills;使用本地安装时,启动 Codex 需设置同样的 `CODEX_HOME`。
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ rem
|
||||||
rem Usage:
|
rem Usage:
|
||||||
rem install_codex_skills.bat
|
rem install_codex_skills.bat
|
||||||
rem install_codex_skills.bat style-cleanup code-review-workflow
|
rem install_codex_skills.bat style-cleanup code-review-workflow
|
||||||
rem install_codex_skills.bat --local
|
rem install_codex_skills.bat -local
|
||||||
rem
|
rem
|
||||||
rem Notes:
|
rem Notes:
|
||||||
rem - Codex loads skills at startup; restart `codex` after installation.
|
rem - Codex loads skills at startup; restart `codex` after installation.
|
||||||
|
|
@ -19,10 +19,23 @@ for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
|
||||||
set "SKILLS_SRC_ROOT=%SRC%\\codex\\skills"
|
set "SKILLS_SRC_ROOT=%SRC%\\codex\\skills"
|
||||||
|
|
||||||
set "LOCAL_MODE=0"
|
set "LOCAL_MODE=0"
|
||||||
if /I "%~1"=="--local" set "LOCAL_MODE=1"
|
:parse_opts
|
||||||
if /I "%~1"=="-l" set "LOCAL_MODE=1"
|
if "%~1"=="" goto opts_done
|
||||||
if "%LOCAL_MODE%"=="1" shift
|
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
|
||||||
|
)
|
||||||
|
goto opts_done
|
||||||
|
|
||||||
|
:opts_done
|
||||||
set "CODEX_HOME=%CODEX_HOME%"
|
set "CODEX_HOME=%CODEX_HOME%"
|
||||||
if "%LOCAL_MODE%"=="1" if "%CODEX_HOME%"=="" set "CODEX_HOME=%CD%\\.codex"
|
if "%LOCAL_MODE%"=="1" if "%CODEX_HOME%"=="" set "CODEX_HOME=%CD%\\.codex"
|
||||||
if "%CODEX_HOME%"=="" set "CODEX_HOME=%USERPROFILE%\\.codex"
|
if "%CODEX_HOME%"=="" set "CODEX_HOME=%USERPROFILE%\\.codex"
|
||||||
|
|
@ -53,6 +66,18 @@ echo Done. Skills installed to: "%SKILLS_DST_ROOT%"
|
||||||
endlocal
|
endlocal
|
||||||
exit /b 0
|
exit /b 0
|
||||||
|
|
||||||
|
:show_help
|
||||||
|
echo Usage:
|
||||||
|
echo install_codex_skills.bat [options] [skill ...]
|
||||||
|
echo.
|
||||||
|
echo Options:
|
||||||
|
echo -local, -l Install to .\\.codex ^(or CODEX_HOME if set^)
|
||||||
|
echo -help, -h Show this help
|
||||||
|
echo.
|
||||||
|
echo Env:
|
||||||
|
echo CODEX_HOME Target Codex home ^(default: %%USERPROFILE%%\\.codex^)
|
||||||
|
exit /b 0
|
||||||
|
|
||||||
:InstallOne
|
:InstallOne
|
||||||
set "NAME=%~1"
|
set "NAME=%~1"
|
||||||
set "SRC_DIR=%SKILLS_SRC_ROOT%\\%NAME%"
|
set "SRC_DIR=%SKILLS_SRC_ROOT%\\%NAME%"
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,28 @@
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
|
[Alias('h', 'help', '?')]
|
||||||
|
[switch]$Help,
|
||||||
|
|
||||||
[switch]$Local,
|
[switch]$Local,
|
||||||
[Parameter(Mandatory = $false, ValueFromRemainingArguments = $true)]
|
[Parameter(Mandatory = $false, ValueFromRemainingArguments = $true)]
|
||||||
[string[]]$Skills
|
[string[]]$Skills
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
if ($Help) {
|
||||||
|
Write-Host "Usage:"
|
||||||
|
Write-Host " powershell -File scripts/install_codex_skills.ps1 [options] [skill ...]"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Options:"
|
||||||
|
Write-Host " -Local Install to ./.codex (or CODEX_HOME if set)."
|
||||||
|
Write-Host " -Help Show this help."
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Env:"
|
||||||
|
Write-Host " CODEX_HOME Target Codex home (default: ~/.codex)."
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||||
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
|
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
|
||||||
$SkillsSrcRoot = Join-Path $Src "codex/skills"
|
$SkillsSrcRoot = Join-Path $Src "codex/skills"
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ set -eu
|
||||||
# Usage:
|
# Usage:
|
||||||
# sh scripts/install_codex_skills.sh # install all skills
|
# 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 style-cleanup code-review-workflow
|
||||||
# sh scripts/install_codex_skills.sh --local # install to <cwd>/.codex
|
# sh scripts/install_codex_skills.sh -local # install to <cwd>/.codex
|
||||||
#
|
#
|
||||||
# Notes:
|
# Notes:
|
||||||
# - Codex loads skills at startup; restart `codex` after installation.
|
# - Codex loads skills at startup; restart `codex` after installation.
|
||||||
|
|
@ -18,11 +18,41 @@ SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
|
||||||
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
|
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
|
||||||
SKILLS_SRC_ROOT="$SRC/codex/skills"
|
SKILLS_SRC_ROOT="$SRC/codex/skills"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<'EOF' >&2
|
||||||
|
Usage:
|
||||||
|
sh scripts/install_codex_skills.sh [options] [skill ...]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-local, -l Install to ./.codex (or CODEX_HOME if set).
|
||||||
|
-h, -help Show this help.
|
||||||
|
|
||||||
|
Env:
|
||||||
|
CODEX_HOME Target Codex home (default: ~/.codex).
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
LOCAL_MODE=0
|
LOCAL_MODE=0
|
||||||
if [ "${1:-}" = "--local" ] || [ "${1:-}" = "-l" ]; then
|
while [ $# -gt 0 ]; do
|
||||||
LOCAL_MODE=1
|
case "$1" in
|
||||||
shift
|
-local|-l)
|
||||||
fi
|
LOCAL_MODE=1
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-h|-help)
|
||||||
|
usage
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
echo "ERROR: Unknown option: $1" >&2
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [ "$LOCAL_MODE" -eq 1 ]; then
|
if [ "$LOCAL_MODE" -eq 1 ]; then
|
||||||
LOCAL_CODEX_HOME="$(pwd -P)/.codex"
|
LOCAL_CODEX_HOME="$(pwd -P)/.codex"
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ rem sync_standards.bat tsl cpp
|
||||||
rem Notes:
|
rem Notes:
|
||||||
rem - When syncing multiple rulesets, .gitattributes is synced only once (first ruleset).
|
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 "SCRIPT_DIR=%~dp0"
|
||||||
set "ROOT=%SYNC_ROOT%"
|
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%"=="" for /f "delims=" %%R in ('git -C "%SCRIPT_DIR%" rev-parse --show-toplevel 2^>nul') do set "ROOT=%%R"
|
||||||
|
|
@ -32,6 +35,23 @@ set "GITATTR_DST=%ROOT%\.gitattributes"
|
||||||
set "SYNC_GITATTR_MODE=%SYNC_GITATTR_MODE%"
|
set "SYNC_GITATTR_MODE=%SYNC_GITATTR_MODE%"
|
||||||
if "%SYNC_GITATTR_MODE%"=="" set "SYNC_GITATTR_MODE=append"
|
if "%SYNC_GITATTR_MODE%"=="" set "SYNC_GITATTR_MODE=append"
|
||||||
|
|
||||||
|
goto after_help
|
||||||
|
|
||||||
|
:show_help
|
||||||
|
echo Usage:
|
||||||
|
echo sync_standards.bat
|
||||||
|
echo sync_standards.bat tsl cpp
|
||||||
|
echo.
|
||||||
|
echo Options:
|
||||||
|
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
|
||||||
|
|
||||||
|
:after_help
|
||||||
rem Multi rulesets: only on outer invocation.
|
rem Multi rulesets: only on outer invocation.
|
||||||
if "%SYNC_STANDARDS_INNER%"=="" (
|
if "%SYNC_STANDARDS_INNER%"=="" (
|
||||||
set "LANG_LIST="
|
set "LANG_LIST="
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,10 @@
|
||||||
# Existing targets are backed up before overwrite.
|
# Existing targets are backed up before overwrite.
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[Alias('h', 'help', '?')]
|
||||||
|
[switch]$Help,
|
||||||
|
|
||||||
# Sync multiple rulesets in one run:
|
# Sync multiple rulesets in one run:
|
||||||
# -Langs tsl,cpp
|
# -Langs tsl,cpp
|
||||||
# -Langs @("tsl","cpp")
|
# -Langs @("tsl","cpp")
|
||||||
|
|
@ -12,6 +16,22 @@ param(
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
if ($Help) {
|
||||||
|
Write-Host "Usage:"
|
||||||
|
Write-Host " powershell -File scripts/sync_standards.ps1"
|
||||||
|
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."
|
||||||
|
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
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||||
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
|
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ set -eu
|
||||||
#
|
#
|
||||||
# Multi rulesets:
|
# Multi rulesets:
|
||||||
# sh .../sync_standards.sh tsl cpp
|
# sh .../sync_standards.sh tsl cpp
|
||||||
# sh .../sync_standards.sh --langs tsl,cpp
|
# sh .../sync_standards.sh -langs tsl,cpp
|
||||||
# Notes:
|
# Notes:
|
||||||
# - When syncing multiple rulesets, .gitattributes is synced only once (first ruleset).
|
# - When syncing multiple rulesets, .gitattributes is synced only once (first ruleset).
|
||||||
|
|
||||||
|
|
@ -21,6 +21,29 @@ else
|
||||||
fi
|
fi
|
||||||
ROOT="$(CDPATH= cd -- "$ROOT" && pwd -P)"
|
ROOT="$(CDPATH= cd -- "$ROOT" && pwd -P)"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<'EOF' >&2
|
||||||
|
Usage:
|
||||||
|
sh scripts/sync_standards.sh
|
||||||
|
sh scripts/sync_standards.sh tsl cpp
|
||||||
|
sh scripts/sync_standards.sh -langs tsl,cpp
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-langs L1,L2 Comma/space-separated list of languages.
|
||||||
|
-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
|
||||||
|
|
||||||
AGENTS_SRC_ROOT="$SRC/rulesets"
|
AGENTS_SRC_ROOT="$SRC/rulesets"
|
||||||
GITATTR_SRC="$SRC/.gitattributes"
|
GITATTR_SRC="$SRC/.gitattributes"
|
||||||
|
|
||||||
|
|
@ -41,7 +64,7 @@ fi
|
||||||
# Parse multi rulesets only on the outer invocation.
|
# Parse multi rulesets only on the outer invocation.
|
||||||
if [ "${SYNC_STANDARDS_INNER:-}" != "1" ]; then
|
if [ "${SYNC_STANDARDS_INNER:-}" != "1" ]; then
|
||||||
langs=""
|
langs=""
|
||||||
if [ "${1:-}" = "--langs" ]; then
|
if [ "${1:-}" = "-langs" ]; then
|
||||||
langs="${2:-}"
|
langs="${2:-}"
|
||||||
shift 2
|
shift 2
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ rem
|
||||||
rem Usage:
|
rem Usage:
|
||||||
rem sync_templates.bat # sync to current git root
|
rem sync_templates.bat # sync to current git root
|
||||||
rem sync_templates.bat <project-root> # sync to specified project
|
rem sync_templates.bat <project-root> # sync to specified project
|
||||||
rem sync_templates.bat --force # overwrite existing files
|
rem sync_templates.bat -force # overwrite existing files
|
||||||
rem sync_templates.bat --full # append full framework to existing AGENTS.md
|
rem sync_templates.bat -full # append full framework to existing AGENTS.md
|
||||||
|
|
||||||
set "SCRIPT_DIR=%~dp0"
|
set "SCRIPT_DIR=%~dp0"
|
||||||
for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
|
for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
|
||||||
|
|
@ -23,18 +23,18 @@ set "PROJECT_ROOT="
|
||||||
|
|
||||||
:parse_args
|
:parse_args
|
||||||
if "%~1"=="" goto args_done
|
if "%~1"=="" goto args_done
|
||||||
if /I "%~1"=="--force" (
|
if /I "%~1"=="-force" (
|
||||||
set "FORCE=1"
|
set "FORCE=1"
|
||||||
shift
|
shift
|
||||||
goto parse_args
|
goto parse_args
|
||||||
)
|
)
|
||||||
if /I "%~1"=="--full" (
|
if /I "%~1"=="-full" (
|
||||||
set "FULL=1"
|
set "FULL=1"
|
||||||
shift
|
shift
|
||||||
goto parse_args
|
goto parse_args
|
||||||
)
|
)
|
||||||
if /I "%~1"=="-h" goto show_help
|
if /I "%~1"=="-h" goto show_help
|
||||||
if /I "%~1"=="--help" goto show_help
|
if /I "%~1"=="-help" goto show_help
|
||||||
set "PROJECT_ROOT=%~1"
|
set "PROJECT_ROOT=%~1"
|
||||||
shift
|
shift
|
||||||
goto parse_args
|
goto parse_args
|
||||||
|
|
@ -44,9 +44,9 @@ echo Usage:
|
||||||
echo sync_templates.bat [options] [project-root]
|
echo sync_templates.bat [options] [project-root]
|
||||||
echo.
|
echo.
|
||||||
echo Options:
|
echo Options:
|
||||||
echo --force Overwrite existing files
|
echo -force Overwrite existing files
|
||||||
echo --full Append full framework (规则优先级 + 新会话开始时) to existing AGENTS.md
|
echo -full Append full framework (规则优先级 + 新会话开始时) to existing AGENTS.md
|
||||||
echo -h, --help Show this help
|
echo -h, -help Show this help
|
||||||
exit /b 0
|
exit /b 0
|
||||||
|
|
||||||
:args_done
|
:args_done
|
||||||
|
|
@ -89,7 +89,7 @@ set "MEMORY_BANK_DST=%PROJECT_ROOT%\memory-bank"
|
||||||
if exist "%MEMORY_BANK_SRC%" (
|
if exist "%MEMORY_BANK_SRC%" (
|
||||||
if exist "%MEMORY_BANK_DST%" (
|
if exist "%MEMORY_BANK_DST%" (
|
||||||
if "%FORCE%"=="0" (
|
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
|
goto sync_prompts
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -118,7 +118,7 @@ set "PROMPTS_DST=%PROJECT_ROOT%\docs\prompts"
|
||||||
if exist "%PROMPTS_SRC%" (
|
if exist "%PROMPTS_SRC%" (
|
||||||
if exist "%PROMPTS_DST%" (
|
if exist "%PROMPTS_DST%" (
|
||||||
if "%FORCE%"=="0" (
|
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
|
goto sync_agents
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
@ -146,7 +146,7 @@ if exist "%PROMPTS_SRC%" (
|
||||||
rem 3. Sync AGENTS.md
|
rem 3. Sync AGENTS.md
|
||||||
set "AGENTS_DST=%PROJECT_ROOT%\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" (
|
if "%FULL%"=="1" (
|
||||||
set "MARKER_START=<!-- playbook:framework:start -->"
|
set "MARKER_START=<!-- playbook:framework:start -->"
|
||||||
set "MARKER_END=<!-- playbook:framework:end -->"
|
set "MARKER_END=<!-- playbook:framework:end -->"
|
||||||
|
|
@ -199,7 +199,7 @@ set "AGENT_RULES_DST=%PROJECT_ROOT%\AGENT_RULES.md"
|
||||||
if exist "%AGENT_RULES_SRC%" (
|
if exist "%AGENT_RULES_SRC%" (
|
||||||
if exist "%AGENT_RULES_DST%" (
|
if exist "%AGENT_RULES_DST%" (
|
||||||
if "%FORCE%"=="0" (
|
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
|
goto sync_todo
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@
|
||||||
# Existing targets are backed up before overwrite.
|
# Existing targets are backed up before overwrite.
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[Alias('h', 'help', '?')]
|
||||||
|
[switch]$Help,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false, Position = 0)]
|
[Parameter(Mandatory = $false, Position = 0)]
|
||||||
[string]$ProjectRoot,
|
[string]$ProjectRoot,
|
||||||
|
|
||||||
|
|
@ -26,6 +30,20 @@ param(
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
if ($Help) {
|
||||||
|
Write-Host "Usage:"
|
||||||
|
Write-Host " powershell -File scripts/sync_templates.ps1 [options] [project-root]"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Options:"
|
||||||
|
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
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||||
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
|
$Src = (Resolve-Path (Join-Path $ScriptDir "..")).Path
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,14 @@ set -eu
|
||||||
# Usage:
|
# Usage:
|
||||||
# sh scripts/sync_templates.sh # sync to current git root
|
# sh scripts/sync_templates.sh # sync to current git root
|
||||||
# sh scripts/sync_templates.sh <project-root> # sync to specified project
|
# sh scripts/sync_templates.sh <project-root> # sync to specified project
|
||||||
# sh scripts/sync_templates.sh --project-name "MyProject" --date "2026-01-20"
|
# sh scripts/sync_templates.sh -project-name "MyProject" -date "2026-01-20"
|
||||||
#
|
#
|
||||||
# Options:
|
# Options:
|
||||||
# --project-name NAME Replace {{PROJECT_NAME}} placeholder
|
# -project-name NAME Replace {{PROJECT_NAME}} placeholder
|
||||||
# --date DATE Replace {{DATE}} placeholder (default: today)
|
# -date DATE Replace {{DATE}} placeholder (default: today)
|
||||||
# --no-backup Skip backup of existing files
|
# -no-backup Skip backup of existing files
|
||||||
# --force Overwrite without prompting
|
# -force Overwrite without prompting
|
||||||
|
# -full Append full framework (规则优先级 + 新会话开始时) to existing AGENTS.md
|
||||||
|
|
||||||
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
|
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
|
||||||
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
|
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
|
||||||
|
|
@ -33,43 +34,43 @@ PROJECT_ROOT=""
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--project-name)
|
-project-name)
|
||||||
PROJECT_NAME="$2"
|
PROJECT_NAME="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--date)
|
-date)
|
||||||
SYNC_DATE="$2"
|
SYNC_DATE="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--no-backup)
|
-no-backup)
|
||||||
NO_BACKUP=1
|
NO_BACKUP=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--force)
|
-force)
|
||||||
FORCE=1
|
FORCE=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--full)
|
-full)
|
||||||
FULL=1
|
FULL=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
-h|-help)
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
Usage:
|
Usage:
|
||||||
sh scripts/sync_templates.sh [options] [project-root]
|
sh scripts/sync_templates.sh [options] [project-root]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--project-name NAME Replace {{PROJECT_NAME}} placeholder
|
-project-name NAME Replace {{PROJECT_NAME}} placeholder
|
||||||
--date DATE Replace {{DATE}} placeholder (default: today)
|
-date DATE Replace {{DATE}} placeholder (default: today)
|
||||||
--no-backup Skip backup of existing files
|
-no-backup Skip backup of existing files
|
||||||
--force Overwrite without prompting
|
-force Overwrite without prompting
|
||||||
--full Append full framework (规则优先级 + 新会话开始时) to existing AGENTS.md
|
-full Append full framework (规则优先级 + 新会话开始时) to existing AGENTS.md
|
||||||
-h, --help Show this help
|
-h, -help Show this help
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
sh scripts/sync_templates.sh
|
sh scripts/sync_templates.sh
|
||||||
sh scripts/sync_templates.sh /path/to/project
|
sh scripts/sync_templates.sh /path/to/project
|
||||||
sh scripts/sync_templates.sh --full /path/to/project
|
sh scripts/sync_templates.sh -full /path/to/project
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
|
@ -160,7 +161,7 @@ if [ -d "$MEMORY_BANK_SRC" ]; then
|
||||||
MEMORY_BANK_DST="$PROJECT_ROOT/memory-bank"
|
MEMORY_BANK_DST="$PROJECT_ROOT/memory-bank"
|
||||||
|
|
||||||
if [ -e "$MEMORY_BANK_DST" ] && [ "$FORCE" -eq 0 ]; then
|
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
|
else
|
||||||
backup_if_exists "$MEMORY_BANK_DST"
|
backup_if_exists "$MEMORY_BANK_DST"
|
||||||
mkdir -p "$MEMORY_BANK_DST"
|
mkdir -p "$MEMORY_BANK_DST"
|
||||||
|
|
@ -185,7 +186,7 @@ if [ -d "$PROMPTS_SRC" ]; then
|
||||||
PROMPTS_DST="$PROJECT_ROOT/docs/prompts"
|
PROMPTS_DST="$PROJECT_ROOT/docs/prompts"
|
||||||
|
|
||||||
if [ -e "$PROMPTS_DST" ] && [ "$FORCE" -eq 0 ]; then
|
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
|
else
|
||||||
backup_if_exists "$PROMPTS_DST"
|
backup_if_exists "$PROMPTS_DST"
|
||||||
mkdir -p "$PROJECT_ROOT/docs"
|
mkdir -p "$PROJECT_ROOT/docs"
|
||||||
|
|
@ -206,7 +207,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. Sync AGENTS.md
|
# 3. Sync AGENTS.md
|
||||||
# Choose markers based on --full flag
|
# Choose markers based on -full flag
|
||||||
if [ "$FULL" -eq 1 ]; then
|
if [ "$FULL" -eq 1 ]; then
|
||||||
MARKER_START="<!-- playbook:framework:start -->"
|
MARKER_START="<!-- playbook:framework:start -->"
|
||||||
MARKER_END="<!-- playbook:framework:end -->"
|
MARKER_END="<!-- playbook:framework:end -->"
|
||||||
|
|
@ -283,7 +284,7 @@ if [ -f "$AGENT_RULES_SRC" ]; then
|
||||||
AGENT_RULES_DST="$PROJECT_ROOT/AGENT_RULES.md"
|
AGENT_RULES_DST="$PROJECT_ROOT/AGENT_RULES.md"
|
||||||
|
|
||||||
if [ -e "$AGENT_RULES_DST" ] && [ "$FORCE" -eq 0 ]; then
|
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
|
else
|
||||||
backup_if_exists "$AGENT_RULES_DST"
|
backup_if_exists "$AGENT_RULES_DST"
|
||||||
cp "$AGENT_RULES_SRC" "$AGENT_RULES_DST"
|
cp "$AGENT_RULES_SRC" "$AGENT_RULES_DST"
|
||||||
|
|
|
||||||
|
|
@ -8,23 +8,23 @@ rem
|
||||||
rem Usage:
|
rem Usage:
|
||||||
rem scripts\vendor_playbook.bat <project-root> (default: tsl)
|
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> tsl cpp
|
||||||
rem scripts\vendor_playbook.bat <project-root> --langs tsl,cpp
|
rem scripts\vendor_playbook.bat <project-root> -langs tsl,cpp
|
||||||
rem scripts\vendor_playbook.bat <project-root> tsl cpp --apply-templates
|
rem scripts\vendor_playbook.bat <project-root> tsl cpp -apply-templates
|
||||||
rem
|
rem
|
||||||
rem Options:
|
rem Options:
|
||||||
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
|
||||||
rem Notes:
|
rem Notes:
|
||||||
rem - Snapshot is written to: <project-root>\docs\standards\playbook\
|
rem - Snapshot is written to: <project-root>\docs\standards\playbook\
|
||||||
rem - Existing snapshot is backed up before overwrite.
|
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"
|
set "SCRIPT_DIR=%~dp0"
|
||||||
for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
|
for %%I in ("%SCRIPT_DIR%..") do set "SRC=%%~fI"
|
||||||
|
|
||||||
if "%~1"=="" goto Usage
|
if "%~1"=="" goto Usage
|
||||||
if "%~1"=="-h" goto Usage
|
if "%~1"=="-h" goto Usage
|
||||||
if "%~1"=="--help" goto Usage
|
if "%~1"=="-help" goto Usage
|
||||||
|
|
||||||
set "DEST_ROOT=%~1"
|
set "DEST_ROOT=%~1"
|
||||||
shift /1
|
shift /1
|
||||||
|
|
@ -35,13 +35,13 @@ set "APPLY_TEMPLATES=0"
|
||||||
rem Parse arguments
|
rem Parse arguments
|
||||||
:parse_args
|
:parse_args
|
||||||
if "%~1"=="" goto args_done
|
if "%~1"=="" goto args_done
|
||||||
if "%~1"=="--langs" (
|
if "%~1"=="-langs" (
|
||||||
set "LANGS=%~2"
|
set "LANGS=%~2"
|
||||||
shift /1
|
shift /1
|
||||||
shift /1
|
shift /1
|
||||||
goto parse_args
|
goto parse_args
|
||||||
)
|
)
|
||||||
if "%~1"=="--apply-templates" (
|
if "%~1"=="-apply-templates" (
|
||||||
set "APPLY_TEMPLATES=1"
|
set "APPLY_TEMPLATES=1"
|
||||||
shift /1
|
shift /1
|
||||||
goto parse_args
|
goto parse_args
|
||||||
|
|
@ -358,9 +358,9 @@ exit /b 0
|
||||||
echo Usage:
|
echo Usage:
|
||||||
echo scripts\vendor_playbook.bat ^<project-root^> ^(default: tsl^)
|
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^> tsl cpp
|
||||||
echo scripts\vendor_playbook.bat ^<project-root^> --langs tsl,cpp
|
echo scripts\vendor_playbook.bat ^<project-root^> -langs tsl,cpp
|
||||||
echo scripts\vendor_playbook.bat ^<project-root^> tsl cpp --apply-templates
|
echo scripts\vendor_playbook.bat ^<project-root^> tsl cpp -apply-templates
|
||||||
echo.
|
echo.
|
||||||
echo Options:
|
echo Options:
|
||||||
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
|
exit /b 1
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,11 @@
|
||||||
|
|
||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $false)]
|
||||||
|
[Alias('h', 'help', '?')]
|
||||||
|
[switch]$Help,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
[string]$DestRoot,
|
[string]$DestRoot,
|
||||||
|
|
||||||
[Parameter(Mandatory = $false)]
|
[Parameter(Mandatory = $false)]
|
||||||
|
|
@ -29,6 +33,24 @@ param(
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
if ($Help) {
|
||||||
|
Write-Host "Usage:"
|
||||||
|
Write-Host " powershell -File scripts/vendor_playbook.ps1 -DestRoot <project-root>"
|
||||||
|
Write-Host " powershell -File scripts/vendor_playbook.ps1 -DestRoot <project-root> -Langs tsl,cpp"
|
||||||
|
Write-Host " powershell -File scripts/vendor_playbook.ps1 -DestRoot <project-root> -Langs @('tsl','cpp') -ApplyTemplates"
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Options:"
|
||||||
|
Write-Host " -DestRoot Target project root."
|
||||||
|
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 $DestRoot) {
|
||||||
|
throw "DestRoot is required. Use -Help for usage."
|
||||||
|
}
|
||||||
|
|
||||||
function Normalize-Langs([string[]]$InputLangs) {
|
function Normalize-Langs([string[]]$InputLangs) {
|
||||||
if (-not $InputLangs -or $InputLangs.Count -eq 0) { return @("tsl") }
|
if (-not $InputLangs -or $InputLangs.Count -eq 0) { return @("tsl") }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,17 +8,17 @@ set -eu
|
||||||
# Usage:
|
# Usage:
|
||||||
# sh scripts/vendor_playbook.sh <project-root> # default: tsl
|
# 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> tsl cpp
|
||||||
# sh scripts/vendor_playbook.sh <project-root> --langs tsl,cpp
|
# sh scripts/vendor_playbook.sh <project-root> -langs tsl,cpp
|
||||||
# sh scripts/vendor_playbook.sh <project-root> tsl cpp --apply-templates
|
# sh scripts/vendor_playbook.sh <project-root> tsl cpp -apply-templates
|
||||||
#
|
#
|
||||||
# Options:
|
# Options:
|
||||||
# --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:
|
# Notes:
|
||||||
# - Snapshot is written to: <project-root>/docs/standards/playbook/
|
# - Snapshot is written to: <project-root>/docs/standards/playbook/
|
||||||
# - Existing snapshot is backed up before overwrite.
|
# - Existing snapshot is backed up before overwrite.
|
||||||
# - Ruleset templates from rulesets/ will be copied to snapshot for sync_standards use.
|
# - 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)"
|
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
|
||||||
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
|
SRC="$(CDPATH= cd -- "$SCRIPT_DIR/.." && pwd -P)"
|
||||||
|
|
@ -28,12 +28,12 @@ usage() {
|
||||||
Usage:
|
Usage:
|
||||||
sh scripts/vendor_playbook.sh <project-root> # default: tsl
|
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> tsl cpp
|
||||||
sh scripts/vendor_playbook.sh <project-root> --langs tsl,cpp
|
sh scripts/vendor_playbook.sh <project-root> -langs tsl,cpp
|
||||||
sh scripts/vendor_playbook.sh <project-root> tsl cpp --apply-templates
|
sh scripts/vendor_playbook.sh <project-root> tsl cpp -apply-templates
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--apply-templates Apply CI/lang templates to project root (skip if exists)
|
-apply-templates Apply CI/lang templates to project root (skip if exists)
|
||||||
-h, --help Show this help
|
-h, -help Show this help
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@ if [ "$#" -lt 1 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
|
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "-help" ]; then
|
||||||
usage
|
usage
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
@ -56,11 +56,11 @@ APPLY_TEMPLATES=0
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
while [ $# -gt 0 ]; do
|
while [ $# -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--langs)
|
-langs)
|
||||||
langs="${2:-}"
|
langs="${2:-}"
|
||||||
shift 2 || true
|
shift 2 || true
|
||||||
;;
|
;;
|
||||||
--apply-templates)
|
-apply-templates)
|
||||||
APPLY_TEMPLATES=1
|
APPLY_TEMPLATES=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ templates/
|
||||||
sh scripts/sync_templates.sh /path/to/project
|
sh scripts/sync_templates.sh /path/to/project
|
||||||
|
|
||||||
# 追加完整框架到已有 AGENTS.md
|
# 追加完整框架到已有 AGENTS.md
|
||||||
sh scripts/sync_templates.sh --full /path/to/project
|
sh scripts/sync_templates.sh -full /path/to/project
|
||||||
```
|
```
|
||||||
|
|
||||||
**Windows PowerShell**:
|
**Windows PowerShell**:
|
||||||
|
|
@ -64,7 +64,7 @@ sh scripts/sync_templates.sh --full /path/to/project
|
||||||
|
|
||||||
```cmd
|
```cmd
|
||||||
scripts\sync_templates.bat C:\path\to\project
|
scripts\sync_templates.bat C:\path\to\project
|
||||||
scripts\sync_templates.bat --full C:\path\to\project
|
scripts\sync_templates.bat -full C:\path\to\project
|
||||||
```
|
```
|
||||||
|
|
||||||
### 部署行为
|
### 部署行为
|
||||||
|
|
@ -72,8 +72,8 @@ scripts\sync_templates.bat --full C:\path\to\project
|
||||||
- **新项目**:创建完整的 AGENTS.md、AGENT_RULES.md、memory-bank/、docs/prompts/
|
- **新项目**:创建完整的 AGENTS.md、AGENT_RULES.md、memory-bank/、docs/prompts/
|
||||||
- **已有 AGENTS.md**:
|
- **已有 AGENTS.md**:
|
||||||
- 默认:追加路由链接(`<!-- playbook:templates:start/end -->`)
|
- 默认:追加路由链接(`<!-- playbook:templates:start/end -->`)
|
||||||
- `--full`:追加完整框架(规则优先级 + 路由 + 新会话开始时)
|
- `-full`:追加完整框架(规则优先级 + 路由 + 新会话开始时)
|
||||||
- **其他文件**:如果已存在则跳过(使用 `--force` 覆盖)
|
- **其他文件**:如果已存在则跳过(使用 `-force` 覆盖)
|
||||||
- **自动创建**:TODO.md 和 CONFIRM.md(如果不存在)
|
- **自动创建**:TODO.md 和 CONFIRM.md(如果不存在)
|
||||||
- **占位符替换**:自动替换 `{{DATE}}` 为当前日期
|
- **占位符替换**:自动替换 `{{DATE}}` 为当前日期
|
||||||
|
|
||||||
|
|
@ -157,11 +157,11 @@ project/
|
||||||
| --------------------------------------- | ----------------------- | -------------- |
|
| --------------------------------------- | ----------------------- | -------------- |
|
||||||
| `<!-- playbook:agents:start/end -->` | 语言规则链接 | sync_standards |
|
| `<!-- playbook:agents:start/end -->` | 语言规则链接 | sync_standards |
|
||||||
| `<!-- playbook:templates:start/end -->` | 路由链接(默认追加) | sync_templates |
|
| `<!-- playbook:templates:start/end -->` | 路由链接(默认追加) | sync_templates |
|
||||||
| `<!-- playbook:framework:start/end -->` | 完整框架(--full 追加) | sync_templates |
|
| `<!-- playbook:framework:start/end -->` | 完整框架(-full 追加) | sync_templates |
|
||||||
|
|
||||||
### ci/、cpp/、python/
|
### ci/、cpp/、python/
|
||||||
|
|
||||||
语言和 CI 配置模板。通过 `vendor_playbook --apply-templates` 部署:
|
语言和 CI 配置模板。通过 `vendor_playbook -apply-templates` 部署:
|
||||||
|
|
||||||
| 目录 | 内容 | 部署位置 |
|
| 目录 | 内容 | 部署位置 |
|
||||||
| ----------- | ----------------------------------------- | ---------- |
|
| ----------- | ----------------------------------------- | ---------- |
|
||||||
|
|
@ -173,7 +173,7 @@ project/
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# vendor_playbook 时一并部署
|
# vendor_playbook 时一并部署
|
||||||
sh scripts/vendor_playbook.sh /path/to/project tsl cpp --apply-templates
|
sh scripts/vendor_playbook.sh /path/to/project tsl cpp -apply-templates
|
||||||
```
|
```
|
||||||
|
|
||||||
## 与 playbook 其他部分的关系
|
## 与 playbook 其他部分的关系
|
||||||
|
|
|
||||||
|
|
@ -102,10 +102,10 @@ sh check_doc_links.sh
|
||||||
- **占位符替换**:
|
- **占位符替换**:
|
||||||
- `{{PROJECT_NAME}}` 与 `{{DATE}}`
|
- `{{PROJECT_NAME}}` 与 `{{DATE}}`
|
||||||
- **目录覆盖策略**:
|
- **目录覆盖策略**:
|
||||||
- 无 `--force` 时不覆盖已有目录
|
- 无 `-force` 时不覆盖已有目录
|
||||||
- `--force` 时覆盖并备份
|
- `-force` 时覆盖并备份
|
||||||
- **AGENTS.md 更新**:
|
- **AGENTS.md 更新**:
|
||||||
- `--full` 更新 framework 区块
|
- `-full` 更新 framework 区块
|
||||||
|
|
||||||
#### test_vendor_playbook.bats
|
#### test_vendor_playbook.bats
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ teardown() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "sync_templates.sh - 基础同步与占位符替换" {
|
@test "sync_templates.sh - 基础同步与占位符替换" {
|
||||||
sh "$SCRIPT_PATH" --project-name "DemoProject" --date "2026-02-03" "$TARGET_DIR"
|
sh "$SCRIPT_PATH" -project-name "DemoProject" -date "2026-02-03" "$TARGET_DIR"
|
||||||
|
|
||||||
[ -d "$TARGET_DIR/memory-bank" ]
|
[ -d "$TARGET_DIR/memory-bank" ]
|
||||||
[ -f "$TARGET_DIR/memory-bank/project-brief.md" ]
|
[ -f "$TARGET_DIR/memory-bank/project-brief.md" ]
|
||||||
|
|
@ -39,7 +39,7 @@ teardown() {
|
||||||
[ -z "$(find "$TARGET_DIR" -name '*.template.md' -print -quit)" ]
|
[ -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/memory-bank"
|
||||||
mkdir -p "$TARGET_DIR/docs/prompts"
|
mkdir -p "$TARGET_DIR/docs/prompts"
|
||||||
echo "keep" > "$TARGET_DIR/memory-bank/keep.md"
|
echo "keep" > "$TARGET_DIR/memory-bank/keep.md"
|
||||||
|
|
@ -53,11 +53,11 @@ teardown() {
|
||||||
[ ! -f "$TARGET_DIR/docs/prompts/README.md" ]
|
[ ! -f "$TARGET_DIR/docs/prompts/README.md" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "sync_templates.sh - --force 覆盖并备份" {
|
@test "sync_templates.sh - -force 覆盖并备份" {
|
||||||
mkdir -p "$TARGET_DIR/memory-bank"
|
mkdir -p "$TARGET_DIR/memory-bank"
|
||||||
echo "marker" > "$TARGET_DIR/memory-bank/marker.txt"
|
echo "marker" > "$TARGET_DIR/memory-bank/marker.txt"
|
||||||
|
|
||||||
sh "$SCRIPT_PATH" --force "$TARGET_DIR"
|
sh "$SCRIPT_PATH" -force "$TARGET_DIR"
|
||||||
|
|
||||||
[ -f "$TARGET_DIR/memory-bank/project-brief.md" ]
|
[ -f "$TARGET_DIR/memory-bank/project-brief.md" ]
|
||||||
[ ! -f "$TARGET_DIR/memory-bank/marker.txt" ]
|
[ ! -f "$TARGET_DIR/memory-bank/marker.txt" ]
|
||||||
|
|
@ -67,7 +67,7 @@ teardown() {
|
||||||
[ -f "$backup_dir/marker.txt" ]
|
[ -f "$backup_dir/marker.txt" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "sync_templates.sh - --full 更新 framework 区块" {
|
@test "sync_templates.sh - -full 更新 framework 区块" {
|
||||||
cat > "$TARGET_DIR/AGENTS.md" << 'EOF'
|
cat > "$TARGET_DIR/AGENTS.md" << 'EOF'
|
||||||
# Agent Instructions
|
# Agent Instructions
|
||||||
|
|
||||||
|
|
@ -78,7 +78,7 @@ OLD_FRAMEWORK
|
||||||
Footer
|
Footer
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
sh "$SCRIPT_PATH" --full "$TARGET_DIR"
|
sh "$SCRIPT_PATH" -full "$TARGET_DIR"
|
||||||
|
|
||||||
! grep -q "OLD_FRAMEWORK" "$TARGET_DIR/AGENTS.md"
|
! grep -q "OLD_FRAMEWORK" "$TARGET_DIR/AGENTS.md"
|
||||||
grep -q "<!-- playbook:framework:start -->" "$TARGET_DIR/AGENTS.md"
|
grep -q "<!-- playbook:framework:start -->" "$TARGET_DIR/AGENTS.md"
|
||||||
|
|
|
||||||
|
|
@ -176,10 +176,10 @@ teardown() {
|
||||||
[ -d "docs/standards/playbook/templates/ci" ]
|
[ -d "docs/standards/playbook/templates/ci" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "vendor_playbook.sh - --apply-templates 应用模板到项目根目录" {
|
@test "vendor_playbook.sh - -apply-templates 应用模板到项目根目录" {
|
||||||
cd "$TARGET_DIR"
|
cd "$TARGET_DIR"
|
||||||
|
|
||||||
sh "$SCRIPT_PATH" "$TARGET_DIR" cpp --apply-templates
|
sh "$SCRIPT_PATH" "$TARGET_DIR" cpp -apply-templates
|
||||||
|
|
||||||
if [ -f "$PLAYBOOK_ROOT/templates/cpp/.clang-format" ]; then
|
if [ -f "$PLAYBOOK_ROOT/templates/cpp/.clang-format" ]; then
|
||||||
[ -f ".clang-format" ]
|
[ -f ".clang-format" ]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue