gsd-reapply-patches
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese<purpose>
After a GSD update wipes and reinstalls files, this command merges user's previously saved local modifications back into the new version. Uses intelligent comparison to handle cases where the upstream file also changed.
</purpose>
<process>
<purpose>
GSD更新会清空并重新安装文件,本命令可将用户之前保存的本地修改合并到新版本中。通过智能比较处理上游文件也发生变更的情况。
</purpose>
<process>
Step 1: Detect backed-up patches
Step 1: 检测备份补丁
Check for local patches directory:
bash
undefined检查本地补丁目录:
bash
undefinedGlobal install (path templated at install time)
Global install (path templated at install time)
PATCHES_DIR={{PLATFORM_ROOT}}/gsd-local-patches
PATCHES_DIR={{PLATFORM_ROOT}}/gsd-local-patches
Local install fallback
Local install fallback
if [ ! -d "$PATCHES_DIR" ]; then
PATCHES_DIR={{PLATFORM_ROOT}}/gsd-local-patches
fi
Read `backup-meta.json` from the patches directory.
**If no patches found:**No local patches found. Nothing to reapply.
Local patches are automatically saved when you run {{COMMAND_PREFIX}}update
after modifying any GSD workflow, command, or agent files.
Exit.if [ ! -d "$PATCHES_DIR" ]; then
PATCHES_DIR={{PLATFORM_ROOT}}/gsd-local-patches
fi
从补丁目录读取`backup-meta.json`文件。
**未找到补丁时:**未找到本地补丁。无需重新应用。
当您修改任何GSD工作流、命令或Agent文件后运行{{COMMAND_PREFIX}}update时,本地补丁会自动保存。
退出。Step 2: Show patch summary
Step 2: 显示补丁摘要
undefinedundefinedLocal Patches to Reapply
待重新应用的本地补丁
Backed up from: v{from_version}
Current version: {read VERSION file}
Files modified: {count}
| # | File | Status |
|---|---|---|
| 1 | {file_path} | Pending |
| 2 | {file_path} | Pending |
undefined备份来源版本: v{from_version}
当前版本: {读取VERSION文件}
已修改文件数: {count}
| 序号 | 文件 | 状态 |
|---|---|---|
| 1 | {file_path} | 待处理 |
| 2 | {file_path} | 待处理 |
undefinedStep 3: Merge each file
Step 3: 合并每个文件
For each file in :
backup-meta.json-
Read the backed-up version (user's modified copy from)
gsd-local-patches/ -
Read the newly installed version (current file after update)
-
Compare and merge:
- If the new file is identical to the backed-up file: skip (modification was incorporated upstream)
- If the new file differs: identify the user's modifications and apply them to the new version
Merge strategy:- Read both versions fully
- Identify sections the user added or modified (look for additions, not just differences from path replacement)
- Apply user's additions/modifications to the new version
- If a section the user modified was also changed upstream: flag as conflict, show both versions, ask user which to keep
-
Write merged result to the installed location
-
Report status:
- — user modifications applied cleanly
Merged - — modification already in upstream
Skipped - — user chose resolution
Conflict
对于中的每个文件:
backup-meta.json-
读取备份版本(用户从保存的修改副本)
gsd-local-patches/ -
读取新安装版本(更新后的当前文件)
-
比较并合并:
- 如果新文件与备份版本完全一致:跳过(修改已被上游合并)
- 如果新文件存在差异:识别用户的修改并将其应用到新版本
合并策略:- 完整读取两个版本的内容
- 识别用户添加或修改的部分(查找新增内容,而非仅路径替换产生的差异)
- 将用户的新增/修改内容应用到新版本
- 如果用户修改的部分在侧也发生了变更:标记为冲突,显示两个版本,询问用户保留哪一个
-
写入合并结果到安装位置
-
报告状态:
- — 用户修改已顺利应用
Merged - — 修改已存在于上游版本
Skipped - — 用户已选择解决方式
Conflict
Step 4: Update manifest
Step 4: 更新清单
After reapplying, regenerate the file manifest so future updates correctly detect these as user modifications:
bash
undefined重新应用完成后,重新生成文件清单,以便未来更新时能正确识别这些内容为用户修改:
bash
undefinedThe manifest will be regenerated on next {{COMMAND_PREFIX}}update
The manifest will be regenerated on next {{COMMAND_PREFIX}}update
For now, just note which files were modified
For now, just note which files were modified
undefinedundefinedStep 5: Cleanup option
Step 5: 清理选项
Ask user:
- "Keep patch backups for reference?" → preserve
gsd-local-patches/ - "Clean up patch backups?" → remove directory
gsd-local-patches/
询问用户:
- "保留补丁备份以供参考?" → 保留目录
gsd-local-patches/ - "清理补丁备份?" → 删除目录
gsd-local-patches/
Step 6: Report
Step 6: 生成报告
undefinedundefinedPatches Reapplied
补丁已重新应用
| # | File | Status |
|---|---|---|
| 1 | {file_path} | ✓ Merged |
| 2 | {file_path} | ○ Skipped (already upstream) |
| 3 | {file_path} | ⚠ Conflict resolved |
{count} file(s) updated. Your local modifications are active again.
</process>
<success_criteria>
- [ ] All backed-up patches processed
- [ ] User modifications merged into new version
- [ ] Conflicts resolved with user input
- [ ] Status reported for each file
</success_criteria>| 序号 | 文件 | 状态 |
|---|---|---|
| 1 | {file_path} | ✓ 已合并 |
| 2 | {file_path} | ○ 已跳过(已存在于上游) |
| 3 | {file_path} | ⚠ 冲突已解决 |
共更新{count}个文件。您的本地修改已重新生效。
</process>
<success_criteria>
- [ ] 所有备份补丁已处理完成
- [ ] 用户修改已合并到新版本
- [ ] 冲突已通过用户输入解决
- [ ] 已报告每个文件的状态
</success_criteria>