agent-Specialization/modules
JOJO 478d24c4dd feat(versioning): 重构版本控制为对话级浅备份 + 可选完全备份
本次变更是对版本控制功能的大范围重构,核心目标:
- 默认使用浅备份(只追踪 write_file/edit_file 实际修改的文件),避免大工作区首次初始化耗时十几秒;
- 保留可选的完全备份(git write-tree),不污染 git log;
- 回溯时统一选择范围(仅对话 / 对话+工作区)和模式(覆盖 / 复制);
- 修复复制对话、侧边栏同步、新建对话延迟、diff 统计与渲染等连锁问题。

后端改动:
- modules/shallow_versioning.py(新增)
  - 实现 ShallowVersioningManager:track_edit、make_snapshot、rewind、list_snapshots。
  - 基于 difflib.SequenceMatcher 计算真实 insertions/deletions,replace 场景正确显示 +N/-M。
  - diff 详情使用结构化 add/remove/context 行,不再解析 unified_diff 文本。
- modules/versioning_manager.py
  - 完全备份从 git commit 改为 git write-tree,字段 commit/parent_commit 改为 tree_hash/parent_tree_hash。
  - 恢复改用 read-tree + checkout-index;create_checkpoint 支持 diff_summary 参数。
  - get_checkpoint_detail 保留 API 字段名 last_commit/restored_commit 以兼容前端。
- core/main_terminal_parts/tools_execution.py
  - write_file/edit_file 在执行前调用浅备份 track_edit,保留编辑前状态。
- server/chat_flow_task_main.py
  - 消息轮次结束时根据 backup_mode 选择完全备份 create_checkpoint 或浅备份 make_snapshot。
  - 浅备份模式下同时写入 ConversationVersioningManager 检查点行,让前端能统一展示。
- server/conversation.py
  - restore/detail/list API 支持 shallow 模式;list/detail 对浅备份实时重新计算统计。
  - 创建对话时读取 personalization 的 versioning_backup_mode,shallow 模式固定 tracking_mode 为 conversation_only。
- core/web_terminal.py
  - _ensure_conversation_versioning_enabled 读取默认备份模式并写入 versioning meta。
- modules/file_manager/crud_mixin.py / replace_mixin.py
  - write_file / edit_file 返回 original_file / new_file / replacement_details(真实旧行/新行)。
- modules/personalization_manager.py
  - 新增 versioning_enabled_by_default、versioning_backup_mode(shallow/full)。
- utils/perf_log.py(新增)
  - 创建新对话全链路性能日志,用于定位延迟瓶颈。
- utils/conversation_manager/{index,list_search,crud}_mixin.py
  - 加性能日志;index_mixin 主动检查新增对话文件,修复侧边栏不同步。

前端改动:
- static/src/components/overlay/VersioningDialog.vue
  - 去掉顶部管理范围下拉;底部新增回溯范围与回溯模式选择。
  - diff 详情改为 div.diff-line 网格布局(marker + content),支持横向滚动,状态显示缩写 A/M/D。
  - 修复 pre 标签空白黑行、容器被挤窄导致折行等问题。
- static/src/app/methods/versioning.ts
  - 移除 mismatch 弹窗逻辑;支持 copy 模式;selectVersioningCheckpoint 增强错误捕获。
- static/src/components/personalization/PersonalizationDrawer.vue
  - 「工作区与权限」新增版本控制默认开关与备份方式选择。
- static/src/stores/personalization.ts
  - 新增 versioning_enabled_by_default、versioning_backup_mode 字段。
- static/src/components/chat/actions/ToolAction.vue / toolRenderers.ts
  - edit_file / write_file 工具展示基于 result.details / result.new_file 的真实替换结果。
- static/src/app/state.ts / watchers.ts / App.vue
  - 新增 versioningInitializingBackupToastId,完全备份初始化时显示 toast。
- static/src/app/methods/conversation/action.ts / message/send.ts
  - host + 完全备份 + 默认开启时,创建新对话/从 /new 发送首条消息显示「正在初始化备份」toast。

