dsh-ppt 0.32.0 → 0.33.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 +20 -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 +35 -198
- package/lib/tools.js +25 -2
- package/lib/types.d.ts +10 -1
- package/lib/workbench.js +16 -5
- package/package.json +3 -3
- package/skills/dsh-ppt/SKILL.md +1 -1
- package/skills/dsh-ppt/package.json +1 -1
- package/skills/dsh-ppt/references/syntax.md +3 -1
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +23 -6
- package/skills/dsh-ppt/scripts/deck-chrome.mjs +2 -1
- package/skills/dsh-ppt/scripts/deck-core.mjs +7 -4
- package/skills/dsh-ppt/scripts/deck-covers.mjs +89 -3
- package/skills/dsh-ppt/scripts/deck-delivery.mjs +1 -0
- package/skills/dsh-ppt/scripts/deck-evidence.mjs +19 -1
- package/skills/dsh-ppt/scripts/deck-exemplars.mjs +15 -6
- package/skills/dsh-ppt/scripts/deck-infographics.mjs +1214 -0
- package/skills/dsh-ppt/scripts/deck-layouts.mjs +44 -0
- package/skills/dsh-ppt/scripts/deck-media.mjs +41 -8
- package/skills/dsh-ppt/scripts/deck-store.mjs +18 -0
- package/skills/dsh-ppt/scripts/deck-taste.mjs +12 -7
package/lib/types.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export interface PptTasteRecipe {
|
|
|
35
35
|
}
|
|
36
36
|
export type PptPersonaId = 'auto' | 'consulting' | 'tech-pitch' | 'academic' | 'gov-exec' | 'education' | 'editorial';
|
|
37
37
|
export type PptLanguage = 'zh' | 'en' | 'bilingual';
|
|
38
|
-
export type PptSlideLayout = 'cover' | 'agenda' | 'section' | 'bullets' | 'statement' | 'quote' | 'kpi' | 'cards' | 'comparison' | 'matrix' | 'process' | 'callout' | 'gantt' | 'architecture' | 'harvey' | 'tam' | 'org' | 'marimekko' | 'sankey' | 'swot' | 'table' | 'closing' | 'image' | 'image-left' | 'image-right' | 'chart' | 'chart-split' | 'gallery' | 'waterfall' | 'flywheel' | 'bento' | 'pillars' | 'exec-summary' | 'timeline' | 'steps' | 'layers' | 'funnel' | 'chevron' | 'value-chain' | 'issue-action' | 'before-after' | 'matrix-2x2' | 'kpi-grid' | 'scorecard' | 'formula-callout' | 'takeaways' | 'gallery-grid' | 'ablation-compare' | 'roadmap' | 'swimlane' | 'team' | 'mermaid' | 'flowchart' | 'sequence';
|
|
38
|
+
export type PptSlideLayout = 'cover' | 'agenda' | 'section' | 'bullets' | 'statement' | 'quote' | 'kpi' | 'cards' | 'comparison' | 'matrix' | 'process' | 'callout' | 'gantt' | 'architecture' | 'harvey' | 'tam' | 'org' | 'marimekko' | 'sankey' | 'swot' | 'table' | 'closing' | 'image' | 'image-left' | 'image-right' | 'chart' | 'chart-split' | 'gallery' | 'waterfall' | 'flywheel' | 'bento' | 'pillars' | 'exec-summary' | 'timeline' | 'steps' | 'layers' | 'funnel' | 'chevron' | 'value-chain' | 'issue-action' | 'before-after' | 'matrix-2x2' | 'kpi-grid' | 'scorecard' | 'formula-callout' | 'takeaways' | 'gallery-grid' | 'ablation-compare' | 'roadmap' | 'swimlane' | 'team' | 'mermaid' | 'flowchart' | 'sequence' | 'map' | 'world-map' | 'china-map' | 'geo-map' | 'isometric' | 'iso-stack' | 'iso-layers' | '3d-stack' | 'iso-pillars';
|
|
39
39
|
export type PptTemplateId = 'weekly' | 'defense' | 'project' | 'pitch' | 'consulting' | 'keynote' | 'gov-report' | 'workshop' | 'architecture-review' | 'financial-earnings' | 'medical-case' | 'postmortem' | 'marketing-campaign' | 'promotion-review' | 'legal-compliance' | 'creative-lookbook' | 'quarterly-okr' | 'product-prd' | 'vc-daylight' | 'industry-research';
|
|
40
40
|
export type PptTableStyle = 'consulting' | 'booktabs' | 'minimal' | 'banded' | 'harvey';
|
|
41
41
|
export interface PptImageSpec {
|
|
@@ -43,8 +43,16 @@ export interface PptImageSpec {
|
|
|
43
43
|
assetId?: string;
|
|
44
44
|
alt?: string;
|
|
45
45
|
fit?: 'contain' | 'cover';
|
|
46
|
+
focalPoint?: 'center' | 'top' | 'bottom' | 'left' | 'right';
|
|
46
47
|
caption?: string;
|
|
47
48
|
}
|
|
49
|
+
export interface PptImageBrief {
|
|
50
|
+
prompt?: string;
|
|
51
|
+
aspect?: string;
|
|
52
|
+
mood?: string;
|
|
53
|
+
safeZone?: string;
|
|
54
|
+
style?: string;
|
|
55
|
+
}
|
|
48
56
|
export interface PptSlideItem {
|
|
49
57
|
tag?: string;
|
|
50
58
|
badge?: string;
|
|
@@ -262,6 +270,7 @@ export interface PptSlideSpec {
|
|
|
262
270
|
notes?: string;
|
|
263
271
|
image?: PptImageSpec | string | null;
|
|
264
272
|
images?: Array<PptImageSpec | string>;
|
|
273
|
+
imageBrief?: PptImageBrief | string | null;
|
|
265
274
|
chart?: PptChartSpec | null;
|
|
266
275
|
/** Optional bounded native font sizes (in points) and layout polish settings. */
|
|
267
276
|
visual?: {
|
package/lib/workbench.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Operator-only workbench. Paths come from successful tools, never browser input. */
|
|
2
2
|
import { createHash, randomUUID } from 'node:crypto';
|
|
3
|
-
import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { appendFileSync, existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync, openSync, fstatSync, readSync, closeSync } from 'node:fs';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import { basename, dirname, extname, join, resolve } from 'node:path';
|
|
6
6
|
import { getEngine } from './execution.js';
|
|
@@ -486,9 +486,19 @@ export class PptWorkbench {
|
|
|
486
486
|
...(modelRoute ? { modelRoute } : {}),
|
|
487
487
|
};
|
|
488
488
|
mkdirSync(dirname(this.catalogPath), { recursive: true });
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
489
|
+
const descriptor = openSync(this.catalogPath, 'a+');
|
|
490
|
+
try {
|
|
491
|
+
const info = fstatSync(descriptor), tail = Buffer.alloc(1);
|
|
492
|
+
const prefix = info.size && readSync(descriptor, tail, 0, 1, info.size - 1) === 1 && tail[0] !== 10 ? '\n' : '';
|
|
493
|
+
const line = prefix + JSON.stringify(row) + '\n';
|
|
494
|
+
if (info.size + Buffer.byteLength(line) > 8 * 1024 * 1024)
|
|
495
|
+
throw new Error('项目索引已满,请备份后整理 projects.jsonl');
|
|
496
|
+
// Preserve any interrupted append and keep this complete record separate.
|
|
497
|
+
appendFileSync(descriptor, line);
|
|
498
|
+
}
|
|
499
|
+
finally {
|
|
500
|
+
closeSync(descriptor);
|
|
501
|
+
}
|
|
492
502
|
}
|
|
493
503
|
async project(id) {
|
|
494
504
|
if (typeof id !== 'string' || !/^[0-9a-f]{64}$/.test(id))
|
|
@@ -1531,7 +1541,8 @@ export class PptWorkbench {
|
|
|
1531
1541
|
return { ...view, selected };
|
|
1532
1542
|
}
|
|
1533
1543
|
if (body.operation === 'undo') {
|
|
1534
|
-
await engine.undoDeck({ deckPath: entry.path, expectedRevision: body.expectedRevision, signal });
|
|
1544
|
+
const result = await engine.undoDeck({ deckPath: entry.path, expectedRevision: body.expectedRevision, signal });
|
|
1545
|
+
await this.remember(result, {});
|
|
1535
1546
|
return this.view(entry.id);
|
|
1536
1547
|
}
|
|
1537
1548
|
throw new Error('不支持此操作');
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ppt",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "DeepSeek Harness 大师级演示文稿引擎与工作台:支持零资料调研核验与 SLOP-13 事实溯源、20 套标杆范本与弱模型零调用自检修复、24 主题 /
|
|
3
|
+
"version": "0.33.0",
|
|
4
|
+
"description": "DeepSeek Harness 大师级演示文稿引擎与工作台:支持零资料调研核验与 SLOP-13 事实溯源、20 套标杆范本与弱模型零调用自检修复、24 主题 / 37+ 原生可编辑图谱(全球/中国点阵地图、2.5D 等轴测架构/柱碑、Mermaid/公式/代码/魔力象限/雷达/哑铃/热力图)、智能配图协作槽位与双屏提词台,导出离线 HTML + 100% 可编辑 PPTX。欢迎 PR 与 Issues。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"csv-parse": "6.1.0",
|
|
92
92
|
"fflate": "0.8.3",
|
|
93
93
|
"jsep": "1.4.0",
|
|
94
|
-
"@stardustlc/dsh-updates": "0.2.
|
|
94
|
+
"@stardustlc/dsh-updates": "0.2.10"
|
|
95
95
|
},
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"@deepseek-ai/libreoffice-kit": "0.1.5 || 0.2.3"
|
package/skills/dsh-ppt/SKILL.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dsh-ppt
|
|
3
|
-
description: "Turn one sentence, a zero-material research topic, a Markdown document, structured slides, Office files (.xlsx/.csv/.docx), or a benchmark .pptx corpus into a world-class presentation deck: standalone HTML web slideshow (with Dual-Screen Presenter Console & Executive One-Pager) + 100% native-editable PPTX (with 20 Curated Gold Exemplars & Slot-Filling Contracts, Zero-Material Research-to-Deck Planner, Verified Evidence Ledger & SLOP-13 Fact-Grounding Gate, Deterministic Weak-LLM Compensator & Zero-LLM Self-Repair Loop,
|
|
3
|
+
description: "Turn one sentence, a zero-material research topic, a Markdown document, structured slides, Office files (.xlsx/.csv/.docx), or a benchmark .pptx corpus into a world-class presentation deck: standalone HTML web slideshow (with Dual-Screen Presenter Console & Executive One-Pager) + 100% native-editable PPTX (with 20 Curated Gold Exemplars & Slot-Filling Contracts, Zero-Material Research-to-Deck Planner, Verified Evidence Ledger & SLOP-13 Fact-Grounding Gate, Deterministic Weak-LLM Compensator & Zero-LLM Self-Repair Loop, Visual & Map Intelligence: World/China Dotted Strategic Maps, 2.5D Isometric Stack & Pillars, Procedural Cover Artwork waves/isometric-mesh/editorial-arcs, Smart Visual Brief slots, Focal-Point Crop & Full-Bleed Contrast Scrim, 8 Curated Taste Recipes, 61 native <a:custGeom> vector icons, device mockups, 9-language syntax-highlighted code terminals, Magic Quadrant, Radar, Dumbbell, Heatmap, native <m:oMath> formulas, Mermaid flowcharts/sequences, Marimekko, Sankey, Porter Value Chain, SWOT) + project manifest + Speaker Handout. Supports batch .pptx exemplar ingestion, 24 themes, 6 Master Chrome Skeletons, 37+ native-editable layouts, 20 industry blueprints, 13 publication-grade charts, and bilingual ZH/EN support. 中文:内置 20 套标杆范本、零资料深度调研与 SLOP-13 事实出处门禁、全球/中国矢量点阵地图、2.5D 等轴测信息图、高定封面矢量底纹与智能配图协作槽位,让任意模型稳定输出出版级可编辑演示文稿。"
|
|
4
4
|
compatibility: "Node ^22.19.0 or >=24.0.0. Images/charts/PPTX absorption use @office-kit/pptx@0.21.0; optional data models use jsep@1.4.0 and csv-parse@6.1.0. Optional PNG/PDF renderer: @deepseek-ai/libreoffice-kit@0.2.3 (bundled by DSH 0.2.2+; 0.1.5 also supported). Cross-harness: copy the full directory and run npm install --ignore-scripts there."
|
|
5
5
|
allowed-tools: "Bash, Read, Write, Edit"
|
|
6
6
|
---
|
|
@@ -33,13 +33,15 @@
|
|
|
33
33
|
| **`tam`** | `concentric` | `kicker, title, items[]`(3 项 TAM/SAM/SOM,含 `value, title, text`) | **同心圆市场空间测算图**:左侧 3 个底切原生同心椭圆 + 右侧 3 张规模与口径说明卡 |
|
|
34
34
|
| **`org`** | `tree \| team` | `kicker, title, items[]`(`tree` 首项为根节点,2–5 项为子节点;`team` 2–4 人) | **组织架构树 / 核心管理团队介绍**:`tree` 带正交直角连接线;`team` 带圆标首字母头像与履历标签 |
|
|
35
35
|
| **`mermaid`** | `flowchart \| sequence`(亦支持顶层别名) | `kicker, title, mermaid`(Mermaid 代码串), `takeaway` | **原生可编辑 Mermaid 流程图与时序图**:Markdown 中 ```` ```mermaid ```` 自动识别,PPTX 编译为带附着连接点(`stCxn`/`endCxn`)的原生矢量图形与箭头 |
|
|
36
|
+
| **`map`** | `world \| china`(别名 `world-map` / `china-map` / `geo-map`) | `kicker, title, items[]` 或 `rows[][]`(自动匹配全球/中国区域坐标), `takeaway, source` | **零依赖战略矢量点阵地图**:左侧 Economist 风格全球/中国点阵轮廓 + 枢纽脉冲圈与互联虚线,右侧按数值排行的比例条卡片栏,随 24 主题自动配色 |
|
|
37
|
+
| **`isometric`** | `stack \| pillars`(别名 `iso-stack` / `iso-pillars` / `3d-stack`) | `kicker, title, items[]` 或 `rows[][]`, `takeaway` | **2.5D 等轴测矢量信息图**:`stack` 为 3–5 层立体菱形平台架构堆叠 + 左侧非遮挡层号胶囊 + 右侧引线解析卡;`pillars` 为 3–4 根 3D 立体柱碑对比 + 顶部悬浮指标 |
|
|
36
38
|
| `closing` | `standard \| cta-cards \| inverted` | `kicker, title, subtitle, items / bullets` | 结束与行动号召页(自动隐藏页码;支持下一步行动卡片,拒绝孤立「谢谢」) |
|
|
37
39
|
|
|
38
40
|
### B. 5 套媒体与出版级图表版式(`@office-kit/pptx` 增强)
|
|
39
41
|
|
|
40
42
|
| `layout` | 可选 `variant` | 核心槽位 | 典型视觉形态与适用场景 |
|
|
41
43
|
| --- | --- | --- | --- |
|
|
42
|
-
| `image` | `framed \| full-bleed \| gallery` | `title, subtitle, image`
|
|
44
|
+
| `image` | `framed \| full-bleed \| gallery` | `title, subtitle, image`(支持 `focalPoint: center\|top\|bottom\|left\|right`)或 `images[]` 或 `imageBrief` | 单图精裱画框、**全屏出血自动叠加底部暗色渐变护眼层(WCAG AAA 白字)**、多图画册,或暂缺真图时的 **Visual Brief 智能配图占位蓝图** |
|
|
43
45
|
| `image-left` | `framed \| split-bleed` | `kicker, title, subtitle, image, items / bullets` | 左图右文(正文列垂直居中 + 导语分层;`split-bleed` 为左半屏无边距出血大图) |
|
|
44
46
|
| `image-right` | `framed \| split-bleed` | `kicker, title, subtitle, image, items / bullets` | 左文右图(同上) |
|
|
45
47
|
| `chart` | — | `kicker, title, subtitle, chart, takeaway, source` | 全幅出版级图表(13 种图表含矢量 `waterfall` 瀑布桥;亦兼容别名 `layout: "waterfall"`) |
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
} from './deck-exemplars.mjs'
|
|
40
40
|
import { upgradeWeakDeck, resequenceSlidesToExemplar, selfRepairDeck, synthesizeActionTitle } from './deck-upgrader.mjs'
|
|
41
41
|
import { normalizeEvidenceLedger, applyEvidenceLedgerToSlides, auditEvidenceAndSourcing, buildResearchPlan } from './deck-evidence.mjs'
|
|
42
|
+
import { computeMapModel, computeIsometricModel, generateVisualBrief, normalizeImageBrief } from './deck-infographics.mjs'
|
|
42
43
|
export { readRenderReceipt } from './deck-render.mjs'
|
|
43
44
|
export { dataNotes, dataReport } from './deck-data.mjs'
|
|
44
45
|
export { buildDeck, resolveLanguage } from './deck-core.mjs'
|
|
@@ -65,6 +66,7 @@ export {
|
|
|
65
66
|
} from './deck-exemplars.mjs'
|
|
66
67
|
export { upgradeWeakDeck, resequenceSlidesToExemplar, selfRepairDeck, synthesizeActionTitle } from './deck-upgrader.mjs'
|
|
67
68
|
export { normalizeEvidenceLedger, applyEvidenceLedgerToSlides, auditEvidenceAndSourcing, buildResearchPlan } from './deck-evidence.mjs'
|
|
69
|
+
export { computeMapModel, computeIsometricModel, generateVisualBrief, normalizeImageBrief } from './deck-infographics.mjs'
|
|
68
70
|
|
|
69
71
|
export async function ingestExemplarCorpus(options = {}) {
|
|
70
72
|
return ingestExemplarDirectory({
|
|
@@ -362,6 +364,9 @@ export function checkManifest(manifest) {
|
|
|
362
364
|
if (asset.width < box.w * 100 || asset.height < box.h * 100) issue(i, 'low-resolution', `图片为 ${asset.width}×${asset.height},放大后可能模糊`, '换成更高分辨率图片;Logo 等小图可忽略此提示')
|
|
363
365
|
}
|
|
364
366
|
if (!slide.image.alt?.trim()) issue(i, 'missing-alt', '图片没有说明文字', '填写 image.alt,方便读屏及理解图片')
|
|
367
|
+
} else if (slide.imageBrief && ['image', 'image-left', 'image-right'].includes(slide.layout)) {
|
|
368
|
+
const briefMeta = generateVisualBrief(slide, theme, manifest.language || 'zh')
|
|
369
|
+
issue(i, 'image-brief-pending', `本页为智能配图协作槽位(建议画幅 ${slide.imageBrief.aspect || briefMeta.recommendedAspect}),尚未填入最终图片`, '请使用生图工具或本地图片后,通过 ppt_edit 填入 image.src 替换占位蓝图')
|
|
365
370
|
}
|
|
366
371
|
if (slide.chart) {
|
|
367
372
|
try { normalizeChart(slide.chart, i + 1) } catch (error) { issue(i, 'invalid-chart', error.message, '修正图表类别和数值', 'error') }
|
|
@@ -452,14 +457,24 @@ async function exportPptx(manifest, theme, language, signal) {
|
|
|
452
457
|
abort(signal)
|
|
453
458
|
const presentation = await lib.loadPresentation(base), slides = lib.getSlides(presentation)
|
|
454
459
|
const emu = box => Object.fromEntries(Object.entries(box).map(([k, v]) => [k, Math.round(v * 914400)]))
|
|
455
|
-
const putImage = (slide, id, box, fit, name, alt) => {
|
|
460
|
+
const putImage = (slide, id, box, fit, name, alt, focalPoint = 'center', sendToBack = false) => {
|
|
456
461
|
const asset = manifest.assets[id], bytes = Buffer.from(asset.data.split(',')[1], 'base64')
|
|
457
462
|
const shape = lib.addSlideImage(slide, bytes, { ...emu(box), name, fit: fit === 'contain' ? 'contain' : 'fill' })
|
|
458
463
|
lib.setShapeDescription(shape, alt || name)
|
|
459
464
|
if (fit === 'cover') {
|
|
460
465
|
const natural = asset.width / asset.height, target = box.w / box.h
|
|
461
|
-
const
|
|
462
|
-
|
|
466
|
+
const excess = natural > target ? (1 - target / natural) : (1 - natural / target)
|
|
467
|
+
const fp = String(focalPoint || 'center').toLowerCase()
|
|
468
|
+
if (natural > target) {
|
|
469
|
+
const left = fp === 'left' ? 0 : fp === 'right' ? excess : excess / 2
|
|
470
|
+
lib.setShapeImageCrop(shape, { left, right: Math.max(0, excess - left) })
|
|
471
|
+
} else {
|
|
472
|
+
const top = fp === 'top' ? 0 : fp === 'bottom' ? excess : excess / 2
|
|
473
|
+
lib.setShapeImageCrop(shape, { top, bottom: Math.max(0, excess - top) })
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
if (sendToBack && typeof lib.sendShapeToBack === 'function') {
|
|
477
|
+
lib.sendShapeToBack(shape)
|
|
463
478
|
}
|
|
464
479
|
}
|
|
465
480
|
manifest.slides.forEach((source, index) => {
|
|
@@ -469,11 +484,12 @@ async function exportPptx(manifest, theme, language, signal) {
|
|
|
469
484
|
if (Array.isArray(boxes.gallery) && Array.isArray(source.images) && source.images.length > 1) {
|
|
470
485
|
boxes.gallery.forEach((gBox, gIdx) => {
|
|
471
486
|
const img = source.images[gIdx]
|
|
472
|
-
if (img?.assetId) putImage(slide, img.assetId, gBox, img.fit || 'cover', `Gallery image ${gIdx + 1}`, img.alt)
|
|
487
|
+
if (img?.assetId) putImage(slide, img.assetId, gBox, img.fit || 'cover', `Gallery image ${gIdx + 1}`, img.alt, img.focalPoint)
|
|
473
488
|
})
|
|
474
489
|
} else if (source.image) {
|
|
475
490
|
let targetBox = boxes.image
|
|
476
491
|
let targetFit = source.image.fit
|
|
492
|
+
const isFullBleed = source.layout === 'image' && String(source.variant || '').toLowerCase() === 'full-bleed'
|
|
477
493
|
if (source.layout === 'cover') {
|
|
478
494
|
targetBox = { x: 6.65, y: 0, w: 6.6833, h: 7.5 }
|
|
479
495
|
targetFit = source.image.fit || 'cover'
|
|
@@ -485,7 +501,7 @@ async function exportPptx(manifest, theme, language, signal) {
|
|
|
485
501
|
targetBox = computeMockupGeometry(source, chromeCfg.bodyTopY, bodyH).screenBox
|
|
486
502
|
targetFit = source.image.fit || 'cover'
|
|
487
503
|
}
|
|
488
|
-
putImage(slide, source.image.assetId, targetBox, targetFit, 'Slide image', source.image.alt)
|
|
504
|
+
putImage(slide, source.image.assetId, targetBox, targetFit, 'Slide image', source.image.alt, source.image.focalPoint, isFullBleed)
|
|
489
505
|
}
|
|
490
506
|
if (source.chart && source.layout !== 'radar') {
|
|
491
507
|
if (source.chart.kind === 'waterfall') {
|
|
@@ -970,7 +986,7 @@ export async function editDeck(options = {}) {
|
|
|
970
986
|
}
|
|
971
987
|
const used = new Set()
|
|
972
988
|
const allowed = new Set([
|
|
973
|
-
'layout', 'variant', 'chrome', 'cardMaterial', 'iconMode', 'coverPattern', 'title', 'subtitle', 'kicker', 'takeaway', 'source', 'evidenceIds',
|
|
989
|
+
'layout', 'variant', 'chrome', 'cardMaterial', 'iconMode', 'coverPattern', 'imageBrief', 'title', 'subtitle', 'kicker', 'takeaway', 'source', 'evidenceIds',
|
|
974
990
|
'text', 'formula', 'mermaid', 'code', 'language', 'filename', 'url', 'xLabel', 'yLabel', 'activeIndex', 'tableStyle',
|
|
975
991
|
'bullets', 'items', 'cards', 'metrics', 'columns', 'steps', 'quadrants', 'rows', 'notes', 'image', 'images', 'chart', 'visual',
|
|
976
992
|
])
|
|
@@ -997,6 +1013,7 @@ export async function editDeck(options = {}) {
|
|
|
997
1013
|
changed.layout = Array.isArray(edit.patch.images) && edit.patch.images.length > 1 ? 'image' : 'image-right'
|
|
998
1014
|
}
|
|
999
1015
|
if (['image', 'image-left', 'image-right', 'gallery', 'cover', 'mockup'].includes(changed.layout)) delete changed.chart
|
|
1016
|
+
if (!edit.patch.imageBrief) delete changed.imageBrief
|
|
1000
1017
|
}
|
|
1001
1018
|
if (edit.patch.layout) {
|
|
1002
1019
|
const eff = effectiveLayout(edit.patch.layout)
|
|
@@ -768,6 +768,7 @@ export function ooxmlCustGeomShape(id, name, boxIn, pathCommandsXml, options = {
|
|
|
768
768
|
gradientStops = null,
|
|
769
769
|
gradientAngle = 0,
|
|
770
770
|
stroke = '',
|
|
771
|
+
strokeAlpha = 1,
|
|
771
772
|
strokePt = 0.75,
|
|
772
773
|
} = options
|
|
773
774
|
const b = boxToEmu(boxIn)
|
|
@@ -777,7 +778,7 @@ export function ooxmlCustGeomShape(id, name, boxIn, pathCommandsXml, options = {
|
|
|
777
778
|
? ooxmlSolidFill(fill, fillAlpha)
|
|
778
779
|
: '<a:noFill/>'
|
|
779
780
|
const lnXml = stroke
|
|
780
|
-
? '<a:ln w="' + ptToEmu(strokePt) + '" cap="flat">' + ooxmlSolidFill(stroke) + '</a:ln>'
|
|
781
|
+
? '<a:ln w="' + ptToEmu(strokePt) + '" cap="flat">' + ooxmlSolidFill(stroke, strokeAlpha) + '</a:ln>'
|
|
781
782
|
: '<a:ln><a:noFill/></a:ln>'
|
|
782
783
|
|
|
783
784
|
return (
|
|
@@ -61,6 +61,7 @@ import {
|
|
|
61
61
|
import {
|
|
62
62
|
CORE_LAYOUTS,
|
|
63
63
|
LAYOUT_ALIASES,
|
|
64
|
+
normalizeImageBrief,
|
|
64
65
|
EMU_W,
|
|
65
66
|
EMU_H,
|
|
66
67
|
escapeXml,
|
|
@@ -511,7 +512,7 @@ function specialSlidesFor(section, ui) {
|
|
|
511
512
|
const out = []
|
|
512
513
|
if (section.quote.length > 0) out.push(quoteSlideFrom(section, ui))
|
|
513
514
|
const dirLayout = section.directive?.layout
|
|
514
|
-
const tableOwnedByDirective = dirLayout && ['marimekko', 'harvey', 'sankey'].includes(dirLayout)
|
|
515
|
+
const tableOwnedByDirective = dirLayout && ['marimekko', 'harvey', 'sankey', 'map', 'isometric'].includes(dirLayout)
|
|
515
516
|
if (section.table !== null && !tableOwnedByDirective) out.push(...tableSlidesFrom(section, ui))
|
|
516
517
|
if (out.length > 0 && section.notes.length > 0) out[0].notes = section.notes.join('\n')
|
|
517
518
|
return out
|
|
@@ -526,7 +527,7 @@ function directiveSlideFrom(section, ui, pointIndexRef) {
|
|
|
526
527
|
...section.paragraphs.slice(spec.layout === 'callout' ? 1 : 0),
|
|
527
528
|
]
|
|
528
529
|
const items = normalizeSlideItems(rawPoints, spec.layout)
|
|
529
|
-
const dirRows = section.table && ['marimekko', 'harvey', 'sankey'].includes(spec.layout)
|
|
530
|
+
const dirRows = section.table && ['marimekko', 'harvey', 'sankey', 'map', 'isometric'].includes(spec.layout)
|
|
530
531
|
? [section.table.header, ...section.table.rows]
|
|
531
532
|
: undefined
|
|
532
533
|
const effVariant = spec.variant || (spec.layout === 'mermaid' && section.mermaid ? detectMermaidMode(section.mermaid) : '')
|
|
@@ -1135,7 +1136,8 @@ function normalizeSlideContent(raw, index) {
|
|
|
1135
1136
|
const filename = stripInlineMarkdown(source.filename ?? '')
|
|
1136
1137
|
const url = stripInlineMarkdown(source.url ?? '')
|
|
1137
1138
|
const rawCoverPattern = String(source.coverPattern ?? '').trim().toLowerCase()
|
|
1138
|
-
const coverPattern = ['dots', 'grid', 'rings'].includes(rawCoverPattern) ? rawCoverPattern : ''
|
|
1139
|
+
const coverPattern = ['dots', 'grid', 'rings', 'waves', 'isometric-mesh', 'editorial-arcs'].includes(rawCoverPattern) ? rawCoverPattern : ''
|
|
1140
|
+
const imageBrief = normalizeImageBrief(source.imageBrief)
|
|
1139
1141
|
const xLabel = stripInlineMarkdown(source.xLabel ?? '')
|
|
1140
1142
|
const yLabel = stripInlineMarkdown(source.yLabel ?? '')
|
|
1141
1143
|
const hasStringQuadrants = Array.isArray(source.quadrants) && source.quadrants.length === 4 && source.quadrants.every((q) => typeof q === 'string')
|
|
@@ -1166,6 +1168,7 @@ function normalizeSlideContent(raw, index) {
|
|
|
1166
1168
|
...(filename !== '' ? { filename } : {}),
|
|
1167
1169
|
...(url !== '' ? { url } : {}),
|
|
1168
1170
|
...(coverPattern !== '' ? { coverPattern } : {}),
|
|
1171
|
+
...(imageBrief ? { imageBrief } : {}),
|
|
1169
1172
|
...(xLabel !== '' ? { xLabel } : {}),
|
|
1170
1173
|
...(yLabel !== '' ? { yLabel } : {}),
|
|
1171
1174
|
...(quadrantLabels ? { quadrants: quadrantLabels } : {}),
|
|
@@ -1203,7 +1206,7 @@ function normalizeSlideContent(raw, index) {
|
|
|
1203
1206
|
return { layout, kicker, title: truncate(quoteText, 220), subtitle, ...commonExtras }
|
|
1204
1207
|
}
|
|
1205
1208
|
|
|
1206
|
-
if (layout === 'harvey' || layout === 'marimekko' || layout === 'sankey' || layout === 'quadrant' || layout === 'radar' || layout === 'dumbbell' || layout === 'heatmap') {
|
|
1209
|
+
if (layout === 'harvey' || layout === 'marimekko' || layout === 'sankey' || layout === 'quadrant' || layout === 'radar' || layout === 'dumbbell' || layout === 'heatmap' || layout === 'map' || layout === 'isometric') {
|
|
1207
1210
|
let rows = []
|
|
1208
1211
|
if (Array.isArray(source.rows)) {
|
|
1209
1212
|
rows = source.rows
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
computeTextFit,
|
|
19
19
|
ooxmlRichParagraph,
|
|
20
20
|
ooxmlShape,
|
|
21
|
+
ooxmlCustGeomShape,
|
|
21
22
|
ooxmlLine,
|
|
22
23
|
computeBadgePillWidth,
|
|
23
24
|
renderSlideChromePptx,
|
|
@@ -30,16 +31,17 @@ export const POSTER_COVER_VARIANTS = new Set([
|
|
|
30
31
|
'split-bleed',
|
|
31
32
|
])
|
|
32
33
|
|
|
33
|
-
export const COVER_PATTERNS = new Set(['dots', 'grid', 'rings'])
|
|
34
|
+
export const COVER_PATTERNS = new Set(['dots', 'grid', 'rings', 'waves', 'isometric-mesh', 'editorial-arcs'])
|
|
34
35
|
|
|
35
36
|
/**
|
|
36
|
-
*
|
|
37
|
+
* 封面高定程序化矢量底纹(dots / grid / rings / waves / isometric-mesh / editorial-arcs)—— 零外部依赖,低透明度克制点缀。
|
|
37
38
|
*/
|
|
38
39
|
export function renderCoverPatternPptx(pattern, theme, nextId) {
|
|
39
40
|
const p = String(pattern || '').trim().toLowerCase()
|
|
40
41
|
if (!COVER_PATTERNS.has(p)) return ''
|
|
41
42
|
const tk = theme.tokens
|
|
42
43
|
const col = theme.dark ? '#FFFFFF' : tk.accentPrimary
|
|
44
|
+
const col2 = theme.dark ? tk.accentPrimary : (tk.accentSecondary || tk.accentPrimary)
|
|
43
45
|
const out = []
|
|
44
46
|
if (p === 'grid') {
|
|
45
47
|
for (let gx = 0.8; gx <= 12.6; gx += 1.18) {
|
|
@@ -68,10 +70,88 @@ export function renderCoverPatternPptx(pattern, theme, nextId) {
|
|
|
68
70
|
}))
|
|
69
71
|
}
|
|
70
72
|
}
|
|
73
|
+
} else if (p === 'waves') {
|
|
74
|
+
// 4 flowing cubic-Bezier topographic waves across the lower-right horizon
|
|
75
|
+
for (let wi = 0; wi < 4; wi += 1) {
|
|
76
|
+
const yOff = 4.55 + wi * 0.52
|
|
77
|
+
const box = { x: 4.8, y: yOff, w: 8.55, h: 2.15 }
|
|
78
|
+
const pathXml =
|
|
79
|
+
`<a:moveTo><a:pt x="0" y="7400"/></a:moveTo>` +
|
|
80
|
+
`<a:cubicBezTo><a:pt x="2800" y="${2200 + wi * 450}"/><a:pt x="5600" y="${9600 - wi * 380}"/><a:pt x="10000" y="${1600 + wi * 520}"/></a:cubicBezTo>`
|
|
81
|
+
out.push(ooxmlCustGeomShape(nextId(), `Cover Wave ${wi + 1}`, box, pathXml, {
|
|
82
|
+
pathW: 10000,
|
|
83
|
+
pathH: 10000,
|
|
84
|
+
fill: '',
|
|
85
|
+
stroke: wi % 2 === 0 ? col : col2,
|
|
86
|
+
strokeAlpha: theme.dark ? (0.18 - wi * 0.025) : (0.20 - wi * 0.028),
|
|
87
|
+
strokePt: wi === 0 ? 1.4 : 0.9,
|
|
88
|
+
}))
|
|
89
|
+
}
|
|
90
|
+
} else if (p === 'isometric-mesh') {
|
|
91
|
+
// Architectural isometric diamond lattice cascading across the right margin
|
|
92
|
+
const rx = 0.62, ry = 0.34
|
|
93
|
+
const cells = [[0, 0], [1, 0], [2, 0], [0.5, 1], [1.5, 1], [1, 2], [2, 2], [1.5, 3]]
|
|
94
|
+
cells.forEach(([gx, gy], ci) => {
|
|
95
|
+
const bx = 9.2 + gx * (rx * 1.95) - rx
|
|
96
|
+
const by = 0.75 + gy * (ry * 2.05) - ry
|
|
97
|
+
const pathXml = '<a:moveTo><a:pt x="5000" y="0"/></a:moveTo><a:lnTo><a:pt x="10000" y="5000"/></a:lnTo><a:lnTo><a:pt x="5000" y="10000"/></a:lnTo><a:lnTo><a:pt x="0" y="5000"/></a:lnTo><a:close/>'
|
|
98
|
+
out.push(ooxmlCustGeomShape(nextId(), `Cover Iso Tile ${ci + 1}`, { x: bx, y: by, w: rx * 2, h: ry * 2 }, pathXml, {
|
|
99
|
+
pathW: 10000,
|
|
100
|
+
pathH: 10000,
|
|
101
|
+
fill: ci % 3 === 0 ? col : '',
|
|
102
|
+
fillAlpha: ci % 3 === 0 ? (theme.dark ? 0.08 : 0.09) : 0,
|
|
103
|
+
stroke: ci % 2 === 0 ? col : col2,
|
|
104
|
+
strokeAlpha: theme.dark ? 0.16 : 0.18,
|
|
105
|
+
strokePt: 0.75,
|
|
106
|
+
}))
|
|
107
|
+
})
|
|
108
|
+
} else if (p === 'editorial-arcs') {
|
|
109
|
+
// Swiss concentric quarter-arcs + golden-ratio crosshair rules on the right edge
|
|
110
|
+
;[4.2, 6.2, 8.2].forEach((d, ri) => {
|
|
111
|
+
out.push(ooxmlShape(nextId(), `Cover Editorial Arc ${ri + 1}`, { x: 12.8 - d / 2, y: 6.9 - d / 2, w: d, h: d }, {
|
|
112
|
+
preset: 'ellipse',
|
|
113
|
+
fill: '',
|
|
114
|
+
stroke: ri === 0 ? col2 : col,
|
|
115
|
+
strokeAlpha: theme.dark ? (0.14 - ri * 0.025) : (0.16 - ri * 0.03),
|
|
116
|
+
strokePt: ri === 0 ? 1.1 : 0.65,
|
|
117
|
+
}))
|
|
118
|
+
})
|
|
119
|
+
out.push(ooxmlLine(nextId(), 'Editorial Crosshair V', { x: 9.75, y: 0.4 }, { x: 9.75, y: 7.1 }, { color: tk.hairline, widthPt: 0.5 }))
|
|
120
|
+
out.push(ooxmlLine(nextId(), 'Editorial Crosshair H', { x: 8.1, y: 4.85 }, { x: 13.0, y: 4.85 }, { color: tk.hairline, widthPt: 0.5 }))
|
|
71
121
|
}
|
|
72
122
|
return out.join('')
|
|
73
123
|
}
|
|
74
124
|
|
|
125
|
+
function renderCoverPatternSvgHtml(pattern, theme) {
|
|
126
|
+
const p = String(pattern || '').trim().toLowerCase()
|
|
127
|
+
if (!['waves', 'isometric-mesh', 'editorial-arcs'].includes(p)) return ''
|
|
128
|
+
const tk = theme?.tokens || {}
|
|
129
|
+
const col = theme?.dark ? '#FFFFFF' : (tk.accentPrimary || '#0057B8')
|
|
130
|
+
const col2 = theme?.dark ? (tk.accentPrimary || '#60A5FA') : (tk.accentSecondary || col)
|
|
131
|
+
if (p === 'waves') {
|
|
132
|
+
const paths = [0, 1, 2, 3].map((wi) => {
|
|
133
|
+
const y0 = 260 + wi * 38
|
|
134
|
+
return `<path d="M 380 ${y0 + 70} C 640 ${y0 - 30 + wi * 12}, 860 ${y0 + 110 - wi * 10}, 1280 ${y0 - 20 + wi * 16}" fill="none" stroke="${wi % 2 === 0 ? col : col2}" stroke-opacity="${(0.22 - wi * 0.03).toFixed(2)}" stroke-width="${wi === 0 ? 2 : 1.3}"/>`
|
|
135
|
+
}).join('')
|
|
136
|
+
return `<svg class="cover-pat-svg" viewBox="0 0 1280 720" preserveAspectRatio="none" aria-hidden="true">${paths}</svg>`
|
|
137
|
+
}
|
|
138
|
+
if (p === 'isometric-mesh') {
|
|
139
|
+
const rx = 60, ry = 32
|
|
140
|
+
const cells = [[0, 0], [1, 0], [2, 0], [0.5, 1], [1.5, 1], [1, 2], [2, 2], [1.5, 3]]
|
|
141
|
+
const polys = cells.map(([gx, gy], ci) => {
|
|
142
|
+
const cx = 880 + gx * (rx * 1.95)
|
|
143
|
+
const cy = 74 + gy * (ry * 2.05)
|
|
144
|
+
const pts = `${cx},${cy - ry} ${cx + rx},${cy} ${cx},${cy + ry} ${cx - rx},${cy}`
|
|
145
|
+
return `<polygon points="${pts}" fill="${ci % 3 === 0 ? col : 'none'}" fill-opacity="0.08" stroke="${ci % 2 === 0 ? col : col2}" stroke-opacity="0.18" stroke-width="1.2"/>`
|
|
146
|
+
}).join('')
|
|
147
|
+
return `<svg class="cover-pat-svg" viewBox="0 0 1280 720" preserveAspectRatio="xMaxYMin slice" aria-hidden="true">${polys}</svg>`
|
|
148
|
+
}
|
|
149
|
+
const arcs = [210, 310, 410].map((r, ri) =>
|
|
150
|
+
`<circle cx="1220" cy="660" r="${r}" fill="none" stroke="${ri === 0 ? col2 : col}" stroke-opacity="${(0.16 - ri * 0.03).toFixed(2)}" stroke-width="${ri === 0 ? 1.6 : 1}"/>`
|
|
151
|
+
).join('')
|
|
152
|
+
return `<svg class="cover-pat-svg" viewBox="0 0 1280 720" preserveAspectRatio="xMaxYMax slice" aria-hidden="true">${arcs}<line x1="940" y1="40" x2="940" y2="680" stroke="${tk.hairline || '#CBD5E1'}" stroke-opacity="0.45"/><line x1="780" y1="465" x2="1260" y2="465" stroke="${tk.hairline || '#CBD5E1'}" stroke-opacity="0.45"/></svg>`
|
|
153
|
+
}
|
|
154
|
+
|
|
75
155
|
export function renderPosterCoverPptx(slide, ctx) {
|
|
76
156
|
const { coverVariant, title, subtitle, kicker, metaText, total, theme, langAttr, manifest, idBase, nextId } = ctx
|
|
77
157
|
const tk = theme.tokens
|
|
@@ -591,10 +671,12 @@ export function renderPosterCoverHtml(slide, ctx) {
|
|
|
591
671
|
const patClass = COVER_PATTERNS.has(String(slide?.coverPattern || '').toLowerCase())
|
|
592
672
|
? ' cover-pat-' + String(slide.coverPattern).toLowerCase()
|
|
593
673
|
: ''
|
|
674
|
+
const patSvg = renderCoverPatternSvgHtml(slide?.coverPattern, theme)
|
|
594
675
|
|
|
595
676
|
if (coverVariant === 'keynote-glow') {
|
|
596
677
|
return (
|
|
597
678
|
'<div class="cover-shell is-keynote-glow' + patClass + '">' +
|
|
679
|
+
patSvg +
|
|
598
680
|
'<div class="cover-glow-orb orb-a" aria-hidden="true"></div>' +
|
|
599
681
|
'<div class="cover-glow-orb orb-b" aria-hidden="true"></div>' +
|
|
600
682
|
'<div class="cover-center-stack">' +
|
|
@@ -612,7 +694,8 @@ export function renderPosterCoverHtml(slide, ctx) {
|
|
|
612
694
|
const yearMark = /\b(20\d{2})\b/.exec([kicker, title, subtitle, meta].join(' '))?.[1] || '01'
|
|
613
695
|
const rightTag = manifest.brand?.name || (langId === 'en' ? 'SPECIAL REPORT' : '专题深度报告')
|
|
614
696
|
return (
|
|
615
|
-
'<div class="cover-shell is-editorial-grid">' +
|
|
697
|
+
'<div class="cover-shell is-editorial-grid' + patClass + '">' +
|
|
698
|
+
patSvg +
|
|
616
699
|
'<div class="ed-top-bar"><span class="kicker">' + escapeHtml(kicker) + '</span><span class="ed-edition">' + escapeHtml(rightTag) + '</span></div>' +
|
|
617
700
|
'<div class="ed-main-grid">' +
|
|
618
701
|
'<div class="ed-copy"><div class="ed-accent-bar"></div><h1>' + renderInlineHtml(title) + '</h1>' +
|
|
@@ -955,4 +1038,7 @@ export const AESTHETIC_STUDIO_CSS = `
|
|
|
955
1038
|
.photo-cover-right img{width:100%;height:100%;object-fit:cover;display:block}
|
|
956
1039
|
.cover-pat-grid{background-image:linear-gradient(to right,color-mix(in srgb,var(--hairline) 42%,transparent) 1px,transparent 1px),linear-gradient(to bottom,color-mix(in srgb,var(--hairline) 42%,transparent) 1px,transparent 1px);background-size:48px 48px}
|
|
957
1040
|
.cover-pat-dots{background-image:radial-gradient(color-mix(in srgb,var(--accent) 26%,transparent) 1.5px,transparent 1.5px);background-size:24px 24px}
|
|
1041
|
+
.cover-shell.is-editorial-grid,.cover-shell.is-architectural{position:relative}
|
|
1042
|
+
.cover-pat-svg{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;z-index:0}
|
|
1043
|
+
.cover-shell.is-editorial-grid > :not(.cover-pat-svg){position:relative;z-index:1}
|
|
958
1044
|
`
|
|
@@ -11,6 +11,7 @@ const VISUAL_DIAGRAM_LAYOUTS = new Set([
|
|
|
11
11
|
'chart', 'chart-split', 'table', 'gantt', 'architecture', 'harvey',
|
|
12
12
|
'tam', 'org', 'marimekko', 'sankey', 'value-chain', 'swot',
|
|
13
13
|
'process', 'matrix', 'mermaid', 'flowchart', 'sequence',
|
|
14
|
+
'quadrant', 'radar', 'dumbbell', 'heatmap', 'map', 'isometric', 'mockup', 'code',
|
|
14
15
|
'image', 'image-left', 'image-right', 'gallery',
|
|
15
16
|
])
|
|
16
17
|
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { stripInlineMarkdown } from './deck-layouts.mjs'
|
|
15
|
+
import { resolveTheme } from './deck-themes.mjs'
|
|
16
|
+
import { generateVisualBrief } from './deck-infographics.mjs'
|
|
15
17
|
import { CURATED_EXEMPLARS, resolveExemplar, matchBestExemplar, getExemplarFewShotSlides } from './deck-exemplars.mjs'
|
|
16
18
|
|
|
17
19
|
const MAX_EVIDENCE_ITEMS = 60
|
|
@@ -534,8 +536,10 @@ export function buildResearchPlan(options = {}) {
|
|
|
534
536
|
|
|
535
537
|
let evCursor = 0
|
|
536
538
|
const gaps = []
|
|
539
|
+
const resolvedThemeObj = resolveTheme(exemplar.theme || 'consulting')
|
|
540
|
+
const visualBriefs = []
|
|
537
541
|
const storyboard = (exemplar.slots || []).map((slot) => {
|
|
538
|
-
const needsQuant = QUANT_LAYOUTS.has(slot.layout) || slot.layout === 'table' || slot.layout === 'sankey'
|
|
542
|
+
const needsQuant = QUANT_LAYOUTS.has(slot.layout) || slot.layout === 'table' || slot.layout === 'sankey' || slot.layout === 'map'
|
|
539
543
|
const assigned = []
|
|
540
544
|
if (needsQuant && evidence.length > 0 && evCursor < evidence.length) {
|
|
541
545
|
assigned.push(evidence[evCursor].id)
|
|
@@ -552,6 +556,18 @@ export function buildResearchPlan(options = {}) {
|
|
|
552
556
|
: ''
|
|
553
557
|
if (gap) gaps.push({ slide: slot.index, role: slot.role, layout: slot.layout, gap })
|
|
554
558
|
|
|
559
|
+
const wantsVisual = slot.layout === 'cover' || ['image', 'image-left', 'image-right'].includes(slot.layout)
|
|
560
|
+
const visualBrief = wantsVisual
|
|
561
|
+
? generateVisualBrief({
|
|
562
|
+
layout: slot.layout,
|
|
563
|
+
variant: slot.variant || '',
|
|
564
|
+
title: slot.layout === 'cover' ? topic : `${topic} — ${slot.role}`,
|
|
565
|
+
}, resolvedThemeObj, langEn ? 'en' : 'zh')
|
|
566
|
+
: undefined
|
|
567
|
+
if (visualBrief) {
|
|
568
|
+
visualBriefs.push({ slide: slot.index, role: slot.role, layout: slot.layout, ...visualBrief })
|
|
569
|
+
}
|
|
570
|
+
|
|
555
571
|
return {
|
|
556
572
|
slide: slot.index,
|
|
557
573
|
role: slot.role,
|
|
@@ -560,6 +576,7 @@ export function buildResearchPlan(options = {}) {
|
|
|
560
576
|
boundEvidenceIds: assigned,
|
|
561
577
|
titleGuide: langEn ? (slot.exampleTitleEn || slot.fillGuideEn || slot.role) : (slot.exampleTitleZh || slot.fillGuideZh || slot.role),
|
|
562
578
|
fillGuide: langEn ? (slot.fillGuideEn || '') : (slot.fillGuideZh || ''),
|
|
579
|
+
...(visualBrief ? { visualBrief } : {}),
|
|
563
580
|
...(gap ? { gap } : {}),
|
|
564
581
|
}
|
|
565
582
|
})
|
|
@@ -622,6 +639,7 @@ export function buildResearchPlan(options = {}) {
|
|
|
622
639
|
},
|
|
623
640
|
researchRounds,
|
|
624
641
|
storyboard,
|
|
642
|
+
visualBriefs,
|
|
625
643
|
fewShotSlides: getExemplarFewShotSlides(exemplar.id, langEn ? 'en' : 'zh'),
|
|
626
644
|
planMarkdown: lines.join('\n'),
|
|
627
645
|
}
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
* 把“自由设计 PPT”降维为“按标杆槽位精准填空”。
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { existsSync,
|
|
11
|
+
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
12
12
|
import { basename, extname, join, resolve } from 'node:path'
|
|
13
13
|
import { GITHUB_DISTILLED_EXEMPLARS, getExemplarFewShotSlides } from './deck-exemplars-corpus.mjs'
|
|
14
|
+
import { writeWorkspaceJson } from './deck-store.mjs'
|
|
14
15
|
|
|
15
16
|
export { GITHUB_DISTILLED_EXEMPLARS, getExemplarFewShotSlides }
|
|
16
17
|
|
|
@@ -252,11 +253,13 @@ export const CURATED_EXEMPLAR_IDS = Object.freeze(Object.keys(CURATED_EXEMPLARS)
|
|
|
252
253
|
/**
|
|
253
254
|
* 读取工作区 .dsh-ppt/exemplars.json 中通过真实优质 .pptx 吸收持久化的标杆范本。
|
|
254
255
|
*/
|
|
255
|
-
|
|
256
|
+
function readWorkspaceExemplars(cwd, strict = false) {
|
|
256
257
|
const filePath = resolve(cwd, EXEMPLAR_STORE_REL)
|
|
257
258
|
if (!existsSync(filePath)) return {}
|
|
258
259
|
try {
|
|
259
260
|
const raw = JSON.parse(readFileSync(filePath, 'utf8'))
|
|
261
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) throw new Error('Invalid exemplar store')
|
|
262
|
+
if (Object.hasOwn(raw, 'exemplars') && !Array.isArray(raw.exemplars)) throw new Error('Invalid exemplar entries')
|
|
260
263
|
const list = Array.isArray(raw?.exemplars) ? raw.exemplars : (raw && typeof raw === 'object' ? Object.values(raw) : [])
|
|
261
264
|
const map = {}
|
|
262
265
|
for (const item of list) {
|
|
@@ -264,11 +267,14 @@ export function loadWorkspaceExemplars(cwd = '.') {
|
|
|
264
267
|
map[String(item.id)] = item
|
|
265
268
|
}
|
|
266
269
|
return map
|
|
267
|
-
} catch {
|
|
270
|
+
} catch (error) {
|
|
271
|
+
if (strict) throw new Error('dsh-ppt:范本库格式无效或无法读取,已保留原文件,请备份并修复后重试', { cause: error })
|
|
268
272
|
return {}
|
|
269
273
|
}
|
|
270
274
|
}
|
|
271
275
|
|
|
276
|
+
export function loadWorkspaceExemplars(cwd = '.') { return readWorkspaceExemplars(cwd) }
|
|
277
|
+
|
|
272
278
|
/**
|
|
273
279
|
* 持久化单份吸收自外部优质 .pptx 的标杆范本至工作区 .dsh-ppt/exemplars.json。
|
|
274
280
|
*/
|
|
@@ -309,12 +315,11 @@ export function saveWorkspaceExemplar(cwd = '.', exemplar) {
|
|
|
309
315
|
savedAt: new Date().toISOString(),
|
|
310
316
|
}
|
|
311
317
|
|
|
312
|
-
const existing =
|
|
318
|
+
const existing = readWorkspaceExemplars(cwd, true)
|
|
313
319
|
existing[id] = normalized
|
|
314
320
|
const trimmed = Object.values(existing).slice(-MAX_WORKSPACE_EXEMPLARS)
|
|
315
321
|
const outPath = resolve(cwd, EXEMPLAR_STORE_REL)
|
|
316
|
-
|
|
317
|
-
writeFileSync(outPath, JSON.stringify({ schemaVersion: 1, exemplars: trimmed }, null, 2) + '\n', 'utf8')
|
|
322
|
+
writeWorkspaceJson(outPath, { schemaVersion: 1, exemplars: trimmed })
|
|
318
323
|
return { exemplar: normalized, path: outPath }
|
|
319
324
|
}
|
|
320
325
|
|
|
@@ -435,6 +440,7 @@ export function extractExemplarFromAbsorbed(absorbed, options = {}) {
|
|
|
435
440
|
* 批量扫描并吸收指定目录下的优质 .pptx 语料,统一写入 .dsh-ppt/exemplars.json 与 .dsh-ppt/taste-recipes.json。
|
|
436
441
|
*/
|
|
437
442
|
export async function ingestExemplarDirectory({ dirPath, cwd = '.', limit = 20, absorbFn, saveTasteFn, signal }) {
|
|
443
|
+
signal?.throwIfAborted()
|
|
438
444
|
if (!dirPath || typeof dirPath !== 'string') {
|
|
439
445
|
throw new Error('dsh-ppt:请提供包含 .pptx 文件的目录路径 dirPath')
|
|
440
446
|
}
|
|
@@ -451,9 +457,11 @@ export async function ingestExemplarDirectory({ dirPath, cwd = '.', limit = 20,
|
|
|
451
457
|
const absorbedList = []
|
|
452
458
|
const failed = []
|
|
453
459
|
for (const file of files) {
|
|
460
|
+
signal?.throwIfAborted()
|
|
454
461
|
const fullPath = join(absDir, file)
|
|
455
462
|
try {
|
|
456
463
|
const absorbed = await absorbFn({ pptxPath: fullPath, cwd: absDir, extractLogo: true, signal })
|
|
464
|
+
signal?.throwIfAborted()
|
|
457
465
|
const exemplar = extractExemplarFromAbsorbed(absorbed)
|
|
458
466
|
const savedEx = saveWorkspaceExemplar(cwd, exemplar)
|
|
459
467
|
let tastePath = ''
|
|
@@ -473,6 +481,7 @@ export async function ingestExemplarDirectory({ dirPath, cwd = '.', limit = 20,
|
|
|
473
481
|
tastePath,
|
|
474
482
|
})
|
|
475
483
|
} catch (err) {
|
|
484
|
+
signal?.throwIfAborted()
|
|
476
485
|
failed.push({ file, error: err instanceof Error ? err.message : String(err) })
|
|
477
486
|
}
|
|
478
487
|
}
|