@slidevideo/cli 0.1.2 → 0.2.1
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 +41 -0
- package/IMPRESSUM.md +18 -4
- package/LICENSE-TERMS.md +46 -13
- package/README.md +5 -5
- package/addons/slidevideo/geometry.ts +63 -30
- package/addons/slidevideo/global-top.vue +41 -9
- package/addons/slidevideo/playback-entries.ts +17 -6
- package/addons/slidevideo/preview.ts +27 -15
- package/dist/adapters/browser-runtime.d.ts +3 -0
- package/dist/adapters/elevenlabs.d.ts +1 -0
- package/dist/adapters/elevenlabs.js +8 -4
- package/dist/adapters/powerpoint.d.ts +7 -4
- package/dist/adapters/powerpoint.js +123 -34
- package/dist/adapters/slidev-inspection.d.ts +5 -2
- package/dist/adapters/slidev-inspection.js +5 -6
- package/dist/adapters/slidev-server.js +136 -15
- package/dist/adapters/slidev.d.ts +12 -4
- package/dist/adapters/slidev.js +356 -70
- package/dist/annotation-paint.d.ts +65 -11
- package/dist/annotation-paint.js +290 -10
- package/dist/annotations.d.ts +13 -8
- package/dist/annotations.js +620 -89
- package/dist/assembly.d.ts +48 -40
- package/dist/assembly.js +72 -28
- package/dist/calibration.js +5 -4
- package/dist/cli.js +180 -39
- package/dist/compositor.d.ts +38 -6
- package/dist/compositor.js +299 -46
- package/dist/contracts.d.ts +96 -35
- package/dist/contracts.js +2 -1
- package/dist/executables.d.ts +2 -0
- package/dist/executables.js +27 -8
- package/dist/media.d.ts +12 -1
- package/dist/media.js +53 -4
- package/dist/pipeline.d.ts +36 -10
- package/dist/pipeline.js +163 -46
- package/dist/preview/contracts.d.ts +3 -3
- package/dist/preview/player.js +20 -15
- package/dist/preview/server.d.ts +2 -1
- package/dist/preview/server.js +8 -7
- package/dist/run.d.ts +1 -1
- package/dist/run.js +8 -3
- package/dist/setup-install.d.ts +1 -0
- package/dist/setup-install.js +8 -1
- package/dist/setup.d.ts +29 -8
- package/dist/setup.js +183 -76
- package/dist/skill-install.d.ts +35 -0
- package/dist/skill-install.js +132 -0
- package/dist/speech.js +10 -6
- package/dist/storyboard.js +12 -6
- package/dist/timing.js +2 -2
- package/package.json +4 -3
- package/schemas/annotation-geometry.v1.json +260 -28
- package/schemas/run-manifest.v1.json +31 -0
- package/schemas/schedule.v1.json +655 -1
- package/schemas/storyboard.v1.json +558 -33
- package/skills/slidevideo/SKILL.md +11 -9
- package/skills/slidevideo/references/decks.md +228 -0
- package/skills/slidevideo/references/production.md +17 -12
- package/skills/slidevideo/references/storyboard.md +71 -38
- package/tools/powerpoint/powerpoint.ps1 +52 -41
- package/tools/powerpoint/preview.ps1 +5 -5
- package/schemas/schedule.v2.json +0 -496
- package/schemas/storyboard.v2.json +0 -802
package/dist/preview/player.js
CHANGED
|
@@ -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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
}
|
package/dist/preview/server.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
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>;
|
package/dist/preview/server.js
CHANGED
|
@@ -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;
|
|
@@ -57,15 +58,15 @@ export async function servePreview(storyboard, cache, port, ready) {
|
|
|
57
58
|
process.once('SIGINT', stop);
|
|
58
59
|
process.once('SIGTERM', stop);
|
|
59
60
|
try {
|
|
60
|
-
await executionScope.run(controller.signal, async () => {
|
|
61
|
+
await executionScope.run({ signal: controller.signal, bounded: false }, async () => {
|
|
61
62
|
const story = await loadStoryboard(resolve(storyboard));
|
|
62
63
|
requireCondition(!story.overlays?.length, 'PREVIEW_CAPABILITY', 'Image overlays require an exported video. Use slidevideo build to review them.', 3);
|
|
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
|
-
adapter.validate(story, inspection);
|
|
67
|
+
await adapter.validate(story, inspection, { viewport });
|
|
67
68
|
const { schedule, approximate } = await resolvePreviewTiming(story, ttsAdapters, cache);
|
|
68
|
-
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,11 +77,11 @@ 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:
|
|
82
|
+
config = { deck: basename(story.deck), width: viewport.width, height: viewport.height,
|
|
82
83
|
duration: schedule.duration_ms, approximate,
|
|
83
|
-
stage: 'url' in session ? { url: session.url } : { annotations: schedule.annotations
|
|
84
|
+
stage: 'url' in session ? { url: session.url } : { annotations: schedule.annotations } };
|
|
84
85
|
ready(origin, approximate);
|
|
85
86
|
await new Promise(resolve => controller.signal.addEventListener('abort', () => resolve(), { once: true }));
|
|
86
87
|
});
|
package/dist/run.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare class Run {
|
|
|
6
6
|
static open(directory: string, storyboard: string, inputs: Record<string, string>, input_hash: string): Promise<Run>;
|
|
7
7
|
verify(stage: Stage): Promise<void>;
|
|
8
8
|
exportSchedule(destination: string, schedule: Schedule): Promise<void>;
|
|
9
|
-
stage(name: Stage, files: string[], operation: () => Promise<void>): Promise<void>;
|
|
9
|
+
stage(name: Stage, files: string[], operation: () => Promise<void>, prehashed?: Record<string, string>): Promise<void>;
|
|
10
10
|
save(): Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export declare function filesIn(directory: string): Promise<string[]>;
|
package/dist/run.js
CHANGED
|
@@ -3,6 +3,7 @@ import { join, resolve } from 'node:path';
|
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { hashFile, json, saveJson } from './media.js';
|
|
5
5
|
import { requireCondition, ProductionError } from './errors.js';
|
|
6
|
+
import { packagePath } from './installation.js';
|
|
6
7
|
export class Run {
|
|
7
8
|
directory;
|
|
8
9
|
manifest;
|
|
@@ -19,7 +20,10 @@ export class Run {
|
|
|
19
20
|
catch (error) {
|
|
20
21
|
if (error.code !== 'ENOENT')
|
|
21
22
|
throw new ProductionError('RUN_MANIFEST', `Cannot read run manifest in ${directory}`);
|
|
22
|
-
|
|
23
|
+
const entries = await readdir(directory);
|
|
24
|
+
requireCondition(entries.every(entry => entry === '.lock'), 'NEW_RUN_REQUIRED', 'Run has no manifest and is not empty. Start with a new or empty run directory.');
|
|
25
|
+
const { version } = await json(packagePath('package.json'));
|
|
26
|
+
manifest = { version: 1, run_id: randomUUID(), created_at: new Date().toISOString(), storyboard, inputs, input_hash, versions: { node: process.version, slidevideo: version }, stages: {} };
|
|
23
27
|
await saveJson(join(directory, 'inputs/storyboard.json'), { source: storyboard, content: await readFile(storyboard, 'utf8'), inputs });
|
|
24
28
|
await saveJson(join(directory, 'manifest.json'), manifest);
|
|
25
29
|
}
|
|
@@ -70,7 +74,7 @@ export class Run {
|
|
|
70
74
|
}
|
|
71
75
|
await saveJson(resolve(destination), schedule);
|
|
72
76
|
}
|
|
73
|
-
async stage(name, files, operation) {
|
|
77
|
+
async stage(name, files, operation, prehashed = {}) {
|
|
74
78
|
if (this.manifest.stages[name]?.status === 'completed') {
|
|
75
79
|
await this.verify(name);
|
|
76
80
|
return;
|
|
@@ -79,9 +83,10 @@ export class Run {
|
|
|
79
83
|
await this.save();
|
|
80
84
|
try {
|
|
81
85
|
await operation();
|
|
86
|
+
const known = new Map(Object.entries(prehashed).map(([file, sha256]) => [resolve(file), sha256]));
|
|
82
87
|
const artifacts = {};
|
|
83
88
|
for (const file of new Set(files.map(file => resolve(file))))
|
|
84
|
-
artifacts[file] = await hashFile(file);
|
|
89
|
+
artifacts[file] = known.get(file) ?? await hashFile(file);
|
|
85
90
|
this.manifest.stages[name] = { status: 'completed', artifacts };
|
|
86
91
|
await this.save();
|
|
87
92
|
return;
|
package/dist/setup-install.d.ts
CHANGED
package/dist/setup-install.js
CHANGED
|
@@ -7,6 +7,8 @@ import { environmentPython, managedBrowserDirectory, packagePath, userDataDirect
|
|
|
7
7
|
import { execute } from './media.js';
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
9
|
const windows = process.platform === 'win32';
|
|
10
|
+
const macos = process.platform === 'darwin';
|
|
11
|
+
const macosExtraDirectories = macos ? ['/opt/homebrew/bin', '/usr/local/bin'] : [];
|
|
10
12
|
const edgeLock = packagePath('tools', 'edge-tts', 'requirements.lock');
|
|
11
13
|
export function runInstaller(command, args, env = process.env) {
|
|
12
14
|
return new Promise((resolve, reject) => {
|
|
@@ -34,6 +36,11 @@ export function ffmpegInstaller() {
|
|
|
34
36
|
if (winget)
|
|
35
37
|
return { command: winget, args: ['install', '--id', 'Gyan.FFmpeg', '--exact', '--accept-package-agreements', '--accept-source-agreements'] };
|
|
36
38
|
}
|
|
39
|
+
if (macos) {
|
|
40
|
+
const brew = findOnPath('brew', macosExtraDirectories);
|
|
41
|
+
if (brew)
|
|
42
|
+
return { command: brew, args: ['install', 'ffmpeg'], env: { ...process.env, HOMEBREW_NO_ASK: '1' } };
|
|
43
|
+
}
|
|
37
44
|
if (process.platform === 'linux') {
|
|
38
45
|
const apt = findOnPath('apt-get');
|
|
39
46
|
const pacman = findOnPath('pacman');
|
|
@@ -52,7 +59,7 @@ export async function installEdgeEnvironment() {
|
|
|
52
59
|
const directory = join(userDataDirectory(), 'edge-tts');
|
|
53
60
|
const lock = `${directory}.lock`;
|
|
54
61
|
const python = environmentPython(directory);
|
|
55
|
-
const uv = findOnPath('uv');
|
|
62
|
+
const uv = findOnPath('uv', macosExtraDirectories);
|
|
56
63
|
const candidate = toolCandidate('python');
|
|
57
64
|
const base = candidate?.path;
|
|
58
65
|
await mkdir(userDataDirectory(), { recursive: true });
|
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;
|
|
@@ -8,22 +9,42 @@ type SetupOptions = ToolPaths & {
|
|
|
8
9
|
json?: boolean;
|
|
9
10
|
quiet?: boolean;
|
|
10
11
|
};
|
|
11
|
-
|
|
12
|
+
type Presentation = 'slidev' | 'powerpoint';
|
|
13
|
+
type Provider = 'edge-tts' | 'elevenlabs';
|
|
14
|
+
type Check = {
|
|
15
|
+
name: string;
|
|
16
|
+
ready: boolean;
|
|
17
|
+
detail: string;
|
|
18
|
+
};
|
|
19
|
+
type Readiness = {
|
|
20
|
+
status: 'ready' | 'missing_dependencies' | 'unavailable';
|
|
21
|
+
checks: Check[];
|
|
22
|
+
};
|
|
23
|
+
type ProviderReadiness = Readiness & {
|
|
24
|
+
deferred?: boolean;
|
|
25
|
+
};
|
|
26
|
+
export type SetupReadiness = {
|
|
27
|
+
shared_checks: Check[];
|
|
28
|
+
presentations: Partial<Record<Presentation, Readiness>>;
|
|
29
|
+
providers: Partial<Record<Provider, ProviderReadiness>>;
|
|
30
|
+
skill: SkillReadiness;
|
|
31
|
+
};
|
|
32
|
+
export declare function setup(options: SetupOptions, beforePrompts?: (report: SetupReadiness) => void): Promise<{
|
|
12
33
|
version: number;
|
|
13
34
|
command: string;
|
|
14
35
|
status: "ready" | "missing_dependencies";
|
|
15
|
-
presentation: string;
|
|
36
|
+
presentation: string | undefined;
|
|
16
37
|
voice: {
|
|
17
38
|
provider: string;
|
|
18
39
|
voice: string;
|
|
19
|
-
};
|
|
40
|
+
} | undefined;
|
|
41
|
+
shared_checks: Check[];
|
|
42
|
+
presentations: Partial<Record<Presentation, Readiness>>;
|
|
43
|
+
providers: Partial<Record<Provider, ProviderReadiness>>;
|
|
44
|
+
skill: SkillReadiness;
|
|
20
45
|
config_file: string;
|
|
21
46
|
saved_paths: Partial<Record<"python" | "browser" | "ffmpeg" | "ffprobe", string>>;
|
|
22
|
-
checks:
|
|
23
|
-
name: string;
|
|
24
|
-
ready: boolean;
|
|
25
|
-
detail: string;
|
|
26
|
-
}[];
|
|
47
|
+
checks: Check[];
|
|
27
48
|
browsers: {
|
|
28
49
|
path: string;
|
|
29
50
|
name: "Chromium" | "Google Chrome" | "Microsoft Edge" | "Custom browser";
|
package/dist/setup.js
CHANGED
|
@@ -2,19 +2,31 @@ import { readFile } from 'node:fs/promises';
|
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { createInterface } from 'node:readline/promises';
|
|
4
4
|
import { parseEnv } from 'node:util';
|
|
5
|
+
import { Writable } from 'node:stream';
|
|
6
|
+
import { elevenLabsApiKey } from './adapters/elevenlabs.js';
|
|
5
7
|
import { chromium } from 'playwright';
|
|
6
|
-
import { browserCandidates, browserName, discoverExecutable, findOnPath, isExecutable, saveExecutablePaths, toolCandidate, withExecutables } from './executables.js';
|
|
7
|
-
import { requireCondition } from './errors.js';
|
|
8
|
+
import { browserCandidates, browserName, configuredLicense, discoverExecutable, findOnPath, isExecutable, saveElevenLabsKey, saveExecutablePaths, toolCandidate, withExecutables } from './executables.js';
|
|
9
|
+
import { ProductionError, requireCondition } from './errors.js';
|
|
8
10
|
import { packagePath, userConfigFile } from './installation.js';
|
|
9
11
|
import { execute } from './media.js';
|
|
10
12
|
import { ffmpegInstaller, installChromium, installEdgeEnvironment, runInstaller } from './setup-install.js';
|
|
11
13
|
import { hasLicenseTerminal, setupLicense } from './setup-license.js';
|
|
14
|
+
import { inspectSkillStatus, installSkill } from './skill-install.js';
|
|
15
|
+
const presentations = ['slidev', 'powerpoint'];
|
|
16
|
+
const providers = ['edge-tts', 'elevenlabs'];
|
|
12
17
|
const windows = process.platform === 'win32';
|
|
18
|
+
const macos = process.platform === 'darwin';
|
|
13
19
|
const ffmpegInstructions = windows
|
|
14
20
|
? 'Install FFmpeg with winget install --id Gyan.FFmpeg --exact, or pass --ffmpeg and --ffprobe with the installed paths.'
|
|
15
|
-
:
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
: macos
|
|
22
|
+
? 'Install FFmpeg with brew install ffmpeg, or pass --ffmpeg and --ffprobe with the installed paths.'
|
|
23
|
+
: 'Install ffmpeg with libx264 and ffprobe through your distribution, or pass --ffmpeg and --ffprobe with the installed paths.';
|
|
24
|
+
const browserInstructions = macos
|
|
25
|
+
? 'Run slidevideo setup --presentation slidev --install to install Chromium, install Chromium manually, or pass --browser with its executable path.'
|
|
26
|
+
: 'Install Chromium and rerun setup, or pass --browser with its executable path.';
|
|
27
|
+
const edgeInstructions = macos
|
|
28
|
+
? `Install Python 3 with venv support or uv (brew install uv), then run setup with --install. For manual setup, install the packages from ${packagePath('tools', 'edge-tts', 'requirements.lock')} in a virtual environment, then pass its interpreter with --python.`
|
|
29
|
+
: `Install Python with venv support or uv, then run setup with --install. For manual setup, install the packages from ${packagePath('tools', 'edge-tts', 'requirements.lock')} in a virtual environment, then pass its interpreter with --python.`;
|
|
18
30
|
async function checkTool(tool, verify, instructions) {
|
|
19
31
|
const candidate = toolCandidate(tool);
|
|
20
32
|
if (!candidate || !isExecutable(candidate.path)) {
|
|
@@ -71,47 +83,43 @@ async function checkPython(path) {
|
|
|
71
83
|
].join('\n');
|
|
72
84
|
return (await execute(path, ['-c', probe, JSON.stringify(requirements)], 10000)).toString().trim();
|
|
73
85
|
}
|
|
74
|
-
async function
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
reader.close();
|
|
89
|
-
}
|
|
86
|
+
async function checkElevenLabs() {
|
|
87
|
+
try {
|
|
88
|
+
const dotenv = await readFile('.env', 'utf8').catch((error) => {
|
|
89
|
+
if (error.code === 'ENOENT')
|
|
90
|
+
return '';
|
|
91
|
+
throw error;
|
|
92
|
+
});
|
|
93
|
+
const credentials = parseEnv(dotenv);
|
|
94
|
+
const hasKey = !!elevenLabsApiKey({ ...credentials, ...process.env })?.trim();
|
|
95
|
+
return { name: 'elevenlabs-key', ready: hasKey, detail: hasKey ? 'ElevenLabs API key is configured' : 'Run slidevideo setup --provider elevenlabs to save your API key for all projects.' };
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return { name: 'elevenlabs-key', ready: false, detail: 'Cannot read the project .env file. Check its format and permissions, then rerun setup.' };
|
|
90
99
|
}
|
|
91
|
-
requireCondition(presentation === 'slidev' || presentation === 'powerpoint', 'OPTION', 'Set --presentation to slidev or powerpoint');
|
|
92
|
-
requireCondition(provider === 'edge-tts' || provider === 'elevenlabs', 'OPTION', 'Set --provider to edge-tts or elevenlabs');
|
|
93
|
-
return { presentation, provider, voiceId: voiceId?.trim() || (provider === 'edge-tts' ? 'en-US-AriaNeural' : ''), install, manual, interactive };
|
|
94
100
|
}
|
|
95
|
-
|
|
96
|
-
const { presentation, provider,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
function choices(options) {
|
|
102
|
+
const { presentation, provider, install, manual } = options;
|
|
103
|
+
requireCondition(!(install && manual), 'OPTION', 'Choose either --install or --manual');
|
|
104
|
+
requireCondition(presentation === undefined || presentations.some(name => name === presentation), 'OPTION', 'Set --presentation to slidev or powerpoint');
|
|
105
|
+
requireCondition(provider === undefined || providers.some(name => name === provider), 'OPTION', 'Set --provider to edge-tts or elevenlabs');
|
|
106
|
+
const selectedPresentations = presentations.filter(name => presentation === undefined || name === presentation);
|
|
107
|
+
const selectedProviders = providers.filter(name => provider === undefined || name === provider);
|
|
108
|
+
const interactive = process.stdin.isTTY && !options.json && !options.quiet && !manual;
|
|
109
|
+
return { selectedPresentations, selectedProviders, install, manual, interactive };
|
|
110
|
+
}
|
|
111
|
+
export async function setup(options, beforePrompts) {
|
|
112
|
+
const { selectedPresentations, selectedProviders, install, manual, interactive } = choices(options);
|
|
113
|
+
const deferred = new Set();
|
|
114
|
+
const supported = process.platform === 'linux' || macos || windows;
|
|
100
115
|
const installed = {};
|
|
101
116
|
const installationErrors = [];
|
|
102
117
|
const checks = async () => {
|
|
103
|
-
|
|
104
|
-
return [{ name: 'platform', ready: false, detail: presentation === 'powerpoint' ? 'Use Windows with installed desktop PowerPoint.' : 'Use Linux or Windows.' }];
|
|
105
|
-
const media = [
|
|
118
|
+
const shared = supported ? await Promise.all([
|
|
106
119
|
checkTool('ffmpeg', async (path) => {
|
|
107
120
|
const encoders = (await execute(path, ['-hide_banner', '-encoders'], 10000)).toString();
|
|
108
121
|
if (!/^\s*V\S*\s+libx264\s/m.test(encoders))
|
|
109
122
|
throw new Error('FFmpeg needs the libx264 encoder');
|
|
110
|
-
if (presentation === 'powerpoint') {
|
|
111
|
-
const devices = (await execute(path, ['-hide_banner', '-devices'], 10000)).toString();
|
|
112
|
-
if (!/\bgdigrab\b/.test(devices))
|
|
113
|
-
throw new Error('FFmpeg needs the gdigrab input');
|
|
114
|
-
}
|
|
115
123
|
return (await execute(path, ['-version'], 10000)).toString().split(/\r?\n/, 1)[0];
|
|
116
124
|
}, ffmpegInstructions),
|
|
117
125
|
checkTool('ffprobe', async (path) => {
|
|
@@ -120,36 +128,116 @@ export async function setup(options) {
|
|
|
120
128
|
throw new Error('Expected the ffprobe executable');
|
|
121
129
|
return version;
|
|
122
130
|
}, ffmpegInstructions),
|
|
123
|
-
];
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
131
|
+
]) : [{ name: 'platform', ready: false, detail: 'Use Linux, macOS, or Windows.' }];
|
|
132
|
+
const presentationReports = {};
|
|
133
|
+
const providerReports = {};
|
|
134
|
+
const readiness = (checks) => ({
|
|
135
|
+
status: checks.every(check => check.ready) ? 'ready' : 'missing_dependencies', checks,
|
|
136
|
+
});
|
|
137
|
+
await Promise.all(selectedPresentations.map(async (name) => {
|
|
138
|
+
if (!supported || name === 'powerpoint' && !windows) {
|
|
139
|
+
presentationReports[name] = { status: 'unavailable', checks: [{ name: 'platform', ready: false,
|
|
140
|
+
detail: name === 'powerpoint' ? 'Use Windows with installed desktop PowerPoint.' : 'Use Linux, macOS, or Windows.' }] };
|
|
141
|
+
}
|
|
142
|
+
else if (name === 'slidev') {
|
|
143
|
+
presentationReports[name] = readiness([await checkTool('browser', checkBrowser, browserInstructions)]);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const [native, capture] = await Promise.all([
|
|
147
|
+
powerpointChecks(),
|
|
148
|
+
checkTool('ffmpeg', async (path) => {
|
|
149
|
+
const devices = (await execute(path, ['-hide_banner', '-devices'], 10000)).toString();
|
|
150
|
+
if (!/\bgdigrab\b/.test(devices))
|
|
151
|
+
throw new Error('FFmpeg needs the gdigrab input');
|
|
152
|
+
return 'FFmpeg has the gdigrab input';
|
|
153
|
+
}, ffmpegInstructions),
|
|
154
|
+
]);
|
|
155
|
+
presentationReports[name] = readiness([{ ...capture, name: 'ffmpeg-gdigrab' }, ...native]);
|
|
156
|
+
}
|
|
157
|
+
}));
|
|
158
|
+
await Promise.all(selectedProviders.map(async (provider) => {
|
|
159
|
+
let prerequisites;
|
|
160
|
+
if (provider === 'edge-tts') {
|
|
161
|
+
prerequisites = [await checkTool('python', checkPython, edgeInstructions)];
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
prerequisites = [await checkElevenLabs()];
|
|
165
|
+
}
|
|
166
|
+
providerReports[provider] = { ...readiness(prerequisites), ...(deferred.has(provider) ? { deferred: true } : {}) };
|
|
167
|
+
}));
|
|
168
|
+
const skill = await inspectSkillStatus('user');
|
|
169
|
+
return { shared_checks: shared, presentations: presentationReports, providers: providerReports, skill };
|
|
144
170
|
};
|
|
145
|
-
let
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
171
|
+
let reports = await checks();
|
|
172
|
+
if (interactive) {
|
|
173
|
+
beforePrompts?.(reports);
|
|
174
|
+
let hidden = false;
|
|
175
|
+
const output = new Writable({ write(chunk, _encoding, done) {
|
|
176
|
+
if (!hidden)
|
|
177
|
+
process.stderr.write(chunk);
|
|
178
|
+
done();
|
|
179
|
+
} });
|
|
180
|
+
const reader = createInterface({ input: process.stdin, output, terminal: true, historySize: 0 });
|
|
181
|
+
const controller = new AbortController();
|
|
182
|
+
reader.once('close', () => controller.abort());
|
|
183
|
+
const ask = (prompt) => reader.question(prompt, { signal: controller.signal });
|
|
184
|
+
try {
|
|
185
|
+
for (const provider of selectedProviders) {
|
|
186
|
+
const report = reports.providers[provider];
|
|
187
|
+
if (!report || report.status === 'ready' && options.provider !== 'elevenlabs')
|
|
188
|
+
continue;
|
|
189
|
+
if (options.provider === undefined) {
|
|
190
|
+
const answer = await ask(`Set up ${provider} now? [Y/n, leave for later]: `);
|
|
191
|
+
if (/^n(?:o)?$/i.test(answer.trim())) {
|
|
192
|
+
deferred.add(provider);
|
|
193
|
+
report.deferred = true;
|
|
194
|
+
continue;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (provider === 'elevenlabs') {
|
|
198
|
+
process.stderr.write('ElevenLabs API key (hidden; Enter leaves it unchanged): ');
|
|
199
|
+
hidden = true;
|
|
200
|
+
let key;
|
|
201
|
+
try {
|
|
202
|
+
key = (await ask('')).trim();
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
hidden = false;
|
|
206
|
+
process.stderr.write('\n');
|
|
207
|
+
}
|
|
208
|
+
if (key) {
|
|
209
|
+
await saveElevenLabsKey(key);
|
|
210
|
+
const check = await withExecutables(options, checkElevenLabs);
|
|
211
|
+
reports.providers.elevenlabs = { status: check.ready ? 'ready' : 'missing_dependencies', checks: [check] };
|
|
212
|
+
console.error(`Saved ElevenLabs key to ${userConfigFile()}.`);
|
|
213
|
+
}
|
|
214
|
+
else if (report.status !== 'ready') {
|
|
215
|
+
deferred.add(provider);
|
|
216
|
+
report.deferred = true;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
if (controller.signal.aborted)
|
|
223
|
+
throw new ProductionError('INTERRUPTED', 'Provider setup interrupted.', 130);
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
226
|
+
finally {
|
|
227
|
+
reader.close();
|
|
228
|
+
}
|
|
229
|
+
if (hasLicenseTerminal() && !configuredLicense())
|
|
230
|
+
await setupLicense();
|
|
231
|
+
}
|
|
232
|
+
const dependencies = () => [...reports.shared_checks,
|
|
233
|
+
...Object.values(reports.presentations).flatMap(report => report.checks),
|
|
234
|
+
...Object.values(reports.providers).flatMap(report => report.checks)];
|
|
235
|
+
const missing = (...names) => dependencies().some(check => !check.ready && names.includes(check.name));
|
|
236
|
+
const ffmpeg = supported && missing('ffmpeg', 'ffprobe', 'ffmpeg-gdigrab') ? ffmpegInstaller() : undefined;
|
|
237
|
+
const installEdge = missing('python') && !reports.providers['edge-tts']?.deferred;
|
|
238
|
+
const canInstall = supported && (ffmpeg || missing('browser') || installEdge);
|
|
149
239
|
let runInstall = install;
|
|
150
240
|
if (interactive && !install && !manual && canInstall) {
|
|
151
|
-
for (const check of dependencies.filter(check => !check.ready))
|
|
152
|
-
console.error(check.detail);
|
|
153
241
|
const reader = createInterface({ input: process.stdin, output: process.stderr });
|
|
154
242
|
try {
|
|
155
243
|
runInstall = /^y(?:es)?$/i.test((await reader.question('Install the supported missing dependencies now? [y/N]: ')).trim());
|
|
@@ -169,9 +257,10 @@ export async function setup(options) {
|
|
|
169
257
|
};
|
|
170
258
|
if (ffmpeg)
|
|
171
259
|
await attempt('FFmpeg', async () => {
|
|
172
|
-
await runInstaller(ffmpeg.command, ffmpeg.args);
|
|
260
|
+
await runInstaller(ffmpeg.command, ffmpeg.args, ffmpeg.env);
|
|
173
261
|
for (const tool of ['ffmpeg', 'ffprobe']) {
|
|
174
|
-
|
|
262
|
+
const needsTool = missing(tool) || tool === 'ffmpeg' && missing('ffmpeg-gdigrab');
|
|
263
|
+
if (!needsTool)
|
|
175
264
|
continue;
|
|
176
265
|
const path = discoverExecutable(tool);
|
|
177
266
|
if (path)
|
|
@@ -180,13 +269,25 @@ export async function setup(options) {
|
|
|
180
269
|
});
|
|
181
270
|
if (missing('browser'))
|
|
182
271
|
await attempt('Chromium', async () => { installed.browser = await installChromium(); });
|
|
183
|
-
if (
|
|
272
|
+
if (installEdge)
|
|
184
273
|
await attempt('Edge TTS', async () => { installed.python = await installEdgeEnvironment(); });
|
|
185
|
-
|
|
274
|
+
reports = await withExecutables({ ...options, ...installed }, checks);
|
|
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
|
+
}
|
|
186
287
|
}
|
|
187
288
|
const paths = {};
|
|
188
289
|
for (const tool of ['browser', 'python', 'ffmpeg', 'ffprobe']) {
|
|
189
|
-
if (!dependencies.some(check => check.name === tool && check.ready))
|
|
290
|
+
if (!dependencies().some(check => check.name === tool && check.ready))
|
|
190
291
|
continue;
|
|
191
292
|
const path = installed[tool] ?? (options[tool] !== undefined ? toolCandidate(tool)?.path : undefined);
|
|
192
293
|
if (path)
|
|
@@ -194,23 +295,29 @@ export async function setup(options) {
|
|
|
194
295
|
}
|
|
195
296
|
if (Object.keys(paths).length)
|
|
196
297
|
await saveExecutablePaths(paths);
|
|
197
|
-
const browsers =
|
|
298
|
+
const browsers = selectedPresentations.includes('slidev') ? browserCandidates() : [];
|
|
198
299
|
const selected = installed.browser ?? toolCandidate('browser')?.path;
|
|
199
|
-
if (
|
|
300
|
+
if (selectedPresentations.includes('slidev') && selected && isExecutable(selected) && !browsers.some(item => item.path === selected)) {
|
|
200
301
|
browsers.push({ path: selected, name: browserName(selected) });
|
|
201
302
|
}
|
|
202
|
-
const browserRequirement =
|
|
303
|
+
const browserRequirement = selectedPresentations.includes('slidev')
|
|
203
304
|
? 'Slidev recording needs Chromium. The packaged release check uses Chromium on Linux. Google Chrome and Microsoft Edge are detected but their capture workflows are unverified.'
|
|
204
305
|
: undefined;
|
|
205
306
|
return {
|
|
206
307
|
version: 1,
|
|
207
308
|
command: 'setup',
|
|
208
|
-
status:
|
|
209
|
-
|
|
210
|
-
|
|
309
|
+
status: reports.shared_checks.every(check => check.ready)
|
|
310
|
+
&& Object.values(reports.presentations).some(report => report.status === 'ready')
|
|
311
|
+
&& Object.values(reports.providers).some(report => report.status === 'ready') ? 'ready' : 'missing_dependencies',
|
|
312
|
+
presentation: options.presentation,
|
|
313
|
+
voice: options.provider ? { provider: options.provider, voice: options['voice-id']?.trim() || (options.provider === 'edge-tts' ? 'en-US-AriaNeural' : 'your-voice-id') } : undefined,
|
|
314
|
+
shared_checks: reports.shared_checks,
|
|
315
|
+
presentations: reports.presentations,
|
|
316
|
+
providers: reports.providers,
|
|
317
|
+
skill: reports.skill,
|
|
211
318
|
config_file: userConfigFile(),
|
|
212
319
|
saved_paths: paths,
|
|
213
|
-
checks: dependencies,
|
|
320
|
+
checks: dependencies(),
|
|
214
321
|
browsers,
|
|
215
322
|
browser_requirement: browserRequirement,
|
|
216
323
|
installation_errors: installationErrors,
|
|
@@ -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>;
|