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
@@ -0,0 +1,347 @@
1
+ /**
2
+ * deck-taste.mjs —— dsh-ppt 大师审美配方系统(Curated Taste Recipes)与标杆 PPTX 品味学习库。
3
+ *
4
+ * 将世界顶级演示流派(麦肯锡合伙人精修、Apple Keynote 暗夜/纯白、瑞士杂志 Monocle、
5
+ * Linear 玻璃工艺、Financial Times 财经研报、Nature 学术顶会、东方宋韵极简)
6
+ * 抽象为结构化、可组合、可由外部真实优质 .pptx 反向吸收并持久化的 Taste Recipe。
7
+ *
8
+ * 零外部运行时依赖,仅使用 Node 内置模块。
9
+ */
10
+
11
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
12
+ import { dirname, join, resolve } from 'node:path'
13
+
14
+ export const CARD_MATERIALS = Object.freeze(['solid', 'frameless', 'glass', 'editorial-rule'])
15
+ export const COVER_VARIANTS = Object.freeze([
16
+ 'default',
17
+ 'inverted',
18
+ 'monolith',
19
+ 'keynote-glow',
20
+ 'editorial-grid',
21
+ 'architectural',
22
+ 'split-bleed',
23
+ ])
24
+ export const ICON_MODES = Object.freeze(['off', 'explicit', 'auto'])
25
+
26
+ /**
27
+ * 8 套向世界顶级演示流派致敬的精选审美配方(Taste Recipes)。
28
+ * 每份配方同时驱动:主题基调、母版骨架、卡片材质、封面/章节/指标/卡片变体、图标语言、图表聚光灯与增长标注。
29
+ */
30
+ export const CURATED_TASTE_RECIPES = Object.freeze({
31
+ 'mckinsey-partner': Object.freeze({
32
+ id: 'mckinsey-partner',
33
+ name: '麦肯锡合伙人精修',
34
+ enName: 'McKinsey Partner',
35
+ school: 'consulting',
36
+ description: '高白度极克制版面、顶部细线无框指标、议程进度章节页、聚光灯单色图表与 CAGR 增长飞线',
37
+ enDescription: 'Crisp executive daylight, frameless hairline metrics, live agenda chapters, spotlight charts & growth callouts',
38
+ theme: 'consulting',
39
+ chromeStyle: 'consulting-classic',
40
+ tableStyle: 'consulting',
41
+ cardMaterial: 'frameless',
42
+ coverVariant: 'architectural',
43
+ sectionVariant: 'agenda',
44
+ kpiVariant: 'spotlight',
45
+ cardsVariant: 'frameless',
46
+ iconMode: 'explicit',
47
+ iconBadgeStyle: 'ring',
48
+ chartSpotlight: true,
49
+ chartGrowthCallout: true,
50
+ density: 'balanced',
51
+ typeScaleRatio: 1.75,
52
+ swatches: ['#FFFFFF', '#003A70', '#0E7490', '#CBD5E1'],
53
+ }),
54
+ 'apple-keynote-dark': Object.freeze({
55
+ id: 'apple-keynote-dark',
56
+ name: 'Apple 发布会暗夜',
57
+ enName: 'Apple Keynote Dark',
58
+ school: 'keynote',
59
+ description: '深邃双色径向光晕封面、半透明玻璃拟态卡片、超大字号无框指标、非对称 Bento 主次排版与线性图标',
60
+ enDescription: 'Luminous dark gradient glow cover, translucent glass cards, monumental frameless KPIs & asymmetric bento',
61
+ theme: 'aurora-stage',
62
+ chromeStyle: 'keynote-spatial',
63
+ tableStyle: 'minimal',
64
+ cardMaterial: 'glass',
65
+ coverVariant: 'keynote-glow',
66
+ sectionVariant: 'agenda',
67
+ kpiVariant: 'frameless',
68
+ cardsVariant: 'bento-hero',
69
+ iconMode: 'auto',
70
+ iconBadgeStyle: 'soft',
71
+ chartSpotlight: true,
72
+ chartGrowthCallout: true,
73
+ density: 'airy',
74
+ typeScaleRatio: 2.35,
75
+ swatches: ['#070B14', '#2DD4BF', '#818CF8', '#192338'],
76
+ }),
77
+ 'apple-keynote-light': Object.freeze({
78
+ id: 'apple-keynote-light',
79
+ name: 'Apple 极简纯白',
80
+ enName: 'Apple Keynote Light',
81
+ school: 'keynote',
82
+ description: '高透气纯白画布、柔光氛围封面、超大视觉重心指标与非对称 Bento 视觉节奏',
83
+ enDescription: 'Alabaster daylight canvas, soft aura cover, spotlight KPI hero & airy bento rhythm',
84
+ theme: 'keynote-light',
85
+ chromeStyle: 'keynote-spatial',
86
+ tableStyle: 'minimal',
87
+ cardMaterial: 'frameless',
88
+ coverVariant: 'keynote-glow',
89
+ sectionVariant: 'agenda',
90
+ kpiVariant: 'spotlight',
91
+ cardsVariant: 'bento-hero',
92
+ iconMode: 'auto',
93
+ iconBadgeStyle: 'soft',
94
+ chartSpotlight: true,
95
+ chartGrowthCallout: true,
96
+ density: 'airy',
97
+ typeScaleRatio: 2.3,
98
+ swatches: ['#FBFBFD', '#0071E3', '#1D1D1F', '#E5E7EB'],
99
+ }),
100
+ 'swiss-editorial': Object.freeze({
101
+ id: 'swiss-editorial',
102
+ name: '瑞士杂志 · Monocle',
103
+ enName: 'Swiss Editorial',
104
+ school: 'editorial',
105
+ description: '暖米纸张底色、0.5pt 瑞士网格发丝封面、大号衬线序数与双线出版物分栏',
106
+ enDescription: 'Warm archival paper, 0.5pt Swiss hairline grid cover, monumental folio numerals & editorial rules',
107
+ theme: 'economist-brief',
108
+ chromeStyle: 'editorial-folio',
109
+ tableStyle: 'minimal',
110
+ cardMaterial: 'editorial-rule',
111
+ coverVariant: 'editorial-grid',
112
+ sectionVariant: 'agenda',
113
+ kpiVariant: 'spotlight',
114
+ cardsVariant: 'frameless',
115
+ iconMode: 'explicit',
116
+ iconBadgeStyle: 'bare',
117
+ chartSpotlight: true,
118
+ chartGrowthCallout: false,
119
+ density: 'airy',
120
+ typeScaleRatio: 2.1,
121
+ swatches: ['#F9F8F5', '#C8102E', '#141413', '#CFC8BA'],
122
+ }),
123
+ 'linear-craft': Object.freeze({
124
+ id: 'linear-craft',
125
+ name: 'Linear 玻璃工艺',
126
+ enName: 'Linear Craft',
127
+ school: 'tech',
128
+ description: '碳黑高质感暗底、电光紫/青双色微光、精细 1px 玻璃高光卡片、自动语义线性矢量图标',
129
+ enDescription: 'Precision carbon dark canvas, indigo-cyan ambient glow, crisp hairline glass cards & semantic line icons',
130
+ theme: 'linear-dark',
131
+ chromeStyle: 'saas-bento',
132
+ tableStyle: 'minimal',
133
+ cardMaterial: 'glass',
134
+ coverVariant: 'keynote-glow',
135
+ sectionVariant: 'agenda',
136
+ kpiVariant: 'spotlight',
137
+ cardsVariant: 'bento-hero',
138
+ iconMode: 'auto',
139
+ iconBadgeStyle: 'ring',
140
+ chartSpotlight: true,
141
+ chartGrowthCallout: true,
142
+ density: 'balanced',
143
+ typeScaleRatio: 2.0,
144
+ swatches: ['#0B0D14', '#7C6DF0', '#22D3EE', '#1E2436'],
145
+ }),
146
+ 'ft-data-journal': Object.freeze({
147
+ id: 'ft-data-journal',
148
+ name: 'Financial Times 研报',
149
+ enName: 'FT Data Journal',
150
+ school: 'finance',
151
+ description: '经典三文鱼粉纸底、酒红+青黛双色数据叙事、瑞士报刊网格封面与聚光灯增长标注',
152
+ enDescription: 'Iconic salmon paper backdrop, claret & teal financial storytelling, grid cover & spotlight growth charts',
153
+ theme: 'financial-ft',
154
+ chromeStyle: 'editorial-folio',
155
+ tableStyle: 'minimal',
156
+ cardMaterial: 'editorial-rule',
157
+ coverVariant: 'editorial-grid',
158
+ sectionVariant: 'agenda',
159
+ kpiVariant: 'spotlight',
160
+ cardsVariant: 'frameless',
161
+ iconMode: 'explicit',
162
+ iconBadgeStyle: 'bare',
163
+ chartSpotlight: true,
164
+ chartGrowthCallout: true,
165
+ density: 'balanced',
166
+ typeScaleRatio: 1.85,
167
+ swatches: ['#FFF1E5', '#990F3D', '#0D7680', '#1A1816'],
168
+ }),
169
+ 'nature-academic': Object.freeze({
170
+ id: 'nature-academic',
171
+ name: 'Nature / NeurIPS 学术',
172
+ enName: 'Nature Academic',
173
+ school: 'academic',
174
+ description: 'Beamer 学术顶底导航条、标准三线表、高对比无干扰细线结构与章节进度条',
175
+ enDescription: 'Beamer top-bottom running headers, booktabs three-line tables, clean hairline hierarchy & chapter tracker',
176
+ theme: 'academic',
177
+ chromeStyle: 'academic-minimal',
178
+ tableStyle: 'booktabs',
179
+ cardMaterial: 'editorial-rule',
180
+ coverVariant: 'editorial-grid',
181
+ sectionVariant: 'agenda',
182
+ kpiVariant: 'frameless',
183
+ cardsVariant: 'frameless',
184
+ iconMode: 'explicit',
185
+ iconBadgeStyle: 'bare',
186
+ chartSpotlight: true,
187
+ chartGrowthCallout: false,
188
+ density: 'balanced',
189
+ typeScaleRatio: 1.65,
190
+ swatches: ['#FFFFFF', '#0F5257', '#1E293B', '#E2E8F0'],
191
+ }),
192
+ 'oriental-zen': Object.freeze({
193
+ id: 'oriental-zen',
194
+ name: '东方极简 · 宋韵',
195
+ enName: 'Oriental Zen',
196
+ school: 'editorial',
197
+ description: '宣纸暖白留白、朱砂印红与天青黛墨点缀、建筑感不对称封面与大留白无框章节',
198
+ enDescription: 'Xuan paper whitespace, cinnabar & celadon accents, architectural asymmetric cover & serene frameless typography',
199
+ theme: 'exec-palace',
200
+ chromeStyle: 'editorial-folio',
201
+ tableStyle: 'minimal',
202
+ cardMaterial: 'frameless',
203
+ coverVariant: 'architectural',
204
+ sectionVariant: 'agenda',
205
+ kpiVariant: 'spotlight',
206
+ cardsVariant: 'frameless',
207
+ iconMode: 'explicit',
208
+ iconBadgeStyle: 'bare',
209
+ chartSpotlight: true,
210
+ chartGrowthCallout: false,
211
+ density: 'airy',
212
+ typeScaleRatio: 2.05,
213
+ swatches: ['#F9F6F0', '#9E2A2B', '#3D6B5E', '#1C1917'],
214
+ }),
215
+ })
216
+
217
+ export const TASTE_RECIPE_IDS = Object.freeze(Object.keys(CURATED_TASTE_RECIPES))
218
+
219
+ export function listCuratedTasteRecipes() {
220
+ return TASTE_RECIPE_IDS.map((id) => ({ ...CURATED_TASTE_RECIPES[id] }))
221
+ }
222
+
223
+ /**
224
+ * 规范化任意品味配方输入(内置 ID 字符串 或 外部吸收的自定义 StyleRecipe 对象)。
225
+ */
226
+ export function resolveTasteRecipe(input, customRegistry = null) {
227
+ if (!input) return null
228
+ if (typeof input === 'string') {
229
+ const key = input.trim().toLowerCase()
230
+ if (!key) return null
231
+ if (CURATED_TASTE_RECIPES[key]) return { ...CURATED_TASTE_RECIPES[key] }
232
+ if (customRegistry && customRegistry[key]) return sanitizeCustomTasteRecipe(customRegistry[key])
233
+ return null
234
+ }
235
+ if (typeof input === 'object' && !Array.isArray(input)) {
236
+ const base = typeof input.extends === 'string' && CURATED_TASTE_RECIPES[input.extends]
237
+ ? CURATED_TASTE_RECIPES[input.extends]
238
+ : typeof input.id === 'string' && CURATED_TASTE_RECIPES[input.id]
239
+ ? CURATED_TASTE_RECIPES[input.id]
240
+ : null
241
+ return sanitizeCustomTasteRecipe(base ? { ...base, ...input } : input)
242
+ }
243
+ return null
244
+ }
245
+
246
+ export function sanitizeCustomTasteRecipe(raw) {
247
+ if (!raw || typeof raw !== 'object') return null
248
+ const cardMaterial = CARD_MATERIALS.includes(raw.cardMaterial) ? raw.cardMaterial : 'solid'
249
+ const coverVariant = COVER_VARIANTS.includes(raw.coverVariant) ? raw.coverVariant : 'default'
250
+ const iconMode = ICON_MODES.includes(raw.iconMode) ? raw.iconMode : 'explicit'
251
+ const iconBadgeStyle = ['soft', 'ring', 'bare', 'solid'].includes(raw.iconBadgeStyle) ? raw.iconBadgeStyle : 'soft'
252
+ return {
253
+ id: String(raw.id || 'absorbed-custom').trim().slice(0, 64),
254
+ name: String(raw.name || raw.id || '自定义标杆品味').trim().slice(0, 80),
255
+ enName: String(raw.enName || raw.name || raw.id || 'Custom Taste Recipe').trim().slice(0, 80),
256
+ school: String(raw.school || 'custom').trim(),
257
+ description: String(raw.description || '').trim(),
258
+ enDescription: String(raw.enDescription || raw.description || '').trim(),
259
+ ...(raw.theme ? { theme: String(raw.theme).trim() } : {}),
260
+ ...(raw.chromeStyle ? { chromeStyle: String(raw.chromeStyle).trim() } : {}),
261
+ ...(raw.tableStyle ? { tableStyle: String(raw.tableStyle).trim() } : {}),
262
+ cardMaterial,
263
+ coverVariant,
264
+ sectionVariant: raw.sectionVariant === 'agenda' ? 'agenda' : 'default',
265
+ kpiVariant: ['spotlight', 'frameless', 'grid'].includes(raw.kpiVariant) ? raw.kpiVariant : 'grid',
266
+ cardsVariant: ['frameless', 'bento-hero', 'bento', 'pillars'].includes(raw.cardsVariant) ? raw.cardsVariant : 'pillars',
267
+ iconMode,
268
+ iconBadgeStyle,
269
+ chartSpotlight: raw.chartSpotlight === true,
270
+ chartGrowthCallout: raw.chartGrowthCallout === true,
271
+ density: ['airy', 'balanced', 'compact'].includes(raw.density) ? raw.density : 'balanced',
272
+ typeScaleRatio: Number.isFinite(Number(raw.typeScaleRatio)) ? Number(Number(raw.typeScaleRatio).toFixed(2)) : 1.8,
273
+ ...(Number.isFinite(Number(raw.whitespaceRatio)) ? { whitespaceRatio: Number(Number(raw.whitespaceRatio).toFixed(2)) } : {}),
274
+ ...(Number.isFinite(Number(raw.rhythmScore)) ? { rhythmScore: Math.round(Number(raw.rhythmScore)) } : {}),
275
+ ...(raw.brand && typeof raw.brand === 'object' ? { brand: { ...raw.brand } } : {}),
276
+ ...(Array.isArray(raw.swatches) ? { swatches: raw.swatches.slice(0, 4).map(String) } : {}),
277
+ ...(raw.sourceFile ? { sourceFile: String(raw.sourceFile) } : {}),
278
+ ...(raw.absorbedAt ? { absorbedAt: String(raw.absorbedAt) } : {}),
279
+ }
280
+ }
281
+
282
+ /**
283
+ * 读取工作区持久化的用户品味配方库(.dsh-ppt/taste-recipes.json)。
284
+ */
285
+ export function loadWorkspaceTasteRecipes(cwd = process.cwd()) {
286
+ const storePath = resolve(cwd, '.dsh-ppt', 'taste-recipes.json')
287
+ if (!existsSync(storePath)) return {}
288
+ try {
289
+ const parsed = JSON.parse(readFileSync(storePath, 'utf8'))
290
+ const rawMap = parsed && typeof parsed === 'object' && !Array.isArray(parsed)
291
+ ? (parsed.recipes && typeof parsed.recipes === 'object' ? parsed.recipes : parsed)
292
+ : {}
293
+ const out = {}
294
+ for (const [k, v] of Object.entries(rawMap)) {
295
+ const clean = sanitizeCustomTasteRecipe({ id: k, ...v })
296
+ if (clean) out[clean.id.toLowerCase()] = clean
297
+ }
298
+ return out
299
+ } catch {
300
+ return {}
301
+ }
302
+ }
303
+
304
+ /**
305
+ * 将从优质 .pptx 吸收提炼的品味配方持久化到工作区(.dsh-ppt/taste-recipes.json),供后续所有新稿一键复用。
306
+ */
307
+ export function saveWorkspaceTasteRecipe(recipe, cwd = process.cwd()) {
308
+ const clean = sanitizeCustomTasteRecipe(recipe)
309
+ if (!clean) throw new Error('dsh-ppt:无效的品味配方对象')
310
+ const storePath = resolve(cwd, '.dsh-ppt', 'taste-recipes.json')
311
+ const existing = loadWorkspaceTasteRecipes(cwd)
312
+ existing[clean.id.toLowerCase()] = {
313
+ ...clean,
314
+ absorbedAt: clean.absorbedAt || new Date().toISOString(),
315
+ }
316
+ mkdirSync(dirname(storePath), { recursive: true })
317
+ writeFileSync(storePath, JSON.stringify({ version: 1, recipes: existing }, null, 2) + '\n', 'utf8')
318
+ return { path: storePath, recipe: existing[clean.id.toLowerCase()], totalSaved: Object.keys(existing).length }
319
+ }
320
+
321
+ /**
322
+ * 从 manifest / brand / slide 中解析当前页有效的审美材质与品味配置。
323
+ */
324
+ export function resolveActiveTaste(manifest = {}, slide = null) {
325
+ const raw = manifest?.taste ?? manifest?.brand?.tasteRecipe ?? manifest?.brand?.taste ?? null
326
+ const recipe = resolveTasteRecipe(raw)
327
+ const cardMaterial = slide?.cardMaterial || manifest?.brand?.cardMaterial || recipe?.cardMaterial || 'solid'
328
+ const iconMode = slide?.iconMode || manifest?.brand?.iconMode || recipe?.iconMode || 'explicit'
329
+ const iconBadgeStyle = slide?.iconBadgeStyle || recipe?.iconBadgeStyle || (cardMaterial === 'frameless' ? 'bare' : cardMaterial === 'glass' ? 'ring' : 'soft')
330
+ return {
331
+ recipe,
332
+ cardMaterial: CARD_MATERIALS.includes(cardMaterial) ? cardMaterial : 'solid',
333
+ iconMode: ICON_MODES.includes(iconMode) ? iconMode : 'explicit',
334
+ iconBadgeStyle,
335
+ chartSpotlight: slide?.chart?.spotlight ?? recipe?.chartSpotlight ?? false,
336
+ chartGrowthCallout: slide?.chart?.showGrowthCallout ?? recipe?.chartGrowthCallout ?? false,
337
+ }
338
+ }
339
+
340
+ /**
341
+ * 列出所有可用品味配方(内置 8 套 + 工作区已吸收的标杆配方)。
342
+ */
343
+ export function listAllTasteRecipes(cwd = process.cwd()) {
344
+ const curated = listCuratedTasteRecipes().map((r) => ({ ...r, builtin: true }))
345
+ const saved = Object.values(loadWorkspaceTasteRecipes(cwd)).map((r) => ({ ...r, builtin: false }))
346
+ return [...curated, ...saved]
347
+ }