dsh-ppt 0.28.0 → 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 +12 -0
- package/README.en.md +1 -0
- package/README.md +1 -0
- package/docs/USAGE.en.md +1 -0
- package/docs/USAGE.md +1 -0
- package/docs/VALIDATION.md +4 -0
- package/lib/client.js +20 -9
- package/lib/execution.d.ts +7 -0
- package/lib/execution.js +47 -6
- package/lib/tools.js +45 -10
- package/lib/types.d.ts +51 -4
- package/lib/workbench.js +32 -4
- 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 +77 -10
- package/skills/dsh-ppt/scripts/deck-charts-pro.mjs +35 -7
- package/skills/dsh-ppt/scripts/deck-core.mjs +5 -2
- package/skills/dsh-ppt/scripts/deck-covers.mjs +1 -1
- package/skills/dsh-ppt/scripts/deck-exemplars.mjs +548 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +6 -2
- package/skills/dsh-ppt/scripts/deck-upgrader.mjs +618 -0
|
@@ -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)
|
|
@@ -483,6 +520,7 @@ function result(manifest, paths, writeHandout = false, writeOnePager = false) {
|
|
|
483
520
|
undoAvailable: manifest.history.length, deliveryStatus: manifest.quality?.issues.some(i => i.code === 'template-unfilled') ? 'draft' : 'ready-for-review',
|
|
484
521
|
quality: manifest.quality, paceBudget, verification: { static: 'checked', pptxRender: 'not-verified', visual: 'not-verified' }, outputDir: dirname(paths.json),
|
|
485
522
|
files: paths, htmlPath: paths.html, pptxPath: paths.pptx, jsonPath: paths.json,
|
|
523
|
+
...(manifest.exemplar ? { exemplar: manifest.exemplar } : {}),
|
|
486
524
|
...(writeHandout ? { handoutPath } : {}),
|
|
487
525
|
...(writeOnePager ? { onePagerPath } : {}) }
|
|
488
526
|
}
|
|
@@ -633,9 +671,20 @@ export async function buildDeckAsync(options = {}) {
|
|
|
633
671
|
absorbed = await absorbPptx({ pptxPath: String(options.referencePptx).trim(), cwd, extractLogo: true, signal: options.signal })
|
|
634
672
|
}
|
|
635
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
|
+
|
|
636
682
|
const workspaceTastes = loadWorkspaceTasteRecipes(cwd)
|
|
637
|
-
const
|
|
638
|
-
?
|
|
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)
|
|
639
688
|
: (absorbed?.styleRecipe && options.cloneStructure === true ? absorbed.styleRecipe : null)
|
|
640
689
|
if (options.taste !== undefined && options.taste !== null && options.taste !== '' && !resolvedTaste) {
|
|
641
690
|
fail('未知品味配方 taste:' + String(options.taste))
|
|
@@ -644,8 +693,10 @@ export async function buildDeckAsync(options = {}) {
|
|
|
644
693
|
const rawThemeOpt = typeof options.theme === 'string' && options.theme.trim() ? options.theme.trim() : undefined
|
|
645
694
|
let chosenThemeId = rawThemeOpt
|
|
646
695
|
let directorHint = null
|
|
647
|
-
if (chosenThemeId === 'auto' || (!chosenThemeId && (options.persona || absorbed || scenario || resolvedTaste))) {
|
|
648
|
-
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) {
|
|
649
700
|
chosenThemeId = resolvedTaste.theme
|
|
650
701
|
} else if (absorbed && (!rawThemeOpt || rawThemeOpt === 'auto') && !options.persona && !scenario) {
|
|
651
702
|
chosenThemeId = absorbed.recommendedTheme
|
|
@@ -677,16 +728,30 @@ export async function buildDeckAsync(options = {}) {
|
|
|
677
728
|
const normalized = normalizeBuildOptions({ ...input, ...(prepared ? { slides: prepared } : {}) })
|
|
678
729
|
if (prepared) normalized.deck.slides = prepared
|
|
679
730
|
|
|
731
|
+
let upgradeReport = null
|
|
732
|
+
const shouldPromote = options.smartLayout === true || (options.smartLayout !== false && (rawThemeOpt === 'auto' || Boolean(options.persona) || Boolean(absorbed) || Boolean(resolvedExemplar)))
|
|
680
733
|
if (fromMarkdown) {
|
|
681
734
|
if (absorbed && options.cloneStructure === true && Array.isArray(absorbed.slideSkeleton) && absorbed.slideSkeleton.length > 0) {
|
|
682
735
|
normalized.deck.slides = mapSlidesToAbsorbedSkeleton(normalized.deck.slides, absorbed.slideSkeleton, langId)
|
|
683
|
-
} else {
|
|
684
|
-
|
|
685
|
-
if (shouldPromote) {
|
|
686
|
-
normalized.deck.slides = promoteMarkdownSlides(normalized.deck.slides, { explicitSmartLayout: options.smartLayout === true })
|
|
687
|
-
}
|
|
736
|
+
} else if (shouldPromote) {
|
|
737
|
+
normalized.deck.slides = promoteMarkdownSlides(normalized.deck.slides, { explicitSmartLayout: options.smartLayout === true })
|
|
688
738
|
}
|
|
689
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
|
+
}
|
|
690
755
|
if (directorHint?.tableStyle === 'booktabs' || resolvedTaste?.tableStyle) {
|
|
691
756
|
const effTableStyle = resolvedTaste?.tableStyle || directorHint?.tableStyle
|
|
692
757
|
normalized.deck.slides = normalized.deck.slides.map(s => s.layout === 'table' && !s.tableStyle ? { ...s, tableStyle: effTableStyle } : s)
|
|
@@ -742,6 +807,7 @@ export async function buildDeckAsync(options = {}) {
|
|
|
742
807
|
language: normalized.language.id,
|
|
743
808
|
motion: normalized.motion,
|
|
744
809
|
...(resolvedTaste ? { taste: listCuratedTasteRecipes().some(r => r.id === resolvedTaste.id) ? resolvedTaste.id : resolvedTaste } : {}),
|
|
810
|
+
...(resolvedExemplar ? { exemplar: resolvedExemplar.id } : {}),
|
|
745
811
|
...(targetMinutesRaw !== undefined ? { targetMinutes: targetMinutesRaw } : {}),
|
|
746
812
|
...(scenario ? { template: scenario.id } : {}),
|
|
747
813
|
...(brand ? { brand } : {}),
|
|
@@ -758,7 +824,8 @@ export async function buildDeckAsync(options = {}) {
|
|
|
758
824
|
const writeHandout = options.handout === true
|
|
759
825
|
const writeOnePager = options.onePager === true
|
|
760
826
|
withLock(paths.json, () => { abort(options.signal); commit(paths, data, writeHandout, writeOnePager) })
|
|
761
|
-
|
|
827
|
+
const builtResult = result(manifest, paths, writeHandout, writeOnePager)
|
|
828
|
+
return upgradeReport ? { ...builtResult, upgradeReport } : builtResult
|
|
762
829
|
}
|
|
763
830
|
|
|
764
831
|
function readDocument(pathInput, cwd = '.') {
|
|
@@ -646,19 +646,37 @@ export function renderProChartSlideBodyPptx(slide, ctx) {
|
|
|
646
646
|
stroke: tk.canvas,
|
|
647
647
|
strokePt: 1.25,
|
|
648
648
|
}))
|
|
649
|
-
//
|
|
649
|
+
// 外侧防撞数值标签(靠近左/右数轴边界时自动上移至圆点正上方,杜绝与行标题或徽章重叠)
|
|
650
650
|
const bLeft = bx <= ax
|
|
651
|
-
|
|
651
|
+
const bText = fmtNum(r.before, r.unit)
|
|
652
|
+
const aText = fmtNum(r.after, r.unit)
|
|
653
|
+
const bW = Math.max(0.68, Math.min(1.15, bText.length * 0.13 + 0.16))
|
|
654
|
+
const aW = Math.max(0.70, Math.min(1.15, aText.length * 0.13 + 0.18))
|
|
655
|
+
const bTightLeft = bLeft && (bx - trackX < bW + 0.14)
|
|
656
|
+
const bTightRight = !bLeft && (trackX + trackW - bx < bW + 0.14)
|
|
657
|
+
const aTightLeft = !bLeft && (ax - trackX < aW + 0.14)
|
|
658
|
+
const aTightRight = bLeft && (trackX + trackW - ax < aW + 0.14)
|
|
659
|
+
const bBox = bTightLeft
|
|
660
|
+
? { x: Math.max(trackX, bx - 0.10), y: cy - 0.39, w: bW, h: 0.26, align: 'l' }
|
|
661
|
+
: bTightRight
|
|
662
|
+
? { x: Math.min(trackX + trackW - bW, bx - bW + 0.12), y: cy - 0.39, w: bW, h: 0.26, align: 'r' }
|
|
663
|
+
: { x: bLeft ? bx - bW - 0.16 : bx + 0.18, y: cy - 0.15, w: bW, h: 0.30, align: bLeft ? 'r' : 'l' }
|
|
664
|
+
const aBox = aTightLeft
|
|
665
|
+
? { x: Math.max(trackX, ax - 0.10), y: cy - 0.39, w: aW, h: 0.26, align: 'l' }
|
|
666
|
+
: aTightRight
|
|
667
|
+
? { x: Math.min(trackX + trackW - aW, ax - aW + 0.12), y: cy - 0.39, w: aW, h: 0.26, align: 'r' }
|
|
668
|
+
: { x: bLeft ? ax + 0.18 : ax - aW - 0.16, y: cy - 0.15, w: aW, h: 0.30, align: bLeft ? 'l' : 'r' }
|
|
669
|
+
shapes.push(ooxmlShape(nextId(), `Dumbbell Val B ${idx + 1}`, { x: bBox.x, y: bBox.y, w: bBox.w, h: bBox.h }, {
|
|
652
670
|
txBox: true,
|
|
653
671
|
anchor: 'ctr',
|
|
654
672
|
marginsIn: { l: 0, r: 0, t: 0, b: 0 },
|
|
655
|
-
paragraphs: [ooxmlRichParagraph(
|
|
673
|
+
paragraphs: [ooxmlRichParagraph(bText, { sizePt: 11, color: tk.inkMuted, bold: true, lang: 'en-US', align: bBox.align, font: theme.fonts.body })],
|
|
656
674
|
}))
|
|
657
|
-
shapes.push(ooxmlShape(nextId(), `Dumbbell Val A ${idx + 1}`, { x:
|
|
675
|
+
shapes.push(ooxmlShape(nextId(), `Dumbbell Val A ${idx + 1}`, { x: aBox.x, y: aBox.y, w: aBox.w, h: aBox.h }, {
|
|
658
676
|
txBox: true,
|
|
659
677
|
anchor: 'ctr',
|
|
660
678
|
marginsIn: { l: 0, r: 0, t: 0, b: 0 },
|
|
661
|
-
paragraphs: [ooxmlRichParagraph(
|
|
679
|
+
paragraphs: [ooxmlRichParagraph(aText, { sizePt: 11.5, color: barCol, bold: true, lang: 'en-US', align: aBox.align, font: theme.fonts.heading })],
|
|
662
680
|
}))
|
|
663
681
|
// 右侧变化量胶囊
|
|
664
682
|
const pillX = 12.71 - deltaW
|
|
@@ -908,14 +926,24 @@ export function renderProChartSlideBodyHtml(slide, ctx = {}) {
|
|
|
908
926
|
const ax = mapX(r.after)
|
|
909
927
|
const col = r.status === 'negative' ? tk.negative : (r.status === 'positive' ? tk.positive : tk.accentPrimary)
|
|
910
928
|
const bLeft = bx <= ax
|
|
929
|
+
const bTightL = bLeft && (bx - lx < 68)
|
|
930
|
+
const bTightR = !bLeft && (rx - bx < 68)
|
|
931
|
+
const aTightL = !bLeft && (ax - lx < 68)
|
|
932
|
+
const aTightR = bLeft && (rx - ax < 68)
|
|
933
|
+
const bLblX = bTightL ? Math.max(lx, bx - 4) : bTightR ? Math.min(rx, bx + 4) : (bLeft ? bx - 14 : bx + 14)
|
|
934
|
+
const bLblY = (bTightL || bTightR) ? cy - 15 : cy + 4
|
|
935
|
+
const bAnchor = bTightL ? 'start' : bTightR ? 'end' : (bLeft ? 'end' : 'start')
|
|
936
|
+
const aLblX = aTightL ? Math.max(lx, ax - 4) : aTightR ? Math.min(rx, ax + 4) : (bLeft ? ax + 14 : ax - 14)
|
|
937
|
+
const aLblY = (aTightL || aTightR) ? cy - 15 : cy + 4
|
|
938
|
+
const aAnchor = aTightL ? 'start' : aTightR ? 'end' : (bLeft ? 'start' : 'end')
|
|
911
939
|
return (
|
|
912
940
|
`<text x="${lx - 18}" y="${(cy + 5).toFixed(1)}" text-anchor="end" font-size="14" font-weight="700" fill="${tk.inkPrimary}">${escapeHtml(r.title)}</text>` +
|
|
913
941
|
`<line x1="${lx}" y1="${cy.toFixed(1)}" x2="${rx}" y2="${cy.toFixed(1)}" stroke="${tk.hairline}" stroke-width="1"/>` +
|
|
914
942
|
`<line x1="${bx.toFixed(1)}" y1="${cy.toFixed(1)}" x2="${ax.toFixed(1)}" y2="${cy.toFixed(1)}" stroke="${col}" stroke-width="6" stroke-linecap="round" stroke-opacity="0.85"/>` +
|
|
915
943
|
`<circle cx="${bx.toFixed(1)}" cy="${cy.toFixed(1)}" r="8" fill="${tk.canvas}" stroke="${tk.inkMuted}" stroke-width="2.5"/>` +
|
|
916
944
|
`<circle cx="${ax.toFixed(1)}" cy="${cy.toFixed(1)}" r="9" fill="${col}" stroke="${tk.canvas}" stroke-width="2"/>` +
|
|
917
|
-
`<text x="${
|
|
918
|
-
`<text x="${
|
|
945
|
+
`<text x="${bLblX.toFixed(1)}" y="${bLblY.toFixed(1)}" text-anchor="${bAnchor}" font-size="12" font-weight="700" fill="${tk.inkMuted}">${escapeHtml(fmtNum(r.before, r.unit))}</text>` +
|
|
946
|
+
`<text x="${aLblX.toFixed(1)}" y="${aLblY.toFixed(1)}" text-anchor="${aAnchor}" font-size="12.5" font-weight="800" fill="${col}">${escapeHtml(fmtNum(r.after, r.unit))}</text>` +
|
|
919
947
|
`<rect x="${rx + 18}" y="${(cy - 13).toFixed(1)}" width="94" height="26" rx="13" fill="${tk.surface1}" stroke="${col}" stroke-width="1.2"/>` +
|
|
920
948
|
`<text x="${rx + 65}" y="${(cy + 4).toFixed(1)}" text-anchor="middle" font-size="12" font-weight="700" fill="${col}">${escapeHtml(r.delta)}</text>`
|
|
921
949
|
)
|
|
@@ -1125,10 +1125,13 @@ function normalizeSlideContent(raw, index) {
|
|
|
1125
1125
|
? source.columns.map((c) => stripInlineMarkdown(c)).filter(Boolean)
|
|
1126
1126
|
: undefined
|
|
1127
1127
|
|
|
1128
|
+
const fencedTextMatch = (!source.code && typeof source.text === 'string')
|
|
1129
|
+
? /```([a-zA-Z0-9_-]*)\r?\n([\s\S]+?)\r?\n```/.exec(source.text)
|
|
1130
|
+
: null
|
|
1128
1131
|
const rawCode = typeof source.code === 'string'
|
|
1129
1132
|
? source.code.replace(/\r\n?/g, '\n').replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '').trimEnd()
|
|
1130
|
-
: ''
|
|
1131
|
-
const codeLanguage = stripInlineMarkdown(source.language ?? '')
|
|
1133
|
+
: (fencedTextMatch ? fencedTextMatch[2].replace(/\r\n?/g, '\n').replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g, '').trimEnd() : '')
|
|
1134
|
+
const codeLanguage = stripInlineMarkdown(source.language ?? (fencedTextMatch?.[1] || ''))
|
|
1132
1135
|
const filename = stripInlineMarkdown(source.filename ?? '')
|
|
1133
1136
|
const url = stripInlineMarkdown(source.url ?? '')
|
|
1134
1137
|
const rawCoverPattern = String(source.coverPattern ?? '').trim().toLowerCase()
|
|
@@ -937,7 +937,7 @@ export const AESTHETIC_STUDIO_CSS = `
|
|
|
937
937
|
.bento-hero-grid.bento-hero-2 > :first-child{grid-row:1}
|
|
938
938
|
.bento-hero-grid.bento-hero-3 > :first-child{grid-row:1 / span 2}
|
|
939
939
|
.bento-hero-grid.bento-hero-4 > :first-child{grid-row:1 / span 3}
|
|
940
|
-
.surface-card.is-inverted-hero{background:linear-gradient(140deg,var(--
|
|
940
|
+
.surface-card.is-inverted-hero{background:linear-gradient(140deg,color-mix(in srgb,var(--accent) 82%,#0F172A),color-mix(in srgb,var(--accent) 55%,#0B1120)) !important;border:0 !important;color:#F8FAFC !important}
|
|
941
941
|
.surface-card.is-inverted-hero .card-title{color:#F8FAFC}
|
|
942
942
|
.surface-card.is-inverted-hero .card-body,.surface-card.is-inverted-hero .card-bullets{color:#E2E8F0}
|
|
943
943
|
.surface-card.is-inverted-hero .card-stat{color:#FDE68A}
|