dsh-ppt 0.21.1 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.en.md +18 -18
  3. package/README.md +16 -16
  4. package/docs/COACHING.md +14 -13
  5. package/docs/DATA.md +8 -8
  6. package/docs/REFERENCE.en.md +17 -19
  7. package/docs/REFERENCE.zh.md +16 -18
  8. package/docs/USAGE.en.md +107 -60
  9. package/docs/USAGE.md +115 -84
  10. package/docs/VALIDATION.md +2 -0
  11. package/docs/VISUAL.md +27 -20
  12. package/docs/WORKBENCH.md +17 -6
  13. package/docs/assets/intro/screen-en.webp +0 -0
  14. package/docs/assets/intro/screen-zh.webp +0 -0
  15. package/lib/client.js +905 -46
  16. package/lib/coaching.d.ts +1 -1
  17. package/lib/coaching.js +25 -12
  18. package/lib/config.d.ts +2 -0
  19. package/lib/config.js +30 -2
  20. package/lib/execution.d.ts +2 -1
  21. package/lib/execution.js +21 -1
  22. package/lib/tools.d.ts +1 -1
  23. package/lib/tools.js +151 -24
  24. package/lib/types.d.ts +108 -8
  25. package/lib/visual.d.ts +3 -1
  26. package/lib/visual.js +40 -13
  27. package/lib/workbench-language.js +45 -9
  28. package/lib/workbench.d.ts +5 -0
  29. package/lib/workbench.js +485 -9
  30. package/package.json +8 -3
  31. package/skills/dsh-ppt/SKILL.md +56 -54
  32. package/skills/dsh-ppt/package.json +1 -1
  33. package/skills/dsh-ppt/references/advanced.md +122 -41
  34. package/skills/dsh-ppt/references/copywriting.md +63 -41
  35. package/skills/dsh-ppt/references/data.md +83 -36
  36. package/skills/dsh-ppt/references/syntax.md +157 -28
  37. package/skills/dsh-ppt/references/themes.md +90 -41
  38. package/skills/dsh-ppt/references/troubleshooting.md +21 -16
  39. package/skills/dsh-ppt/scripts/build-deck.mjs +67 -28
  40. package/skills/dsh-ppt/scripts/deck-absorb.mjs +1029 -0
  41. package/skills/dsh-ppt/scripts/deck-advanced.mjs +406 -99
  42. package/skills/dsh-ppt/scripts/deck-core.mjs +568 -717
  43. package/skills/dsh-ppt/scripts/deck-data-view.mjs +30 -11
  44. package/skills/dsh-ppt/scripts/deck-data.mjs +35 -5
  45. package/skills/dsh-ppt/scripts/deck-director.mjs +1717 -0
  46. package/skills/dsh-ppt/scripts/deck-layouts.mjs +4557 -0
  47. package/skills/dsh-ppt/scripts/deck-media.mjs +1408 -86
  48. package/skills/dsh-ppt/scripts/deck-themes.mjs +1503 -0
  49. package/skills/dsh-ppt/scripts/deck-visual.mjs +133 -31
package/lib/workbench.js CHANGED
@@ -10,9 +10,24 @@ import { PptCoaching } from './coaching.js';
10
10
  import { PptVisual } from './visual.js';
11
11
  export const PPT_WORKBENCH_ROUTE = '/api/dsh-ppt/workbench';
12
12
  export const PPT_DOWNLOAD_ROUTE = '/api/dsh-ppt/download';
13
- const REQUEST_LIMIT = 12 * 1024 * 1024;
13
+ const REQUEST_LIMIT = 15 * 1024 * 1024;
14
+ const ABSORB_PPTX_LIMIT = 10 * 1024 * 1024;
14
15
  const FILE_LIMIT = 64 * 1024 * 1024;
15
16
  const BUNDLE_LIMIT = 128 * 1024 * 1024;
17
+ const ALLOWED_LAYOUTS = new Set([
18
+ 'cover', 'agenda', 'section', 'bullets', 'statement', 'quote',
19
+ 'kpi', 'cards', 'comparison', 'matrix', 'process', 'callout',
20
+ 'gantt', 'architecture', 'harvey', 'tam', 'org',
21
+ 'table', 'closing', 'image', 'image-left', 'image-right', 'chart', 'chart-split',
22
+ 'waterfall', 'gallery', 'flywheel',
23
+ ]);
24
+ const ALLOWED_TABLE_STYLES = new Set(['consulting', 'booktabs', 'minimal', 'banded', 'harvey']);
25
+ const ALLOWED_DENSITIES = new Set(['compact', 'balanced', 'airy']);
26
+ const ALLOWED_ITEM_STATUS = new Set(['neutral', 'accent', 'positive', 'negative', 'warning']);
27
+ const ALLOWED_CHROME_STYLES = new Set(['consulting-classic', 'keynote-spatial', 'editorial-folio', 'saas-bento', 'academic-minimal', 'gov-ceremonial']);
28
+ const ITEM_KEYS = new Set(['tag', 'badge', 'title', 'text', 'body', 'value', 'unit', 'delta', 'start', 'span', 'milestone', 'role', 'conversion', 'status', 'tone', 'bullets']);
29
+ const BRAND_KEYS = new Set(['name', 'primaryColor', 'backgroundColor', 'textColor', 'fontFamily', 'logo', 'footer', 'chromeStyle']);
30
+ const VISUAL_KEYS = new Set(['titleSize', 'bodySize', 'chartLabelSize', 'density', 'tableStyle', 'chrome']);
16
31
  /** Sharing keeps the offline deck, but omits the control for a project not in the ZIP. */
