@slidevideo/cli 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +2 -2
  3. package/addons/slidevideo/geometry.ts +63 -30
  4. package/addons/slidevideo/global-top.vue +41 -9
  5. package/addons/slidevideo/playback-entries.ts +16 -5
  6. package/addons/slidevideo/preview.ts +26 -14
  7. package/dist/adapters/powerpoint.d.ts +7 -4
  8. package/dist/adapters/powerpoint.js +146 -40
  9. package/dist/adapters/slidev-inspection.d.ts +5 -2
  10. package/dist/adapters/slidev-inspection.js +3 -2
  11. package/dist/adapters/slidev.d.ts +3 -4
  12. package/dist/adapters/slidev.js +20 -19
  13. package/dist/annotation-paint.d.ts +65 -11
  14. package/dist/annotation-paint.js +290 -10
  15. package/dist/annotations.d.ts +13 -8
  16. package/dist/annotations.js +619 -88
  17. package/dist/assembly.d.ts +4 -2
  18. package/dist/assembly.js +23 -18
  19. package/dist/cli.js +102 -16
  20. package/dist/compositor.d.ts +10 -5
  21. package/dist/compositor.js +215 -128
  22. package/dist/contracts.d.ts +93 -30
  23. package/dist/contracts.js +2 -1
  24. package/dist/media.d.ts +5 -0
  25. package/dist/media.js +30 -0
  26. package/dist/pipeline.d.ts +37 -9
  27. package/dist/pipeline.js +62 -10
  28. package/dist/preview/contracts.d.ts +3 -3
  29. package/dist/preview/player.js +20 -15
  30. package/dist/preview/server.d.ts +2 -1
  31. package/dist/preview/server.js +6 -5
  32. package/dist/setup.d.ts +3 -0
  33. package/dist/setup.js +16 -1
  34. package/dist/skill-install.d.ts +35 -0
  35. package/dist/skill-install.js +132 -0
  36. package/dist/storyboard.js +9 -0
  37. package/package.json +4 -1
  38. package/schemas/annotation-geometry.v1.json +260 -28
  39. package/schemas/run-manifest.v1.json +31 -0
  40. package/schemas/schedule.v1.json +448 -182
  41. package/schemas/storyboard.v1.json +358 -174
  42. package/skills/slidevideo/SKILL.md +11 -9
  43. package/skills/slidevideo/references/decks.md +228 -0
  44. package/skills/slidevideo/references/production.md +14 -10
  45. package/skills/slidevideo/references/storyboard.md +69 -37
  46. package/tools/powerpoint/Native.cs +85 -1
  47. package/tools/powerpoint/powerpoint.ps1 +188 -101
  48. package/tools/powerpoint/preview.ps1 +10 -9
package/dist/media.js CHANGED
@@ -62,6 +62,36 @@ export async function probe(path) {
62
62
  return { width: video?.width ?? 0, height: video?.height ?? 0, fps: d ? n / d : 0, duration_ms: Number(data.format.duration) * 1000, has_audio: data.streams.some((s) => s.codec_type === 'audio') };
63
63
  }
64
64
  export async function decode(path) { await execute('ffmpeg', ['-v', 'error', '-xerror', '-i', path, '-f', 'null', '-']); }
65
+ export function balancedSum(terms) {
66
+ if (terms.length === 0)
67
+ return '0';
68
+ let level = [...terms];
69
+ while (level.length > 1) {
70
+ const next = [];
71
+ for (let index = 0; index < level.length; index += 2) {
72
+ next.push(index + 1 < level.length ? `(${level[index]}+${level[index + 1]})` : level[index]);
73
+ }
74
+ level = next;
75
+ }
76
+ return level[0];
77
+ }
78
+ const filterScriptFlags = new Map();
79
+ export function ffmpegFilterScriptFlags(ffmpegPath = executable('ffmpeg')) {
80
+ let cached = filterScriptFlags.get(ffmpegPath);
81
+ if (!cached) {
82
+ cached = execute(ffmpegPath, ['-version'], 10000).then(output => {
83
+ const major = Number(output.toString().match(/^\s*libavfilter\s+(\d+)\./m)?.[1] ?? 0);
84
+ return major >= 10
85
+ ? { complex: '-/filter_complex', video: '-/vf' }
86
+ : { complex: '-filter_complex_script', video: '-filter_script:v' };
87
+ }).catch(error => {
88
+ filterScriptFlags.delete(ffmpegPath);
89
+ throw error;
90
+ });
91
+ filterScriptFlags.set(ffmpegPath, cached);
92
+ }
93
+ return cached;
94
+ }
65
95
  export async function audioDuration(path) { const pcm = await execute('ffmpeg', ['-v', 'error', '-i', path, '-vn', '-ac', '1', '-ar', '48000', '-f', 's16le', '-']); return pcm.length / 96; }
