dsh-ppt 0.25.0 → 0.27.0

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 (48) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.en.md +14 -13
  3. package/README.md +14 -13
  4. package/docs/DATA.md +2 -2
  5. package/docs/REFERENCE.en.md +8 -8
  6. package/docs/REFERENCE.zh.md +8 -8
  7. package/docs/USAGE.en.md +12 -7
  8. package/docs/USAGE.md +12 -7
  9. package/docs/VALIDATION.md +8 -0
  10. package/docs/WORKBENCH.md +4 -4
  11. package/docs/assets/intro/workflow-en-dark.svg +1 -1
  12. package/docs/assets/intro/workflow-en-light.svg +1 -1
  13. package/docs/assets/intro/workflow-en-mobile-dark.svg +1 -1
  14. package/docs/assets/intro/workflow-en-mobile-light.svg +1 -1
  15. package/docs/assets/intro/workflow-zh-dark.svg +1 -1
  16. package/docs/assets/intro/workflow-zh-light.svg +1 -1
  17. package/docs/assets/intro/workflow-zh-mobile-dark.svg +1 -1
  18. package/docs/assets/intro/workflow-zh-mobile-light.svg +1 -1
  19. package/lib/client.js +312 -84
  20. package/lib/ecosystem.d.ts +73 -0
  21. package/lib/ecosystem.js +1352 -0
  22. package/lib/execution.d.ts +6 -1
  23. package/lib/execution.js +77 -4
  24. package/lib/tools.js +133 -1
  25. package/lib/types.d.ts +121 -1
  26. package/lib/workbench-language.js +4 -0
  27. package/lib/workbench.d.ts +2 -0
  28. package/lib/workbench.js +397 -10
  29. package/package.json +1 -1
  30. package/skills/dsh-ppt/SKILL.md +6 -6
  31. package/skills/dsh-ppt/package.json +1 -1
  32. package/skills/dsh-ppt/references/advanced.md +10 -5
  33. package/skills/dsh-ppt/references/syntax.md +1 -0
  34. package/skills/dsh-ppt/scripts/build-deck.mjs +53 -10
  35. package/skills/dsh-ppt/scripts/deck-absorb.mjs +114 -1
  36. package/skills/dsh-ppt/scripts/deck-advanced.mjs +153 -25
  37. package/skills/dsh-ppt/scripts/deck-chrome.mjs +1814 -0
  38. package/skills/dsh-ppt/scripts/deck-core.mjs +122 -6
  39. package/skills/dsh-ppt/scripts/deck-covers.mjs +804 -0
  40. package/skills/dsh-ppt/scripts/deck-delivery.mjs +636 -41
  41. package/skills/dsh-ppt/scripts/deck-diagrams.mjs +2842 -0
  42. package/skills/dsh-ppt/scripts/deck-director.mjs +167 -4
  43. package/skills/dsh-ppt/scripts/deck-icons.mjs +469 -0
  44. package/skills/dsh-ppt/scripts/deck-layouts.mjs +816 -5177
  45. package/skills/dsh-ppt/scripts/deck-media.mjs +159 -15
  46. package/skills/dsh-ppt/scripts/deck-mermaid.mjs +2737 -0
  47. package/skills/dsh-ppt/scripts/deck-office.mjs +1541 -0
  48. package/skills/dsh-ppt/scripts/deck-taste.mjs +347 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ppt-skill",
3
- "version": "0.24.0",
3
+ "version": "0.27.0",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "Standalone dsh-ppt skill dependencies for image/chart export",
@@ -83,15 +83,16 @@ Agent 先提炼真实内容与数据结论,再通过结构化参数生成可
83
83
 
84
84
  ---
85
85
 
86
- ## 五、双屏演讲者提词台、演讲讲义、按页编辑与撤销
86
+ ## 五、双屏演讲者提词台、配速预算、高管一页纸战报与按页编辑
87
87
 