17
32
  function shareHtml(bytes) {
18
33
  const html = bytes.toString('utf8'), marker = '<a id="download-project"';
@@ -42,6 +57,171 @@ function speakerNotes(manifest) {
42
57
  });
43
58
  return '# ' + heading(manifest.title) + '\n\n' + sections.join('\n\n---\n\n') + '\n';
44
59
  }
60
+ function starterSlide(archetype, language) {
61
+ const en = language === 'en';
62
+ const kind = typeof archetype === 'string' && ALLOWED_LAYOUTS.has(archetype) ? archetype : 'bullets';
63
+ if (kind === 'kpi') {
64
+ return {
65
+ layout: 'kpi',
66
+ variant: 'grid',
67
+ title: en ? 'Key metrics show clear momentum' : '核心指标呈现稳健增长态势',
68
+ items: [
69
+ { value: '98.5%', title: en ? 'Completion rate' : '关键任务达成率', delta: en ? '+4.2% QoQ' : '环比 +4.2%', status: 'positive' },
70
+ { value: '2.4x', title: en ? 'Efficiency gain' : '协同交付效率', delta: en ? 'Verified' : '阶段核验', status: 'accent' },
71
+ { value: '12', unit: en ? 'wks' : '周', title: en ? 'Lead cycle' : '端到端交付周期', delta: en ? '-30%' : '缩短 30%', status: 'positive' },
72
+ ],
73
+ };
74
+ }
75
+ if (kind === 'cards') {
76
+ return {
77
+ layout: 'cards',
78
+ variant: 'pillars',
79
+ title: en ? 'Three strategic pillars drive execution' : '三大核心支柱支撑目标落地',
80
+ items: [
81
+ { tag: '01', title: en ? 'Clear focus' : '聚焦核心场景', text: en ? 'Concentrate resources on high-impact deliverables.' : '围绕高频刚需场景集中投入,避免战线分散。' },
82
+ { tag: '02', title: en ? 'Standardized flow' : '标准化工作流', text: en ? 'Unify templates, review gates, and handoff criteria.' : '统一输入规范、质量门禁与跨团队交接标准。' },
83
+ { tag: '03', title: en ? 'Measurable loop' : '量化闭环复盘', text: en ? 'Track leading indicators and iterate weekly.' : '按周追踪先行指标,及时纠偏并沉淀经验。' },
84
+ ],
85
+ };
86
+ }
87
+ if (kind === 'comparison') {
88
+ return {
89
+ layout: 'comparison',
90
+ variant: 'versus',
91
+ title: en ? 'Upgraded workflow removes manual bottlenecks' : '新方案消除人工瓶颈并提升交付确定性',
92
+ items: [
93
+ { tag: en ? 'Before' : '调整前', title: en ? 'Fragmented handoffs' : '流程分散、口径不一', text: en ? 'Repeated manual formatting and late quality checks.' : '依赖人工反复改版,交付前才发现遗漏。', status: 'neutral' },
94
+ { tag: en ? 'After' : '调整后', title: en ? 'Integrated delivery' : '同源构建、闭环核验', text: en ? 'Synchronized outputs with traceable metrics and checks.' : '多端产物一次同步生成,关键数字可追溯。', status: 'positive' },
95
+ ],
96
+ };
97
+ }
98
+ if (kind === 'matrix') {
99
+ return {
100
+ layout: 'matrix',
101
+ variant: '2x2',
102
+ title: en ? 'Prioritize high-impact, quick-win initiatives' : '按价值与实施难度划分四象限优先级',
103
+ items: [
104
+ { tag: 'Q1', title: en ? 'Quick wins' : '优先速赢项', text: en ? 'High impact, low complexity — ship first.' : '高价值、低阻力,本阶段优先落地。', status: 'positive' },
105
+ { tag: 'Q2', title: en ? 'Strategic bets' : '战略攻坚项', text: en ? 'High impact, staged milestones required.' : '高价值、长周期,分阶段里程碑推进。', status: 'accent' },
106
+ { tag: 'Q3', title: en ? 'Routine upkeep' : '常规维护项', text: en ? 'Automate and keep lightweight.' : '保持自动化轻量运转,控制投入。', status: 'neutral' },
107
+ { tag: 'Q4', title: en ? 'Defer / prune' : '暂缓或精简', text: en ? 'Low return — avoid resource dilution.' : '收益有限,避免分散核心团队精力。', status: 'warning' },
108
+ ],
109
+ };
110
+ }
111
+ if (kind === 'process') {
112
+ return {
113
+ layout: 'process',
114
+ variant: 'steps',
115
+ title: en ? 'Four-stage execution roadmap' : '分四阶段推进方案落地与验收',
116
+ items: [
117
+ { tag: '01', title: en ? 'Align scope' : '明确边界', text: en ? 'Confirm goals, metrics, and constraints.' : '对齐业务目标、考核口径与资源边界。' },
118
+ { tag: '02', title: en ? 'Pilot build' : '样板试点', text: en ? 'Validate core workflow on one benchmark.' : '跑通首个标杆样板,验证端到端闭环。' },
119
+ { tag: '03', title: en ? 'Scale rollout' : '全面推广', text: en ? 'Expand coverage with standard playbooks.' : '沉淀标准手册,向全业务线有序铺开。' },
120
+ { tag: '04', title: en ? 'Audit & refine' : '复盘固化', text: en ? 'Review outcomes and lock best practices.' : '核验量化成效,将最佳实践固化为制度。' },
121
+ ],
122
+ };
123
+ }
124
+ if (kind === 'callout') {
125
+ return {
126
+ layout: 'callout',
127
+ variant: 'takeaways',
128
+ title: en ? 'Core takeaways and immediate actions' : '核心结论与下一步行动清单',
129
+ text: en ? 'Confirm owner assignments and milestone dates before the kick-off review.' : '请在启动评审前确认各项任务负责人与关键时间节点。',
130
+ bullets: en ? ['Confirm baseline metrics and target thresholds', 'Assign milestone owners and weekly check-ins'] : ['确认基线数据与阶段目标阈值', '明确各模块负责人与周度跟进机制'],
131
+ };
132
+ }
133
+ if (kind === 'table') {
134
+ return {
135
+ layout: 'table',
136
+ tableStyle: 'consulting',
137
+ title: en ? 'Milestone ownership and delivery schedule' : '关键里程碑、负责人与交付节点一览',
138
+ rows: en
139
+ ? [['Workstream', 'Owner', 'Target', 'Status'], ['Core architecture', 'Platform', 'Q2', 'On track'], ['Validation suite', 'QA', 'Q3', 'Planned']]
140
+ : [['工作模块', '负责人', '目标节点', '当前状态'], ['核心方案搭建', '研发组', 'Q2', '按计划推进'], ['全量验收交付', '质量组', 'Q3', '待启动']],
141
+ };
142
+ }
143
+ if (kind === 'gantt') {
144
+ return {
145
+ layout: 'gantt',
146
+ variant: 'quarters',
147
+ title: en ? 'Quarterly execution roadmap and key milestones' : '季度推进甘特图与关键里程碑节点',
148
+ columns: ['Q1', 'Q2', 'Q3', 'Q4'],
149
+ items: [
150
+ { tag: en ? 'Foundation' : '底座建设', title: en ? 'Core platform & schema' : '核心架构与协议落地', start: 0, span: 2, status: 'accent' },
151
+ { tag: en ? 'Rollout' : '试点推广', title: en ? 'Pilot deployment & review' : '标杆场景试点与验证', start: 1, span: 2, status: 'positive' },
152
+ { tag: en ? 'Launch' : '正式验收', title: en ? 'Production GA sign-off' : '全量上线验收里程碑', start: 3, span: 0, milestone: true, status: 'warning' },
153
+ ],
154
+ };
155
+ }
156
+ if (kind === 'architecture') {
157
+ return {
158
+ layout: 'architecture',
159
+ variant: 'layered',
160
+ title: en ? 'Layered system architecture and governance backbone' : '分层系统架构与跨层安全治理底座',
161
+ items: [
162
+ { tag: en ? 'Experience' : '交互层', title: en ? 'Portal & Workbench' : '多端工作台与交互入口', bullets: en ? ['Web Studio', 'CLI & SDK'] : ['可视化工作台', 'CLI 与插件接口'] },
163
+ { tag: en ? 'Orchestration' : '编排层', title: en ? 'Workflow & Agent Engine' : '智能编排与推理引擎', bullets: en ? ['Task Router', 'Policy Guard'] : ['任务路由', '规则门禁'] },
164
+ { tag: en ? 'Foundation' : '底座层', title: en ? 'Storage & Audit Ledger' : '同源存储与审计追踪', bullets: en ? ['Atomic Store', 'Telemetry'] : ['原子落盘', '全链路可观测'] },
165
+ { tag: en ? 'Cross-cutting' : '横切保障', title: en ? 'Security & Compliance' : '安全合规与权限隔离', status: 'accent', bullets: en ? ['Zero Trust', 'Audit Trail'] : ['最小权限', '审计留痕'] },
166
+ ],
167
+ };
168
+ }
169
+ if (kind === 'harvey') {
170
+ return {
171
+ layout: 'harvey',
172
+ tableStyle: 'harvey',
173
+ title: en ? 'Capability matrix highlights full-stack differentiation' : '核心能力哈维球评估矩阵凸显差异化优势',
174
+ rows: en
175
+ ? [['Capability', 'Ours', 'Vendor A', 'Vendor B'], ['Native Editability', '●', '◑', '○'], ['Contrast Guardrails', '●', '◕', '◑'], ['Offline Delivery', '●', '○', '◑']]
176
+ : [['评估维度', '本方案', '竞品 A', '竞品 B'], ['原生可编辑输出', '●', '◑', '○'], ['自动对比度净化', '●', '◕', '◑'], ['离线安全交付', '●', '○', '◑']],
177
+ };
178
+ }
179
+ if (kind === 'tam') {
180
+ return {
181
+ layout: 'tam',
182
+ variant: 'concentric',
183
+ title: en ? 'Addressable market sizing from TAM to near-term SOM' : '目标市场空间拆解:从 TAM 到近期可触达 SOM',
184
+ items: [
185
+ { tag: 'TAM', value: '$18B', title: en ? 'Total Addressable Market' : '潜在市场总规模', text: en ? 'Global enterprise workflow automation spend.' : '全球企业级智能化办公与协作总支出。', status: 'neutral' },
186
+ { tag: 'SAM', value: '$4.2B', title: en ? 'Serviceable Addressable Market' : '可服务市场规模', text: en ? 'Regulated knowledge-worker teams.' : '对数据合规与本地交付有强需求的中大型机构。', status: 'accent' },
187
+ { tag: 'SOM', value: '$380M', title: en ? 'Serviceable Obtainable Market' : '近期可获取市场', text: en ? '3-year target across flagship verticals.' : '未来三年重点行业标杆客户可实现营收空间。', status: 'positive' },
188
+ ],
189
+ };
190
+ }
191
+ if (kind === 'org') {
192
+ return {
193
+ layout: 'org',
194
+ variant: 'tree',
195
+ title: en ? 'Cross-functional governance and delivery organization' : '跨职能组织架构与关键职责分工',
196
+ items: [
197
+ { tag: 'LEAD', role: en ? 'Program Sponsor' : '项目总负责人', title: en ? 'Steering Lead' : '统筹决策与资源协调', text: en ? 'Owns strategic alignment and quarterly gates.' : '负责跨部门协同、里程碑拍板与预算保障。', status: 'accent' },
198
+ { tag: 'ENG', role: en ? 'Platform Lead' : '核心研发组', title: en ? 'Architecture & Build' : '底层引擎与稳定性保障', text: en ? 'Delivers core runtime and automated checks.' : '负责核心链路研发、性能与自动化测试。' },
199
+ { tag: 'PROD', role: en ? 'Product Lead' : '产品与交付组', title: en ? 'Experience & Rollout' : '场景打磨与试点落地', text: en ? 'Drives customer validation and playbook ops.' : '负责客户需求闭环、标杆试点与交付培训。' },
200
+ { tag: 'QA', role: en ? 'Quality Lead' : '质量与合规组', title: en ? 'Verification & Security' : '验收门禁与安全审计', text: en ? 'Enforces release gates and audit readiness.' : '负责质量门禁把关与合规审计留痕。' },
201
+ ],
202
+ };
203
+ }
204
+ if (kind === 'statement') {
205
+ return { layout: 'statement', title: en ? 'Focus on measurable user outcomes over raw output volume.' : '以可验证的实际成效衡量交付,而非堆砌表面工作量。', subtitle: en ? 'Core principle' : '核心准则' };
206
+ }
207
+ if (kind === 'quote') {
208
+ return { layout: 'quote', title: en ? 'Clarity comes from disciplined structure and honest evidence.' : '清晰的结构与扎实的证据,是说服力的唯一来源。', subtitle: en ? 'Project note' : '项目纪要' };
209
+ }
210
+ if (kind === 'section') {
211
+ return { layout: 'section', kicker: '01', title: en ? 'Next Chapter' : '新章节标题', subtitle: en ? 'Key focus of this section' : '本章节核心议题说明' };
212
+ }
213
+ if (kind === 'agenda') {
214
+ return { layout: 'agenda', title: en ? 'Agenda' : '汇报目录', bullets: en ? ['Context & objectives', 'Key findings & solution', 'Execution plan & next steps'] : ['背景与核心目标', '关键发现与总体方案', '推进计划与下一步安排'] };
215
+ }
216
+ if (kind === 'closing') {
217
+ return { layout: 'closing', title: en ? 'Thank You · Next Steps' : '感谢聆听 · 下一步行动', subtitle: en ? 'Confirm pilot scope this week and review initial metrics next Friday.' : '本周内确认试点范围,下周五同步首轮评估结果。' };
218
+ }
219
+ return {
220
+ layout: 'bullets',
221
+ title: en ? 'New slide key takeaway' : '请填写本页核心结论句',
222
+ bullets: en ? ['First supporting point with concrete evidence', 'Second supporting point and next action'] : ['第一条支撑论据(建议附具体事实或数字)', '第二条支撑论据与下一步动作'],
223
+ };
224
+ }
45
225
  function json(status, value) {
46
226
  return new Response(JSON.stringify(value), { status, headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' } });
47
227
  }
@@ -85,8 +265,20 @@ export class PptWorkbench {
85
265
  try {
86
266
  const row = JSON.parse(line);
87
267
  if (typeof row.path === 'string' && row.path.endsWith('.json') && row.id === digest(row.path) && typeof row.title === 'string' && typeof row.updatedAt === 'string') {
268
+ const clean = {
269
+ id: row.id,
270
+ path: row.path,
271
+ title: row.title,
272
+ updatedAt: row.updatedAt,
273
+ ...(typeof row.theme === 'string' ? { theme: row.theme } : {}),
274
+ ...(Number.isInteger(row.slideCount) ? { slideCount: row.slideCount } : {}),
275
+ ...(Number.isInteger(row.revision) ? { revision: row.revision } : {}),
276
+ ...(row.modelRoute && typeof row.modelRoute.provider === 'string' && typeof row.modelRoute.model === 'string'
277
+ ? { modelRoute: { provider: row.modelRoute.provider, model: row.modelRoute.model } }
278
+ : {}),
279
+ };
88
280
  rows.delete(row.id);
89
- rows.set(row.id, row);
281
+ rows.set(row.id, clean);
90
282
  }
91
283
  }
92
284
  catch { /* A crash may leave an incomplete last append; keep older rows. */ }
@@ -110,7 +302,16 @@ export class PptWorkbench {
110
302
  if (!route?.provider || !route?.model)
111
303
  route = exec?.agent?.session.requestHeader?.()?.config;
112
304
  const modelRoute = typeof route?.provider === 'string' && typeof route?.model === 'string' ? { provider: route.provider, model: route.model } : this.catalog().find(p => p.path === path)?.modelRoute;
113
- const row = { id: digest(path), path, title: manifest.title, updatedAt: new Date().toISOString(), ...(modelRoute ? { modelRoute } : {}) };
305
+ const row = {
306
+ id: digest(path),
307
+ path,
308
+ title: manifest.title,
309
+ updatedAt: new Date().toISOString(),
310
+ ...(typeof manifest.theme === 'string' ? { theme: manifest.theme } : {}),
311
+ ...(Array.isArray(manifest.slides) ? { slideCount: manifest.slides.length } : {}),
312
+ ...(Number.isInteger(manifest.revision) ? { revision: manifest.revision } : {}),
313
+ ...(modelRoute ? { modelRoute } : {}),
314
+ };
114
315
  mkdirSync(dirname(this.catalogPath), { recursive: true });
115
316
  if (existsSync(this.catalogPath) && lstatSync(this.catalogPath).size >= 8 * 1024 * 1024)
116
317
  throw new Error('项目索引已满,请备份后整理 projects.jsonl');
@@ -139,7 +340,9 @@ export class PptWorkbench {
139
340
  catch { /* A check can register an older JSON-only project. */ }
140
341
  const render = this.renders.get(entry.id);
141
342
  const currentRender = render && render.revision === manifest.revision && digest(ordinaryFile(files.pptx)) === render.sourceSha256 ? render : undefined;
142
- return { ok: true, project: { ...entry, deckId: manifest.deckId, revision: manifest.revision, slides: manifest.slides,
343
+ const themes = typeof engine.listThemes === 'function' ? engine.listThemes(manifest.language === 'en' ? 'en' : 'zh') : [];
344
+ return { ok: true, project: { ...entry, deckId: manifest.deckId, revision: manifest.revision, theme: manifest.theme ?? 'data',
345
+ brand: manifest.brand ?? null, themes, slides: manifest.slides,
143
346
  undoAvailable: manifest.history.length, quality: check, html, dataModel: manifest.dataModel ?? null,
144
347
  assets: Object.fromEntries(Object.entries(manifest.assets ?? {}).map(([key, value]) => [key, { data: value.data, mime: value.mime }])),
145
348
  render: currentRender ? { pageCount: currentRender.pngPaths.length, missingFonts: currentRender.missingFonts ?? [] } : null } };
@@ -148,18 +351,238 @@ export class PptWorkbench {
148
351
  if (!Number.isSafeInteger(body.expectedRevision) || body.expectedRevision !== manifest.revision)
149
352
  throw new Error('项目已被修改,请重新打开后再编辑;当前输入保留');
150
353
  }
354
+ themeId(value) {
355
+ if (typeof value !== 'string' || !/^[a-z][a-z0-9-]{1,31}$/.test(value.trim()))
356
+ throw new Error('主题名称无效');
357
+ return value.trim();
358
+ }
359
+ brandPatch(value) {
360
+ if (value === null)
361
+ return null;
362
+ if (!value || typeof value !== 'object' || Array.isArray(value))
363
+ throw new Error('品牌设置无效:请检查 #RRGGBB 颜色、安全字体名称、页脚长度或面板上传的 PNG/JPEG Logo');
364
+ const raw = value, out = {};
365
+ for (const [key, item] of Object.entries(raw)) {
366
+ if (!BRAND_KEYS.has(key))
367
+ throw new Error('品牌设置无效:请检查 #RRGGBB 颜色、安全字体名称、页脚长度或面板上传的 PNG/JPEG Logo');
368
+ if (item === undefined)
369
+ continue;
370
+ if (['primaryColor', 'backgroundColor', 'textColor'].includes(key)) {
371
+ if (item === '')
372
+ continue;
373
+ if (typeof item !== 'string' || !/^#[0-9A-Fa-f]{6}$/.test(item.trim()))
374
+ throw new Error('品牌设置无效:请检查 #RRGGBB 颜色、安全字体名称、页脚长度或面板上传的 PNG/JPEG Logo');
375
+ out[key] = item.trim().toUpperCase();
376
+ }
377
+ else if (key === 'fontFamily') {
378
+ if (item === '')
379
+ continue;
380
+ if (typeof item !== 'string' || !/^[A-Za-z0-9\u4e00-\u9fff ,.'_-]{1,80}$/.test(item.trim()))
381
+ throw new Error('品牌设置无效:请检查 #RRGGBB 颜色、安全字体名称、页脚长度或面板上传的 PNG/JPEG Logo');
382
+ out[key] = item.trim();
383
+ }
384
+ else if (key === 'name' || key === 'footer') {
385
+ if (typeof item !== 'string' || item.length > 200 || /[\x00-\x08\x0b\x0c\x0e-\x1f]/.test(item))
386
+ throw new Error('品牌设置无效:请检查 #RRGGBB 颜色、安全字体名称、页脚长度或面板上传的 PNG/JPEG Logo');
387
+ out[key] = item;
388
+ }
389
+ else if (key === 'logo') {
390
+ if (item === null)
391
+ out.logo = null;
392
+ else if (typeof item === 'string' && item.length <= 7_000_000 && /^data:image\/(png|jpeg);base64,[A-Za-z0-9+/=]+$/.test(item))
393
+ out.logo = item;
394
+ else
395
+ throw new Error('图片必须从面板上传,不能读取其他本地文件');
396
+ }
397
+ else if (key === 'chromeStyle') {
398
+ if (item === null) {
399
+ out.chromeStyle = null;
400
+ continue;
401
+ }
402
+ if (typeof item !== 'string' || !ALLOWED_CHROME_STYLES.has(item))
403
+ throw new Error('母版骨架名称无效 / Invalid chrome skeleton style');
404
+ out.chromeStyle = item;
405
+ }
406
+ }
407
+ return out;
408
+ }
409
+ itemsPatch(value) {
410
+ if (!Array.isArray(value) || value.length > 8)
411
+ throw new Error('结构化卡片内容无效');
412
+ return value.map(entry => {
413
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry))
414
+ throw new Error('结构化卡片内容无效');
415
+ const raw = entry;
416
+ if (Object.keys(raw).some(k => !ITEM_KEYS.has(k)))
417
+ throw new Error('结构化卡片内容无效');
418
+ const tag = raw.tag ?? raw.badge;
419
+ const title = raw.title;
420
+ const text = raw.text ?? raw.body;
421
+ const val = raw.value;
422
+ const unit = raw.unit;
423
+ const delta = raw.delta;
424
+ const status = raw.status ?? raw.tone;
425
+ const bullets = raw.bullets;
426
+ if (tag !== undefined && (typeof tag !== 'string' || tag.length > 120))
427
+ throw new Error('结构化卡片内容无效');
428
+ if (title !== undefined && (typeof title !== 'string' || title.length > 300))
429
+ throw new Error('结构化卡片内容无效');
430
+ if (text !== undefined && (typeof text !== 'string' || text.length > 1500))
431
+ throw new Error('结构化卡片内容无效');
432
+ if (val !== undefined && !((typeof val === 'string' && val.length <= 120) || (typeof val === 'number' && Number.isFinite(val))))
433
+ throw new Error('结构化卡片内容无效');
434
+ if (unit !== undefined && (typeof unit !== 'string' || unit.length > 120))
435
+ throw new Error('结构化卡片内容无效');
436
+ if (delta !== undefined && (typeof delta !== 'string' || delta.length > 120))
437
+ throw new Error('结构化卡片内容无效');
438
+ if (status !== undefined && status !== '' && (typeof status !== 'string' || !ALLOWED_ITEM_STATUS.has(status)))
439
+ throw new Error('结构化卡片内容无效');
440
+ if (bullets !== undefined && (!Array.isArray(bullets) || bullets.length > 8 || bullets.some(b => typeof b !== 'string' || b.length > 500)))
441
+ throw new Error('结构化卡片内容无效');
442
+ const clean = {};
443
+ if (typeof tag === 'string' && tag.trim())
444
+ clean.tag = tag.trim();
445
+ if (typeof title === 'string' && title.trim())
446
+ clean.title = title.trim();
447
+ if (typeof text === 'string' && text.trim())
448
+ clean.text = text.trim();
449
+ if (val !== undefined && String(val).trim() !== '')
450
+ clean.value = String(val).trim();
451
+ if (typeof unit === 'string' && unit.trim())
452
+ clean.unit = unit.trim();
453
+ if (typeof delta === 'string' && delta.trim())
454
+ clean.delta = delta.trim();
455
+ if (typeof status === 'string' && status)
456
+ clean.status = status;
457
+ if (Array.isArray(bullets)) {
458
+ const lines = bullets.map(b => b.trim()).filter(Boolean);
459
+ if (lines.length)
460
+ clean.bullets = lines;
461
+ }
462
+ const start = raw.start;
463
+ const span = raw.span;
464
+ const milestone = raw.milestone;
465
+ const role = raw.role;
466
+ const conversion = raw.conversion;
467
+ if (start !== undefined && (typeof start !== 'number' || !Number.isFinite(start) || start < 0 || start > 999))
468
+ throw new Error('结构化卡片内容无效');
469
+ if (span !== undefined && (typeof span !== 'number' || !Number.isFinite(span) || span < 0 || span > 999))
470
+ throw new Error('结构化卡片内容无效');
471
+ if (milestone !== undefined && typeof milestone !== 'boolean')
472
+ throw new Error('结构化卡片内容无效');
473
+ if (role !== undefined && (typeof role !== 'string' || role.length > 120))
474
+ throw new Error('结构化卡片内容无效');
475
+ if (conversion !== undefined && (typeof conversion !== 'string' || conversion.length > 120))
476
+ throw new Error('结构化卡片内容无效');
477
+ if (typeof start === 'number')
478
+ clean.start = start;
479
+ if (typeof span === 'number')
480
+ clean.span = span;
481
+ if (milestone === true)
482
+ clean.milestone = true;
483
+ if (typeof role === 'string' && role.trim())
484
+ clean.role = role.trim();
485
+ if (typeof conversion === 'string' && conversion.trim())
486
+ clean.conversion = conversion.trim();
487
+ return clean;
488
+ });
489
+ }
151
490
  patch(value) {
152
491
  if (!value || typeof value !== 'object' || Array.isArray(value))
153
492
  throw new Error('修改内容无效');
493
+ const raw = value;
494
+ if (Object.hasOwn(raw, 'items') && Object.hasOwn(raw, 'cards'))
495
+ throw new Error('结构化卡片内容无效');
154
496
  const result = {};
155
- for (const [key, item] of Object.entries(value)) {
156
- if (['title', 'subtitle', 'kicker', 'text', 'notes'].includes(key)) {
497
+ for (const [key, item] of Object.entries(raw)) {
498
+ if (['title', 'subtitle', 'kicker', 'takeaway', 'source', 'text', 'notes'].includes(key)) {
157
499
  if (typeof item !== 'string' || item.length > 8000)
158
500
  throw new Error('文字字段过长或无效');
501
+ result[key] = item;
159
502
  }
160
503
  else if (key === 'bullets') {
161
504
  if (!Array.isArray(item) || item.length > 50 || item.some(v => typeof v !== 'string' || v.length > 2000))
162
505
  throw new Error('要点内容无效');
506
+ result[key] = item;
507
+ }
508
+ else if (key === 'layout') {
509
+ if (typeof item !== 'string' || !ALLOWED_LAYOUTS.has(item))
510
+ throw new Error('版式名称无效');
511
+ result.layout = item;
512
+ }
513
+ else if (key === 'variant') {
514
+ if (item !== null && item !== '' && (typeof item !== 'string' || !/^[a-z0-9-]{1,40}$/.test(item)))
515
+ throw new Error('版式变体名称过长或无效');
516
+ result.variant = item ? item : undefined;
517
+ }
518
+ else if (key === 'chrome') {
519
+ if (item !== null && item !== '' && (typeof item !== 'string' || !ALLOWED_CHROME_STYLES.has(item)))
520
+ throw new Error('母版骨架名称无效 / Invalid chrome skeleton style');
521
+ result.chrome = item ? item : undefined;
522
+ }
523
+ else if (key === 'tableStyle') {
524
+ if (item !== null && item !== '' && (typeof item !== 'string' || !ALLOWED_TABLE_STYLES.has(item)))
525
+ throw new Error('表格样式无效');
526
+ result.tableStyle = item ? item : undefined;
527
+ }
528
+ else if (key === 'items' || key === 'cards') {
529
+ result.items = this.itemsPatch(item);
530
+ }
531
+ else if (key === 'rows') {
532
+ if (!Array.isArray(item) || item.length < 1 || item.length > 50 || !Array.isArray(item[0]) || item[0].length < 1 || item[0].length > 12 ||
533
+ item.some(r => !Array.isArray(r) || r.length !== item[0].length || r.some(c => !((typeof c === 'string' && c.length <= 500) || (typeof c === 'number' && Number.isFinite(c)))))) {
534
+ throw new Error('表格内容需为 1–50 行、1–12 列的文字或有限数字,且每行格数一致');
535
+ }
536
+ result.rows = item;
537
+ }
538
+ else if (key === 'visual') {
539
+ if (item === null) {
540
+ result.visual = undefined;
541
+ continue;
542
+ }
543
+ if (!item || typeof item !== 'object' || Array.isArray(item))
544
+ throw new Error('排版设置无效或字号超出允许范围');
545
+ const v = item, out = {};
546
+ if (Object.keys(v).some(k => !VISUAL_KEYS.has(k)))
547
+ throw new Error('排版设置无效或字号超出允许范围');
548
+ const ranges = { titleSize: [24, 60], bodySize: [14, 28], chartLabelSize: [12, 24] };
549
+ for (const [vk, vv] of Object.entries(v)) {
550
+ if (vv === undefined)
551
+ continue;
552
+ if (ranges[vk]) {
553
+ const [min, max] = ranges[vk];
554
+ if (typeof vv !== 'number' || !Number.isInteger(vv) || vv < min || vv > max)
555
+ throw new Error('排版设置无效或字号超出允许范围');
556
+ out[vk] = vv;
557
+ }
558
+ else if (vk === 'density') {
559
+ if (typeof vv !== 'string' || !ALLOWED_DENSITIES.has(vv))
560
+ throw new Error('排版设置无效或字号超出允许范围');
561
+ out.density = vv;
562
+ }
563
+ else if (vk === 'tableStyle') {
564
+ if (typeof vv !== 'string' || !ALLOWED_TABLE_STYLES.has(vv))
565
+ throw new Error('表格样式无效');
566
+ out.tableStyle = vv;
567
+ }
568
+ else if (vk === 'chrome') {
569
+ if (vv === null)
570
+ continue;
571
+ if (typeof vv !== 'string' || !ALLOWED_CHROME_STYLES.has(vv))
572
+ throw new Error('母版骨架名称无效 / Invalid chrome skeleton style');
573
+ out.chrome = vv;
574
+ }
575
+ }
576
+ result.visual = out;
577
+ }
578
+ else if (key === 'columns') {
579
+ if (item === null) {
580
+ result.columns = undefined;
581
+ continue;
582
+ }
583
+ if (!Array.isArray(item) || item.length < 1 || item.length > 52 || item.some(c => typeof c !== 'string' || c.length > 120))
584
+ throw new Error('甘特图列头无效');
585
+ result.columns = item;
163
586
  }
164
587
  else if (key === 'image') {
165
588
  if (!item || typeof item !== 'object' || Array.isArray(item))
@@ -169,13 +592,26 @@ export class PptWorkbench {
169
592
  throw new Error('图片必须从面板上传,不能读取其他本地文件');
170
593
  if (['alt', 'caption'].some(k => image[k] !== undefined && (typeof image[k] !== 'string' || image[k].length > 2000)) || (image.fit !== undefined && !['contain', 'cover'].includes(String(image.fit))))
171
594
  throw new Error('图片说明或适应方式无效');
595
+ result.image = item;
172
596
  }
173
597
  else
174
598
  throw new Error('面板不支持修改此字段:' + key);
175
- result[key] = item;
176
599
  }
177
600
  return result;
178
601
  }
602
+ pptxBytes(raw) {
603
+ if (typeof raw !== 'string' || raw.length < 120)
604
+ throw new Error('请选择有效的参考 PPTX 文件(10 MiB 以内)');
605
+ const clean = raw.replace(/^data:[^;,]+;base64,/, '').replace(/\s+/g, '');
606
+ if (!clean || clean.length > 14_000_000 || clean.length % 4 === 1 || !/^[A-Za-z0-9+/]+={0,2}$/.test(clean)) {
607
+ throw new Error('请选择有效的参考 PPTX 文件(10 MiB 以内)');
608
+ }
609
+ const bytes = Buffer.from(clean, 'base64');
610
+ if (bytes.byteLength < 100 || bytes.byteLength > ABSORB_PPTX_LIMIT || bytes[0] !== 0x50 || bytes[1] !== 0x4b) {
611
+ throw new Error('请选择有效的参考 PPTX 文件(10 MiB 以内)');
612
+ }
613
+ return new Uint8Array(bytes);
614
+ }
179
615
  async action(body, signal) {
180
616
  signal?.throwIfAborted();
181
617
  if (body.operation === 'list')
@@ -210,6 +646,32 @@ export class PptWorkbench {
210
646
  return { ok: true, run: this.coaching.finish(context, body.runId) };
211
647
  if (body.operation === 'coach-delete')
212
648
  return { ok: true, ...this.coaching.remove(context, body.runId) };
649
+ if (body.operation === 'absorb-upload') {
650
+ if (body.expectedRevision !== undefined)
651
+ this.revision(body, manifest);
652
+ if (Object.hasOwn(body, 'pptxPath') || Object.hasOwn(body, 'path'))
653
+ throw new Error('图片必须从面板上传,不能读取其他本地文件');
654
+ if (typeof engine.absorbPptx !== 'function')
655
+ throw new Error('当前引擎版本暂不支持参考 PPTX 吸收');
656
+ const bytes = this.pptxBytes(body.data);
657
+ const absorbed = await engine.absorbPptx({ bytes, extractLogo: body.extractLogo !== false, signal });
658
+ return {
659
+ ok: true,
660
+ absorbed: {
661
+ slideCount: absorbed?.slideCount ?? 0,
662
+ slideSize: absorbed?.slideSize ?? null,
663
+ extractedPalette: absorbed?.extractedPalette ?? null,
664
+ extractedFonts: absorbed?.extractedFonts ?? null,
665
+ extractedSkeleton: absorbed?.extractedSkeleton ?? null,
666
+ sanitizedBrand: absorbed?.sanitizedBrand ?? null,
667
+ sanitizedTokens: absorbed?.sanitizedTokens ?? null,
668
+ recommendedTheme: absorbed?.recommendedTheme ?? null,
669
+ recommendedChrome: absorbed?.recommendedChrome ?? null,
670
+ slideSkeleton: absorbed?.slideSkeleton ?? null,
671
+ layoutSummary: absorbed?.layoutSummary ?? null,
672
+ },
673
+ };
674
+ }
213
675
  if (body.operation === 'download') {
214
676
  if (!['html', 'pptx', 'json'].includes(String(body.kind)))
215
677
  throw new Error('不支持此文件类型');
@@ -283,14 +745,28 @@ export class PptWorkbench {
283
745
  if (body.operation === 'edit') {
284
746
  if (body.slide !== undefined && (typeof body.slide !== 'string' || !manifest.slides.some((s) => s.id === body.slide)))
285
747
  throw new Error('页面不存在');
748
+ if (Object.hasOwn(body, 'referencePptx'))
749
+ throw new Error('图片必须从面板上传,不能读取其他本地文件');
286
750
  const args = { deckPath: entry.path, expectedRevision: body.expectedRevision, signal,
287
751
  saveAs: body.saveAs === true,
288
752
  ...(body.slide === undefined ? {} : { edits: [{ slide: body.slide, patch: this.patch(body.patch) }] }),
289
- ...(body.order === undefined ? {} : { order: body.order }) };
753
+ ...(body.order === undefined ? {} : { order: body.order }),
754
+ ...(body.theme === undefined ? {} : { theme: this.themeId(body.theme) }),
755
+ ...(body.brand === undefined ? {} : { brand: this.brandPatch(body.brand) }) };
290
756
  const result = await engine.editDeck(args);
291
757
  await this.remember(result, args);
292
758
  return { ...await this.view(digest(result.jsonPath)), changed: result.changed };
293
759
  }
760
+ if (body.operation === 'append') {
761
+ if (manifest.slides.length >= 120)
762
+ throw new Error('页数已达 120 页上限,无法继续新增页面');
763
+ const starter = starterSlide(body.archetype, manifest.language);
764
+ const args = { deckPath: entry.path, expectedRevision: body.expectedRevision, signal, saveAs: body.saveAs === true, append: [starter] };
765
+ const result = await engine.editDeck(args);
766
+ await this.remember(result, args);
767
+ const view = await this.view(digest(result.jsonPath));
768
+ return { ...view, selected: view.project.slides.at(-1)?.id };
769
+ }
294
770
  if (body.operation === 'duplicate' || body.operation === 'remove') {
295
771
  if (typeof body.slide !== 'string' || !manifest.slides.some((s) => s.id === body.slide))
296
772
  throw new Error('页面不存在');
@@ -343,7 +819,7 @@ export class PptWorkbench {
343
819
  const entries = {};
344
820
  let total = 0;
345
821
  const selected = kind === 'share' ? [files.html, files.pptx] : Object.values(files);
346
- const add = (name, content) => { total += content.byteLength; if (total > BUNDLE_LIMIT)
822
+ const add = (name, content) => { total += total >= 0 ? content.byteLength : 0; if (total > BUNDLE_LIMIT)
347
823
  return false; entries[name] = content; return true; };
348
824
  for (const path of selected) {
349
825
  if (!existsSync(path))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ppt",
3
- "version": "0.21.1",
3
+ "version": "0.22.1",
4
4
  "description": "DeepSeek Harness 演示文稿生成与编辑工作台:输入材料即可导出离线 HTML 放映、可编辑 PPTX 与工程包,支持按页编辑、数据推演与预审演练,以及原生清透 / 米白纸感 / Claude 暖书卷 / 8-Bit 像素 / 晴空薄荷五套明亮工作台主题。欢迎提交 issues 和 PR。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -60,7 +60,12 @@
60
60
  "pptx",
61
61
  "presentation",
62
62
  "slides",
63
- "html"
63
+ "html",
64
+ "deepseek",
65
+ "ai-agent",
66
+ "pptx-generator",
67
+ "演示文稿",
68
+ "幻灯片"
64
69
  ],
65
70
  "license": "MIT",
66
71
  "engines": {
@@ -86,7 +91,7 @@
86
91
  "csv-parse": "6.1.0",
87
92
  "fflate": "0.8.3",
88
93
  "jsep": "1.4.0",
89
- "@stardustlc/dsh-updates": "0.2.1"
94
+ "@stardustlc/dsh-updates": "0.2.2"
90
95
  },
91
96
  "peerDependencies": {
92
97
  "@deepseek-ai/libreoffice-kit": "0.1.5 || 0.2.3"