dsh-ppt 0.26.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 (33) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.en.md +5 -4
  3. package/README.md +5 -4
  4. package/docs/USAGE.en.md +1 -0
  5. package/docs/USAGE.md +1 -0
  6. package/docs/VALIDATION.md +4 -0
  7. package/docs/assets/intro/workflow-en-dark.svg +1 -1
  8. package/docs/assets/intro/workflow-en-light.svg +1 -1
  9. package/docs/assets/intro/workflow-en-mobile-dark.svg +1 -1
  10. package/docs/assets/intro/workflow-en-mobile-light.svg +1 -1
  11. package/docs/assets/intro/workflow-zh-dark.svg +1 -1
  12. package/docs/assets/intro/workflow-zh-light.svg +1 -1
  13. package/docs/assets/intro/workflow-zh-mobile-dark.svg +1 -1
  14. package/docs/assets/intro/workflow-zh-mobile-light.svg +1 -1
  15. package/lib/client.js +83 -9
  16. package/lib/execution.js +8 -4
  17. package/lib/tools.js +56 -1
  18. package/lib/types.d.ts +64 -0
  19. package/lib/workbench.js +67 -3
  20. package/package.json +1 -1
  21. package/skills/dsh-ppt/SKILL.md +3 -3
  22. package/skills/dsh-ppt/package.json +1 -1
  23. package/skills/dsh-ppt/scripts/build-deck.mjs +15 -3
  24. package/skills/dsh-ppt/scripts/deck-absorb.mjs +114 -1
  25. package/skills/dsh-ppt/scripts/deck-advanced.mjs +106 -15
  26. package/skills/dsh-ppt/scripts/deck-chrome.mjs +114 -6
  27. package/skills/dsh-ppt/scripts/deck-core.mjs +6 -0
  28. package/skills/dsh-ppt/scripts/deck-covers.mjs +804 -0
  29. package/skills/dsh-ppt/scripts/deck-director.mjs +118 -1
  30. package/skills/dsh-ppt/scripts/deck-icons.mjs +469 -0
  31. package/skills/dsh-ppt/scripts/deck-layouts.mjs +519 -92
  32. package/skills/dsh-ppt/scripts/deck-media.mjs +159 -15
  33. package/skills/dsh-ppt/scripts/deck-taste.mjs +347 -0