66
96
  export async function videoFramePeriod(path) {
67
97
  const data = JSON.parse((await execute('ffprobe', ['-v', 'error', '-select_streams', 'v:0', '-show_frames', '-show_entries', 'frame=best_effort_timestamp_time,duration_time', '-of', 'json', path])).toString());
@@ -1,7 +1,19 @@
1
- import type { ProgressReporter } from './contracts.js';
1
+ import { type FrameRate, type Viewport, type ProgressReporter } from './contracts.js';
2
+ export type InspectInput = {
3
+ kind: 'storyboard';
4
+ storyboard: string;
5
+ viewport?: Viewport;
6
+ } | {
7
+ kind: 'deck';
8
+ deck: string;
9
+ viewport?: Viewport;
10
+ };
2
11
  export type Options = {
3
12
  command: string;
4
13
  storyboard?: string;
14
+ inspect?: InspectInput;
15
+ viewport?: Viewport;
16
+ fps?: FrameRate;
5
17
  run?: string;
6
18
  cache?: string;
7
19
  output?: string;
@@ -21,30 +33,46 @@ export declare function produce(options: Options): Promise<{
21
33
  run_id: string | undefined;
22
34
  timing_status: string;
23
35
  } | {
36
+ version: number;
37
+ command: string;
38
+ status: string;
39
+ artifacts: Record<string, string>;
40
+ warnings: string[];
41
+ completed_stages: string[];
42
+ run_id: string | undefined;
43
+ timing_status: string;
24
44
  inspection: {
25
45
  annotation_targets: {
26
46
  slide: string;
47
+ clicks?: number;
27
48
  targets: {
28
49
  identity: string;
29
50
  description: string;
30
51
  }[];
31
52
  }[] | undefined;
53
+ dimensions?: Viewport;
32
54
  slides: {
33
55
  id: string;
56
+ alias?: string;
34
57
  index: number;
35
58
  clicks: number;
36
59
  clicks_known?: boolean;
60
+ transition_duration_ms?: number;
61
+ entry_duration_ms?: number;
62
+ click_durations_ms?: number[];
37
63
  }[];
38
64
  media_ids: string[];
65
+ media?: {
66
+ id: string;
67
+ slide: string;
68
+ sha256: string;
69
+ duration_ms: number;
70
+ }[];
39
71
  files: string[];
40
72
  capabilities: string[];
73
+ unsupported?: {
74
+ slide?: string;
75
+ reason: string;
76
+ }[];
41
77
  };
42
- version: number;
43
- command: string;
44
- status: string;
45
- artifacts: Record<string, string>;
46
- warnings: string[];
47
- completed_stages: string[];
48
- run_id: string | undefined;
49
- timing_status: string;
50
78
  }>;
package/dist/pipeline.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { mkdir, readdir, rm } from 'node:fs/promises';
2
2
  import { join, resolve } from 'node:path';
3
+ import { defaultVideoOutput, defaultViewport } from './contracts.js';
3
4
  import { loadStoryboard, fingerprint } from './storyboard.js';
4
5
  import { presentationAdapter, ttsAdapters } from './adapters/registry.js';
5
6
  import { generateSpeech } from './speech.js';
@@ -21,7 +22,7 @@ function defaultStageTimeoutMs(stage, story, options) {
21
22
  ? Math.ceil(duration * 2) + 240_000
22
23
  : Math.ceil(duration * 1.25) + baseStageTimeoutMs;
23
24
  }
24
- const pixelScale = Math.max(1, (story.output.width * story.output.height) / (1920 * 1080));
25
+ const pixelScale = Math.max(1, (options.video.width * options.video.height) / (1920 * 1080));
25
26
  const hasEffects = (options.schedule?.annotations.length ?? 0) > 0
26
27
  || (options.schedule?.overlays?.length ?? 0) > 0
27
28
  || !options.licensed;
@@ -51,6 +52,32 @@ export async function produce(options) {
51
52
  process.once('SIGTERM', interrupt);
52
53
  try {
53
54
  options.progress?.('Validating inputs');
55
+ if (options.command === 'inspect' && options.inspect?.kind === 'deck') {
56
+ const target = options.inspect;
57
+ const deck = resolve(target.deck);
58
+ const adapter = presentationAdapter(deck);
59
+ requireCondition(adapter.inspectTargets, 'ANNOTATION_CAPABILITY', `Adapter ${adapter.id} does not expose annotation targets`, 3);
60
+ activeAdapter = adapter;
61
+ try {
62
+ const { inspection, annotation_targets } = await executionScope.run({ signal: controller.signal, bounded: false }, async () => {
63
+ const inspected = await adapter.inspect(deck);
64
+ const viewport = target.viewport ?? inspected.dimensions ?? defaultViewport;
65
+ const targets = await adapter.inspectTargets(deck, viewport);
66
+ return { inspection: inspected, annotation_targets: targets };
67
+ });
68
+ controller.signal.throwIfAborted();
69
+ const warnings = [];
70
+ if (inspection.slides.some(slide => slide.clicks_known === false))
71
+ warnings.push('Slides without explicit click bounds require runtime reveal checks before recording.');
72
+ if ((inspection.unsupported?.length ?? 0) > 0)
73
+ warnings.push('Deck contains unsupported native features. Adjust the deck before production.');
74
+ return { version: 1, command: options.command, status: 'completed', artifacts: {}, warnings, completed_stages: [], run_id: undefined, timing_status: 'not_evaluated', inspection: { ...inspection, annotation_targets } };
75
+ }
76
+ finally {
77
+ await adapter.cleanup();
78
+ activeAdapter = undefined;
79
+ }
80
+ }
54
81
  if (options.command === 'assemble') {
55
82
  requireCondition(options.run, 'RUN_REQUIRED', 'assemble requires --run');
56
83
  try {
@@ -65,8 +92,13 @@ export async function produce(options) {
65
92
  const story = await loadStoryboard(source);
66
93
  const overlays = story.overlays ?? [];
67
94
  const adapter = presentationAdapter(story.deck);
95
+ const initialViewport = options.command === 'inspect'
96
+ ? (options.inspect?.kind === 'storyboard' ? options.inspect.viewport : undefined) ?? options.viewport ?? defaultViewport
97
+ : options.command === 'validate'
98
+ ? options.viewport ?? defaultViewport
99
+ : undefined;
68
100
  const inspection = await adapter.inspect(story.deck);
69
- await adapter.validate(story, inspection);
101
+ await adapter.validate(story, inspection, initialViewport ? { viewport: initialViewport } : undefined);
70
102
  for (const segment of story.narration) {
71
103
  const voice = segment.voice ?? story.voice;
72
104
  requireCondition(voice, 'VOICE_REQUIRED', `Narration ${segment.id} needs a voice`);
@@ -84,7 +116,7 @@ export async function produce(options) {
84
116
  requireCondition(adapter.inspectTargets, 'ANNOTATION_CAPABILITY', `Adapter ${adapter.id} does not expose annotation targets`, 3);
85
117
  activeAdapter = adapter;
86
118
  try {
87
- const annotation_targets = await adapter.inspectTargets(story);
119
+ const annotation_targets = await executionScope.run({ signal: controller.signal, bounded: false }, () => adapter.inspectTargets(story.deck, initialViewport));
88
120
  controller.signal.throwIfAborted();
89
121
  return { ...result, inspection: { ...inspection, annotation_targets } };
90
122
  }
@@ -120,6 +152,7 @@ export async function produce(options) {
120
152
  throw error;
121
153
  }
122
154
  requireCondition(entries.length === 0, 'NEW_RUN_REQUIRED', 'build requires a new or empty directory. Use --resume for unchanged inputs.');
155
+ await adapter.validate(story, inspection, { viewport: options.viewport ?? defaultViewport });
123
156
  }
124
157
  await mkdir(directory, { recursive: true });
125
158
  lock = join(directory, '.lock');
@@ -136,11 +169,28 @@ export async function produce(options) {
136
169
  run = await Run.open(directory, source, fingerprints.inputs, fingerprints.input_hash);
137
170
  result.run_id = run.manifest.run_id;
138
171
  const recordedMode = run.manifest.verify_timing ?? (run.manifest.stages.record ? true : undefined);
139
- const production = { verify_timing: options.verify_timing ?? recordedMode ?? false };
172
+ const recordedVideo = run.manifest.video;
173
+ const video = {
174
+ width: options.viewport?.width ?? recordedVideo?.width ?? defaultVideoOutput.width,
175
+ height: options.viewport?.height ?? recordedVideo?.height ?? defaultVideoOutput.height,
176
+ fps: options.fps ?? recordedVideo?.fps ?? defaultVideoOutput.fps,
177
+ };
178
+ const production = { verify_timing: options.verify_timing ?? recordedMode ?? false, output: video };
140
179
  if (['build', 'record', 'assemble'].includes(options.command)) {
141
180
  requireCondition(recordedMode === undefined || recordedMode === production.verify_timing, 'RUN_MODE_MISMATCH', 'Timing verification differs from this run. Start a new run directory.');
142
- run.manifest.verify_timing = production.verify_timing;
143
- await run.save();
181
+ requireCondition(recordedVideo === undefined || (recordedVideo.width === video.width && recordedVideo.height === video.height && recordedVideo.fps === video.fps), 'RUN_MODE_MISMATCH', 'Output dimensions or frame rate differ from this run. Start a new run directory.');
182
+ if (!(options.command === 'build' && !options.resume) && (options.command !== 'assemble' || recordedVideo !== undefined)) {
183
+ await adapter.validate(story, inspection, { viewport: video });
184
+ }
185
+ if (options.command === 'build' || options.command === 'record') {
186
+ run.manifest.verify_timing = production.verify_timing;
187
+ run.manifest.video = video;
188
+ await run.save();
189
+ }
190
+ else if (recordedMode !== undefined) {
191
+ run.manifest.verify_timing = production.verify_timing;
192
+ await run.save();
193
+ }
144
194
  options.progress?.(production.verify_timing ? 'Timing verification enabled' : 'Timing verification skipped; the user reviews the video');
145
195
  }
146
196
  requireCondition(!options.output || !run.manifest.output || resolve(options.output) === run.manifest.output, 'OUTPUT_MISMATCH', 'Run is bound to a different output path');
@@ -148,9 +198,10 @@ export async function produce(options) {
148
198
  const schedulePath = join(directory, 'timing/schedule.json');
149
199
  const visualPath = join(directory, 'recording/visual.json');
150
200
  const reportPath = join(directory, 'assembly/report.json');
201
+ const resolveViewport = ['build', 'record', 'assemble'].includes(options.command) ? video : undefined;
151
202
  const resolveSchedule = async () => {
152
203
  const schedule = await resolveTiming(story, await json(speechPath));
153
- await adapter.validate(story, inspection, schedule);
204
+ await adapter.validate(story, inspection, { ...(resolveViewport ? { viewport: resolveViewport } : {}), schedule });
154
205
  return schedule;
155
206
  };
156
207
  const selected = options.command === 'build' ? ['tts', 'resolve', 'record', 'assemble'] : [options.command];
@@ -203,7 +254,7 @@ export async function produce(options) {
203
254
  }
204
255
  let schedule;
205
256
  if (stage === 'record' && !reused) {
206
- const resolveDeadline = options.timeout_ms ?? defaultStageTimeoutMs('resolve', story, { verifyTiming: production.verify_timing, licensed });
257
+ const resolveDeadline = options.timeout_ms ?? defaultStageTimeoutMs('resolve', story, { video, verifyTiming: production.verify_timing, licensed });
207
258
  if (run.manifest.stages.resolve?.status === 'completed') {
208
259
  await runBounded('resolve', resolveDeadline, undefined, async () => {
209
260
  const resolved = await resolveSchedule();
@@ -263,10 +314,11 @@ export async function produce(options) {
263
314
  run.manifest.versions.ffmpeg = (await execute('ffmpeg', ['-version'])).toString().split('\n')[0];
264
315
  }
265
316
  if (stage === 'assemble') {
317
+ requireCondition(run.manifest.video, 'RUN_MANIFEST', 'Run manifest has no recorded video output settings. Start a new run directory.');
266
318
  const output = resolve(options.output ?? run.manifest.output ?? join(directory, 'final.mp4'));
267
319
  requireCondition(!run.manifest.output || run.manifest.output === output, 'OUTPUT_MISMATCH', 'Run is bound to a different output path');
268
320
  try {
269
- const { outputSha256 } = await assemble(story, schedule, await json(speechPath), await json(visualPath), join(directory, 'assembly'), output, {
321
+ const { outputSha256 } = await assemble(schedule, await json(speechPath), await json(visualPath), join(directory, 'assembly'), output, {
270
322
  ...production, licensed, inputHashes: run.manifest.inputs,
271
323
  onOutputReserved: async () => {
272
324
  run.manifest.output = output;
@@ -284,7 +336,7 @@ export async function produce(options) {
284
336
  artifacts.push(output, reportPath, ...await filesIn(join(directory, 'assembly')));
285
337
  }
286
338
  };
287
- const deadline = options.timeout_ms ?? defaultStageTimeoutMs(stage, story, { schedule, verifyTiming: production.verify_timing, licensed });
339
+ const deadline = options.timeout_ms ?? defaultStageTimeoutMs(stage, story, { schedule, video, verifyTiming: production.verify_timing, licensed });
288
340
  const plannedDurationMs = schedule?.duration_ms;
289
341
  await run.stage(stage, artifacts, () => runBounded(stage, deadline, plannedDurationMs, operation), prehashed);
290
342
  options.progress?.(`${reused ? 'Reused' : 'Completed'} ${stage}`);
@@ -26,9 +26,9 @@ export type NativeFrame = {
26
26
  height: number;
27
27
  };
28
28
  content: Rectangle;
29
- annotations: {
30
- id: string;
31
- bounds: Rectangle;
29
+ targets: {
30
+ key: string;
31
+ fragments: Rectangle[];
32
32
  }[];
33
33
  image: string;
34
34
  };
@@ -1,4 +1,4 @@
1
- import { annotationPaint } from '../annotation-paint.js';
1
+ import { annotationPaint, paintEffects, targetKey, underlineFragmentsVisible } from '../annotation-paint.js';
2
2
  const labels = { loading: 'Loading presentation…', ready: 'Ready', playing: 'Playing', paused: 'Paused', ended: 'Finished', error: 'Playback failed' };
3
3
  const stage = document.querySelector('#stage');
4
4
  const status = document.querySelector('#status');
@@ -62,7 +62,6 @@ function nativePlayer(annotations) {
62
62
  canvas.setAttribute('aria-label', 'PowerPoint presentation');
63
63
  const context = canvas.getContext('2d');
64
64
  stage.append(canvas);
65
- const markers = new Map(annotations.map(marker => [marker.id, marker]));
66
65
  let refreshTimer;
67
66
  let revision = 0;
68
67
  async function refresh(current) {
@@ -77,21 +76,27 @@ function nativePlayer(annotations) {
77
76
  if (canvas.height !== frame.viewport.height)
78
77
  canvas.height = frame.viewport.height;
79
78
  context.drawImage(image, 0, 0, canvas.width, canvas.height);
80
- for (const { id, bounds } of frame.annotations) {
81
- const marker = markers.get(id);
82
- if (!marker)
83
- throw new Error(`Unknown native annotation ${id}`);
84
- const fill = annotationPaint(marker, { ...frame, bounds });
85
- for (const paint of [fill, ...(fill.bottom_border ? [fill.bottom_border] : [])]) {
86
- context.save();
87
- context.globalAlpha = paint.opacity;
88
- context.globalCompositeOperation = paint.blend;
89
- context.fillStyle = paint.color;
90
- const { x, y, width, height } = paint.rectangle;
91
- context.fillRect(x, y, width, height);
92
- context.restore();
79
+ const targets = new Map(frame.targets.map(item => [item.key, item.fragments]));
80
+ const activeEffects = [];
81
+ for (const marker of annotations) {
82
+ if (frame.position_ms < marker.start_ms || frame.position_ms >= marker.end_ms)
83
+ continue;
84
+ switch (marker.effect) {
85
+ case 'highlight':
86
+ case 'underline': {
87
+ const fragments = targets.get(targetKey(marker.target));
88
+ if (!fragments)
89
+ throw new Error(`Missing native target geometry for ${marker.id}`);
90
+ const painted = annotationPaint(marker, { viewport: frame.viewport, content: frame.content, fragments });
91
+ if (painted.effect === 'underline' && !underlineFragmentsVisible(painted)) {
92
+ throw new Error(`Annotation ${marker.id}: underline is clipped outside the slide-content rectangle`);
93
+ }
94
+ activeEffects.push(painted);
95
+ break;
96
+ }
93
97
  }
94
98
  }
99
+ paintEffects(context, activeEffects, frame.position_ms);
95
100
  display(frame.status, frame.position_ms);
96
101
  refreshTimer = window.setTimeout(() => refresh(current).catch(failed), frame.status === 'playing' ? 16 : 500);
97
102
  }
@@ -1 +1,2 @@
1
- export declare function servePreview(storyboard: string, cache: string | undefined, port: number, ready: (url: string, approximate: string[]) => void): Promise<void>;
1
+ import { type Viewport } from '../contracts.js';
2
+ export declare function servePreview(storyboard: string, cache: string | undefined, port: number, viewport: Viewport | undefined, ready: (url: string, approximate: string[]) => void): Promise<void>;
@@ -2,6 +2,7 @@ import { createServer } from 'node:http';
2
2
  import { mkdtemp, readFile, rm } from 'node:fs/promises';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { basename, join, resolve } from 'node:path';
5
+ import { defaultViewport } from '../contracts.js';
5
6
  import { presentationAdapter, ttsAdapters } from '../adapters/registry.js';
6
7
  import { ProductionError, requireCondition } from '../errors.js';
7
8
  import { executionScope } from '../media.js';
@@ -12,7 +13,7 @@ function send(res, status, contentType, body) {
12
13
  res.writeHead(status, { 'Content-Type': contentType });
13
14
  res.end(body);
14
15
  }
15
- export async function servePreview(storyboard, cache, port, ready) {
16
+ export async function servePreview(storyboard, cache, port, viewport = defaultViewport, ready) {
16
17
  let origin = '';
17
18
  let config;
18
19
  let session;
@@ -63,9 +64,9 @@ export async function servePreview(storyboard, cache, port, ready) {
63
64
  adapter = presentationAdapter(story.deck);
64
65
  requireCondition(adapter.startPreview, 'PREVIEW_CAPABILITY', `Adapter ${adapter.id} does not support preview`, 3);
65
66
  const inspection = await adapter.inspect(story.deck);
66
- await adapter.validate(story, inspection);
67
+ await adapter.validate(story, inspection, { viewport });
67
68
  const { schedule, approximate } = await resolvePreviewTiming(story, ttsAdapters, cache);
68
- await adapter.validate(story, inspection, schedule);
69
+ await adapter.validate(story, inspection, { viewport, schedule });
69
70
  controller.signal.throwIfAborted();
70
71
  await new Promise((resolve, reject) => {
71
72
  server.once('error', reject);
@@ -76,9 +77,9 @@ export async function servePreview(storyboard, cache, port, ready) {
76
77
  origin = `http://127.0.0.1:${address.port}`;
77
78
  directory = await mkdtemp(join(tmpdir(), 'slidevideo-preview-'));
78
79
  controller.signal.throwIfAborted();
79
- session = await adapter.startPreview(story, schedule, directory, origin);
80
+ session = await adapter.startPreview(story, schedule, directory, origin, viewport);
80
81
  controller.signal.throwIfAborted();
81
- config = { deck: basename(story.deck), width: story.output.width, height: story.output.height,
82
+ config = { deck: basename(story.deck), width: viewport.width, height: viewport.height,
82
83
  duration: schedule.duration_ms, approximate,
83
84
  stage: 'url' in session ? { url: session.url } : { annotations: schedule.annotations } };
84
85
  ready(origin, approximate);
package/dist/setup.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type ToolPaths } from './executables.js';
2
+ import { type SkillReadiness } from './skill-install.js';
2
3
  type SetupOptions = ToolPaths & {
3
4
  presentation?: string;
4
5
  provider?: string;
@@ -26,6 +27,7 @@ export type SetupReadiness = {
26
27
  shared_checks: Check[];
27
28
  presentations: Partial<Record<Presentation, Readiness>>;
28
29
  providers: Partial<Record<Provider, ProviderReadiness>>;
30
+ skill: SkillReadiness;
29
31
  };
30
32
  export declare function setup(options: SetupOptions, beforePrompts?: (report: SetupReadiness) => void): Promise<{
31
33
  version: number;
@@ -39,6 +41,7 @@ export declare function setup(options: SetupOptions, beforePrompts?: (report: Se
39
41
  shared_checks: Check[];
40
42
  presentations: Partial<Record<Presentation, Readiness>>;
41
43
  providers: Partial<Record<Provider, ProviderReadiness>>;
44
+ skill: SkillReadiness;
42
45
  config_file: string;
43
46
  saved_paths: Partial<Record<"python" | "browser" | "ffmpeg" | "ffprobe", string>>;
44
47
  checks: Check[];
package/dist/setup.js CHANGED
@@ -11,6 +11,7 @@ import { packagePath, userConfigFile } from './installation.js';
11
11
  import { execute } from './media.js';
12
12
  import { ffmpegInstaller, installChromium, installEdgeEnvironment, runInstaller } from './setup-install.js';
13
13
  import { hasLicenseTerminal, setupLicense } from './setup-license.js';
14
+ import { inspectSkillStatus, installSkill } from './skill-install.js';
14
15
  const presentations = ['slidev', 'powerpoint'];
15
16
  const providers = ['edge-tts', 'elevenlabs'];
16
17
  const windows = process.platform === 'win32';
@@ -164,7 +165,8 @@ export async function setup(options, beforePrompts) {
164
165
  }
165
166
  providerReports[provider] = { ...readiness(prerequisites), ...(deferred.has(provider) ? { deferred: true } : {}) };
166
167
  }));
167
- return { shared_checks: shared, presentations: presentationReports, providers: providerReports };
168
+ const skill = await inspectSkillStatus('user');
169
+ return { shared_checks: shared, presentations: presentationReports, providers: providerReports, skill };
168
170
  };
169
171
  let reports = await checks();
170
172
  if (interactive) {
@@ -271,6 +273,18 @@ export async function setup(options, beforePrompts) {
271
273
  await attempt('Edge TTS', async () => { installed.python = await installEdgeEnvironment(); });
272
274
  reports = await withExecutables({ ...options, ...installed }, checks);
273
275
  }
276
+ if (interactive && !install && options.presentation === undefined && options.provider === undefined && reports.skill.status !== 'installed' && !reports.skill.targets.some(target => target.status === 'conflict')) {
277
+ const reader = createInterface({ input: process.stdin, output: process.stderr });
278
+ try {
279
+ if (/^y(?:es)?$/i.test((await reader.question('Register the SlideVideo skill for coding agents now? [y/N]: ')).trim())) {
280
+ await installSkill('user');
281
+ reports.skill = await inspectSkillStatus('user');
282
+ }
283
+ }
284
+ finally {
285
+ reader.close();
286
+ }
287
+ }
274
288
  const paths = {};
275
289
  for (const tool of ['browser', 'python', 'ffmpeg', 'ffprobe']) {
276
290
  if (!dependencies().some(check => check.name === tool && check.ready))
@@ -300,6 +314,7 @@ export async function setup(options, beforePrompts) {
300
314
  shared_checks: reports.shared_checks,
301
315
  presentations: reports.presentations,
302
316
  providers: reports.providers,
317
+ skill: reports.skill,
303
318
  config_file: userConfigFile(),
304
319
  saved_paths: paths,
305
320
  checks: dependencies(),
@@ -0,0 +1,35 @@
1
+ export type SkillScope = 'user' | 'project';
2
+ export type SkillAgent = 'agents' | 'claude';
3
+ export type SkillTargetState = 'installed' | 'outdated' | 'broken' | 'missing' | 'conflict';
4
+ export type SkillTargetStatus = {
5
+ agent: SkillAgent;
6
+ scope: SkillScope;
7
+ path: string;
8
+ status: SkillTargetState;
9
+ target?: string;
10
+ conflict_path?: string;
11
+ };
12
+ export type SkillReadiness = {
13
+ status: 'installed' | 'not_installed';
14
+ source: string;
15
+ targets: SkillTargetStatus[];
16
+ };
17
+ export type SkillInstallAction = 'installed' | 'updated' | 'unchanged';
18
+ export type SkillInstallTarget = {
19
+ agent: SkillAgent;
20
+ scope: SkillScope;
21
+ path: string;
22
+ action: SkillInstallAction;
23
+ target: string;
24
+ };
25
+ export type SkillInstallReport = {
26
+ version: 1;
27
+ command: 'skill';
28
+ action: 'install';
29
+ status: 'completed';
30
+ scope: SkillScope;
31
+ source: string;
32
+ targets: SkillInstallTarget[];
33
+ };
34
+ export declare function inspectSkillStatus(scope?: SkillScope): Promise<SkillReadiness>;
35
+ export declare function installSkill(scope?: SkillScope): Promise<SkillInstallReport>;
@@ -0,0 +1,132 @@
1
+ import { access, lstat, mkdir, readlink, realpath, stat, symlink, unlink } from 'node:fs/promises';
2
+ import { homedir } from 'node:os';
3
+ import { delimiter, dirname, isAbsolute, join, resolve } from 'node:path';
4
+ import { ProductionError, requireCondition } from './errors.js';
5
+ import { findOnPath, isExecutable } from './executables.js';
6
+ import { packagePath } from './installation.js';
7
+ const windows = process.platform === 'win32';
8
+ const macosExtraDirectories = process.platform === 'darwin' ? ['/opt/homebrew/bin', '/usr/local/bin'] : [];
9
+ async function inspectDirectoryStep(path) {
10
+ let entry;
11
+ try {
12
+ entry = await lstat(path);
13
+ }
14
+ catch (error) {
15
+ const code = error.code;
16
+ if (code === 'ENOENT')
17
+ return 'missing';
18
+ if (code === 'ENOTDIR' || code === 'ELOOP' || code === 'EACCES' || code === 'EPERM')
19
+ return 'conflict';
20
+ throw error;
21
+ }
22
+ if (entry.isDirectory())
23
+ return 'directory';
24
+ if (!entry.isSymbolicLink())
25
+ return 'conflict';
26
+ try {
27
+ return (await stat(path)).isDirectory() ? 'directory' : 'conflict';
28
+ }
29
+ catch {
30
+ return 'conflict';
31
+ }
32
+ }
33
+ function claudeOnPath() {
34
+ if (!windows)
35
+ return Boolean(findOnPath('claude', macosExtraDirectories));
36
+ const directories = (process.env.PATH ?? '').split(delimiter).filter(isAbsolute);
37
+ const configured = (process.env.PATHEXT ?? '').split(';').map(ext => ext.trim()).filter(ext => ext.startsWith('.') && ext.length > 1 && !/[\\/]/.test(ext));
38
+ const extensions = [...new Set([...configured, '.COM', '.EXE', '.BAT', '.CMD'].flatMap(ext => [ext, ext.toLowerCase()]))];
39
+ return directories.some(directory => extensions.some(ext => isExecutable(join(directory, `claude${ext}`))));
40
+ }
41
+ async function inspectTarget(agent, scope, root, agentDirectory, source) {
42
+ const baseDirectory = join(root, agentDirectory);
43
+ const skillsDirectory = join(baseDirectory, 'skills');
44
+ const path = join(skillsDirectory, 'slidevideo');
45
+ for (const parent of [baseDirectory, skillsDirectory]) {
46
+ const step = await inspectDirectoryStep(parent);
47
+ if (step === 'missing')
48
+ return { agent, scope, path, status: 'missing' };
49
+ if (step === 'conflict')
50
+ return { agent, scope, path, status: 'conflict', conflict_path: parent };
51
+ }
52
+ let entry;
53
+ try {
54
+ entry = await lstat(path);
55
+ }
56
+ catch (error) {
57
+ const code = error.code;
58
+ if (code === 'ENOENT')
59
+ return { agent, scope, path, status: 'missing' };
60
+ if (code === 'ENOTDIR' || code === 'ELOOP' || code === 'EACCES' || code === 'EPERM') {
61
+ return { agent, scope, path, status: 'conflict', conflict_path: path };
62
+ }
63
+ throw error;
64
+ }
65
+ if (!entry.isSymbolicLink())
66
+ return { agent, scope, path, status: 'conflict', conflict_path: path };
67
+ try {
68
+ const resolved = await realpath(path);
69
+ const matches = windows ? resolved.toLowerCase() === source.toLowerCase() : resolved === source;
70
+ return { agent, scope, path, status: matches ? 'installed' : 'outdated', target: resolved };
71
+ }
72
+ catch {
73
+ const raw = await readlink(path).catch(() => undefined);
74
+ return { agent, scope, path, status: 'broken', ...(raw ? { target: raw } : {}) };
75
+ }
76
+ }
77
+ export async function inspectSkillStatus(scope = 'user') {
78
+ const directory = packagePath('skills', 'slidevideo');
79
+ let source;
80
+ try {
81
+ source = await realpath(directory);
82
+ await access(join(source, 'SKILL.md'));
83
+ }
84
+ catch {
85
+ throw new ProductionError('MISSING_SKILL', `Bundled skill is unavailable at ${directory}`, 3);
86
+ }
87
+ const root = scope === 'user' ? homedir() : resolve('.');
88
+ const specs = [{ agent: 'agents', directory: '.agents' }];
89
+ const claudeStep = await inspectDirectoryStep(join(root, '.claude'));
90
+ if (claudeStep === 'directory' || (scope === 'user' && claudeOnPath())) {
91
+ specs.push({ agent: 'claude', directory: '.claude' });
92
+ }
93
+ const targets = await Promise.all(specs.map(spec => inspectTarget(spec.agent, scope, root, spec.directory, source)));
94
+ return {
95
+ status: targets.length > 0 && targets.every(target => target.status === 'installed') ? 'installed' : 'not_installed',
96
+ source,
97
+ targets,
98
+ };
99
+ }
100
+ export async function installSkill(scope = 'user') {
101
+ const readiness = await inspectSkillStatus(scope);
102
+ const conflict = readiness.targets.find(target => target.status === 'conflict');
103
+ requireCondition(!conflict, 'SKILL_CONFLICT', `Cannot link skill at ${conflict?.path} because ${conflict?.conflict_path ?? conflict?.path} already exists and is not a skill link. Remove or move it and rerun slidevideo skill --install.`, 3);
104
+ const linkType = windows ? 'junction' : 'dir';
105
+ const targets = [];
106
+ for (const item of readiness.targets) {
107
+ if (item.status === 'installed') {
108
+ targets.push({ agent: item.agent, scope: item.scope, path: item.path, action: 'unchanged', target: readiness.source });
109
+ continue;
110
+ }
111
+ await mkdir(dirname(item.path), { recursive: true });
112
+ if (item.status === 'broken' || item.status === 'outdated')
113
+ await unlink(item.path);
114
+ await symlink(readiness.source, item.path, linkType);
115
+ targets.push({
116
+ agent: item.agent,
117
+ scope: item.scope,
118
+ path: item.path,
119
+ action: item.status === 'missing' ? 'installed' : 'updated',
120
+ target: readiness.source,
121
+ });
122
+ }
123
+ return {
124
+ version: 1,
125
+ command: 'skill',
126
+ action: 'install',
127
+ status: 'completed',
128
+ scope,
129
+ source: readiness.source,
130
+ targets,
131
+ };
132
+ }
@@ -47,6 +47,15 @@ export async function loadStoryboard(file) {
47
47
  if (annotation.target.type === 'region') {
48
48
  const { x, y, width, height } = annotation.target;
49
49
  requireCondition(x + width <= 1 && y + height <= 1, 'ANNOTATION_BOUNDS', `Annotation ${annotation.id}: region exceeds normalized slide bounds`, 2, context);
50
+ if (annotation.effect === 'underline') {
51
+ const top = y + height + (annotation.appearance.offset ?? 0);
52
+ requireCondition(top < 1 && top + annotation.appearance.width > 0, 'ANNOTATION_BOUNDS', `Annotation ${annotation.id}: underline offset places stroke outside normalized slide bounds`, 2, context);
53
+ }
54
+ }
55
+ if (annotation.effect === 'underline' && annotation.motion) {
56
+ const inMs = annotation.motion.in_ms ?? 0;
57
+ const outMs = annotation.motion.out_ms ?? 0;
58
+ requireCondition(inMs + outMs <= annotation.duration_ms, 'ANNOTATION_MOTION', `Annotation ${annotation.id}: wipe motion exceeds annotation duration`, 2, context);
50
59
  }
51
60
  }
52
61
  const scenes = new Set(data.scenes.map(scene => scene.id));