88
- - **双屏演讲者提词台(独立 HTML 放映内置)**:按 **`P`** 或点击 `#presenter-toggle` 打开双屏控制窗口(通过 `BroadcastChannel` + `postMessage` 双向实时同步),支持当前页与下一页预览、大字号提词器(`A+ / A-` 缩放,无手写备注时自动回退为 `takeaway` 与要点提示)、正计时与目标配速倒计时、缩略图条快速跳页,以及按 **`L`** 在观众主屏同步投射虚拟激光笔!
89
- - **演讲讲义导出(`<slug>.handout.md`)**:HTML 检查面板内置「下载讲义 (.md)」按钮(客户端离线生成下载);CLI 传 `--handout`(或 API `handout: true`)可同时落盘 `<slug>.handout.md`,包含演示概览、预计总时长、每页核心指标/表格/要点与逐页演讲手稿。
88
+ - **双屏演讲者提词台与配速预算(`computePaceBudget`)**:按 **`P`** 或点击 `#presenter-toggle` 打开双屏控制窗口(通过 `BroadcastChannel` + `postMessage` 双向实时同步),支持当前页与下一页预览、大字号提词器(`A+ / A-` 缩放,无手写备注时自动回退为 `takeaway` 与要点提示)、正计时与目标配速倒计时、逐页演讲预算徽章(按中文 `220 字/分`、英文 `145 词/分` + 图表/图示 `+12s` 理解缓冲测算,超 `1.45x` 目标切片或 `>150s` 自动标红 `over-budget`),以及按 **`L`** 在观众主屏同步投射虚拟激光笔!
89
+ - **演讲讲义与高管一页纸战报(`.handout.md` / `.onepager.html`)**:HTML 检查面板内置「下载讲义 (.md)」与「下载一页纸战报 (.html)」离线 `Blob` 下载按钮(默认仍严格保持 3 件套落盘不变);CLI 传 `--handout` / `--one-pager`(或 API `handout: true` / `onePager: true`)可同步落盘,其中高管一页纸支持 **A4 打印版 ↔ 移动端长图战报(Mobile Long-Card)** 一键切换,浓缩展示核心结论、KPI 条、关键图表/表格/流程图摘要、支柱行动与逐页配速预算。
90
+ - **Office 文件直吞引擎(`ppt_from_office` / `--from-office`)**:零新增依赖直读 `.xlsx` / `.csv` / `.tsv`(自动识别 `[Source, Target, Amount]` 桑基图、任务排期甘特图、市场份额 Marimekko、增减桥瀑布图、>10x 量纲差双轴组合图、通用 `chart-split` + 明细附录表)与 `.docx` Word 报告(标题/中文编号标题、加粗导语、Word 表格、嵌入图片、Mermaid 代码块与 `$...$` 公式),直出完整 5–20 页演示工程。
90
91
 
91
92
  1. **先查后改**:调 `ppt_check { deckPath: "report.json" }` 获取当前 `revision` 与稳定页面 `id`。
92
93
  2. **原子编辑(`ppt_edit`)**:
93
- - **单页局部补丁 `edits`**:支持修改 `title, subtitle, kicker, takeaway, source, formula, layout, variant, chrome, tableStyle, bullets, items, columns, rows, image, images, chart, notes, visual`(`slide` 传 1 起始页码或稳定 ID)。
94
- - **整套换肤与品牌更新**:顶层可传 `theme: "exec-jilan"`、`referencePptx: "ref.pptx"` 或 `brand`(`brand: null` 清空品牌,`logo: null` 清空 Logo)。
94
+ - **单页局部补丁 `edits`**:支持修改 `title, subtitle, kicker, takeaway, source, formula, mermaid, layout, variant, chrome, tableStyle, bullets, items, columns, rows, image, images, chart, notes, visual`(`slide` 传 1 起始页码或稳定 ID)。
95
+ - **整套换肤、目标时长与品牌更新**:顶层可传 `theme: "exec-jilan"`、`targetMinutes: 12`、`referencePptx: "ref.pptx"` 或 `brand`(`brand: null` 清空品牌,`logo: null` 清空 Logo)。
95
96
  - **追加、复制、排序与删除**:`append: [slide1, ...]`(单次追加 1–5 页新页面)、`duplicate: [2]`、`remove: [4]`、`order: [id1, id2, ...]`(包含全部原始页面 ID 各一次;执行顺序:先编辑/排序,再复制/删除/追加,最终保留 1–120 页)。
96
97
  - 每次修改原子重写 HTML / PPTX / JSON,失败自动回滚,保留最近 20 步历史。
