@slidevideo/cli 0.9.0 → 0.10.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 CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.10.0
6
+
7
+ - Extract per-slide speaker notes in `slidevideo inspect` for both Slidev and PowerPoint decks.
8
+ - Add `slidevideo init --deck <file>` to scaffold a runnable `slidevideo.yaml` directly from a Slidev or PowerPoint deck's slides, speaker notes, and reveal clicks without writing YAML by hand.
9
+
5
10
  ## 0.9.0
6
11
 
7
12
  - Add storyboard-controlled straight `arrow` annotations with normalized or explicitly anchored target endpoints, endpoint padding, solid or dashed strokes, filled or open arrowheads, and optional `fade` or `draw` motion for Slidev and PowerPoint.
package/README.md CHANGED
@@ -18,7 +18,7 @@ slidevideo build --storyboard slidevideo.yaml
18
18
 
19
19
  A completed build writes `final.mp4` (plus `final.vtt` and `final.srt` captions for narrated decks) inside a fresh `runs/<timestamp>` directory (or the path passed to `--run`) at `1920x1080` and `30 fps` by default, and caches generated speech in `.slidevideo/speech` beside the storyboard for reuse across runs (override with `--cache-dir` or disable with `--no-cache`). Pass `--width` and `--height` together and optional `--fps` to select another resolution or frame rate, and `--captions <vtt|srt|both|none>` to control subtitle export. Use `slidevideo setup --license` to activate a key. The installed version checks its bundled revocation list offline. New exports using a revoked key include the watermark.
20
20
 
21
- To draft or edit a storyboard with a coding agent, run `slidevideo skill --install` to link the bundled skill into `~/.agents/skills/slidevideo` and `~/.claude/skills/slidevideo` when Claude Code is detected, or ask the agent to run `slidevideo skill`. For non-interactive setup, run `slidevideo setup --install --json` and see `slidevideo setup --help` and `slidevideo skill --help` for provider and project flags. Use `slidevideo inspect --deck <file> --json` to list slide names, click counts, media IDs, and highlight targets before creating `slidevideo.yaml`. The CLI includes the skill and its storyboard, deck-compatibility, and recording references.
21
+ To draft or edit a storyboard with a coding agent, run `slidevideo skill --install` to link the bundled skill into `~/.agents/skills/slidevideo` and `~/.claude/skills/slidevideo` when Claude Code is detected, or ask the agent to run `slidevideo skill`. To create a starter `slidevideo.yaml` directly from an existing `.md` or `.pptx` deck without a coding agent, run `slidevideo init --deck <file>`. For non-interactive setup, run `slidevideo setup --install --json` and see `slidevideo setup --help`, `slidevideo init --help`, and `slidevideo skill --help` for provider and project flags. Use `slidevideo inspect --deck <file> --json` to list slide names, click counts, speaker notes, media IDs, and highlight targets before creating `slidevideo.yaml`. The CLI includes the skill and its storyboard, deck-compatibility, and recording references.
22
22
 
23
23
  CLI commands check `https://slidevideo.io/release.json` (falling back to npm) in the background at most once every 24 hours and show cached update notices on later interactive calls. Stable installations use `latest`; existing alpha installations use `alpha`. Notices include an exact-version upgrade command. If you installed with `--prefix`, add the same `--prefix` option to that command so npm updates the copy on your `PATH`. Set `SLIDEVIDEO_NO_UPDATE_CHECK=1` or `DO_NOT_TRACK=1` to disable checks and notices. CI, `--version`, `--help`, `setup --manual`, read-only `skill` views, `license`, and `impressum` skip both, and `--json` and `--quiet` suppress notices.
24
24
 
@@ -4,7 +4,7 @@ import { tmpdir } from 'node:os';
4
4
  import { extname, join, resolve } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { nativePreview } from './powerpoint-preview.js';
7
- import { defaultVideoOutput, defaultViewport } from '../contracts.js';
7
+ import { defaultVideoOutput, defaultViewport, normalizeSpeakerNotes } from '../contracts.js';
8
8
  import { geometryRequests } from '../annotation-paint.js';
9
9
  import { planStaticSkips, remapCaptureTimestamps } from './capture-compression.js';
10
10
  import { calibrate, estimateOrigin } from '../calibration.js';
