dsh-ppt 0.33.0 → 0.35.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 +42 -0
- package/README.en.md +8 -10
- package/README.md +8 -10
- package/docs/USAGE.en.md +44 -35
- package/docs/USAGE.md +45 -36
- package/docs/VALIDATION.md +8 -0
- package/lib/client.js +116 -17
- package/lib/ecosystem.js +10 -0
- package/lib/execution.js +36 -5
- package/lib/tools.js +74 -4
- package/lib/types.d.ts +79 -1
- package/lib/workbench.js +255 -14
- package/package.json +2 -2
- package/skills/dsh-ppt/SKILL.md +34 -31
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/references/office-pack.md +124 -0
- package/skills/dsh-ppt/references/research-plan.md +93 -62
- package/skills/dsh-ppt/scripts/build-deck.mjs +109 -3
- package/skills/dsh-ppt/scripts/deck-absorb.mjs +21 -0
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +330 -37
- package/skills/dsh-ppt/scripts/deck-brand-kit.mjs +257 -0
- package/skills/dsh-ppt/scripts/deck-charts-exec.mjs +805 -0
- package/skills/dsh-ppt/scripts/deck-chrome.mjs +47 -1
- package/skills/dsh-ppt/scripts/deck-compose.mjs +386 -0
- package/skills/dsh-ppt/scripts/deck-core.mjs +136 -16
- package/skills/dsh-ppt/scripts/deck-delivery.mjs +750 -17
- package/skills/dsh-ppt/scripts/deck-evidence.mjs +811 -118
- package/skills/dsh-ppt/scripts/deck-export.mjs +652 -0
- package/skills/dsh-ppt/scripts/deck-i18n.mjs +170 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +72 -8
- package/skills/dsh-ppt/scripts/deck-media.mjs +22 -0
- package/skills/dsh-ppt/scripts/deck-office.mjs +1455 -14
- package/skills/dsh-ppt/scripts/deck-remix.mjs +471 -0
|
@@ -19,6 +19,7 @@ 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
21
|
import { extractExemplarFromAbsorbed, saveWorkspaceExemplar } from './deck-exemplars.mjs'
|
|
22
|
+
import { buildBrandKitFromAbsorbed, saveWorkspaceBrandKit } from './deck-brand-kit.mjs'
|
|
22
23
|
|
|
23
24
|
const MAX_PPTX_BYTES = 64 * 1024 * 1024
|
|
24
25
|
const MAX_LOGO_BYTES = 2 * 1024 * 1024
|
|
@@ -1482,8 +1483,28 @@ export async function absorbPptx(options = {}) {
|
|
|
1482
1483
|
exemplar = savedEx.exemplar
|
|
1483
1484
|
}
|
|
1484
1485
|
|
|
1486
|
+
let savedBrandKitPath
|
|
1487
|
+
let brandKit
|
|
1488
|
+
if (options.saveBrandKit === true || (options.saveBrandKit && typeof options.saveBrandKit === 'object')) {
|
|
1489
|
+
const bkOpts = typeof options.saveBrandKit === 'object' ? options.saveBrandKit : {}
|
|
1490
|
+
const builtKit = buildBrandKitFromAbsorbed(baseResult, {
|
|
1491
|
+
name: options.brandKitName || bkOpts.name || options.tasteName,
|
|
1492
|
+
enforce: bkOpts.enforce !== false,
|
|
1493
|
+
watermark: options.watermark || bkOpts.watermark,
|
|
1494
|
+
footer: options.footer || bkOpts.footer,
|
|
1495
|
+
forbiddenTerms: Array.isArray(options.forbiddenTerms) ? options.forbiddenTerms : bkOpts.forbiddenTerms,
|
|
1496
|
+
preferredSources: Array.isArray(options.preferredSources) ? options.preferredSources : bkOpts.preferredSources,
|
|
1497
|
+
blockedDomains: Array.isArray(options.blockedDomains) ? options.blockedDomains : bkOpts.blockedDomains,
|
|
1498
|
+
mandatoryClosing: options.mandatoryClosing || bkOpts.mandatoryClosing,
|
|
1499
|
+
})
|
|
1500
|
+
const savedBk = saveWorkspaceBrandKit(cwd, builtKit)
|
|
1501
|
+
savedBrandKitPath = savedBk.path
|
|
1502
|
+
brandKit = savedBk.brandKit
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1485
1505
|
return {
|
|
1486
1506
|
...baseResult,
|
|
1487
1507
|
...(savedExemplarPath ? { savedExemplarPath, exemplar } : {}),
|
|
1508
|
+
...(savedBrandKitPath ? { savedBrandKitPath, brandKit } : {}),
|
|
1488
1509
|
}
|
|
1489
1510
|
}
|
|
@@ -10,7 +10,8 @@ import { normalizeDataModel, prepareDataSlides, validateDataSnapshot, previewDat
|
|
|
10
10
|
import { normalizeVisual, applyVisualActions } from './deck-visual.mjs'
|
|
11
11
|
import { absorbPptx, CHROME_STYLE_IDS } from './deck-absorb.mjs'
|
|
12
12
|
import { extractPptxSlides } from './deck-import.mjs'
|
|
13
|
-
import { renderHandoutMarkdown, computePaceBudget, renderOnePagerHtml } from './deck-delivery.mjs'
|
|
13
|
+
import { renderHandoutMarkdown, computePaceBudget, renderOnePagerHtml, renderSubtitlesSrt, renderSubtitlesVtt } from './deck-delivery.mjs'
|
|
14
|
+
import { REMIX_PRESETS, REMIX_PRESET_IDS, remixSlides, renderSocialCarouselHtml } from './deck-remix.mjs'
|
|
14
15
|
import { SCENARIO_TEMPLATES, findScenarioTemplate, buildScenarioSlides, listScenarioTemplates, inferThemeFromContent, promoteMarkdownSlides, optimizeVisualRhythm, auditSlideAesthetics } from './deck-director.mjs'
|
|
15
16
|
import {
|
|
16
17
|
CARD_MATERIALS,
|
|
@@ -38,16 +39,41 @@ import {
|
|
|
38
39
|
renderExemplarPromptGuide,
|
|
39
40
|
} from './deck-exemplars.mjs'
|
|
40
41
|
import { upgradeWeakDeck, resequenceSlidesToExemplar, selfRepairDeck, synthesizeActionTitle } from './deck-upgrader.mjs'
|
|
41
|
-
import {
|
|
42
|
+
import {
|
|
43
|
+
normalizeEvidenceLedger,
|
|
44
|
+
applyEvidenceLedgerToSlides,
|
|
45
|
+
auditEvidenceAndSourcing,
|
|
46
|
+
buildResearchPlan,
|
|
47
|
+
AUTHORITATIVE_DOMAINS,
|
|
48
|
+
NOISE_DOMAINS,
|
|
49
|
+
detectResearchDomain,
|
|
50
|
+
buildAuthoritativeQueryPack,
|
|
51
|
+
classifySourceAuthority,
|
|
52
|
+
buildHybridEnrichmentPlan,
|
|
53
|
+
mergeHybridEvidence,
|
|
54
|
+
} from './deck-evidence.mjs'
|
|
55
|
+
import { renderDeckWorkbookXlsx, renderDeckReportDocx, renderDeckMemoMarkdown, renderQaPrepMarkdown } from './deck-export.mjs'
|
|
56
|
+
import { slideBankPathFor, loadSlideBank, saveSlideToBank, listSlideBank, removeBankSlide, mergeDecks } from './deck-compose.mjs'
|
|
57
|
+
import { extractTranslationBundle, applyTranslationBundle } from './deck-i18n.mjs'
|
|
42
58
|
import { computeMapModel, computeIsometricModel, generateVisualBrief, normalizeImageBrief } from './deck-infographics.mjs'
|
|
59
|
+
import {
|
|
60
|
+
normalizeBrandKit,
|
|
61
|
+
brandKitPathFor,
|
|
62
|
+
loadWorkspaceBrandKit,
|
|
63
|
+
saveWorkspaceBrandKit,
|
|
64
|
+
buildBrandKitFromAbsorbed,
|
|
65
|
+
applyBrandKitToSlidesAndBrand,
|
|
66
|
+
auditBrandCompliance,
|
|
67
|
+
} from './deck-brand-kit.mjs'
|
|
43
68
|
export { readRenderReceipt } from './deck-render.mjs'
|
|
44
69
|
export { dataNotes, dataReport } from './deck-data.mjs'
|
|
45
70
|
export { buildDeck, resolveLanguage } from './deck-core.mjs'
|
|
46
71
|
export { listThemes, listMasterPresets, resolveTheme } from './deck-themes.mjs'
|
|
47
72
|
export { absorbPptx } from './deck-absorb.mjs'
|
|
48
73
|
export { extractPptxSlides } from './deck-import.mjs'
|
|
49
|
-
export { renderHandoutMarkdown, computePaceBudget, renderOnePagerHtml } from './deck-delivery.mjs'
|
|
50
|
-
export {
|
|
74
|
+
export { renderHandoutMarkdown, computePaceBudget, renderOnePagerHtml, renderSubtitlesSrt, renderSubtitlesVtt } from './deck-delivery.mjs'
|
|
75
|
+
export { REMIX_PRESETS, REMIX_PRESET_IDS, remixSlides, renderSocialCarouselHtml } from './deck-remix.mjs'
|
|
76
|
+
export { extractOfficeSource, importOfficeDeck, inspectLocalImage, inspectImageBytes, inspectOfficePack } from './deck-office.mjs'
|
|
51
77
|
export { inferThemeFromContent, optimizeVisualRhythm } from './deck-director.mjs'
|
|
52
78
|
export { listAllTasteRecipes, listCuratedTasteRecipes, loadWorkspaceTasteRecipes, saveWorkspaceTasteRecipe, resolveTasteRecipe } from './deck-taste.mjs'
|
|
53
79
|
export {
|
|
@@ -65,8 +91,33 @@ export {
|
|
|
65
91
|
renderExemplarPromptGuide,
|
|
66
92
|
} from './deck-exemplars.mjs'
|
|
67
93
|
export { upgradeWeakDeck, resequenceSlidesToExemplar, selfRepairDeck, synthesizeActionTitle } from './deck-upgrader.mjs'
|
|
68
|
-
export {
|
|
94
|
+
export {
|
|
95
|
+
normalizeEvidenceLedger,
|
|
96
|
+
applyEvidenceLedgerToSlides,
|
|
97
|
+
auditEvidenceAndSourcing,
|
|
98
|
+
buildResearchPlan,
|
|
99
|
+
AUTHORITATIVE_DOMAINS,
|
|
100
|
+
NOISE_DOMAINS,
|
|
101
|
+
detectResearchDomain,
|
|
102
|
+
buildAuthoritativeQueryPack,
|
|
103
|
+
classifySourceAuthority,
|
|
104
|
+
buildHybridEnrichmentPlan,
|
|
105
|
+
mergeHybridEvidence,
|
|
106
|
+
} from './deck-evidence.mjs'
|
|
107
|
+
export { renderDeckWorkbookXlsx, renderDeckReportDocx, renderDeckMemoMarkdown, renderQaPrepMarkdown } from './deck-export.mjs'
|
|
108
|
+
export { slideBankPathFor, loadSlideBank, saveSlideToBank, listSlideBank, removeBankSlide, mergeDecks } from './deck-compose.mjs'
|
|
109
|
+
export { extractTranslationBundle, applyTranslationBundle } from './deck-i18n.mjs'
|
|
110
|
+
export { EXEC_CHART_LAYOUTS, computeIssueTreeModel, computeTreemapModel, computeGaugeModel, computePricingModel } from './deck-charts-exec.mjs'
|
|
69
111
|
export { computeMapModel, computeIsometricModel, generateVisualBrief, normalizeImageBrief } from './deck-infographics.mjs'
|
|
112
|
+
export {
|
|
113
|
+
normalizeBrandKit,
|
|
114
|
+
brandKitPathFor,
|
|
115
|
+
loadWorkspaceBrandKit,
|
|
116
|
+
saveWorkspaceBrandKit,
|
|
117
|
+
buildBrandKitFromAbsorbed,
|
|
118
|
+
applyBrandKitToSlidesAndBrand,
|
|
119
|
+
auditBrandCompliance,
|
|
120
|
+
} from './deck-brand-kit.mjs'
|
|
70
121
|
|
|
71
122
|
export async function ingestExemplarCorpus(options = {}) {
|
|
72
123
|
return ingestExemplarDirectory({
|
|
@@ -193,6 +244,11 @@ function normalizeBrand(input, assets, cwd) {
|
|
|
193
244
|
if (String(input.footer).length > 100) fail('brand.footer 最多 100 字符')
|
|
194
245
|
brand.footer = String(input.footer)
|
|
195
246
|
}
|
|
247
|
+
if (input.watermark !== undefined && input.watermark !== null && String(input.watermark).trim() !== '') {
|
|
248
|
+
const wm = String(input.watermark).replace(/\s+/g, ' ').trim()
|
|
249
|
+
if (wm.length > 48) fail('brand.watermark 最多 48 字符')
|
|
250
|
+
brand.watermark = wm
|
|
251
|
+
}
|
|
196
252
|
if (input.chromeStyle !== undefined && input.chromeStyle !== null && input.chromeStyle !== '') {
|
|
197
253
|
const cs = String(input.chromeStyle).trim().toLowerCase()
|
|
198
254
|
if (!CHROME_STYLE_SET.has(cs)) fail('brand.chromeStyle 需为 ' + CHROME_STYLE_IDS.join(' / '))
|
|
@@ -273,7 +329,7 @@ function validateRawSlides(slides) {
|
|
|
273
329
|
}
|
|
274
330
|
|
|
275
331
|
function snapshot(manifest) {
|
|
276
|
-
return clone(Object.fromEntries(['title', 'theme', 'language', 'motion', 'slides', 'brand', 'template', 'dataModel', 'evidence', 'targetMinutes', 'taste'].filter(k => manifest[k] !== undefined).map(k => [k, manifest[k]])))
|
|
332
|
+
return clone(Object.fromEntries(['title', 'theme', 'language', 'motion', 'motionProfile', 'slides', 'brand', 'brandKit', 'template', 'dataModel', 'evidence', 'targetMinutes', 'taste'].filter(k => manifest[k] !== undefined).map(k => [k, manifest[k]])))
|
|
277
333
|
}
|
|
278
334
|
|
|
279
335
|
function collectAssets(manifest) {
|
|
@@ -342,8 +398,10 @@ export function checkManifest(manifest) {
|
|
|
342
398
|
issue(i, 'template-unfilled', '模板中还有待填写内容', '提供实际事实、依据和行动,填完后重新检查')
|
|
343
399
|
}
|
|
344
400
|
if (slide.layout === 'table') {
|
|
345
|
-
|
|
346
|
-
if (
|
|
401
|
+
const colCount = slide.rows?.[0]?.length ?? 0
|
|
402
|
+
if (colCount > 6) issue(i, 'small-font', '表格超过 6 列,使用较小字号,小屏放映可能难以阅读', '减少列数或把重点数据改成图表,导出后检查可读性')
|
|
403
|
+
const cellLimit = colCount <= 4 && slide.tableStyle === 'booktabs' ? 24 : 18
|
|
404
|
+
if (slide.rows?.some(row => row.some(c => textWidth(c) > cellLimit))) issue(i, 'table-density', '表格单元格文字较长,可能换行拥挤', '精简单元格或减少列数')
|
|
347
405
|
}
|
|
348
406
|
const boxes = MEDIA_LAYOUTS.has(slide.layout) ? mediaBoxes(slide.layout, slide.variant, slide) : null
|
|
349
407
|
if (Array.isArray(boxes?.gallery) && Array.isArray(slide.images) && slide.images.length > 1) {
|
|
@@ -388,6 +446,10 @@ export function checkManifest(manifest) {
|
|
|
388
446
|
for (const evidenceIssue of auditEvidenceAndSourcing(manifest)) {
|
|
389
447
|
issues.push(evidenceIssue)
|
|
390
448
|
}
|
|
449
|
+
// 追加 SLOP-14 企业品牌宪章与合规禁用词静态门禁
|
|
450
|
+
for (const brandIssue of auditBrandCompliance(manifest)) {
|
|
451
|
+
issues.push(brandIssue)
|
|
452
|
+
}
|
|
391
453
|
|
|
392
454
|
return { ok: !issues.some(i => i.severity === 'error'), slideCount: manifest.slides.length,
|
|
393
455
|
errorCount: issues.filter(i => i.severity === 'error').length, warningCount: issues.filter(i => i.severity === 'warning').length,
|
|
@@ -519,9 +581,11 @@ async function exportPptx(manifest, theme, language, signal) {
|
|
|
519
581
|
}
|
|
520
582
|
}
|
|
521
583
|
if (manifest.brand?.logoAssetId) putImage(slide, manifest.brand.logoAssetId, LOGO_BOX, 'contain', 'Brand logo', manifest.brand.name)
|
|
522
|
-
if (manifest.brand?.footer && source.layout !== 'cover' && source.layout !== 'closing' && !lib.findShapeByName(slide, '
|
|
523
|
-
const
|
|
524
|
-
|
|
584
|
+
if (manifest.brand?.footer && source.layout !== 'cover' && source.layout !== 'closing' && source.layout !== 'section' && !lib.findShapeByName(slide, 'Beamer footer band')) {
|
|
585
|
+
const hasSourceShape = Boolean(lib.findShapeByName(slide, 'Footer source') || lib.findShapeByName(slide, 'Source'))
|
|
586
|
+
const footerBox = hasSourceShape ? { x: FOOTER_BOX.x, y: 6.95, w: 4.55, h: 0.32 } : FOOTER_BOX
|
|
587
|
+
const footer = lib.addSlideTextBox(slide, { ...emu(footerBox), text: manifest.brand.footer, name: 'Brand footer' })
|
|
588
|
+
lib.setShapeTextFormat(footer, { size: 9.5, font: pptxEastAsianFont(theme.fonts.body), color: theme.palette.muted })
|
|
525
589
|
}
|
|
526
590
|
})
|
|
527
591
|
const invalid = lib.validatePresentation(presentation).filter(i => i.severity === 'error')
|
|
@@ -536,9 +600,46 @@ function documentBytes(manifest) {
|
|
|
536
600
|
if (Buffer.byteLength(text) > MAX_DOCUMENT) fail('JSON 工程含历史超过 64 MiB,请缩减图片或清理历史后另存工程')
|
|
537
601
|
return text
|
|
538
602
|
}
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
603
|
+
const ALLOWED_EXPORT_KINDS = new Set(['xlsx', 'docx', 'qa-prep', 'memo', 'social-carousel', 'subtitles', 'handout', 'one-pager', 'i18n'])
|
|
604
|
+
|
|
605
|
+
function parseExportOptions(options = {}) {
|
|
606
|
+
const list = Array.isArray(options.exports)
|
|
607
|
+
? options.exports.map(x => String(x ?? '').trim().toLowerCase()).filter(Boolean)
|
|
608
|
+
: []
|
|
609
|
+
for (const kind of list) {
|
|
610
|
+
if (!ALLOWED_EXPORT_KINDS.has(kind)) {
|
|
611
|
+
fail('未知导出格式 exports:' + kind + '(支持 ' + [...ALLOWED_EXPORT_KINDS].join(' / ') + ')')
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
const set = new Set(list)
|
|
615
|
+
return {
|
|
616
|
+
writeHandout: options.handout === true || set.has('handout'),
|
|
617
|
+
writeOnePager: options.onePager === true || set.has('one-pager'),
|
|
618
|
+
writeCarousel: Boolean(options.socialCarousel) || set.has('social-carousel'),
|
|
619
|
+
carouselRatio: options.socialCarousel === '1:1' ? '1:1' : '4:5',
|
|
620
|
+
writeSubtitles: Boolean(options.subtitles) || set.has('subtitles'),
|
|
621
|
+
subtitlesFormat: options.subtitles === 'vtt' ? 'vtt' : 'srt',
|
|
622
|
+
writeXlsx: set.has('xlsx'),
|
|
623
|
+
writeDocx: set.has('docx'),
|
|
624
|
+
writeMemo: set.has('memo'),
|
|
625
|
+
writeQaPrep: set.has('qa-prep'),
|
|
626
|
+
writeI18n: set.has('i18n'),
|
|
627
|
+
hasAnyExtra: set.size > 0 || options.handout === true || options.onePager === true || Boolean(options.socialCarousel) || Boolean(options.subtitles),
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
function result(manifest, paths, writeHandout = false, writeOnePager = false, extra = {}) {
|
|
632
|
+
const base = paths.json.slice(0, -5)
|
|
633
|
+
const handoutPath = base + '.handout.md'
|
|
634
|
+
const onePagerPath = base + '.onepager.html'
|
|
635
|
+
const carouselPath = base + '.carousel.html'
|
|
636
|
+
const subtitlesExt = extra.subtitlesFormat === 'vtt' ? '.vtt' : '.srt'
|
|
637
|
+
const subtitlesPath = base + subtitlesExt
|
|
638
|
+
const xlsxPath = base + '.xlsx'
|
|
639
|
+
const docxPath = base + '.docx'
|
|
640
|
+
const memoPath = base + '.memo.md'
|
|
641
|
+
const qaPrepPath = base + '.qa-prep.md'
|
|
642
|
+
const i18nPath = base + '.i18n.json'
|
|
542
643
|
const paceBudget = computePaceBudget(manifest)
|
|
543
644
|
return { ok: true, title: manifest.title, theme: manifest.theme, language: manifest.language,
|
|
544
645
|
slideCount: manifest.slides.length, deckId: manifest.deckId, revision: manifest.revision,
|
|
@@ -547,9 +648,17 @@ function result(manifest, paths, writeHandout = false, writeOnePager = false) {
|
|
|
547
648
|
quality: manifest.quality, paceBudget, verification: { static: 'checked', pptxRender: 'not-verified', visual: 'not-verified' }, outputDir: dirname(paths.json),
|
|
548
649
|
files: paths, htmlPath: paths.html, pptxPath: paths.pptx, jsonPath: paths.json,
|
|
549
650
|
...(manifest.exemplar ? { exemplar: manifest.exemplar } : {}),
|
|
651
|
+
...(manifest.brandKit?.name ? { brandKit: manifest.brandKit.name } : {}),
|
|
550
652
|
...(Array.isArray(manifest.evidence) && manifest.evidence.length > 0 ? { evidenceCount: manifest.evidence.length } : {}),
|
|
551
653
|
...(writeHandout ? { handoutPath } : {}),
|
|
552
|
-
...(writeOnePager ? { onePagerPath } : {})
|
|
654
|
+
...(writeOnePager ? { onePagerPath } : {}),
|
|
655
|
+
...(extra.writeCarousel ? { carouselPath } : {}),
|
|
656
|
+
...(extra.writeSubtitles ? { subtitlesPath } : {}),
|
|
657
|
+
...(extra.writeXlsx ? { xlsxPath } : {}),
|
|
658
|
+
...(extra.writeDocx ? { docxPath } : {}),
|
|
659
|
+
...(extra.writeMemo ? { memoPath } : {}),
|
|
660
|
+
...(extra.writeQaPrep ? { qaPrepPath } : {}),
|
|
661
|
+
...(extra.writeI18n ? { i18nPath } : {}) }
|
|
553
662
|
}
|
|
554
663
|
function pathsFor(jsonPath) {
|
|
555
664
|
const base = jsonPath.slice(0, -5)
|
|
@@ -574,13 +683,19 @@ async function generate(manifest, signal) {
|
|
|
574
683
|
abort(signal)
|
|
575
684
|
return { json, pptx, manifest, theme, language }
|
|
576
685
|
}
|
|
577
|
-
function commit(paths, data, writeHandout = false, writeOnePager = false) {
|
|
578
|
-
const
|
|
579
|
-
const
|
|
686
|
+
function commit(paths, data, writeHandout = false, writeOnePager = false, extra = {}) {
|
|
687
|
+
const base = paths.json.slice(0, -5)
|
|
688
|
+
const handoutPath = base + '.handout.md'
|
|
689
|
+
const onePagerPath = base + '.onepager.html'
|
|
690
|
+
const carouselPath = base + '.carousel.html'
|
|
691
|
+
const subtitlesExt = extra.subtitlesFormat === 'vtt' ? '.vtt' : '.srt'
|
|
692
|
+
const subtitlesPath = base + subtitlesExt
|
|
580
693
|
const html = renderHtml(data.manifest, data.theme, data.language, {
|
|
581
694
|
...paths,
|
|
582
695
|
...(writeHandout ? { handout: handoutPath } : {}),
|
|
583
696
|
...(writeOnePager ? { onepager: onePagerPath } : {}),
|
|
697
|
+
...(extra.writeCarousel ? { carousel: carouselPath } : {}),
|
|
698
|
+
...(extra.writeSubtitles ? { subtitles: subtitlesPath } : {}),
|
|
584
699
|
})
|
|
585
700
|
data.manifest.artifacts = { html: hash(html), pptx: hash(data.pptx) }
|
|
586
701
|
const artifacts = [
|
|
@@ -594,6 +709,34 @@ function commit(paths, data, writeHandout = false, writeOnePager = false) {
|
|
|
594
709
|
if (writeOnePager) {
|
|
595
710
|
artifacts.push({ path: onePagerPath, data: renderOnePagerHtml(data.manifest, data.language.id), encoding: 'utf8' })
|
|
596
711
|
}
|
|
712
|
+
if (extra.writeCarousel) {
|
|
713
|
+
artifacts.push({
|
|
714
|
+
path: carouselPath,
|
|
715
|
+
data: renderSocialCarouselHtml(data.manifest, { ratio: extra.carouselRatio || '4:5', lang: data.language.id }),
|
|
716
|
+
encoding: 'utf8',
|
|
717
|
+
})
|
|
718
|
+
}
|
|
719
|
+
if (extra.writeSubtitles) {
|
|
720
|
+
const subData = extra.subtitlesFormat === 'vtt'
|
|
721
|
+
? renderSubtitlesVtt(data.manifest, data.language.id)
|
|
722
|
+
: renderSubtitlesSrt(data.manifest, data.language.id)
|
|
723
|
+
artifacts.push({ path: subtitlesPath, data: subData, encoding: 'utf8' })
|
|
724
|
+
}
|
|
725
|
+
if (extra.writeXlsx) {
|
|
726
|
+
artifacts.push({ path: base + '.xlsx', data: renderDeckWorkbookXlsx(data.manifest) })
|
|
727
|
+
}
|
|
728
|
+
if (extra.writeDocx) {
|
|
729
|
+
artifacts.push({ path: base + '.docx', data: renderDeckReportDocx(data.manifest, data.language.id) })
|
|
730
|
+
}
|
|
731
|
+
if (extra.writeMemo) {
|
|
732
|
+
artifacts.push({ path: base + '.memo.md', data: renderDeckMemoMarkdown(data.manifest, data.language.id), encoding: 'utf8' })
|
|
733
|
+
}
|
|
734
|
+
if (extra.writeQaPrep) {
|
|
735
|
+
artifacts.push({ path: base + '.qa-prep.md', data: renderQaPrepMarkdown(data.manifest, data.language.id), encoding: 'utf8' })
|
|
736
|
+
}
|
|
737
|
+
if (extra.writeI18n) {
|
|
738
|
+
artifacts.push({ path: base + '.i18n.json', data: JSON.stringify(extractTranslationBundle(data.manifest), null, 2) + '\n', encoding: 'utf8' })
|
|
739
|
+
}
|
|
597
740
|
commitDeckArtifacts(artifacts)
|
|
598
741
|
}
|
|
599
742
|
|
|
@@ -614,7 +757,7 @@ function validateSnapshot(value, assets) {
|
|
|
614
757
|
if (value.evidence !== undefined) normalizeEvidenceLedger(value.evidence)
|
|
615
758
|
if (value.brand != null) {
|
|
616
759
|
if (Object.hasOwn(value.brand, 'logo')) fail('工程品牌仅支持嵌入的 logoAssetId,不读取本地 logo 路径')
|
|
617
|
-
for (const key of ['primaryColor', 'secondaryColor', 'backgroundColor', 'textColor', 'fontFamily', 'headingFont', 'coverMode', 'coverBg', 'name', 'footer', 'chromeStyle', 'cardMaterial', 'iconMode', 'taste']) {
|
|
760
|
+
for (const key of ['primaryColor', 'secondaryColor', 'backgroundColor', 'textColor', 'fontFamily', 'headingFont', 'coverMode', 'coverBg', 'name', 'footer', 'watermark', 'chromeStyle', 'cardMaterial', 'iconMode', 'taste']) {
|
|
618
761
|
if (value.brand[key] !== undefined && typeof value.brand[key] !== 'string') fail('工程 brand.' + key + ' 必须为字符串')
|
|
619
762
|
}
|
|
620
763
|
normalizeBrand(value.brand, assets, '.')
|
|
@@ -689,6 +832,9 @@ function mapSlidesToAbsorbedSkeleton(slides, slideSkeleton, langId) {
|
|
|
689
832
|
|
|
690
833
|
export async function buildDeckAsync(options = {}) {
|
|
691
834
|
abort(options.signal)
|
|
835
|
+
if (Array.isArray(options.mergeSources) && options.mergeSources.length > 0) {
|
|
836
|
+
return mergeDecks({ ...options, sources: options.mergeSources })
|
|
837
|
+
}
|
|
692
838
|
validateRawSlides(options.slides)
|
|
693
839
|
const cwd = resolve(options.cwd || '.')
|
|
694
840
|
const scenario = options.template ? findScenarioTemplate(options.template) : undefined
|
|
@@ -726,16 +872,24 @@ export async function buildDeckAsync(options = {}) {
|
|
|
726
872
|
fail('未知品味配方 taste:' + String(options.taste))
|
|
727
873
|
}
|
|
728
874
|
|
|
875
|
+
const activeBrandKit = options.brandKit && typeof options.brandKit === 'object'
|
|
876
|
+
? normalizeBrandKit(options.brandKit)
|
|
877
|
+
: (options.useBrandKit !== false ? loadWorkspaceBrandKit(cwd) : null)
|
|
878
|
+
|
|
729
879
|
const rawThemeOpt = typeof options.theme === 'string' && options.theme.trim() ? options.theme.trim() : undefined
|
|
730
880
|
let chosenThemeId = rawThemeOpt
|
|
731
881
|
let directorHint = null
|
|
732
|
-
if (chosenThemeId === 'auto' || (!chosenThemeId && (options.persona || absorbed || scenario || resolvedTaste || resolvedExemplar))) {
|
|
733
|
-
if (
|
|
882
|
+
if (chosenThemeId === 'auto' || (!chosenThemeId && (options.persona || absorbed || scenario || resolvedTaste || resolvedExemplar || activeBrandKit?.theme))) {
|
|
883
|
+
if (activeBrandKit?.enforce && activeBrandKit?.theme && (!rawThemeOpt || rawThemeOpt === 'auto')) {
|
|
884
|
+
chosenThemeId = activeBrandKit.theme
|
|
885
|
+
} else if (resolvedExemplar?.theme && (!rawThemeOpt || rawThemeOpt === 'auto') && !options.persona) {
|
|
734
886
|
chosenThemeId = resolvedExemplar.theme
|
|
735
887
|
} else if (resolvedTaste?.theme && (!rawThemeOpt || rawThemeOpt === 'auto') && !options.persona) {
|
|
736
888
|
chosenThemeId = resolvedTaste.theme
|
|
737
889
|
} else if (absorbed && (!rawThemeOpt || rawThemeOpt === 'auto') && !options.persona && !scenario) {
|
|
738
890
|
chosenThemeId = absorbed.recommendedTheme
|
|
891
|
+
} else if (activeBrandKit?.theme && (!rawThemeOpt || rawThemeOpt === 'auto') && !options.persona && !scenario) {
|
|
892
|
+
chosenThemeId = activeBrandKit.theme
|
|
739
893
|
} else {
|
|
740
894
|
directorHint = inferThemeFromContent({
|
|
741
895
|
title: options.title,
|
|
@@ -797,7 +951,10 @@ export async function buildDeckAsync(options = {}) {
|
|
|
797
951
|
normalized.deck.slides = optimizeVisualRhythm(normalized.deck.slides, resolvedTaste)
|
|
798
952
|
}
|
|
799
953
|
|
|
800
|
-
const evidence = normalizeEvidenceLedger(options.evidence
|
|
954
|
+
const evidence = normalizeEvidenceLedger(options.evidence, {
|
|
955
|
+
preferredSources: activeBrandKit?.preferredSources,
|
|
956
|
+
blockedDomains: activeBrandKit?.blockedDomains,
|
|
957
|
+
})
|
|
801
958
|
if (evidence.length > 0) {
|
|
802
959
|
const appliedEvidence = applyEvidenceLedgerToSlides(normalized.deck.slides, evidence, {
|
|
803
960
|
lang: langId,
|
|
@@ -834,7 +991,27 @@ export async function buildDeckAsync(options = {}) {
|
|
|
834
991
|
}
|
|
835
992
|
brandInput = options.brand === null ? null : { ...baseAbsorbedBrand, ...(brandInput || {}) }
|
|
836
993
|
}
|
|
994
|
+
if (activeBrandKit) {
|
|
995
|
+
const appliedKit = applyBrandKitToSlidesAndBrand(normalized.deck.slides, brandInput, activeBrandKit)
|
|
996
|
+
if (appliedKit.slides !== normalized.deck.slides) {
|
|
997
|
+
const last = appliedKit.slides[appliedKit.slides.length - 1]
|
|
998
|
+
const normalizedLast = normalizeSlides([last], 120, langId)[0]
|
|
999
|
+
normalized.deck.slides = [...appliedKit.slides.slice(0, -1), normalizedLast]
|
|
1000
|
+
}
|
|
1001
|
+
brandInput = appliedKit.brandInput
|
|
1002
|
+
}
|
|
837
1003
|
const brand = normalizeBrand(brandInput, assets, cwd)
|
|
1004
|
+
const manifestBrandKit = activeBrandKit
|
|
1005
|
+
? {
|
|
1006
|
+
name: activeBrandKit.name,
|
|
1007
|
+
enforce: activeBrandKit.enforce,
|
|
1008
|
+
...(activeBrandKit.watermark ? { watermark: activeBrandKit.watermark } : {}),
|
|
1009
|
+
...(activeBrandKit.brand?.primaryColor ? { brand: { primaryColor: activeBrandKit.brand.primaryColor } } : {}),
|
|
1010
|
+
...(Array.isArray(activeBrandKit.forbiddenTerms) && activeBrandKit.forbiddenTerms.length > 0 ? { forbiddenTerms: activeBrandKit.forbiddenTerms } : {}),
|
|
1011
|
+
...(Array.isArray(activeBrandKit.preferredSources) && activeBrandKit.preferredSources.length > 0 ? { preferredSources: activeBrandKit.preferredSources } : {}),
|
|
1012
|
+
...(Array.isArray(activeBrandKit.blockedDomains) && activeBrandKit.blockedDomains.length > 0 ? { blockedDomains: activeBrandKit.blockedDomains } : {}),
|
|
1013
|
+
}
|
|
1014
|
+
: undefined
|
|
838
1015
|
|
|
839
1016
|
const targetMinutesRaw = options.targetMinutes !== undefined && options.targetMinutes !== null
|
|
840
1017
|
? Number(options.targetMinutes)
|
|
@@ -852,11 +1029,13 @@ export async function buildDeckAsync(options = {}) {
|
|
|
852
1029
|
theme: normalized.theme.id,
|
|
853
1030
|
language: normalized.language.id,
|
|
854
1031
|
motion: normalized.motion,
|
|
1032
|
+
...(normalized.motionProfile ? { motionProfile: normalized.motionProfile } : {}),
|
|
855
1033
|
...(resolvedTaste ? { taste: listCuratedTasteRecipes().some(r => r.id === resolvedTaste.id) ? resolvedTaste.id : resolvedTaste } : {}),
|
|
856
1034
|
...(resolvedExemplar ? { exemplar: resolvedExemplar.id } : {}),
|
|
857
1035
|
...(targetMinutesRaw !== undefined ? { targetMinutes: targetMinutesRaw } : {}),
|
|
858
1036
|
...(scenario ? { template: scenario.id } : {}),
|
|
859
1037
|
...(brand ? { brand } : {}),
|
|
1038
|
+
...(manifestBrandKit ? { brandKit: manifestBrandKit } : {}),
|
|
860
1039
|
...(dataModel ? { dataModel } : {}),
|
|
861
1040
|
...(evidence.length > 0 ? { evidence } : {}),
|
|
862
1041
|
assets,
|
|
@@ -896,10 +1075,9 @@ export async function buildDeckAsync(options = {}) {
|
|
|
896
1075
|
// Resolve collisions after asynchronous rendering; an earlier call may have committed meanwhile.
|
|
897
1076
|
const file = resolveDeckFileName(normalized.outputDir, normalized.fileName, normalized.overwrite)
|
|
898
1077
|
const paths = pathsFor(resolve(normalized.outputDir, file + '.json'))
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
const builtResult = result(activeManifest, paths, writeHandout, writeOnePager)
|
|
1078
|
+
const exp = parseExportOptions(options)
|
|
1079
|
+
withLock(paths.json, () => { abort(options.signal); commit(paths, data, exp.writeHandout, exp.writeOnePager, exp) })
|
|
1080
|
+
const builtResult = result(activeManifest, paths, exp.writeHandout, exp.writeOnePager, exp)
|
|
903
1081
|
return upgradeReport ? { ...builtResult, upgradeReport } : builtResult
|
|
904
1082
|
}
|
|
905
1083
|
|
|
@@ -942,7 +1120,7 @@ export function readDeckProject(options = {}) {
|
|
|
942
1120
|
function expected(manifest, revision) {
|
|
943
1121
|
if (revision !== undefined && (!Number.isInteger(revision) || revision !== manifest.revision)) fail(`修订号冲突:当前 revision=${manifest.revision},请重新读取工程后修改`)
|
|
944
1122
|
}
|
|
945
|
-
async function saveRevision(state, next, signal, saveAs = false, preserveUndo = false) {
|
|
1123
|
+
async function saveRevision(state, next, signal, saveAs = false, preserveUndo = false, saveAsSuffix = '-dsh', expOpts = {}) {
|
|
946
1124
|
if (!saveAs) { const problem = artifactProblem(state.manifest, pathsFor(state.path)); if (problem) fail(problem) }
|
|
947
1125
|
next.version = DECK_VERSION; next.schemaVersion = 1; next.revision = state.manifest.revision + 1
|
|
948
1126
|
if (saveAs) { next.deckId = randomUUID(); next.revision = 0; next.history = preserveUndo ? [snapshot(state.manifest)] : [] }
|
|
@@ -952,14 +1130,33 @@ async function saveRevision(state, next, signal, saveAs = false, preserveUndo =
|
|
|
952
1130
|
abort(signal)
|
|
953
1131
|
if (hash(readFileSync(state.path)) !== state.fingerprint) fail('工程已被其他操作修改,请重新读取后重试')
|
|
954
1132
|
if (saveAs) {
|
|
955
|
-
const file = resolveDeckFileName(dirname(state.path), basename(state.path, '.json') +
|
|
1133
|
+
const file = resolveDeckFileName(dirname(state.path), basename(state.path, '.json') + saveAsSuffix, false)
|
|
956
1134
|
paths = pathsFor(resolve(dirname(state.path), file + '.json'))
|
|
957
1135
|
} else {
|
|
958
1136
|
const problem = artifactProblem(state.manifest, paths); if (problem) fail(problem)
|
|
959
1137
|
}
|
|
960
|
-
commit(paths, data)
|
|
1138
|
+
commit(paths, data, expOpts.writeHandout === true, expOpts.writeOnePager === true, expOpts)
|
|
961
1139
|
})
|
|
962
|
-
return result(next, paths)
|
|
1140
|
+
return result(next, paths, expOpts.writeHandout === true, expOpts.writeOnePager === true, expOpts)
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
export async function remixDeck(options = {}) {
|
|
1144
|
+
abort(options.signal)
|
|
1145
|
+
const state = readDocument(options.deckPath, options.cwd)
|
|
1146
|
+
expected(state.manifest, options.expectedRevision)
|
|
1147
|
+
const presetId = String(options.preset ?? options.remixPreset ?? 'exec-5min').trim().toLowerCase()
|
|
1148
|
+
const remixed = remixSlides(state.manifest, presetId, options.lang || state.manifest.language)
|
|
1149
|
+
const next = clone(state.manifest)
|
|
1150
|
+
next.slides = remixed.slides.map((s) => ({ ...s, id: s.id || randomUUID() }))
|
|
1151
|
+
next.targetMinutes = remixed.targetMinutes
|
|
1152
|
+
next.history = [...next.history, snapshot(state.manifest)].slice(-MAX_HISTORY)
|
|
1153
|
+
const saveAs = options.saveAs !== false
|
|
1154
|
+
const saved = await saveRevision(state, next, options.signal, saveAs, true, '-' + remixed.preset.id)
|
|
1155
|
+
return {
|
|
1156
|
+
...saved,
|
|
1157
|
+
changed: true,
|
|
1158
|
+
remixReport: remixed.report,
|
|
1159
|
+
}
|
|
963
1160
|
}
|
|
964
1161
|
|
|
965
1162
|
export async function editDeck(options = {}) {
|
|
@@ -968,6 +1165,7 @@ export async function editDeck(options = {}) {
|
|
|
968
1165
|
const state = readDocument(options.deckPath, options.cwd), current = state.manifest
|
|
969
1166
|
expected(current, options.expectedRevision)
|
|
970
1167
|
const next = clone(current)
|
|
1168
|
+
const expOpts = parseExportOptions(options)
|
|
971
1169
|
if (!Array.isArray(options.edits) || !options.edits.length) {
|
|
972
1170
|
if (
|
|
973
1171
|
options.brand === undefined &&
|
|
@@ -979,14 +1177,19 @@ export async function editDeck(options = {}) {
|
|
|
979
1177
|
options.remove === undefined &&
|
|
980
1178
|
options.append === undefined &&
|
|
981
1179
|
options.targetMinutes === undefined &&
|
|
1180
|
+
options.remixPreset === undefined &&
|
|
1181
|
+
options.motionProfile === undefined &&
|
|
1182
|
+
options.saveToBank === undefined &&
|
|
1183
|
+
options.translations === undefined &&
|
|
1184
|
+
!expOpts.hasAnyExtra &&
|
|
982
1185
|
options.saveAs !== true
|
|
983
1186
|
) {
|
|
984
|
-
fail('请提供 edits、theme、taste、referencePptx、order、duplicate、remove、append、targetMinutes 或 brand')
|
|
1187
|
+
fail('请提供 edits、theme、taste、referencePptx、order、duplicate、remove、append、targetMinutes、remixPreset、motionProfile、saveToBank、translations、exports 或 brand')
|
|
985
1188
|
}
|
|
986
1189
|
}
|
|
987
1190
|
const used = new Set()
|
|
988
1191
|
const allowed = new Set([
|
|
989
|
-
'layout', 'variant', 'chrome', 'cardMaterial', 'iconMode', 'coverPattern', 'imageBrief', 'title', 'subtitle', 'kicker', 'takeaway', 'source', 'evidenceIds',
|
|
1192
|
+
'layout', 'variant', 'chrome', 'cardMaterial', 'iconMode', 'reveal', 'coverPattern', 'imageBrief', 'title', 'subtitle', 'kicker', 'takeaway', 'source', 'evidenceIds',
|
|
990
1193
|
'text', 'formula', 'mermaid', 'code', 'language', 'filename', 'url', 'xLabel', 'yLabel', 'activeIndex', 'tableStyle',
|
|
991
1194
|
'bullets', 'items', 'cards', 'metrics', 'columns', 'steps', 'quadrants', 'rows', 'notes', 'image', 'images', 'chart', 'visual',
|
|
992
1195
|
])
|
|
@@ -1132,9 +1335,70 @@ export async function editDeck(options = {}) {
|
|
|
1132
1335
|
...(options.brand?.logo === null ? { logo: undefined, logoAssetId: undefined } : {}) }, next.assets, cwd)
|
|
1133
1336
|
if (next.brand && Object.keys(next.brand).length === 0) delete next.brand
|
|
1134
1337
|
}
|
|
1135
|
-
if (options.
|
|
1136
|
-
|
|
1137
|
-
|
|
1338
|
+
if (options.motionProfile !== undefined) {
|
|
1339
|
+
if (options.motionProfile === null || options.motionProfile === '') {
|
|
1340
|
+
delete next.motionProfile
|
|
1341
|
+
} else {
|
|
1342
|
+
const mp = String(options.motionProfile).trim().toLowerCase()
|
|
1343
|
+
if (!['subtle', 'executive', 'keynote'].includes(mp)) fail('motionProfile 仅支持 subtle / executive / keynote')
|
|
1344
|
+
next.motionProfile = mp
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
let savedBankEntry
|
|
1349
|
+
if (options.saveToBank !== undefined && options.saveToBank !== null) {
|
|
1350
|
+
const bankSpec = typeof options.saveToBank === 'number' || typeof options.saveToBank === 'string'
|
|
1351
|
+
? { slide: options.saveToBank }
|
|
1352
|
+
: options.saveToBank
|
|
1353
|
+
savedBankEntry = saveSlideToBank(cwd, next, bankSpec.slide, {
|
|
1354
|
+
bankId: bankSpec.bankId,
|
|
1355
|
+
name: bankSpec.name,
|
|
1356
|
+
tags: bankSpec.tags,
|
|
1357
|
+
})
|
|
1358
|
+
}
|
|
1359
|
+
|
|
1360
|
+
if (options.translations !== undefined && options.translations !== null) {
|
|
1361
|
+
const mode = (options.bilingualMode === true || options.bilingualMode === 'bilingual') ? 'bilingual' : 'replace'
|
|
1362
|
+
const translated = applyTranslationBundle(next, options.translations, {
|
|
1363
|
+
mode,
|
|
1364
|
+
targetLang: options.targetLang,
|
|
1365
|
+
})
|
|
1366
|
+
next.title = translated.title
|
|
1367
|
+
next.language = translated.language
|
|
1368
|
+
next.slides = translated.slides
|
|
1369
|
+
}
|
|
1370
|
+
|
|
1371
|
+
let remixReport
|
|
1372
|
+
let saveAsFlag = options.saveAs === true
|
|
1373
|
+
let saveAsSuffix = '-dsh'
|
|
1374
|
+
if (options.remixPreset !== undefined && options.remixPreset !== null && String(options.remixPreset).trim() !== '') {
|
|
1375
|
+
const remixed = remixSlides(next, String(options.remixPreset).trim().toLowerCase(), next.language)
|
|
1376
|
+
next.slides = remixed.slides.map((s) => ({ ...s, id: s.id || randomUUID() }))
|
|
1377
|
+
if (options.targetMinutes === undefined) next.targetMinutes = remixed.targetMinutes
|
|
1378
|
+
remixReport = remixed.report
|
|
1379
|
+
if (options.saveAs !== false) {
|
|
1380
|
+
saveAsFlag = true
|
|
1381
|
+
saveAsSuffix = '-' + remixed.preset.id
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
const unchangedContent = JSON.stringify(snapshot(next)) === JSON.stringify(snapshot(current))
|
|
1385
|
+
if (!saveAsFlag && unchangedContent && !expOpts.hasAnyExtra) {
|
|
1386
|
+
return {
|
|
1387
|
+
...result(current, pathsFor(state.path)),
|
|
1388
|
+
changed: false,
|
|
1389
|
+
...(savedBankEntry ? { savedBankEntry } : {}),
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
if (!unchangedContent) {
|
|
1393
|
+
next.history = [...next.history, snapshot(current)].slice(-MAX_HISTORY)
|
|
1394
|
+
}
|
|
1395
|
+
const saved = await saveRevision(state, next, options.signal, saveAsFlag, options.preserveUndo === true || Boolean(remixReport), saveAsSuffix, expOpts)
|
|
1396
|
+
return {
|
|
1397
|
+
...saved,
|
|
1398
|
+
changed: !unchangedContent || saveAsFlag || expOpts.hasAnyExtra,
|
|
1399
|
+
...(remixReport ? { remixReport } : {}),
|
|
1400
|
+
...(savedBankEntry ? { savedBankEntry } : {}),
|
|
1401
|
+
}
|
|
1138
1402
|
}
|
|
1139
1403
|
|
|
1140
1404
|
/** An AI-selected, bounded formatting vocabulary; always an undoable new copy. */
|
|
@@ -1157,7 +1421,7 @@ export async function undoDeck(options = {}) {
|
|
|
1157
1421
|
expected(state.manifest, options.expectedRevision)
|
|
1158
1422
|
if (!state.manifest.history.length) fail('该工程没有可撤销的修改')
|
|
1159
1423
|
const next = clone(state.manifest), prior = next.history.pop()
|
|
1160
|
-
for (const key of ['brand', 'template', 'dataModel', 'targetMinutes', 'taste']) delete next[key]
|
|
1424
|
+
for (const key of ['brand', 'brandKit', 'template', 'dataModel', 'targetMinutes', 'taste', 'motionProfile']) delete next[key]
|
|
1161
1425
|
Object.assign(next, prior)
|
|
1162
1426
|
return saveRevision(state, next, options.signal)
|
|
1163
1427
|
}
|
|
@@ -1184,13 +1448,42 @@ export async function updateDeckData(options = {}) {
|
|
|
1184
1448
|
|
|
1185
1449
|
export function checkDeck(options = {}) {
|
|
1186
1450
|
abort(options.signal)
|
|
1187
|
-
const
|
|
1451
|
+
const cwd = resolve(options.cwd || '.')
|
|
1452
|
+
const { manifest, path } = readDocument(options.deckPath, cwd)
|
|
1188
1453
|
const quality = checkManifest(manifest), problem = artifactProblem(manifest, pathsFor(path))
|
|
1189
1454
|
if (problem) {
|
|
1190
1455
|
quality.issues.push({ slide: 0, severity: 'error', code: 'artifact-conflict', message: problem, suggestion: '保留原成品,使用 saveAs:true 或面板「另存副本」。副本不包含 Office 手工修改。' })
|
|
1191
1456
|
quality.errorCount++; quality.ok = false
|
|
1192
1457
|
}
|
|
1458
|
+
let stakeholderFeedback
|
|
1459
|
+
if (options.feedbackPath !== undefined && options.feedbackPath !== null && String(options.feedbackPath).trim() !== '') {
|
|
1460
|
+
const fbFile = resolve(cwd, String(options.feedbackPath).trim())
|
|
1461
|
+
let parsedFb
|
|
1462
|
+
try { parsedFb = JSON.parse(readFileSync(fbFile, 'utf8')) } catch { fail('无法读取审阅反馈文件 feedbackPath:' + fbFile) }
|
|
1463
|
+
const rawList = Array.isArray(parsedFb) ? parsedFb : (Array.isArray(parsedFb?.comments) ? parsedFb.comments : [])
|
|
1464
|
+
stakeholderFeedback = rawList
|
|
1465
|
+
.filter(c => c && typeof c === 'object' && String(c.text || '').trim())
|
|
1466
|
+
.map((c, idx) => ({
|
|
1467
|
+
id: String(c.id || `fb-${idx + 1}`),
|
|
1468
|
+
slide: Number.isInteger(c.slide) && c.slide >= 1 ? Math.min(manifest.slides.length, c.slide) : 1,
|
|
1469
|
+
author: String(c.author || 'Reviewer').slice(0, 60),
|
|
1470
|
+
text: String(c.text).replace(/\s+/g, ' ').trim().slice(0, 400),
|
|
1471
|
+
createdAt: c.createdAt ? String(c.createdAt) : '',
|
|
1472
|
+
}))
|
|
1473
|
+
for (const c of stakeholderFeedback) {
|
|
1474
|
+
quality.issues.push({
|
|
1475
|
+
slide: c.slide,
|
|
1476
|
+
slideId: manifest.slides[c.slide - 1]?.id,
|
|
1477
|
+
severity: 'warning',
|
|
1478
|
+
code: 'stakeholder-feedback',
|
|
1479
|
+
message: `[审阅批注 · ${c.author}] ${c.text}`,
|
|
1480
|
+
suggestion: '请根据审阅人意见调用 ppt_edit 修改对应页面并复核',
|
|
1481
|
+
})
|
|
1482
|
+
quality.warningCount += 1
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1193
1485
|
return { ...quality, deckPath: path, deckId: manifest.deckId, revision: manifest.revision,
|
|
1486
|
+
...(stakeholderFeedback ? { stakeholderFeedback } : {}),
|
|
1194
1487
|
verification: { static: 'checked', pptxRender: 'not-verified', visual: 'not-verified' },
|
|
1195
1488
|
undoAvailable: manifest.history.length, slides: manifest.slides.map((s, i) => ({ slide: i + 1, id: s.id, title: s.title, layout: s.layout })) }
|
|
1196
1489
|
}
|