97
98
  3. **一键撤销(`ppt_undo`)**:`ppt_undo { deckPath: "report.json", expectedRevision: 1 }` 完整恢复上一状态(含主题、页面结构、图表、图片与数据模型),`revision` 单调递增。
@@ -126,6 +127,10 @@ node scripts/build-deck.mjs --absorb corp.pptx
126
127
  # 全量导入旧 PPTX 并一键翻新(支持 --preserve-theme 与 --handout)
127
128
  node scripts/build-deck.mjs --import-pptx legacy.pptx --theme auto --handout --out dist
128
129
 
130
+ # 直吞 Excel/CSV/TSV/Word 生成全套演示文稿(可选 --target-minutes 与 --one-pager)
131
+ node scripts/build-deck.mjs --from-office financials.xlsx --theme auto --target-minutes 10 --one-pager --out dist
132
+ node scripts/build-deck.mjs --from-office annual-report.docx --theme consulting --handout --out dist
133
+
129
134
  # 将 Office 修改后的 PPTX 导回已有工程(自动快照至 .history/ 支持撤销)
130
135
  node scripts/build-deck.mjs --sync-pptx dist/deck.pptx --edit dist/deck.json
131
136
 
@@ -32,6 +32,7 @@
32
32
  | **`harvey`** | `matrix` | `kicker, title, rows[][]`(支持 `● ◕ ◑ ◔ ○ ✓ ✗` 或 `100%/75%/50%/25%/0%`) | **麦肯锡式哈维球竞品/能力矩阵**:自动高亮「本方案 / Ours」列并将符号渲染为精确矢量圆球 |
33
33
  | **`tam`** | `concentric` | `kicker, title, items[]`(3 项 TAM/SAM/SOM,含 `value, title, text`) | **同心圆市场空间测算图**:左侧 3 个底切原生同心椭圆 + 右侧 3 张规模与口径说明卡 |
34
34
  | **`org`** | `tree \| team` | `kicker, title, items[]`(`tree` 首项为根节点,2–5 项为子节点;`team` 2–4 人) | **组织架构树 / 核心管理团队介绍**:`tree` 带正交直角连接线;`team` 带圆标首字母头像与履历标签 |
35
+ | **`mermaid`** | `flowchart \| sequence`(亦支持顶层别名) | `kicker, title, mermaid`(Mermaid 代码串), `takeaway` | **原生可编辑 Mermaid 流程图与时序图**:Markdown 中 ```` ```mermaid ```` 自动识别,PPTX 编译为带附着连接点(`stCxn`/`endCxn`)的原生矢量图形与箭头 |
35
36
  | `closing` | `standard \| cta-cards \| inverted` | `kicker, title, subtitle, items / bullets` | 结束与行动号召页(自动隐藏页码;支持下一步行动卡片,拒绝孤立「谢谢」) |
36
37
 
37
38
  ### B. 5 套媒体与出版级图表版式(`@office-kit/pptx` 增强)
@@ -17,7 +17,7 @@ import { resolve as resolvePath } from 'node:path'
17
17
  import { pathToFileURL } from 'node:url'
18
18
  import { listThemes, THEME_IDS, DEFAULT_THEME } from './deck-themes.mjs'
19
19
  import { CHROME_STYLE_IDS } from './deck-absorb.mjs'
20
- import { buildDeckAsync, listTemplates, editDeck, undoDeck, checkDeckAsync, renderDeck, absorbPptx, importPptxDeck } from './deck-advanced.mjs'
20
+ import { buildDeckAsync, listTemplates, editDeck, undoDeck, checkDeckAsync, renderDeck, absorbPptx, importPptxDeck, importOfficeDeck, listAllTasteRecipes } from './deck-advanced.mjs'
21
21
 
22
22
  const HELP = `dsh-ppt —— 一句话 / 一篇文档 → HTML 放映 + PPTX 导出
23
23
 