package/lib/workbench.js CHANGED
@@ -28,8 +28,10 @@ const ALLOWED_TABLE_STYLES = new Set(['consulting', 'booktabs', 'minimal', 'band
28
28
  const ALLOWED_DENSITIES = new Set(['compact', 'balanced', 'airy']);
29
29
  const ALLOWED_ITEM_STATUS = new Set(['neutral', 'accent', 'positive', 'negative', 'warning']);
30
30
  const ALLOWED_CHROME_STYLES = new Set(['consulting-classic', 'keynote-spatial', 'editorial-folio', 'saas-bento', 'academic-minimal', 'gov-ceremonial']);
31
- const ITEM_KEYS = new Set(['tag', 'badge', 'title', 'text', 'body', 'value', 'unit', 'delta', 'start', 'span', 'milestone', 'role', 'conversion', 'status', 'tone', 'bullets']);
32
- const BRAND_KEYS = new Set(['name', 'primaryColor', 'secondaryColor', 'backgroundColor', 'textColor', 'fontFamily', 'headingFont', 'coverMode', 'coverBg', 'logo', 'footer', 'chromeStyle']);
31
+ const ALLOWED_CARD_MATERIALS = new Set(['solid', 'frameless', 'glass', 'editorial-rule']);
32
+ const ALLOWED_ICON_MODES = new Set(['off', 'explicit', 'auto']);
33
+ const ITEM_KEYS = new Set(['tag', 'badge', 'title', 'text', 'body', 'value', 'unit', 'delta', 'start', 'span', 'milestone', 'role', 'conversion', 'icon', 'status', 'tone', 'bullets']);
34
+ const BRAND_KEYS = new Set(['name', 'primaryColor', 'secondaryColor', 'backgroundColor', 'textColor', 'fontFamily', 'headingFont', 'coverMode', 'coverBg', 'logo', 'footer', 'chromeStyle', 'cardMaterial', 'iconMode', 'taste']);
33
35
  const VISUAL_KEYS = new Set(['titleSize', 'bodySize', 'chartLabelSize', 'density', 'tableStyle', 'chrome']);
34
36
  /** Sharing keeps the offline deck, but omits the control for a project not in the ZIP. */
35
37
  function shareHtml(bytes) {
@@ -442,6 +444,7 @@ export class PptWorkbench {
442
444
  const langCode = manifest.language === 'en' ? 'en' : 'zh';
443
445
  const themes = typeof engine.listThemes === 'function' ? engine.listThemes(langCode) : [];
444
446
  const presets = typeof engine.listMasterPresets === 'function' ? engine.listMasterPresets(langCode) : [];
447
+ const tasteRecipes = typeof engine.listAllTasteRecipes === 'function' ? engine.listAllTasteRecipes(dirname(entry.path)) : [];
445
448
  const rawPace = typeof engine.computePaceBudget === 'function'
446
449
  ? engine.computePaceBudget(manifest, manifest.targetMinutes)
447
450
  : computePaceBudgetFallback(manifest, manifest.targetMinutes);
@@ -466,7 +469,8 @@ export class PptWorkbench {
466
469
  deltaMinutes,
467
470
  };
468
471
  return { ok: true, project: { ...entry, deckId: manifest.deckId, revision: manifest.revision, theme: manifest.theme ?? 'data',
469
- brand: manifest.brand ?? null, targetMinutes: manifest.targetMinutes ?? null, paceBudget, themes, presets, slides: manifest.slides,
472
+ taste: manifest.taste ?? null,
473
+ brand: manifest.brand ?? null, targetMinutes: manifest.targetMinutes ?? null, paceBudget, themes, presets, tasteRecipes, slides: manifest.slides,
470
474
  undoAvailable: manifest.history.length, quality: check, html, dataModel: manifest.dataModel ?? null,
471
475
  assets: Object.fromEntries(Object.entries(manifest.assets ?? {}).map(([key, value]) => [key, { data: value.data, mime: value.mime }])),
472
476
  render: currentRender ? { pageCount: currentRender.pngPaths.length, missingFonts: currentRender.missingFonts ?? [] } : null } };
@@ -534,6 +538,33 @@ export class PptWorkbench {
534
538
  throw new Error('母版骨架名称无效 / Invalid chrome skeleton style');
535
539
  out.chromeStyle = item;
536
540
  }
541
+ else if (key === 'cardMaterial') {
542
+ if (item === null || item === '') {
543
+ out.cardMaterial = null;
544
+ continue;
545
+ }
546
+ if (typeof item !== 'string' || !ALLOWED_CARD_MATERIALS.has(item))
547
+ throw new Error('卡片材质名称无效 / Invalid cardMaterial');
548
+ out.cardMaterial = item;
549
+ }
550
+ else if (key === 'iconMode') {
551
+ if (item === null || item === '') {
552
+ out.iconMode = null;
553
+ continue;
554
+ }
555
+ if (typeof item !== 'string' || !ALLOWED_ICON_MODES.has(item))
556
+ throw new Error('图标模式无效 / Invalid iconMode');
557
+ out.iconMode = item;
558
+ }
559
+ else if (key === 'taste') {
560
+ if (item === null || item === '') {
561
+ out.taste = null;
562
+ continue;
563
+ }
564
+ if (typeof item !== 'string' || item.length > 64)
565
+ throw new Error('品味配方 ID 无效');
566
+ out.taste = item.trim();
567
+ }
537
568
  }
538
569
  return out;
539
570
  }
@@ -595,6 +626,7 @@ export class PptWorkbench {
595
626
  const milestone = raw.milestone;
596
627
  const role = raw.role;
597
628
  const conversion = raw.conversion;
629
+ const icon = raw.icon;
598
630
  if (start !== undefined && (typeof start !== 'number' || !Number.isFinite(start) || start < 0 || start > 999))
599
631
  throw new Error('结构化卡片内容无效');
600
632
  if (span !== undefined && (typeof span !== 'number' || !Number.isFinite(span) || span < 0 || span > 999))
@@ -605,6 +637,8 @@ export class PptWorkbench {
605
637
  throw new Error('结构化卡片内容无效');
606
638
  if (conversion !== undefined && (typeof conversion !== 'string' || conversion.length > 120))
607
639
  throw new Error('结构化卡片内容无效');
640
+ if (icon !== undefined && (typeof icon !== 'string' || icon.length > 48))
641
+ throw new Error('结构化卡片内容无效');
608
642
  if (typeof start === 'number')
609
643
  clean.start = start;
610
644
  if (typeof span === 'number')
@@ -615,6 +649,8 @@ export class PptWorkbench {
615
649
  clean.role = role.trim();
616
650
  if (typeof conversion === 'string' && conversion.trim())
617
651
  clean.conversion = conversion.trim();
652
+ if (typeof icon === 'string' && icon.trim())
653
+ clean.icon = icon.trim();
618
654
  return clean;
619
655
  });
620
656
  }
@@ -656,6 +692,16 @@ export class PptWorkbench {
656
692
  throw new Error('母版骨架名称无效 / Invalid chrome skeleton style');
657
693
  result.chrome = item ? item : undefined;
658
694
  }
695
+ else if (key === 'cardMaterial') {
696
+ if (item !== null && item !== '' && (typeof item !== 'string' || !ALLOWED_CARD_MATERIALS.has(item)))
697
+ throw new Error('卡片材质名称无效 / Invalid cardMaterial');
698
+ result.cardMaterial = item ? item : undefined;
699
+ }
700
+ else if (key === 'iconMode') {
701
+ if (item !== null && item !== '' && (typeof item !== 'string' || !ALLOWED_ICON_MODES.has(item)))
702
+ throw new Error('图标模式无效 / Invalid iconMode');
703
+ result.iconMode = item ? item : undefined;
704
+ }
659
705
  else if (key === 'tableStyle') {
660
706
  if (item !== null && item !== '' && (typeof item !== 'string' || !ALLOWED_TABLE_STYLES.has(item)))
661
707
  throw new Error('表格样式无效');
@@ -898,6 +944,7 @@ export class PptWorkbench {
898
944
  ok: true,
899
945
  themes: typeof engine.listThemes === 'function' ? engine.listThemes(langCode) : [],
900
946
  presets: typeof engine.listMasterPresets === 'function' ? engine.listMasterPresets(langCode) : [],
947
+ tasteRecipes: typeof engine.listAllTasteRecipes === 'function' ? engine.listAllTasteRecipes(dirname(this.catalogPath)) : [],
901
948
  templates: typeof engine.listTemplates === 'function' ? engine.listTemplates(langCode) : [],
902
949
  };
903
950
  }
@@ -1180,6 +1227,7 @@ export class PptWorkbench {
1180
1227
  recommendedChrome: absorbed?.recommendedChrome ?? null,
1181
1228
  recommendedTableStyle: absorbed?.recommendedTableStyle ?? null,
1182
1229
  narrativeProfile: absorbed?.narrativeProfile ?? null,
1230
+ styleRecipe: absorbed?.styleRecipe ?? null,
1183
1231
  warnings: absorbed?.warnings ?? [],
1184
1232
  slideSkeleton: absorbed?.slideSkeleton ?? null,
1185
1233
  layoutSummary: absorbed?.layoutSummary ?? null,
@@ -1301,12 +1349,28 @@ export class PptWorkbench {
1301
1349
  targetMinutesPatch = { targetMinutes: mins };
1302
1350
  }
1303
1351
  }
1352
+ let tastePatch = {};
1353
+ if (body.taste !== undefined) {
1354
+ if (body.taste === null || body.taste === '') {
1355
+ tastePatch = { taste: null };
1356
+ }
1357
+ else if (typeof body.taste === 'string' && /^[a-z0-9\u4e00-\u9fff-]{1,64}$/i.test(body.taste.trim())) {
1358
+ tastePatch = { taste: body.taste.trim() };
1359
+ }
1360
+ else if (body.taste && typeof body.taste === 'object' && !Array.isArray(body.taste)) {
1361
+ tastePatch = { taste: body.taste };
1362
+ }
1363
+ else {
1364
+ throw new Error('品味配方参数无效');
1365
+ }
1366
+ }
1304
1367
  const args = { deckPath: entry.path, expectedRevision: body.expectedRevision, signal,
1305
1368
  saveAs: body.saveAs === true,
1306
1369
  ...(body.slide === undefined ? {} : { edits: [{ slide: body.slide, patch: this.patch(body.patch) }] }),
1307
1370
  ...(body.order === undefined ? {} : { order: body.order }),
1308
1371
  ...(body.theme === undefined ? {} : { theme: this.themeId(body.theme) }),
1309
1372
  ...(body.brand === undefined ? {} : { brand: this.brandPatch(body.brand) }),
1373
+ ...tastePatch,
1310
1374
  ...targetMinutesPatch };
1311
1375
  const result = await engine.editDeck(args);
1312
1376
  await this.remember(result, args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ppt",
3
- "version": "0.26.0",
3
+ "version": "0.27.0",
4
4
  "description": "DeepSeek Harness 演示文稿生成与编辑工作台:输入材料即可导出离线 HTML 放映、可编辑 PPTX 与工程包,支持按页编辑、数据推演与预审演练,以及原生清透 / 米白纸感 / Claude 暖书卷 / 8-Bit 像素 / 晴空薄荷五套明亮工作台主题。欢迎提交 issues 和 PR。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: dsh-ppt
3
- description: "Turn one sentence, a Markdown document, structured slides, or an existing/reference .pptx into a world-class presentation deck: standalone HTML web slideshow (with Dual-Screen Presenter Console & Laser Pointer) + 100% native-editable PPTX (with native <m:oMath> formulas, Marimekko, Sankey, Porter Value Chain, SWOT) + project manifest + Speaker Handout (.handout.md). Features Zero-Question Scenario Auto-Direction (theme: auto), 24 curated themes, 8 reference presets, 6 Master Chrome Skeletons, 27+ native-editable layouts & pro diagrams, 20 industry blueprints, 13 Economist/FT-grade charts, deep external .pptx content import & Office round-trip sync (ppt_import / --import-pptx / --sync-pptx), data provenance, and bilingual ZH/EN support. 中文:把一句话、文档、数据或已有/参考 PPTX 变成大师级演示文稿(独立 HTML 双屏提词台放映 + 100% 原生可编辑 PPTX + 演讲讲义),内置零追问智能导演、24 套主题、6 套母版骨架、Marimekko/桑基图/波特价值链/SWOT/原生数学公式 <m:oMath> 等 27+ 版式、外部 PPTX 全量导入翻新与 Office 双向回导同步。"
3
+ description: "Turn one sentence, a Markdown document, structured slides, Office files (.xlsx/.csv/.docx), or a benchmark .pptx into a world-class presentation deck: standalone HTML web slideshow (with Dual-Screen Presenter Console & Executive One-Pager) + 100% native-editable PPTX (with 8 Curated Taste Recipes, 4 poster covers, 61 native <a:custGeom> vector icons, glass/frameless/editorial materiality, native <m:oMath> formulas, Mermaid flowcharts/sequences, Marimekko, Sankey, Porter Value Chain, SWOT) + project manifest + Speaker Handout. Features Zero-Question Scenario Auto-Direction (theme: auto), 24 curated themes, 8 Taste Recipes & benchmark .pptx aesthetic DNA learning (.dsh-ppt/taste-recipes.json), 6 Master Chrome Skeletons, 29+ native-editable layouts, 20 industry blueprints, 13 publication-grade charts with spotlight/referenceLine/growth callouts, and bilingual ZH/EN support. 中文:把一句话、文档、表格或标杆 PPTX 变成大师级演示文稿,内置 8 套大师品味配方(Taste Recipes)、4 套海报级封面、61 枚原生矢量图标、玻璃/无框/双发丝材质、Mermaid/公式/桑基/Mekko 等 29+ 版式与标杆 PPTX 审美 DNA 持久化复用。"
4
4
  compatibility: "Node ^22.19.0 or >=24.0.0. Images/charts/PPTX absorption use @office-kit/pptx@0.21.0; optional data models use jsep@1.4.0 and csv-parse@6.1.0. Optional PNG/PDF renderer: @deepseek-ai/libreoffice-kit@0.2.3 (bundled by DSH 0.2.2+; 0.1.5 also supported). Cross-harness: copy the full directory and run npm install --ignore-scripts there."
5
5
  allowed-tools: "Bash, Read, Write, Edit"
6
6
  ---
@@ -20,8 +20,8 @@ allowed-tools: "Bash, Read, Write, Edit"
20
20
  1. **零追问场景定调(Zero-Question Auto-Director)**:用户说“帮我做个汇报 PPT”时,**不要反问一堆设计参数**。直接根据内容语义识别六大画像(商业咨询、政务述职、学术答辩、科技路演、教育讲义、人文品牌),传 `theme: 'auto'` 或显式匹配 24 套大师主题(含 `bcg-emerald`、`economist-brief`、`venture-daylight`、`stripe-craft`、`aurora-stage`、`obsidian-amber`、`keynote-light`、`financial-ft`、`medical-clean`、`luxury-noir`)。**明亮投影优先**:会议室汇报、政企述职、学术答辩、教学课件一律优先选用 16 套浅底主题(通用默认 `consulting` 蔚蓝战略),绝不在常规办公场景盲目套用纯黑赛博风 `data`!并按场景自动匹配 **6 套差异化母版骨架(`chromeStyle`:`consulting-classic` / `keynote-spatial` / `editorial-folio` / `saas-bento` / `academic-minimal` / `gov-ceremonial`)**,彻底告别「一套模板换颜色」。
21
21
  2. **结论先行(Action Titles)**:除封面、目录与章节页外,每页标题必须是**完整的结论判断句**(如「异步评审将工程师周均例会耗时压缩 75%」),严禁使用「项目背景」「数据分析」「周末到馆人次」等空洞名词标签。
22
22
  3. **版式节奏与反要点墙(Anti-Bullet-Wall)**:优先传**结构化 `slides`**(或使用 `::: kpi / cards / comparison / process / chevron / matrix / callout / gantt / architecture / harvey / tam / org` 指令)充分利用 **24+ 套原生版式与专业图示**。**整套文稿严禁连续超过 2 页使用普通 `bullets` 要点列表**;8 页以上文稿须有节奏地交替视觉密度(指标用 `kpi`、端到端价值链用 `chevron`、排期用 `gantt`、系统分层用 `architecture`、竞品能力用 `harvey`、市场空间用 `tam`、组织团队用 `org`、并列支柱用 `cards[pillars/bento]`、痛点整改用 `comparison[issue-action]`、演进/闭环用 `process[timeline/steps/flywheel/funnel]`、四象限用 `matrix`、数据配洞察用 `chart-split`、学术对比用 `table[booktabs]` 三线表)。
23
- 4. **出版级图表与三线表**:单系列图表自动隐藏冗余图例,使用 `highlight: 'max' | 'last'` 突出焦点色柱、其余灰阶退后,直接显示数据标签,左下角附 `source` 数据来源;学术与严谨数据对比使用无竖线的 `booktabs` 三线表。
24
- 5. **双轨深层吸收优质 PPT**:无外部模板时调用内置 **24 套大师主题**、**8 套名家范本预设**、**6 套母版骨架**与 **20 套行业结构蓝图**;用户提供参考 `.pptx` 时先调 `ppt_absorb` 或直接传 `referencePptx` 自动递归拆解嵌套组合形状(`<p:grpSp>`)、提取并净化主辅双品牌色(`primaryColor` + `secondaryColor`)、标题/正文字体配对(`headingFont` + `fontFamily`)、深色封面+浅色正文极性(`coverMode: 'inverted-accent'`)、Logo、推荐骨架(`recommendedChrome`)与 24 版式逐页分布(`slideSkeleton`),传 `cloneStructure: true` 可将 Markdown 大纲直接映射到吸收出的逐页版式序列与母版骨架!
23
+ 4. **出版级图表与三线表**:单系列图表自动隐藏冗余图例,使用 `spotlight: true` / `highlight: 'max' | 'last'` 突出焦点色柱、其余灰阶退后,按需叠加 `referenceLine` 基准虚线与 `showGrowthCallout: true` 麦肯锡增长飞线批注,左下角附 `source` 数据来源;学术与严谨数据对比使用无竖线的 `booktabs` 三线表。
24
+ 5. **双轨深层吸收优质 PPT 与 8 套大师品味配方(Taste Recipes)**:无外部模板时直接按场景选用内置 **8 套大师审美配方**(`taste: 'mckinsey-partner' | 'apple-keynote-dark' | 'apple-keynote-light' | 'swiss-editorial' | 'linear-craft' | 'ft-data-journal' | 'nature-academic' | 'oriental-zen'`),协同驱动 4 套海报封面(`keynote-glow` / `editorial-grid` / `architectural` / `split-bleed`)、`section[agenda]` 实时章节进度、4 种卡片材质(`solid` / `frameless` / `glass` / `editorial-rule`)、`kpi[spotlight]` / `cards[bento-hero]` 非对称主次布局与 **61 枚原生 `<a:custGeom>` 矢量图标**;用户提供标杆 `.pptx` 时调 `ppt_absorb`(传 `saveTasteAs` / CLI `--save-taste`)提取留白率/材质/字阶比/节奏分生成 `styleRecipe` 持久化至 `.dsh-ppt/taste-recipes.json`,后续新稿直接用 `taste: "<savedId>"` 复用,或传 `referencePptx` + `cloneStructure: true` 直接映射逐页版式序列与母版骨架!
25
25
 
26
26
  ## 执行纪律(每次都要遵守)
27
27
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ppt-skill",
3
- "version": "0.26.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",
@@ -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, importOfficeDeck } 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,7 +33,10 @@ 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 工程
38
41
  --from-office <path> 直吞 .xlsx / .csv / .tsv / .docx 数据表或 Word 报告,自动画像并生成全套文稿
39
42
  --sync-pptx <path> 将 Office 修改后的 .pptx 内容回导同步至已有工程(自动写入 .history/ 支持撤销)
@@ -91,11 +94,14 @@ export function parseArgv(argv) {
91
94
  if (key === '--help' || key === '-h') args.help = true
92
95
  else if (key === '--list-themes') args.listThemes = true
93
96
  else if (key === '--list-templates') args.listTemplates = true
97
+ else if (key === '--list-tastes') args.listTastes = true
94
98
  else if (key === '--overwrite') args.overwrite = true
95
99
  else if (key === '--smart-layout') args.smartLayout = true
96
100
  else if (key === '--no-smart-layout') args.smartLayout = false
97
101
  else if (key === '--clone-structure') args.cloneStructure = true
98
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()
99
105
  else if (key === '--title') args.title = nextValue()
100
106
  else if (key === '--content') args.content = nextValue()
101
107
  else if (key === '--slides') args.slides = readJson(nextValue())
@@ -159,6 +165,7 @@ export async function main(argv = process.argv.slice(2), io = {}) {
159
165
  return 0
160
166
  }
161
167
  if (args.listTemplates) { log(JSON.stringify({ templates: listTemplates(args.lang) }, null, 2)); return 0 }
168
+ if (args.listTastes) { log(JSON.stringify({ tasteRecipes: listAllTasteRecipes(process.cwd()) }, null, 2)); return 0 }
162
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) {
163
170
  throw new Error('dsh-ppt CLI:--edit / --undo / --check / --render / --absorb / --import-pptx / --sync-pptx / --from-office 只能选择一项')
164
171
  }
@@ -209,7 +216,10 @@ export async function main(argv = process.argv.slice(2), io = {}) {
209
216
  return 0
210
217
  }
211
218
  if (args.absorb) {
212
- const absorbed = await absorbPptx({ pptxPath: args.absorb })
219
+ const absorbed = await absorbPptx({
220
+ pptxPath: args.absorb,
221
+ ...(args.saveTaste ? { saveTasteAs: args.saveTaste } : {}),
222
+ })
213
223
  log(JSON.stringify(absorbed, null, 2))
214
224
  return 0
215
225
  }
@@ -231,6 +241,7 @@ export async function main(argv = process.argv.slice(2), io = {}) {
231
241
  deckPath: args.edit,
232
242
  edits: args.edits,
233
243
  theme: args.theme,
244
+ ...(args.taste ? { taste: args.taste } : {}),
234
245
  referencePptx: args.referencePptx,
235
246
  brand: effectiveBrand,
236
247
  ...(args.targetMinutes !== undefined ? { targetMinutes: args.targetMinutes } : {}),
@@ -258,6 +269,7 @@ export async function main(argv = process.argv.slice(2), io = {}) {
258
269
  content,
259
270
  slides,
260
271
  theme: args.theme,
272
+ ...(args.taste ? { taste: args.taste } : {}),
261
273
  persona: args.persona,
262
274
  referencePptx: args.referencePptx,
263
275
  cloneStructure: args.cloneStructure,
@@ -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,