dsh-ppt 0.24.2 → 0.26.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 (43) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.en.md +13 -13
  3. package/README.md +13 -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 +11 -7
  8. package/docs/USAGE.md +11 -7
  9. package/docs/VALIDATION.md +4 -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 +3435 -467
  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 +69 -0
  24. package/lib/tools.js +77 -0
  25. package/lib/types.d.ts +57 -1
  26. package/lib/workbench-language.js +4 -0
  27. package/lib/workbench.d.ts +2 -0
  28. package/lib/workbench.js +331 -8
  29. package/package.json +1 -1
  30. package/skills/dsh-ppt/SKILL.md +3 -3
  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 +39 -8
  35. package/skills/dsh-ppt/scripts/deck-advanced.mjs +50 -13
  36. package/skills/dsh-ppt/scripts/deck-chrome.mjs +1706 -0
  37. package/skills/dsh-ppt/scripts/deck-core.mjs +116 -6
  38. package/skills/dsh-ppt/scripts/deck-delivery.mjs +636 -41
  39. package/skills/dsh-ppt/scripts/deck-diagrams.mjs +2842 -0
  40. package/skills/dsh-ppt/scripts/deck-director.mjs +49 -3
  41. package/skills/dsh-ppt/scripts/deck-layouts.mjs +482 -5270
  42. package/skills/dsh-ppt/scripts/deck-mermaid.mjs +2737 -0
  43. package/skills/dsh-ppt/scripts/deck-office.mjs +1541 -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,13 +1007,18 @@ 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() : ''
@@ -937,6 +1030,11 @@ function normalizeSlideContent(raw, index) {
937
1030
  const formula = typeof source.formula === 'string'
938
1031
  ? source.formula.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '').trim()
939
1032
  : ''
1033
+ const mermaid = rawMermaid !== ''
1034
+ ? rawMermaid
1035
+ : (layout === 'mermaid' && typeof source.text === 'string' && source.text.trim() !== ''
1036
+ ? source.text.replace(/\r\n?/g, '\n').replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '').trim()
1037
+ : '')
940
1038
  const takeaway = cleanRichText(source.takeaway ?? '')
941
1039
  const slideSource = stripInlineMarkdown(source.source ?? '')
942
1040
  const notes = String(source.notes ?? '').trim()
@@ -971,6 +1069,7 @@ function normalizeSlideContent(raw, index) {
971
1069
  ...(variant !== '' ? { variant } : {}),
972
1070
  ...(chrome ? { chrome } : {}),
973
1071
  ...(formula !== '' ? { formula } : {}),
1072
+ ...(mermaid !== '' ? { mermaid } : {}),
974
1073
  ...(takeaway !== '' ? { takeaway } : {}),
975
1074
  ...(slideSource !== '' ? { source: slideSource } : {}),
976
1075
  ...(activeIndex !== undefined ? { activeIndex } : {}),
@@ -1171,12 +1270,18 @@ export function buildDeck(options = {}) {
1171
1270
  mkdirSync(outputDir, { recursive: true })
1172
1271
  const fileName = resolveDeckFileName(outputDir, normalized.fileName, overwrite)
1173
1272
 
1273
+ const rawTargetMin = options.targetMinutes !== undefined && options.targetMinutes !== null
1274
+ ? Number(options.targetMinutes)
1275
+ : NaN
1276
+ const targetMinutes = Number.isFinite(rawTargetMin) && rawTargetMin > 0 ? rawTargetMin : undefined
1277
+
1174
1278
  const manifest = {
1175
1279
  version: DECK_VERSION,
1176
1280
  title,
1177
1281
  theme: theme.id,
1178
1282
  language: language.id,
1179
1283
  motion,
1284
+ ...(targetMinutes !== undefined ? { targetMinutes } : {}),
1180
1285
  slideCount: deck.slides.length,
1181
1286
  slides: deck.slides,
1182
1287
  }
@@ -1184,15 +1289,19 @@ export function buildDeck(options = {}) {
1184
1289
  const htmlPath = resolvePath(outputDir, fileName + '.html')
1185
1290
  const pptxPath = resolvePath(outputDir, fileName + '.pptx')
1186
1291
  const handoutPath = options.handout === true ? resolvePath(outputDir, fileName + '.handout.md') : undefined
1292
+ const onePagerPath = options.onePager === true ? resolvePath(outputDir, fileName + '.onepager.html') : undefined
1187
1293
 
1188
1294
  const artifacts = [
1189
1295
  { 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' },
1296
+ { path: htmlPath, data: renderHtml(manifest, theme, language, { pptx: pptxPath, json: jsonPath, ...(handoutPath ? { handout: handoutPath } : {}), ...(onePagerPath ? { onepager: onePagerPath } : {}) }), encoding: 'utf8' },
1191
1297
  { path: pptxPath, data: buildPptx(manifest, theme, language) },
1192
1298
  ]
1193
1299
  if (handoutPath) {
1194
1300
  artifacts.push({ path: handoutPath, data: renderHandoutMarkdown(manifest, language.id), encoding: 'utf8' })
1195
1301
  }
1302
+ if (onePagerPath) {
1303
+ artifacts.push({ path: onePagerPath, data: renderOnePagerHtml(manifest, language.id), encoding: 'utf8' })
1304
+ }
1196
1305
  commitDeckArtifacts(artifacts)
1197
1306
 
1198
1307
  return {
@@ -1211,6 +1320,7 @@ export function buildDeck(options = {}) {
1211
1320
  pptxPath,
1212
1321
  jsonPath,
1213
1322
  ...(handoutPath ? { handoutPath } : {}),
1323
+ ...(onePagerPath ? { onePagerPath } : {}),
1214
1324
  }
1215
1325
  }
1216
1326