@@ -33,17 +33,23 @@ const HELP = `dsh-ppt —— 一句话 / 一篇文档 → HTML 放映 + PPTX 导
33
33
  --reference-pptx <path> 只读吸收本地参考 .pptx 的净化双色板、双字体、封面反白、母版 Logo 与骨架
34
34
  --clone-structure 配合 --reference-pptx 使用,克隆参考文稿的逐页版式骨架与母版 chrome
35
35
  --chrome <style> 母版骨架风格:${CHROME_STYLE_IDS.join(' / ')}
36
- --absorb <deck.pptx> 只读检查并输出参考 .pptx 的净化主题、推荐内置主题/骨架与逐页分布 JSON
36
+ --taste <id> 大师审美配方 ID(mckinsey-partner / apple-keynote-dark / apple-keynote-light / swiss-editorial / linear-craft / ft-data-journal / nature-academic / oriental-zen 或已吸收自定义 ID)
37
+ --save-taste <id> 配合 --absorb 将标杆 .pptx 深度提炼并保存为可复用品味配方
38
+ --list-tastes 列出内置 8 套大师审美配方及当前工作区已吸收的标杆配方
39
+ --absorb <deck.pptx> 只读检查并输出参考 .pptx 的净化主题、推荐内置主题/骨架、深度审美配方 styleRecipe 与逐页分布 JSON
37
40
  --import-pptx <path> 导入外部 .pptx 全量内容(标题/要点/表格/图表/图片/备注)并一键翻新为 dsh-ppt 工程
41
+ --from-office <path> 直吞 .xlsx / .csv / .tsv / .docx 数据表或 Word 报告,自动画像并生成全套文稿
38
42
  --sync-pptx <path> 将 Office 修改后的 .pptx 内容回导同步至已有工程(自动写入 .history/ 支持撤销)
39
43
  --target-project <dir> 配合 --sync-pptx 指定目标工程目录(或传 --edit <deck.json>)
40
44
  --preserve-theme 配合 --import-pptx 使用,保留原 .pptx 净化后的品牌配色与 Logo
41
45
  --no-modernize 配合 --import-pptx/--sync-pptx 关闭自动版式升维
42
46
  --handout 同时生成 <file>.handout.md 演讲者讲义与逐字稿文件
47
+ --one-pager 同时生成 <file>.onepager.html 高管一页纸战报(默认不额外写盘,可在检查面板离线导出)
48
+ --target-minutes <n> 指定演讲目标总时长(分钟),计算逐页配速预算并标记超预算页
43
49
  --smart-layout 显式开启多版式叙事节奏自动升维(配合 --no-smart-layout 可关闭)
44
50
  --brand <json|@path> 品牌主辅颜色、标题/正文字体、封面反白、Logo、页脚、chromeStyle
45
51
  --data-model <json|@path> 可选数字来源、公式与推演假设;配合 --slides
46
- --edit <deck.json> 修改指定页或整套换肤,配合 --edits / --theme / --reference-pptx / --brand
52
+ --edit <deck.json> 修改指定页或整套换肤,配合 --edits / --theme / --reference-pptx / --brand / --target-minutes
47
53
  --edits <json|@path> 页面修改指令数组
48
54
  --undo <deck.json> 撤销最近一次修改
49
55
  --check <deck.json> 查看质量报告和页码 / ID
@@ -64,10 +70,11 @@ const HELP = `dsh-ppt —— 一句话 / 一篇文档 → HTML 放映 + PPTX 导
64
70
  --help 显示本帮助
65
71
 
66
72
  输出:
