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
|
@@ -3,8 +3,8 @@ import { resolve, dirname, extname, basename, join } from 'node:path'
|
|
|
3
3
|
import { createHash, randomUUID } from 'node:crypto'
|
|
4
4
|
import { inflateSync } from 'node:zlib'
|
|
5
5
|
import { buildPptx, renderHtml, normalizeBuildOptions, normalizeSlides, resolveLanguage, resolveDeckFileName, commitDeckArtifacts, DECK_VERSION, buildDeck } from './deck-core.mjs'
|
|
6
|
-
import { listThemes, listMasterPresets, resolveTheme, buildThemePreview as buildThemePreviewFromThemes, deriveBrandedTheme, pptxEastAsianFont } from './deck-themes.mjs'
|
|
7
|
-
import { CORE_LAYOUTS, LAYOUT_ALIASES, stripInlineMarkdown } from './deck-layouts.mjs'
|
|
6
|
+
import { listThemes, listMasterPresets, resolveTheme, resolveChromeStyle, buildThemePreview as buildThemePreviewFromThemes, deriveBrandedTheme, pptxEastAsianFont } from './deck-themes.mjs'
|
|
7
|
+
import { CORE_LAYOUTS, LAYOUT_ALIASES, stripInlineMarkdown, computeMockupGeometry, getChromeConfig } from './deck-layouts.mjs'
|
|
8
8
|
import { MEDIA_LAYOUTS, mediaBoxes, LOGO_BOX, FOOTER_BOX, normalizeChart, buildOfficeKitChartSpec, computeWaterfallGeometry } from './deck-media.mjs'
|
|
9
9
|
import { normalizeDataModel, prepareDataSlides, validateDataSnapshot, previewDataChange, dataNotes, dataReport } from './deck-data.mjs'
|
|
10
10
|
import { normalizeVisual, applyVisualActions } from './deck-visual.mjs'
|
|
@@ -23,6 +23,19 @@ import {
|
|
|
23
23
|
listAllTasteRecipes,
|
|
24
24
|
listCuratedTasteRecipes,
|
|
25
25
|
} from './deck-taste.mjs'
|
|
26
|
+
import {
|
|
27
|
+
CURATED_EXEMPLARS,
|
|
28
|
+
CURATED_EXEMPLAR_IDS,
|
|
29
|
+
listCuratedExemplars,
|
|
30
|
+
resolveExemplar,
|
|
31
|
+
loadWorkspaceExemplars,
|
|
32
|
+
saveWorkspaceExemplar,
|
|
33
|
+
extractExemplarFromAbsorbed,
|
|
34
|
+
ingestExemplarDirectory,
|
|
35
|
+
matchBestExemplar,
|
|
36
|
+
renderExemplarPromptGuide,
|
|
37
|
+
} from './deck-exemplars.mjs'
|
|
38
|
+
import { upgradeWeakDeck } from './deck-upgrader.mjs'
|
|
26
39
|
export { readRenderReceipt } from './deck-render.mjs'
|
|
27
40
|
export { dataNotes, dataReport } from './deck-data.mjs'
|
|
28
41
|
export { buildDeck, resolveLanguage } from './deck-core.mjs'
|
|
@@ -33,6 +46,30 @@ export { renderHandoutMarkdown, computePaceBudget, renderOnePagerHtml } from './
|
|
|
33
46
|
export { extractOfficeSource, importOfficeDeck } from './deck-office.mjs'
|
|
34
47
|
export { inferThemeFromContent, optimizeVisualRhythm } from './deck-director.mjs'
|
|
35
48
|
export { listAllTasteRecipes, listCuratedTasteRecipes, loadWorkspaceTasteRecipes, saveWorkspaceTasteRecipe, resolveTasteRecipe } from './deck-taste.mjs'
|
|
49
|
+
export {
|
|
50
|
+
CURATED_EXEMPLARS,
|
|
51
|
+
CURATED_EXEMPLAR_IDS,
|
|
52
|
+
listCuratedExemplars,
|
|
53
|
+
resolveExemplar,
|
|
54
|
+
loadWorkspaceExemplars,
|
|
55
|
+
saveWorkspaceExemplar,
|
|
56
|
+
extractExemplarFromAbsorbed,
|
|
57
|
+
ingestExemplarDirectory,
|
|
58
|
+
matchBestExemplar,
|
|
59
|
+
renderExemplarPromptGuide,
|
|
60
|
+
} from './deck-exemplars.mjs'
|
|
61
|
+
export { upgradeWeakDeck } from './deck-upgrader.mjs'
|
|
62
|
+
|
|
63
|
+
export async function ingestExemplarCorpus(options = {}) {
|
|
64
|
+
return ingestExemplarDirectory({
|
|
65
|
+
dirPath: options.dirPath,
|
|
66
|
+
cwd: options.cwd || '.',
|
|
67
|
+
limit: options.limit,
|
|
68
|
+
signal: options.signal,
|
|
69
|
+
absorbFn: absorbPptx,
|
|
70
|
+
saveTasteFn: (cwdPath, recipe) => saveWorkspaceTasteRecipe(recipe, cwdPath),
|
|
71
|
+
})
|
|
72
|
+
}
|
|
36
73
|
|
|
37
74
|
export function buildThemePreview(options = {}) {
|
|
38
75
|
return buildThemePreviewFromThemes(options, resolveLanguage, DECK_VERSION)
|
|
@@ -222,8 +259,8 @@ function validateRawSlides(slides) {
|
|
|
222
259
|
const eff = effectiveLayout(s.layout)
|
|
223
260
|
const hasImg = Boolean(s.image || (Array.isArray(s.images) && s.images.length > 0))
|
|
224
261
|
if (s.chart && hasImg) fail(`第 ${i + 1} 页不能同时放入 image 和 chart`)
|
|
225
|
-
if (hasImg && eff && !['image', 'image-left', 'image-right'].includes(eff)) fail(`第 ${i + 1} 页图片需使用 image / image-left / image-right / gallery 布局`)
|
|
226
|
-
if (s.chart && eff && !['chart', 'chart-split'].includes(eff)) fail(`第 ${i + 1} 页图表需使用 chart / chart-split / waterfall 布局`)
|
|
262
|
+
if (hasImg && eff && !['image', 'image-left', 'image-right', 'cover', 'mockup'].includes(eff)) fail(`第 ${i + 1} 页图片需使用 image / image-left / image-right / gallery / cover / mockup 布局`)
|
|
263
|
+
if (s.chart && eff && !['chart', 'chart-split', 'radar'].includes(eff)) fail(`第 ${i + 1} 页图表需使用 chart / chart-split / waterfall / radar 布局`)
|
|
227
264
|
})
|
|
228
265
|
}
|
|
229
266
|
|
|
@@ -425,9 +462,22 @@ async function exportPptx(manifest, theme, language, signal) {
|
|
|
425
462
|
if (img?.assetId) putImage(slide, img.assetId, gBox, img.fit || 'cover', `Gallery image ${gIdx + 1}`, img.alt)
|
|
426
463
|
})
|
|
427
464
|
} else if (source.image) {
|
|
428
|
-
|
|
465
|
+
let targetBox = boxes.image
|
|
466
|
+
let targetFit = source.image.fit
|
|
467
|
+
if (source.layout === 'cover') {
|
|
468
|
+
targetBox = { x: 6.65, y: 0, w: 6.6833, h: 7.5 }
|
|
469
|
+
targetFit = source.image.fit || 'cover'
|
|
470
|
+
} else if (source.layout === 'mockup') {
|
|
471
|
+
const chromeStyle = resolveChromeStyle(theme, source, manifest.brand)
|
|
472
|
+
const chromeCfg = getChromeConfig(chromeStyle, theme)
|
|
473
|
+
const hasTakeaway = typeof source.takeaway === 'string' && source.takeaway.trim() !== ''
|
|
474
|
+
const bodyH = (hasTakeaway ? 6.08 : 6.72) - chromeCfg.bodyTopY
|
|
475
|
+
targetBox = computeMockupGeometry(source, chromeCfg.bodyTopY, bodyH).screenBox
|
|
476
|
+
targetFit = source.image.fit || 'cover'
|
|
477
|
+
}
|
|
478
|
+
putImage(slide, source.image.assetId, targetBox, targetFit, 'Slide image', source.image.alt)
|
|
429
479
|
}
|
|
430
|
-
if (source.chart) {
|
|
480
|
+
if (source.chart && source.layout !== 'radar') {
|
|
431
481
|
if (source.chart.kind === 'waterfall') {
|
|
432
482
|
if (!lib.findShapeByName(slide, 'Waterfall Bar 1')) {
|
|
433
483
|
drawNativeWaterfallWithKit(lib, slide, source.chart, boxes.chart, theme)
|
|
@@ -470,6 +520,7 @@ function result(manifest, paths, writeHandout = false, writeOnePager = false) {
|
|
|
470
520
|
undoAvailable: manifest.history.length, deliveryStatus: manifest.quality?.issues.some(i => i.code === 'template-unfilled') ? 'draft' : 'ready-for-review',
|
|
471
521
|
quality: manifest.quality, paceBudget, verification: { static: 'checked', pptxRender: 'not-verified', visual: 'not-verified' }, outputDir: dirname(paths.json),
|
|
472
522
|
files: paths, htmlPath: paths.html, pptxPath: paths.pptx, jsonPath: paths.json,
|
|
523
|
+
...(manifest.exemplar ? { exemplar: manifest.exemplar } : {}),
|
|
473
524
|
...(writeHandout ? { handoutPath } : {}),
|
|
474
525
|
...(writeOnePager ? { onePagerPath } : {}) }
|
|
475
526
|
}
|
|
@@ -620,9 +671,20 @@ export async function buildDeckAsync(options = {}) {
|
|
|
620
671
|
absorbed = await absorbPptx({ pptxPath: String(options.referencePptx).trim(), cwd, extractLogo: true, signal: options.signal })
|
|
621
672
|
}
|
|
622
673
|
|
|
674
|
+
const workspaceExemplars = loadWorkspaceExemplars(cwd)
|
|
675
|
+
const resolvedExemplar = options.exemplar !== undefined && options.exemplar !== null && options.exemplar !== ''
|
|
676
|
+
? resolveExemplar(options.exemplar, workspaceExemplars)
|
|
677
|
+
: null
|
|
678
|
+
if (options.exemplar !== undefined && options.exemplar !== null && options.exemplar !== '' && !resolvedExemplar) {
|
|
679
|
+
fail('未知标杆范本 exemplar:' + String(options.exemplar))
|
|
680
|
+
}
|
|
681
|
+
|
|
623
682
|
const workspaceTastes = loadWorkspaceTasteRecipes(cwd)
|
|
624
|
-
const
|
|
625
|
-
?
|
|
683
|
+
const effectiveTasteInput = (options.taste !== undefined && options.taste !== null && options.taste !== '')
|
|
684
|
+
? options.taste
|
|
685
|
+
: (resolvedExemplar?.styleRecipe || resolvedExemplar?.taste || undefined)
|
|
686
|
+
const resolvedTaste = effectiveTasteInput !== undefined
|
|
687
|
+
? resolveTasteRecipe(effectiveTasteInput, workspaceTastes)
|
|
626
688
|
: (absorbed?.styleRecipe && options.cloneStructure === true ? absorbed.styleRecipe : null)
|
|
627
689
|
if (options.taste !== undefined && options.taste !== null && options.taste !== '' && !resolvedTaste) {
|
|
628
690
|
fail('未知品味配方 taste:' + String(options.taste))
|
|
@@ -631,8 +693,10 @@ export async function buildDeckAsync(options = {}) {
|
|
|
631
693
|
const rawThemeOpt = typeof options.theme === 'string' && options.theme.trim() ? options.theme.trim() : undefined
|
|
632
694
|
let chosenThemeId = rawThemeOpt
|
|
633
695
|
let directorHint = null
|
|
634
|
-
if (chosenThemeId === 'auto' || (!chosenThemeId && (options.persona || absorbed || scenario || resolvedTaste))) {
|
|
635
|
-
if (
|
|
696
|
+
if (chosenThemeId === 'auto' || (!chosenThemeId && (options.persona || absorbed || scenario || resolvedTaste || resolvedExemplar))) {
|
|
697
|
+
if (resolvedExemplar?.theme && (!rawThemeOpt || rawThemeOpt === 'auto') && !options.persona) {
|
|
698
|
+
chosenThemeId = resolvedExemplar.theme
|
|
699
|
+
} else if (resolvedTaste?.theme && (!rawThemeOpt || rawThemeOpt === 'auto') && !options.persona) {
|
|
636
700
|
chosenThemeId = resolvedTaste.theme
|
|
637
701
|
} else if (absorbed && (!rawThemeOpt || rawThemeOpt === 'auto') && !options.persona && !scenario) {
|
|
638
702
|
chosenThemeId = absorbed.recommendedTheme
|
|
@@ -664,16 +728,30 @@ export async function buildDeckAsync(options = {}) {
|
|
|
664
728
|
const normalized = normalizeBuildOptions({ ...input, ...(prepared ? { slides: prepared } : {}) })
|
|
665
729
|
if (prepared) normalized.deck.slides = prepared
|
|
666
730
|
|
|
731
|
+
let upgradeReport = null
|
|
732
|
+
const shouldPromote = options.smartLayout === true || (options.smartLayout !== false && (rawThemeOpt === 'auto' || Boolean(options.persona) || Boolean(absorbed) || Boolean(resolvedExemplar)))
|
|
667
733
|
if (fromMarkdown) {
|
|
668
734
|
if (absorbed && options.cloneStructure === true && Array.isArray(absorbed.slideSkeleton) && absorbed.slideSkeleton.length > 0) {
|
|
669
735
|
normalized.deck.slides = mapSlidesToAbsorbedSkeleton(normalized.deck.slides, absorbed.slideSkeleton, langId)
|
|
670
|
-
} else {
|
|
671
|
-
|
|
672
|
-
if (shouldPromote) {
|
|
673
|
-
normalized.deck.slides = promoteMarkdownSlides(normalized.deck.slides, { explicitSmartLayout: options.smartLayout === true })
|
|
674
|
-
}
|
|
736
|
+
} else if (shouldPromote) {
|
|
737
|
+
normalized.deck.slides = promoteMarkdownSlides(normalized.deck.slides, { explicitSmartLayout: options.smartLayout === true })
|
|
675
738
|
}
|
|
676
739
|
}
|
|
740
|
+
const shouldAutoUpgrade = !dataModel && options.autoUpgrade !== false && options.smartLayout !== false && (
|
|
741
|
+
options.autoUpgrade === true ||
|
|
742
|
+
Boolean(resolvedExemplar) ||
|
|
743
|
+
(fromMarkdown && shouldPromote) ||
|
|
744
|
+
(Array.isArray(options.slides) && options.slides.length >= 4 && (rawThemeOpt === 'auto' || Boolean(options.persona)))
|
|
745
|
+
)
|
|
746
|
+
if (shouldAutoUpgrade) {
|
|
747
|
+
const upgraded = upgradeWeakDeck(normalized.deck.slides, {
|
|
748
|
+
exemplar: resolvedExemplar,
|
|
749
|
+
lang: langId,
|
|
750
|
+
allowSplit: !fromMarkdown || normalized.deck.slides.length <= 24,
|
|
751
|
+
})
|
|
752
|
+
normalized.deck.slides = upgraded.slides
|
|
753
|
+
if (upgraded.report.applied) upgradeReport = upgraded.report
|
|
754
|
+
}
|
|
677
755
|
if (directorHint?.tableStyle === 'booktabs' || resolvedTaste?.tableStyle) {
|
|
678
756
|
const effTableStyle = resolvedTaste?.tableStyle || directorHint?.tableStyle
|
|
679
757
|
normalized.deck.slides = normalized.deck.slides.map(s => s.layout === 'table' && !s.tableStyle ? { ...s, tableStyle: effTableStyle } : s)
|
|
@@ -729,6 +807,7 @@ export async function buildDeckAsync(options = {}) {
|
|
|
729
807
|
language: normalized.language.id,
|
|
730
808
|
motion: normalized.motion,
|
|
731
809
|
...(resolvedTaste ? { taste: listCuratedTasteRecipes().some(r => r.id === resolvedTaste.id) ? resolvedTaste.id : resolvedTaste } : {}),
|
|
810
|
+
...(resolvedExemplar ? { exemplar: resolvedExemplar.id } : {}),
|
|
732
811
|
...(targetMinutesRaw !== undefined ? { targetMinutes: targetMinutesRaw } : {}),
|
|
733
812
|
...(scenario ? { template: scenario.id } : {}),
|
|
734
813
|
...(brand ? { brand } : {}),
|
|
@@ -745,7 +824,8 @@ export async function buildDeckAsync(options = {}) {
|
|
|
745
824
|
const writeHandout = options.handout === true
|
|
746
825
|
const writeOnePager = options.onePager === true
|
|
747
826
|
withLock(paths.json, () => { abort(options.signal); commit(paths, data, writeHandout, writeOnePager) })
|
|
748
|
-
|
|
827
|
+
const builtResult = result(manifest, paths, writeHandout, writeOnePager)
|
|
828
|
+
return upgradeReport ? { ...builtResult, upgradeReport } : builtResult
|
|
749
829
|
}
|
|
750
830
|
|
|
751
831
|
function readDocument(pathInput, cwd = '.') {
|
|
@@ -831,9 +911,9 @@ export async function editDeck(options = {}) {
|
|
|
831
911
|
}
|
|
832
912
|
const used = new Set()
|
|
833
913
|
const allowed = new Set([
|
|
834
|
-
'layout', 'variant', 'chrome', 'cardMaterial', 'iconMode', 'title', 'subtitle', 'kicker', 'takeaway', 'source',
|
|
835
|
-
'text', 'formula', 'mermaid', '
|
|
836
|
-
'columns', 'steps', 'quadrants', 'rows', 'notes', 'image', 'images', 'chart', 'visual',
|
|
914
|
+
'layout', 'variant', 'chrome', 'cardMaterial', 'iconMode', 'coverPattern', 'title', 'subtitle', 'kicker', 'takeaway', 'source',
|
|
915
|
+
'text', 'formula', 'mermaid', 'code', 'language', 'filename', 'url', 'xLabel', 'yLabel', 'activeIndex', 'tableStyle',
|
|
916
|
+
'bullets', 'items', 'cards', 'metrics', 'columns', 'steps', 'quadrants', 'rows', 'notes', 'image', 'images', 'chart', 'visual',
|
|
837
917
|
])
|
|
838
918
|
for (const edit of options.edits ?? []) {
|
|
839
919
|
const index = typeof edit.slide === 'number' && Number.isInteger(edit.slide) ? edit.slide - 1 : next.slides.findIndex(s => s.id === edit.slide)
|
|
@@ -850,18 +930,21 @@ export async function editDeck(options = {}) {
|
|
|
850
930
|
delete changed.items
|
|
851
931
|
}
|
|
852
932
|
if (edit.patch.chart) {
|
|
853
|
-
if (!edit.patch.layout && !['chart', 'chart-split', 'waterfall'].includes(changed.layout)) changed.layout = 'chart'
|
|
854
|
-
if (['chart', 'chart-split', 'waterfall'].includes(changed.layout)) { delete changed.image; delete changed.images }
|
|
933
|
+
if (!edit.patch.layout && !['chart', 'chart-split', 'waterfall', 'radar'].includes(changed.layout)) changed.layout = 'chart'
|
|
934
|
+
if (['chart', 'chart-split', 'waterfall', 'radar'].includes(changed.layout)) { delete changed.image; delete changed.images }
|
|
855
935
|
}
|
|
856
936
|
if (edit.patch.image || edit.patch.images) {
|
|
857
|
-
if (!edit.patch.layout && !['image', 'image-left', 'image-right', 'gallery'].includes(changed.layout)) {
|
|
937
|
+
if (!edit.patch.layout && !['image', 'image-left', 'image-right', 'gallery', 'cover', 'mockup'].includes(changed.layout)) {
|
|
858
938
|
changed.layout = Array.isArray(edit.patch.images) && edit.patch.images.length > 1 ? 'image' : 'image-right'
|
|
859
939
|
}
|
|
860
|
-
if (['image', 'image-left', 'image-right', 'gallery'].includes(changed.layout)) delete changed.chart
|
|
940
|
+
if (['image', 'image-left', 'image-right', 'gallery', 'cover', 'mockup'].includes(changed.layout)) delete changed.chart
|
|
861
941
|
}
|
|
862
942
|
if (edit.patch.layout) {
|
|
863
943
|
const eff = effectiveLayout(edit.patch.layout)
|
|
864
|
-
if (!MEDIA_LAYOUTS.has(eff)) {
|
|
944
|
+
if (!MEDIA_LAYOUTS.has(eff)) {
|
|
945
|
+
if (eff !== 'cover' && eff !== 'mockup') { delete changed.image; delete changed.images }
|
|
946
|
+
if (eff !== 'radar') { delete changed.chart }
|
|
947
|
+
}
|
|
865
948
|
}
|
|
866
949
|
validateRawSlides([changed])
|
|
867
950
|
let slides
|