diff --git a/ProjectNLD/.ai/agents/code-reviewer.md b/ProjectNLD/.ai/agents/code-reviewer.md index 9efc8dffb29..49b41bd4c84 100644 --- a/ProjectNLD/.ai/agents/code-reviewer.md +++ b/ProjectNLD/.ai/agents/code-reviewer.md @@ -1,6 +1,8 @@ --- name: code-reviewer description: NLD 项目代码审查专用 Agent,专注 C# 代码质量、性能、架构审查 +version: "1.0" +updated: "2026-05-08" --- # Code Reviewer Agent @@ -18,7 +20,7 @@ description: NLD 项目代码审查专用 Agent,专注 C# 代码质量、性 | 严重度 | 判断标准 | |--------|----------| -| **高** | 会导致崩溃/卡死/数据丢失,或在每帧热路径产生 GC,或内存泄漏 | +| **高** | 会导致崩溃/卡死/数据丢失;或在每帧热路径产生 GC;或在 Update/LateUpdate 中调用 `GameObject.Find`、`GetComponent`、`FindObjectOfType` 等全局搜索 API;或内存泄漏 | | **中** | 影响性能但不致崩溃,或违反架构分层,或缺少空引用保护 | | **低** | 命名不规范、缺少缓存但不在热路径、代码风格问题 | diff --git a/ProjectNLD/.ai/agents/default.md b/ProjectNLD/.ai/agents/default.md index de3c8fcce90..1b283563356 100644 --- a/ProjectNLD/.ai/agents/default.md +++ b/ProjectNLD/.ai/agents/default.md @@ -1,12 +1,14 @@ --- name: default description: NLD 项目默认 AI 编码助手 — GamePlay 模块开发专家,擅长 Unity C# 游戏逻辑、Buff/战斗/技能/角色系统开发 +version: "1.0" +updated: "2026-05-08" --- # Default Agent — GamePlay Developer ## 角色 -你是 NLD 游戏项目的 GamePlay 开发专家,专注于 `Assets/Code/Scripts/GamePlay/` 下 75+ 功能模块的日常开发。 +你是 NLD 游戏项目的 GamePlay 开发专家,专注于 `Assets/Code/Scripts/GamePlay/` 下 75+ 功能模块(常用核心模块见下方索引,完整列表可通过 `list_dir` 查看 `GamePlay/` 目录)的日常开发。 ## 核心决策原则 diff --git a/ProjectNLD/.ai/agents/ui-developer.md b/ProjectNLD/.ai/agents/ui-developer.md index f93bda1bfae..7626e35e39a 100644 --- a/ProjectNLD/.ai/agents/ui-developer.md +++ b/ProjectNLD/.ai/agents/ui-developer.md @@ -1,6 +1,8 @@ --- name: ui-developer description: NLD 项目 UI 开发专用 Agent,专注 Unity UGUI Prefab 开发和 UI 控制器代码 +version: "1.0" +updated: "2026-05-08" --- # UI Developer Agent @@ -13,10 +15,14 @@ description: NLD 项目 UI 开发专用 Agent,专注 Unity UGUI Prefab 开发 ## 设计决策原则 ### 何时使用 AutoGen -- Prefab 中有 **5+ 个需要代码引用的组件** → 用 AutoGen 自动绑定 -- 只有 1-2 个简单引用 → 手动绑定即可 +- 组件层级深(3+ 层嵌套)或引用数量多(5+ 个代码引用)→ 优先用 AutoGen 自动绑定 +- 少量简单引用(1-2 个顶层组件)→ 手动绑定即可 - AutoGen 文件命名: `UI_XXXController.AutoGen.cs`(不可手动修改) +### 何时不用 AutoGen +- 组件需要运行时条件绑定(根据状态决定绑定哪个)→ 手动绑定 +- 动态生成/销毁的 UI 元素 → 必须在代码中动态查找或缓存 + ### 何时使用对象池 - 列表项数量 > 10 或会频繁刷新 → 必须用对象池 - 固定数量的静态 UI 元素 → 直接放在 Prefab 中 diff --git a/ProjectNLD/.ai/hooks/post-file-create.md b/ProjectNLD/.ai/hooks/post-file-create.md index 54e53409418..4baea1f8b96 100644 --- a/ProjectNLD/.ai/hooks/post-file-create.md +++ b/ProjectNLD/.ai/hooks/post-file-create.md @@ -4,6 +4,8 @@ condition: "new file created in Assets/" action: remind protocol: ../protocols/no-meta-files.md description: 提醒不要生成 Unity .meta 文件 +version: "1.0" +updated: "2026-05-08" --- > 完整规则定义见 [../protocols/no-meta-files.md](../protocols/no-meta-files.md) diff --git a/ProjectNLD/.ai/hooks/pre-code-change.md b/ProjectNLD/.ai/hooks/pre-code-change.md index ad15d7ad74f..5f1d421bbf4 100644 --- a/ProjectNLD/.ai/hooks/pre-code-change.md +++ b/ProjectNLD/.ai/hooks/pre-code-change.md @@ -4,6 +4,8 @@ condition: "large code modification (>50 lines or >3 files)" action: confirm_with_user protocol: ../protocols/confirm-before-act.md description: 大量代码修改前先与用户确认设计思路 +version: "1.0" +updated: "2026-05-08" --- > 完整规则定义见 [../protocols/confirm-before-act.md](../protocols/confirm-before-act.md) diff --git a/ProjectNLD/.ai/hooks/pre-commit.md b/ProjectNLD/.ai/hooks/pre-commit.md index a15742fc666..f6cebc632e8 100644 --- a/ProjectNLD/.ai/hooks/pre-commit.md +++ b/ProjectNLD/.ai/hooks/pre-commit.md @@ -5,6 +5,8 @@ action: run_skill skill: batch-git-ops protocol: ../protocols/git-safety.md description: Git 提交前确保三仓同步,遵循 batch-git-ops 技能流程 +version: "1.0" +updated: "2026-05-08" --- > 完整规则定义见 [../protocols/git-safety.md](../protocols/git-safety.md) diff --git a/ProjectNLD/.ai/protocols/confirm-before-act.md b/ProjectNLD/.ai/protocols/confirm-before-act.md index 61a49884847..7f3d087a4c4 100644 --- a/ProjectNLD/.ai/protocols/confirm-before-act.md +++ b/ProjectNLD/.ai/protocols/confirm-before-act.md @@ -1,6 +1,8 @@ --- scope: always description: 确认再行动协议 — 大量修改前必须与用户确认设计思路 +version: "1.0" +updated: "2026-05-08" --- # 确认再行动 diff --git a/ProjectNLD/.ai/protocols/git-safety.md b/ProjectNLD/.ai/protocols/git-safety.md index fef0c211d7f..68589bf3dee 100644 --- a/ProjectNLD/.ai/protocols/git-safety.md +++ b/ProjectNLD/.ai/protocols/git-safety.md @@ -1,6 +1,8 @@ --- scope: always description: Git 操作安全协议 — 不做未经确认的 git 操作,三仓同步 +version: "1.0" +updated: "2026-05-08" --- # Git 操作安全协议 diff --git a/ProjectNLD/.ai/protocols/no-meta-files.md b/ProjectNLD/.ai/protocols/no-meta-files.md index 3fecb6fda7d..21dacd3d369 100644 --- a/ProjectNLD/.ai/protocols/no-meta-files.md +++ b/ProjectNLD/.ai/protocols/no-meta-files.md @@ -1,6 +1,8 @@ --- scope: always description: 不生成 Unity meta 文件,不主动编译项目 +version: "1.0" +updated: "2026-05-08" --- # Unity 项目约定 diff --git a/ProjectNLD/.ai/skills/batch-git-ops/SKILL.md b/ProjectNLD/.ai/skills/batch-git-ops/SKILL.md index e227f528e74..c6a95860718 100644 --- a/ProjectNLD/.ai/skills/batch-git-ops/SKILL.md +++ b/ProjectNLD/.ai/skills/batch-git-ops/SKILL.md @@ -1,6 +1,8 @@ --- name: batch-git-ops description: 三仓 Git 操作(NLDClient/NLDMisc/GamePlay)。触发关键词:git pull push commit checkout branch status stash fetch log、三仓同步、batch git。 +version: "1.0" +updated: "2026-05-08" --- # Batch Git Operations @@ -25,8 +27,15 @@ All paths are relative to the workspace root (`ProjectNLD`). Use forward slashes - Never use `\` in paths; always use `/` - Always remind the user that git operations carry risk before proceeding +## 不适用场景 + +- 只修改了单个仓库的单个文件且无需同步其他仓库 → 不需要走三仓流程 +- AI 未经用户要求主动做 git 操作 → 遵循 git-safety 协议,不主动操作 + ## Operations +### 核心操作(高频) + ### 1. batch-status Show current state of all repos. @@ -168,36 +177,12 @@ Push current branches for all repos. 3. If upstream exists, use: `git push` 4. Report results per repo -### 7. batch-fetch +### 7. batch-fetch / batch-stash / batch-log(低频) -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 -``` +简洁操作,不再展开详细流程: +- **batch-fetch**: 每个仓库执行 `git fetch --all --prune`,报告更新情况 +- **batch-stash ``**: save 时 `git stash push -m "batch-stash"`;pop 时 `git stash pop`;跳过无变更仓库 +- **batch-log**: 每个仓库执行 `git log --oneline -5`,汇总展示 Present as grouped output per repo. diff --git a/ProjectNLD/.ai/skills/compile-gameplay-dll/SKILL.md b/ProjectNLD/.ai/skills/compile-gameplay-dll/SKILL.md index e66df0f3132..e93febc79b7 100644 --- a/ProjectNLD/.ai/skills/compile-gameplay-dll/SKILL.md +++ b/ProjectNLD/.ai/skills/compile-gameplay-dll/SKILL.md @@ -1,6 +1,8 @@ --- name: compile-gameplay-dll description: 编译 GamePlay C# 源码为 GamePlay.dll。触发关键词:编译 compile、GamePlay.dll、转换为Dll、build DLL、编译错误、Assembly Definition asmdef。 +version: "1.0" +updated: "2026-05-08" --- # Compile GamePlay DLL @@ -14,12 +16,19 @@ description: 编译 GamePlay C# 源码为 GamePlay.dll。触发关键词:编 - **编译菜单**: `Tools/文件与路径/转换为Dll`(快捷键 F1) - **Assembly Definition**: `Assets/Code/Scripts/GamePlay/GamePlay.asmdef` +## 不适用场景 + +- 只修改了 `GamePlay/` 以外的代码(Framework/GameWrapper/UI/ 等)→ 不需要编译 DLL +- 只修改了配置表 → 走 `luban-config` 流程即可 + ## 编译流程 根据是否有 Unity MCP 可用,选择对应路径: ### 路径 A:通过 Unity MCP 自动编译(优先) +> **前置检测**:首先确认 Unity MCP (`user-unityMCP`) 是否可用。可用则走此路径,不可用则自动降级到路径 B。 + **前置步骤** — 确保代码最新: 1. `git pull` NLDClient 仓库(`../../`) 2. `git pull` GamePlay 仓库(`Assets/Code/Scripts/GamePlay`) diff --git a/ProjectNLD/.ai/skills/knowledge-base/SKILL.md b/ProjectNLD/.ai/skills/knowledge-base/SKILL.md index 42fce26c813..c5c44502701 100644 --- a/ProjectNLD/.ai/skills/knowledge-base/SKILL.md +++ b/ProjectNLD/.ai/skills/knowledge-base/SKILL.md @@ -1,6 +1,8 @@ --- name: knowledge-base description: 项目知识库索引。查阅功能说明、性能优化记录、开发日志时使用。触发关键词:武器熟练度 WeaponDegree、ShowAreaId 显示区域、攻击换弹 canAttackNoReloadFull、暂停技能释放、载具科技树、PerformanceManager 性能参数 性能优化、GC 分配 内存优化 Buff性能、密钥泄露 secret exposure、资源检查 FileChecker batch runner。涵盖 AI_Gen_Doc 和 AI_CODE 中的所有文档。 +version: "1.0" +updated: "2026-05-08" --- # 项目知识库 @@ -83,6 +85,7 @@ description: 项目知识库索引。查阅功能说明、性能优化记录、 ## 安全规则 +- 查询前先用 `file_search` 确认目标文档是否存在,若不存在则搜索相似文件名并告知用户 - 只读查阅,不要修改已归档的文档(除非用户要求更新) - 性能优化任务执行前必须评估风险(跨类修改、生命周期影响等) - 有风险的任务标记为跳过,等用户确认后再执行 diff --git a/ProjectNLD/.ai/skills/luban-config/SKILL.md b/ProjectNLD/.ai/skills/luban-config/SKILL.md index a3f55931faf..2dfeae96f04 100644 --- a/ProjectNLD/.ai/skills/luban-config/SKILL.md +++ b/ProjectNLD/.ai/skills/luban-config/SKILL.md @@ -1,6 +1,8 @@ --- name: luban-config description: Luban 配置表操作:生成代码、修改配置、校验数据。涉及配置表(Excel/XML)和 Luban 工具链的操作。触发关键词:配置表 config table、Luban 导出 export、Excel 数据、Root.xml、GenCode、LubanExportConfig、数值配置、新增配置表、配置校验。 +version: "1.0" +updated: "2026-05-08" --- # Luban 配置表操作 @@ -35,6 +37,11 @@ Assets/PhxhSDK/Editor/Settings/Luban_Client_EN.asset # 客户端英文 Assets/PhxhSDK/Editor/Settings/Luban_Server.asset # 服务端 ``` +## 不适用场景 + +- 只修改了游戏逻辑代码(不涉及配置表)→ 不需要走 Luban 流程 +- 只查配置表字段结构 → 直接看 `Assets/Code/Scripts/GenCode/Luban/` 中的生成代码即可 + ## 工作流 ### 1. 修改配置表 diff --git a/ProjectNLD/.ai/skills/ui-prefab-dev/SKILL.md b/ProjectNLD/.ai/skills/ui-prefab-dev/SKILL.md index 3b3d4780061..dcb70ad750d 100644 --- a/ProjectNLD/.ai/skills/ui-prefab-dev/SKILL.md +++ b/ProjectNLD/.ai/skills/ui-prefab-dev/SKILL.md @@ -1,6 +1,8 @@ --- name: ui-prefab-dev description: Unity UI Prefab 开发:结构分析、组件修改、代码生成。涉及 UI Prefab 层级查看、组件属性读取、UI 控制器代码编写。触发关键词:UI界面 UI开发、Prefab 预制体、UIBaseController、AutoGen、UGUI、RectTransform、Image Button Text、ScrollRect 列表、extract_ui_prefab、ExtractedPrefabs、UI控制器。 +version: "1.0" +updated: "2026-05-08" --- # UI Prefab 开发 @@ -34,22 +36,7 @@ execute_custom_tool: { ### 2. 理解 UI 层级结构 -JSON 输出格式: - -``` -UIInfoNode { - name: string // GameObject 名称 - active: boolean // 激活状态 - components: [] // UIInfoComponent 列表 - children: [] // 子节点(递归) -} - -UIInfoComponent { - componentName: string // 组件类型名(RectTransform, Image, Text, Button...) - enable: boolean // 启用状态 - properties: string[] // "Key:Value" 格式属性列表 -} -``` +JSON 格式和属性格式定义见 `ExtractedPrefabs/README.md`。 常见组件类型: - **RectTransform**: 锚点、位置、尺寸 @@ -91,6 +78,11 @@ public class UI_XXXController.AutoGen : ... 3. 如需自动绑定,编写 AutoGen 辅助类 4. 注册到 UI 管理系统中 +## 不适用场景 + +- 纯逻辑 UI 改动(不涉及 Prefab 结构变化)→ 直接改 Controller 代码即可 +- 简单的位置/颜色微调 → 无需走完整提取流程,直接描述修改即可 + ## 属性格式参考 | 类型 | 格式示例 | diff --git a/ProjectNLD/.ai/sync-all.ps1 b/ProjectNLD/.ai/sync-all.ps1 index 85b94231bf1..a5d4f634f2d 100644 --- a/ProjectNLD/.ai/sync-all.ps1 +++ b/ProjectNLD/.ai/sync-all.ps1 @@ -68,9 +68,31 @@ if (Test-Path $AGENTS_SRC) { } } +# ── 4. Sync hooks ────────────────────────────────────────────── +$HOOKS_SRC = ".ai/hooks" +Write-Host "" +Write-Host "=== Syncing hooks from $HOOKS_SRC ===" +$hookCount = 0 + +if (Test-Path $HOOKS_SRC) { + Get-ChildItem "$HOOKS_SRC" -Filter "*.md" | ForEach-Object { + $filename = $_.Name + + foreach ($platform in $PLATFORMS) { + $targetDir = Join-Path $platform "hooks" + New-Item -ItemType Directory -Force -Path $targetDir | Out-Null + Copy-Item $_.FullName (Join-Path $targetDir $filename) -Force + } + + Write-Host " ✓ hook: $filename" + $hookCount++ + } +} + # ── Summary ───────────────────────────────────────────────────── Write-Host "" Write-Host "Done. Synced to $($PLATFORMS.Count) platforms:" Write-Host " Skills: $skillCount" Write-Host " Protocols: $protoCount" Write-Host " Agents: $agentCount" +Write-Host " Hooks: $hookCount" diff --git a/ProjectNLD/.ai/sync-all.sh b/ProjectNLD/.ai/sync-all.sh index cae71d85f32..097579c3e0a 100755 --- a/ProjectNLD/.ai/sync-all.sh +++ b/ProjectNLD/.ai/sync-all.sh @@ -72,9 +72,32 @@ if [ -d "$AGENTS_SRC" ]; then done fi +# ── 4. Sync hooks ────────────────────────────────────────────── +HOOKS_SRC=".ai/hooks" +echo "" +echo "=== Syncing hooks from $HOOKS_SRC ===" +hook_count=0 + +if [ -d "$HOOKS_SRC" ]; then + for hook_file in "$HOOKS_SRC"/*.md; do + [ -f "$hook_file" ] || continue + filename=$(basename "$hook_file") + + for platform in "${PLATFORMS[@]}"; do + target_dir="$platform/hooks" + mkdir -p "$target_dir" + cp "$hook_file" "$target_dir/$filename" + done + + echo " ✓ hook: $filename" + ((hook_count++)) + done +fi + # ── Summary ───────────────────────────────────────────────────── echo "" echo "Done. Synced to ${#PLATFORMS[@]} platforms:" echo " Skills: $skill_count" echo " Protocols: $proto_count" echo " Agents: $agent_count" +echo " Hooks: $hook_count" diff --git a/ProjectNLD/.github/copilot-instructions.md b/ProjectNLD/.github/copilot-instructions.md index 1030bf4e675..efe7b942d60 100644 --- a/ProjectNLD/.github/copilot-instructions.md +++ b/ProjectNLD/.github/copilot-instructions.md @@ -1,24 +1,7 @@ # VS Code Copilot 专属补充 -> 通用编码规范、git 操作规则、项目结构等已在 `AGENTS.md` 中定义,Copilot 会自动读取。 -> 本文件包含 Copilot 独有的补充说明和核心行为约束的嵌入摘要。 - -## 核心行为约束(嵌入自 .ai/protocols/) - -以下规则摘自 `.ai/protocols/`,嵌入此处确保 Copilot 能直接加载: - -- **确认再行动**:除非用户要求特别清晰,开始编码前将计划描述给用户并获得确认(收集信息和编写计划不需要确认) -- **Unity 约定**:不要生成 .meta 文件;不要主动编译项目;可以做静态代码检查 -- **Git 安全**:除非用户要求,不做任何 git 操作;git 操作有风险,须提醒用户;本项目有三个关联仓库(NLDClient / NLDMisc / GamePlay),任何 git 操作须读取 `batch-git-ops` 技能后执行 - -## 技能引用 -- 技能源位于 `.ai/skills/`(同步副本在 `.github/skills/`) -- 协议源位于 `.ai/protocols/`(同步副本在 `.github/protocols/`) -- 新增或更新后运行 `.ai/sync-all.sh` 同步到各平台 +> 通用编码规范、Git 操作规则、项目结构、技能系统等已在 `AGENTS.md` 中完整定义,Copilot 会自动读取。 +> 本文件仅保留 Copilot 需要额外关注的补充说明。核心行为约束以 `.ai/protocols/` 为权威定义。 ## 编辑器开发 - 使用 Odin 工具开发 Unity 编辑器扩展 - -## 编译 -- 不要主动编译项目,Unity 会自动编译 -- 可以做自己的静态代码检查