67
- <file>.html 独立网页放映(无外链,支持按 P 启动双屏演讲者提词台、按 L 开启虚拟激光笔)
68
- <file>.pptx 可编辑 PPTX(16:9)
69
- <file>.json deck manifest
70
- <file>.handout.md 演讲者讲义(传 --handout 时同步落盘,HTML 检查面板随时可下载)
73
+ <file>.html 独立网页放映(无外链,支持按 P 启动双屏演讲者提词台、按 L 开启虚拟激光笔)
74
+ <file>.pptx 可编辑 PPTX(16:9)
75
+ <file>.json deck manifest
76
+ <file>.handout.md 演讲者讲义(传 --handout 时同步落盘,HTML 检查面板随时可下载)
77
+ <file>.onepager.html 高管一页纸战报(传 --one-pager 时同步落盘,HTML 检查面板随时可下载)
71
78
  `
72
79
 
73
80
  export function parseArgv(argv) {
@@ -87,11 +94,14 @@ export function parseArgv(argv) {
87
94
  if (key === '--help' || key === '-h') args.help = true
88
95
  else if (key === '--list-themes') args.listThemes = true
89
96
  else if (key === '--list-templates') args.listTemplates = true
97
+ else if (key === '--list-tastes') args.listTastes = true
90
98
  else if (key === '--overwrite') args.overwrite = true
91
99
  else if (key === '--smart-layout') args.smartLayout = true
92
100
  else if (key === '--no-smart-layout') args.smartLayout = false
93
101
  else if (key === '--clone-structure') args.cloneStructure = true
94
102
  else if (key === '--chrome') args.chrome = nextValue()
103
+ else if (key === '--taste') args.taste = nextValue()
104
+ else if (key === '--save-taste') args.saveTaste = nextValue()
95
105
  else if (key === '--title') args.title = nextValue()
96
106
  else if (key === '--content') args.content = nextValue()
97
107
  else if (key === '--slides') args.slides = readJson(nextValue())
@@ -100,11 +110,14 @@ export function parseArgv(argv) {
100
110
  else if (key === '--reference-pptx') args.referencePptx = nextValue()
101
111
  else if (key === '--absorb') args.absorb = nextValue()
102
112
  else if (key === '--import-pptx') args.importPptx = nextValue()
113
+ else if (key === '--from-office') args.fromOffice = nextValue()
103
114
  else if (key === '--sync-pptx') args.syncPptx = nextValue()
104
115
  else if (key === '--target-project') args.targetProject = nextValue()
105
116
  else if (key === '--preserve-theme') args.preserveTheme = true
106
117
  else if (key === '--no-modernize') args.modernize = false
107
118
  else if (key === '--handout') args.handout = true
119
+ else if (key === '--one-pager') args.onePager = true
120
+ else if (key === '--target-minutes') args.targetMinutes = Number(nextValue())
108
121
  else if (key === '--brand') args.brand = readJson(nextValue())
109
122
  else if (key === '--data-model') args.dataModel = readJson(nextValue())
110
123
  else if (key === '--edit') args.edit = nextValue()
@@ -152,11 +165,32 @@ export async function main(argv = process.argv.slice(2), io = {}) {
152
165
  return 0
153
166
  }
154
167
  if (args.listTemplates) { log(JSON.stringify({ templates: listTemplates(args.lang) }, null, 2)); return 0 }
155
- if ([args.edit && !args.syncPptx ? args.edit : null, args.undo, args.check, args.render, args.absorb, args.importPptx, args.syncPptx].filter(Boolean).length > 1) {
156
- throw new Error('dsh-ppt CLI:--edit / --undo / --check / --render / --absorb / --import-pptx / --sync-pptx 只能选择一项')
168
+ if (args.listTastes) { log(JSON.stringify({ tasteRecipes: listAllTasteRecipes(process.cwd()) }, null, 2)); return 0 }
169
+ if ([args.edit && !args.syncPptx ? args.edit : null, args.undo, args.check, args.render, args.absorb, args.importPptx, args.syncPptx, args.fromOffice].filter(Boolean).length > 1) {
170
+ throw new Error('dsh-ppt CLI:--edit / --undo / --check / --render / --absorb / --import-pptx / --sync-pptx / --from-office 只能选择一项')
157
171
  }
158
172
  if (args.renderReceipt !== undefined && !args.check) throw new Error('dsh-ppt CLI:--render-receipt 需配合 --check')
159
173
  if (!args.render && [args.format, args.width, args.timeoutMs].some(v => v !== undefined)) throw new Error('dsh-ppt CLI:--format / --width / --timeout 需配合 --render')
174
+ if (args.fromOffice) {
175
+ const imported = await importOfficeDeck({
176
+ filePath: args.fromOffice,
177
+ outDir: resolvePath(args.out || '.'),
178
+ outputDir: resolvePath(args.out || '.'),
179
+ ...(args.title ? { title: args.title } : {}),
180
+ ...(args.file ? { fileName: args.file } : {}),
181
+ ...(args.theme ? { theme: args.theme } : {}),
182
+ ...(args.persona ? { persona: args.persona } : {}),
183
+ ...(args.chrome ? { chromeStyle: args.chrome } : {}),
184
+ ...(args.lang ? { lang: args.lang } : {}),
185
+ ...(args.motion ? { motion: args.motion } : {}),
186
+ ...(args.targetMinutes !== undefined ? { targetMinutes: args.targetMinutes } : {}),
187
+ overwrite: args.overwrite === true,
188
+ handout: args.handout === true,
189
+ onePager: args.onePager === true,
190
+ })
191
+ log(JSON.stringify(imported, null, 2))
192
+ return 0
193
+ }
160
194
  if (args.importPptx || args.syncPptx) {
161
195
  const imported = await importPptxDeck({
162
196
  pptxPath: args.importPptx || args.syncPptx,
@@ -182,7 +216,10 @@ export async function main(argv = process.argv.slice(2), io = {}) {
182
216
  return 0
183
217
  }
184
218
  if (args.absorb) {
185
- const absorbed = await absorbPptx({ pptxPath: args.absorb })
219
+ const absorbed = await absorbPptx({
220
+ pptxPath: args.absorb,
221
+ ...(args.saveTaste ? { saveTasteAs: args.saveTaste } : {}),
222
+ })
186
223
  log(JSON.stringify(absorbed, null, 2))
187
224
  return 0
188
225
  }
@@ -204,8 +241,10 @@ export async function main(argv = process.argv.slice(2), io = {}) {
204
241
  deckPath: args.edit,
205
242
  edits: args.edits,
206
243
  theme: args.theme,
244
+ ...(args.taste ? { taste: args.taste } : {}),
207
245
  referencePptx: args.referencePptx,
208
246
  brand: effectiveBrand,
247
+ ...(args.targetMinutes !== undefined ? { targetMinutes: args.targetMinutes } : {}),
209
248
  expectedRevision: args.revision,
210
249
  })
211
250
  : await undoDeck({ deckPath: args.undo, expectedRevision: args.revision })
@@ -230,6 +269,7 @@ export async function main(argv = process.argv.slice(2), io = {}) {
230
269
  content,
231
270
  slides,
232
271
  theme: args.theme,
272
+ ...(args.taste ? { taste: args.taste } : {}),
233
273
  persona: args.persona,
234
274
  referencePptx: args.referencePptx,
235
275
  cloneStructure: args.cloneStructure,
@@ -243,6 +283,8 @@ export async function main(argv = process.argv.slice(2), io = {}) {
243
283
  brand: effectiveBrand,
244
284
  dataModel: args.dataModel,
245
285
  ...(args.handout ? { handout: true } : {}),
286
+ ...(args.onePager ? { onePager: true } : {}),
287
+ ...(args.targetMinutes !== undefined ? { targetMinutes: args.targetMinutes } : {}),
246
288
  }
247
289
  const result = await buildDeckAsync(options)
248
290
  log('dsh-ppt 已生成 ' + result.slideCount + ' 页演示文稿:')
@@ -250,6 +292,7 @@ export async function main(argv = process.argv.slice(2), io = {}) {
250
292
  log(' PPTX 导出:' + result.pptxPath)
251
293
  log(' Manifest :' + result.jsonPath)
252
294
  if (result.handoutPath) log(' 讲义 Handout:' + result.handoutPath)
295
+ if (result.onePagerPath) log(' 高管一页纸:' + result.onePagerPath)
253
296
  if (result.deliveryStatus === 'draft') log(' 草稿:还有待填写内容,不可作为成品交付。')
254
297
  log(' 质量检查:' + result.quality.errorCount + ' 个错误 / ' + result.quality.warningCount + ' 个提醒;修订号 ' + result.revision)
255
298
  return 0
@@ -14,9 +14,10 @@
14
14
  */
15
15
 
16
16
  import { lstatSync, readFileSync } from 'node:fs'
17
- import { resolve } from 'node:path'
17
+ import { basename, resolve } from 'node:path'
18
18
  import { inflateSync } from 'node:zlib'
19
19
  import { sanitizeAbsorbedTheme, normalizeHex, hexToHsl, relativeLuminance } from './deck-themes.mjs'
20
+ import { sanitizeCustomTasteRecipe, saveWorkspaceTasteRecipe } from './deck-taste.mjs'
20
21
 
21
22
  const MAX_PPTX_BYTES = 64 * 1024 * 1024
22
23
  const MAX_LOGO_BYTES = 2 * 1024 * 1024
@@ -1316,6 +1317,116 @@ export async function absorbPptx(options = {}) {
1316
1317
  recommendedTableStyle,
1317
1318
  }
1318
1319
 
1320
+ // Phase 6:深度审美 DNA 提炼(留白比、卡片材质倾向、字阶倍率、封面构图、跨页节奏分 -> 可复用 StyleRecipe)
1321
+ const canvasArea = Math.max(1, widthEmu * heightEmu)
1322
+ let wsSamples = []
1323
+ let filledBoxCount = 0
1324
+ let totalContentShapes = 0
1325
+ let maxTitlePt = 0
1326
+ const bodyPts = []
1327
+ for (const s of slides.slice(1, 9)) {
1328
+ try {
1329
+ const shs = flattenShapes(lib, lib.getSlideShapes(s) ?? [])
1330
+ let covered = 0
1331
+ for (const sh of shs) {
1332
+ const b = getBoundsSafe(lib, sh)
1333
+ if (!b || b.w <= 0 || b.h <= 0) continue
1334
+ if (b.w >= widthEmu * 0.88 && b.h >= heightEmu * 0.88) continue
1335
+ totalContentShapes += 1
1336
+ covered += Math.min(canvasArea * 0.45, b.w * b.h)
1337
+ const fill = resolveShapeFillSafe(lib, pres, sh, rawTheme, colorMap)
1338
+ if (fill) filledBoxCount += 1
1339
+ const xml = typeof sh?.xml === 'string' ? sh.xml : ''
1340
+ for (const m of xml.matchAll(/\bsz="(\d{3,4})"/g)) {
1341
+ const pt = Number(m[1]) / 100
1342
+ if (pt >= 22 && pt <= 72) maxTitlePt = Math.max(maxTitlePt, pt)
1343
+ else if (pt >= 10 && pt <= 20) bodyPts.push(pt)
1344
+ }
1345
+ }
1346
+ wsSamples.push(Math.max(0.18, Math.min(0.82, 1 - Math.min(0.82, covered / canvasArea))))
1347
+ } catch { /* ignore */ }
1348
+ }
1349
+ const whitespaceRatio = wsSamples.length > 0
1350
+ ? Number((wsSamples.reduce((a, b) => a + b, 0) / wsSamples.length).toFixed(2))
1351
+ : 0.48
1352
+ const density = whitespaceRatio >= 0.54 ? 'airy' : whitespaceRatio < 0.34 ? 'compact' : 'balanced'
1353
+ const filledRatio = totalContentShapes > 0 ? filledBoxCount / totalContentShapes : 0.4
1354
+ const inferredCardMaterial = sanitized.dark && rawSkeleton.cornerStyle !== 'sharp'
1355
+ ? 'glass'
1356
+ : recommendedChrome === 'editorial-folio'
1357
+ ? 'editorial-rule'
1358
+ : (filledRatio < 0.28 || whitespaceRatio >= 0.58)
1359
+ ? 'frameless'
1360
+ : 'solid'
1361
+ const medianBodyPt = bodyPts.length > 0
1362
+ ? bodyPts.sort((a, b) => a - b)[Math.floor(bodyPts.length / 2)]
1363
+ : 15
1364
+ const typeScaleRatio = maxTitlePt > 0
1365
+ ? Number(Math.max(1.4, Math.min(3.0, maxTitlePt / Math.max(11, medianBodyPt))).toFixed(2))
1366
+ : (recommendedChrome === 'keynote-spatial' ? 2.2 : 1.8)
1367
+ const coverVariant = sanitized.dark
1368
+ ? 'keynote-glow'
1369
+ : recommendedChrome === 'editorial-folio'
1370
+ ? 'editorial-grid'
1371
+ : sanitized.sanitizedTokens.coverMode === 'inverted-accent'
1372
+ ? 'inverted'
1373
+ : rawSkeleton.hasSideSpine
1374
+ ? 'architectural'
1375
+ : 'architectural'
1376
+ const sectionCount = slideSkeleton.filter((s) => s.inferredLayout === 'section').length
1377
+ let layoutTransitions = 0
1378
+ for (let i = 1; i < slideSkeleton.length; i += 1) {
1379
+ if (slideSkeleton[i].inferredLayout !== slideSkeleton[i - 1].inferredLayout) layoutTransitions += 1
1380
+ }
1381
+ const rhythmScore = slideSkeleton.length > 1
1382
+ ? Math.round((layoutTransitions / (slideSkeleton.length - 1)) * 100)
1383
+ : 85
1384
+
1385
+ const baseId = String(options.saveTasteAs || coreTitle || (resolvedPath ? basename(resolvedPath, '.pptx') : 'absorbed-deck'))
1386
+ .toLowerCase()
1387
+ .replace(/[^a-z0-9\u4e00-\u9fff]+/g, '-')
1388
+ .replace(/^-|-$/g, '')
1389
+ .slice(0, 48) || 'absorbed-taste'
1390
+
1391
+ const styleRecipe = sanitizeCustomTasteRecipe({
1392
+ id: baseId,
1393
+ name: options.tasteName || coreTitle || (resolvedPath ? basename(resolvedPath, '.pptx') : '吸收的标杆品味'),
1394
+ enName: options.tasteName || coreTitle || baseId,
1395
+ school: recommendedChrome,
1396
+ description: `提取自标杆 PPTX(${slideCount} 页):${recommendedChrome} 骨架 · ${inferredCardMaterial} 材质 · 留白率 ${Math.round(whitespaceRatio * 100)}%`,
1397
+ enDescription: `Absorbed benchmark (${slideCount} slides): ${recommendedChrome} chrome, ${inferredCardMaterial} cards, ${Math.round(whitespaceRatio * 100)}% whitespace`,
1398
+ theme: sanitized.recommendedTheme,
1399
+ chromeStyle: recommendedChrome,
1400
+ tableStyle: recommendedTableStyle,
1401
+ cardMaterial: inferredCardMaterial,
1402
+ coverVariant,
1403
+ sectionVariant: sectionCount >= 2 ? 'agenda' : 'default',
1404
+ kpiVariant: whitespaceRatio >= 0.46 ? 'spotlight' : 'grid',
1405
+ cardsVariant: inferredCardMaterial === 'frameless' ? 'frameless' : (sanitized.dark ? 'bento-hero' : 'pillars'),
1406
+ iconMode: recommendedChrome === 'keynote-spatial' || recommendedChrome === 'saas-bento' ? 'auto' : 'explicit',
1407
+ iconBadgeStyle: inferredCardMaterial === 'frameless' ? 'bare' : (inferredCardMaterial === 'glass' ? 'ring' : 'soft'),
1408
+ chartSpotlight: true,
1409
+ chartGrowthCallout: chartCount > 0,
1410
+ density,
1411
+ typeScaleRatio,
1412
+ whitespaceRatio,
1413
+ rhythmScore,
1414
+ brand: sanitizedBrand,
1415
+ swatches: [
1416
+ sanitized.sanitizedTokens.canvas,
1417
+ sanitized.sanitizedTokens.accentPrimary,
1418
+ sanitized.sanitizedTokens.accentSecondary,
1419
+ sanitized.sanitizedTokens.inkPrimary,
1420
+ ],
1421
+ ...(resolvedPath ? { sourceFile: basename(resolvedPath) } : {}),
1422
+ })
1423
+
1424
+ let savedTastePath
1425
+ if (typeof options.saveTasteAs === 'string' && options.saveTasteAs.trim()) {
1426
+ const saved = saveWorkspaceTasteRecipe(styleRecipe, cwd)
1427
+ savedTastePath = saved.path
1428
+ }
1429
+
1319
1430
  return {
1320
1431
  ok: true,
1321
1432
  ...(resolvedPath ? { pptxPath: resolvedPath } : {}),
@@ -1329,6 +1440,8 @@ export async function absorbPptx(options = {}) {
1329
1440
  recommendedChrome,
1330
1441
  recommendedTableStyle,
1331
1442
  narrativeProfile,
1443
+ styleRecipe,
1444
+ ...(savedTastePath ? { savedTastePath } : {}),
1332
1445
  dark: sanitized.dark,
1333
1446
  warnings: sanitized.warnings,
1334
1447
  layoutSummary,