7.3 KiB
| name | description |
|---|---|
| batch-git-ops | 三仓 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_directoryset 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:
- Run
git status --porcelainon each repo in parallel - If any repo has uncommitted changes, warn the user and ask whether to continue (stash / skip / abort)
- Run
git pullon each repo - 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: <branch-name> (required), <base-branch> (optional, default: current branch)
Workflow:
- Check uncommitted changes in each repo (same as batch-pull step 1-2)
- For each repo, check if branch already exists:
git branch --list <branch-name> git branch -r --list "origin/<branch-name>" - If branch exists in some repos, ask user: switch to existing / skip / abort
- If base-branch specified, run
git checkout <base-branch>thengit pullfirst - Create and switch:
git checkout -b <branch-name> - Report results per repo
4. batch-checkout
Switch all repos to a specified branch.
Parameters: <branch-name> (required)
Workflow:
- Check uncommitted changes (same as above)
- For each repo, verify branch exists:
git branch -a - If a repo does NOT have the target branch:
- List all branches from
git branch -aoutput - Search for similar names using substring/prefix matching (e.g., user typed
featrue/x, actual isfeature/x) - Present similar branch names to the user
- Skip this repo but continue switching others
- List all branches from
- For repos where branch exists:
- If branch is remote-only (
remotes/origin/<name>but no local), rungit checkout -b <branch-name> origin/<branch-name> - If branch is local, run
git checkout <branch-name>
- If branch is remote-only (
- Report results:
| Repo | Result | Current Branch |
Fuzzy matching logic (applied when exact branch not found):
- Extract clean branch names from
git branch -aoutput (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: <commit-message> (optional — if not provided, AI must auto-generate)
Commit Message Rules:
AI 必须自动检索所有仓库的变更内容(git diff、git status),分析修改涉及的模块和意图,自动生成合适的 commit message。用户也可以手动指定 message 来覆盖。
格式规范:
- 人工编码修改(用户自己写的代码,AI 只是帮忙提交):
【所属模块】描述内容 - AI 编码修改(AI 在本次会话中编写/修改的代码):
【AI编码】【所属模块】描述内容
模块名称根据变更文件的路径和内容自动判断,例如:
Buff/目录下的文件 → 模块为BuffCharacter/State/目录下 → 模块为角色状态UI/目录下 → 模块为UI- 配置表相关 → 模块为
配置表 - 多个模块同时修改时,列出主要模块,如
【Buff/角色状态】
示例:
【Buff】将普攻计数时机从攻击前移到攻击后【AI编码】【UI】新增背包界面道具排序功能【AI编码】【Buff/角色】修复buff叠加时属性未正确刷新的问题
Workflow:
- For each repo in parallel, run:
git status --porcelain git diff --stat git diff - Analyze changes to determine affected modules and generate commit message
- 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
- Ask user to confirm (user may modify the message)
- For each repo with changes:
git add . git commit -m "<commit-message>" - Ask if user wants to push as well (see batch-push)
- Report results:
| Repo | Files Changed | Committed | Pushed |
6. batch-push
Push current branches for all repos.
Workflow:
- For each repo, check if remote tracking branch exists:
git rev-parse --abbrev-ref --symbolic-full-name @{u} - If no upstream, use:
git push -u origin HEAD - If upstream exists, use:
git push - 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: rungit stash push -m "batch-stash"on each repo (skip if clean)pop: rungit stash popon 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 文件变更时:
- 提交前自动触发
compile-gameplay-dll技能的编译流程 - 编译成功后 NLDClient 也会有变更(更新的 DLL 文件),一并纳入提交
- 编译失败 → 中止所有仓库的提交并报告错误
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 |