seewo-kit: 新增审计/改样式/删页排序/备份列表

- inspect_courseware:按页序审计文字、字号、颜色、位置、动画与点击顺序,支持全课件搜索
- set_text_style:批量改字号/加粗/颜色/对齐/框宽,只改 TextRun,保护默认属性与项目符号
- replace_text:支持 pages/allPages、matchAll、dryRun 预览
- delete_slides / move_slides:重写 Board 页序与索引映射,删页默认进回收目录
- list_backups:列出快照,供 restore_courseware 取 backupId
- README 更新到 17 个工具
This commit is contained in:
wangfar
2026-11-13 08:12:27 +08:00
parent 9484699526
commit 32b0e74e9d
4 changed files with 824 additions and 67 deletions
+117 -4
View File
@@ -16,6 +16,7 @@ import {
setAnimations, getAnimations, clearAnimations,
replaceText, verifyCourseware, backupCourseware, restoreCourseware, copySlides,
listCoursewares, syncCourseware, pruneOrphanFiles, removeLocalCourseware,
inspectCourseware, setTextStyle, listBackups, deleteSlides, moveSlides,
} from './core.mjs';
const log = (...a) => console.error('[seewo-kit]', ...a);
@@ -87,17 +88,20 @@ const TOOLS = [
{
name: 'replace_text',
description:
'批量修改某页文本内容(希沃自带 edit_text_element 不能改文字)。\n'
'批量修改文本内容(希沃自带 edit_text_element 不能改文字)。\n'
+ 'replacements 每项:{ elementId 或 find, text 或 (find+replace), width? }\n'
+ '· text:整段替换(要求该元素只有一个不同文本片段)\n'
+ '· find+replace:子串替换,必须命中\n'
+ '· find+replace:子串替换;同一页命中多个时加 elementId 或 matchAll=true\n'
+ '· width:可选,传了就按「固定框宽 + 单行折行」重排(适合正文 1160)\n'
+ '会更新 <Lines> 折行缓存,避免重开后按旧折行显示。写操作流程同 set_animations。',
+ 'page 单页,或 pages 多页,或 allPages=true 全部页。\n'
+ 'dryRun=true 只预览改动,不关课件、不写文件。写操作流程同 set_animations。',
inputSchema: {
type: 'object',
properties: {
courseware: { type: 'string' },
page: { type: 'integer', minimum: 1 },
pages: { type: 'array', items: { type: 'integer', minimum: 1 }, description: '多页模式:页码数组' },
allPages: { type: 'boolean', default: false, description: '全部页面' },
replacements: {
type: 'array',
items: {
@@ -111,12 +115,116 @@ const TOOLS = [
},
},
},
matchAll: { type: 'boolean', default: false, description: 'find 命中多个时全部替换' },
dryRun: { type: 'boolean', default: false, description: '只预览,不写文件、不关/开课件' },
reopen: { type: 'boolean', default: true },
sync: { type: 'boolean', default: false },
force: { type: 'boolean', default: false },
backup: { type: 'boolean', default: true },
},
required: ['replacements'],
},
},
{
name: 'inspect_courseware',
description:
'按 Board 页序检查课件内容(只读):每页元素 Id、文字、字号、加粗、颜色、位置、是否带动画、点击顺序,'
+ '以及可能的超宽行。\n'
+ 'page 单页;pages 多页;不传则全部页(多页默认只给摘要,不展开每页元素)。\n'
+ 'query 可全课件搜索文字,返回匹配的页码/元素 Id;format="text" 返回人读清单。',
inputSchema: {
type: 'object',
properties: {
courseware: { type: 'string' },
page: { type: 'integer', minimum: 1 },
pages: { type: 'array', items: { type: 'integer', minimum: 1 } },
query: { type: 'string', description: '按文字包含搜索(全课件)' },
includeElements: { type: 'boolean', description: '是否展开每页元素;默认单页/双页展开,多页只给摘要' },
includeAnimations: { type: 'boolean', default: true },
format: { type: 'string', enum: ['json', 'text'], default: 'json' },
},
},
},
{
name: 'set_text_style',
description:
'批量改文本样式(不换文字):字号、加粗、颜色、对齐、文本框宽度。\n'
+ '用 elementIds / textMatches 选元素;都不传则改所选页的全部文本(建议先 dryRun 预览)。\n'
+ 'page 单页,或 pages 多页,或 allPages=true 全部页。\n'
+ '颜色用 #RRGGBB 或 #AARRGGBB;改字号后会自动更新折行缓存。',
inputSchema: {
type: 'object',
properties: {
courseware: { type: 'string' },
page: { type: 'integer', minimum: 1 },
pages: { type: 'array', items: { type: 'integer', minimum: 1 } },
allPages: { type: 'boolean', default: false },
elementIds: { type: 'array', items: { type: 'string' } },
textMatches: { type: 'array', items: { type: 'string' } },
matchAll: { type: 'boolean', default: false },
fontSize: { type: 'number', minimum: 1 },
bold: { type: 'boolean' },
color: { type: 'string', description: '#RRGGBB 或 #AARRGGBB' },
align: { type: 'string', enum: ['Left', 'Center', 'Right'] },
width: { type: 'number', minimum: 1, description: '文本块宽度,可选' },
dryRun: { type: 'boolean', default: false, description: '只预览,不写文件、不关/开课件' },
reopen: { type: 'boolean', default: true },
sync: { type: 'boolean', default: false },
force: { type: 'boolean', default: false },
backup: { type: 'boolean', default: true },
},
},
},
{
name: 'list_backups',
description:
'列出本地备份快照(backupId / 时间 / 备注 / 页数 / Revision),可按课件过滤。'
+ 'restore_courseware 需要的 backupId 就从这个列表取。只读。',
inputSchema: {
type: 'object',
properties: {
courseware: { type: 'string', description: '课件名片段或 LocalId;不传列全部' },
limit: { type: 'integer', minimum: 1, default: 50 },
},
},
},
{
name: 'delete_slides',
description:
'按页删除页面:重写 Board.xml 页序、索引 Slides\\Slide_N 映射和 DB。\n'
+ '页面文件默认移到 %TEMP%\\opencode\\seewo-kit-trash,不会硬删除;至少保留 1 页。\n'
+ '删除后可用 prune_orphan_files 清理不再被索引引用的资源文件。写操作流程同 set_animations。',
inputSchema: {
type: 'object',
properties: {
courseware: { type: 'string' },
pages: { type: 'array', items: { type: 'integer', minimum: 1 }, description: '要删除的页码(按当前页序)' },
trash: { type: 'boolean', default: true, description: 'true=移到回收目录,false=直接删除' },
reopen: { type: 'boolean', default: true },
sync: { type: 'boolean', default: false },
force: { type: 'boolean', default: false },
backup: { type: 'boolean', default: true },
},
required: ['pages'],
},
},
{
name: 'move_slides',
description:
'调整页面顺序:from+to 把第 from 页移到第 to 个位置;或用 order 传完整新页序(当前页码数组)。\n'
+ '只重写 Board.xml 和索引映射,不改页面内容。写操作流程同 set_animations。',
inputSchema: {
type: 'object',
properties: {
courseware: { type: 'string' },
from: { type: 'integer', minimum: 1, description: '当前页码' },
to: { type: 'integer', minimum: 1, description: '移动后的新位置' },
order: { type: 'array', items: { type: 'integer', minimum: 1 }, description: '完整新页序(当前页码),如 [3,1,2]' },
reopen: { type: 'boolean', default: true },
sync: { type: 'boolean', default: false },
force: { type: 'boolean', default: false },
backup: { type: 'boolean', default: true },
},
required: ['page', 'replacements'],
},
},
{
@@ -245,6 +353,11 @@ const HANDLERS = {
get_animations: getAnimations,
clear_animations: clearAnimations,
replace_text: replaceText,
inspect_courseware: inspectCourseware,
set_text_style: setTextStyle,
list_backups: listBackups,
delete_slides: deleteSlides,
move_slides: moveSlides,
verify_courseware: verifyCourseware,
backup_courseware: backupCourseware,
restore_courseware: restoreCourseware,