diff --git a/README.md b/README.md index e7d7e77..4763df2 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,8 @@ Playbook:TSL(`.tsl`/`.tsf`)+ C++ + Python 工程规范与代理规则合 sh docs/standards/playbook/scripts/sync_standards.sh tsl cpp ``` + > 说明:若项目根目录没有 `AGENTS.md`,`sync_standards.*` 会自动生成最小版;已存在则不会覆盖。 + 3. 验收(任意满足其一即可): - 目录存在:`.agents/tsl/` @@ -112,6 +114,25 @@ Playbook:TSL(`.tsl`/`.tsf`)+ C++ + Python 工程规范与代理规则合 - `docs/standards/playbook/`(标准快照) - `.agents/tsl/`(落地规则集) - `.gitattributes`(managed block 更新) + - `AGENTS.md`(若本次自动生成) + +#### 新项目 / 旧项目(命令示例) + +新项目(无 `.agents/` 与 `AGENTS.md`): + +```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 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 tsl +``` + +旧项目的 `AGENTS.md` 不会被覆盖;如需指向 `.agents/`,请手动对齐内容。 #### 可选:项目包装脚本(多 playbook 串联) diff --git a/scripts/sync_standards.bat b/scripts/sync_standards.bat index 59491d2..b4d0c6c 100644 --- a/scripts/sync_standards.bat +++ b/scripts/sync_standards.bat @@ -120,6 +120,16 @@ if not exist "%AGENTS_ROOT%\index.md" ( echo Created .agents\index.md ) +if not exist "%ROOT%\AGENTS.md" ( + > "%ROOT%\AGENTS.md" echo # Agent Instructions + >> "%ROOT%\AGENTS.md" echo. + >> "%ROOT%\AGENTS.md" echo 请以 `.agents/` 下的规则为准: + >> "%ROOT%\AGENTS.md" echo. + >> "%ROOT%\AGENTS.md" echo - 入口:`.agents/index.md` + >> "%ROOT%\AGENTS.md" echo - 语言规则:`.agents/tsl/index.md`、`.agents/cpp/index.md`、`.agents/python/index.md` + echo Created AGENTS.md +) + :SyncGitAttr if exist "%GITATTR_SRC%" ( if /I "%SYNC_GITATTR_MODE%"=="skip" ( diff --git a/scripts/sync_standards.ps1 b/scripts/sync_standards.ps1 index 6868da5..716612b 100644 --- a/scripts/sync_standards.ps1 +++ b/scripts/sync_standards.ps1 @@ -121,6 +121,19 @@ if (-not (Test-Path $AgentsIndex)) { Write-Host "Created .agents/index.md" } +$AgentsMd = Join-Path $Root "AGENTS.md" +if (-not (Test-Path $AgentsMd)) { +@' +# Agent Instructions + +请以 `.agents/` 下的规则为准: + +- 入口:`.agents/index.md` +- 语言规则:`.agents/tsl/index.md`、`.agents/cpp/index.md`、`.agents/python/index.md` +'@ | Set-Content -Path $AgentsMd -Encoding UTF8 + Write-Host "Created AGENTS.md" +} + $GitAttrDst = Join-Path $Root ".gitattributes" if (Test-Path $GitAttrSrc) { $mode = $env:SYNC_GITATTR_MODE diff --git a/scripts/sync_standards.sh b/scripts/sync_standards.sh index 9985545..0053404 100644 --- a/scripts/sync_standards.sh +++ b/scripts/sync_standards.sh @@ -125,6 +125,19 @@ EOF echo "Created .agents/index.md" fi +AGENTS_MD="$ROOT/AGENTS.md" +if [ ! -f "$AGENTS_MD" ]; then + cat >"$AGENTS_MD" <<'EOF' +# Agent Instructions + +请以 `.agents/` 下的规则为准: + +- 入口:`.agents/index.md` +- 语言规则:`.agents/tsl/index.md`、`.agents/cpp/index.md`、`.agents/python/index.md` +EOF + echo "Created AGENTS.md" +fi + echo "Synced agents ruleset to $AGENTS_DST." GITATTR_DST="$ROOT/.gitattributes"