seewo-kit: 重名检测 / 恢复保留身份 / 清理重复与孤儿文件

- resolveCourseware 同名多份直接报错并列出 localId/RemoteId/Revision
- 开/关课件时用 RemoteId 核对,避免同名副本操作错
- restore_courseware 默认 keepIdentity=true,只恢复内容保留 Name/RemoteId
- syncShell 轮询备课界面,遇「必须处于备课界面」自动重试
- 新增 prune_orphan_files(默认 dryRun,清理前备份并移入回收目录)
- 新增 remove_local_courseware(目录进回收站 + 删 DB 行,不动云端)
- verify_courseware 返回每页动画数 animations / animationTotal
- 文档补充新工具与身份冲突处理
This commit is contained in:
wangfar
2026-11-09 11:49:55 +08:00
parent e6d74ebb35
commit 9484699526
4 changed files with 364 additions and 48 deletions
+41 -2
View File
@@ -15,7 +15,7 @@ import { createInterface } from 'node:readline';
import {
setAnimations, getAnimations, clearAnimations,
replaceText, verifyCourseware, backupCourseware, restoreCourseware, copySlides,
listCoursewares, syncCourseware,
listCoursewares, syncCourseware, pruneOrphanFiles, removeLocalCourseware,
} from './core.mjs';
const log = (...a) => console.error('[seewo-kit]', ...a);
@@ -123,7 +123,8 @@ const TOOLS = [
name: 'verify_courseware',
description:
'课件自检(只读):页数、Board.xml 页序、索引与磁盘文件的 MD5/大小、重复 Id、图片资源引用、'
+ 'DB 里的 Revision/行数是否一致、孤儿文件。返回 { ok, issues[] }。',
+ 'DB 里的 Revision/行数是否一致、孤儿文件,以及每页动画数(animations / animationTotal)。'
+ '返回 { ok, issues[] }。',
inputSchema: {
type: 'object',
properties: {
@@ -148,6 +149,7 @@ const TOOLS = [
name: 'restore_courseware',
description:
'从 backup_courseware 的快照恢复(覆盖当前缓存文件与索引/DB)。必须传 confirm=true。\n'
+ '默认 keepIdentity=true:只恢复内容,保留当前课件的 Name/RemoteId,避免把本地指针指到备份里的另一份云端副本。\n'
+ '恢复是本地操作:Revision 会比当前值再 +1,不会自动上传;需要时传 sync=true。',
inputSchema: {
type: 'object',
@@ -155,6 +157,7 @@ const TOOLS = [
backupId: { type: 'string', description: 'backup_courseware 返回的 backupId' },
courseware: { type: 'string', description: '覆盖到哪份课件;默认用备份里的 LocalId' },
confirm: { type: 'boolean', description: '必须为 true' },
keepIdentity: { type: 'boolean', default: true, description: '保留当前 Name/RemoteId(推荐)' },
reopen: { type: 'boolean', default: true },
sync: { type: 'boolean', default: false },
force: { type: 'boolean', default: false },
@@ -162,6 +165,40 @@ const TOOLS = [
required: ['backupId', 'confirm'],
},
},
{
name: 'prune_orphan_files',
description:
'清理课件目录里「存在但未被索引引用」的旧文件(每次恢复/复制都会堆积)。\n'
+ '默认 dryRun=true 只预览;真正清理需要 dryRun=false + confirm=true。\n'
+ '清理前会自动备份,文件移进 %TEMP%\\opencode\\seewo-kit-orphans,不会硬删除。',
inputSchema: {
type: 'object',
properties: {
courseware: { type: 'string', description: '课件名片段或 LocalId' },
dryRun: { type: 'boolean', default: true, description: 'true=只列出将要清理的文件' },
confirm: { type: 'boolean', default: false, description: 'dryRun=false 时必须为 true' },
force: { type: 'boolean', default: false, description: '忽略未同步检查' },
backup: { type: 'boolean', default: true },
reopen: { type: 'boolean', default: true, description: '原本开着的话,清理后重新打开' },
},
},
},
{
name: 'remove_local_courseware',
description:
'移除本地重复课件:关闭课件 → 把缓存目录移到 %TEMP%\\opencode\\seewo-kit-trash → 删除 Courseware / CoursewareFile 记录。\n'
+ '只影响本地缓存和 DB,不会删除云端课件。必须传 confirm=true。',
inputSchema: {
type: 'object',
properties: {
courseware: { type: 'string', description: '课件名片段或 LocalId(重名时必须用 LocalId)' },
confirm: { type: 'boolean', description: '必须为 true' },
force: { type: 'boolean', default: false, description: '忽略未同步检查' },
trash: { type: 'boolean', default: true, description: 'true=移到回收目录,false=直接删除' },
},
required: ['confirm'],
},
},
{
name: 'copy_slides',
description:
@@ -213,6 +250,8 @@ const HANDLERS = {
restore_courseware: restoreCourseware,
copy_slides: copySlides,
sync_courseware: syncCourseware,
prune_orphan_files: pruneOrphanFiles,
remove_local_courseware: removeLocalCourseware,
list_coursewares: () => {
const all = listCoursewares();
let dbCountHint = null;