dsh-ppt 0.27.2 → 0.29.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.
- package/CHANGELOG.md +27 -0
- package/README.en.md +23 -22
- package/README.md +23 -22
- package/docs/USAGE.en.md +2 -0
- package/docs/USAGE.md +2 -0
- package/docs/VALIDATION.md +8 -0
- package/docs/assets/intro/workflow-en-dark.svg +1 -1
- package/docs/assets/intro/workflow-en-light.svg +1 -1
- package/docs/assets/intro/workflow-en-mobile-dark.svg +1 -1
- package/docs/assets/intro/workflow-en-mobile-light.svg +1 -1
- package/docs/assets/intro/workflow-zh-dark.svg +1 -1
- package/docs/assets/intro/workflow-zh-light.svg +1 -1
- package/docs/assets/intro/workflow-zh-mobile-dark.svg +1 -1
- package/docs/assets/intro/workflow-zh-mobile-light.svg +1 -1
- package/lib/client.js +283 -33
- package/lib/execution.d.ts +7 -0
- package/lib/execution.js +47 -6
- package/lib/tools.js +62 -12
- package/lib/types.d.ts +51 -4
- package/lib/workbench.js +185 -9
- package/package.json +1 -1
- package/skills/dsh-ppt/SKILL.md +4 -2
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/references/exemplars.md +116 -0
- package/skills/dsh-ppt/scripts/build-deck.mjs +20 -1
- package/skills/dsh-ppt/scripts/deck-absorb.mjs +27 -3
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +107 -24
- package/skills/dsh-ppt/scripts/deck-charts-pro.mjs +1004 -0
- package/skills/dsh-ppt/scripts/deck-chrome.mjs +27 -6
- package/skills/dsh-ppt/scripts/deck-core.mjs +96 -3
- package/skills/dsh-ppt/scripts/deck-covers.mjs +157 -3
- package/skills/dsh-ppt/scripts/deck-exemplars.mjs +548 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +90 -2
- package/skills/dsh-ppt/scripts/deck-showcase.mjs +729 -0
- package/skills/dsh-ppt/scripts/deck-upgrader.mjs +618 -0
package/lib/workbench.js
CHANGED
|
@@ -20,6 +20,7 @@ const ALLOWED_LAYOUTS = new Set([
|
|
|
20
20
|
'kpi', 'cards', 'comparison', 'matrix', 'process', 'callout',
|
|
21
21
|
'gantt', 'architecture', 'harvey', 'tam', 'org',
|
|
22
22
|
'marimekko', 'sankey', 'swot',
|
|
23
|
+
'mockup', 'code', 'quadrant', 'radar', 'dumbbell', 'heatmap',
|
|
23
24
|
'table', 'closing', 'image', 'image-left', 'image-right', 'chart', 'chart-split',
|
|
24
25
|
'waterfall', 'gallery', 'flywheel', 'chevron', 'value-chain',
|
|
25
26
|
'mermaid', 'flowchart', 'sequence',
|
|
@@ -30,7 +31,8 @@ const ALLOWED_ITEM_STATUS = new Set(['neutral', 'accent', 'positive', 'negative'
|
|
|
30
31
|
const ALLOWED_CHROME_STYLES = new Set(['consulting-classic', 'keynote-spatial', 'editorial-folio', 'saas-bento', 'academic-minimal', 'gov-ceremonial']);
|
|
31
32
|
const ALLOWED_CARD_MATERIALS = new Set(['solid', 'frameless', 'glass', 'editorial-rule']);
|
|
32
33
|
const ALLOWED_ICON_MODES = new Set(['off', 'explicit', 'auto']);
|
|
33
|
-
const
|
|
34
|
+
const ALLOWED_COVER_PATTERNS = new Set(['dots', 'grid', 'rings']);
|
|
35
|
+
const ITEM_KEYS = new Set(['tag', 'badge', 'title', 'text', 'body', 'value', 'unit', 'delta', 'start', 'span', 'milestone', 'role', 'conversion', 'icon', 'avatar', 'x', 'y', 'size', 'before', 'after', 'status', 'tone', 'bullets']);
|
|
34
36
|
const BRAND_KEYS = new Set(['name', 'primaryColor', 'secondaryColor', 'backgroundColor', 'textColor', 'fontFamily', 'headingFont', 'coverMode', 'coverBg', 'logo', 'footer', 'chromeStyle', 'cardMaterial', 'iconMode', 'taste']);
|
|
35
37
|
const VISUAL_KEYS = new Set(['titleSize', 'bodySize', 'chartLabelSize', 'density', 'tableStyle', 'chrome']);
|
|
36
38
|
/** Sharing keeps the offline deck, but omits the control for a project not in the ZIP. */
|
|
@@ -317,6 +319,76 @@ function starterSlide(archetype, language) {
|
|
|
317
319
|
: 'sequenceDiagram\n participant 用户\n participant 工作台\n participant 引擎\n 用户->>工作台: 上传 .xlsx / .docx\n 工作台->>引擎: 智能剖析与编排\n 引擎-->>用户: HTML + 原生 PPTX',
|
|
318
320
|
};
|
|
319
321
|
}
|
|
322
|
+
if (kind === 'mockup') {
|
|
323
|
+
return {
|
|
324
|
+
layout: 'mockup',
|
|
325
|
+
variant: 'browser',
|
|
326
|
+
title: en ? 'Unified studio delivers live preview & native export' : '一体化工作台实时联动预览与原生导出',
|
|
327
|
+
url: 'https://studio.dsh-ppt.dev/workspace',
|
|
328
|
+
items: [
|
|
329
|
+
{ tag: 'LIVE', value: '60 fps', title: en ? 'Zero-latency canvas' : '实时同源预览', text: en ? 'Double-click any heading to edit inline.' : '画布双击标题或要点即刻原地改字。' },
|
|
330
|
+
{ tag: 'NATIVE', value: '100%', title: en ? 'Editable OOXML' : '原生可编辑 PPTX', text: en ? 'Charts, Mermaid, math & 61 vector icons.' : '图表、流程图、公式与 61 枚矢量图标原生可改。' },
|
|
331
|
+
],
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
if (kind === 'code') {
|
|
335
|
+
return {
|
|
336
|
+
layout: 'code',
|
|
337
|
+
language: 'typescript',
|
|
338
|
+
filename: 'src/pipeline.ts',
|
|
339
|
+
title: en ? 'Declarative pipeline compiles slides deterministically' : '声明式流水线一行生成高审美同源三件套',
|
|
340
|
+
code: "import { buildDeckAsync } from 'dsh-ppt/deck-advanced'\n\nexport async function shipExecutiveDeck(notes: string) {\n return buildDeckAsync({\n title: '2026 Annual Strategy Review',\n taste: 'mckinsey-partner',\n content: notes,\n outputDir: './dist',\n })\n}",
|
|
341
|
+
items: [
|
|
342
|
+
{ tag: '01', icon: 'sparkles', title: en ? 'Curated Taste Recipe' : '大师品味配方驱动', text: en ? 'Orchestrates cover, materiality & chart spotlight.' : '自动联动封面、材质、图标与图表聚光灯。' },
|
|
343
|
+
{ tag: '02', icon: 'shield', title: en ? 'Zero-Dep Compiler' : '零外部依赖确定性编译', text: en ? 'Validates OOXML schema before writing files.' : '落盘前自动校验 OOXML 结构,确保零报错。' },
|
|
344
|
+
],
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
if (kind === 'quadrant') {
|
|
348
|
+
return {
|
|
349
|
+
layout: 'quadrant',
|
|
350
|
+
title: en ? 'Competitive positioning leads on execution & vision' : '竞品魔力象限:我们在执行力与产品前瞻性双双领跑',
|
|
351
|
+
xLabel: en ? 'Completeness of Vision →' : '产品前瞻性与生态完整度 →',
|
|
352
|
+
yLabel: en ? 'Ability to Execute ↑' : '工程交付与规模化执行力 ↑',
|
|
353
|
+
items: [
|
|
354
|
+
{ title: en ? 'Our Platform' : '本平台', x: 84, y: 86, size: 80, status: 'accent' },
|
|
355
|
+
{ title: en ? 'Vendor A' : '竞品 A', x: 64, y: 68, size: 58, status: 'neutral' },
|
|
356
|
+
{ title: en ? 'Vendor B' : '竞品 B', x: 32, y: 74, size: 46, status: 'neutral' },
|
|
357
|
+
{ title: en ? 'Vendor C' : '竞品 C', x: 74, y: 34, size: 40, status: 'neutral' },
|
|
358
|
+
{ title: en ? 'Legacy Suite' : '传统工具', x: 24, y: 26, size: 50, status: 'negative' },
|
|
359
|
+
],
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
if (kind === 'radar') {
|
|
363
|
+
return {
|
|
364
|
+
layout: 'radar',
|
|
365
|
+
title: en ? 'Six-dimension capability benchmark outperforms market average' : '六维核心能力评估全面领先行业基线',
|
|
366
|
+
rows: en
|
|
367
|
+
? [['Dimension', 'Our Platform', 'Industry Avg'], ['Throughput', 94, 70], ['Latency', 91, 68], ['Reliability', 96, 76], ['Security', 92, 72], ['Efficiency', 88, 64], ['Ecosystem', 86, 74]]
|
|
368
|
+
: [['能力维度', '本平台', '行业均值'], ['推理吞吐', 94, 70], ['响应延迟', 91, 68], ['高可用性', 96, 76], ['安全合规', 92, 72], ['成本效率', 88, 64], ['生态兼容', 86, 74]],
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
if (kind === 'dumbbell') {
|
|
372
|
+
return {
|
|
373
|
+
layout: 'dumbbell',
|
|
374
|
+
title: en ? 'Automation upgrade delivers step-change gains across KPIs' : '智能化升级驱动核心运营指标全面跃迁(Before → After)',
|
|
375
|
+
items: [
|
|
376
|
+
{ title: en ? 'Automation Rate' : '流程自动化率', before: 38, after: 84, unit: '%', delta: '+46pp', status: 'positive' },
|
|
377
|
+
{ title: en ? 'First-Pass Yield' : '一次交付达标率', before: 64, after: 93, unit: '%', delta: '+29pp', status: 'positive' },
|
|
378
|
+
{ title: en ? 'Unit Cost Index' : '单笔成本指数', before: 92, after: 54, unit: '', delta: '-41%', status: 'accent' },
|
|
379
|
+
{ title: en ? 'Team Adoption' : '团队活跃渗透率', before: 45, after: 89, unit: '%', delta: '+44pp', status: 'positive' },
|
|
380
|
+
],
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
if (kind === 'heatmap') {
|
|
384
|
+
return {
|
|
385
|
+
layout: 'heatmap',
|
|
386
|
+
title: en ? 'Regional attainment heatmap highlights Q4 acceleration' : '各大区季度目标达成率热力图凸显 Q4 全面冲刺',
|
|
387
|
+
rows: en
|
|
388
|
+
? [['Region \\ Qtr', 'Q1', 'Q2', 'Q3', 'Q4'], ['North America', 74, 82, 89, 96], ['Europe', 65, 72, 80, 88], ['APAC', 60, 76, 86, 94], ['LatAm', 44, 52, 61, 73]]
|
|
389
|
+
: [['区域 \\ 季度', 'Q1', 'Q2', 'Q3', 'Q4'], ['华东大区', 78, 84, 91, 97], ['华南大区', 68, 75, 83, 90], ['华北大区', 62, 69, 77, 85], ['海外新兴', 44, 56, 71, 88]],
|
|
390
|
+
};
|
|
391
|
+
}
|
|
320
392
|
return {
|
|
321
393
|
layout: 'bullets',
|
|
322
394
|
title: en ? 'New slide key takeaway' : '请填写本页核心结论句',
|
|
@@ -627,6 +699,14 @@ export class PptWorkbench {
|
|
|
627
699
|
const role = raw.role;
|
|
628
700
|
const conversion = raw.conversion;
|
|
629
701
|
const icon = raw.icon;
|
|
702
|
+
const avatar = raw.avatar;
|
|
703
|
+
for (const nk of ['x', 'y', 'size', 'before', 'after']) {
|
|
704
|
+
const nv = raw[nk];
|
|
705
|
+
if (nv !== undefined && (typeof nv !== 'number' || !Number.isFinite(nv)))
|
|
706
|
+
throw new Error('结构化卡片内容无效');
|
|
707
|
+
if (typeof nv === 'number')
|
|
708
|
+
clean[nk] = nv;
|
|
709
|
+
}
|
|
630
710
|
if (start !== undefined && (typeof start !== 'number' || !Number.isFinite(start) || start < 0 || start > 999))
|
|
631
711
|
throw new Error('结构化卡片内容无效');
|
|
632
712
|
if (span !== undefined && (typeof span !== 'number' || !Number.isFinite(span) || span < 0 || span > 999))
|
|
@@ -639,6 +719,8 @@ export class PptWorkbench {
|
|
|
639
719
|
throw new Error('结构化卡片内容无效');
|
|
640
720
|
if (icon !== undefined && (typeof icon !== 'string' || icon.length > 48))
|
|
641
721
|
throw new Error('结构化卡片内容无效');
|
|
722
|
+
if (avatar !== undefined && (typeof avatar !== 'string' || avatar.length > 64))
|
|
723
|
+
throw new Error('结构化卡片内容无效');
|
|
642
724
|
if (typeof start === 'number')
|
|
643
725
|
clean.start = start;
|
|
644
726
|
if (typeof span === 'number')
|
|
@@ -651,6 +733,8 @@ export class PptWorkbench {
|
|
|
651
733
|
clean.conversion = conversion.trim();
|
|
652
734
|
if (typeof icon === 'string' && icon.trim())
|
|
653
735
|
clean.icon = icon.trim();
|
|
736
|
+
if (typeof avatar === 'string' && avatar.trim())
|
|
737
|
+
clean.avatar = avatar.trim();
|
|
654
738
|
return clean;
|
|
655
739
|
});
|
|
656
740
|
}
|
|
@@ -662,11 +746,30 @@ export class PptWorkbench {
|
|
|
662
746
|
throw new Error('结构化卡片内容无效');
|
|
663
747
|
const result = {};
|
|
664
748
|
for (const [key, item] of Object.entries(raw)) {
|
|
665
|
-
if (['title', 'subtitle', 'kicker', 'takeaway', 'source', 'text', 'formula', 'notes'].includes(key)) {
|
|
749
|
+
if (['title', 'subtitle', 'kicker', 'takeaway', 'source', 'text', 'formula', 'notes', 'language', 'filename', 'url', 'xLabel', 'yLabel'].includes(key)) {
|
|
666
750
|
if (typeof item !== 'string' || item.length > 8000)
|
|
667
751
|
throw new Error('文字字段过长或无效');
|
|
668
752
|
result[key] = item;
|
|
669
753
|
}
|
|
754
|
+
else if (key === 'code') {
|
|
755
|
+
if (typeof item !== 'string' || item.length > 16000)
|
|
756
|
+
throw new Error('代码片段无效或超过 16,000 字符');
|
|
757
|
+
result.code = item;
|
|
758
|
+
}
|
|
759
|
+
else if (key === 'coverPattern') {
|
|
760
|
+
if (item !== null && item !== '' && (typeof item !== 'string' || !ALLOWED_COVER_PATTERNS.has(item)))
|
|
761
|
+
throw new Error('封面底纹名称无效');
|
|
762
|
+
result.coverPattern = item ? item : undefined;
|
|
763
|
+
}
|
|
764
|
+
else if (key === 'quadrants') {
|
|
765
|
+
if (item === null) {
|
|
766
|
+
result.quadrants = undefined;
|
|
767
|
+
continue;
|
|
768
|
+
}
|
|
769
|
+
if (!Array.isArray(item) || item.length !== 4 || item.some(q => typeof q !== 'string' || q.length > 80))
|
|
770
|
+
throw new Error('象限名称需为 4 项字符串');
|
|
771
|
+
result.quadrants = item;
|
|
772
|
+
}
|
|
670
773
|
else if (key === 'mermaid') {
|
|
671
774
|
if (typeof item !== 'string' || item.length > 16000)
|
|
672
775
|
throw new Error('Mermaid 代码无效或超过 16,000 字符');
|
|
@@ -940,11 +1043,14 @@ export class PptWorkbench {
|
|
|
940
1043
|
const engine = await this.loadEngine();
|
|
941
1044
|
signal?.throwIfAborted();
|
|
942
1045
|
const langCode = body.lang === 'en' ? 'en' : 'zh';
|
|
1046
|
+
const storeDir = dirname(this.catalogPath);
|
|
1047
|
+
const workspaceExemplars = typeof engine.loadWorkspaceExemplars === 'function' ? engine.loadWorkspaceExemplars(storeDir) : {};
|
|
943
1048
|
return {
|
|
944
1049
|
ok: true,
|
|
945
1050
|
themes: typeof engine.listThemes === 'function' ? engine.listThemes(langCode) : [],
|
|
946
1051
|
presets: typeof engine.listMasterPresets === 'function' ? engine.listMasterPresets(langCode) : [],
|
|
947
|
-
tasteRecipes: typeof engine.listAllTasteRecipes === 'function' ? engine.listAllTasteRecipes(
|
|
1052
|
+
tasteRecipes: typeof engine.listAllTasteRecipes === 'function' ? engine.listAllTasteRecipes(storeDir) : [],
|
|
1053
|
+
exemplars: typeof engine.listCuratedExemplars === 'function' ? engine.listCuratedExemplars(workspaceExemplars) : [],
|
|
948
1054
|
templates: typeof engine.listTemplates === 'function' ? engine.listTemplates(langCode) : [],
|
|
949
1055
|
};
|
|
950
1056
|
}
|
|
@@ -962,11 +1068,20 @@ export class PptWorkbench {
|
|
|
962
1068
|
const lang = body.lang === 'en' || body.lang === 'bilingual' ? body.lang : 'zh';
|
|
963
1069
|
const theme = typeof body.theme === 'string' && body.theme.trim() ? (body.theme.trim() === 'auto' ? 'auto' : this.themeId(body.theme)) : 'auto';
|
|
964
1070
|
const template = typeof body.template === 'string' && body.template.trim() ? body.template.trim() : undefined;
|
|
1071
|
+
let exemplar;
|
|
1072
|
+
if (body.exemplar !== undefined && body.exemplar !== null && body.exemplar !== '') {
|
|
1073
|
+
if (typeof body.exemplar !== 'string' || !/^[a-z0-9\u4e00-\u9fff-]{1,64}$/i.test(body.exemplar.trim())) {
|
|
1074
|
+
throw new Error('标杆范本 ID 无效');
|
|
1075
|
+
}
|
|
1076
|
+
exemplar = body.exemplar.trim();
|
|
1077
|
+
}
|
|
1078
|
+
const autoUpgrade = typeof body.autoUpgrade === 'boolean' ? body.autoUpgrade : undefined;
|
|
965
1079
|
const brand = body.brand !== undefined ? this.brandPatch(body.brand) : undefined;
|
|
966
1080
|
const cloneStructure = body.cloneStructure === true;
|
|
967
1081
|
const engine = await this.loadEngine();
|
|
968
1082
|
signal?.throwIfAborted();
|
|
969
|
-
const
|
|
1083
|
+
const storeDir = dirname(this.catalogPath);
|
|
1084
|
+
const decksDir = join(storeDir, 'workbench-decks');
|
|
970
1085
|
mkdirSync(decksDir, { recursive: true });
|
|
971
1086
|
let tmpRefPath;
|
|
972
1087
|
let skeletonSlides;
|
|
@@ -1011,12 +1126,14 @@ export class PptWorkbench {
|
|
|
1011
1126
|
...(skeletonSlides ? { slides: skeletonSlides } : {}),
|
|
1012
1127
|
...(fallbackContent ? { content: fallbackContent } : {}),
|
|
1013
1128
|
...(template ? { template } : {}),
|
|
1129
|
+
...(exemplar ? { exemplar } : {}),
|
|
1130
|
+
...(autoUpgrade !== undefined ? { autoUpgrade } : {}),
|
|
1014
1131
|
theme,
|
|
1015
1132
|
lang,
|
|
1016
1133
|
...(tmpRefPath ? { referencePptx: tmpRefPath, cloneStructure } : {}),
|
|
1017
1134
|
...(brand ? { brand } : {}),
|
|
1018
1135
|
outputDir: decksDir,
|
|
1019
|
-
cwd:
|
|
1136
|
+
cwd: storeDir,
|
|
1020
1137
|
signal,
|
|
1021
1138
|
});
|
|
1022
1139
|
await this.remember(created, {});
|
|
@@ -1212,7 +1329,19 @@ export class PptWorkbench {
|
|
|
1212
1329
|
if (typeof engine.absorbPptx !== 'function')
|
|
1213
1330
|
throw new Error('当前引擎版本暂不支持参考 PPTX 吸收');
|
|
1214
1331
|
const bytes = this.pptxBytes(body.data);
|
|
1215
|
-
const
|
|
1332
|
+
const saveExemplarAs = typeof body.saveExemplarAs === 'string' && /^[a-z0-9\u4e00-\u9fff-]{1,64}$/i.test(body.saveExemplarAs.trim())
|
|
1333
|
+
? body.saveExemplarAs.trim()
|
|
1334
|
+
: undefined;
|
|
1335
|
+
const exemplarName = typeof body.exemplarName === 'string' && body.exemplarName.trim()
|
|
1336
|
+
? body.exemplarName.trim().slice(0, 80)
|
|
1337
|
+
: undefined;
|
|
1338
|
+
const storeDir = dirname(this.catalogPath);
|
|
1339
|
+
const absorbed = await engine.absorbPptx({
|
|
1340
|
+
bytes,
|
|
1341
|
+
extractLogo: body.extractLogo !== false,
|
|
1342
|
+
...(saveExemplarAs ? { saveExemplarAs, ...(exemplarName ? { exemplarName } : {}), cwd: storeDir } : {}),
|
|
1343
|
+
signal,
|
|
1344
|
+
});
|
|
1216
1345
|
return {
|
|
1217
1346
|
ok: true,
|
|
1218
1347
|
absorbed: {
|
|
@@ -1228,6 +1357,8 @@ export class PptWorkbench {
|
|
|
1228
1357
|
recommendedTableStyle: absorbed?.recommendedTableStyle ?? null,
|
|
1229
1358
|
narrativeProfile: absorbed?.narrativeProfile ?? null,
|
|
1230
1359
|
styleRecipe: absorbed?.styleRecipe ?? null,
|
|
1360
|
+
savedExemplarPath: absorbed?.savedExemplarPath ?? null,
|
|
1361
|
+
exemplar: absorbed?.exemplar ?? null,
|
|
1231
1362
|
warnings: absorbed?.warnings ?? [],
|
|
1232
1363
|
slideSkeleton: absorbed?.slideSkeleton ?? null,
|
|
1233
1364
|
layoutSummary: absorbed?.layoutSummary ?? null,
|
|
@@ -1411,7 +1542,7 @@ export class PptWorkbench {
|
|
|
1411
1542
|
return denied;
|
|
1412
1543
|
try {
|
|
1413
1544
|
const params = new URL(request.url).searchParams, kind = params.get('kind');
|
|
1414
|
-
if (!['html', 'pptx', 'json', 'bundle', 'share', 'notes', 'handout', 'onepager', 'remotion', 'coaching', 'data', 'visual'].includes(String(kind)))
|
|
1545
|
+
if (!['html', 'pptx', 'json', 'bundle', 'share', 'notes', 'handout', 'onepager', 'remotion', 'pdf', 'png-zip', 'coaching', 'data', 'visual'].includes(String(kind)))
|
|
1415
1546
|
return fail(400, '不支持此文件类型');
|
|
1416
1547
|
const { entry, manifest, files, engine } = await this.project(params.get('id'));
|
|
1417
1548
|
if (String(manifest.revision) !== params.get('revision'))
|
|
@@ -1468,6 +1599,51 @@ export class PptWorkbench {
|
|
|
1468
1599
|
bytes = zipSync(zipEntries, { level: 0 });
|
|
1469
1600
|
name = basename(entry.path, '.json') + '-remotion.zip';
|
|
1470
1601
|
}
|
|
1602
|
+
else if (kind === 'pdf' || kind === 'png-zip') {
|
|
1603
|
+
if (!existsSync(files.pptx))
|
|
1604
|
+
return fail(400, 'PPTX 文件不存在,请先保存一次再导出');
|
|
1605
|
+
const tmpOut = join(dirname(this.catalogPath), `.export-${randomUUID()}`);
|
|
1606
|
+
try {
|
|
1607
|
+
const rendered = await engine.renderDeck({
|
|
1608
|
+
pptxPath: files.pptx,
|
|
1609
|
+
outputDir: tmpOut,
|
|
1610
|
+
format: kind === 'pdf' ? 'pdf' : 'png',
|
|
1611
|
+
width: 1440,
|
|
1612
|
+
signal: request.signal,
|
|
1613
|
+
});
|
|
1614
|
+
if (!rendered.ok) {
|
|
1615
|
+
return fail(rendered.status === 'unavailable' ? 503 : 500, rendered.message || '导出失败:当前环境未安装 @deepseek-ai/libreoffice-kit 渲染引擎 / PDF/PNG export requires @deepseek-ai/libreoffice-kit');
|
|
1616
|
+
}
|
|
1617
|
+
if (kind === 'pdf') {
|
|
1618
|
+
if (!rendered.pdfPath || !existsSync(rendered.pdfPath))
|
|
1619
|
+
return fail(400, 'PDF 渲染产物缺失');
|
|
1620
|
+
bytes = ordinaryFile(rendered.pdfPath);
|
|
1621
|
+
name = basename(entry.path, '.json') + '.pdf';
|
|
1622
|
+
}
|
|
1623
|
+
else {
|
|
1624
|
+
const pngList = Array.isArray(rendered.pngPaths) ? rendered.pngPaths : [];
|
|
1625
|
+
if (pngList.length === 0)
|
|
1626
|
+
return fail(400, 'PNG 渲染产物缺失');
|
|
1627
|
+
const zipEntries = {};
|
|
1628
|
+
let totalBytes = 0;
|
|
1629
|
+
pngList.forEach((pPath, pi) => {
|
|
1630
|
+
const buf = ordinaryFile(pPath);
|
|
1631
|
+
totalBytes += buf.byteLength;
|
|
1632
|
+
if (totalBytes > BUNDLE_LIMIT)
|
|
1633
|
+
throw new Error('PNG 图包超过 128 MiB 上限');
|
|
1634
|
+
zipEntries[`slide-${String(pi + 1).padStart(2, '0')}.png`] = buf;
|
|
1635
|
+
});
|
|
1636
|
+
bytes = zipSync(zipEntries, { level: 0 });
|
|
1637
|
+
name = basename(entry.path, '.json') + '-slides-png.zip';
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
finally {
|
|
1641
|
+
try {
|
|
1642
|
+
rmSync(tmpOut, { recursive: true, force: true });
|
|
1643
|
+
}
|
|
1644
|
+
catch { /* ignore */ }
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1471
1647
|
else if (kind === 'bundle' || kind === 'share') {
|
|
1472
1648
|
const entries = {};
|
|
1473
1649
|
let total = 0;
|
|
@@ -1505,8 +1681,8 @@ export class PptWorkbench {
|
|
|
1505
1681
|
request.signal.throwIfAborted();
|
|
1506
1682
|
if ((await this.project(entry.id)).manifest.revision !== manifest.revision)
|
|
1507
1683
|
return fail(409, '项目已被修改,请重新打开后下载');
|
|
1508
|
-
const archive = kind === 'bundle' || kind === 'share' || kind === 'remotion';
|
|
1509
|
-
const type = ['notes', 'handout', 'coaching', 'data', 'visual'].includes(String(kind)) ? 'text/markdown; charset=utf-8' : archive ? 'application/zip' : kind === 'pptx' ? 'application/vnd.openxmlformats-officedocument.presentationml.presentation' : (kind === 'html' || kind === 'onepager') ? 'text/html; charset=utf-8' : 'application/json; charset=utf-8';
|
|
1684
|
+
const archive = kind === 'bundle' || kind === 'share' || kind === 'remotion' || kind === 'png-zip';
|
|
1685
|
+
const type = ['notes', 'handout', 'coaching', 'data', 'visual'].includes(String(kind)) ? 'text/markdown; charset=utf-8' : archive ? 'application/zip' : kind === 'pdf' ? 'application/pdf' : kind === 'pptx' ? 'application/vnd.openxmlformats-officedocument.presentationml.presentation' : (kind === 'html' || kind === 'onepager') ? 'text/html; charset=utf-8' : 'application/json; charset=utf-8';
|
|
1510
1686
|
return new Response(new Uint8Array(bytes), { headers: {
|
|
1511
1687
|
'content-type': type, 'cache-control': 'no-store', 'x-content-type-options': 'nosniff',
|
|
1512
1688
|
'content-disposition': `attachment; filename="presentation.${archive ? 'zip' : ['notes', 'handout', 'coaching', 'data', 'visual'].includes(String(kind)) ? 'md' : kind === 'onepager' ? 'html' : kind}"; filename*=UTF-8''${encodeURIComponent(name)}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ppt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "DeepSeek Harness 演示文稿生成与编辑工作台:输入材料即可导出离线 HTML 放映、可编辑 PPTX 与工程包,支持按页编辑、数据推演与预审演练,以及原生清透 / 米白纸感 / Claude 暖书卷 / 8-Bit 像素 / 晴空薄荷五套明亮工作台主题。欢迎提交 issues 和 PR。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
package/skills/dsh-ppt/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dsh-ppt
|
|
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.
|
|
3
|
+
description: "Turn one sentence, a Markdown document, structured slides, Office files (.xlsx/.csv/.docx), or a benchmark .pptx corpus 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 Gold Exemplars & Slot-Filling Contracts, Deterministic Weak-LLM Compensator & Anti-Slop Upgrader, 8 Curated Taste Recipes, 4 poster covers + Hero Photo Split + coverPattern, 61 native <a:custGeom> vector icons, glass/frameless/editorial materiality, device mockups, 9-language syntax-highlighted code terminals, Magic Quadrant, Radar, Dumbbell, Heatmap, native <m:oMath> formulas, Mermaid flowcharts/sequences, Marimekko, Sankey, Porter Value Chain, SWOT) + project manifest + Speaker Handout. Supports batch .pptx exemplar ingestion (.dsh-ppt/exemplars.json), Zero-Question Scenario Auto-Direction (theme: auto), 24 curated themes, 6 Master Chrome Skeletons, 35+ native-editable layouts, 20 industry blueprints, 13 publication-grade charts, and bilingual ZH/EN support. 中文:内置 8 套标杆范本槽位契约、确定性防退化升维器(专治中弱模型文字墙与平庸标题)与批量优质 .pptx 目录吸收引擎,让任意模型稳定输出麦肯锡/红杉/Stripe 级可编辑演示文稿。"
|
|
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
|
---
|
|
@@ -21,7 +21,8 @@ allowed-tools: "Bash, Read, Write, Edit"
|
|
|
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
23
|
4. **出版级图表与三线表**:单系列图表自动隐藏冗余图例,使用 `spotlight: true` / `highlight: 'max' | 'last'` 突出焦点色柱、其余灰阶退后,按需叠加 `referenceLine` 基准虚线与 `showGrowthCallout: true` 麦肯锡增长飞线批注,左下角附 `source` 数据来源;学术与严谨数据对比使用无竖线的 `booktabs` 三线表。
|
|
24
|
-
5.
|
|
24
|
+
5. **标杆范本槽位填空(Slot-Filling)+ 确定性防退化升维器**:不要从零发明排版!优先从内置 **8 套标杆范本**(`exemplar: 'mckinsey-strategy' | 'sequoia-pitch' | 'stripe-product-launch' | 'quarterly-exec-review' | 'tech-arch-rfc' | 'academic-defense' | 'enterprise-proposal' | 'gov-institutional'`)或工作区已吸收范本中择一,先调 `ppt_templates({ exemplarId })` 获取逐页槽位契约与满分标题示范,再按槽位调用 `ppt_create({ exemplar, ... })`;引擎内置 **确定性弱模型补偿器(`autoUpgrade`,默认开启)**,即使输入为粗糙 `bullets` 也能以 0 额外模型开销自动升格 `kpi / dumbbell / radar / quadrant / heatmap / code / mockup`、拆分超长要点墙并抢救平庸标题与裸结尾。用户手头有优质 GitHub / 企业 `.pptx` 目录时,直接调 `ppt_absorb({ corpusDir })`(或 CLI `--ingest-exemplars <dir>`)批量投喂至 `.dsh-ppt/exemplars.json` 与 `.dsh-ppt/taste-recipes.json` 持久化复用。
|
|
25
|
+
6. **8 套大师品味配方(Taste Recipes)与单份母版吸收**:无外部模板时也可独立选用 `taste: 'mckinsey-partner' | 'apple-keynote-dark' | 'apple-keynote-light' | 'swiss-editorial' | 'linear-craft' | 'ft-data-journal' | 'nature-academic' | 'oriental-zen'` 驱动 4 套海报封面、4 种卡片材质与 61 枚原生矢量图标;单份标杆 `.pptx` 用 `ppt_absorb`(`saveTasteAs` / `saveExemplarAs`)或 `referencePptx` + `cloneStructure: true` 吸收。
|
|
25
26
|
|
|
26
27
|
## 执行纪律(每次都要遵守)
|
|
27
28
|
|
|
@@ -48,6 +49,7 @@ allowed-tools: "Bash, Read, Write, Edit"
|
|
|
48
49
|
|
|
49
50
|
| 何时必读 | 参考文件 | 核心内容 |
|
|
50
51
|
| --- | --- | --- |
|
|
52
|
+
| 按标杆范本槽位填空或批量投喂 `.pptx` 语料 | `references/exemplars.md` | 8 套标杆范本槽位契约、`ppt_templates(exemplarId)`、批量 `--ingest-exemplars` 与弱模型升维补偿器 |
|
|
51
53
|
| 写大纲、标题与正文前 | `references/copywriting.md` | 六大画像叙事骨架、Action Title 写法、字数预算、反空话与双语规范 |
|
|
52
54
|
| 选主题、配色、骨架或吸收母版 | `references/themes.md` | 18 套大师主题色板(12 浅 6 深)、6 套母版骨架(Chrome)、18 语义 Token、六大画像选型树 |
|
|
53
55
|
| 写结构化 `slides` 或扩展 Markdown | `references/syntax.md` | 24 套原生版式与专业图示 + `variant`、统一 `items` 结构、`:::` 容器指令、三线表与 `takeaway` |
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# 标杆范本库与槽位填空契约(Curated Exemplar Corpus & Weak-LLM Compensator)
|
|
2
|
+
|
|
3
|
+
本参考面向两类高频需求:
|
|
4
|
+
1. **将自由规划降维为「槽位填空(Slot-Filling)」**:直接按内置 **8 套满分标杆范本**(或工作区批量吸收的优质 `.pptx` 范本)逐页填空,让任意能力层级的模型稳定产出麦肯锡 / 红杉 / Stripe / Nature 级排版。
|
|
5
|
+
2. **向工作区投喂外部优质 PPT 语料**:把本地或开源社区收集的高颜值 `.pptx` 目录批量吸收为持久化范本库(`.dsh-ppt/exemplars.json` + `.dsh-ppt/taste-recipes.json`),零额外运行时依赖、100% 离线提取且自动过滤隐藏说明页。
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. 内置 8 套标杆范本速查表
|
|
10
|
+
|
|
11
|
+
| Exemplar ID | 场景名称 | 继承主题 | 继承品味配方 | 骨架 | 页数与版式节奏 |
|
|
12
|
+
| --- | --- | --- | --- | --- | --- |
|
|
13
|
+
| `mckinsey-strategy` | 麦肯锡战略诊断与破局报告 | `consulting` | `mckinsey-partner` | `consulting-classic` | 10 页:architectural 封面 → exec-summary → spotlight KPI → agenda → Marimekko → 魔力象限 → agenda → 哑铃跃迁 → 甘特图 → cta-cards |
|
|
14
|
+
| `sequoia-pitch` | 红杉 / YC 创投融资路演 BP | `venture-daylight` | `apple-keynote-light` | `keynote-spatial` | 10 页:keynote-glow 封面 → 金句宣言 → 痛点对比 → browser 原型 → spotlight KPI → TAM 同心圆 → 魔力象限 → 桑基盈利流 → 团队图谱 → cta-cards |
|
|
15
|
+
| `stripe-product-launch` | Stripe / Apple 科技产品与开发者发布 | `stripe-craft` | `linear-craft` | `saas-bento` | 10 页:grid 光晕封面 → 无框大数字 → bento-hero → browser 原型 → mobile 原型 → 语法高亮代码 → 6 维雷达图 → 哑铃提速 → 甘特图 → cta-cards |
|
|
16
|
+
| `quarterly-exec-review` | 季度经营复盘与董事会汇报 | `financial-ft` | `ft-data-journal` | `editorial-folio` | 9 页:editorial-grid 封面 → spotlight KPI → 区域热力图 → 瀑布利润桥 → 桑基资金流 → 价值链箭头 → 痛点对策 → 甘特图 → cta-cards |
|
|
17
|
+
| `tech-arch-rfc` | 核心技术架构评审与系统重构 RFC | `stripe-craft` | `linear-craft` | `saas-bento` | 9 页:grid 光晕封面 → 新旧对比 → 分层拓扑 → Mermaid 流程图 → Mermaid 时序图 → 语法高亮代码 → 6 维权衡雷达 → 灰度甘特 → 准出清单 |
|
|
18
|
+
| `academic-defense` | Nature / 顶会学术答辩与实验报告 | `academic` | `nature-academic` | `academic-minimal` | 9 页:editorial-grid 封面 → 动机与贡献 → 原生公式定理框 → 方法流程图 → booktabs 三线表 → 消融哑铃图 → 泛化热力图 → 边界对比 → 总结致谢 |
|
|
19
|
+
| `enterprise-proposal` | 政企大客户解决方案与竞标提案 | `bcg-emerald` | `mckinsey-partner` | `consulting-classic` | 9 页:architectural 封面 → 价值摘要 → 痛点对策 → 私有化部署架构 → 哈维球盲测 → ROI 指标 → 12 周甘特 → SLA 团队 → POC 行动卡 |
|
|
20
|
+
| `gov-institutional` | 现代东方政务述职与年度工作报告 | `exec-jilan` | `oriental-zen` | `gov-ceremonial` | 8 页:inverted 封面 → spotlight KPI → 重点成果卡片 → 区域热力图 → 阶段推进时间轴 → 问题与整改 → 下阶段部署甘特 → 结语 |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## 2. 弱/中等模型标准两步出稿法(推荐)
|
|
25
|
+
|
|
26
|
+
### Step 1:拉取目标范本的逐页槽位契约
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
// Agent 工具调用:
|
|
30
|
+
ppt_templates({ "exemplarId": "mckinsey-strategy", "lang": "zh" })
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
或 CLI 查看全部范本:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
node skills/dsh-ppt/scripts/build-deck.mjs --list-exemplars
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Step 2:按槽位填空并传 `exemplar` 生成
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
// Agent 工具调用(传结构化 slides 或粗纲 Markdown 均可):
|
|
43
|
+
ppt_create({
|
|
44
|
+
"title": "2026 华东区企业级增长破局战略",
|
|
45
|
+
"exemplar": "mckinsey-strategy",
|
|
46
|
+
"content": "# 2026 华东区企业级增长破局战略\n..."
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
或 CLI:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
node skills/dsh-ppt/scripts/build-deck.mjs \
|
|
54
|
+
--title "2026 华东区企业级增长破局战略" \
|
|
55
|
+
--exemplar mckinsey-strategy \
|
|
56
|
+
--content @notes.md \
|
|
57
|
+
--out dist
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 3. 批量向工作区投喂外部优质 `.pptx`(如开源 GitHub / 企业模板)
|
|
63
|
+
|
|
64
|
+
把你收集的优质 `.pptx`(例如 MIT / CC0 开源模板或公司设计部标准模板)放入任意本地目录,一条命令或工具调用即可批量扫描、过滤隐藏说明页、提取色板/双字体/母版骨架/逐页版式序列,自动持久化至 `.dsh-ppt/exemplars.json` 与 `.dsh-ppt/taste-recipes.json`:
|
|
65
|
+
|
|
66
|
+
### Agent 工具(`ppt_absorb`)
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
// 批量吸收整个文件夹(最多 40 份)
|
|
70
|
+
ppt_absorb({ "corpusDir": "./my-reference-decks", "limit": 20 })
|
|
71
|
+
|
|
72
|
+
// 或单份深度吸收并保存为可复用范本
|
|
73
|
+
ppt_absorb({
|
|
74
|
+
"pptxPath": "./company-q4-master.pptx",
|
|
75
|
+
"saveTasteAs": "corp-master",
|
|
76
|
+
"saveExemplarAs": "corp-q4",
|
|
77
|
+
"exemplarName": "公司 Q4 经营汇报标杆"
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### CLI 命令
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# 批量吸收目录
|
|
85
|
+
node skills/dsh-ppt/scripts/build-deck.mjs --ingest-exemplars ./my-reference-decks
|
|
86
|
+
|
|
87
|
+
# 单份吸收并存为范本
|
|
88
|
+
node skills/dsh-ppt/scripts/build-deck.mjs --absorb ./company-q4-master.pptx --save-exemplar corp-q4
|
|
89
|
+
|
|
90
|
+
# 立即使用刚吸收的范本生成新文稿
|
|
91
|
+
node skills/dsh-ppt/scripts/build-deck.mjs --title "2026 Q1 汇报" --exemplar corp-q4 --content @notes.md --out dist
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 4. 确定性防退化升维器(Weak-LLM Compensator,`autoUpgrade`)
|
|
97
|
+
|
|
98
|
+
即使模型输出了粗糙的连续 `bullets` 文字墙或平庸标题,只要未显式设置 `autoUpgrade: false`(或 CLI `--no-auto-upgrade`),引擎会在落盘前以 **0 额外模型调用、100% 文本无损** 确定性执行四重修复:
|
|
99
|
+
|
|
100
|
+
1. **高阶视觉语义自动升维**:
|
|
101
|
+
- 含代码块/函数声明 → 自动升格 `code[split]` 语法高亮代码页;
|
|
102
|
+
- 含多组「旧值 → 新值 / 改造前→后」数值跃迁 → 自动升格 `dumbbell` 哑铃图;
|
|
103
|
+
- 含 4–6 维评分(如「性能 94 vs 行业 70」)→ 自动升格 `radar` 多维雷达图;
|
|
104
|
+
- 含坐标/象限分布信号 → 自动升格 `quadrant` 魔力象限;
|
|
105
|
+
- 含区域/季度纯数值矩阵表 → 自动升格 `heatmap` 热力图;
|
|
106
|
+
- 含 URL / Web / App 界面特性 → 自动升格 `mockup[browser|mobile]` 设备原型;
|
|
107
|
+
- 含 3+ 核心指标大数字 → 自动升格 `kpi[spotlight]` 聚光灯指标卡。
|
|
108
|
+
2. **范本槽位节奏投影**:传 `exemplar` 时,把兼容的普通 `bullets` 页按标杆范本对应页序投影为 `cards[exec-summary/bento-hero]`、`comparison[issue-action]`、`process[steps/chevron]`、`closing[cta-cards]`,继承封面/章节变体。
|
|
109
|
+
3. **防文字墙与防单调连页**:
|
|
110
|
+
- 单页 `>6` 条 bullets 自动拆分为两页(`(续)` / `(Cont.)`),杜绝挤压溢出;
|
|
111
|
+
- 连续 `>=2` 页 `bullets` 自动打断为 `cards` / `comparison` / `process`;
|
|
112
|
+
- 无加粗引导词的长要点自动切分加粗 `**主语**:说明`,提升扫视效率。
|
|
113
|
+
4. **反 AI 土味标题与结尾兜底(`SLOP-01 / 02 / 09`)**:
|
|
114
|
+
- 「项目背景 / 核心指标 / 竞品分析 / 性能提升 / 总结」等空洞标签自动结合正文首条核心结论提炼为 Action Title;
|
|
115
|
+
- 自动补齐有意义的章节面包屑 `kicker`;
|
|
116
|
+
- 仅写「谢谢 / Thank you」的裸结尾自动补齐可执行行动副标题与下一步指引。
|
|
@@ -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, listAllTasteRecipes } from './deck-advanced.mjs'
|
|
20
|
+
import { buildDeckAsync, listTemplates, editDeck, undoDeck, checkDeckAsync, renderDeck, absorbPptx, importPptxDeck, importOfficeDeck, listAllTasteRecipes, listCuratedExemplars, loadWorkspaceExemplars, ingestExemplarCorpus } from './deck-advanced.mjs'
|
|
21
21
|
|
|
22
22
|
const HELP = `dsh-ppt —— 一句话 / 一篇文档 → HTML 放映 + PPTX 导出
|
|
23
23
|
|
|
@@ -34,6 +34,11 @@ const HELP = `dsh-ppt —— 一句话 / 一篇文档 → HTML 放映 + PPTX 导
|
|
|
34
34
|
--clone-structure 配合 --reference-pptx 使用,克隆参考文稿的逐页版式骨架与母版 chrome
|
|
35
35
|
--chrome <style> 母版骨架风格:${CHROME_STYLE_IDS.join(' / ')}
|
|
36
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
|
+
--exemplar <id> 标杆范本槽位契约 ID(8 套内置满分范本或 .dsh-ppt/exemplars.json 已吸收范本,锁定叙事节奏与版式升维)
|
|
38
|
+
--list-exemplars 列出内置 8 套满分标杆范本及工作区已吸收的标杆 .pptx 范本
|
|
39
|
+
--ingest-exemplars <dir> 批量吸收目录下所有优质 .pptx 语料并持久化至 .dsh-ppt/exemplars.json 与 taste-recipes.json
|
|
40
|
+
--save-exemplar <id> 配合 --absorb 将单份标杆 .pptx 同步保存为可复用范本契约
|
|
41
|
+
--no-auto-upgrade 关闭弱模型自动兜底升维与反文字墙拆分
|
|
37
42
|
--save-taste <id> 配合 --absorb 将标杆 .pptx 深度提炼并保存为可复用品味配方
|
|
38
43
|
--list-tastes 列出内置 8 套大师审美配方及当前工作区已吸收的标杆配方
|
|
39
44
|
--absorb <deck.pptx> 只读检查并输出参考 .pptx 的净化主题、推荐内置主题/骨架、深度审美配方 styleRecipe 与逐页分布 JSON
|
|
@@ -95,6 +100,11 @@ export function parseArgv(argv) {
|
|
|
95
100
|
else if (key === '--list-themes') args.listThemes = true
|
|
96
101
|
else if (key === '--list-templates') args.listTemplates = true
|
|
97
102
|
else if (key === '--list-tastes') args.listTastes = true
|
|
103
|
+
else if (key === '--list-exemplars') args.listExemplars = true
|
|
104
|
+
else if (key === '--exemplar') args.exemplar = nextValue()
|
|
105
|
+
else if (key === '--ingest-exemplars') args.ingestExemplars = nextValue()
|
|
106
|
+
else if (key === '--save-exemplar') args.saveExemplar = nextValue()
|
|
107
|
+
else if (key === '--no-auto-upgrade') args.autoUpgrade = false
|
|
98
108
|
else if (key === '--overwrite') args.overwrite = true
|
|
99
109
|
else if (key === '--smart-layout') args.smartLayout = true
|
|
100
110
|
else if (key === '--no-smart-layout') args.smartLayout = false
|
|
@@ -166,6 +176,12 @@ export async function main(argv = process.argv.slice(2), io = {}) {
|
|
|
166
176
|
}
|
|
167
177
|
if (args.listTemplates) { log(JSON.stringify({ templates: listTemplates(args.lang) }, null, 2)); return 0 }
|
|
168
178
|
if (args.listTastes) { log(JSON.stringify({ tasteRecipes: listAllTasteRecipes(process.cwd()) }, null, 2)); return 0 }
|
|
179
|
+
if (args.listExemplars) { log(JSON.stringify({ exemplars: listCuratedExemplars(loadWorkspaceExemplars(process.cwd())) }, null, 2)); return 0 }
|
|
180
|
+
if (args.ingestExemplars) {
|
|
181
|
+
const report = await ingestExemplarCorpus({ dirPath: args.ingestExemplars, cwd: process.cwd() })
|
|
182
|
+
log(JSON.stringify(report, null, 2))
|
|
183
|
+
return 0
|
|
184
|
+
}
|
|
169
185
|
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
186
|
throw new Error('dsh-ppt CLI:--edit / --undo / --check / --render / --absorb / --import-pptx / --sync-pptx / --from-office 只能选择一项')
|
|
171
187
|
}
|
|
@@ -219,6 +235,7 @@ export async function main(argv = process.argv.slice(2), io = {}) {
|
|
|
219
235
|
const absorbed = await absorbPptx({
|
|
220
236
|
pptxPath: args.absorb,
|
|
221
237
|
...(args.saveTaste ? { saveTasteAs: args.saveTaste } : {}),
|
|
238
|
+
...(args.saveExemplar ? { saveExemplarAs: args.saveExemplar } : {}),
|
|
222
239
|
})
|
|
223
240
|
log(JSON.stringify(absorbed, null, 2))
|
|
224
241
|
return 0
|
|
@@ -270,6 +287,8 @@ export async function main(argv = process.argv.slice(2), io = {}) {
|
|
|
270
287
|
slides,
|
|
271
288
|
theme: args.theme,
|
|
272
289
|
...(args.taste ? { taste: args.taste } : {}),
|
|
290
|
+
...(args.exemplar ? { exemplar: args.exemplar } : {}),
|
|
291
|
+
...(args.autoUpgrade !== undefined ? { autoUpgrade: args.autoUpgrade } : {}),
|
|
273
292
|
persona: args.persona,
|
|
274
293
|
referencePptx: args.referencePptx,
|
|
275
294
|
cloneStructure: args.cloneStructure,
|
|
@@ -18,6 +18,7 @@ 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
20
|
import { sanitizeCustomTasteRecipe, saveWorkspaceTasteRecipe } from './deck-taste.mjs'
|
|
21
|
+
import { extractExemplarFromAbsorbed, saveWorkspaceExemplar } from './deck-exemplars.mjs'
|
|
21
22
|
|
|
22
23
|
const MAX_PPTX_BYTES = 64 * 1024 * 1024
|
|
23
24
|
const MAX_LOGO_BYTES = 2 * 1024 * 1024
|
|
@@ -498,6 +499,8 @@ function inspectTableForHarveyAndStyle(lib, tables) {
|
|
|
498
499
|
function analyzeSlideLayout(lib, slide, slideIndex, totalSlides, slideW, slideH) {
|
|
499
500
|
const result = { slideNumber: slideIndex + 1, inferredLayout: 'bullets' }
|
|
500
501
|
try {
|
|
502
|
+
const slideXmlStr = typeof slide?.xml === 'string' ? slide.xml : ''
|
|
503
|
+
if (/<p:sld\b[^>]*\bshow="0"/.test(slideXmlStr)) result.hidden = true
|
|
501
504
|
const rawShapes = lib.getSlideShapes(slide) ?? []
|
|
502
505
|
const shapes = flattenShapes(lib, rawShapes)
|
|
503
506
|
let layoutType = ''
|
|
@@ -1427,9 +1430,9 @@ export async function absorbPptx(options = {}) {
|
|
|
1427
1430
|
savedTastePath = saved.path
|
|
1428
1431
|
}
|
|
1429
1432
|
|
|
1430
|
-
|
|
1433
|
+
const baseResult = {
|
|
1431
1434
|
ok: true,
|
|
1432
|
-
...(resolvedPath ? { pptxPath: resolvedPath } : {}),
|
|
1435
|
+
...(resolvedPath ? { pptxPath: resolvedPath, sourceFile: basename(resolvedPath) } : {}),
|
|
1433
1436
|
slideCount,
|
|
1434
1437
|
slideSize,
|
|
1435
1438
|
extractedPalette,
|
|
@@ -1446,6 +1449,27 @@ export async function absorbPptx(options = {}) {
|
|
|
1446
1449
|
warnings: sanitized.warnings,
|
|
1447
1450
|
layoutSummary,
|
|
1448
1451
|
extractedSkeleton,
|
|
1449
|
-
slideSkeleton
|
|
1452
|
+
slideSkeleton: slideSkeleton.map((entry) => (
|
|
1453
|
+
entry.titleSample && /\(hidden\)|模板说明|使用说明|template\s+instructions/i.test(entry.titleSample)
|
|
1454
|
+
? { ...entry, hidden: true }
|
|
1455
|
+
: entry
|
|
1456
|
+
)),
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
let savedExemplarPath
|
|
1460
|
+
let exemplar
|
|
1461
|
+
if (typeof options.saveExemplarAs === 'string' && options.saveExemplarAs.trim()) {
|
|
1462
|
+
const extracted = extractExemplarFromAbsorbed(baseResult, {
|
|
1463
|
+
id: options.saveExemplarAs.trim(),
|
|
1464
|
+
name: options.tasteName || options.exemplarName,
|
|
1465
|
+
})
|
|
1466
|
+
const savedEx = saveWorkspaceExemplar(cwd, extracted)
|
|
1467
|
+
savedExemplarPath = savedEx.path
|
|
1468
|
+
exemplar = savedEx.exemplar
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
return {
|
|
1472
|
+
...baseResult,
|
|
1473
|
+
...(savedExemplarPath ? { savedExemplarPath, exemplar } : {}),
|
|
1450
1474
|
}
|
|
1451
1475
|
}
|