@@ -46,7 +46,7 @@ function slideEntrySettleMs(slide) {
46
46
  function parseDeck(value) {
47
47
  requireCondition(object(value) && value.version === 1 && value.kind === 'inspection' && typeof value.deck_sha256 === 'string' && finite(value.width) && finite(value.height) && value.width > 0 && value.height > 0 && Array.isArray(value.slides) && value.slides.length > 0 && Array.isArray(value.media) && Array.isArray(value.unsupported) && object(value.dependencies), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid catalog', 5);
48
48
  for (const slide of value.slides) {
49
- requireCondition(object(slide) && typeof slide.id === 'string' && ['native_id', 'index', 'transition', 'transition_duration_ms', 'auto_advance', 'hidden', 'interactive'].every(key => finite(slide[key])) && Array.isArray(slide.effects) && Array.isArray(slide.shapes), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid slide', 5);
49
+ requireCondition(object(slide) && typeof slide.id === 'string' && (slide.notes === undefined || typeof slide.notes === 'string') && ['native_id', 'index', 'transition', 'transition_duration_ms', 'auto_advance', 'hidden', 'interactive'].every(key => finite(slide[key])) && Array.isArray(slide.effects) && Array.isArray(slide.shapes), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid slide', 5);
50
50
  for (const shape of slide.shapes) {
51
51
  requireCondition(object(shape), 'POWERPOINT_PROTOCOL', 'Native inspection returned an invalid shape identity', 5);
52
52
  const bounds = shape.bounds;
@@ -354,16 +354,20 @@ export class PowerPointAdapter {
354
354
  const unsupported = deckCapabilityIssues(this.deck);
355
355
  return {
356
356
  dimensions: { width: this.deck.width, height: this.deck.height },
357
- slides: this.deck.slides.map(slide => ({
358
- id: slide.id || `slide-${slide.native_id}`,
359
- ...(slide.id ? { alias: `slide-${slide.native_id}` } : {}),
360
- index: slide.index,
361
- clicks: slide.clicks.length,
362
- clicks_known: true,
363
- ...(slide.transition_duration_ms > 0 ? { transition_duration_ms: slide.transition_duration_ms } : {}),
364
- ...(slide.entry_duration_ms > 0 ? { entry_duration_ms: slide.entry_duration_ms } : {}),
365
- ...(slide.clicks.length ? { click_durations_ms: [...slide.clicks] } : {}),
366
- })),
357
+ slides: this.deck.slides.map(slide => {
358
+ const notes = normalizeSpeakerNotes(slide.notes);
359
+ return {
360
+ id: slide.id || `slide-${slide.native_id}`,
361
+ ...(slide.id ? { alias: `slide-${slide.native_id}` } : {}),
362
+ index: slide.index,
363
+ clicks: slide.clicks.length,
364
+ clicks_known: true,
365
+ ...(slide.transition_duration_ms > 0 ? { transition_duration_ms: slide.transition_duration_ms } : {}),
366
+ ...(slide.entry_duration_ms > 0 ? { entry_duration_ms: slide.entry_duration_ms } : {}),
367
+ ...(slide.clicks.length ? { click_durations_ms: [...slide.clicks] } : {}),
368
+ ...(notes ? { notes } : {}),
369
+ };
370
+ }),
367
371
  media_ids: [...new Set(this.deck.media.map(media => media.id))],
368
372
  ...(this.deck.media.length ? {
369
373
  media: this.deck.media.map(media => {
@@ -1,4 +1,4 @@
1
- import type { PresentationInspection, Storyboard, Schedule, Viewport } from '../contracts.js';
1
+ import { type PresentationInspection, type Storyboard, type Schedule, type Viewport } from '../contracts.js';
2
2
  export declare function inspectSlidev(deck: string): Promise<PresentationInspection>;
3
3
  export declare function validateSlidev(story: Storyboard, inspection: PresentationInspection, options?: {
4
4
  viewport?: Viewport;
@@ -2,6 +2,7 @@ import { access } from 'node:fs/promises';
2
2
  import { fork } from 'node:child_process';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { dirname } from 'node:path';
5
+ import { normalizeSpeakerNotes } from '../contracts.js';
5
6
  import { slidevInputs } from './slidev-inputs.js';
6
7
  import { requireCondition, ProductionError } from '../errors.js';
7
8
  async function loadDeck(deck) {
@@ -36,10 +37,14 @@ export async function inspectSlidev(deck) {
36
37
  }
37
38
  const parsed = await loadDeck(deck);
38
39
  requireCondition(parsed.errors.length === 0, 'DECK_SYNTAX', parsed.errors.join('\n'));
39
- const slides = parsed.slides.map((slide, index) => ({
40
- id: String(slide.frontmatter.name ?? `slide-${index + 1}`), index: index + 1,
41
- clicks: Number(slide.frontmatter.clicks ?? 0), clicks_known: slide.frontmatter.clicks != null,
42
- }));
40
+ const slides = parsed.slides.map((slide, index) => {
41
+ const notes = normalizeSpeakerNotes(slide.note);
42
+ return {
43
+ id: String(slide.frontmatter.name ?? `slide-${index + 1}`), index: index + 1,
44
+ clicks: Number(slide.frontmatter.clicks ?? 0), clicks_known: slide.frontmatter.clicks != null,
45
+ ...(notes ? { notes } : {}),
46
+ };
47
+ });
43
48
  requireCondition(new Set(slides.map(s => s.id)).size === slides.length, 'SLIDE_ID', 'Slide names must be unique');
44
49
  const media_ids = parsed.slides.flatMap(slide => [...slide.content.matchAll(/<(?:video|audio)\b[^>]*\bid=["']([^"']+)["']/g)].map(match => match[1]));
45
50
  return { slides, media_ids, files: await slidevInputs(deck, parsed.headmatter, parsed.files), capabilities: ['slide', 'reveal', 'play', 'highlight:region', 'highlight:element', 'highlight:text', 'underline:region', 'underline:element', 'underline:text', 'spotlight:region', 'spotlight:element', 'spotlight:text', 'zoom:region', 'zoom:element', 'zoom:text', 'laser:path', 'laser:region', 'laser:element', 'laser:text', 'stamp:point', 'stamp:region', 'stamp:element', 'stamp:text', 'arrow:connector', 'arrow:region', 'arrow:element', 'arrow:text'] };
@@ -17,7 +17,7 @@ if (port === 'inspect') {
17
17
  if (!process.send || !process.disconnect)
18
18
  throw new Error('Inspection requires an IPC channel');
19
19
  process.send({
20
- slides: options.data.slides.map(slide => ({ frontmatter: slide.frontmatter, content: slide.content })),
20
+ slides: options.data.slides.map(slide => ({ frontmatter: slide.frontmatter, content: slide.content, note: slide.note })),
21
21
  headmatter: options.data.headmatter,
22
22
  files: Object.keys(options.data.markdownFiles),
23
23
  errors: Object.values(options.data.markdownFiles).flatMap(file => (file.errors ?? []).map(error => `${file.filepath}:${error.row + 1}: ${error.message}`)),
package/dist/cli.js CHANGED
@@ -12,6 +12,7 @@ import { configuredLicense, withExecutables } from './executables.js';
12
12
  import { setup } from './setup.js';
13
13
  import { setupLicense } from './setup-license.js';
14
14
  import { installSkill } from './skill-install.js';
15
+ import { initStoryboard } from './init.js';
15
16
  import { notifyUpdate } from './update-check.js';
16
17
  const commands = ['inspect', 'validate', 'play', 'tts', 'resolve', 'record', 'assemble', 'build'];
17
18
  const documents = new Map([
@@ -60,6 +61,17 @@ skill decks Print the Slidev and PowerPoint deck-compatibility reference
60
61
  current directory (and ./.claude/skills/slidevideo if .claude exists).
61
62
  --json Print document metadata or installation results as JSON.
62
63
  `;
64
+ const initHelp = `slidevideo init --deck <file> [options]
65
+ Create a starter slidevideo.yaml from an existing Slidev or PowerPoint deck.
66
+
67
+ --deck <file> Required .md or .pptx deck to inspect.
68
+ --output <file> Destination storyboard path (default: slidevideo.yaml beside the deck).
69
+ --provider <edge-tts|elevenlabs> Speech provider (default: edge-tts).
70
+ --voice <id> Voice name or ID (default: en-US-AriaNeural for edge-tts).
71
+ --force Overwrite an existing storyboard file.
72
+ --json Print structured result as JSON.
73
+ --quiet Suppress progress on stderr.
74
+ `;
63
75
  function setupChecklist(report, licensed) {
64
76
  const labels = {
65
77
  ffmpeg: 'FFmpeg', ffprobe: 'ffprobe', browser: 'Chromium', python: 'Python environment',
@@ -99,7 +111,7 @@ try {
99
111
  const { values, positionals } = parseArgs({ options: {
100
112
  storyboard: { type: 'string' }, deck: { type: 'string' }, width: { type: 'string' }, height: { type: 'string' }, fps: { type: 'string' }, port: { type: 'string' }, run: { type: 'string' }, 'cache-dir': { type: 'string' }, output: { type: 'string' }, captions: { type: 'string' }, export: { type: 'string' }, 'timeout-minutes': { type: 'string' },
101
113
  browser: { type: 'string' }, python: { type: 'string' }, ffmpeg: { type: 'string' }, ffprobe: { type: 'string' },
102
- presentation: { type: 'string' }, provider: { type: 'string' }, 'voice-id': { type: 'string' }, install: { type: 'boolean' }, project: { type: 'boolean' }, manual: { type: 'boolean' },
114
+ presentation: { type: 'string' }, provider: { type: 'string' }, 'voice-id': { type: 'string' }, voice: { type: 'string' }, force: { type: 'boolean' }, install: { type: 'boolean' }, project: { type: 'boolean' }, manual: { type: 'boolean' },
103
115
  license: { type: 'boolean' },
104
116
  json: { type: 'boolean' }, quiet: { type: 'boolean' }, resume: { type: 'boolean' }, 'no-cache': { type: 'boolean' }, 'verify-timing': { type: 'boolean' }, help: { type: 'boolean', short: 'h' }, version: { type: 'boolean' },
105
117
  }, allowPositionals: true });
@@ -116,17 +128,17 @@ try {
116
128
  console.log(values.json ? JSON.stringify({ version: 1, package_version: version }) : version);
117
129
  }
118
130
  else if (values.help || command === 'help') {
119
- const help = command === 'setup' ? setupHelp : command === 'skill' ? skillHelp : `slidevideo <setup|inspect|validate|play|tts|resolve|record|assemble|build|skill|license|impressum>
131
+ const help = command === 'setup' ? setupHelp : command === 'skill' ? skillHelp : command === 'init' ? initHelp : `slidevideo <setup|init|inspect|validate|play|tts|resolve|record|assemble|build|skill|license|impressum>
120
132
 
121
- --storyboard <file> Required for presentation commands except assemble; inspect also accepts --deck.
122
- --deck <file> Inspect a .md or .pptx deck directly before a storyboard exists.
133
+ --storyboard <file> Required for presentation commands except assemble; inspect and init accept --deck.
134
+ --deck <file> Deck file (.md or .pptx) for inspect or init before a storyboard exists.
123
135
  --width/--height <px> Even viewport or output size (default: 1920x1080; PPTX inspect --deck uses slide size).
124
136
  --fps <15|24|30|60> Output frame rate for record, assemble, or build (default: 30).
125
137
  --run <directory> Run directory (default: runs/YYYYMMDD-HHmmss for build and tts; required for resolve, record, assemble, and build --resume).
126
138
  --cache-dir <dir> Speech cache directory for play, tts, or build (default: .slidevideo/speech beside storyboard).
127
139
  --no-cache Disable speech cache reading and writing for play, tts, or build.
128
140
  --port <number> Local play server port (default: auto).
129
- --output <file> New final MP4 destination for assemble or build.
141
+ --output <file> Output path: new final MP4 for assemble/build, or storyboard path for init.
130
142
  --captions <vtt|srt|both|none> Caption export (default: both for build/assemble with narration; optional for resolve).
131
143
  --resume Reuse intact build stages with matching inputs and mode.
132
144
  --verify-timing Opt in to decoded timing proof for build or record; assemble checks the recorded mode.
@@ -138,8 +150,9 @@ try {
138
150
  --version Package version.
139
151
 
140
152
  setup prepares shared tools and speech providers, and detects Slidev and native PowerPoint support (see setup --help).
153
+ init --deck <file> creates a starter slidevideo.yaml from slide structure and speaker notes (see init --help).
141
154
  Normal production leaves timing unevaluated and the video for user review.
142
- inspect lists slide targets, click counts, media IDs and annotation targets from --deck or --storyboard without recording.
155
+ inspect lists slide targets, click counts, speaker notes, media IDs and annotation targets from --deck or --storyboard without recording.
143
156
  validate checks inputs without recording.
144
157
  play --storyboard <file> serves slides and annotations (with cached audio when available) with Play, Pause and Replay. Ctrl+C stops the server.
145
158
  skill displays or registers (--install) the bundled coding-agent skill; see skill --help for references and options.
@@ -169,12 +182,32 @@ impressum displays the provider's contact details.
169
182
  const result = { version: 1, command, document, path: command === 'skill' ? path : undefined };
170
183
  process.stdout.write(values.json ? JSON.stringify(result) + '\n' : document);
171
184
  }
185
+ else if (command === 'init') {
186
+ requireCondition(positionals.length === 1 && Object.keys(values).every(key => ['deck', 'output', 'provider', 'voice', 'force', 'json', 'quiet', 'browser', 'python', 'ffmpeg', 'ffprobe'].includes(key)), 'OPTION', 'Run slidevideo init --help for init options');
187
+ requireCondition(values.deck !== undefined && values.deck.trim().length > 0, 'OPTION', 'init requires --deck <file>');
188
+ requireCondition(values.output === undefined || values.output.trim().length > 0, 'OPTION', '--output requires a file path');
189
+ const result = await withExecutables(values, () => initStoryboard({
190
+ deck: values.deck,
191
+ output: values.output,
192
+ provider: values.provider,
193
+ voice: values.voice,
194
+ force: values.force,
195
+ }));
196
+ if (values.json)
197
+ console.log(JSON.stringify(result));
198
+ else {
199
+ console.log(`Created ${result.output} (${result.slides} slide${result.slides === 1 ? '' : 's'}, ${result.narrated_slides} narrated).`);
200
+ for (const warning of result.warnings)
201
+ console.log(`Warning: ${warning}`);
202
+ console.log(`Next steps:\n slidevideo play --storyboard ${result.output}\n slidevideo build --storyboard ${result.output}`);
203
+ }
204
+ }
172
205
  else if (command === 'setup' && values.license) {
173
206
  requireCondition(positionals.length === 1 && Object.keys(values).every(key => key === 'license'), 'OPTION', 'Use slidevideo setup --license by itself in a terminal.');
174
207
  await withExecutables({}, setupLicense);
175
208
  }
176
209
  else if (command === 'setup') {
177
- requireCondition(positionals.length === 1 && !['storyboard', 'deck', 'width', 'height', 'fps', 'port', 'run', 'cache-dir', 'no-cache', 'output', 'captions', 'export', 'timeout-minutes', 'resume', 'verify-timing', 'project'].some(key => key in values), 'OPTION', 'Run slidevideo setup --help for setup options');
210
+ requireCondition(positionals.length === 1 && !['storyboard', 'deck', 'width', 'height', 'fps', 'port', 'run', 'cache-dir', 'no-cache', 'output', 'captions', 'export', 'timeout-minutes', 'resume', 'verify-timing', 'project', 'voice', 'force'].some(key => key in values), 'OPTION', 'Run slidevideo setup --help for setup options');
178
211
  let initialChecklist;
179
212
  const report = await withExecutables(values, () => setup(values, current => {
180
213
  initialChecklist = setupChecklist(current, configuredLicense());
@@ -227,7 +260,7 @@ impressum displays the provider's contact details.
227
260
  else {
228
261
  requireCondition(commands.includes(command) && positionals.length === 1, 'COMMAND', 'Run slidevideo --help for available commands');
229
262
  requireCondition(!values.project, 'OPTION', '--project requires slidevideo skill --install');
230
- requireCondition(!['presentation', 'provider', 'voice-id', 'install', 'manual', 'license'].some(key => key in values), 'OPTION', 'Presentation, provider, voice ID, install and license options require setup');
263
+ requireCondition(!['presentation', 'provider', 'voice-id', 'voice', 'force', 'install', 'manual', 'license'].some(key => key in values), 'OPTION', 'Presentation, provider, voice, force, install and license options require setup or init');
231
264
  let timeout;
232
265
  if (values['timeout-minutes'] !== undefined) {
233
266
  const raw = values['timeout-minutes'].trim();
@@ -649,6 +649,7 @@ export interface TtsAdapter {
649
649
  validate(voice: Voice): void;
650
650
  synthesize(segment: Narration, voice: Voice, destination: string): Promise<Omit<SpeechAsset, 'key'>>;
651
651
  }
652
+ export declare function normalizeSpeakerNotes(raw: string | null | undefined): string | undefined;
652
653
  export type PresentationInspection = {
653
654
  dimensions?: Viewport;
654
655
  slides: {
@@ -660,6 +661,7 @@ export type PresentationInspection = {
660
661
  transition_duration_ms?: number;
661
662
  entry_duration_ms?: number;
662
663
  click_durations_ms?: number[];
664
+ notes?: string;
663
665
  }[];
664
666
  media_ids: string[];
665
667
  media?: {
package/dist/contracts.js CHANGED
@@ -1,2 +1,8 @@
1
1
  export const defaultViewport = { width: 1920, height: 1080 };
2
2
  export const defaultVideoOutput = { width: 1920, height: 1080, fps: 30 };
3
+ export function normalizeSpeakerNotes(raw) {
4
+ if (typeof raw !== 'string')
5
+ return undefined;
6
+ const normalized = raw.replace(/\r\n?/g, '\n').trim();
7
+ return normalized.length > 0 ? normalized : undefined;
8
+ }
package/dist/init.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { type Voice } from './contracts.js';
2
+ export type InitOptions = {
3
+ deck: string;
4
+ output?: string;
5
+ provider?: string;
6
+ voice?: string;
7
+ force?: boolean;
8
+ };
9
+ export type InitResult = {
10
+ version: 1;
11
+ command: 'init';
12
+ status: 'completed';
13
+ deck: string;
14
+ output: string;
15
+ slides: number;
16
+ narrated_slides: number;
17
+ voice: Voice;
18
+ warnings: string[];
19
+ };
20
+ export declare function initStoryboard(options: InitOptions): Promise<InitResult>;
package/dist/init.js ADDED
@@ -0,0 +1,223 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { mkdir, writeFile } from 'node:fs/promises';
3
+ import { dirname, extname, isAbsolute, join, relative, resolve } from 'node:path';
4
+ import { parse, stringify } from 'yaml';
5
+ import { presentationAdapter, ttsAdapters } from './adapters/registry.js';
6
+ import { defaultViewport } from './contracts.js';
7
+ import { requireCondition } from './errors.js';
8
+ import { validateStoryboard } from './storyboard.js';
9
+ const defaultProvider = 'edge-tts';
10
+ const defaultEdgeVoice = 'en-US-AriaNeural';
11
+ const silentHoldMs = 3000;
12
+ const trailingHoldMs = 500;
13
+ const clickHoldMs = 1500;
14
+ const defaultRevealMs = 400;
15
+ const clickMarkerPattern = /\[click\]/i;
16
+ function sanitizeId(raw, fallback) {
17
+ const cleaned = raw
18
+ .trim()
19
+ .replace(/[^a-zA-Z0-9_-]+/g, '-')
20
+ .replace(/-+/g, '-')
21
+ .replace(/^-+|-+$/g, '');
22
+ if (!cleaned)
23
+ return fallback;
24
+ return /^[a-zA-Z]/.test(cleaned) ? cleaned : `s-${cleaned}`;
25
+ }
26
+ function relativeDeckPath(outputFile, deckFile) {
27
+ const raw = relative(dirname(outputFile), deckFile);
28
+ if (!raw)
29
+ return './';
30
+ const normalized = raw.replaceAll('\\', '/');
31
+ if (isAbsolute(raw) || /^[a-zA-Z]:\//.test(normalized) || normalized.startsWith('//')) {
32
+ return normalized;
33
+ }
34
+ return normalized.startsWith('.') ? normalized : `./${normalized}`;
35
+ }
36
+ function resolveInitVoice(providerInput, voiceInput) {
37
+ const provider = providerInput?.trim() || defaultProvider;
38
+ const tts = ttsAdapters.get(provider);
39
+ requireCondition(tts, 'TTS_ADAPTER', `Unsupported TTS provider ${provider}`, 3);
40
+ const voiceId = voiceInput?.trim() || (provider === defaultProvider ? defaultEdgeVoice : '');
41
+ requireCondition(voiceId.length > 0, 'OPTION', `Pass --voice <id> when using --provider ${provider}`);
42
+ const voice = { provider, voice: voiceId };
43
+ tts.validate(voice);
44
+ return voice;
45
+ }
46
+ function buildStoryboardFromInspection(inspection, deckRef, voice) {
47
+ const usedIds = new Set();
48
+ const allocateId = (base, fallback = 'item') => {
49
+ const stem = sanitizeId(base, fallback);
50
+ if (!usedIds.has(stem)) {
51
+ usedIds.add(stem);
52
+ return stem;
53
+ }
54
+ let suffix = 2;
55
+ while (usedIds.has(`${stem}-${suffix}`))
56
+ suffix++;
57
+ const candidate = `${stem}-${suffix}`;
58
+ usedIds.add(candidate);
59
+ return candidate;
60
+ };
61
+ const narration = [];
62
+ const scenes = [];
63
+ const unusedClickMarkerSlides = [];
64
+ let narratedSlides = 0;
65
+ for (const slide of inspection.slides) {
66
+ const base = sanitizeId(slide.id, `slide-${slide.index}`);
67
+ const sceneId = allocateId(base, `slide-${slide.index}`);
68
+ const actions = [];
69
+ const revealDuration = (click) => Math.max(0, Math.round(slide.click_durations_ms?.[click - 1] ?? defaultRevealMs));
70
+ const notes = slide.notes;
71
+ let slideHasNarration = false;
72
+ const addSpeech = (stem, text) => {
73
+ const segmentId = allocateId(`narration-${stem}`, `narration-${slide.index}`);
74
+ narration.push({ id: segmentId, text });
75
+ actions.push({ id: allocateId(`say-${stem}`, `say-${slide.index}`), type: 'speak', segment: segmentId });
76
+ slideHasNarration = true;
77
+ };
78
+ const addHold = (stem, durationMs) => {
79
+ actions.push({ id: allocateId(`hold-${stem}`, `hold-${slide.index}`), type: 'hold', duration_ms: durationMs });
80
+ };
81
+ const addReveal = (click) => {
82
+ actions.push({
83
+ id: allocateId(`reveal-${base}-${click}`, `reveal-${slide.index}-${click}`),
84
+ type: 'reveal',
85
+ click,
86
+ duration_ms: revealDuration(click),
87
+ });
88
+ };
89
+ if (slide.clicks > 0 && notes && clickMarkerPattern.test(notes)) {
90
+ const rawChunks = notes.split(clickMarkerPattern).map(part => part.trim());
91
+ const chunks = rawChunks.slice(0, slide.clicks + 1);
92
+ if (rawChunks.length > slide.clicks + 1) {
93
+ const overflow = rawChunks.slice(slide.clicks + 1).filter(Boolean);
94
+ if (overflow.length) {
95
+ chunks[slide.clicks] = [chunks[slide.clicks], ...overflow].filter(Boolean).join('\n\n');
96
+ }
97
+ }
98
+ for (let click = 0; click <= slide.clicks; click++) {
99
+ if (click > 0)
100
+ addReveal(click);
101
+ const chunk = chunks[click];
102
+ if (chunk)
103
+ addSpeech(click === 0 ? base : `${base}-${click}`, chunk);
104
+ else if (click > 0)
105
+ addHold(`${base}-${click}`, clickHoldMs);
106
+ }
107
+ if (actions.at(-1)?.type === 'speak')
108
+ addHold(`${base}-end`, trailingHoldMs);
109
+ }
110
+ else if (slide.clicks > 0 && notes) {
111
+ addSpeech(base, notes);
112
+ for (let click = 1; click <= slide.clicks; click++) {
113
+ addReveal(click);
114
+ addHold(`${base}-${click}`, clickHoldMs);
115
+ }
116
+ }
117
+ else if (slide.clicks > 0) {
118
+ addHold(`${base}-intro`, clickHoldMs);
119
+ for (let click = 1; click <= slide.clicks; click++) {
120
+ addReveal(click);
121
+ addHold(`${base}-${click}`, clickHoldMs);
122
+ }
123
+ }
124
+ else if (notes) {
125
+ const cleaned = clickMarkerPattern.test(notes)
126
+ ? notes.split(clickMarkerPattern).map(part => part.trim()).filter(Boolean).join('\n\n')
127
+ : notes;
128
+ if (clickMarkerPattern.test(notes))
129
+ unusedClickMarkerSlides.push(slide.id);
130
+ if (cleaned) {
131
+ addSpeech(base, cleaned);
132
+ addHold(`${base}-end`, trailingHoldMs);
133
+ }
134
+ else {
135
+ addHold(base, silentHoldMs);
136
+ }
137
+ }
138
+ else {
139
+ addHold(base, silentHoldMs);
140
+ }
141
+ if (slideHasNarration)
142
+ narratedSlides++;
143
+ scenes.push({ id: sceneId, slide: slide.id, actions });
144
+ }
145
+ return {
146
+ storyboard: {
147
+ version: 1,
148
+ deck: deckRef,
149
+ voice,
150
+ media: [],
151
+ narration,
152
+ scenes,
153
+ cues: [],
154
+ annotations: [],
155
+ },
156
+ narratedSlides,
157
+ unusedClickMarkerSlides,
158
+ };
159
+ }
160
+ export async function initStoryboard(options) {
161
+ const deck = resolve(options.deck);
162
+ const output = resolve(options.output ?? join(dirname(deck), 'slidevideo.yaml'));
163
+ requireCondition(/^\.ya?ml$/i.test(extname(output)), 'OPTION', '--output for init must end with .yaml or .yml');
164
+ requireCondition(Boolean(options.force) || !existsSync(output), 'OUTPUT_EXISTS', `Storyboard already exists at ${output}. Pass --force to overwrite or --output <file> to write elsewhere.`);
165
+ const voice = resolveInitVoice(options.provider, options.voice);
166
+ const adapter = presentationAdapter(deck);
167
+ let inspection;
168
+ try {
169
+ inspection = await adapter.inspect(deck);
170
+ if (inspection.slides.some(slide => slide.clicks_known === false) && adapter.inspectTargets) {
171
+ const targets = await adapter.inspectTargets(deck, inspection.dimensions ?? defaultViewport);
172
+ const clicksBySlide = new Map((targets ?? []).map(entry => [entry.slide, entry.clicks]));
173
+ inspection = {
174
+ ...inspection,
175
+ slides: inspection.slides.map(slide => {
176
+ if (slide.clicks_known !== false)
177
+ return slide;
178
+ const mountedClicks = clicksBySlide.get(slide.id);
179
+ return typeof mountedClicks === 'number' && Number.isInteger(mountedClicks) && mountedClicks >= 0
180
+ ? { ...slide, clicks: mountedClicks, clicks_known: true }
181
+ : slide;
182
+ }),
183
+ };
184
+ }
185
+ }
186
+ finally {
187
+ await adapter.cleanup();
188
+ }
189
+ const deckRef = relativeDeckPath(output, deck);
190
+ const { storyboard, narratedSlides, unusedClickMarkerSlides } = buildStoryboardFromInspection(inspection, deckRef, voice);
191
+ const yamlText = stringify(storyboard, { lineWidth: 100 });
192
+ const validated = validateStoryboard(parse(yamlText), output);
193
+ await adapter.validate(validated, inspection);
194
+ await mkdir(dirname(output), { recursive: true });
195
+ await writeFile(output, yamlText, 'utf8');
196
+ const warnings = [];
197
+ if (narratedSlides === 0) {
198
+ warnings.push('No speaker notes were found in this deck. Generated slides use silent holds until you add speaker notes or edit narration in slidevideo.yaml.');
199
+ }
200
+ if (unusedClickMarkerSlides.length > 0) {
201
+ warnings.push(`Removed [click] markers from speaker notes on slides without reveal clicks (${unusedClickMarkerSlides.join(', ')}).`);
202
+ }
203
+ if (inspection.slides.some(slide => slide.clicks_known === false)) {
204
+ warnings.push('Slides without explicit click bounds require runtime reveal checks before recording.');
205
+ }
206
+ if ((inspection.unsupported?.length ?? 0) > 0) {
207
+ warnings.push('Deck contains unsupported native features. Adjust the deck before production.');
208
+ }
209
+ if (inspection.media_ids.length > 0) {
210
+ warnings.push(`Deck contains media elements (${inspection.media_ids.join(', ')}). Add media entries and play actions in slidevideo.yaml if you want to play them.`);
211
+ }
212
+ return {
213
+ version: 1,
214
+ command: 'init',
215
+ status: 'completed',
216
+ deck,
217
+ output,
218
+ slides: inspection.slides.length,
219
+ narrated_slides: narratedSlides,
220
+ voice,
221
+ warnings,
222
+ };
223
+ }
@@ -65,6 +65,7 @@ export declare function produce(options: Options): Promise<{
65
65
  transition_duration_ms?: number;
66
66
  entry_duration_ms?: number;
67
67
  click_durations_ms?: number[];
68
+ notes?: string;
68
69
  }[];
69
70
  media_ids: string[];
70
71
  media?: {
@@ -1,5 +1,6 @@
1
1
  import type { Storyboard } from './contracts.js';
2
2
  export declare function loadStoryboard(file: string): Promise<Storyboard>;
3
+ export declare function validateStoryboard(data: unknown, file: string): Storyboard;
3
4
  export declare function fingerprint(storyboard: string, files: string[]): Promise<{
4
5
  inputs: Record<string, string>;
5
6
  input_hash: string;
@@ -15,6 +15,9 @@ export async function loadStoryboard(file) {
15
15
  catch (error) {
16
16
  throw new ProductionError('STORYBOARD', `Cannot read storyboard: ${String(error)}`);
17
17
  }
18
+ return validateStoryboard(data, file);
19
+ }
20
+ export function validateStoryboard(data, file) {
18
21
  requireCondition(validate(data), 'SCHEMA', JSON.stringify(validate.errors));
19
22
  data.deck = resolve(dirname(file), data.deck);
20
23
  data.media = data.media.map(media => ({ ...media, src: resolve(dirname(file), media.src) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slidevideo/cli",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Turn a slide deck into a narrated video.",
5
5
  "license": "SEE LICENSE IN LICENSE-TERMS.md",
6
6
  "type": "module",
@@ -80,6 +80,8 @@
80
80
  "dist/errors.js",
81
81
  "dist/executables.d.ts",
82
82
  "dist/executables.js",
83
+ "dist/init.d.ts",
84
+ "dist/init.js",
83
85
  "dist/installation.d.ts",
84
86
  "dist/installation.js",
85
87
  "dist/license-key.d.ts",
@@ -19,7 +19,7 @@ Run `slidevideo skill production` for the [production workflow](references/produ
19
19
 
20
20
  Read the supplied deck, existing storyboard, brief and supporting material. Identify the intended audience, narration language, tone, length and voice from the request. Ask only for missing information that affects a useful draft. Keep reasonable draft assumptions visible for review.
21
21
 
22
- Inspect actual slide targets, reveal steps, effect durations, and embedded-media names with `slidevideo inspect --deck <file> --json` before a storyboard exists, or `slidevideo inspect --storyboard <file> --json` when revising one. For Slidev, account for imports and the effective slide order. For PowerPoint, use native slide names or actual SlideID aliases, native click-group durations, and video `Shape.Name` values. Do not invent targets or claim unknown animation bounds are verified.
22
+ Inspect actual slide targets, reveal steps, speaker notes (`slides[].notes`), effect durations, and embedded-media names with `slidevideo inspect --deck <file> --json` before a storyboard exists, or `slidevideo inspect --storyboard <file> --json` when revising one. For Slidev, account for imports and the effective slide order. For PowerPoint, use native slide names or actual SlideID aliases, native click-group durations, speaker notes, and video `Shape.Name` values. Do not invent targets or claim unknown animation bounds are verified.
23
23
 
24
24
  Preserve an existing supplied `.md` or `.pptx` deck by default so storyboard work never rewrites the creator's slides unprompted. Create or edit slides when the creator asks to build a deck from notes, screenshots, or clips, requests slide changes, or approves adding stable `name` fields or element `id` attributes needed by requested storyboard actions or `annotations`. Follow the [deck compatibility reference](references/decks.md) when creating or editing slides, and never overwrite a supplied deck with an unrelated example script.
25
25
 
@@ -12,7 +12,7 @@ Keep the existing presentation as input. The production CLI does not require an
12
12
 
13
13
  ## Choose the operation
14
14
 
15
- Before drafting a storyboard for an existing presentation, run `slidevideo inspect --deck <file> --json` to list slide targets, click counts, media IDs, and highlight targets without generating speech or recording. For an authoring or explanation request, return the draft, revision, or answer without starting production. When validation is requested, use `validate`; it checks syntax, references, and capabilities without requesting speech or recording. Pending phrase alignment is checked later, during resolution.
15
+ Before drafting a storyboard for an existing presentation, run `slidevideo inspect --deck <file> --json` to list slide targets, click counts, speaker notes (`slides[].notes`), media IDs, and highlight targets without generating speech or recording. You can also run `slidevideo init --deck <file>` to scaffold a starter `slidevideo.yaml` directly from slide structure, speaker notes, and reveal clicks. For an authoring or explanation request, return the draft, revision, or answer without starting production. When validation is requested, use `validate`; it checks syntax, references, and capabilities without requesting speech or recording. Pending phrase alignment is checked later, during resolution.
16
16
 
17
17
  For a visual pacing review, use `play --storyboard <file>` and open the printed URL. Pass `--width` and `--height` together as even integers from `640` to `3840` wide and `360` to `2160` high to test a non-default viewport; the default is `1920` by `1080`. `play` automatically reads retained speech timing and synchronized cached narration audio (with a Mute/Unmute toggle) from `.slidevideo/speech` beside the storyboard; pass `--cache-dir <directory>` to override the cache path or `--no-cache` to ignore cached speech. Uncached segments estimate duration and stay silent while embedded media stays muted. Phrase cues and `follow` annotations require matching alignment. Keep the CLI running while the creator uses the browser controls, timeline scrubber, and scene selector. Stop and relaunch it after storyboard edits.
18
18
 
@@ -150,11 +150,41 @@ function Part-Hash($zip, [string]$name) {
150
150
  try { return [BitConverter]::ToString($sha.ComputeHash($stream)).Replace('-', '').ToLowerInvariant() }
151
151
  finally { $sha.Dispose(); $stream.Dispose() }
152
152
  }
153
+ function Read-SlideNotes($zip, [string]$slidePart, $slideRelations) {
154
+ $notesRelation = $null
155
+ foreach ($relationship in $slideRelations.Values) {
156
+ if ($relationship.GetAttribute('TargetMode') -ne 'External' -and $relationship.GetAttribute('Type').EndsWith('/notesSlide')) {
157
+ $notesRelation = $relationship
158
+ break
159
+ }
160
+ }
161
+ if ($null -eq $notesRelation) { return $null }
162
+ $notesPart = Part-Name $slidePart $notesRelation.GetAttribute('Target')
163
+ if ($null -eq $zip.GetEntry($notesPart)) { return $null }
164
+ $notesXml = Read-Part $zip $notesPart
165
+ $paragraphs = [Collections.Generic.List[string]]::new()
166
+ foreach ($shape in $notesXml.SelectNodes('//*[local-name()="sp"]')) {
167
+ $placeholder = $shape.SelectSingleNode('./*[local-name()="nvSpPr"]/*[local-name()="nvPr"]/*[local-name()="ph"][@type="body"]')
168
+ if ($null -eq $placeholder) { continue }
169
+ foreach ($paragraph in $shape.SelectNodes('./*[local-name()="txBody"]/*[local-name()="p"]')) {
170
+ $line = [Text.StringBuilder]::new()
171
+ foreach ($node in $paragraph.SelectNodes('.//*[local-name()="t" or local-name()="br"]')) {
172
+ if ($node.LocalName -eq 'br') { [void]$line.Append("`n") }
173
+ else { [void]$line.Append($node.InnerText) }
174
+ }
175
+ $paragraphs.Add($line.ToString())
176
+ }
177
+ }
178
+ $text = ([string]::Join("`n", $paragraphs.ToArray()) -replace "`r`n?", "`n").Trim()
179
+ if ($text.Length -eq 0) { return $null }
180
+ return $text
181
+ }
153
182
  function Read-Package([string]$file) {
154
183
  $zip = [IO.Compression.ZipFile]::OpenRead($file)
155
184
  $media = [Collections.Generic.List[object]]::new()
156
185
  $unsupported = [Collections.Generic.List[object]]::new()
157
186
  $targets = [Collections.Generic.List[object]]::new()
187
+ $notes = @{}
158
188
  try {
159
189
  foreach ($entry in $zip.Entries) {
160
190
  if ($entry.FullName.EndsWith('.rels')) {
@@ -216,6 +246,8 @@ function Read-Package([string]$file) {
216
246
  $slideRels = Read-Part $zip $relationPart
217
247
  foreach ($relationship in $slideRels.DocumentElement.ChildNodes) { $slideRelations[$relationship.GetAttribute('Id')] = $relationship }
218
248
  }
249
+ $slideNotes = Read-SlideNotes $zip $part $slideRelations
250
+ if ($null -ne $slideNotes) { $notes[$nativeId] = $slideNotes }
219
251
  foreach ($picture in $slideXml.SelectNodes('//*[local-name()="pic"]')) {
220
252
  $video = $picture.SelectSingleNode('.//*[local-name()="videoFile"]')
221
253
  $audio = $picture.SelectSingleNode('.//*[local-name()="audioFile"]')
@@ -259,7 +291,7 @@ function Read-Package([string]$file) {
259
291
  if (($node.HasAttribute('repeatCount') -and $node.GetAttribute('repeatCount') -eq 'indefinite') -or ($node.HasAttribute('repeatDur') -and $node.GetAttribute('repeatDur') -eq 'indefinite')) { $unsupported.Add(@{ slide = [string]$nativeId; reason = 'Unbounded native animation repeats are unsupported.' }) }
260
292
  }
261
293
  }
262
- return @{ media = @($media.ToArray()); unsupported = @($unsupported.ToArray()); targets = @($targets.ToArray()) }
294
+ return @{ media = @($media.ToArray()); unsupported = @($unsupported.ToArray()); targets = @($targets.ToArray()); notes = $notes }
263
295
  } finally { $zip.Dispose() }
264
296
  }
265
297
  function Open-PrivateDeck([bool]$visible) {
@@ -408,7 +440,9 @@ function Inspect-Native($package) {
408
440
  $shapes = @(Inspect-Shapes $slideId $slideWidth $slideHeight $slide.Shapes $targetsByKey $effectsByShape $false)
409
441
  $transitionEffect = [int]$slide.SlideShowTransition.EntryEffect
410
442
  $transitionDurationMs = $(if ($transitionEffect -ne 0) { [Math]::Round([double]$slide.SlideShowTransition.Duration * 1000) } else { 0 })
411
- $slides.Add(@{ id = $slideName; native_id = $slideId; index = [int]$slide.SlideIndex; effects = @($effects.ToArray()); shapes = $shapes; transition = $transitionEffect; transition_duration_ms = $transitionDurationMs; auto_advance = [int]$slide.SlideShowTransition.AdvanceOnTime; hidden = [int]$slide.SlideShowTransition.Hidden; interactive = [int]$slide.TimeLine.InteractiveSequences.Count })
443
+ $slideEntry = @{ id = $slideName; native_id = $slideId; index = [int]$slide.SlideIndex; effects = @($effects.ToArray()); shapes = $shapes; transition = $transitionEffect; transition_duration_ms = $transitionDurationMs; auto_advance = [int]$slide.SlideShowTransition.AdvanceOnTime; hidden = [int]$slide.SlideShowTransition.Hidden; interactive = [int]$slide.TimeLine.InteractiveSequences.Count }
444
+ if ($package.notes.ContainsKey($slideId)) { $slideEntry.notes = $package.notes[$slideId] }
445
+ $slides.Add($slideEntry)
412
446
  foreach ($shape in $slide.Shapes) {
413
447
  if ([int]$shape.Type -eq 16) {
414
448
  $videoShapeId = [int]$shape.Id