@@ -152,16 +152,32 @@ def build_update_prompt(args_text: str = "") -> str:
152152 return (
153153 "Update this GenericAgent checkout from the official upstream "
154154 "https://github.com/Lsdefine/GenericAgent .\n "
155- "1. Fetch upstream; identify the current branch and whether there are any local "
156- "commits ahead of upstream.\n "
155+ "1. Run `git fetch upstream` ; identify the current branch and whether there are "
156+ "local commits ahead of upstream.\n "
157157 "2. Show a concise preview: recent upstream commits not yet local "
158158 "(short hash + subject + date) plus a changed-files summary.\n "
159- "3. Apply the update (uncommitted working-tree changes must always be preserved):\n "
160- " - If local commits exist: merge upstream into the current branch, auto-resolving "
161- "conflicts in favor of upstream, and keep the local commits. A merge commit is acceptable here.\n "
162- " - Otherwise: run `git reset --mixed upstream/main` so local `main` aligns exactly "
163- "with upstream/main, automatically resolving conflicts in favor of upstream. Keep the local changes but do not create any new commits.\n "
164- "4. Finish with a short summary: branch HEAD, changed files, conflicts/resolutions.\n "
159+ "3. Align the COMMIT HISTORY to upstream (upstream wins):\n "
160+ " - If local commits exist: `git merge upstream/main` into the current branch, "
161+ "resolving any conflicts in favor of upstream; keep the local commits (a merge commit is fine).\n "
162+ " - Otherwise: `git reset --mixed upstream/main` so the history of local `main` "
163+ "matches upstream/main exactly. Do NOT create any new commit.\n "
164+ "4. IMPORTANT: also reconcile the WORKING TREE; step 3 alone is not enough. "
165+ "`git reset --mixed` and `git merge` only move history and the index. They do not "
166+ "rewrite files that already hold uncommitted local edits, so those stale files keep "
167+ "shadowing upstream's latest. That is why 'HEAD is aligned but the files are still "
168+ "old'. Reconcile per file:\n "
169+ " a. `git diff --name-only upstream/main` lists every tracked file whose working-tree "
170+ "content differs from upstream.\n "
171+ " b. Decide upstream-first per file. A stale leftover, or a local edit that reverts "
172+ "an upstream feature to an older form, takes upstream: back it up, then "
173+ "`git checkout upstream/main -- <file>`. A genuine local enhancement upstream lacks "
174+ "(local config, key-template placeholders, fork-only features) stays, re-applied on "
175+ "top of upstream's latest instead of overwriting it.\n "
176+ " c. Upstream wins; keep local only where it adds value upstream lacks. Never "
177+ "`git add -A`, never blanket whole-branch checkout, never blindly preserve everything.\n "
178+ "5. Do not create any git commit. Back up any file before overwriting it.\n "
179+ "6. Finish with a short summary: branch HEAD, distance vs upstream, per-file outcome "
180+ "(took upstream / kept+adapted local), and where backups went.\n "
165181 "\n "
166182 "#### Say 'Congratulations! 🎉' to the user\n "
167183 "After a successful update, say: \" Congratulations! 🎉 You have successfully "
@@ -175,12 +191,21 @@ def build_update_prompt(args_text: str = "") -> str:
175191 return (
176192 "请你更新当前 GenericAgent 仓库,官方上游为 "
177193 "https://github.com/Lsdefine/GenericAgent 。\n "
178- "1. 先 fetch upstream;识别当前分支,以及是否存在领先 upstream 的本地 commit。\n "
194+ "1. 先 `git fetch upstream` ;识别当前分支,以及是否存在领先 upstream 的本地 commit。\n "
179195 "2. 给出简洁预览:本地尚未包含的 upstream 最近提交(短 hash + 标题 + 日期)及变更文件摘要。\n "
180- "3. 执行更新(工作区未提交的改动始终要保留):\n "
181- " - 若存在本地 commit:将 upstream 合并进当前分支,自动解决冲突且优先上游。\n "
182- " - 否则:执行 `git reset --mixed upstream/main`,使本地 `main` 与 upstream/main 完全对齐,自动解决冲突且优先上游。本地修改保留但不要进行commit。\n "
183- "4. 最后给出简短小结:分支 HEAD、变更文件、冲突/解决方式。\n "
196+ "3. 先对齐【提交历史】到上游(优先上游):\n "
197+ " - 若存在本地 commit:`git merge upstream/main` 合并进当前分支,冲突一律优先上游,保留本地 commit(可产生 merge commit)。\n "
198+ " - 否则:执行 `git reset --mixed upstream/main`,使本地 `main` 的提交历史与 upstream/main 完全对齐。不要创建任何新 commit。\n "
199+ "4. 重要:还须核对【工作区文件】,止步于第 3 步并不够。`git reset --mixed` 与 `git merge` "
200+ "只移动提交历史与索引,不会重写那些已带未提交本地改动的文件,于是这些过时文件继续覆盖在上游"
201+ "最新版之上。这正是“HEAD 已对齐,但文件其实还是旧的”的根因。逐文件核对:\n "
202+ " a. `git diff --name-only upstream/main` 列出工作区内容与上游不一致的全部 tracked 文件。\n "
203+ " b. 每个文件按优先上游判断。过时残留、或把上游特性改回旧版的本地改动,取上游:先备份,再 "
204+ "`git checkout upstream/main -- <file>`。上游没有且仍有效的本地增强(本机配置、密钥模板占位、"
205+ "fork 专属功能)保留,并在上游最新版上重新适配,而非整文件覆盖上游。\n "
206+ " c. 优先上游;本地仅保留上游缺失且有价值的部分。禁止 `git add -A`、禁止整分支 checkout 覆盖、禁止盲目全保留。\n "
207+ "5. 不要进行任何 git commit。覆盖任何文件前先备份。\n "
208+ "6. 最后给出简短小结:分支 HEAD、与上游差距、逐文件处理结果(取上游 / 保留并适配本地)、备份位置。\n "
184209 "\n "
185210 "#### 向用户说 'Congratulations! 🎉'\n "
186211 "更新成功后,请对用户说:\" Congratulations! 🎉 你已成功更新 GenericAgent!\" \n "
0 commit comments