dsh-ppt 0.13.0 → 0.15.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 +17 -0
- package/README.en.md +50 -47
- package/README.md +52 -48
- package/docs/COACHING.md +44 -0
- package/docs/DATA.md +43 -0
- package/docs/USAGE.en.md +196 -196
- package/docs/USAGE.md +218 -217
- package/docs/VALIDATION.md +4 -0
- package/docs/validation/0.8.0.md +10 -10
- package/docs/validation-0.14.0.md +24 -0
- package/docs/validation-0.15.0.md +25 -0
- package/lib/client.js +613 -326
- package/lib/coaching-model.d.ts +12 -0
- package/lib/coaching-model.js +93 -0
- package/lib/coaching.d.ts +197 -0
- package/lib/coaching.js +317 -0
- package/lib/execution.d.ts +3 -0
- package/lib/execution.js +11 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +8 -1
- package/lib/tools.js +27 -0
- package/lib/types.d.ts +43 -0
- package/lib/workbench-language.js +2 -0
- package/lib/workbench.d.ts +4 -0
- package/lib/workbench.js +68 -10
- package/package.json +5 -3
- package/skills/dsh-ppt/SKILL.md +80 -76
- package/skills/dsh-ppt/package.json +11 -11
- package/skills/dsh-ppt/references/advanced.md +41 -41
- package/skills/dsh-ppt/references/data.md +67 -0
- package/skills/dsh-ppt/references/syntax.md +43 -43
- package/skills/dsh-ppt/references/troubleshooting.md +19 -19
- package/skills/dsh-ppt/scripts/build-deck.mjs +3 -0
- package/skills/dsh-ppt/scripts/deck-advanced.mjs +574 -538
- package/skills/dsh-ppt/scripts/deck-core.mjs +2388 -2380
- package/skills/dsh-ppt/scripts/deck-data-math.mjs +76 -0
- package/skills/dsh-ppt/scripts/deck-data-view.mjs +113 -0
- package/skills/dsh-ppt/scripts/deck-data.mjs +190 -0
- package/skills/dsh-ppt/scripts/deck-delivery.mjs +104 -104
- package/skills/dsh-ppt/scripts/deck-render.mjs +270 -270
package/lib/execution.js
CHANGED
|
@@ -63,6 +63,7 @@ export function createPptExecutors(config, loadEngine = getEngine) {
|
|
|
63
63
|
maxSlides: config.maxSlides,
|
|
64
64
|
template: args.template,
|
|
65
65
|
brand: args.brand,
|
|
66
|
+
dataModel: args.dataModel,
|
|
66
67
|
cwd,
|
|
67
68
|
signal: exec?.signal,
|
|
68
69
|
});
|
|
@@ -98,5 +99,15 @@ export function createPptExecutors(config, loadEngine = getEngine) {
|
|
|
98
99
|
exec?.signal?.throwIfAborted();
|
|
99
100
|
return engine.renderDeck({ ...asRecord(rawArgs), cwd: exec?.agent?.session.header.cwd ?? process.cwd(), signal: exec?.signal });
|
|
100
101
|
},
|
|
102
|
+
async data(rawArgs, exec) {
|
|
103
|
+
exec?.signal?.throwIfAborted();
|
|
104
|
+
const engine = await loadEngine(), args = asRecord(rawArgs);
|
|
105
|
+
const options = { ...args, cwd: exec?.agent?.session.header.cwd ?? process.cwd(), signal: exec?.signal, allowFiles: true };
|
|
106
|
+
if (args.action === 'preview')
|
|
107
|
+
return engine.previewDeckData(options);
|
|
108
|
+
if (args.action === 'apply')
|
|
109
|
+
return engine.updateDeckData(options);
|
|
110
|
+
throw new Error('dsh-ppt:action 需为 preview 或 apply / Use preview or apply');
|
|
111
|
+
},
|
|
101
112
|
};
|
|
102
113
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -21,4 +21,4 @@ export interface PptPluginContext {
|
|
|
21
21
|
export declare function apply(ctx: PptPluginContext, config?: Config): void;
|
|
22
22
|
export { resolvePptConfig, PPT_OUTPUT_DIR_ENV, DEFAULT_MAX_SLIDES, clampInt } from './config.js';
|
|
23
23
|
export { bundledSkillsDir, parseSkillFile, registerPptSkill, SKILL_NAMES } from './skill.js';
|
|
24
|
-
export type { PptConfig, PptCreateArgs, PptCreateResult, PptLanguage, PptSlideLayout, PptSlideSpec, PptThemeId, PptThemeInfo, PptThemesResult, PptTemplateId, PptImageSpec, PptChartSpec, PptBrand, PptQualityIssue, PptQualityResult, PptVerification, PptRenderArgs, PptRenderResult, PptCheckResult, PptEditArgs, PptProjectArgs, } from './types.js';
|
|
24
|
+
export type { PptConfig, PptCreateArgs, PptCreateResult, PptLanguage, PptSlideLayout, PptSlideSpec, PptThemeId, PptThemeInfo, PptThemesResult, PptTemplateId, PptImageSpec, PptChartSpec, PptBrand, PptQualityIssue, PptQualityResult, PptVerification, PptRenderArgs, PptRenderResult, PptCheckResult, PptEditArgs, PptProjectArgs, PptDataModel, PptDataSource, PptDataMetric, } from './types.js';
|
package/lib/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { resolvePptConfig } from './config.js';
|
|
|
19
19
|
import { registerPptSkill } from './skill.js';
|
|
20
20
|
import { buildPptTools } from './tools.js';
|
|
21
21
|
import { PptWorkbench, installPptWorkbench } from './workbench.js';
|
|
22
|
+
import { nativeCoachingModel } from './coaching-model.js';
|
|
22
23
|
/** cordis 服务注入:apply 里要使用 ctx.tools 与 ctx.skills。 */
|
|
23
24
|
export const inject = ['tools', 'skills'];
|
|
24
25
|
export const name = 'dsh-ppt';
|
|
@@ -27,8 +28,14 @@ export function apply(ctx, config = {}) {
|
|
|
27
28
|
const warn = (message) => { ctx.logger?.warn?.(message); };
|
|
28
29
|
const disposers = [];
|
|
29
30
|
const workbench = typeof ctx.inject === 'function' ? new PptWorkbench() : undefined;
|
|
30
|
-
if (workbench)
|
|
31
|
+
if (workbench) {
|
|
31
32
|
installPptWorkbench(ctx, workbench);
|
|
33
|
+
ctx.inject?.(['llm'], host => {
|
|
34
|
+
workbench.coaching.setModel(nativeCoachingModel(host.llm));
|
|
35
|
+
host.effect?.(() => () => workbench.coaching.setModel());
|
|
36
|
+
});
|
|
37
|
+
disposers.push(() => workbench.coaching.dispose());
|
|
38
|
+
}
|
|
32
39
|
// 技能注册:单个技能文件缺失只告警,不弄崩宿主启动。
|
|
33
40
|
try {
|
|
34
41
|
disposers.push(registerPptSkill(ctx));
|
package/lib/tools.js
CHANGED
|
@@ -162,6 +162,19 @@ const projectParameters = {
|
|
|
162
162
|
deckPath: { type: 'string', required: true, description: 'Path to a dsh-ppt .json project, relative to this session cwd or absolute. Arbitrary external PPTX editing is not supported.' },
|
|
163
163
|
expectedRevision: { type: 'integer', description: 'Use revision returned by ppt_create/ppt_check to prevent overwriting another edit.' },
|
|
164
164
|
};
|
|
165
|
+
const sourceProperties = {
|
|
166
|
+
id: { type: 'string', description: 'Letters and digits, starting with a letter; unique ID.' }, name: { type: 'string' },
|
|
167
|
+
format: { type: 'string', enum: ['csv', 'tsv', 'text'] }, content: { type: 'string', description: 'CSV/TSV or text content, combined sources at most 1 MiB.' },
|
|
168
|
+
path: { type: 'string', description: 'Explicit local CSV/TSV/TXT/Markdown import path, relative to session cwd. Embedded once; no file watcher.' },
|
|
169
|
+
kind: { type: 'string', enum: ['table', 'text'] }, rows: { type: 'array', items: { type: 'array', items: { oneOf: [{ type: 'string' }, { type: 'number' }] } } }, text: { type: 'string' },
|
|
170
|
+
};
|
|
171
|
+
const metricProperties = {
|
|
172
|
+
id: { type: 'string' }, label: { type: 'string' }, kind: { type: 'string', enum: ['source', 'input', 'formula'] },
|
|
173
|
+
source: { type: 'object', properties: { sourceId: { type: 'string' }, cell: { type: 'string', description: 'A1 to Z500; first CSV row counts as row 1.' }, line: { type: 'integer', description: '1-based text line.' }, numberIndex: { type: 'integer', description: '0-based numeric token on that line.' } }, required: ['sourceId'] },
|
|
174
|
+
value: { type: 'number' }, min: { type: 'number' }, max: { type: 'number' }, step: { type: 'number' }, note: { type: 'string', description: 'Explain the user assumption; do not invent factual provenance.' },
|
|
175
|
+
formula: { type: 'string', description: 'Metric IDs, + - * / % **, parentheses and min/max/sum/abs/floor/ceil/round only. No JS property access or I/O.' },
|
|
176
|
+
format: { type: 'object', properties: { style: { type: 'string', enum: ['number', 'percent'] }, digits: { type: 'integer' }, unit: { type: 'string' } } },
|
|
177
|
+
};
|
|
165
178
|
/** Assemble presentation schemas, rendering and the session-aware executors. */
|
|
166
179
|
export function buildPptTools(config) {
|
|
167
180
|
const executors = createPptExecutors(config);
|
|
@@ -193,6 +206,7 @@ export function buildPptTools(config) {
|
|
|
193
206
|
slides: { type: 'array', items: { type: 'object', properties: slideProperties, additionalProperties: true }, description: 'Structured slides including image/image-left/image-right and chart. Images: {src, alt, fit: contain|cover, caption}. Charts: {kind: column|bar|line|pie, categories, series:[{name,values}]} or rows with header. Tables paginate at 8 data rows. Keep full content editable; use images only for actual photos/screenshots/logos.' },
|
|
194
207
|
template: { type: 'string', enum: ['weekly', 'defense', 'project', 'pitch'], description: 'Scenario reference from ppt_templates. Provide finished content/slides following its outline. Template alone creates a clearly marked draft with unfilled slots, never a finished presentation.' },
|
|
195
208
|
brand: { type: 'object', properties: brandProperties, additionalProperties: false, description: 'Shared brand: #RRGGBB primary/background/text colors, fontFamily, logo and footer. Applied to HTML and PPTX.' },
|
|
209
|
+
dataModel: { type: 'object', properties: { schemaVersion: { type: 'integer', enum: [1] }, sources: { type: 'array', items: { type: 'object', properties: sourceProperties, required: ['id'] } }, metrics: { type: 'array', items: { type: 'object', properties: metricProperties, required: ['id', 'kind'] } } }, additionalProperties: false, description: 'Optional explicit lineage and what-if model. Use with structured slides containing {{metricId}} in text/tables or an exact token as chart values. Source facts reference a real cell or text line; assumptions require value/min/max/step. Formulas compute derived metrics. HTML offers live sliders; PPTX includes confirmed static values, formulas and assumptions in speaker notes. Leave absent for ordinary finished decks.' },
|
|
196
210
|
outputDir: { type: 'string', description: 'Directory to write the files into. Default: session working directory (or the plugin outputDir config).' },
|
|
197
211
|
fileName: { type: 'string', description: 'Base file name for the three artifacts. Default: sanitized deck title.' },
|
|
198
212
|
overwrite: { type: 'boolean', description: 'Replace an existing same-name HTML/PPTX/JSON trio. Default false: choose a unique numeric suffix instead.' },
|
|
@@ -224,6 +238,19 @@ export function buildPptTools(config) {
|
|
|
224
238
|
output: { schema: createResultSchema, render: (_args, value) => renderCreate(value) },
|
|
225
239
|
execute: executors.edit,
|
|
226
240
|
},
|
|
241
|
+
{
|
|
242
|
+
name: 'ppt_data',
|
|
243
|
+
description: 'Preview or confirm source/assumption changes in a data-enabled project. Preview first; inspect affected slides and before/after values, then apply with confirmed:true, exact previewToken and expectedRevision. Default saves an undoable new copy. HTML remains interactive; PPTX is a confirmed static snapshot. Never invent provenance or silently treat assumptions as facts. 中文:预览来源更新或推演参数的影响,确认后保存可撤销副本;只允许更改声明的假设。',
|
|
244
|
+
parameters: compileParameters({ ...projectParameters,
|
|
245
|
+
action: { type: 'string', enum: ['preview', 'apply'], required: true },
|
|
246
|
+
parameters: { type: 'object', additionalProperties: true, description: 'Declared input metric IDs to numeric values only.' },
|
|
247
|
+
sourceUpdates: { type: 'array', items: { type: 'object', properties: sourceProperties, required: ['id'] }, description: 'Replacement content for existing source IDs; keep source type.' },
|
|
248
|
+
scenario: { type: 'object', additionalProperties: true, description: 'Exact scenario.json from HTML: schemaVersion, deckId, revision, fingerprint, parameters. Rejects stale/foreign projects.' },
|
|
249
|
+
previewToken: { type: 'string' }, confirmed: { type: 'boolean' }, saveAs: { type: 'boolean', description: 'Default true. false updates only when artifacts have not been externally modified.' },
|
|
250
|
+
}),
|
|
251
|
+
output: { schema: { type: 'object', additionalProperties: true }, render: (_args, value) => oneText(JSON.stringify(value, null, 2)) },
|
|
252
|
+
execute: executors.data,
|
|
253
|
+
},
|
|
227
254
|
{
|
|
228
255
|
name: 'ppt_undo',
|
|
229
256
|
description: 'Undo the most recent edit in a dsh-ppt JSON project, restoring slides, charts, embedded images and branding together. Revision increases so stale edits cannot overwrite the undo. Keeps up to 20 edits. 中文:撤销最近一次修改,恢复正文、图表、图片和品牌设置。',
|
package/lib/types.d.ts
CHANGED
|
@@ -94,6 +94,43 @@ export interface PptProjectArgs {
|
|
|
94
94
|
deckPath: string;
|
|
95
95
|
expectedRevision?: number;
|
|
96
96
|
}
|
|
97
|
+
export interface PptDataSource {
|
|
98
|
+
id: string;
|
|
99
|
+
name?: string;
|
|
100
|
+
format?: 'csv' | 'tsv' | 'text';
|
|
101
|
+
path?: string;
|
|
102
|
+
content?: string;
|
|
103
|
+
kind?: 'table' | 'text';
|
|
104
|
+
rows?: Array<Array<string | number>>;
|
|
105
|
+
text?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface PptDataMetric {
|
|
108
|
+
id: string;
|
|
109
|
+
label?: string;
|
|
110
|
+
kind: 'source' | 'input' | 'formula';
|
|
111
|
+
source?: {
|
|
112
|
+
sourceId: string;
|
|
113
|
+
cell?: string;
|
|
114
|
+
line?: number;
|
|
115
|
+
numberIndex?: number;
|
|
116
|
+
};
|
|
117
|
+
value?: number;
|
|
118
|
+
min?: number;
|
|
119
|
+
max?: number;
|
|
120
|
+
step?: number;
|
|
121
|
+
note?: string;
|
|
122
|
+
formula?: string;
|
|
123
|
+
format?: {
|
|
124
|
+
style?: 'number' | 'percent';
|
|
125
|
+
digits?: number;
|
|
126
|
+
unit?: string;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
export interface PptDataModel {
|
|
130
|
+
schemaVersion?: 1;
|
|
131
|
+
sources: PptDataSource[];
|
|
132
|
+
metrics: PptDataMetric[];
|
|
133
|
+
}
|
|
97
134
|
export interface PptSlideSpec {
|
|
98
135
|
id?: string;
|
|
99
136
|
layout?: PptSlideLayout;
|
|
@@ -135,6 +172,8 @@ export interface PptCreateArgs {
|
|
|
135
172
|
overwrite?: boolean;
|
|
136
173
|
template?: PptTemplateId;
|
|
137
174
|
brand?: PptBrand;
|
|
175
|
+
/** Optional explicit source facts, assumptions and safe arithmetic; bind slides with {{metricId}}. */
|
|
176
|
+
dataModel?: PptDataModel;
|
|
138
177
|
}
|
|
139
178
|
export interface PptThemeInfo {
|
|
140
179
|
id: string;
|
|
@@ -186,6 +225,10 @@ export interface PptCreateResult {
|
|
|
186
225
|
}
|
|
187
226
|
/** Shared generator and optional renderer exposed to the plugin. */
|
|
188
227
|
export interface DeckEngine {
|
|
228
|
+
previewDeckData(options: Record<string, unknown>): Record<string, any>;
|
|
229
|
+
updateDeckData(options: Record<string, unknown>): Promise<PptCreateResult>;
|
|
230
|
+
dataReport(manifest: any): string;
|
|
231
|
+
dataNotes(manifest: any, slide: any): string;
|
|
189
232
|
buildDeckAsync?(options: Record<string, unknown>): Promise<PptCreateResult>;
|
|
190
233
|
listTemplates(lang?: string): unknown[];
|
|
191
234
|
editDeck(options: Record<string, unknown>): Promise<PptCreateResult>;
|
|
@@ -24,6 +24,8 @@ const messages = {
|
|
|
24
24
|
'图片或请求超过 12 MiB,请压缩后重试': 'The image or request exceeds 12 MiB. Reduce its size and try again.', '请求必须是对象': 'The request must be an object.',
|
|
25
25
|
};
|
|
26
26
|
export function englishWorkbenchMessage(message) {
|
|
27
|
+
if (message.includes(' / '))
|
|
28
|
+
return message.slice(message.lastIndexOf(' / ') + 3);
|
|
27
29
|
if (messages[message])
|
|
28
30
|
return messages[message];
|
|
29
31
|
if (/外部修改|成品校验|保留原成品/.test(message))
|
package/lib/workbench.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type PptExecution } from './execution.js';
|
|
2
2
|
import type { DeckEngine } from './types.js';
|
|
3
|
+
import { PptCoaching } from './coaching.js';
|
|
4
|
+
import type { CoachingModel } from './coaching-model.js';
|
|
3
5
|
export declare const PPT_WORKBENCH_ROUTE = "/api/dsh-ppt/workbench";
|
|
4
6
|
export declare const PPT_DOWNLOAD_ROUTE = "/api/dsh-ppt/download";
|
|
5
7
|
type WorkbenchEngine = DeckEngine & {
|
|
@@ -11,9 +13,11 @@ type WorkbenchEngine = DeckEngine & {
|
|
|
11
13
|
type Options = {
|
|
12
14
|
catalogPath?: string;
|
|
13
15
|
loadEngine?: () => Promise<WorkbenchEngine>;
|
|
16
|
+
coachingModel?: CoachingModel;
|
|
14
17
|
};
|
|
15
18
|
export declare class PptWorkbench {
|
|
16
19
|
readonly catalogPath: string;
|
|
20
|
+
readonly coaching: PptCoaching;
|
|
17
21
|
private readonly loadEngine;
|
|
18
22
|
private readonly renders;
|
|
19
23
|
constructor(options?: Options);
|
package/lib/workbench.js
CHANGED
|
@@ -6,6 +6,7 @@ import { basename, dirname, join, resolve } from 'node:path';
|
|
|
6
6
|
import { getEngine } from './execution.js';
|
|
7
7
|
import { bilingualQuality, englishWorkbenchMessage } from './workbench-language.js';
|
|
8
8
|
import { zipSync, strToU8 } from 'fflate';
|
|
9
|
+
import { PptCoaching } from './coaching.js';
|
|
9
10
|
export const PPT_WORKBENCH_ROUTE = '/api/dsh-ppt/workbench';
|
|
10
11
|
export const PPT_DOWNLOAD_ROUTE = '/api/dsh-ppt/download';
|
|
11
12
|
const REQUEST_LIMIT = 12 * 1024 * 1024;
|
|
@@ -32,7 +33,10 @@ function speakerNotes(manifest) {
|
|
|
32
33
|
function json(status, value) {
|
|
33
34
|
return new Response(JSON.stringify(value), { status, headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' } });
|
|
34
35
|
}
|
|
35
|
-
function fail(status, message) {
|
|
36
|
+
function fail(status, message) {
|
|
37
|
+
const display = /[\u3400-\u9fff]/.test(message) && message.includes(' / ') ? message.slice(0, message.indexOf(' / ')) : message;
|
|
38
|
+
return json(status, { ok: false, message: display, messageEn: englishWorkbenchMessage(message) });
|
|
39
|
+
}
|
|
36
40
|
function originVerdict(request) {
|
|
37
41
|
const site = request.headers.get('sec-fetch-site'), origin = request.headers.get('origin');
|
|
38
42
|
if (site && !['same-origin', 'none'].includes(site))
|
|
@@ -49,11 +53,13 @@ function originVerdict(request) {
|
|
|
49
53
|
}
|
|
50
54
|
export class PptWorkbench {
|
|
51
55
|
catalogPath;
|
|
56
|
+
coaching;
|
|
52
57
|
loadEngine;
|
|
53
58
|
renders = new Map();
|
|
54
59
|
constructor(options = {}) {
|
|
55
60
|
this.catalogPath = options.catalogPath ?? join(process.env.DSH_HOME || join(homedir(), '.dsh'), 'plugins', 'dsh-ppt', 'projects.jsonl');
|
|
56
61
|
this.loadEngine = options.loadEngine ?? getEngine;
|
|
62
|
+
this.coaching = new PptCoaching(join(dirname(this.catalogPath), 'rehearsals'), options.coachingModel);
|
|
57
63
|
}
|
|
58
64
|
catalog() {
|
|
59
65
|
if (!existsSync(this.catalogPath))
|
|
@@ -86,7 +92,11 @@ export class PptWorkbench {
|
|
|
86
92
|
// Versioned generator projects only; arbitrary JSON and externally edited PPTX cannot enter.
|
|
87
93
|
if (manifest.schemaVersion !== 1 || typeof manifest.deckId !== 'string' || manifest.slides.some((s) => typeof s.id !== 'string'))
|
|
88
94
|
return;
|
|
89
|
-
|
|
95
|
+
let route = exec?.agent?.session.requestContext?.();
|
|
96
|
+
if (!route?.provider || !route?.model)
|
|
97
|
+
route = exec?.agent?.session.requestHeader?.()?.config;
|
|
98
|
+
const modelRoute = typeof route?.provider === 'string' && typeof route?.model === 'string' ? { provider: route.provider, model: route.model } : this.catalog().find(p => p.path === path)?.modelRoute;
|
|
99
|
+
const row = { id: digest(path), path, title: manifest.title, updatedAt: new Date().toISOString(), ...(modelRoute ? { modelRoute } : {}) };
|
|
90
100
|
mkdirSync(dirname(this.catalogPath), { recursive: true });
|
|
91
101
|
if (existsSync(this.catalogPath) && lstatSync(this.catalogPath).size >= 8 * 1024 * 1024)
|
|
92
102
|
throw new Error('项目索引已满,请备份后整理 projects.jsonl');
|
|
@@ -116,7 +126,7 @@ export class PptWorkbench {
|
|
|
116
126
|
const render = this.renders.get(entry.id);
|
|
117
127
|
const currentRender = render && render.revision === manifest.revision && digest(ordinaryFile(files.pptx)) === render.sourceSha256 ? render : undefined;
|
|
118
128
|
return { ok: true, project: { ...entry, deckId: manifest.deckId, revision: manifest.revision, slides: manifest.slides,
|
|
119
|
-
undoAvailable: manifest.history.length, quality: check, html,
|
|
129
|
+
undoAvailable: manifest.history.length, quality: check, html, dataModel: manifest.dataModel ?? null,
|
|
120
130
|
assets: Object.fromEntries(Object.entries(manifest.assets ?? {}).map(([key, value]) => [key, { data: value.data, mime: value.mime }])),
|
|
121
131
|
render: currentRender ? { pageCount: currentRender.pngPaths.length, missingFonts: currentRender.missingFonts ?? [] } : null } };
|
|
122
132
|
}
|
|
@@ -160,6 +170,19 @@ export class PptWorkbench {
|
|
|
160
170
|
return this.view(body.id);
|
|
161
171
|
const { entry, engine, manifest, files } = await this.project(body.id);
|
|
162
172
|
signal?.throwIfAborted();
|
|
173
|
+
const context = { id: entry.id, manifest, ...(manifest.dataModel ? { dataNotes: Object.fromEntries(manifest.slides.map((s) => [s.id, engine.dataNotes(manifest, s)])) } : {}) };
|
|
174
|
+
if (body.operation === 'coach-options')
|
|
175
|
+
return { ok: true, ...await this.coaching.options(signal) };
|
|
176
|
+
if (body.operation === 'coach-list')
|
|
177
|
+
return { ok: true, runs: this.coaching.list(context) };
|
|
178
|
+
if (body.operation === 'coach-get')
|
|
179
|
+
return { ok: true, run: this.coaching.get(context, body.runId) };
|
|
180
|
+
if (body.operation === 'coach-stop')
|
|
181
|
+
return { ok: true, run: this.coaching.stop(context, body.runId) };
|
|
182
|
+
if (body.operation === 'coach-finish')
|
|
183
|
+
return { ok: true, run: this.coaching.finish(context, body.runId) };
|
|
184
|
+
if (body.operation === 'coach-delete')
|
|
185
|
+
return { ok: true, ...this.coaching.remove(context, body.runId) };
|
|
163
186
|
if (body.operation === 'download') {
|
|
164
187
|
if (!['html', 'pptx', 'json'].includes(String(body.kind)))
|
|
165
188
|
throw new Error('不支持此文件类型');
|
|
@@ -178,6 +201,33 @@ export class PptWorkbench {
|
|
|
178
201
|
return { ok: true, data: 'data:image/png;base64,' + bytes.toString('base64') };
|
|
179
202
|
}
|
|
180
203
|
this.revision(body, manifest);
|
|
204
|
+
if (body.operation === 'data-preview' || body.operation === 'data-apply') {
|
|
205
|
+
// Always force file reads off, including nested source updates and scenario packets.
|
|
206
|
+
const args = { deckPath: entry.path, expectedRevision: body.expectedRevision, parameters: body.parameters, sourceUpdates: body.sourceUpdates,
|
|
207
|
+
scenario: body.scenario, previewToken: body.previewToken, confirmed: body.confirmed, saveAs: body.saveAs !== false, allowFiles: false, signal };
|
|
208
|
+
if (body.operation === 'data-preview')
|
|
209
|
+
return engine.previewDeckData(args);
|
|
210
|
+
const result = await engine.updateDeckData(args);
|
|
211
|
+
await this.remember(result, args);
|
|
212
|
+
return { ...await this.view(digest(result.jsonPath)), originalId: entry.id };
|
|
213
|
+
}
|
|
214
|
+
if (body.operation === 'coach-create')
|
|
215
|
+
return { ok: true, run: await this.coaching.create(context, body, signal) };
|
|
216
|
+
if (body.operation === 'coach-step') {
|
|
217
|
+
await this.coaching.step(context, body.runId, body, signal);
|
|
218
|
+
const current = await this.project(entry.id);
|
|
219
|
+
return { ok: true, run: this.coaching.get({ id: entry.id, manifest: current.manifest }, body.runId) };
|
|
220
|
+
}
|
|
221
|
+
if (body.operation === 'coach-apply') {
|
|
222
|
+
if (body.confirmed !== true)
|
|
223
|
+
throw new Error('请确认采纳所选建议 / Confirm selected suggestions');
|
|
224
|
+
const { edits, append } = this.coaching.application(context, body.runId, body.selected, body.backup);
|
|
225
|
+
const args = { deckPath: entry.path, expectedRevision: manifest.revision, signal, saveAs: true, preserveUndo: true,
|
|
226
|
+
...(edits.length ? { edits } : {}), ...(append.length ? { append } : {}) };
|
|
227
|
+
const result = await engine.editDeck(args);
|
|
228
|
+
await this.remember(result, args);
|
|
229
|
+
return { ...await this.view(digest(result.jsonPath)), originalId: entry.id };
|
|
230
|
+
}
|
|
181
231
|
if (body.operation === 'render') {
|
|
182
232
|
const result = await engine.renderDeck({ pptxPath: files.pptx, format: 'png', signal });
|
|
183
233
|
if (result.ok)
|
|
@@ -226,15 +276,23 @@ export class PptWorkbench {
|
|
|
226
276
|
return denied;
|
|
227
277
|
try {
|
|
228
278
|
const params = new URL(request.url).searchParams, kind = params.get('kind');
|
|
229
|
-
if (!['html', 'pptx', 'json', 'bundle', 'notes'].includes(String(kind)))
|
|
279
|
+
if (!['html', 'pptx', 'json', 'bundle', 'notes', 'coaching', 'data'].includes(String(kind)))
|
|
230
280
|
return fail(400, '不支持此文件类型');
|
|
231
|
-
const { entry, manifest, files } = await this.project(params.get('id'));
|
|
281
|
+
const { entry, manifest, files, engine } = await this.project(params.get('id'));
|
|
232
282
|
if (String(manifest.revision) !== params.get('revision'))
|
|
233
283
|
return fail(409, '项目已被修改,请重新打开后下载');
|
|
234
284
|
request.signal.throwIfAborted();
|
|
235
285
|
let name, bytes;
|
|
236
|
-
if (kind === '
|
|
237
|
-
bytes = strToU8(
|
|
286
|
+
if (kind === 'data') {
|
|
287
|
+
bytes = strToU8(engine.dataReport(manifest));
|
|
288
|
+
name = basename(entry.path, '.json') + '-data-lineage.md';
|
|
289
|
+
}
|
|
290
|
+
else if (kind === 'coaching') {
|
|
291
|
+
bytes = strToU8(this.coaching.markdown({ id: entry.id, manifest }, params.get('run')));
|
|
292
|
+
name = basename(entry.path, '.json') + '-rehearsal.md';
|
|
293
|
+
}
|
|
294
|
+
else if (kind === 'notes') {
|
|
295
|
+
bytes = strToU8(speakerNotes({ ...manifest, slides: manifest.slides.map((slide) => ({ ...slide, notes: engine.dataNotes(manifest, slide) })) }));
|
|
238
296
|
name = basename(entry.path, '.json') + '-speaker-notes.md';
|
|
239
297
|
}
|
|
240
298
|
else if (kind === 'bundle') {
|
|
@@ -265,10 +323,10 @@ export class PptWorkbench {
|
|
|
265
323
|
request.signal.throwIfAborted();
|
|
266
324
|
if ((await this.project(entry.id)).manifest.revision !== manifest.revision)
|
|
267
325
|
return fail(409, '项目已被修改,请重新打开后下载');
|
|
268
|
-
const type = kind === 'notes' ? 'text/markdown; charset=utf-8' : kind === 'bundle' ? 'application/zip' : kind === 'pptx' ? 'application/vnd.openxmlformats-officedocument.presentationml.presentation' : kind === 'html' ? 'text/html; charset=utf-8' : 'application/json; charset=utf-8';
|
|
326
|
+
const type = kind === 'notes' || kind === 'coaching' || kind === 'data' ? 'text/markdown; charset=utf-8' : kind === 'bundle' ? 'application/zip' : kind === 'pptx' ? 'application/vnd.openxmlformats-officedocument.presentationml.presentation' : kind === 'html' ? 'text/html; charset=utf-8' : 'application/json; charset=utf-8';
|
|
269
327
|
return new Response(new Uint8Array(bytes), { headers: {
|
|
270
328
|
'content-type': type, 'cache-control': 'no-store', 'x-content-type-options': 'nosniff',
|
|
271
|
-
'content-disposition': `attachment; filename="presentation.${kind === 'bundle' ? 'zip' : kind === 'notes' ? 'md' : kind}"; filename*=UTF-8''${encodeURIComponent(name)}`,
|
|
329
|
+
'content-disposition': `attachment; filename="presentation.${kind === 'bundle' ? 'zip' : kind === 'notes' || kind === 'coaching' || kind === 'data' ? 'md' : kind}"; filename*=UTF-8''${encodeURIComponent(name)}`,
|
|
272
330
|
} });
|
|
273
331
|
}
|
|
274
332
|
catch (error) {
|
|
@@ -312,7 +370,7 @@ export class PptWorkbench {
|
|
|
312
370
|
}
|
|
313
371
|
catch (error) {
|
|
314
372
|
const message = error instanceof Error ? error.message : String(error);
|
|
315
|
-
return fail(
|
|
373
|
+
return fail(/修订号冲突|已被修改|工程已被修改|正在被另一次|其他操作修改/.test(message) ? 409 : 400, message);
|
|
316
374
|
}
|
|
317
375
|
}
|
|
318
376
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ppt",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "DSH 演示文稿插件:生成 HTML、可编辑 PPTX
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"description": "DSH 演示文稿插件:生成 HTML、可编辑 PPTX 和工程文件,支持数字溯源、现场推演、编辑与可选 AI 演练。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
@@ -79,7 +79,9 @@
|
|
|
79
79
|
"packageManager": "pnpm@11.7.0",
|
|
80
80
|
"dependencies": {
|
|
81
81
|
"@office-kit/pptx": "0.21.0",
|
|
82
|
-
"
|
|
82
|
+
"csv-parse": "6.1.0",
|
|
83
|
+
"fflate": "0.8.3",
|
|
84
|
+
"jsep": "1.4.0"
|
|
83
85
|
},
|
|
84
86
|
"peerDependencies": {
|
|
85
87
|
"@deepseek-ai/libreoffice-kit": "0.1.5"
|
package/skills/dsh-ppt/SKILL.md
CHANGED
|
@@ -1,76 +1,80 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dsh-ppt
|
|
3
|
-
description: "Turn one sentence or a Markdown document into a complete, presentation-ready deck: a standalone HTML web slideshow plus an editable PPTX export, with 5 built-in visual themes (Swiss Pulse / Velvet Standard / Data Drift / Soft Signal / Maximalist Type), slide transitions + bullet entrance animations (motion, on by default), and bilingual Chinese/English support. Use when the user asks for a PPT, slides, deck, keynote, 演示文稿, 幻灯片, 汇报, 提案, 路演, 培训材料, or wants to turn a document into a presentation. 中文:把一句话或一篇文档变成完整演示文稿(HTML 网页放映 + PPTX 导出),内置 5 套视觉主题、页间转场与要点入场动画,中英双语。"
|
|
4
|
-
compatibility: "Node ^22.19.0 or >=24.0.0. Images/charts use @office-kit/pptx@0.21.0. Optional PNG/PDF renderer: @deepseek-ai/libreoffice-kit@0.1.
|
|
5
|
-
allowed-tools: "Bash, Read, Write, Edit"
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# dsh-ppt
|
|
9
|
-
|
|
10
|
-
一句话或一篇文档 → 完整演示文稿:**独立 HTML 网页放映 + 可编辑 PPTX**。本文件只做路由与纪律;具体规则按需读取 `references/`。
|
|
11
|
-
|
|
12
|
-
## 触发条件
|
|
13
|
-
|
|
14
|
-
用户要做 PPT / 幻灯片 / 演示文稿 / deck / 汇报 / 提案 / 路演 / 培训材料,或给一句话、一段文字、一篇 Markdown 想变成可放映的演示。
|
|
15
|
-
|
|
16
|
-
## 执行纪律(每次都要遵守)
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
- [ ]
|
|
59
|
-
- [ ]
|
|
60
|
-
- [ ]
|
|
61
|
-
- [ ]
|
|
62
|
-
- [ ]
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
76
|
-
|
|
1
|
+
---
|
|
2
|
+
name: dsh-ppt
|
|
3
|
+
description: "Turn one sentence or a Markdown document into a complete, presentation-ready deck: a standalone HTML web slideshow plus an editable PPTX export, with 5 built-in visual themes (Swiss Pulse / Velvet Standard / Data Drift / Soft Signal / Maximalist Type), slide transitions + bullet entrance animations (motion, on by default), and bilingual Chinese/English support. Use when the user asks for a PPT, slides, deck, keynote, 演示文稿, 幻灯片, 汇报, 提案, 路演, 培训材料, or wants to turn a document into a presentation. 中文:把一句话或一篇文档变成完整演示文稿(HTML 网页放映 + PPTX 导出),内置 5 套视觉主题、页间转场与要点入场动画,中英双语。"
|
|
4
|
+
compatibility: "Node ^22.19.0 or >=24.0.0. Images/charts 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.1.5. Cross-harness: copy the full directory and run npm install --ignore-scripts there."
|
|
5
|
+
allowed-tools: "Bash, Read, Write, Edit"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# dsh-ppt
|
|
9
|
+
|
|
10
|
+
一句话或一篇文档 → 完整演示文稿:**独立 HTML 网页放映 + 可编辑 PPTX**。本文件只做路由与纪律;具体规则按需读取 `references/`。
|
|
11
|
+
|
|
12
|
+
## 触发条件
|
|
13
|
+
|
|
14
|
+
用户要做 PPT / 幻灯片 / 演示文稿 / deck / 汇报 / 提案 / 路演 / 培训材料,或给一句话、一段文字、一篇 Markdown 想变成可放映的演示。
|
|
15
|
+
|
|
16
|
+
## 执行纪律(每次都要遵守)
|
|
17
|
+
|
|
18
|
+
- 默认直接交付成品,不自动触发 AI 预审或答辩。用户可在设置页成品下载区主动开启两个可选模式;选择模型、范围与调用上限后再发送材料。AI 演练不等于事实核验,不编造实验、数据或引用;采纳建议另存副本,原件保留。
|
|
19
|
+
- 数字溯源和现场推演也按需启用。提供 `dataModel` 与结构化 `slides` 的 `{{metricId}}` 绑定;先读 `references/data.md`。源事实必须对应真实材料行或单元格;用户假设用 `kind:input` 标注,禁止虚构来源。修改数据先 `ppt_data(action:preview)`,展示指标与页面差异,得到确认后携带原预览凭证和修订号保存;默认新副本。离线 HTML 参数必须回存确认后才能交付对应静态 PPTX。
|
|
20
|
+
|
|
21
|
+
- 修改工程先 `ppt_check`。外部编辑过的 HTML/PPTX、缺少成品校验记录的旧工程不可覆盖;告知用户 `saveAs:true` 只从 JSON 另存新副本,原件保留,Office 手工修改不会导入。不得绕过校验或自行篡改校验值。
|
|
22
|
+
|
|
23
|
+
- 一页一个观点;标题是判断句,不是名词短语。
|
|
24
|
+
- 内容语言由你撰写;`lang` 只决定界面文字。
|
|
25
|
+
- 先选主题再构建;不确定就用默认 `data`。
|
|
26
|
+
- 交付前逐项过一遍文末「质量门禁」。
|
|
27
|
+
- 目标是可用成品:先组织真实内容,再调用生成器;未填模板必须标注草稿,不编造缺失事实。
|
|
28
|
+
- 渲染报告缺失字体时,替换为环境和接收方机器可用字体,重新生成并逐页检查;未解决需标注字体问题,不能声称已验收。
|
|
29
|
+
|
|
30
|
+
## 核心流水线
|
|
31
|
+
|
|
32
|
+
1. **Probe 需求**:读入用户的句子/文档,确定听众、目标、语气。一句话输入不要反问,直接按发布场景推断。
|
|
33
|
+
2. **Outline 大纲**:产出 5–12 页大纲(封面 → 问题/背景 → 方案/论点 3–6 页 → 证据 → 行动号召 → 结束页)。
|
|
34
|
+
→ 写大纲与正文前先读 `references/copywriting.md`。
|
|
35
|
+
3. **Theme 主题**:调 `ppt_themes`(DSH)或 `node scripts/build-deck.mjs --list-themes`(跨 harness)。
|
|
36
|
+
→ 拿不准选哪套时读 `references/themes.md` 的情绪决策树。
|
|
37
|
+
4. **Build 生成**:
|
|
38
|
+
- DSH 内:调 `ppt_create`,大纲写成 Markdown 传 `content`(推荐),或传结构化 `slides`。
|
|
39
|
+
- 跨 harness:`node <skill-dir>/scripts/build-deck.mjs --title "标题" --content deck.md --theme data --lang zh --out dist`。
|
|
40
|
+
- 动效默认开(页间转场 + 要点逐条入场);严肃/打印场景传 `motion: 'off'`。
|
|
41
|
+
→ 用表格 / 金句 / 备注 / 结构化 slides 前读 `references/syntax.md`。
|
|
42
|
+
5. **Verify 校验与修正**:调 `ppt_check` 检查具体页;在浏览器操作放映、总览和备注,查看图片/图表。若可选官方引擎可用,调 `ppt_render` 读取最终 PPTX 生成逐页 PNG/PDF,逐页看画面。修正用 `ppt_edit`,以 `expectedRevision` 防冲突;需要时 `ppt_undo`。修改后重新渲染,以收据复核当前文件。文件头/结构通过不等同于视觉验收,静态估算、渲染、视觉检查必须分开说明。
|
|
43
|
+
6. **Deliver 交付**:给用户三个绝对路径,说明 HTML 直接放映(← → 翻页 · F 全屏 · G 总览 · S 备注 · P 打印),PPTX 用 PowerPoint / WPS / Keynote 打开(备注在演示者视图可见,bullets 页放映时逐条点击出现)。DSH 用户也可在「设置 → 演示文稿」修改文字、替换 PNG/JPEG、移动/复制/删除页面、撤销和下载最新文件;已有 JSON 工程先 `ppt_check` 才会出现在项目列表。`ppt_edit.order` 使用每个稳定页面 ID 各一次;`duplicate`、`remove` 使用修改前的页码或稳定 ID,复制保留图片/图表/备注,最终保留 1–120 页。结构与正文修改可合为一次撤销。
|
|
44
|
+
|
|
45
|
+
## 按需装载索引
|
|
46
|
+
|
|
47
|
+
| 何时读 | 文件 | 内容 |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| 写大纲 / 正文前 | `references/copywriting.md` | 叙事骨架、单页规则、双语规则 |
|
|
50
|
+
| 选主题拿不准 | `references/themes.md` | 5 套主题色板 + 情绪决策树 |
|
|
51
|
+
| 用表格/金句/备注/结构化 slides | `references/syntax.md` | Markdown 解析、进阶语法、slides JSON、motion 开关 |
|
|
52
|
+
| 图片/图表/模板/品牌/编辑/渲染 | `references/advanced.md` | 参数、限制、草稿与成品、收据语义 |
|
|
53
|
+
| 数字溯源与现场推演 | `references/data.md` | 来源绑定、公式、更新预览与离线参数回存 |
|
|
54
|
+
| 交付异常 | `references/troubleshooting.md` | 症状 → 处理对照表 |
|
|
55
|
+
|
|
56
|
+
## 质量门禁(交付前逐项确认)
|
|
57
|
+
|
|
58
|
+
- [ ] 页数 3–60,首屏是封面,末屏是结束页。
|
|
59
|
+
- [ ] 每页有明确标题;bullets 页 1–8 条,中文每条 ≤ 20 字、英文 ≤ 12 词。
|
|
60
|
+
- [ ] HTML 与 PPTX 使用同一主题,配色一致。
|
|
61
|
+
- [ ] 主题色对比度足够(深底浅字或浅底深字)。
|
|
62
|
+
- [ ] 中文内容无错别字;英文标题用 Title Case。
|
|
63
|
+
- [ ] 最后一页有可执行的行动号召,不只是「谢谢」。
|
|
64
|
+
- [ ] 文件已写到用户工作区,路径为绝对路径。
|
|
65
|
+
- [ ] 没有未填模板;保留真实数据来源,检查每页画面而非只检查生成成功。
|
|
66
|
+
- [ ] 图片嵌入成功,图表与原始数据一致;渲染收据匹配最终 PPTX,说明尚未验证的部分。
|
|
67
|
+
|
|
68
|
+
## 跨 harness 安装
|
|
69
|
+
|
|
70
|
+
把整个 `dsh-ppt` 技能目录复制到目标 agent 的技能目录,使用 Node `^22.19.0 || >=24.0.0`,在该目录运行 `npm install --ignore-scripts`。纯文本可直接运行;图片/图表/品牌导出需要 Office Kit,PNG/PDF 需另外安装可选官方引擎:
|
|
71
|
+
|
|
72
|
+
| Agent | 技能目录 |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| DeepSeek Harness | `dsh plugin --profile web add dsh-ppt` |
|
|
75
|
+
| Claude Code | `~/.claude/skills/` |
|
|
76
|
+
| Cursor | `.cursor/skills/` |
|
|
77
|
+
| Gemini CLI | `~/.gemini/skills/` |
|
|
78
|
+
| OpenAI Codex | `~/.codex/skills/` |
|
|
79
|
+
|
|
80
|
+
一次编写,处处可用。
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "dsh-ppt-skill",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"description": "Standalone dsh-ppt skill dependencies for image/chart export",
|
|
7
|
-
"dependencies": { "@office-kit/pptx": "0.21.0" },
|
|
8
|
-
"peerDependencies": { "@deepseek-ai/libreoffice-kit": "0.1.
|
|
9
|
-
"peerDependenciesMeta": { "@deepseek-ai/libreoffice-kit": { "optional": true } },
|
|
10
|
-
"engines": { "node": "^22.19.0 || >=24.0.0" }
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-ppt-skill",
|
|
3
|
+
"version": "0.15.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Standalone dsh-ppt skill dependencies for image/chart export",
|
|
7
|
+
"dependencies": { "@office-kit/pptx": "0.21.0", "csv-parse": "6.1.0", "jsep": "1.4.0" },
|
|
8
|
+
"peerDependencies": { "@deepseek-ai/libreoffice-kit": "0.1.5" },
|
|
9
|
+
"peerDependenciesMeta": { "@deepseek-ai/libreoffice-kit": { "optional": true } },
|
|
10
|
+
"engines": { "node": "^22.19.0 || >=24.0.0" }
|
|
11
|
+
}
|