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
@@ -18,7 +18,7 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, w
18
18
  import { resolve as resolvePath } from 'node:path'
19
19
  import { deflateRawSync } from 'node:zlib'
20
20
  import * as deckMedia from './deck-media.mjs'
21
- import { renderDelivery, renderHandoutMarkdown } from './deck-delivery.mjs'
21
+ import { renderDelivery, renderHandoutMarkdown, renderOnePagerHtml } from './deck-delivery.mjs'
22
22
  import { renderDataView } from './deck-data-view.mjs'
23
23
  import { normalizeVisual, visualHtmlStyle, visualShapeXml, VISUAL_CSS } from './deck-visual.mjs'
24
24
  import {
@@ -78,6 +78,7 @@ import {
78
78
  ooxmlShape,
79
79
  ooxmlCustGeomShape,
80
80
  ooxmlMathShape,
81
+ ooxmlConnector,
81
82
  ooxmlRichParagraph,
82
83
  getChromeConfig,
83
84
  parseHarveyValue,
@@ -85,6 +86,15 @@ import {
85
86
  computeSankeyLayout,
86
87
  partitionValueChainItems,
87
88
  computeSwotModel,
89
+ extractMermaidSource,
90
+ detectMermaidMode,
91
+ parseMermaidFlowchart,
92
+ layoutMermaidFlowchart,
93
+ parseMermaidSequence,
94
+ layoutMermaidSequence,
95
+ compileMermaidSlide,
96
+ renderMermaidPptx,
97
+ renderMermaidHtml,
88
98
  renderSlideChromePptx,
89
99
  renderCoreSlidePptx,
90
100
  renderCoreSlideHtml,
@@ -125,12 +135,22 @@ export {
125
135
  roundRectAdj,
126
136
  ooxmlCustGeomShape,
127
137
  ooxmlMathShape,
138
+ ooxmlConnector,
128
139
  getChromeConfig,
129
140
  parseHarveyValue,
130
141
  computeMarimekkoModel,
131
142
  computeSankeyLayout,
132
143
  partitionValueChainItems,
133
144
  computeSwotModel,
145
+ extractMermaidSource,
146
+ detectMermaidMode,
147
+ parseMermaidFlowchart,
148
+ layoutMermaidFlowchart,
149
+ parseMermaidSequence,
150
+ layoutMermaidSequence,
151
+ compileMermaidSlide,
152
+ renderMermaidPptx,
153
+ renderMermaidHtml,
134
154
  renderSlideChromePptx,
135
155
  containsLatexMath,
136
156
  looksLikeRawLatex,
@@ -391,6 +411,7 @@ function createSection(heading = '', level = 0, coverOnly = false) {
391
411
  notes: [],
392
412
  directive: null,
393
413
  formula: '',
414
+ mermaid: '',
394
415
  takeaway: '',
395
416
  source: '',
396
417
  }
@@ -506,12 +527,14 @@ function directiveSlideFrom(section, ui, pointIndexRef) {
506
527
  const dirRows = section.table && ['marimekko', 'harvey', 'sankey'].includes(spec.layout)
507
528
  ? [section.table.header, ...section.table.rows]
508
529
  : undefined
530
+ const effVariant = spec.variant || (spec.layout === 'mermaid' && section.mermaid ? detectMermaidMode(section.mermaid) : '')
509
531
  const slide = {
510
532
  layout: spec.layout,
511
- ...(spec.variant ? { variant: spec.variant } : {}),
533
+ ...(effVariant ? { variant: effVariant } : {}),
512
534
  kicker: label,
513
535
  title: label,
514
536
  ...(section.formula ? { formula: section.formula } : {}),
537
+ ...(section.mermaid ? { mermaid: section.mermaid } : {}),
515
538
  ...(spec.layout === 'callout' && section.paragraphs[0] ? { text: section.paragraphs[0] } : {}),
516
539
  ...(dirRows ? { rows: dirRows } : {}),
517
540
  ...(rawPoints.length > 0 ? { bullets: rawPoints } : {}),
@@ -543,14 +566,25 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
543
566
  let awaitingTakeawayLine = false
544
567
  let inMathBlock = false
545
568
  let mathBlockLines = []
569
+ let inMermaidFence = false
570
+ let mermaidFenceMarker = ''
571
+ let mermaidFenceLines = []
546
572
 
547
573
  const flush = () => {
574
+ if (inMermaidFence && mermaidFenceLines.length > 0) {
575
+ if (current === null) current = createSection()
576
+ const pendingMermaid = mermaidFenceLines.join('\n').trim()
577
+ if (pendingMermaid !== '') {
578
+ current.mermaid = current.mermaid ? current.mermaid + '\n' + pendingMermaid : pendingMermaid
579
+ }
580
+ }
548
581
  if (
549
582
  current !== null &&
550
583
  (current.heading !== '' ||
551
584
  current.bullets.length > 0 ||
552
585
  current.paragraphs.length > 0 ||
553
586
  current.formula !== '' ||
587
+ current.mermaid !== '' ||
554
588
  current.table !== null ||
555
589
  current.quote.length > 0 ||
556
590
  current.directive !== null)
@@ -562,10 +596,38 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
562
596
  awaitingTakeawayLine = false
563
597
  inMathBlock = false
564
598
  mathBlockLines = []
599
+ inMermaidFence = false
600
+ mermaidFenceMarker = ''
601
+ mermaidFenceLines = []
565
602
  }
566
603
 
567
604
  for (const rawLine of body.split('\n')) {
568
605
  const line = rawLine.trim()
606
+ if (inMermaidFence) {
607
+ if (line.startsWith(mermaidFenceMarker) && new RegExp('^' + mermaidFenceMarker + '\\s*$').test(line)) {
608
+ if (current === null) current = createSection()
609
+ const joinedMermaid = mermaidFenceLines.join('\n').trim()
610
+ if (joinedMermaid !== '') {
611
+ current.mermaid = current.mermaid ? current.mermaid + '\n' + joinedMermaid : joinedMermaid
612
+ }
613
+ inMermaidFence = false
614
+ mermaidFenceMarker = ''
615
+ mermaidFenceLines = []
616
+ } else {
617
+ mermaidFenceLines.push(rawLine)
618
+ }
619
+ continue
620
+ }
621
+
622
+ const mermaidOpen = /^(`{3,}|~{3,})\s*mermaid\b.*$/i.exec(line)
623
+ if (mermaidOpen !== null) {
624
+ if (current === null) current = createSection()
625
+ inMermaidFence = true
626
+ mermaidFenceMarker = mermaidOpen[1]
627
+ mermaidFenceLines = []
628
+ continue
629
+ }
630
+
569
631
  if (inMathBlock) {
570
632
  if (line === '$$') {
571
633
  if (current === null) current = createSection()
@@ -681,6 +743,11 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
681
743
  }
682
744
  awaitingTakeawayLine = false
683
745
 
746
+ if (inDirective && current?.directive?.layout === 'mermaid') {
747
+ current.mermaid = current.mermaid ? current.mermaid + '\n' + rawLine : rawLine
748
+ continue
749
+ }
750
+
684
751
  const bulletMatch = /^\s*(?:[-*+]|\d+[.)])\s+(.+)$/.exec(line)
685
752
  if (bulletMatch !== null) {
686
753
  const bullet = cleanRichText(bulletMatch[1])
@@ -746,10 +813,11 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
746
813
  }
747
814
  }
748
815
 
749
- if (coverSource && (coverSource.table !== null || coverSource.quote.length > 0)) {
816
+ if (coverSource && (coverSource.table !== null || coverSource.quote.length > 0 || coverSource.mermaid !== '')) {
750
817
  const special = createSection()
751
818
  special.table = coverSource.table
752
819
  special.quote = coverSource.quote
820
+ special.mermaid = coverSource.mermaid
753
821
  special.notes = coverSource.notes
754
822
  special.takeaway = coverSource.takeaway
755
823
  special.source = coverSource.source
@@ -769,7 +837,9 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
769
837
  return { title: coverTitle || 'Untitled', subtitle: coverSubtitle, slides }
770
838
  }
771
839
 
772
- const hadHeadings = bodySections.some((section) => section.heading !== '' || section.directive !== null)
840
+ const hadHeadings = bodySections.some(
841
+ (section) => section.heading !== '' || section.directive !== null || section.mermaid !== '',
842
+ )
773
843
 
774
844
  if (!hadHeadings) {
775
845
  const ordered = bodySections.map((section) => ({
@@ -823,6 +893,24 @@ export function parseMarkdownDeck(titleInput, content, lang = 'zh') {
823
893
  continue
824
894
  }
825
895
 
896
+ if (section.mermaid !== '') {
897
+ const label = section.heading || (ui.pointKicker + ' ' + (++pointRef.count))
898
+ const rawPoints = [...section.bullets, ...section.paragraphs]
899
+ const slide = {
900
+ layout: 'mermaid',
901
+ variant: detectMermaidMode(section.mermaid),
902
+ kicker: label,
903
+ title: label,
904
+ mermaid: section.mermaid,
905
+ ...(rawPoints.length > 0 ? { bullets: rawPoints } : {}),
906
+ ...(section.takeaway ? { takeaway: section.takeaway } : {}),
907
+ ...(section.source ? { source: section.source } : {}),
908
+ }
909
+ if (specials.length === 0 && notes !== '') slide.notes = notes
910
+ slides.push(slide)
911
+ continue
912
+ }
913
+
826
914
  if (section.formula !== '') {
827
915
  const label = section.heading || (ui.pointKicker + ' ' + (++pointRef.count))
828
916
  const rawPoints = [...section.bullets, ...section.paragraphs]
@@ -919,17 +1007,26 @@ function normalizeSlideContent(raw, index) {
919
1007
  const rawLayoutKey = String(source.layout ?? '').trim().toLowerCase()
920
1008
  const alias = LAYOUT_ALIASES[rawLayoutKey]
921
1009
  const candidateLayout = alias ? alias.layout : rawLayoutKey
1010
+ const rawMermaid = typeof source.mermaid === 'string'
1011
+ ? source.mermaid.replace(/\r\n?/g, '\n').replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '').trim()
1012
+ : ''
922
1013
  const layout = (CORE_LAYOUTS.has(candidateLayout) || deckMedia.MEDIA_LAYOUTS.has(candidateLayout))
923
1014
  ? candidateLayout
924
1015
  : source.chart
925
1016
  ? 'chart'
926
1017
  : (source.image || (Array.isArray(source.images) && source.images.length > 0))
927
1018
  ? 'image-right'
928
- : 'bullets'
1019
+ : rawMermaid !== ''
1020
+ ? 'mermaid'
1021
+ : 'bullets'
929
1022
 
930
1023
  const variant = stripInlineMarkdown(source.variant ?? alias?.variant ?? '')
931
1024
  const rawChrome = typeof source.chrome === 'string' ? source.chrome.trim() : ''
932
1025
  const chrome = VALID_CHROME_STYLES.has(rawChrome) ? rawChrome : undefined
1026
+ const rawMat = typeof source.cardMaterial === 'string' ? source.cardMaterial.trim().toLowerCase() : ''
1027
+ const cardMaterial = ['solid', 'frameless', 'glass', 'editorial-rule'].includes(rawMat) ? rawMat : undefined
1028
+ const rawIconMode = typeof source.iconMode === 'string' ? source.iconMode.trim().toLowerCase() : ''
1029
+ const iconMode = ['off', 'explicit', 'auto'].includes(rawIconMode) ? rawIconMode : undefined
933
1030
  const title = stripInlineMarkdown(source.title ?? '')
934
1031
  const subtitle = cleanRichText(source.subtitle ?? '')
935
1032
  const kicker = stripInlineMarkdown(source.kicker ?? '')
@@ -937,6 +1034,11 @@ function normalizeSlideContent(raw, index) {
937
1034
  const formula = typeof source.formula === 'string'
938
1035
  ? source.formula.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '').trim()
939
1036
  : ''
1037
+ const mermaid = rawMermaid !== ''
1038
+ ? rawMermaid
1039
+ : (layout === 'mermaid' && typeof source.text === 'string' && source.text.trim() !== ''
1040
+ ? source.text.replace(/\r\n?/g, '\n').replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '').trim()
1041
+ : '')
940
1042
  const takeaway = cleanRichText(source.takeaway ?? '')
941
1043
  const slideSource = stripInlineMarkdown(source.source ?? '')
942
1044
  const notes = String(source.notes ?? '').trim()
@@ -970,7 +1072,10 @@ function normalizeSlideContent(raw, index) {
970
1072
  const commonExtras = {
971
1073
  ...(variant !== '' ? { variant } : {}),
972
1074
  ...(chrome ? { chrome } : {}),
1075
+ ...(cardMaterial ? { cardMaterial } : {}),
1076
+ ...(iconMode ? { iconMode } : {}),
973
1077
  ...(formula !== '' ? { formula } : {}),
1078
+ ...(mermaid !== '' ? { mermaid } : {}),
974
1079
  ...(takeaway !== '' ? { takeaway } : {}),
975
1080
  ...(slideSource !== '' ? { source: slideSource } : {}),
976
1081
  ...(activeIndex !== undefined ? { activeIndex } : {}),
@@ -1171,12 +1276,18 @@ export function buildDeck(options = {}) {
1171
1276
  mkdirSync(outputDir, { recursive: true })
1172
1277
  const fileName = resolveDeckFileName(outputDir, normalized.fileName, overwrite)
1173
1278
 
1279
+ const rawTargetMin = options.targetMinutes !== undefined && options.targetMinutes !== null
1280
+ ? Number(options.targetMinutes)
1281
+ : NaN
1282
+ const targetMinutes = Number.isFinite(rawTargetMin) && rawTargetMin > 0 ? rawTargetMin : undefined
1283
+
1174
1284
  const manifest = {
1175
1285
  version: DECK_VERSION,
1176
1286
  title,
1177
1287
  theme: theme.id,
1178
1288
  language: language.id,
1179
1289
  motion,
1290
+ ...(targetMinutes !== undefined ? { targetMinutes } : {}),
1180
1291
  slideCount: deck.slides.length,
1181
1292
  slides: deck.slides,
1182
1293
  }
@@ -1184,15 +1295,19 @@ export function buildDeck(options = {}) {
1184
1295
  const htmlPath = resolvePath(outputDir, fileName + '.html')
1185
1296
  const pptxPath = resolvePath(outputDir, fileName + '.pptx')
1186
1297
  const handoutPath = options.handout === true ? resolvePath(outputDir, fileName + '.handout.md') : undefined
1298
+ const onePagerPath = options.onePager === true ? resolvePath(outputDir, fileName + '.onepager.html') : undefined
1187
1299
 
1188
1300
  const artifacts = [
1189
1301
  { path: jsonPath, data: JSON.stringify(manifest, null, 2) + '\n', encoding: 'utf8' },
1190
- { path: htmlPath, data: renderHtml(manifest, theme, language, { pptx: pptxPath, json: jsonPath, ...(handoutPath ? { handout: handoutPath } : {}) }), encoding: 'utf8' },
1302
+ { path: htmlPath, data: renderHtml(manifest, theme, language, { pptx: pptxPath, json: jsonPath, ...(handoutPath ? { handout: handoutPath } : {}), ...(onePagerPath ? { onepager: onePagerPath } : {}) }), encoding: 'utf8' },
1191
1303
  { path: pptxPath, data: buildPptx(manifest, theme, language) },
1192
1304
  ]
1193
1305
  if (handoutPath) {
1194
1306
  artifacts.push({ path: handoutPath, data: renderHandoutMarkdown(manifest, language.id), encoding: 'utf8' })
1195
1307
  }
1308
+ if (onePagerPath) {
1309
+ artifacts.push({ path: onePagerPath, data: renderOnePagerHtml(manifest, language.id), encoding: 'utf8' })
1310
+ }
1196
1311
  commitDeckArtifacts(artifacts)
1197
1312
 
1198
1313
  return {
@@ -1211,6 +1326,7 @@ export function buildDeck(options = {}) {
1211
1326
  pptxPath,
1212
1327
  jsonPath,
1213
1328
  ...(handoutPath ? { handoutPath } : {}),
1329
+ ...(onePagerPath ? { onePagerPath } : {}),
1214
1330
  }
1215
1331
  }
1216
1332