--- name: batch-git-ops description: 三仓 Git 操作(NLDClient/NLDMisc/GamePlay)。触发关键词:git pull push commit checkout branch status stash fetch log、三仓同步、batch git。 --- # Batch Git Operations Perform git operations across three project repositories simultaneously. ## Repository Definitions All paths are relative to the workspace root (`ProjectNLD`). Use forward slashes only. | Name | Relative Path | Description | |------|--------------|-------------| | NLDClient | `../../` | Main client repo | | NLDMisc | `../../../NLDMisc` | Config/data repo | | GamePlay | `Assets/Code/Scripts/GamePlay` | Core gameplay code repo | ## Cross-Platform Rules - Execute git commands via the Shell tool with `working_directory` set to each repo's **absolute path** (resolve from workspace root + relative path) - Issue one Shell call per repo per command (parallelizable when independent) - Never use `&&` to chain commands (PowerShell incompatible) - Never use `\` in paths; always use `/` - Always remind the user that git operations carry risk before proceeding ## Operations ### 1. batch-status Show current state of all repos. For each repo, run: ``` git status -sb ``` Present results in a summary table: ``` | Repo | Branch | Clean | Ahead/Behind | ``` ### 2. batch-pull Pull latest changes for all repos. **Workflow:** 1. Run `git status --porcelain` on each repo in parallel 2. If any repo has uncommitted changes, warn the user and ask whether to continue (stash / skip / abort) 3. Run `git pull` on each repo 4. Report results: ``` | Repo | Result | Details | ``` Result values: updated / already up-to-date / conflict / error ### 3. batch-create-branch Create a new branch with the same name in all repos and switch to it. **Parameters:** `` (required), `` (optional, default: current branch) **Workflow:** 1. Check uncommitted changes in each repo (same as batch-pull step 1-2) 2. For each repo, check if branch already exists: ``` git branch --list git branch -r --list "origin/" ``` 3. If branch exists in some repos, ask user: switch to existing / skip / abort 4. If base-branch specified, run `git checkout ` then `git pull` first 5. Create and switch: `git checkout -b ` 6. Report results per repo ### 4. batch-checkout Switch all repos to a specified branch. **Parameters:** `` (required) **Workflow:** 1. Check uncommitted changes (same as above) 2. For each repo, verify branch exists: ``` git branch -a ``` 3. If a repo does NOT have the target branch: - List all branches from `git branch -a` output - Search for similar names using substring/prefix matching (e.g., user typed `featrue/x`, actual is `feature/x`) - Present similar branch names to the user - Skip this repo but continue switching others 4. For repos where branch exists: - If branch is remote-only (`remotes/origin/` but no local), run `git checkout -b origin/` - If branch is local, run `git checkout ` 5. Report results: ``` | Repo | Result | Current Branch | ``` **Fuzzy matching logic** (applied when exact branch not found): - Extract clean branch names from `git branch -a` output (strip whitespace, `*`, `remotes/origin/` prefix) - Check for: exact case-insensitive match, substring containment, common typo patterns (transposed chars) - Present top 5 closest matches to user ### 5. batch-commit Commit changes in all repos with the same message. **Parameters:** `` (optional — if not provided, AI must auto-generate) **Commit Message Rules:** AI 必须自动检索所有仓库的变更内容(`git diff`、`git status`),分析修改涉及的模块和意图,自动生成合适的 commit message。用户也可以手动指定 message 来覆盖。 格式规范: - **人工编码修改**(用户自己写的代码,AI 只是帮忙提交):`【所属模块】描述内容` - **AI 编码修改**(AI 在本次会话中编写/修改的代码):`【AI编码】【所属模块】描述内容` 模块名称根据变更文件的路径和内容自动判断,例如: - `Buff/` 目录下的文件 → 模块为 `Buff` - `Character/State/` 目录下 → 模块为 `角色状态` - `UI/` 目录下 → 模块为 `UI` - 配置表相关 → 模块为 `配置表` - 多个模块同时修改时,列出主要模块,如 `【Buff/角色状态】` 示例: - `【Buff】将普攻计数时机从攻击前移到攻击后` - `【AI编码】【UI】新增背包界面道具排序功能` - `【AI编码】【Buff/角色】修复buff叠加时属性未正确刷新的问题` **Workflow:** 1. For each repo in parallel, run: ``` git status --porcelain git diff --stat git diff ``` 2. Analyze changes to determine affected modules and generate commit message 3. Present a summary showing changed files per repo, the auto-generated commit message, and whether it's AI-authored code. If a repo has no changes, note it will be skipped 4. Ask user to confirm (user may modify the message) 5. For each repo with changes: ``` git add . git commit -m "" ``` 6. Ask if user wants to push as well (see batch-push) 7. Report results: ``` | Repo | Files Changed | Committed | Pushed | ``` ### 6. batch-push Push current branches for all repos. **Workflow:** 1. For each repo, check if remote tracking branch exists: ``` git rev-parse --abbrev-ref --symbolic-full-name @{u} ``` 2. If no upstream, use: `git push -u origin HEAD` 3. If upstream exists, use: `git push` 4. Report results per repo ### 7. batch-fetch Fetch remote updates without merging. For each repo, run: ``` git fetch --all --prune ``` Report fetched updates per repo. ### 8. batch-stash Stash or pop changes across all repos. **Parameters:** `save` or `pop` - `save`: run `git stash push -m "batch-stash"` on each repo (skip if clean) - `pop`: run `git stash pop` on each repo (skip if stash is empty) Report results per repo. ### 9. batch-log Show recent commit history across repos. For each repo, run: ``` git log --oneline -5 ``` Present as grouped output per repo. ### 10. compile-gameplay-dll > **详细编译流程见 `compile-gameplay-dll` 技能的 SKILL.md**,此处仅说明与 batch-commit 的集成逻辑。 当 `batch-commit` 检测到 GamePlay 有 `.cs` 文件变更时: 1. **提交前**自动触发 `compile-gameplay-dll` 技能的编译流程 2. 编译成功后 NLDClient 也会有变更(更新的 DLL 文件),一并纳入提交 3. 编译失败 → 中止所有仓库的提交并报告错误 ## Safety Rules - NEVER run `--force`, `--hard`, `reset`, or any destructive git command - NEVER skip user confirmation before commits or branch operations - If any operation fails or produces a conflict, stop and report immediately — do not continue silently - Each repo operates independently: one repo's failure must not block others - Always show a summary report after batch operations complete ## Output Format Always present results in a structured table for quick scanning. Example: ``` ## Batch Operation Results | Repo | Operation | Result | Details | |------|-----------|--------|---------| | NLDClient | pull | updated | 3 files changed | | NLDMisc | pull | up-to-date | — | | GamePlay | pull | updated | 12 files changed | ```