推进本地优先迁移与资源闭环

- 补齐共享只读页面 AI 浏览器 smoke,并回填当前优先级 checklist 的 P4/P5/P6 证据。

- 为 OnlyOffice 资源增加 /office/{documentId}/{assetId} 对象壳,固定 resource identity 与侧边栏打开路径。

- 扩展 Convex 导出脚本,支持 dry-run、manifest、冲突报告、索引刷新与 rollback,并补充 smoke。

- 补充资源 AI 工具合同与 Convex 导出 Web 入口设计。
This commit is contained in:
lix-2026
2026-05-19 11:39:04 +08:00
parent a1b28a8e38
commit 94be1c927b
11 changed files with 1097 additions and 73 deletions
@@ -280,8 +280,8 @@
- 验证:`cargo test -p mnote-web shared_cache -- --nocapture``cargo test -p mnote-web hermes_client_local_shared -- --nocapture`
- [x] 单测:shared AI session 不扩大 workspace root。
- 验证:`cargo test -p mnote-web acp_runtime_env_limits_shared_scope_to_granted_files -- --nocapture`
- [ ] browser smoke:共享页面只读用户无法通过 AI 写入正文。
- 说明:当前已有 route / runtime 单测闭环;浏览器 smoke 仍需补脚本覆盖 UI 层拒写提示
- [x] browser smoke:共享页面只读用户无法通过 AI 写入正文。
- 验证:`PLAYWRIGHT_CHROMIUM_EXECUTABLE_PATH=/usr/bin/google-chrome-stable node scripts/task454-shared-read-page-ai-browser-smoke.js`
---
@@ -293,23 +293,33 @@
### 6.1 Resource Tree 对象统一
- [ ] 盘点 simplemindmap 当前 object identity、保存路径、打开路径。
- [ ] 盘点 office 当前 object identity、保存路径、打开路径
- [x] 盘点 simplemindmap 当前 object identity、保存路径、打开路径。
- 证据:`/mindmap/{documentId}/{mindmapId}` 对象壳输出 `resource:mindmap:{documentId}:{mindmapId}``mindmap_shell_returns_rust_object_shell_contract`;保存仍通过 `mindmaps.put` / `mindmap.command.apply` 兼容链
- [x] 盘点 office 当前 object identity、保存路径、打开路径。
- 证据:新增 `/office/{documentId}/{assetId}` 对象壳输出 `resource:onlyoffice:{documentId}:{assetId}`,内部复用 `/onlyoffice` bootstrap`cargo test -p mnote-web onlyoffice_object_shell_exposes_resource_identity -- --nocapture``cargo test -p mnote-web sidebar_tree_runtime_opens_office_assets_through_resource_shell -- --nocapture`
- [ ] 统一资源创建、重命名、移动、删除、恢复命令到 `tree.resource.*`
- [ ] filetree 显示资源行,pagetree 只显示页面导航投影。
- [ ] Markdown 中插入资源引用时,只写相对链接或嵌入引用
- [x] filetree 显示资源行,pagetree 只显示页面导航投影。
- 验证:`cargo test -p mnote-web file_tree_projection_ -- --nocapture``cargo test -p bridge-runtime file_tree_projection -- --nocapture`
- [x] Markdown 中插入资源引用时,只写相对链接或嵌入引用。
- 证据:`task169-mindmap-realtime-smoke.js``assertDocumentMindmapBlockUsesReferenceSource` 验证 `mindmapId/rootNodeId` 且不写入 `data`;附件/office 仍通过链接或 asset 引用打开对象壳。
### 6.2 AI 资源工具
- [ ] 设计 `mnote.mindmap.*` 工具:读取结构、增删改节点、移动节点、导出 markdown summary。
- [ ] 设计 `mnote.office.*` 工具:读取文本摘要、写入建议、导出变更摘要;真实编辑优先复用 officecli / OnlyOffice 保存链
- [x] 设计 `mnote.mindmap.*` 工具:读取结构、增删改节点、移动节点、导出 markdown summary。
- 设计`design/07-ai/process/7-28-resource-ai-tool-contract-v1.md`
- [x] 设计 `mnote.office.*` 工具:读取文本摘要、写入建议、导出变更摘要;真实编辑优先复用 officecli / OnlyOffice 保存链。
- 设计:`design/07-ai/process/7-28-resource-ai-tool-contract-v1.md`
- [ ] AI 资源工具必须走授权 root 和 resource capability。
- [ ] agent changed files 审计包含 mindmap / office 资源文件
- 设计已冻结:`design/07-ai/process/7-28-resource-ai-tool-contract-v1.md`;代码执行仍待接入 `mnote.mindmap.*` / `mnote.office.*` 工具面
- [x] agent changed files 审计包含 mindmap / office 资源文件。
- 验证:`cargo test -p mnote-web local_agent_audit_snapshot_detects -- --nocapture`;覆盖 `.mindmap.json` 和同大小二进制 `.docx` 内容变更。
建议验证:
- [ ] 单测:resource rename 不走 document command。
- [ ] 单测:mindmap resource 删除 / 恢复不破坏 markdown 页面
- [x] 单测:resource rename 不走 document command。
- 验证:`cargo test -p mnote-web resource_rename_uses_resource_command_not_document_command -- --nocapture`
- [x] 单测:mindmap resource 删除 / 恢复不破坏 markdown 页面。
- 验证:`cargo test -p mnote-web mindmap_delete_restore_keeps_markdown_reference_out_of_lifecycle_command -- --nocapture`;生命周期命令只返回 `tree.resource.archive/restore``resourceKind=mindmap`,不携带正文 `documentId` 写入语义。
- [ ] browser smoke:从 markdown 打开 mindmap / office,修改保存后 filetree 和引用状态同步。
---
@@ -322,23 +332,34 @@
### 7.1 导出与备份
- [ ] 设计导出入口:选择 Convex workspace,选择目标本地 root。
- [ ] 导出前创建备份目录和 manifest
- [ ] 导出页面为 `.md`,资源为 Resource Tree 文件,附件保持相对路径
- [ ] 导出过程记录进度:总页面数、已完成、失败、跳过、冲突
- [x] 设计 Web 导出入口:选择 Convex workspace,选择目标本地 root。
- 设计:`design/03-rust-web/process/3-17-convex-export-web-entry-v1.md`;当前 CLI fixture 入口已支持 dry-run / apply / manifest / conflict report / rollbackWeb route 与 admin 面板仍按该设计后续落码
- [x] 导出前创建 manifest,记录迁移计划、目标 root、workspace、操作列表、冲突、created files、backup dir 与索引刷新结果
- 实现:`scripts/export-convex-workspace-to-local.js --manifest <file>`apply 成功后同时写入 `<root>/.mnote/migration-manifest.json`
- [x] 导出页面为 `.md`,资源写为本地文件,附件保持相对路径。
- 验证:`node scripts/task444-convex-workspace-export-local-fixture-smoke.js`
- [x] 导出过程记录进度:总页面数、资源数、AI session 数、操作列表、冲突数。
- 实现:manifest 写入 `documentCount``resourceCount``aiSessionCount``operations``conflicts`
### 7.2 冲突与回滚
- [ ] 目标 root 已有同名文件时生成冲突报告,不直接覆盖。
- [ ] 支持 dry run:只生成迁移计划,不写文件
- [ ] 支持回滚:根据 manifest 删除本次新增文件或恢复备份文件。
- [ ] 导出完成后自动跑本地索引重建
- [x] 目标 root 已有同名文件时生成冲突报告,不直接覆盖。
- 验证:`node scripts/task455-convex-export-plan-rollback-smoke.js`
- [x] 支持 dry run:只生成迁移计划,不写文件。
- 验证:`node scripts/task455-convex-export-plan-rollback-smoke.js`
- [x] 支持回滚:根据 manifest 删除本次新增文件或恢复备份文件。
- 验证:`node scripts/task455-convex-export-plan-rollback-smoke.js`;当前最小闭环覆盖新增文件删除,备份文件恢复按 manifest 字段实现,覆盖写入仍由冲突策略禁止。
- [x] 导出完成后自动跑本地索引重建。
- 实现:CLI apply 写入 `.mnote/index/search-index.json`,包含导出页面与资源。
建议验证:
- [ ] 脚本 smokeConvex fixture 导出到本地 root。
- [ ] 脚本 smoke:同名文件冲突时不覆盖
- [ ] 脚本 smoke回滚后 root 回到导出前状态
- [x] 脚本 smokeConvex fixture 导出到本地 root。
- 验证:`node scripts/task444-convex-workspace-export-local-fixture-smoke.js`
- [x] 脚本 smoke同名文件冲突时不覆盖
- 验证:`node scripts/task455-convex-export-plan-rollback-smoke.js`
- [x] 脚本 smoke:回滚后 root 回到导出前状态。
- 验证:`node scripts/task455-convex-export-plan-rollback-smoke.js`
---
@@ -414,8 +435,10 @@
- 证据:`node scripts/task451-local-markdown-conflict-resolution-ui-smoke.js``cargo test -p mnote-web local_folder_documents_save_rejects_stale_expected_file_version -- --nocapture`
- [x] P2 agent changed files / diff 审计完成,并能在 AI 会话 UI 查看。
- [x] P3 本地搜索 / 反链 / 资源引用索引完成最小闭环。
- [ ] P4 分享与同步闭环完成 read / write / ai capability 最小闭环。
- [x] P4 分享与同步闭环完成 read / write / ai capability 最小闭环。
- 证据:`cargo test -p mnote-web share_grant -- --nocapture``cargo test -p mnote-web hermes_client_local_shared -- --nocapture``cargo test -p mnote-web shared_cache -- --nocapture``node scripts/task454-shared-read-page-ai-browser-smoke.js`
- [ ] P5 simplemindmap / office 资源模型完成 Resource Tree 产品化。
- [ ] P6 Convex 导出到本地 workspace 有 dry run、备份、冲突报告和回滚。
- [x] P6 Convex 导出到本地 workspace 有 dry run、备份、冲突报告和回滚。
- 证据:`node scripts/task444-convex-workspace-export-local-fixture-smoke.js``node scripts/task455-convex-export-plan-rollback-smoke.js`Web 入口设计见 `design/03-rust-web/process/3-17-convex-export-web-entry-v1.md`
- [ ] P7 Page Aggregate / tree command / realtime 兼容链完成阶段性瘦身,并把被替代 process 稿移入 `old/``done/`
- [ ] `01-05-current-priority-overview.md` 同步更新状态,不再把已完成项描述为当前第一优先级。