验证:
- /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9 -m unittest test.test_server_refactor_smoke 通过。
- npm run build 通过。
- 宿主机与 docker 模式新建对话、编辑文件、回溯、复制对话均验证通过。
2026-07-07 12:07:44 +08:00
..
__pycache__ <fix thinking chunk> 2025-11-19 20:47:56 +08:00
file_manager feat(versioning): 重构版本控制为对话级浅备份 + 可选完全备份 2026-07-07 12:07:44 +08:00
mcp_client_manager fix(mcp_client_manager): restore missing imports and dataclass decorators after split 2026-06-25 11:56:19 +08:00
persistent_terminal fix(frontend): 修复刷新后AI等待提示与终端侧边栏重复问题 2026-06-22 20:35:00 +08:00
sub_agent fix: 修复对话计时器持久化、子智能体工具美化与状态查询,统一后台通知池 2026-06-25 04:16:44 +08:00
terminal_ops fix(terminal_ops): ssh 远程命令中避免重写 /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/bin/python3.9/pip 路径 2026-06-24 17:33:12 +08:00
admin_policy_manager.py fix(mcp): split categories by server and preserve toggle states 2026-04-27 01:42:40 +08:00
api_user_manager.py feat(memory): refactor proactive memory and conversation recall 2026-05-27 03:09:42 +08:00
approval_agent.py refactor(config): 移除硬编码模型残留,部署级配置外置到 ~/.agents 2026-06-01 16:59:34 +08:00
auto_approval_service.py fix(permission,docker): enforce docker-specific approval flow and polish permission menu layout 2026-05-11 22:56:10 +08:00
background_command_manager.py feat: 宿主机模式网络沙箱 2026-06-19 00:22:30 +08:00
balance_client.py refactor(config): 统一配置源,迁移数据到 ~/.agents/agents/ 2026-06-13 21:37:02 +08:00
container_file_proxy.py fix(prompt): merge disabled-tool notice into leading system prompts 2026-05-09 18:56:49 +08:00
container_monitor.py docs: refresh readme and phase2 summary 2025-11-23 21:24:09 +08:00
custom_tool_executor.py refactor: remove run_python tool, consolidate all execution to run_command 2026-06-07 16:23:01 +08:00
custom_tool_registry.py feat: add custom tools guide and id validation 2026-01-05 21:46:55 +08:00
easter_egg_manager.py feat: modularize easter egg effects 2025-11-22 13:07:54 +08:00
goal_review_agent.py refactor(config): 移除硬编码模型残留,部署级配置外置到 ~/.agents 2026-06-01 16:59:34 +08:00
goal_state_manager.py feat(goal): add autonomous goal mode workflow 2026-05-30 12:51:42 +08:00
gui_file_manager.py chore: initial import 2025-11-14 16:44:12 +08:00
host_sandbox_policy.py refactor(config): 移除硬编码模型残留,部署级配置外置到 ~/.agents 2026-06-01 16:59:34 +08:00
host_sandbox_runner.py feat: 宿主机模式网络沙箱 2026-06-19 00:22:30 +08:00
host_workspace_manager.py feat: support setting default workspace/project from frontend 2026-06-19 21:48:24 +08:00
mcp_server_registry.py fix(mcp): split categories by server and preserve toggle states 2026-04-27 01:42:40 +08:00
memory_manager.py feat: index-based memory tool with append/replace/delete 2025-12-14 17:56:18 +08:00
ocr_client.py fix: allow WebTerminal init without OCR API key (openai>=2.40 requires key) 2026-06-19 01:35:39 +08:00
personalization_manager.py feat(versioning): 重构版本控制为对话级浅备份 + 可选完全备份 2026-07-07 12:07:44 +08:00
search_engine.py fix(search): 移除 web_search 的 Tavily AI 摘要 2026-06-22 00:18:29 +08:00
shallow_versioning.py feat(versioning): 重构版本控制为对话级浅备份 + 可选完全备份 2026-07-07 12:07:44 +08:00
skill_hint_manager.py chore: add docs and remove sub_agent 2026-03-17 22:46:43 +08:00
skills_manager.py feat(docker): support isolated projects in web mode 2026-05-29 19:49:48 +08:00
terminal_manager.py fix(frontend): 修复刷新后AI等待提示与终端侧边栏重复问题 2026-06-22 20:35:00 +08:00
todo_manager.py feat: support batch todo updates 2026-01-30 18:50:02 +08:00
tool_approval_manager.py feat(permission): add auto-approval mode with approval agent, UI flow, and docs sync 2026-05-11 17:55:27 +08:00
toolbox_container.py refactor: remove run_python tool, consolidate all execution to run_command 2026-06-07 16:23:01 +08:00
upload_security.py feat: add upload quarantine scanning and ui toasts 2025-11-24 14:31:13 +08:00
usage_tracker.py fix: improve api error diagnostics and raise model quotas 2026-03-06 17:02:19 +08:00
user_container_manager.py feat(security): harden host execution model with sandbox/direct controls 2026-05-10 19:19:01 +08:00
user_manager.py feat: support setting default workspace/project from frontend 2026-06-19 21:48:24 +08:00
user_question_manager.py feat: add blocking user question tool 2026-05-28 16:30:55 +08:00
versioning_manager.py feat(versioning): 重构版本控制为对话级浅备份 + 可选完全备份 2026-07-07 12:07:44 +08:00
webpage_extractor.py chore: initial import 2025-11-14 16:44:12 +08:00